diff options
author | megamage <none@none> | 2009-04-19 00:54:01 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-04-19 00:54:01 -0500 |
commit | 7f8cf6c5fe709d73e89d3ae5a1c85fec2f4618d1 (patch) | |
tree | c789774e9786bc3eb2d398b6d7afd347b1a56138 /src | |
parent | 60736b1f7da05e5eee5100edc3e80fbb9e228495 (diff) |
*Update castcustomspell(). Allow change other spell values than basepoints.
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/game/Spell.cpp | 33 | ||||
-rw-r--r-- | src/game/Spell.h | 27 | ||||
-rw-r--r-- | src/game/Unit.cpp | 69 | ||||
-rw-r--r-- | src/game/Unit.h | 23 |
4 files changed, 104 insertions, 48 deletions
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index ee9855dea09..867d17688e4 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -274,14 +274,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; @@ -340,7 +337,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; @@ -396,6 +393,7 @@ Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 origi Spell::~Spell() { + delete m_spellValue; } void Spell::FillTargetMap() @@ -1521,7 +1519,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; if(m_originalCaster) { @@ -5431,3 +5429,24 @@ int32 Spell::CalculateDamageDone(Unit *unit, const uint32 effectMask, float *mul return damageDone; } +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 df630a33432..824450061d3 100644 --- a/src/game/Spell.h +++ b/src/game/Spell.h @@ -23,12 +23,9 @@ #include "GridDefines.h" -class WorldSession; class Unit; -class DynamicObj; class Player; class GameObject; -class Group; class Aura; enum SpellCastTargetFlags @@ -182,6 +179,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, @@ -208,10 +217,6 @@ enum SpellTargets SPELL_TARGETS_CHAINHEAL, }; -#define SPELL_SPELL_CHANNEL_UPDATE_INTERVAL 1000 - -typedef std::multimap<uint64, uint64> SpellTargetTimeMap; - class Spell { friend struct Trinity::SpellNotifierCreatureAndPlayer; @@ -383,7 +388,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; @@ -431,11 +436,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/Unit.cpp b/src/game/Unit.cpp index 218ccf1437c..70a03d75379 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -991,66 +991,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, Aura* triggeredByAura, uint64 originalCaster) +void Unit::CastCustomSpell(Unit* target, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item *castItem, Aura* triggeredByAura, uint64 originalCaster) { - SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId ); - - if(!spellInfo) - { - sLog.outError("CastCustomSpell: unknown spell id %i\n", 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, Aura* 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, Aura* triggeredByAura, uint64 originalCaster) +void Unit::CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit* Victim, bool triggered, Item *castItem, Aura* 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 f63ce4c4f23..89c0ddad86a 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -120,6 +120,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 @@ -235,7 +253,7 @@ enum InventorySlot struct FactionTemplateEntry; struct Modifier; struct SpellEntry; -struct SpellEntryExt; +struct SpellValue; class Aura; class Creature; @@ -1024,7 +1042,8 @@ class TRINITY_DLL_SPEC Unit : public WorldObject void CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0); void CastSpell(Unit* Victim,SpellEntry const *spellInfo, bool triggered, Item *castItem= NULL, Aura* 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, Aura* 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, Aura* triggeredByAura = NULL, uint64 originalCaster = 0); + void CastCustomSpell(uint32 spellId, SpellValueMod mod, uint32 value, Unit* Victim = NULL, bool triggered = true, Item *castItem = NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0); + void CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit* Victim = NULL, bool triggered = true, Item *castItem = NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0); void CastSpell(float x, float y, float z, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0); void CastSpell(GameObject *go, uint32 spellId, bool triggered, Item *castItem = NULL, Aura* triggeredByAura = NULL, uint64 originalCaster = 0); void AddAura(uint32 spellId, Unit *target); |