Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-02-2010, 01:42 AM
Caryatis
Dragon
 
Join Date: May 2009
Location: Milky Way
Posts: 539
Default COMMITTED: TriggerOnCast

I'm not too skilled with C++ but there are alot of spell effects I would like to see supported so here is my attempt at one.

This effect causes another spell to land at the completion of casting a spell. This is used by many spells, the enchanter Mana Flare line which adds a DD to any DD spell cast, the wizard Pyro/Cyromancy AAs that proc a snare or dot on mob after a nuke, priest AAs that make heals proc small hots, etc.

I've tested this on my server and it seems stable, however due to my complete lack of understanding of C, I'm sure it needs tweaking.

I'm not quite sure how to make those fancy diff files so please bear with me.

First I changed the GetBuffSlotFromType function from passing the type variable as an int8 to an int16 as it was not reading effects above 255.

spells - line 4436 - alter this

Code:
sint8 Mob::GetBuffSlotFromType(int8 type) {
to

Code:
sint8 Mob::GetBuffSlotFromType(int16 type) {
mob.h - line 524 - alter this

Code:
sint8	GetBuffSlotFromType(int8 type);
to

Code:
sint8	GetBuffSlotFromType(int16 type);
Then define the TriggerOnCast

mob.h - line 767 - add this
Code:
void TryTriggerOnCast(Mob* caster, Mob* spelltar, uint16 spell_id);
spells.cpp - line 3047 - add this
Code:
// Trigger on Cast Effects - restricted to single target spells that modify hps, have no duration and can use spell(so most procs don't trigger, but instant cast spells still can).
	
if(spells[spell_id].targettype == ST_Target && IsEffectHitpointsSpell(spell_id) && spells[spell_id].buffduration == 0 && CanUseSpell(spell_id, this->GetClass(), this->GetLevel())) {
		TryTriggerOnCast(this, spelltar, spell_id);
	}
spell effects.cpp - line 2820 - add this
Code:
case SE_TriggerOnCast:
			{
#ifdef SPELL_EFFECT_SPAM
				snprintf(effect_desc, _EDLEN, "Trigger on Cast: %+i", effect_value);
#endif
				// Stop the unknown spam
				break;
			}
spell effects.cpp - line 4138 - add this
Code:
void Mob::TryTriggerOnCast(Mob* caster, Mob* spelltar, uint16 spell_id)
{	
	int buffSlot = caster->GetBuffSlotFromType(SE_TriggerOnCast);
	if(buffSlot >= 0) {
		int trigger_spell = spells[buffs[buffSlot].spellid].base2[0];
                // Make sure it doesnt trigger on the trigger spell
		if(trigger_spell != spell_id) {
                        // Detrimental triggers only land on NPCs.
			if (IsDetrimentalSpell(trigger_spell) && spelltar->IsNPC()) {
				int trigger_chance = spells[buffs[buffSlot].spellid].base[0];
				if (MakeRandomFloat(0, 100) <= trigger_chance) {
					SpellOnTarget(trigger_spell, spelltar);
				}
			}
			else if (IsBeneficialSpell(trigger_spell)) {
				int trigger_chance = spells[buffs[buffSlot].spellid].base[0];
				if (MakeRandomFloat(0, 100) <= trigger_chance) {
					SpellOnTarget(trigger_spell, spelltar);
				}
			}
		}
	}
}

Last edited by Caryatis; 07-02-2010 at 02:10 AM.. Reason: fix
Reply With Quote
 


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 12:21 PM.


 

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 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3