Merge branch 'master' of github.com:TrinityCore/TrinityCore into 4.3.4

This commit is contained in:
Vincent-Michael committed 2014-05-08 02:47:29 +02:00
commit 09ff96914a
7 files changed
+60 -82

No files matched your search

@@ -47,6 +47,7 @@ GameObject::GameObject() : WorldObject(false), MapObject(),
m_respawnTime = 0;
m_respawnDelayTime = 300;
m_lootState = GO_NOT_READY;
m_lootStateUnitGUID = 0;
m_spawnedByDefault = true;
m_usetimes = 0;
m_spellId = 0;
@@ -309,13 +310,13 @@ void GameObject::Update(uint32 diff)
GameObjectTemplate const* goInfo = GetGOInfo();
// Bombs
if (goInfo->trap.type == 2)
m_cooldownTime = time(NULL) + 10; // Hardcoded tooltip value
// Hardcoded tooltip value
m_cooldownTime = time(NULL) + 10;
else if (Unit* owner = GetOwner())
{
if (owner->IsInCombat())
m_cooldownTime = time(NULL) + goInfo->trap.startDelay;
}
m_lootState = GO_READY;
SetLootState(GO_READY);
break;
}
case GAMEOBJECT_TYPE_TRANSPORT:
@@ -396,7 +397,7 @@ void GameObject::Update(uint32 diff)
if (targetGuid == dbtableHighGuid) // if linking self, never respawn (check delayed to next day)
SetRespawnTime(DAY);
else
m_respawnTime = (now > linkedRespawntime ? now : linkedRespawntime)+urand(5, MINUTE); // else copy time from master and add a little
m_respawnTime = (now > linkedRespawntime ? now : linkedRespawntime) + urand(5, MINUTE); // else copy time from master and add a little
SaveRespawnTime(); // also save to DB immediately
return;
}
@@ -423,7 +424,7 @@ void GameObject::Update(uint32 diff)
}
case GAMEOBJECT_TYPE_DOOR:
case GAMEOBJECT_TYPE_BUTTON:
//we need to open doors if they are closed (add there another condition if this code breaks some usage, but it need to be here for battlegrounds)
// We need to open doors if they are closed (add there another condition if this code breaks some usage, but it need to be here for battlegrounds)
if (GetGoState() != GO_STATE_READY)
ResetDoorOrButton();
break;
@@ -435,13 +436,15 @@ void GameObject::Update(uint32 diff)
break;
}
if (!m_spawnedByDefault) // despawn timer
// Despawn timer
if (!m_spawnedByDefault)
{
// can be despawned or destroyed
// Can be despawned or destroyed
SetLootState(GO_JUST_DEACTIVATED);
return;
}
// respawn timer
// Respawn timer
uint32 poolid = GetDBTableGUIDLow() ? sPoolMgr->IsPartOfAPool<GameObject>(GetDBTableGUIDLow()) : 0;
if (poolid)
sPoolMgr->UpdatePool<GameObject>(poolid, GetDBTableGUIDLow());
@@ -466,47 +469,35 @@ void GameObject::Update(uint32 diff)
}
// Type 0 despawns after being triggered, type 1 does not.
bool isBattlegroundTrap;
/// @todo This is activation radius. Casting radius must be selected from spell data.
/// @todo Move activated state code to GO_ACTIVATED, in this place just check for activation and set state.
float radius;
if (!goInfo->trap.diameter)
{
// Cast in other case (at some triggering/linked go/etc explicit call)
if (goInfo->trap.cooldown != 3 || m_respawnTime > 0)
// Battleground traps: data2 == 0 && data5 == 3
if (goInfo->trap.cooldown != 3)
break;
// Battleground gameobjects have data2 == 0 && data5 == 3
isBattlegroundTrap = true;
radius = 3.f;
}
else
{
isBattlegroundTrap = false;
radius = goInfo->trap.diameter / 2.f;
}
Unit* owner = GetOwner();
// Pointer to appropriate target if found any
Unit* target = NULL;
/// @todo this hack with search required until GO casting not implemented
// Hunter trap: Search units which are unfriendly to the trap's owner
if (owner)
if (Unit* owner = GetOwner())
{
// Hunter trap: Search units which are unfriendly to the trap's owner
Trinity::AnyUnfriendlyNoTotemUnitInObjectRangeCheck checker(this, owner, radius);
Trinity::UnitSearcher<Trinity::AnyUnfriendlyNoTotemUnitInObjectRangeCheck> searcher(this, target, checker);
VisitNearbyGridObject(radius, searcher);
if (!target)
VisitNearbyWorldObject(radius, searcher);
}
// Environmental trap: Any target
else
{
// Environmental damage spells already have around enemies targeting but this does not help in case of not existing GO casting support
// Affect only players
// Environmental trap: Any player
Player* player = NULL;
Trinity::AnyPlayerInObjectRangeCheck checker(this, radius);
Trinity::PlayerSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(this, player, checker);
@@ -515,23 +506,8 @@ void GameObject::Update(uint32 diff)
}
if (target)
{
// Some traps do not have a spell but should be triggered
if (goInfo->trap.spellId)
CastSpell(target, goInfo->trap.spellId);
SetLootState(GO_ACTIVATED, target);
// Template value or 4 seconds
m_cooldownTime = time(NULL) + (goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4));
if (goInfo->trap.type == 1)
SetLootState(GO_JUST_DEACTIVATED);
// Battleground gameobjects case
if (isBattlegroundTrap)
if (Player* player = target->ToPlayer())
if (Battleground* bg = player->GetBattleground())
bg->HandleTriggerBuff(GetGUID());
}
}
else if (uint32 max_charges = goInfo->GetCharges())
{
@@ -580,11 +556,30 @@ void GameObject::Update(uint32 diff)
case GAMEOBJECT_TYPE_TRAP:
{
GameObjectTemplate const* goInfo = GetGOInfo();
if (goInfo->trap.spellId)
if (goInfo->trap.type == 2 && goInfo->trap.spellId)
{
/// @todo NULL target won't work for target type 1
CastSpell(NULL, goInfo->trap.spellId);
SetLootState(GO_JUST_DEACTIVATED);
}
else if (Unit* target = Unit::GetUnit(*this, m_lootStateUnitGUID))
{
// Some traps do not have a spell but should be triggered
if (goInfo->trap.spellId)
CastSpell(target, goInfo->trap.spellId);
SetLootState(GO_JUST_DEACTIVATED);
// Template value or 4 seconds
m_cooldownTime = time(NULL) + (goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4));
if (goInfo->trap.type == 1)
SetLootState(GO_JUST_DEACTIVATED);
// Battleground gameobjects have data2 == 0 && data5 == 3
if (!goInfo->trap.diameter && goInfo->trap.cooldown == 3)
if (Player* player = target->ToPlayer())
if (Battleground* bg = player->GetBattleground())
bg->HandleTriggerBuff(GetGUID());
}
break;
}
default:
@@ -2014,6 +2009,7 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player*
void GameObject::SetLootState(LootState state, Unit* unit)
{
m_lootState = state;
m_lootStateUnitGUID = unit ? unit->GetGUID() : 0;
AI()->OnStateChanged(state, unit);
sScriptMgr->OnGameObjectLootStateChanged(this, state, unit);
if (m_model)