Core/SmartAI: Add actions SMART_ACTION_LEAVE_VEHICLE and SMART_ACTION_REMOVE_PASSENGERS.

Fix maxdist for SMART_TARGET_CLOSEST_PLAYER.
This commit is contained in:
kaelima
2011-10-25 23:50:00 +01:00
parent 6ca1487c48
commit f958fdf246
3 changed files with 55 additions and 4 deletions
@@ -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);
}
@@ -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:
@@ -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