> For the complete documentation index, see [llms.txt](https://heroicsolo.gitbook.io/heroic-engine/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://heroicsolo.gitbook.io/heroic-engine/basics/publish-your-docs/gameplay-systems/random-events-manager.md).

# Random Events Manager

Presented by IRandomEventsManager interface, this system works with random events and provides such mechanisms like Bad Luck Protection and Good Luck Protection for them.

To use this system, inject IRandomEventsManager interface into your class, as shown below:

```csharp
[Inject] private IRandomEventsManager randomEventsManager;
```

### Parameters in inspector

**possibleEvents** – reference to scriptable object which contains a collection of possible random events.

### Available methods

```csharp
bool DoEventAttempt(string eventType)
```

*This method attempts to fire random event with certain **eventType**. Returns **true** if attempt was successful and event has occurred.*

*Example:*

```csharp
if (randomEventsManager.DoEventAttempt("SuperRareItemDrop"))
{
    Debug.Log("Super rare item dropped!");
}
```

***

```csharp
bool DoEventAttempt(RandomEventInfo eventInfo)
```

*This method attempts to fire random event described in* **eventInfo***. Returns **true** if attempt was successful and event has occurred.*

*Example:*

```csharp
if (randomEventsManager.DoEventAttempt(superRareEventInfo))
{
    Debug.Log("Super rare item dropped!");
}
```

***

```csharp
void ResetEventChance(string eventType)
```

*This method resets random event chance (cancels all modifiers applied by Bad Luck Protection and Good Luck Protection logics).*

*Example:*

```csharp
public void StartNewGame()
{
    randomEventsManager.ResetEventChance("SuperRareItemDrop");
}
```

***

```csharp
float GetEventChance(string eventType)
```

*This method returns current chance of **eventType** event occurance.*

*Example:*

```csharp
float eventChance = randomEventsManager.GetEventChance("SuperRareItemDrop");

Debug.Log($"Super rare drop chance: {eventChance}");
```
