//:://///////////////////////////////////////////// //:: Name corpse_spell //:: FileName //:: //::////////////////////////////////////////////// /* Responds to the onspellcastat event of the placeable. Handles the resurrection and the raise of dead creatures/PC. */ //::////////////////////////////////////////////// //:: Created By: Alexandre Brunel //:: Created On: 21/04/2003 //::////////////////////////////////////////////// #include "corpse_lib" void next2(object corpse,string script); void next1(object PC,int spell) { location moveTo = GetLocation(OBJECT_SELF); effect resurrection = EffectResurrection(); ApplyEffectToObject(DURATION_TYPE_INSTANT,resurrection,PC); object corpse = OBJECT_SELF; AssignCommand(PC,ClearAllActions(TRUE)); AssignCommand(PC,ActionJumpToLocation(moveTo)); //AssignCommand(PC,ActionDoCommand(next2(corpse,script))); AssignCommand(PC,ActionDoCommand(SetCommandable(TRUE))); AssignCommand(PC,SetCommandable(FALSE)); effect eVis = EffectVisualEffect(VFX_IMP_RAISE_DEAD); ApplyEffectAtLocation(DURATION_TYPE_INSTANT,eVis,GetLocation(OBJECT_SELF)); if(spell == SPELL_RESURRECTION) { ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(PC)),PC); } DeleteLocalObject(PC,CorpsePCCorpse); giveBackItems(PC,TRUE,TRUE,TRUE); } void next2(object corpse,string script) { object PC = OBJECT_SELF; effect death = EffectDeath(FALSE,FALSE); SetLocalObject(PC,CorpsePCCorpse,PC); ApplyEffectToObject(DURATION_TYPE_INSTANT,death,PC); //AssignCommand(corpse,SetLocalObject(OBJECT_SELF,CorpseCreatureCorpse,PC)); AssignCommand(corpse,giveBackItems(PC,TRUE,TRUE,TRUE)); AssignCommand(corpse,SetCommandable(TRUE)); //AssignCommand(corpse,ActionWait(3.0)); AssignCommand(corpse,ActionDoCommand(ExecuteScript(script,OBJECT_SELF))); //AssignCommand(corpse,ActionDoCommand(DeleteLocalObject(PC,CorpsePCCorpse))); AssignCommand(corpse,ActionDoCommand(SetCommandable(TRUE))); AssignCommand(corpse,SetCommandable(FALSE)); } void main() { int spell = GetLastSpell(); object this = OBJECT_SELF; object caster = GetLastSpellCaster(); object target = GetLocalObject(OBJECT_SELF,CorpseCreatureCorpse); object PC = GetLocalObject(target,CorpsePCCorpse); SetLocalObject(OBJECT_SELF,CorpseSpellCaster,caster); //WriteTimestampedLogEntry("Spell casted on corpse: "+IntToString(spell)); if(!GetCorpseIsNotResurectable(target) && GetLocalString(target,CorpseDeadPCLeftID) == "") { if(SPELL_RESURRECTION == spell) { if(GetIsObjectValid(PC)) { //target = PC; DestroyEquipment(target); //GetItemsInInventory(target,0,FALSE,OBJECT_INVALID,TRUE); SetCommandable(TRUE); ActionDoCommand(SetLocalObject(OBJECT_SELF,CorpseCreatureCorpse,PC)); ActionDoCommand(next1(PC,spell)); ActionDoCommand(SetCommandable(TRUE)); SetCommandable(FALSE); } else { AssignCommand(target,giveBackItems(OBJECT_SELF,TRUE,TRUE)); ExecuteScript(ResurectionScriptName,OBJECT_SELF); giveBackItems(target,TRUE,TRUE,TRUE); } } else if(SPELL_RAISE_DEAD == spell) { if(GetIsObjectValid(PC)) { //target = PC; DestroyEquipment(target); //GetItemsInInventory(target,0,FALSE,OBJECT_INVALID,TRUE); SetCommandable(TRUE); ActionDoCommand(next1(PC,spell)); ActionDoCommand(SetCommandable(TRUE)); SetCommandable(FALSE); } else { AssignCommand(target,giveBackItems(OBJECT_SELF,TRUE,TRUE)); ExecuteScript(RaiseDeadScriptName,OBJECT_SELF); giveBackItems(target,TRUE,TRUE,TRUE); } } } }