*Update castcustomspell(). Allow change other spell values than basepoints.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-04-19 00:54:01 -05:00
parent 60736b1f7d
commit 7f8cf6c5fe
4 changed files with 105 additions and 49 deletions
+26 -7
View File
@@ -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;
}
}
+18 -9
View File
@@ -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
+40 -31
View File
@@ -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;
}
CastCustomSpell(Victim,spellInfo,bp0,bp1,bp2,triggered,castItem,triggeredByAura, originalCaster);
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);
}
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, 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(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);
Spell *spell = new Spell(this, spellInfo, triggered, originalCaster );
if(bp0)
spell->m_currentBasePoints[0] = *bp0-int32(spellInfo->EffectBaseDice[0]);
if(castItem)
{
DEBUG_LOG("WORLD: cast Item spellId - %i", spellInfo->Id);
spell->m_CastItem = castItem;
}
if(bp1)
spell->m_currentBasePoints[1] = *bp1-int32(spellInfo->EffectBaseDice[1]);
for(CustomSpellValues::const_iterator itr = value.begin(); itr != value.end(); ++itr)
spell->SetSpellValue(itr->first, itr->second);
if(bp2)
spell->m_currentBasePoints[2] = *bp2-int32(spellInfo->EffectBaseDice[2]);
spell->m_CastItem = castItem;
spell->prepare(&targets, triggeredByAura);
}
+21 -2
View File
@@ -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);