Core/Scripts: Added wrapper method for despawning creatures DespawnOrUnsummon

This commit is contained in:
Shauren
2011-01-02 21:33:37 +01:00
parent c2f98606b2
commit 9c0cd63e93
66 changed files with 153 additions and 194 deletions
+1 -1
View File
@@ -310,7 +310,7 @@ void VehicleAI::UpdateAI(const uint32 diff)
{
m_DoDismiss = false;
me->SetVisible(false);
me->ForcedDespawn();
me->DespawnOrUnsummon();
}else m_DismissTimer -= diff;
}
}
@@ -813,7 +813,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
}
case ACTION_T_FORCE_DESPAWN:
{
me->ForcedDespawn(action.forced_despawn.msDelay);
me->DespawnOrUnsummon(action.forced_despawn.msDelay);
break;
}
case ACTION_T_SET_INVINCIBILITY_HP_LEVEL:
@@ -246,7 +246,7 @@ void npc_escortAI::UpdateAI(const uint32 uiDiff)
me->Respawn();
}
else
me->ForcedDespawn();
me->DespawnOrUnsummon();
return;
}
@@ -287,7 +287,7 @@ void npc_escortAI::UpdateAI(const uint32 uiDiff)
me->Respawn();
}
else
me->ForcedDespawn();
me->DespawnOrUnsummon();
return;
}
@@ -192,7 +192,7 @@ void FollowerAI::UpdateAI(const uint32 uiDiff)
if (HasFollowState(STATE_FOLLOW_COMPLETE) && !HasFollowState(STATE_FOLLOW_POSTEVENT))
{
sLog->outDebug("TSCR: FollowerAI is set completed, despawns.");
me->ForcedDespawn();
me->DespawnOrUnsummon();
return;
}
@@ -232,7 +232,7 @@ void FollowerAI::UpdateAI(const uint32 uiDiff)
if (bIsMaxRangeExceeded)
{
sLog->outDebug("TSCR: FollowerAI failed because player/group was to far away or not found");
me->ForcedDespawn();
me->DespawnOrUnsummon();
return;
}
@@ -266,7 +266,7 @@ void FollowerAI::MovementInform(uint32 uiMotionType, uint32 uiPointId)
AddFollowState(STATE_FOLLOW_RETURNING);
}
else
me->ForcedDespawn();
me->DespawnOrUnsummon();
}
}
+1 -1
View File
@@ -84,7 +84,7 @@ void SmartAI::UpdateDespawn(const uint32 diff)
mDespawnState++;
}
else
me->ForcedDespawn();
me->DespawnOrUnsummon();
} else mDespawnTime -= diff;
}
@@ -1656,6 +1656,14 @@ void Creature::ForcedDespawn(uint32 timeMSToDespawn)
RemoveCorpse(false);
}
void Creature::DespawnOrUnsummon(uint32 msTimeToDespawn /*= 0*/)
{
if (TempSummon* summon = this->ToTempSummon())
summon->UnSummon();
else
ForcedDespawn(msTimeToDespawn);
}
bool Creature::IsImmunedToSpell(SpellEntry const* spellInfo)
{
if (!spellInfo)
@@ -596,6 +596,7 @@ class Creature : public Unit, public GridObject<Creature>
bool isDeadByDefault() const { return m_isDeadByDefault; };
void ForcedDespawn(uint32 timeMSToDespawn = 0);
void DespawnOrUnsummon(uint32 msTimeToDespawn = 0);
time_t const& GetRespawnTime() const { return m_respawnTime; }
time_t GetRespawnTimeEx() const;
+1 -1
View File
@@ -199,7 +199,7 @@ void Vehicle::RemoveAllPassengers()
// creature passengers mounted on player mounts should be despawned at dismount
if (GetBase()->GetTypeId() == TYPEID_PLAYER && passenger->ToCreature())
passenger->ToCreature()->ForcedDespawn();
passenger->ToCreature()->DespawnOrUnsummon();
}
}
+1 -1
View File
@@ -801,7 +801,7 @@ void Map::ScriptsProcess()
case SCRIPT_COMMAND_DESPAWN_SELF:
// Target or source must be Creature.
if (Creature* cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script, true))
cSource->ForcedDespawn(step.script->DespawnSelf.DespawnDelay);
cSource->DespawnOrUnsummon(step.script->DespawnSelf.DespawnDelay);
break;
case SCRIPT_COMMAND_LOAD_PATH:
@@ -660,7 +660,7 @@ void WorldSession::HandleEjectPassenger(WorldPacket &data)
{
ASSERT(GetPlayer() == vehicle->GetBase());
unit->ExitVehicle();
unit->ToCreature()->ForcedDespawn(1000);
unit->ToCreature()->DespawnOrUnsummon(1000);
ASSERT(!unit->IsOnVehicle(vehicle->GetBase()));
}
else
@@ -2229,7 +2229,7 @@ void AuraEffect::TriggerSpell(Unit * target, Unit * caster) const
player->AutoStoreLoot(creature->GetCreatureInfo()->SkinLootId,LootTemplates_Skinning,true);
creature->ForcedDespawn();
creature->DespawnOrUnsummon();
}
return;
}
@@ -2279,7 +2279,7 @@ void AuraEffect::TriggerSpell(Unit * target, Unit * caster) const
Creature* creatureTarget = target->ToCreature();
creatureTarget->ForcedDespawn();
creatureTarget->DespawnOrUnsummon();
return;
}
// Tear of Azzinoth Summon Channel - it's not really supposed to do anything,and this only prevents the console spam
@@ -2375,7 +2375,7 @@ void AuraEffect::TriggerSpell(Unit * target, Unit * caster) const
if (permafrostCaster)
{
if (Creature *permafrostCasterAsCreature = permafrostCaster->ToCreature())
permafrostCasterAsCreature->ForcedDespawn(3000);
permafrostCasterAsCreature->DespawnOrUnsummon(3000);
caster->CastSpell(caster, 66181, false);
caster->RemoveAllAuras();
+3 -3
View File
@@ -879,7 +879,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
m_caster->SummonGameObject(179644, creatureTarget->GetPositionX(), creatureTarget->GetPositionY(), creatureTarget->GetPositionZ(), creatureTarget->GetOrientation(), 0, 0, 0, 0, uint32(creatureTarget->GetRespawnTime()-time(NULL)));
sLog->outDebug("SummonGameObject at SpellEfects.cpp EffectDummy for Spell 23019");
creatureTarget->ForcedDespawn();
creatureTarget->DespawnOrUnsummon();
return;
}
@@ -1044,7 +1044,7 @@ void Spell::EffectDummy(SpellEffIndex effIndex)
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT)
return;
unitTarget->ToCreature()->ForcedDespawn();
unitTarget->ToCreature()->DespawnOrUnsummon();
//cast spell Raptor Capture Credit
m_caster->CastSpell(m_caster, 42337, true, NULL);
@@ -3681,7 +3681,7 @@ void Spell::EffectTameCreature(SpellEffIndex /*effIndex*/)
return;
// "kill" original creature
creatureTarget->ForcedDespawn();
creatureTarget->DespawnOrUnsummon();
uint8 level = (creatureTarget->getLevel() < (m_caster->getLevel() - 5)) ? (m_caster->getLevel() - 5) : creatureTarget->getLevel();