I am trying to put together a custom AoE Rez Spell.
I copied the resurrection spell and changed target type to 4:PBAE and left spell category as 27: Resurrection.
I added a Boolean to allow the server to know the spell is an AoE Rez
Code:
bool IsAERezSpell(int16 spell_id)
{
switch (spell_id)
{
case 9801:
return true;
}
return false;
}
From spells.cpp the the targeting data for the spell should be
Code:
case ST_AECaster:
{
spell_target = NULL;
ae_center = this;
CastAction = AECaster;
break;
}
Looking at AECaster
Code:
case AECaster:
case AETarget:
{
#ifdef BOTS
if(IsBot()) {
bool StopLogic = false;
if(!this->CastToBot()->DoFinishedSpellAETarget(spell_id, spell_target, slot, StopLogic))
return false;
if(StopLogic)
break;
}
#endif //BOTS
// we can't cast an AE spell without something to center it on
assert(ae_center != NULL);
if(ae_center->IsBeacon()) {
// special ae duration spell
ae_center->CastToBeacon()->AELocationSpell(this, spell_id, resist_adjust);
} else {
// regular PB AE or targeted AE spell - spell_target is null if PB
if(spell_target) // this must be an AETarget spell
{
// affect the target too
SpellOnTarget(spell_id, spell_target, false, true, resist_adjust);
}
if(ae_center && ae_center == this && IsBeneficialSpell(spell_id))
SpellOnTarget(spell_id, this);
bool affect_caster = !IsNPC(); //NPC AE spells do not affect the NPC caster
entity_list.AESpell(this, ae_center, spell_id, affect_caster, resist_adjust);
}
break;
}
So I go to entity_list.AESpell and add a few lines to have it cast the spell on corpses instead of regular mobs
Code:
void EntityList::AESpell(Mob *caster, Mob *center, int16 spell_id, bool affect_caster, sint16 resist_adjust)
{
LinkedListIterator<Mob*> iterator(mob_list);
Mob *curmob;
float dist = caster->GetAOERange(spell_id);
float dist2 = dist * dist;
bool bad = IsDetrimentalSpell(spell_id);
bool isnpc = caster->IsNPC();
const int MAX_TARGETS_ALLOWED = 4;
int iCounter = 0;
if(!IsAERezSpell(spell_id))
{
for(iterator.Reset(); iterator.MoreElements(); iterator.Advance())
{
curmob = iterator.GetData();
if(curmob == center) //do not affect center
continue;
if(curmob == caster && !affect_caster) //watch for caster too
continue;
if(center->DistNoRoot(*curmob) > dist2) //make sure they are in range
continue;
if(isnpc && curmob->IsNPC()) { //check npc->npc casting
FACTION_VALUE f = curmob->GetReverseFactionCon(caster);
if(bad) {
//affect mobs that are on our hate list, or
//which have bad faction with us
if( ! (caster->CheckAggro(curmob) || f == FACTION_THREATENLY || f == FACTION_SCOWLS) )
continue;
} else {
//only affect mobs we would assist.
if( ! (f <= FACTION_AMIABLE))
continue;
}
}
//finally, make sure they are within range
if(bad) {
if(!caster->IsAttackAllowed(curmob, true))
continue;
if(!center->CheckLosFN(curmob))
continue;
}
//if we get here... cast the spell.
if(IsTargetableAESpell(spell_id) && bad)
{
if(iCounter < MAX_TARGETS_ALLOWED)
{
caster->SpellOnTarget(spell_id, curmob, false, true, resist_adjust);
}
}
else
{
caster->SpellOnTarget(spell_id, curmob, false, true, resist_adjust);
}
if(!isnpc) //npcs are not target limited...
iCounter++;
}
}
else
{
for(iterator.Reset(); iterator.MoreElements(); iterator.Advance())
{
curmob = iterator.GetData();
bool isCorpse = curmob->IsPlayerCorpse();
if(!isCorpse)
continue;
if(center->DistNoRoot(*curmob) > dist2) //make sure they are in range
continue;
caster->SpellOnTarget(spell_id, curmob);
}
}
}
Anyone have any input for why this may not be working or any pointers on how to get it to work?