mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
Implement delay ranges https://github.com/ElunaLuaEngine/Eluna/issues/205
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user