diff options
author | megamage <none@none> | 2009-04-19 11:10:07 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-04-19 11:10:07 -0500 |
commit | 0c27856ee4d26125b7e5cb2ca207449f218e1702 (patch) | |
tree | 63cdf3d0b7b3231c6f380c4acdc6fe66ff900b15 /src | |
parent | a23df5a270cd47ea3b4f433699b484c6c61a27e6 (diff) | |
parent | 6baf53ad15e4454637e0399fa8dab15914383fc2 (diff) |
*Merge.
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/bindings/scripts/ScriptMgr.cpp | 4 | ||||
-rw-r--r-- | src/game/Spell.cpp | 34 | ||||
-rw-r--r-- | src/game/Spell.h | 27 | ||||
-rw-r--r-- | src/game/SpellAuras.cpp | 6 | ||||
-rw-r--r-- | src/game/SpellEffects.cpp | 9 | ||||
-rw-r--r-- | src/game/Unit.cpp | 69 | ||||
-rw-r--r-- | src/game/Unit.h | 24 |
7 files changed, 122 insertions, 51 deletions
diff --git a/src/bindings/scripts/ScriptMgr.cpp b/src/bindings/scripts/ScriptMgr.cpp index f23fd83832d..850b9bb467f 100644 --- a/src/bindings/scripts/ScriptMgr.cpp +++ b/src/bindings/scripts/ScriptMgr.cpp @@ -1622,14 +1622,14 @@ void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target) void Script::RegisterSelf() { int id = GetScriptId(Name.c_str()); - if (id != 0) + if(id) { m_scripts[id] = this; ++num_sc_scripts; } else { - debug_log("TSCR: RegisterSelf, but script named %s does not have ScriptName assigned in database.",(this)->Name.c_str()); + error_db_log("CRASH ALERT! TrinityScript: RegisterSelf, but script named %s does not have ScriptName assigned in database.",(this)->Name.c_str()); delete this; } } diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 8b0014caaae..69ac197f6be 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -295,14 +295,11 @@ void SpellCastTargets::write ( WorldPacket * data ) } Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 originalCasterGUID, Spell** triggeringContainer, bool skipCheck ) +: m_spellInfo(info), m_spellValue(new SpellValue(m_spellInfo)) +, m_caster(Caster) { - ASSERT( Caster != NULL && info != NULL ); - ASSERT( info == sSpellStore.LookupEntry( info->Id ) && "`info` must be pointer to sSpellStore element"); - - m_spellInfo = info; m_customAttr = spellmgr.GetSpellCustomAttr(m_spellInfo->Id); m_skipCheck = skipCheck; - m_caster = Caster; m_selfContainer = NULL; m_triggeringContainer = triggeringContainer; m_referencedFromCurrentSpell = false; @@ -362,7 +359,7 @@ Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 origi } for(int i=0; i <3; ++i) - m_currentBasePoints[i] = m_spellInfo->EffectBasePoints[i]; + m_currentBasePoints[i] = m_spellValue->EffectBasePoints[i]; m_spellState = SPELL_STATE_NULL; @@ -419,6 +416,7 @@ Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 origi Spell::~Spell() { + delete m_spellValue; } void Spell::FillTargetMap() @@ -1506,7 +1504,7 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list<Unit*> &TagUnitMap) //Chain: 2, 6, 22, 25, 45, 77 uint32 EffectChainTarget = m_spellInfo->EffectChainTarget[i]; - uint32 unMaxTargets = m_spellInfo->MaxAffectedTargets; + uint32 unMaxTargets = m_spellValue->MaxAffectedTargets; Unit::AuraEffectList const& Auras = m_caster->GetAurasByType(SPELL_AURA_MOD_MAX_AFFECTED_TARGETS); for(Unit::AuraEffectList::const_iterator j = Auras.begin();j != Auras.end(); ++j) @@ -5767,3 +5765,25 @@ SpellCastResult Spell::CanOpenLock(uint32 effIndex, uint32 lockId, SkillType& sk return SPELL_CAST_OK; } + +void Spell::SetSpellValue(SpellValueMod mod, int32 value) +{ + switch(mod) + { + case SPELLVALUE_BASE_POINT0: + m_spellValue->EffectBasePoints[0] = value - int32(m_spellInfo->EffectBaseDice[0]); + m_currentBasePoints[0] = m_spellValue->EffectBasePoints[0]; //this should be removed in the future + break; + case SPELLVALUE_BASE_POINT1: + m_spellValue->EffectBasePoints[1] = value - int32(m_spellInfo->EffectBaseDice[1]); + m_currentBasePoints[1] = m_spellValue->EffectBasePoints[1]; + break; + case SPELLVALUE_BASE_POINT2: + m_spellValue->EffectBasePoints[2] = value - int32(m_spellInfo->EffectBaseDice[2]); + m_currentBasePoints[2] = m_spellValue->EffectBasePoints[2]; + break; + case SPELLVALUE_MAX_TARGETS: + m_spellValue->MaxAffectedTargets = (uint32)value; + break; + } +} diff --git a/src/game/Spell.h b/src/game/Spell.h index 0f9483bf38c..f5ee99fe171 100644 --- a/src/game/Spell.h +++ b/src/game/Spell.h @@ -24,12 +24,9 @@ #include "GridDefines.h" #include "SharedDefines.h" -class WorldSession; class Unit; -class DynamicObj; class Player; class GameObject; -class Group; class Aura; enum SpellCastTargetFlags @@ -209,6 +206,18 @@ class SpellCastTargets uint32 m_itemTargetEntry; }; +struct SpellValue +{ + explicit SpellValue(SpellEntry const *proto) + { + for(uint32 i = 0; i < 3; ++i) + EffectBasePoints[i] = proto->EffectBasePoints[i]; + MaxAffectedTargets = proto->MaxAffectedTargets; + } + int32 EffectBasePoints[3]; + uint32 MaxAffectedTargets; +}; + enum SpellState { SPELL_STATE_NULL = 0, @@ -235,10 +244,6 @@ enum SpellTargets SPELL_TARGETS_CHAINHEAL, }; -#define SPELL_SPELL_CHANNEL_UPDATE_INTERVAL (1*IN_MILISECONDS) - -typedef std::multimap<uint64, uint64> SpellTargetTimeMap; - class Spell { friend struct Trinity::SpellNotifierCreatureAndPlayer; @@ -419,7 +424,7 @@ class Spell void HandleThreatSpells(uint32 spellId); //void HandleAddAura(Unit* Target); - SpellEntry const* m_spellInfo; + const SpellEntry * const m_spellInfo; int32 m_currentBasePoints[3]; // cache SpellEntry::EffectBasePoints and use for set custom base points Item* m_CastItem; uint64 m_castItemGUID; @@ -467,11 +472,15 @@ class Spell void AddTriggeredSpell(SpellEntry const* spell) { m_TriggerSpells.push_back(spell); } void CleanupTargetList(); + + void SetSpellValue(SpellValueMod mod, int32 value); protected: void SendLoot(uint64 guid, LootType loottype); - Unit* m_caster; + Unit* const m_caster; + + SpellValue * const m_spellValue; uint64 m_originalCasterGUID; // real source of cast (aura caster/etc), used for spell targets selection // e.g. damage around area spell trigered by victim aura and damage enemies of aura caster diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index a619d14ff06..e3a920866f7 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -2216,6 +2216,12 @@ void AuraEffect::TriggerSpell() caster->CastCustomSpell(target, trigger_spell_id, &m_amount, NULL, NULL, true, NULL, this); return; } + // Negative Energy Periodic + case 46284: + { + caster->CastCustomSpell(trigger_spell_id, SPELLVALUE_MAX_TARGETS, m_tickNumber / 10 + 1, NULL, true, NULL, this, originalCasterGUID); + return; + } } } diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index f4f7ae2e78b..cd1471055cb 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -4714,6 +4714,15 @@ void Spell::EffectScriptEffect(uint32 effIndex) unitTarget->CastSpell(unitTarget, 44870, true); break; } + // Negative Energy + case 46289: + { + if(!unitTarget) + return; + + m_caster->CastSpell(unitTarget, 46285, true); + break; + } // Goblin Weather Machine case 46203: { diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index efa85d137a4..2dca6c45491 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -1023,66 +1023,75 @@ void Unit::CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, I spell->prepare(&targets, triggeredByAura); } -void Unit::CastCustomSpell(Unit* Victim,uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, AuraEffect* triggeredByAura, uint64 originalCaster) +void Unit::CastCustomSpell(Unit* target, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, AuraEffect* triggeredByAura, uint64 originalCaster) { - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId ); - - if(!spellInfo) - { - sLog.outError("CastCustomSpell: unknown spell id %i", spellId); - return; - } + CustomSpellValues values; + if(bp0) values.AddSpellMod(SPELLVALUE_BASE_POINT0, *bp0); + if(bp1) values.AddSpellMod(SPELLVALUE_BASE_POINT1, *bp1); + if(bp2) values.AddSpellMod(SPELLVALUE_BASE_POINT2, *bp2); + CastCustomSpell(spellId, values, target, triggered, castItem, triggeredByAura, originalCaster); +} - CastCustomSpell(Victim,spellInfo,bp0,bp1,bp2,triggered,castItem,triggeredByAura, originalCaster); +void Unit::CastCustomSpell(uint32 spellId, SpellValueMod mod, uint32 value, Unit* target, bool triggered, Item *castItem, AuraEffect* triggeredByAura, uint64 originalCaster) +{ + CustomSpellValues values; + values.AddSpellMod(mod, value); + CastCustomSpell(spellId, values, target, triggered, castItem, triggeredByAura, originalCaster); } -void Unit::CastCustomSpell(Unit* Victim,SpellEntry const *spellInfo, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, AuraEffect* triggeredByAura, uint64 originalCaster) +void Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit* Victim, bool triggered, Item *castItem, AuraEffect* triggeredByAura, uint64 originalCaster) { + SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId ); if(!spellInfo) { - sLog.outError("CastCustomSpell: unknown spell"); + sLog.outError("CastSpell: unknown spell id %i by caster: %s %u)", spellId,(GetTypeId()==TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId()==TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); return; } SpellCastTargets targets; uint32 targetMask = spellInfo->Targets; - targets.setUnitTarget(Victim); - /*if(targetMask & (TARGET_FLAG_UNIT|TARGET_FLAG_UNK2)) + + //check unit target + for(int i = 0; i < 3; ++i) { - if(!Victim) + if(spellmgr.SpellTargetType[spellInfo->EffectImplicitTargetA[i]] == TARGET_TYPE_UNIT_TARGET) { - sLog.outError("CastCustomSpell: spell id %i by caster: %s %u) does not have unit target", spellInfo->Id,(GetTypeId()==TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId()==TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); - return; + if(!Victim) + { + sLog.outError("CastSpell: spell id %i by caster: %s %u) does not have unit target", spellInfo->Id,(GetTypeId()==TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId()==TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); + return; + } + else + break; } - }*/ + } + targets.setUnitTarget(Victim); + + //check destination if(targetMask & (TARGET_FLAG_SOURCE_LOCATION|TARGET_FLAG_DEST_LOCATION)) { if(!Victim) { - sLog.outError("CastCustomSpell: spell id %i by caster: %s %u) does not have destination", spellInfo->Id,(GetTypeId()==TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId()==TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); + sLog.outError("CastSpell: spell id %i by caster: %s %u) does not have destination", spellInfo->Id,(GetTypeId()==TYPEID_PLAYER ? "player (GUID:" : "creature (Entry:"),(GetTypeId()==TYPEID_PLAYER ? GetGUIDLow() : GetEntry())); return; } targets.setDestination(Victim); } - if (castItem) - DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id); - if(!originalCaster && triggeredByAura) originalCaster = triggeredByAura->GetCasterGUID(); - Spell *spell = new Spell(this, spellInfo, triggered, originalCaster); - - if(bp0) - spell->m_currentBasePoints[0] = *bp0-int32(spellInfo->EffectBaseDice[0]); + Spell *spell = new Spell(this, spellInfo, triggered, originalCaster ); - if(bp1) - spell->m_currentBasePoints[1] = *bp1-int32(spellInfo->EffectBaseDice[1]); + if(castItem) + { + DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id); + spell->m_CastItem = castItem; + } - if(bp2) - spell->m_currentBasePoints[2] = *bp2-int32(spellInfo->EffectBaseDice[2]); + for(CustomSpellValues::const_iterator itr = value.begin(); itr != value.end(); ++itr) + spell->SetSpellValue(itr->first, itr->second); - spell->m_CastItem = castItem; spell->prepare(&targets, triggeredByAura); } diff --git a/src/game/Unit.h b/src/game/Unit.h index 03331861b9e..e49f07c0fcb 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -123,6 +123,24 @@ enum SpellModOp #define MAX_SPELLMOD 32 +enum SpellValueMod +{ + SPELLVALUE_BASE_POINT0, + SPELLVALUE_BASE_POINT1, + SPELLVALUE_BASE_POINT2, + SPELLVALUE_MAX_TARGETS, +}; + +typedef std::pair<SpellValueMod, int32> CustomSpellValueMod; +class CustomSpellValues : public std::vector<CustomSpellValueMod> +{ + public: + void AddSpellMod(SpellValueMod mod, int32 value) + { + push_back(std::make_pair(mod, value)); + } +}; + enum SpellFacingFlags { SPELL_FACING_FLAG_INFRONT = 0x0001 @@ -282,7 +300,7 @@ enum InventorySlot struct FactionTemplateEntry; struct SpellEntry; -struct SpellEntryExt; +struct SpellValue; class Aura; class AuraEffect; @@ -1157,8 +1175,8 @@ class TRINITY_DLL_SPEC Unit : public WorldObject void CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem = NULL, AuraEffect* triggeredByAura = NULL, uint64 originalCaster = 0); void CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, Item *castItem= NULL, AuraEffect* triggeredByAura = NULL, uint64 originalCaster = 0); void CastCustomSpell(Unit* Victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem= NULL, AuraEffect* triggeredByAura = NULL, uint64 originalCaster = 0); - void CastCustomSpell(Unit* Victim,SpellEntry const *spellInfo, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem= NULL, AuraEffect* triggeredByAura = NULL, uint64 originalCaster = 0); - void CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem = NULL, AuraEffect* triggeredByAura = NULL, uint64 originalCaster = 0); + void CastCustomSpell(uint32 spellId, SpellValueMod mod, uint32 value, Unit* Victim = NULL, bool triggered = true, Item *castItem = NULL, AuraEffect* triggeredByAura = NULL, uint64 originalCaster = 0); + void CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit* Victim = NULL, bool triggered = true, Item *castItem = NULL, AuraEffect* triggeredByAura = NULL, uint64 originalCaster = 0); void CastSpell(GameObject *go, uint32 spellId, bool triggered, Item *castItem = NULL, AuraEffect* triggeredByAura = NULL, uint64 originalCaster = 0); void AddAura(uint32 spellId, Unit *target); void HandleAuraEffect(AuraEffect * aureff, bool apply); |