mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 18:15:31 +01:00
Core/SmartAI:
- Drop useless actions SMART_ACTION_ENTER_VEHICLE, SMART_ACTION_LEAVE_VEHICLE and SMART_ACTION_REMOVE_PASSENGERS. (Vehicles are aura-driven, just remove or add the proper aura to achieve the same as these actions did) - Fixed possible crash in SMART_ACTION_SEND_GOSSIP_MENU - Areatriggers should not be triggered by dead players
This commit is contained in:
@@ -917,13 +917,13 @@ class SmartTrigger : public AreaTriggerScript
|
||||
{
|
||||
public:
|
||||
|
||||
SmartTrigger()
|
||||
: AreaTriggerScript("SmartTrigger")
|
||||
{
|
||||
}
|
||||
SmartTrigger() : AreaTriggerScript("SmartTrigger") {}
|
||||
|
||||
bool OnTrigger(Player* player, AreaTriggerEntry const* trigger)
|
||||
{
|
||||
if (!player->isAlive())
|
||||
return false;
|
||||
|
||||
sLog->outDebug(LOG_FILTER_DATABASE_AI, "AreaTrigger %u is using SmartTrigger script", trigger->id);
|
||||
SmartScript script;
|
||||
script.OnInitialize(NULL, trigger);
|
||||
|
||||
@@ -1472,75 +1472,6 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
case SMART_ACTION_CALL_SCRIPT_RESET:
|
||||
OnReset();
|
||||
break;
|
||||
case SMART_ACTION_ENTER_VEHICLE:
|
||||
{
|
||||
if (!me)
|
||||
return;
|
||||
|
||||
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->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;
|
||||
}
|
||||
}
|
||||
|
||||
delete targets;
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_CALL_TIMED_ACTIONLIST:
|
||||
{
|
||||
if (e.GetTargetType() == SMART_TARGET_NONE)
|
||||
@@ -1852,6 +1783,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
}
|
||||
case SMART_ACTION_SEND_GOSSIP_MENU:
|
||||
{
|
||||
if (!GetBaseObject())
|
||||
return;
|
||||
|
||||
sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_SEND_GOSSIP_MENU: gossipMenuId %d, gossip_option_id %d",
|
||||
e.action.sendGossipMenu.gossipMenuId, e.action.sendGossipMenu.gossipOptionId);
|
||||
|
||||
|
||||
@@ -767,9 +767,6 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
|
||||
case SMART_ACTION_RESET_SCRIPT_BASE_OBJECT:
|
||||
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:
|
||||
|
||||
@@ -439,7 +439,7 @@ enum SMART_ACTION
|
||||
SMART_ACTION_OVERRIDE_SCRIPT_BASE_OBJECT = 76, // WARNING: CAN CRASH CORE, do not use if you dont know what you are doing
|
||||
SMART_ACTION_RESET_SCRIPT_BASE_OBJECT = 77, // none
|
||||
SMART_ACTION_CALL_SCRIPT_RESET = 78, // none
|
||||
SMART_ACTION_ENTER_VEHICLE = 79, // seatID
|
||||
// Unused = 79,
|
||||
SMART_ACTION_CALL_TIMED_ACTIONLIST = 80, // ID (overwrites already running actionlist), stop after combat?(0/1), timer update type(0-OOC, 1-IC, 2-ALWAYS)
|
||||
SMART_ACTION_SET_NPC_FLAG = 81, // Flags
|
||||
SMART_ACTION_ADD_NPC_FLAG = 82, // Flags
|
||||
@@ -459,10 +459,8 @@ 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 = 101,
|
||||
SMART_ACTION_END = 99,
|
||||
};
|
||||
|
||||
struct SmartAction
|
||||
@@ -1129,7 +1127,7 @@ const uint32 SmartAIEventMask[SMART_EVENT_END][2] =
|
||||
{SMART_EVENT_JUST_CREATED, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
|
||||
{SMART_EVENT_GOSSIP_HELLO, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
|
||||
{SMART_EVENT_FOLLOW_COMPLETED, SMART_SCRIPT_TYPE_MASK_CREATURE },
|
||||
{SMART_EVENT_DUMMY_EFFECT, SMART_SCRIPT_TYPE_MASK_CREATURE },
|
||||
{SMART_EVENT_DUMMY_EFFECT, SMART_SCRIPT_TYPE_MASK_SPELL },
|
||||
{SMART_EVENT_IS_BEHIND_TARGET, SMART_SCRIPT_TYPE_MASK_CREATURE }
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user