Good Morning, I’m trying to integrate Axe’s “Killer Death System” into PRC v3.9.1.
I need to integrate the body targeting elements of this KDS script:
// Killer Death System 1 v2.2 - Spellhook script
//::///////////////////////////////////////////////
// kds1_spellhook
//::///////////////////////////////////////////////
#include "_kds1_inc"
void main()
{ object oCaster = OBJECT_SELF;
object oBody = GetSpellTargetObject();
int iSpell = GetSpellId();
if( GetIsObjectValid( oCaster) && (GetArea( oCaster) == GetArea( GetPurgatoryWaypoint( oCaster))))
{ // No spell works in purgatory.
if( GetIsPC( oCaster)) SendMessageToPC( oCaster, "Spells don't work here.");
else AssignCommand( oCaster, SpeakString( "Hmm...my spells don't work here."));
SetModuleOverrideSpellScriptFinished();
return;
}
if( GetIsObjectValid( oCaster) && GetIsObjectValid( oBody))
// A valid object was targetted by a valid caster.
if( (GetResRef( oBody) == DEAD_PC_RESREF) ||
(GetResRef( oBody) == DEAD_PC_RESREF_F) ||
(GetResRef( oBody) == DEAD_PC_ITEM_RESREF))
{ // The spell was cast at a dead PCs body on the ground or the dead PCs body item in an inventory window.
switch( iSpell)
{ case SPELL_RESURRECTION:
case SPELL_RAISE_DEAD:
{ // Find the PC linked to this body.
object oDeadPC = GetFirstPC();
while( GetIsPC( oDeadPC) && (GetLocalString( oBody, PCID_VAR) != GetPCID( oDeadPC))) oDeadPC = GetNextPC();
if( GetIsPC( oDeadPC)) // If we found him, bring him back to life.
AssignCommand( oDeadPC, ActionResRaise( oBody, iSpell));
else // Well the PC logged out -- that cheater!! I'd like to be able to take
// his death token away and send him back where he died, but since he
// couldn't wait the 3 min. he will simply not get rezzed. Inform the
// caster that his spell has had no effect. He will be punished in the
// OnClientEnter when he rejoins the module.
if( GetIsPC( oCaster))
SendMessageToPC( oCaster, "The spirit of this dead soul is wandering in planes unknown. Your spell is ineffective.");
else AssignCommand( oCaster, SpeakString( "The spirit of this dead soul is wandering in planes unknown. My spell was ineffective."));
}
break;
default: // All other spells have no effect on a dead pc.
if( GetIsPC( oCaster))
SendMessageToPC( oCaster, "Your spell has no effect.");
else AssignCommand( oCaster, SpeakString( "Hmm....my spell has no effect."));
break;
}
// Cancel the normal spell behavior since we just replaced it with custom stuff.
SetModuleOverrideSpellScriptFinished();
}
else if( GetIsPC( oBody))
// The spell was cast at a PC. If it was a Resurrection or Raise Dead spell, it
// will have no effect. These spells will now only work when cast at a dead NPC or
// a dead PCs dead-body placeable. Casting them directly on a PC will do nothing.
// This will ensure that whenever a PC dies he will always go to purgatory.
switch( iSpell)
{ case SPELL_RESURRECTION:
case SPELL_RAISE_DEAD:
if( GetIsPC( oCaster))
SendMessageToPC( oCaster, "Your spell has no effect.");
else AssignCommand( oCaster, SpeakString( "Hmm...my spell has no effect."));
SetModuleOverrideSpellScriptFinished();
break;
default: // Other spells will behave normally when cast on PCs.
break;
}
}
Into this spell script from the PRC:
/*
nw_s0_res.nss
Raise Dead, Resurrection
By: Flaming_Sword
Created: Jun 16, 2006
Modified: Jun 16, 2006
Consolidation of 2 scripts, cleaned up
*/
#include "prc_sp_func"
//Implements the spell impact, put code here
// if called in many places, return TRUE if
// stored charges should be decreased
// eg. touch attack hits
//
// Variables passed may be changed if necessary
int DoSpell(object oCaster, object oTarget, int nCasterLevel, int nEvent)
{
int nSpellID = PRCGetSpellId();
int bRes = (nSpellID == SPELL_RESURRECTION);
if (GetIsObjectValid(oTarget))
{
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, nSpellID, FALSE));
if (GetIsDead(oTarget))
{
SPApplyEffectToObject(DURATION_TYPE_INSTANT, EffectResurrection(), oTarget);
if(bRes) SPApplyEffectToObject(DURATION_TYPE_INSTANT, PRCEffectHeal(GetMaxHitPoints(oTarget) + 10, oTarget), oTarget);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_RAISE_DEAD), GetLocation(oTarget));
ExecuteScript(bRes ? "prc_pw_res" : "prc_pw_raisedead", oCaster);
if(GetPRCSwitch(PRC_PW_DEATH_TRACKING) && GetIsPC(oTarget))
SetPersistantLocalInt(oTarget, "persist_dead", FALSE);
}
else
{
if (GetObjectType(oTarget) == OBJECT_TYPE_PLACEABLE)
{
int nStrRef = GetLocalInt(oTarget,"X2_L_RESURRECT_SPELL_MSG_RESREF");
if(nStrRef == 0)
nStrRef = 83861;
if(nStrRef != -1)
FloatingTextStrRefOnCreature(nStrRef,oCaster);
}
}
}
return TRUE; //return TRUE if spell charges should be decremented
}
void main()
{
object oCaster = OBJECT_SELF;
int nCasterLevel = PRCGetCasterLevel(oCaster);
PRCSetSchool(GetSpellSchool(PRCGetSpellId()));
if (!X2PreSpellCastCode()) return;
object oTarget = PRCGetSpellTargetObject();
int nEvent = GetLocalInt(oCaster, PRC_SPELL_EVENT); //use bitwise & to extract flags
if(!nEvent) //normal cast
{
if(GetLocalInt(oCaster, PRC_SPELL_HOLD) && oCaster == oTarget)
{ //holding the charge, casting spell on self
SetLocalSpellVariables(oCaster, 1); //change 1 to number of charges
return;
}
DoSpell(oCaster, oTarget, nCasterLevel, nEvent);
}
else
{
if(nEvent & PRC_SPELL_EVENT_ATTACK)
{
if(DoSpell(oCaster, oTarget, nCasterLevel, nEvent))
DecrementSpellCharges(oCaster);
}
}
PRCSetSchool();
}
According to Stratovarius, I need to prevent the PRC script from targeting innappropriate items. Rather than muck with the PRC’s spellhook scripts, I think it would be easier to just do it directly in the spell. Unfortunately, figuring out where to put the code is above my skill level with nwscript.
Any help anyone can offer is greatly appreciated.