PDA

View Full Version : Growing spells


Scorpious2k
01-20-2016, 09:17 PM
Since jpyou127 asked how it is done, I thought I would explain. It's not that complicated, really.

I'll start with an explanation. On our server, all custom code is bracketed with #ifdef SCORPIOUS2K / #else / #endif which makes it easier to find and maintain.

To start with, I added the following function to spell_effects.cpp
#ifdef SCORPIOUS2K
// make spells friendlier - adjust for class/grow with level
int32 AdjustEffectForGrowth(int32 dmg, Mob* caster, int16 spellid)
{

// printf("adjusting effect for class\n");
if (caster->IsNPC() && caster->GetOwnerID() == 0)
{
// printf("IsNPC\n");
return dmg;
}

// make spells grow starting at level when they can get the spell
int caster_level = caster->GetLevel() - (int)spells[spellid].classes[caster->GetClass() - 1];
if (caster_level < 1)
{ // probably a clicky
caster_level = caster->GetLevel() / 6;
}

int tmp;
if (caster->GetCasterClass() != 'N')
{
// printf("Caster class: ");
if (caster->IsWarriorClass())
{ // hybrid
// printf("hybrid\n");
tmp = (dmg*(100 + caster_level)) / 100;
}
else
{ // pure caster
// printf("pure\n");
tmp = (dmg*(100 + (caster_level * 2))) / 100;
}
}
else
{ // melee
// printf("Melee class\n");
tmp = (dmg*(100 + (caster_level / 3))) / 100;

}
if (tmp>24000)
{
tmp = 24000 - (tmp % 1000) + (caster_level * 2);
}

return tmp;

}
#endif


Then all you have to do is add the function calls to Mob::SpellEffect, for example

case SE_CurrentHP: // nukes, heals; also regen/dot if a buff
{
#ifdef SPELL_EFFECT_SPAM
snprintf(effect_desc, _EDLEN, "Current Hitpoints: %+i", effect_value);
#endif
// SE_CurrentHP is calculated at first tick if its a dot/buff
if (buffslot >= 0)
break;

// for offensive spells check if we have a spell rune on
int32 dmg = effect_value;
if(dmg < 0)
{
if (!PassCastRestriction(false, spells[spell_id].base2[i], true))
break;

// take partial damage into account
dmg = (int32) (dmg * partial / 100);

//handles AAs and what not...
if(caster) {
dmg = caster->GetActSpellDamage(spell_id, dmg, this);
caster->ResourceTap(-dmg, spell_id);
}

#ifdef SCORPIOUS2K
// growing spells
dmg = AdjustEffectForGrowth(dmg, caster, spell_id);
#endif

dmg = -dmg;


that one line makes HP changes of the SE_CurrentHP type grow based upon the spell, it's req level, and the current level of the castor.

Like I said. Simple.

jpyou127
01-21-2016, 09:37 AM
Thank you sir! Going to give this a shot!


Celestial