Core/SmartAI: all actions regarding to TIMED_ACTIONLIST will now use targeting:

you can now 'send' a list of timed actions to any targeted creature if it has SmartAI

NOTE: already made script with timed actions should be remade to use self as target

--HG--
branch : trunk
This commit is contained in:
Rat
2010-12-07 18:31:34 +01:00
parent 703835ee94
commit bb09a4a50f
4 changed files with 47 additions and 5 deletions

View File

@@ -789,6 +789,11 @@ void SmartAI::SetFollow(Unit* target, float dist, float angle, uint32 credit, ui
me->GetMotionMaster()->MoveFollow(target, dist, angle);
mFollowCreditType = creditType;
}
void SmartAI::SetScript9(SmartScriptHolder &e, uint32 entry)
{
GetScript()->SetScript9(e, entry);
}
/*
SMART_EVENT_UPDATE_OOC
SMART_EVENT_SPELLHIT

View File

@@ -65,6 +65,7 @@ class SmartAI : public CreatureAI
void SetCombatMove(bool on);
void SetFollow(Unit* target, float dist = 0.0f, float angle = 0.0f, uint32 credit = 0, uint32 end = 0, uint32 creditType = 0);
void SetScript9(SmartScriptHolder &e, uint32 entry);
SmartScript* GetScript() { return &mScript; }
bool IsEscortInvokerInRange();

View File

@@ -1063,7 +1063,18 @@ void SmartScript::ProcessAction(SmartScriptHolder &e, Unit* unit, uint32 var0, u
}
case SMART_ACTION_CALL_TIMED_ACTIONLIST:
{
SetScript9(e, e.action.timedActionList.id);
ObjectList* targets = GetTargets(e, unit);
if (targets)
{
for (ObjectList::iterator itr = targets->begin(); itr != targets->end(); itr++)
{
if (Creature* target = (*itr)->ToCreature())
{
if (IsSmart(target))
CAST_AI(SmartAI, target->AI())->SetScript9(e, e.action.timedActionList.id);
}
}
}
break;
}
case SMART_ACTION_SET_NPC_FLAG:
@@ -1135,12 +1146,36 @@ void SmartScript::ProcessAction(SmartScriptHolder &e, Unit* unit, uint32 var0, u
count++;
}
}
SetScript9(e, temp[urand(0, count)]);
uint32 id = temp[urand(0, count)];
ObjectList* targets = GetTargets(e, unit);
if (targets)
{
for (ObjectList::iterator itr = targets->begin(); itr != targets->end(); itr++)
{
if (Creature* target = (*itr)->ToCreature())
{
if (IsSmart(target))
CAST_AI(SmartAI, target->AI())->SetScript9(e, id);
}
}
}
break;
}
case SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST:
{
SetScript9(e, urand(e.action.randTimedActionList.entry1, e.action.randTimedActionList.entry2));
uint32 id = urand(e.action.randTimedActionList.entry1, e.action.randTimedActionList.entry2);
ObjectList* targets = GetTargets(e, unit);
if (targets)
{
for (ObjectList::iterator itr = targets->begin(); itr != targets->end(); itr++)
{
if (Creature* target = (*itr)->ToCreature())
{
if (IsSmart(target))
CAST_AI(SmartAI, target->AI())->SetScript9(e, id);
}
}
}
break;
}
case SMART_ACTION_ACTIVATE_TAXI:

View File

@@ -180,6 +180,9 @@ class SmartScript
meOrigGUID = 0;
}
//TIMED_ACTIONLIST (script type 9 aka script9)
void SetScript9(SmartScriptHolder &e, uint32 entry);
private:
void IncPhase(int32 p = 1) {
if(p >= 0)
@@ -250,8 +253,6 @@ class SmartScript
SmartScriptHolder s;
return s;
}
//TIMED_ACTIONLIST (script type 9 aka script9)
void SetScript9(SmartScriptHolder &e, uint32 entry);
};
#endif