Core/SmartAI:

added ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST
added ACTION_CALL_RANDOM_TIMED_ACTIONLIST
you can now call in random timed action lists (script type 9 aka Script9)

--HG--
branch : trunk
This commit is contained in:
Rat
2010-11-07 22:10:11 +01:00
parent d180e485e9
commit 2ee0fda94e
4 changed files with 68 additions and 21 deletions

View File

@@ -1064,26 +1064,7 @@ void SmartScript::ProcessAction(SmartScriptHolder &e, Unit* unit, uint32 var0, u
}
case SMART_ACTION_CALL_TIMED_ACTIONLIST:
{
mTimedActionList.clear();
mTimedActionList = sSmartScriptMgr.GetScript(e.action.timedActionList.id, SMART_SCRIPT_TYPE_TIMED_ACTIONLIST);
if (mTimedActionList.empty())
return;
for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
{
if (i == mTimedActionList.begin())
{
i->enableTimed = true;//enable processing only for the first action
}
else i->enableTimed = false;
//i->event.type = SMART_EVENT_UPDATE_IC;//default value
if (e.action.timedActionList.timerType == 1)
i->event.type = SMART_EVENT_UPDATE_IC;
else if (e.action.timedActionList.timerType > 1)
i->event.type = SMART_EVENT_UPDATE;
mResumeActionList = e.action.timedActionList.dontResume ? false : true;
InitTimer((*i));
}
SetScript9(e, e.action.timedActionList.id);
break;
}
case SMART_ACTION_SET_NPC_FLAG:
@@ -1136,6 +1117,33 @@ void SmartScript::ProcessAction(SmartScriptHolder &e, Unit* unit, uint32 var0, u
}
break;
}
case SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST:
{
uint32 actions[SMART_ACTION_PARAM_COUNT];
actions[0] = e.action.randTimedActionList.entry1;
actions[1] = e.action.randTimedActionList.entry2;
actions[2] = e.action.randTimedActionList.entry3;
actions[3] = e.action.randTimedActionList.entry4;
actions[4] = e.action.randTimedActionList.entry5;
actions[5] = e.action.randTimedActionList.entry6;
uint32 temp[SMART_ACTION_PARAM_COUNT];
uint32 count = 0;
for (uint8 i = 0; i < SMART_ACTION_PARAM_COUNT; i++)
{
if (actions[i] > 0)
{
temp[count] = actions[i];
count++;
}
}
SetScript9(e, temp[urand(0, count)]);
break;
}
case SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST:
{
SetScript9(e, urand(e.action.randTimedActionList.entry1, e.action.randTimedActionList.entry2));
break;
}
default:
sLog.outErrorDb("SmartScript::ProcessAction: Unhandled Action type %u", e.GetActionType());
break;
@@ -2216,4 +2224,27 @@ void SmartScript::DoFindFriendlyMissingBuff(std::list<Creature*>& _list, float r
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::FriendlyMissingBuffInRange>, GridTypeMapContainer > grid_creature_searcher(searcher);
cell.Visit(p, grid_creature_searcher, *me->GetMap());
}
void SmartScript::SetScript9(SmartScriptHolder &e, uint32 entry)
{
mTimedActionList.clear();
mTimedActionList = sSmartScriptMgr.GetScript(entry, SMART_SCRIPT_TYPE_TIMED_ACTIONLIST);
if (mTimedActionList.empty())
return;
for (SmartAIEventList::iterator i = mTimedActionList.begin(); i != mTimedActionList.end(); ++i)
{
if (i == mTimedActionList.begin())
{
i->enableTimed = true;//enable processing only for the first action
}
else i->enableTimed = false;
if (e.action.timedActionList.timerType == 1)
i->event.type = SMART_EVENT_UPDATE_IC;
else if (e.action.timedActionList.timerType > 1)
i->event.type = SMART_EVENT_UPDATE;
mResumeActionList = e.action.timedActionList.dontResume ? false : true;
InitTimer((*i));
}
}

View File

@@ -250,6 +250,8 @@ class SmartScript
SmartScriptHolder s;
return s;
}
//TIMED_ACTIONLIST (script type 9 aka script9)
void SetScript9(SmartScriptHolder &e, uint32 entry);
};
#endif

View File

@@ -754,6 +754,8 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder &e)
case SMART_ACTION_TALK:
case SMART_ACTION_SIMPLE_TALK:
case SMART_ACTION_CROSS_CAST:
case SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST:
case SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST:
break;
default:
sLog.outErrorDb("SmartAIMgr: Not handled action_type(%u), Entry %d SourceType %u Event %u, skipped.", e.GetActionType(), e.GetEventType(), e.entryOrGuid, e.GetScriptType(), e.event_id);

View File

@@ -433,8 +433,10 @@ enum SMART_ACTION
SMART_ACTION_SIMPLE_TALK = 84, // groupID, can be used to make players say groupID, Text_over event is not triggered, whisper can not be used (Target units will say the text)
SMART_ACTION_INVOKER_CAST = 85, // spellID, castFlags, if avaliable, last used invoker will cast spellId with castFlags on targets
SMART_ACTION_CROSS_CAST = 86, // spellID, castFlags, CasterTargetType, CasterTarget param1, CasterTarget param2, CasterTarget param3, ( + the origonal target fields as Destination target), CasterTargets will cast spellID on all Targets (use with caution if targeting multiple * multiple units)
SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST = 87, // script9 ids 1-9
SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST = 88, // script9 id min, max
SMART_ACTION_END = 87,
SMART_ACTION_END = 89,
};
struct SmartAction
@@ -787,6 +789,16 @@ struct SmartAction
uint32 timerType;
} timedActionList;
struct
{
uint32 entry1;
uint32 entry2;
uint32 entry3;
uint32 entry4;
uint32 entry5;
uint32 entry6;
} randTimedActionList;
struct
{
uint32 param1;