diff options
author | kaelima <kaelima@live.se> | 2011-10-25 23:50:00 +0100 |
---|---|---|
committer | kaelima <kaelima@live.se> | 2011-10-25 23:50:00 +0100 |
commit | f958fdf246b16b11103d0b8ce6a9d17909da42a9 (patch) | |
tree | d9994bdcf06277c406d3308e89302d9eb103ef30 /src | |
parent | 6ca1487c48a1e6362075cc7ce3cdfcc6049cd0b4 (diff) |
Core/SmartAI: Add actions SMART_ACTION_LEAVE_VEHICLE and SMART_ACTION_REMOVE_PASSENGERS.
Fix maxdist for SMART_TARGET_CLOSEST_PLAYER.
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.cpp | 53 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScriptMgr.cpp | 2 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScriptMgr.h | 4 |
3 files changed, 55 insertions, 4 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index be73ba15c86..6c2b8fe9f8b 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -1470,9 +1470,56 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u for (ObjectList::iterator itr = targets->begin(); itr != targets->end(); ++itr) { - if (IsUnit(*itr) && (*itr)->ToUnit()->GetVehicleKit()) + if (Unit* target = (*itr)->ToUnit()) { - me->EnterVehicle((*itr)->ToUnit(), e.action.enterVehicle.seat); + if (target->GetVehicleKit()) + { + me->EnterVehicle(target, e.action.enterVehicle.seat); + delete targets; + return; + } + } + } + + delete targets; + break; + } + case SMART_ACTION_LEAVE_VEHICLE: + { + ObjectList* targets = GetTargets(e, unit); + if (!targets) + return; + + for (ObjectList::iterator itr = targets->begin(); itr != targets->end(); ++itr) + { + if (Unit* target = (*itr)->ToUnit()) + { + if (!target->GetVehicle()) + continue; + + target->ExitVehicle(); + delete targets; + return; + } + } + + delete targets; + break; + } + case SMART_ACTION_REMOVE_PASSENGERS: + { + ObjectList* targets = GetTargets(e, unit); + if (!targets) + return; + + for (ObjectList::iterator itr = targets->begin(); itr != targets->end(); ++itr) + { + if (!IsUnit(*itr)) + continue; + + if (Vehicle* veh = (*itr)->ToUnit()->GetVehicle()) + { + veh->RemoveAllPassengers(); delete targets; return; } @@ -2155,7 +2202,7 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /* { if (me) { - Player* target = me->SelectNearestPlayer((float)(e.target.closest.dist ? e.target.closest.dist : 100)); + Player* target = me->SelectNearestPlayer((float)e.target.playerDistance.dist); if (target) l->push_back(target); } diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index e39910bae5d..3fba9fa7c4a 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -758,6 +758,8 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) case SMART_ACTION_ACTIVATE_GOBJECT: case SMART_ACTION_CALL_SCRIPT_RESET: case SMART_ACTION_ENTER_VEHICLE: + case SMART_ACTION_LEAVE_VEHICLE: + case SMART_ACTION_REMOVE_PASSENGERS: case SMART_ACTION_NONE: case SMART_ACTION_CALL_TIMED_ACTIONLIST: case SMART_ACTION_SET_NPC_FLAG: diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index 15589cb39a2..7b7e2b6311a 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -459,8 +459,10 @@ enum SMART_ACTION SMART_ACTION_REMOVE_DYNAMIC_FLAG = 96, // Flags SMART_ACTION_JUMP_TO_POS = 97, // speedXY, speedZ, targetX, targetY, targetZ SMART_ACTION_SEND_GOSSIP_MENU = 98, // menuId, optionId + SMART_ACTION_LEAVE_VEHICLE = 99, + SMART_ACTION_REMOVE_PASSENGERS = 100, - SMART_ACTION_END = 99, + SMART_ACTION_END = 101, }; struct SmartAction |