mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07: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)
|
||||
{
|
||||
TakeRunePower();
|
||||
CheckOrTakeRunePower(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -3723,7 +3723,7 @@ void Spell::TakePower()
|
|||
m_caster->SetLastManaUse();
|
||||
}
|
||||
|
||||
SpellCastResult Spell::CheckRuneCost(uint32 runeCostID)
|
||||
SpellCastResult Spell::CheckOrTakeRunePower(bool take)
|
||||
{
|
||||
if(m_caster->GetTypeId() != TYPEID_PLAYER)
|
||||
return SPELL_CAST_OK;
|
||||
|
|
@ -3733,75 +3733,42 @@ SpellCastResult Spell::CheckRuneCost(uint32 runeCostID)
|
|||
if(plr->getClass() != CLASS_DEATH_KNIGHT)
|
||||
return SPELL_CAST_OK;
|
||||
|
||||
SpellRuneCostEntry const *src = sSpellRuneCostStore.LookupEntry(runeCostID);
|
||||
SpellRuneCostEntry const *src = sSpellRuneCostStore.LookupEntry(m_spellInfo->runeCostID);
|
||||
|
||||
if(!src)
|
||||
return SPELL_CAST_OK;
|
||||
|
||||
if(src->NoRuneCost())
|
||||
if(src->NoRuneCost() && (!take || src->NoRunicPowerGain()))
|
||||
return SPELL_CAST_OK;
|
||||
|
||||
int32 runeCost[NUM_RUNE_TYPES]; // blood, frost, unholy, death
|
||||
|
||||
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
|
||||
if (take)
|
||||
m_runesState = plr->GetRunesState(); // store previous state
|
||||
|
||||
int32 runeCost[NUM_RUNE_TYPES]; // blood, frost, unholy, death
|
||||
|
||||
for(uint32 i = 0; i < RUNE_DEATH; ++i)
|
||||
{
|
||||
runeCost[i] = src->RuneCost[i];
|
||||
}
|
||||
|
||||
runeCost[RUNE_DEATH] = 0; // calculated later
|
||||
|
||||
for(uint32 i = 0; i < MAX_RUNES; ++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
|
||||
runeCost[rune]--;
|
||||
if (take)
|
||||
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)
|
||||
{
|
||||
|
|
@ -3810,19 +3777,32 @@ void Spell::TakeRunePower()
|
|||
RuneType rune = plr->GetCurrentRune(i);
|
||||
if((plr->GetRuneCooldown(i) == 0) && (rune == RUNE_DEATH))
|
||||
{
|
||||
plr->SetRuneCooldown(i, RUNE_COOLDOWN); // 5*2=10 sec
|
||||
runeCost[rune]--;
|
||||
plr->ConvertRune(i, plr->GetBaseRune(i));
|
||||
if (take)
|
||||
plr->SetRuneCooldown(i, RUNE_COOLDOWN); // 5*2=10 sec
|
||||
|
||||
--runeCost[rune];
|
||||
|
||||
if (take)
|
||||
plr->ConvertRune(i, plr->GetBaseRune(i));
|
||||
|
||||
if(runeCost[RUNE_DEATH] == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
if(!take && runeCost[RUNE_DEATH] > 0)
|
||||
return SPELL_FAILED_NO_POWER; // not sure if result code is correct
|
||||
|
||||
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()
|
||||
|
|
@ -5385,7 +5365,7 @@ SpellCastResult Spell::CheckPower()
|
|||
//check rune cost only if a spell has PowerType == POWER_RUNE
|
||||
if(m_spellInfo->powerType == POWER_RUNE)
|
||||
{
|
||||
SpellCastResult failReason = CheckRuneCost(m_spellInfo->runeCostID);
|
||||
SpellCastResult failReason = CheckOrTakeRunePower(false);
|
||||
if(failReason != SPELL_CAST_OK)
|
||||
return failReason;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -337,7 +337,6 @@ class Spell
|
|||
void cast(bool skipCheck = false);
|
||||
void finish(bool ok = true);
|
||||
void TakePower();
|
||||
void TakeRunePower();
|
||||
void TakeReagents();
|
||||
void TakeCastItem();
|
||||
|
||||
|
|
@ -354,7 +353,7 @@ class Spell
|
|||
SpellCastResult CheckItems();
|
||||
SpellCastResult CheckRange(bool strict);
|
||||
SpellCastResult CheckPower();
|
||||
SpellCastResult CheckRuneCost(uint32 runeCostID);
|
||||
SpellCastResult CheckOrTakeRunePower(bool take);
|
||||
SpellCastResult CheckCasterAuras() const;
|
||||
|
||||
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)
|
||||
return;
|
||||
|
||||
// how to determine what rune need to be converted?
|
||||
for(uint32 i = 0; i < MAX_RUNES; ++i)
|
||||
RuneType runeFrom = RuneType(GetSpellProto()->EffectMiscValue[m_effIndex]);
|
||||
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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "9242"
|
||||
#define REVISION_NR "9243"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue