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

Reply
 
Thread Tools Display Modes
  #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
  #2  
Old 07-02-2010, 06:43 PM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

I added this but I changed it to use the common focus effect calculation instead of having all that stuff hard coded.
Reply With Quote
  #3  
Old 07-02-2010, 07:38 PM
Caryatis
Dragon
 
Join Date: May 2009
Location: Milky Way
Posts: 539
Default

Thanks KLS, will be good learning to see how you implemented it properly.

edit: was this intentional?
Code:
if(MakeRandomInt(0, 1000)
I assume you meant 100?
Reply With Quote
  #4  
Old 07-02-2010, 10:15 PM
Caryatis
Dragon
 
Join Date: May 2009
Location: Milky Way
Posts: 539
Default

Also, would your way allow it proc off of a passive AA(like Gift of Mana, pyromancy, etc are)? I know my way didnt and yours doesnt seem to either, although perhaps I have the AA set incorrectly. When I get back from the weekend, I will see about adding the functionality unless you see an easy fix.
Reply With Quote
  #5  
Old 07-03-2010, 01:50 AM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

The spells that have 10% chance to proc have 100 for their base value. Also no it doesn't but we could add that. That is more a limitation of focus effects in general than how we do it this one time.
Reply With Quote
  #6  
Old 11-05-2010, 07:35 PM
Caryatis
Dragon
 
Join Date: May 2009
Location: Milky Way
Posts: 539
Default

Updated this effect. Uses bonus system as well as loading an array to track many different cast effects. Also added support for AA Spell Triggers(ie Gift of mana)... blah
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 10:17 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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3