mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-14 20:22:23 -04:00
Core/SmartScripts
This commit is contained in:
@@ -897,13 +897,19 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
}
|
||||
case SMART_ACTION_CALL_KILLEDMONSTER:
|
||||
{
|
||||
Player* player = NULL;
|
||||
if (me)
|
||||
player = me->GetLootRecipient();
|
||||
if (e.target.type == SMART_TARGET_NONE) // Loot recipient and his group members
|
||||
{
|
||||
if (!me)
|
||||
break;
|
||||
|
||||
if (me && player)
|
||||
player->RewardPlayerAndGroupAtEvent(e.action.killedMonster.creature, player);
|
||||
else if (GetBaseObject())
|
||||
if (Player* player = me->GetLootRecipient())
|
||||
{
|
||||
player->RewardPlayerAndGroupAtEvent(e.action.killedMonster.creature, player);
|
||||
TC_LOG_DEBUG(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: Player %u, Killcredit: %u",
|
||||
player->GetGUIDLow(), e.action.killedMonster.creature);
|
||||
}
|
||||
}
|
||||
else // Specific target type
|
||||
{
|
||||
ObjectList* targets = GetTargets(e, unit);
|
||||
if (!targets)
|
||||
@@ -911,29 +917,21 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
// Special handling for vehicles
|
||||
if (IsUnit(*itr))
|
||||
if (IsPlayer(*itr))
|
||||
{
|
||||
(*itr)->ToPlayer()->KilledMonsterCredit(e.action.killedMonster.creature);
|
||||
TC_LOG_DEBUG(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: Player %u, Killcredit: %u",
|
||||
(*itr)->GetGUIDLow(), e.action.killedMonster.creature);
|
||||
}
|
||||
else if (IsUnit(*itr)) // Special handling for vehicles
|
||||
if (Vehicle* vehicle = (*itr)->ToUnit()->GetVehicleKit())
|
||||
for (SeatMap::iterator it = vehicle->Seats.begin(); it != vehicle->Seats.end(); ++it)
|
||||
if (Player* player = ObjectAccessor::FindPlayer(it->second.Passenger.Guid))
|
||||
player->RewardPlayerAndGroupAtEvent(e.action.killedMonster.creature, player);
|
||||
|
||||
if (!IsPlayer(*itr))
|
||||
continue;
|
||||
|
||||
(*itr)->ToPlayer()->RewardPlayerAndGroupAtEvent(e.action.killedMonster.creature, (*itr)->ToPlayer());
|
||||
TC_LOG_DEBUG(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: Player %u, Killcredit: %u",
|
||||
(*itr)->GetGUIDLow(), e.action.killedMonster.creature);
|
||||
for (SeatMap::iterator itr = vehicle->Seats.begin(); itr != vehicle->Seats.end(); ++itr)
|
||||
if (Player* player = ObjectAccessor::FindPlayer(itr->second.Passenger.Guid))
|
||||
player->KilledMonsterCredit(e.action.killedMonster.creature);
|
||||
}
|
||||
|
||||
delete targets;
|
||||
}
|
||||
else if (trigger && IsPlayer(unit))
|
||||
{
|
||||
unit->ToPlayer()->RewardPlayerAndGroupAtEvent(e.action.killedMonster.creature, unit);
|
||||
TC_LOG_DEBUG(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction: SMART_ACTION_CALL_KILLEDMONSTER: (trigger == true) Player %u, Killcredit: %u",
|
||||
unit->GetGUIDLow(), e.action.killedMonster.creature);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SMART_ACTION_SET_INST_DATA:
|
||||
@@ -1300,10 +1298,10 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
|
||||
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
|
||||
{
|
||||
if (!IsPlayer(*itr))
|
||||
continue;
|
||||
|
||||
(*itr)->ToPlayer()->TeleportTo(e.action.teleport.mapID, e.target.x, e.target.y, e.target.z, e.target.o);
|
||||
if (IsPlayer(*itr))
|
||||
(*itr)->ToPlayer()->TeleportTo(e.action.teleport.mapID, e.target.x, e.target.y, e.target.z, e.target.o);
|
||||
else if (IsCreature(*itr))
|
||||
(*itr)->ToCreature()->NearTeleportTo(e.target.x, e.target.y, e.target.z, e.target.o);
|
||||
}
|
||||
|
||||
delete targets;
|
||||
|
||||
Reference in New Issue
Block a user