mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04: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
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue