aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRat <none@none>2010-11-07 22:10:11 +0100
committerRat <none@none>2010-11-07 22:10:11 +0100
commit2ee0fda94e54515cfbf6dc5c1839015dbabf01e6 (patch)
treefd352bfea724d56806c3e66769144c2928ea4e6d /src
parentd180e485e9e3523a221e66bf06b34f7dec7e7129 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp71
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.h2
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.cpp2
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.h14
4 files changed, 68 insertions, 21 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index 10bed1a0709..c847bda9127 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -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));
+ }
} \ No newline at end of file
diff --git a/src/server/game/AI/SmartScripts/SmartScript.h b/src/server/game/AI/SmartScripts/SmartScript.h
index 345ab58c8d8..0384afc4a44 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.h
+++ b/src/server/game/AI/SmartScripts/SmartScript.h
@@ -250,6 +250,8 @@ class SmartScript
SmartScriptHolder s;
return s;
}
+ //TIMED_ACTIONLIST (script type 9 aka script9)
+ void SetScript9(SmartScriptHolder &e, uint32 entry);
};
#endif
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
index 037ca5ceeac..42e30cb2009 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
@@ -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);
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
index 0af6e4997d3..ba360171acb 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
@@ -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
@@ -789,6 +791,16 @@ struct SmartAction
struct
{
+ uint32 entry1;
+ uint32 entry2;
+ uint32 entry3;
+ uint32 entry4;
+ uint32 entry5;
+ uint32 entry6;
+ } randTimedActionList;
+
+ struct
+ {
uint32 param1;
uint32 param2;
uint32 param3;