From 02f56a6ad80bd8389c31a6796b25088047c08e33 Mon Sep 17 00:00:00 2001 From: megamage Date: Thu, 30 Apr 2009 23:40:51 -0500 Subject: *Fix build. --HG-- branch : trunk --- src/bindings/scripts/include/sc_creature.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/bindings/scripts/include/sc_creature.cpp b/src/bindings/scripts/include/sc_creature.cpp index 0615d865f9f..a7cc388bbbb 100644 --- a/src/bindings/scripts/include/sc_creature.cpp +++ b/src/bindings/scripts/include/sc_creature.cpp @@ -584,7 +584,7 @@ void FillSpellSummary() if ( TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA || TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA_INSTANT || TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_AROUND_CASTER || - TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA_CHANNELED ) + TempSpell->EffectImplicitTargetA[j] == TARGET_DEST_DYNOBJ_ENEMY ) SpellSummary[i].Targets |= 1 << (SELECT_TARGET_AOE_ENEMY-1); //Spell targets an enemy @@ -593,7 +593,7 @@ void FillSpellSummary() TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA || TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA_INSTANT || TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_AROUND_CASTER || - TempSpell->EffectImplicitTargetA[j] == TARGET_ALL_ENEMY_IN_AREA_CHANNELED ) + TempSpell->EffectImplicitTargetA[j] == TARGET_DEST_DYNOBJ_ENEMY ) SpellSummary[i].Targets |= 1 << (SELECT_TARGET_ANY_ENEMY-1); //Spell targets a single friend(or self) -- cgit v1.2.3 From 08d1d7334f890a075cc72288dc3ad1199954a6de Mon Sep 17 00:00:00 2001 From: Anubisss Date: Fri, 1 May 2009 17:29:11 +0200 Subject: *Backport from TrinityCore2: [7739] Implement boss spell 38441. Author: NoFantasy --HG-- branch : trunk --- src/game/SpellEffects.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 37f1dc0a083..15f5833c39b 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -366,7 +366,12 @@ void Spell::SpellDamageSchoolDmg(uint32 effect_idx) if(!radius) return; float distance = m_caster->GetDistance2d(unitTarget); damage = (distance > radius ) ? 0 : (int32)(m_spellInfo->EffectBasePoints[0]*((radius - distance)/radius)); - }break; + break; + } + // Cataclysmic Bolt + case 38441: + damage = unitTarget->GetMaxHealth() / 2; + break; } break; } -- cgit v1.2.3 From 1ea5d4265da97657c903f73fa18cbd0ca26eebff Mon Sep 17 00:00:00 2001 From: Anubisss Date: Fri, 1 May 2009 17:32:22 +0200 Subject: *Remove unused CastCustomSpell() code from Fathom-Lord Karathress' script. --HG-- branch : trunk --- .../coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp index 3a3f7e8291d..7fb9c74be21 100644 --- a/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp +++ b/src/bindings/scripts/scripts/zone/coilfang_resevoir/serpent_shrine/boss_fathomlord_karathress.cpp @@ -250,9 +250,8 @@ struct TRINITY_DLL_DECL boss_fathomlord_karathressAI : public ScriptedAI if (!target) target = m_creature->getVictim(); - int32 dmg = target->GetMaxHealth() / 2; - m_creature->CastCustomSpell(target, SPELL_CATACLYSMIC_BOLT, &dmg, NULL, NULL, false, NULL, NULL, m_creature->GetGUID()); - + if(target) + DoCast(target, SPELL_CATACLYSMIC_BOLT); CataclysmicBolt_Timer = 10000; }else CataclysmicBolt_Timer -= diff; -- cgit v1.2.3 From 623c97edd696f23a65bdfcaf1ee9aa5094260c7d Mon Sep 17 00:00:00 2001 From: megamage Date: Fri, 1 May 2009 11:38:53 -0500 Subject: *Always call Initialize when a instancedata is created. --HG-- branch : trunk --- src/game/Map.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 65c30f1781e..4ed7593d725 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -2021,6 +2021,8 @@ void InstanceMap::CreateInstanceData(bool load) if(!i_data) return; + i_data->Initialize(); + if(load) { // TODO: make a global storage for this @@ -2037,11 +2039,6 @@ void InstanceMap::CreateInstanceData(bool load) delete result; } } - else - { - sLog.outDebug("New instance data, \"%s\" ,initialized!", objmgr.GetScriptName(i_script_id)); - i_data->Initialize(); - } } /* -- cgit v1.2.3 From 77bd6f148a85940e784c614af939e74688580a2c Mon Sep 17 00:00:00 2001 From: Iskander Date: Fri, 1 May 2009 19:23:10 +0200 Subject: *Do not allow 2 same blessings to stack --HG-- branch : trunk --- src/game/SpellMgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index e77bce1fc4d..a66ea70755f 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -1361,7 +1361,7 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2, bool return true; // spells with different specific always stack - if(spellId_spec_1 || spellId_spec_2) + if(spellId_spec_1 != spellId_spec_2) return false; if(spellInfo_1->SpellFamilyName != spellInfo_2->SpellFamilyName) -- cgit v1.2.3 From 4fb815a9b85087e6dbc1983780b33e9611ea14dd Mon Sep 17 00:00:00 2001 From: megamage Date: Fri, 1 May 2009 15:01:07 -0500 Subject: *Fix a bug that gohello is called twice for goober. --HG-- branch : trunk --- src/game/SpellEffects.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 15f5833c39b..e0589918dad 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -2818,6 +2818,8 @@ void Spell::SendLoot(uint64 guid, LootType loottype) return; Script->GOHello(player, gameObjTarget); + sWorld.ScriptsStart(sGameObjectScripts, gameObjTarget->GetDBTableGUIDLow(), player, gameObjTarget); + gameObjTarget->AddUniqueUse(player); gameObjTarget->SetLootState(GO_JUST_DEACTIVATED); @@ -2831,10 +2833,6 @@ void Spell::SendLoot(uint64 guid, LootType loottype) if(uint32 trapEntry = gameObjTarget->GetGOInfo()->goober.linkedTrapId) gameObjTarget->TriggeringLinkedGameObject(trapEntry,m_caster); - // activate GO scripts - Script->GOHello(player, gameObjTarget); - sWorld.ScriptsStart(sGameObjectScripts, gameObjTarget->GetDBTableGUIDLow(), player, gameObjTarget); - return; case GAMEOBJECT_TYPE_CHEST: -- cgit v1.2.3 From 5a667740082b8afa6af30d0f1e7082e8a3321fd3 Mon Sep 17 00:00:00 2001 From: megamage Date: Fri, 1 May 2009 15:36:32 -0500 Subject: *Fix the bug that shapeshift can remove blind. --HG-- branch : trunk --- src/game/SpellAuras.cpp | 3 +-- src/game/SpellMgr.cpp | 24 +++++++++++++++++++----- src/game/SpellMgr.h | 1 + src/game/Unit.cpp | 11 +++++++++++ src/game/Unit.h | 1 + 5 files changed, 33 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 0296f12a34b..63952c723b0 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -2434,8 +2434,7 @@ void Aura::HandleAuraModShapeshift(bool apply, bool Real) case FORM_FLIGHT: case FORM_MOONKIN: // remove movement affects - m_target->RemoveSpellsCausingAura(SPELL_AURA_MOD_ROOT); - m_target->RemoveSpellsCausingAura(SPELL_AURA_MOD_DECREASE_SPEED); + m_target->RemoveMovementImpairingAuras(); // and polymorphic affects if(m_target->IsPolymorphed()) diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index a66ea70755f..25c68da03d6 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -2145,13 +2145,12 @@ void SpellMgr::LoadSpellCustomAttr() case SPELL_AURA_OBS_MOD_HEALTH: mSpellCustomAttr[i] |= SPELL_ATTR_CU_AURA_HOT; break; - case SPELL_AURA_MOD_POSSESS: - case SPELL_AURA_MOD_CONFUSE: - case SPELL_AURA_MOD_CHARM: - case SPELL_AURA_MOD_FEAR: - case SPELL_AURA_MOD_STUN: case SPELL_AURA_MOD_ROOT: mSpellCustomAttr[i] |= SPELL_ATTR_CU_AURA_CC; + mSpellCustomAttr[i] |= SPELL_ATTR_CU_MOVEMENT_IMPAIR; + break; + case SPELL_AURA_MOD_DECREASE_SPEED: + mSpellCustomAttr[i] |= SPELL_ATTR_CU_MOVEMENT_IMPAIR; break; default: break; @@ -2178,6 +2177,21 @@ void SpellMgr::LoadSpellCustomAttr() } } + for(uint32 j = 0; j < 3; ++j) + { + switch(spellInfo->EffectApplyAuraName[j]) + { + case SPELL_AURA_MOD_POSSESS: + case SPELL_AURA_MOD_CONFUSE: + case SPELL_AURA_MOD_CHARM: + case SPELL_AURA_MOD_FEAR: + case SPELL_AURA_MOD_STUN: + mSpellCustomAttr[i] |= SPELL_ATTR_CU_AURA_CC; + mSpellCustomAttr[i] &= ~SPELL_ATTR_CU_MOVEMENT_IMPAIR; + break; + } + } + if(spellInfo->SpellVisual == 3879) mSpellCustomAttr[i] |= SPELL_ATTR_CU_CONE_BACK; diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h index 35d867dce2b..f9d5cdd09f4 100644 --- a/src/game/SpellMgr.h +++ b/src/game/SpellMgr.h @@ -719,6 +719,7 @@ inline bool IsProfessionSkill(uint32 skill) #define SPELL_ATTR_CU_LINK_HIT 0x00000800 #define SPELL_ATTR_CU_LINK_AURA 0x00001000 #define SPELL_ATTR_CU_LINK_REMOVE 0x00002000 +#define SPELL_ATTR_CU_MOVEMENT_IMPAIR 0x00004000 typedef std::vector SpellCustomAttribute; diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 756a1ac7d43..d4503c0f55c 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -503,6 +503,17 @@ void Unit::GetRandomContactPoint( const Unit* obj, float &x, float &y, float &z, , GetAngle(obj) + (attacker_number ? (M_PI/2 - M_PI * rand_norm()) * (float)attacker_number / combat_reach / 3 : 0)); } +void Unit::RemoveMovementImpairingAuras() +{ + for(AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end();) + { + if(spellmgr.GetSpellCustomAttr(iter->second->GetId()) & SPELL_ATTR_CU_MOVEMENT_IMPAIR) + RemoveAura(iter); + else + ++iter; + } +} + void Unit::RemoveSpellsCausingAura(AuraType auraType) { if (auraType >= TOTAL_AURAS) return; diff --git a/src/game/Unit.h b/src/game/Unit.h index 79fff7a7351..4281ac55038 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1161,6 +1161,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject bool RemoveNoStackAurasDueToAura(Aura *Aur); void RemoveAurasWithInterruptFlags(uint32 flags, uint32 except = 0); void RemoveAurasWithDispelType( DispelType type ); + void RemoveMovementImpairingAuras(); void RemoveAllAuras(); void RemoveArenaAuras(bool onleave = false); -- cgit v1.2.3 From c9cd3b07f9e69030a86bcd9f06055f4247732d1d Mon Sep 17 00:00:00 2001 From: megamage Date: Fri, 1 May 2009 18:24:12 -0500 Subject: *Add some InstanceData functions to better handle instance doors. --HG-- branch : trunk --- src/bindings/scripts/include/sc_instance.h | 9 --- src/game/Creature.cpp | 5 +- src/game/GameObject.cpp | 3 + src/game/InstanceData.cpp | 89 ++++++++++++++++++++++++++++++ src/game/InstanceData.h | 45 ++++++++++++++- 5 files changed, 139 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/bindings/scripts/include/sc_instance.h b/src/bindings/scripts/include/sc_instance.h index 4443c510110..8f5d657fbaa 100644 --- a/src/bindings/scripts/include/sc_instance.h +++ b/src/bindings/scripts/include/sc_instance.h @@ -8,15 +8,6 @@ #include "InstanceData.h" #include "Map.h" -enum EncounterState -{ - NOT_STARTED = 0, - IN_PROGRESS = 1, - FAIL = 2, - DONE = 3, - SPECIAL = 4 -}; - #define OUT_SAVE_INST_DATA debug_log("TSCR: Saving Instance Data for Instance %s (Map %d, Instance Id %d)", instance->GetMapName(), instance->GetId(), instance->GetInstanceId()) #define OUT_SAVE_INST_DATA_COMPLETE debug_log("TSCR: Saving Instance Data for Instance %s (Map %d, Instance Id %d) completed.", instance->GetMapName(), instance->GetId(), instance->GetInstanceId()) #define OUT_LOAD_INST_DATA(a) debug_log("TSCR: Loading Instance Data for Instance %s (Map %d, Instance Id %d). Input is '%s'", instance->GetMapName(), instance->GetId(), instance->GetInstanceId(), a) diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 520e5cb62c3..a1907c9525d 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -191,6 +191,9 @@ void Creature::RemoveFromWorld() ///- Remove the creature from the accessor if(IsInWorld()) { + if(Map *map = FindMap()) + if(map->IsDungeon() && ((InstanceMap*)map)->GetInstanceData()) + ((InstanceMap*)map)->GetInstanceData()->OnCreatureRemove(this); if(m_formation) formation_mgr.RemoveCreatureFromGroup(m_formation, this); ObjectAccessor::Instance().RemoveObject(this); @@ -1371,7 +1374,7 @@ bool Creature::CreateFromProto(uint32 guidlow, uint32 Entry, uint32 team, const //Notify the map's instance data. //Only works if you create the object in it, not if it is moves to that map. //Normally non-players do not teleport to other maps. - Map *map = MapManager::Instance().FindMap(GetMapId(), GetInstanceId()); + Map *map = FindMap(); if(map && map->IsDungeon() && ((InstanceMap*)map)->GetInstanceData()) { ((InstanceMap*)map)->GetInstanceData()->OnCreatureCreate(this, Entry); diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index d1bb0362872..f71c08b3403 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -94,6 +94,9 @@ void GameObject::RemoveFromWorld() ///- Remove the gameobject from the accessor if(IsInWorld()) { + if(Map *map = FindMap()) + if(map->IsDungeon() && ((InstanceMap*)map)->GetInstanceData()) + ((InstanceMap*)map)->GetInstanceData()->OnObjectRemove(this); ObjectAccessor::Instance().RemoveObject(this); WorldObject::RemoveFromWorld(); } diff --git a/src/game/InstanceData.cpp b/src/game/InstanceData.cpp index 622dc7842e7..0f62e9e27af 100644 --- a/src/game/InstanceData.cpp +++ b/src/game/InstanceData.cpp @@ -40,3 +40,92 @@ void InstanceData::HandleGameObject(uint64 GUID, bool open, GameObject *go) debug_log("TSCR: InstanceData: HandleGameObject failed"); } +bool InstanceData::IsEncounterInProgress() const +{ + for(std::vector::const_iterator itr = bosses.begin(); itr != bosses.end(); ++itr) + if(itr->state == IN_PROGRESS) + return true; + + return false; +} + +void InstanceData::AddBossRoomDoor(uint32 id, GameObject *door) +{ + if(id < bosses.size()) + { + BossInfo *bossInfo = &bosses[id]; + bossInfo->roomDoor.insert(door); + // Room door is only closed when encounter is in progress + if(bossInfo->state == IN_PROGRESS) + door->SetGoState(1); + else + door->SetGoState(0); + } +} + +void InstanceData::AddBossPassageDoor(uint32 id, GameObject *door) +{ + if(id < bosses.size()) + { + BossInfo *bossInfo = &bosses[id]; + bossInfo->passageDoor.insert(door); + // Passage door is only opened when boss is defeated + if(bossInfo->state == DONE) + door->SetGoState(0); + else + door->SetGoState(1); + } +} + +void InstanceData::RemoveBossRoomDoor(uint32 id, GameObject *door) +{ + if(id < bosses.size()) + { + bosses[id].roomDoor.erase(door); + } +} + +void InstanceData::RemoveBossPassageDoor(uint32 id, GameObject *door) +{ + if(id < bosses.size()) + { + bosses[id].passageDoor.erase(door); + } +} + +void InstanceData::SetBossState(uint32 id, EncounterState state) +{ + if(id < bosses.size()) + { + BossInfo *bossInfo = &bosses[id]; + + bossInfo->state = state; + switch(state) + { + case NOT_STARTED: + // Open all room doors, close all passage doors + for(DoorSet::iterator i = bossInfo->roomDoor.begin(); i != bossInfo->roomDoor.end(); ++i) + (*i)->SetGoState(0); + for(DoorSet::iterator i = bossInfo->passageDoor.begin(); i != bossInfo->passageDoor.end(); ++i) + (*i)->SetGoState(1); + break; + case IN_PROGRESS: + // Close all doors + for(DoorSet::iterator i = bossInfo->roomDoor.begin(); i != bossInfo->roomDoor.end(); ++i) + (*i)->SetGoState(1); + for(DoorSet::iterator i = bossInfo->passageDoor.begin(); i != bossInfo->passageDoor.end(); ++i) + (*i)->SetGoState(1); + break; + case DONE: + // Open all doors + for(DoorSet::iterator i = bossInfo->roomDoor.begin(); i != bossInfo->roomDoor.end(); ++i) + (*i)->SetGoState(0); + for(DoorSet::iterator i = bossInfo->passageDoor.begin(); i != bossInfo->passageDoor.end(); ++i) + (*i)->SetGoState(0); + break; + default: + break; + } + } +} + diff --git a/src/game/InstanceData.h b/src/game/InstanceData.h index ec36a794525..2f2b0c49be0 100644 --- a/src/game/InstanceData.h +++ b/src/game/InstanceData.h @@ -31,6 +31,24 @@ class Player; class GameObject; class Creature; +enum EncounterState +{ + NOT_STARTED = 0, + IN_PROGRESS = 1, + FAIL = 2, + DONE = 3, + SPECIAL = 4 +}; + +typedef std::set DoorSet; + +struct BossInfo +{ + BossInfo() : state(NOT_STARTED) {} + EncounterState state; + DoorSet roomDoor, passageDoor; +}; + class TRINITY_DLL_SPEC InstanceData { public: @@ -56,7 +74,7 @@ class TRINITY_DLL_SPEC InstanceData //Used by the map's CanEnter function. //This is to prevent players from entering during boss encounters. - virtual bool IsEncounterInProgress() const { return false; }; + virtual bool IsEncounterInProgress() const; //Called when a player successfully enters the instance. virtual void OnPlayerEnter(Player *) {} @@ -67,6 +85,9 @@ class TRINITY_DLL_SPEC InstanceData //called on creature creation virtual void OnCreatureCreate(Creature * /*creature*/, uint32 /*creature_entry*/) {} + virtual void OnCreatureRemove(Creature*) {} + virtual void OnObjectRemove(GameObject*) {} + //All-purpose data storage 32 bit virtual uint32 GetData(uint32) { return 0; } virtual void SetData(uint32, uint32 data) {} @@ -74,7 +95,27 @@ class TRINITY_DLL_SPEC InstanceData //Handle open / close objects //use HandleGameObject(NULL,boolen,GO); in OnObjectCreate in instance scripts //use HandleGameObject(GUID,boolen,NULL); in any other script - virtual void HandleGameObject(uint64 GUID, bool open, GameObject *go = NULL); + void HandleGameObject(uint64 GUID, bool open, GameObject *go = NULL); + + protected: + void AddBossRoomDoor(uint32 id, GameObject *door); + void AddBossPassageDoor(uint32 id, GameObject *door); + void RemoveBossRoomDoor(uint32 id, GameObject *door); + void RemoveBossPassageDoor(uint32 id, GameObject *door); + + void SetBossState(uint32 id, EncounterState state); + + std::string GetBossSave() + { + std::ostringstream saveStream; + for(std::vector::iterator i = bosses.begin(); i != bosses.end(); ++i) + saveStream << (uint32)i->state << " "; + return saveStream.str(); + } + + private: + std::vector bosses; + }; #endif -- cgit v1.2.3