This commit is contained in:
Rochet2
2017-07-25 21:20:59 +03:00
parent 897bf79854
commit 5638cc53f8
5 changed files with 73 additions and 20 deletions

View File

@@ -9,6 +9,7 @@
#include "ElunaUtility.h"
#include "Common.h"
#include "Random.h"
#include <map>
#ifdef TRINITY
@@ -31,8 +32,8 @@ enum LuaEventState
struct LuaEvent
{
LuaEvent(int _funcRef, uint32 _delay, uint32 _repeats) :
delay(_delay), repeats(_repeats), funcRef(_funcRef), state(LUAEVENT_STATE_RUN)
LuaEvent(int _funcRef, uint32 _min, uint32 _max, uint32 _repeats) :
min(_min), max(_max), delay(0), repeats(_repeats), funcRef(_funcRef), state(LUAEVENT_STATE_RUN)
{
}
@@ -42,7 +43,14 @@ struct LuaEvent
state = _state;
}
uint32 delay; // Delay between event calls
void GenerateDelay()
{
delay = urand(min, max);
}
uint32 min; // Minimum delay between event calls
uint32 max; // Maximum delay between event calls
uint32 delay; // The currently used waiting time
uint32 repeats; // Amount of repeats to make, 0 for infinite
int funcRef; // Lua function reference ID, also used as event ID
LuaEventState state; // State for next call
@@ -64,7 +72,7 @@ public:
void SetStates(LuaEventState state);
// set the event to be removed when executing
void SetState(int eventId, LuaEventState state);
void AddEvent(int funcRef, uint32 delay, uint32 repeats);
void AddEvent(int funcRef, uint32 min, uint32 max, uint32 repeats);
EventMap eventMap;
private: