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);
}
}
}
}
}