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;
|
||||
|
||||
@@ -761,6 +761,11 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
|
||||
case SMART_ACTION_CALL_KILLEDMONSTER:
|
||||
if (!IsCreatureValid(e, e.action.killedMonster.creature))
|
||||
return false;
|
||||
if (e.GetTargetType() == SMART_TARGET_POSITION)
|
||||
{
|
||||
TC_LOG_ERROR(LOG_FILTER_SQL, "SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses incorrect TargetType %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.GetTargetType());
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case SMART_ACTION_UPDATE_TEMPLATE:
|
||||
if (e.action.updateTemplate.creature && !IsCreatureValid(e, e.action.updateTemplate.creature))
|
||||
|
||||
@@ -16173,7 +16173,7 @@ void Player::KilledMonster(CreatureTemplate const* cInfo, uint64 guid)
|
||||
KilledMonsterCredit(cInfo->KillCredit[i], 0);
|
||||
}
|
||||
|
||||
void Player::KilledMonsterCredit(uint32 entry, uint64 guid)
|
||||
void Player::KilledMonsterCredit(uint32 entry, uint64 guid /*= 0*/)
|
||||
{
|
||||
uint16 addkillcount = 1;
|
||||
uint32 real_entry = entry;
|
||||
|
||||
@@ -1413,7 +1413,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
void ItemAddedQuestCheck(uint32 entry, uint32 count);
|
||||
void ItemRemovedQuestCheck(uint32 entry, uint32 count);
|
||||
void KilledMonster(CreatureTemplate const* cInfo, uint64 guid);
|
||||
void KilledMonsterCredit(uint32 entry, uint64 guid);
|
||||
void KilledMonsterCredit(uint32 entry, uint64 guid = 0);
|
||||
void KilledPlayerCredit();
|
||||
void CastedCreatureOrGO(uint32 entry, uint64 guid, uint32 spell_id);
|
||||
void TalkedToCreature(uint32 entry, uint64 guid);
|
||||
|
||||
@@ -820,6 +820,8 @@ void Map::MoveAllCreaturesInMoveList()
|
||||
{
|
||||
// update pos
|
||||
c->Relocate(c->_newPosition);
|
||||
if (c->IsVehicle())
|
||||
c->GetVehicleKit()->RelocatePassengers();
|
||||
//CreatureRelocationNotify(c, new_cell, new_cell.cellCoord());
|
||||
c->UpdateObjectVisibility(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user