Go Back   EQEmulator Home > EQEmulator Forums > Development > Development: Custom Code

Development: Custom Code This is for code thatdoes not emulate live and wont be added to the official code.

Reply
 
Thread Tools Display Modes
  #1  
Old 01-20-2016, 09:17 PM
Scorpious2k's Avatar
Scorpious2k
Demi-God
 
Join Date: Mar 2003
Location: USA
Posts: 1,067
Default Growing spells

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
Code:
#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

Code:
			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.
__________________
Maybe I should try making one of these servers...
Reply With Quote
  #2  
Old 01-21-2016, 09:37 AM
jpyou127's Avatar
jpyou127
Discordant
 
Join Date: Nov 2005
Posts: 270
Default

Thank you sir! Going to give this a shot!


Celestial
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 11:49 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3