mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 01:37:00 +00:00
[10372] Implement EFLAG_RANDOM_ACTION
It allow execute one random action from EventAI event actions instead each action from event actions.
This commit is contained in:
parent
dbe9c6f190
commit
a17450047b
4 changed files with 40 additions and 13 deletions
|
|
@ -832,7 +832,8 @@ Below is the list of current Event Flags that EventAI can handle. Event flags ar
|
|||
4 16 EFLAG_DIFFICULTY_3 Event occurs in instance difficulty 3 (will not occur if not set)
|
||||
5 32
|
||||
6 64
|
||||
7 128 EFLAG_DEBUG_ONLY Prevents events from occuring on Release builds. Useful for testing new features.
|
||||
7 128 EFLAG_DEBUG_ONLY Prevents events from occuring on Release builds. Useful for testing new features.
|
||||
8 256 EFLAG_RANDOM_ACTION At event occur execute one random action from event actions instead all actions.
|
||||
|
||||
NOTE: You can add the numbers in the decimal column to combine flags.
|
||||
|
||||
|
|
|
|||
|
|
@ -350,10 +350,35 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction
|
|||
if (pHolder.Event.event_chance <= rnd % 100)
|
||||
return false;
|
||||
|
||||
//Process actions
|
||||
for (uint32 j = 0; j < MAX_ACTIONS; j++)
|
||||
ProcessAction(pHolder.Event.action[j], rnd, pHolder.Event.event_id, pActionInvoker);
|
||||
//Process actions, normal case
|
||||
if (!(pHolder.Event.event_flags & EFLAG_RANDOM_ACTION))
|
||||
{
|
||||
for (uint32 j = 0; j < MAX_ACTIONS; ++j)
|
||||
ProcessAction(pHolder.Event.action[j], rnd, pHolder.Event.event_id, pActionInvoker);
|
||||
}
|
||||
//Process actions, random case
|
||||
else
|
||||
{
|
||||
// amount of real actions
|
||||
uint32 count = 0;
|
||||
for (uint32 j = 0; j < MAX_ACTIONS; j++)
|
||||
if (pHolder.Event.action[j].type != ACTION_T_NONE)
|
||||
++count;
|
||||
|
||||
if (count)
|
||||
{
|
||||
// select action number from found amount
|
||||
uint32 idx = urand(0,count-1);
|
||||
|
||||
// find selected action, skipping not used
|
||||
uint32 j = 0;
|
||||
for (; idx; ++j)
|
||||
if (pHolder.Event.action[j].type != ACTION_T_NONE)
|
||||
--idx;
|
||||
|
||||
ProcessAction(pHolder.Event.action[j], rnd, pHolder.Event.event_id, pActionInvoker);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -142,14 +142,15 @@ enum Target
|
|||
|
||||
enum EventFlags
|
||||
{
|
||||
EFLAG_REPEATABLE = 0x01, //Event repeats
|
||||
EFLAG_DIFFICULTY_0 = 0x02, //Event only occurs in instance difficulty 0
|
||||
EFLAG_DIFFICULTY_1 = 0x04, //Event only occurs in instance difficulty 1
|
||||
EFLAG_DIFFICULTY_2 = 0x08, //Event only occurs in instance difficulty 2
|
||||
EFLAG_DIFFICULTY_3 = 0x10, //Event only occurs in instance difficulty 3
|
||||
EFLAG_RESERVED_5 = 0x20,
|
||||
EFLAG_RESERVED_6 = 0x40,
|
||||
EFLAG_DEBUG_ONLY = 0x80, //Event only occurs in debug build
|
||||
EFLAG_REPEATABLE = 0x0001, //Event repeats
|
||||
EFLAG_DIFFICULTY_0 = 0x0002, //Event only occurs in instance difficulty 0
|
||||
EFLAG_DIFFICULTY_1 = 0x0004, //Event only occurs in instance difficulty 1
|
||||
EFLAG_DIFFICULTY_2 = 0x0008, //Event only occurs in instance difficulty 2
|
||||
EFLAG_DIFFICULTY_3 = 0x0010, //Event only occurs in instance difficulty 3
|
||||
EFLAG_RESERVED_5 = 0x0020,
|
||||
EFLAG_RESERVED_6 = 0x0040,
|
||||
EFLAG_DEBUG_ONLY = 0x0080, //Event only occurs in debug build
|
||||
EFLAG_RANDOM_ACTION = 0x0100, //Event only execute one from existed actions instead each action.
|
||||
|
||||
EFLAG_DIFFICULTY_ALL = (EFLAG_DIFFICULTY_0|EFLAG_DIFFICULTY_1|EFLAG_DIFFICULTY_2|EFLAG_DIFFICULTY_3)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "10371"
|
||||
#define REVISION_NR "10372"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue