mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[9243] Some spell rune code fixes
* Also replace check/take functions for runes by single 2 mode function * Implement proper check for dead runes case * Implement proper rune selection for Aura::HandleAuraConvertRune
This commit is contained in:
parent
546ee35953
commit
bf9cccfd5b
4 changed files with 53 additions and 69 deletions
|
|
@ -3712,7 +3712,7 @@ void Spell::TakePower()
|
||||||
|
|
||||||
if(powerType == POWER_RUNE)
|
if(powerType == POWER_RUNE)
|
||||||
{
|
{
|
||||||
TakeRunePower();
|
CheckOrTakeRunePower(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3723,7 +3723,7 @@ void Spell::TakePower()
|
||||||
m_caster->SetLastManaUse();
|
m_caster->SetLastManaUse();
|
||||||
}
|
}
|
||||||
|
|
||||||
SpellCastResult Spell::CheckRuneCost(uint32 runeCostID)
|
SpellCastResult Spell::CheckOrTakeRunePower(bool take)
|
||||||
{
|
{
|
||||||
if(m_caster->GetTypeId() != TYPEID_PLAYER)
|
if(m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||||
return SPELL_CAST_OK;
|
return SPELL_CAST_OK;
|
||||||
|
|
@ -3733,75 +3733,42 @@ SpellCastResult Spell::CheckRuneCost(uint32 runeCostID)
|
||||||
if(plr->getClass() != CLASS_DEATH_KNIGHT)
|
if(plr->getClass() != CLASS_DEATH_KNIGHT)
|
||||||
return SPELL_CAST_OK;
|
return SPELL_CAST_OK;
|
||||||
|
|
||||||
SpellRuneCostEntry const *src = sSpellRuneCostStore.LookupEntry(runeCostID);
|
SpellRuneCostEntry const *src = sSpellRuneCostStore.LookupEntry(m_spellInfo->runeCostID);
|
||||||
|
|
||||||
if(!src)
|
if(!src)
|
||||||
return SPELL_CAST_OK;
|
return SPELL_CAST_OK;
|
||||||
|
|
||||||
if(src->NoRuneCost())
|
if(src->NoRuneCost() && (!take || src->NoRunicPowerGain()))
|
||||||
return SPELL_CAST_OK;
|
return SPELL_CAST_OK;
|
||||||
|
|
||||||
int32 runeCost[NUM_RUNE_TYPES]; // blood, frost, unholy, death
|
if (take)
|
||||||
|
m_runesState = plr->GetRunesState(); // store previous state
|
||||||
for(uint32 i = 0; i < RUNE_DEATH; ++i)
|
|
||||||
runeCost[i] = src->RuneCost[i];
|
|
||||||
|
|
||||||
runeCost[RUNE_DEATH] = MAX_RUNES; // calculated later
|
|
||||||
|
|
||||||
for(uint32 i = 0; i < MAX_RUNES; ++i)
|
|
||||||
{
|
|
||||||
RuneType rune = plr->GetCurrentRune(i);
|
|
||||||
if((plr->GetRuneCooldown(i) == 0) && (runeCost[rune] > 0))
|
|
||||||
runeCost[rune]--;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(uint32 i = 0; i < RUNE_DEATH; ++i)
|
|
||||||
if(runeCost[i] > 0)
|
|
||||||
runeCost[RUNE_DEATH] += runeCost[i];
|
|
||||||
|
|
||||||
if(runeCost[RUNE_DEATH] > MAX_RUNES)
|
|
||||||
return SPELL_FAILED_NO_POWER; // not sure if result code is correct
|
|
||||||
|
|
||||||
return SPELL_CAST_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Spell::TakeRunePower()
|
|
||||||
{
|
|
||||||
if(m_caster->GetTypeId() != TYPEID_PLAYER)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Player *plr = (Player*)m_caster;
|
|
||||||
|
|
||||||
if(plr->getClass() != CLASS_DEATH_KNIGHT)
|
|
||||||
return;
|
|
||||||
|
|
||||||
SpellRuneCostEntry const *src = sSpellRuneCostStore.LookupEntry(m_spellInfo->runeCostID);
|
|
||||||
|
|
||||||
if(!src || (src->NoRuneCost() && src->NoRunicPowerGain()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_runesState = plr->GetRunesState(); // store previous state
|
|
||||||
|
|
||||||
int32 runeCost[NUM_RUNE_TYPES]; // blood, frost, unholy, death
|
int32 runeCost[NUM_RUNE_TYPES]; // blood, frost, unholy, death
|
||||||
|
|
||||||
for(uint32 i = 0; i < RUNE_DEATH; ++i)
|
for(uint32 i = 0; i < RUNE_DEATH; ++i)
|
||||||
{
|
|
||||||
runeCost[i] = src->RuneCost[i];
|
runeCost[i] = src->RuneCost[i];
|
||||||
}
|
|
||||||
|
|
||||||
runeCost[RUNE_DEATH] = 0; // calculated later
|
runeCost[RUNE_DEATH] = 0; // calculated later
|
||||||
|
|
||||||
for(uint32 i = 0; i < MAX_RUNES; ++i)
|
for(uint32 i = 0; i < MAX_RUNES; ++i)
|
||||||
{
|
{
|
||||||
RuneType rune = plr->GetCurrentRune(i);
|
RuneType rune = plr->GetCurrentRune(i);
|
||||||
if((plr->GetRuneCooldown(i) == 0) && (runeCost[rune] > 0))
|
if (runeCost[rune] <= 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(plr->GetRuneCooldown(i) == 0)
|
||||||
{
|
{
|
||||||
plr->SetRuneCooldown(i, RUNE_COOLDOWN); // 5*2=10 sec
|
if (take)
|
||||||
runeCost[rune]--;
|
plr->SetRuneCooldown(i, RUNE_COOLDOWN); // 5*2=10 sec
|
||||||
|
|
||||||
|
--runeCost[rune];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runeCost[RUNE_DEATH] = runeCost[RUNE_BLOOD] + runeCost[RUNE_UNHOLY] + runeCost[RUNE_FROST];
|
for(uint32 i = 0; i < RUNE_DEATH; ++i)
|
||||||
|
if(runeCost[i] > 0)
|
||||||
|
runeCost[RUNE_DEATH] += runeCost[i];
|
||||||
|
|
||||||
if(runeCost[RUNE_DEATH] > 0)
|
if(runeCost[RUNE_DEATH] > 0)
|
||||||
{
|
{
|
||||||
|
|
@ -3810,19 +3777,32 @@ void Spell::TakeRunePower()
|
||||||
RuneType rune = plr->GetCurrentRune(i);
|
RuneType rune = plr->GetCurrentRune(i);
|
||||||
if((plr->GetRuneCooldown(i) == 0) && (rune == RUNE_DEATH))
|
if((plr->GetRuneCooldown(i) == 0) && (rune == RUNE_DEATH))
|
||||||
{
|
{
|
||||||
plr->SetRuneCooldown(i, RUNE_COOLDOWN); // 5*2=10 sec
|
if (take)
|
||||||
runeCost[rune]--;
|
plr->SetRuneCooldown(i, RUNE_COOLDOWN); // 5*2=10 sec
|
||||||
plr->ConvertRune(i, plr->GetBaseRune(i));
|
|
||||||
|
--runeCost[rune];
|
||||||
|
|
||||||
|
if (take)
|
||||||
|
plr->ConvertRune(i, plr->GetBaseRune(i));
|
||||||
|
|
||||||
if(runeCost[RUNE_DEATH] == 0)
|
if(runeCost[RUNE_DEATH] == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// you can gain some runic power when use runes
|
if(!take && runeCost[RUNE_DEATH] > 0)
|
||||||
float rp = src->runePowerGain;;
|
return SPELL_FAILED_NO_POWER; // not sure if result code is correct
|
||||||
rp *= sWorld.getRate(RATE_POWER_RUNICPOWER_INCOME);
|
|
||||||
plr->ModifyPower(POWER_RUNIC_POWER, (int32)rp);
|
if(take)
|
||||||
|
{
|
||||||
|
// you can gain some runic power when use runes
|
||||||
|
float rp = src->runePowerGain;;
|
||||||
|
rp *= sWorld.getRate(RATE_POWER_RUNICPOWER_INCOME);
|
||||||
|
plr->ModifyPower(POWER_RUNIC_POWER, (int32)rp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return SPELL_CAST_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spell::TakeReagents()
|
void Spell::TakeReagents()
|
||||||
|
|
@ -5385,7 +5365,7 @@ SpellCastResult Spell::CheckPower()
|
||||||
//check rune cost only if a spell has PowerType == POWER_RUNE
|
//check rune cost only if a spell has PowerType == POWER_RUNE
|
||||||
if(m_spellInfo->powerType == POWER_RUNE)
|
if(m_spellInfo->powerType == POWER_RUNE)
|
||||||
{
|
{
|
||||||
SpellCastResult failReason = CheckRuneCost(m_spellInfo->runeCostID);
|
SpellCastResult failReason = CheckOrTakeRunePower(false);
|
||||||
if(failReason != SPELL_CAST_OK)
|
if(failReason != SPELL_CAST_OK)
|
||||||
return failReason;
|
return failReason;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -337,7 +337,6 @@ class Spell
|
||||||
void cast(bool skipCheck = false);
|
void cast(bool skipCheck = false);
|
||||||
void finish(bool ok = true);
|
void finish(bool ok = true);
|
||||||
void TakePower();
|
void TakePower();
|
||||||
void TakeRunePower();
|
|
||||||
void TakeReagents();
|
void TakeReagents();
|
||||||
void TakeCastItem();
|
void TakeCastItem();
|
||||||
|
|
||||||
|
|
@ -354,7 +353,7 @@ class Spell
|
||||||
SpellCastResult CheckItems();
|
SpellCastResult CheckItems();
|
||||||
SpellCastResult CheckRange(bool strict);
|
SpellCastResult CheckRange(bool strict);
|
||||||
SpellCastResult CheckPower();
|
SpellCastResult CheckPower();
|
||||||
SpellCastResult CheckRuneCost(uint32 runeCostID);
|
SpellCastResult CheckOrTakeRunePower(bool take);
|
||||||
SpellCastResult CheckCasterAuras() const;
|
SpellCastResult CheckCasterAuras() const;
|
||||||
|
|
||||||
int32 CalculateDamage(uint8 i, Unit* target) { return m_caster->CalculateSpellDamage(m_spellInfo,i,m_currentBasePoints[i],target); }
|
int32 CalculateDamage(uint8 i, Unit* target) { return m_caster->CalculateSpellDamage(m_spellInfo,i,m_currentBasePoints[i],target); }
|
||||||
|
|
|
||||||
|
|
@ -7679,22 +7679,27 @@ void Aura::HandleAuraConvertRune(bool apply, bool Real)
|
||||||
if(plr->getClass() != CLASS_DEATH_KNIGHT)
|
if(plr->getClass() != CLASS_DEATH_KNIGHT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// how to determine what rune need to be converted?
|
RuneType runeFrom = RuneType(GetSpellProto()->EffectMiscValue[m_effIndex]);
|
||||||
for(uint32 i = 0; i < MAX_RUNES; ++i)
|
RuneType runeTo = RuneType(GetSpellProto()->EffectMiscValueB[m_effIndex]);
|
||||||
|
|
||||||
|
if (apply)
|
||||||
{
|
{
|
||||||
if(apply)
|
for(uint32 i = 0; i < MAX_RUNES; ++i)
|
||||||
{
|
{
|
||||||
if(!plr->GetRuneCooldown(i))
|
if (plr->GetCurrentRune(i) == runeFrom && !plr->GetRuneCooldown(i))
|
||||||
{
|
{
|
||||||
plr->ConvertRune(i, RuneType(GetSpellProto()->EffectMiscValueB[m_effIndex]));
|
plr->ConvertRune(i, runeTo);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(uint32 i = 0; i < MAX_RUNES; ++i)
|
||||||
{
|
{
|
||||||
if(plr->GetCurrentRune(i) == RuneType(GetSpellProto()->EffectMiscValueB[m_effIndex]))
|
if(plr->GetCurrentRune(i) == runeTo && plr->GetBaseRune(i) == runeFrom)
|
||||||
{
|
{
|
||||||
plr->ConvertRune(i, plr->GetBaseRune(i));
|
plr->ConvertRune(i, runeFrom);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "9242"
|
#define REVISION_NR "9243"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue