Skip to content

How to make the templeheal script also restore spells?

Dark_AnsemDark_Ansem Member Posts: 992
edited September 2018 in Builders - Scripting
So, here's the templeheal default script

//:://///////////////////////////////////////////// //:: Temple Cast Heal //:: NW_D1_TEMPLEHEAL.nss //:: Copyright (c) 2001 Bioware Corp. //::////////////////////////////////////////////// /* Fakes the effects of a greater restorations spell on the PC and any associates. */ //::////////////////////////////////////////////// //:: Created By: Aidan //:: Created On: May29,2002 //::////////////////////////////////////////////// void FakeRestore(object oTarget); void main() { object oPC = GetPCSpeaker(); object oHenchman = GetAssociate(ASSOCIATE_TYPE_HENCHMAN,oPC,1); object oHenchman2 = GetAssociate(ASSOCIATE_TYPE_HENCHMAN,oPC,2); object oHenchman3 = GetAssociate(ASSOCIATE_TYPE_HENCHMAN,oPC,3); object oAnimal = GetAssociate(ASSOCIATE_TYPE_ANIMALCOMPANION,oPC); object oFamiliar = GetAssociate(ASSOCIATE_TYPE_FAMILIAR,oPC); object oDominated = GetAssociate(ASSOCIATE_TYPE_DOMINATED,oPC); object oSummoned = GetAssociate(ASSOCIATE_TYPE_SUMMONED,oPC); ActionPauseConversation(); ActionCastFakeSpellAtObject(SPELL_GREATER_RESTORATION, OBJECT_SELF); ActionDoCommand(FakeRestore(oPC)); if(GetIsObjectValid(oHenchman)) { ActionDoCommand(FakeRestore(oHenchman)); // checks to see if they have any cure crital wound potions; if not, creates it on them. if (!GetIsObjectValid(GetItemPossessedBy(oHenchman,"NW_IT_MPOTION003"))) { CreateItemOnObject("NW_IT_MPOTION003",oHenchman,3); } } if(GetIsObjectValid(oHenchman2)) { ActionDoCommand(FakeRestore(oHenchman2)); // checks to see if they have any cure crital wound potions; if not, creates it on them. if (!GetIsObjectValid(GetItemPossessedBy(oHenchman2,"NW_IT_MPOTION003"))) { CreateItemOnObject("NW_IT_MPOTION003",oHenchman2,3); } } if(GetIsObjectValid(oHenchman3)) { ActionDoCommand(FakeRestore(oHenchman3)); // checks to see if they have any cure crital wound potions; if not, creates it on them. if (!GetIsObjectValid(GetItemPossessedBy(oHenchman3,"NW_IT_MPOTION003"))) { CreateItemOnObject("NW_IT_MPOTION003",oHenchman3,3); } } if(GetIsObjectValid(oAnimal)) { ActionDoCommand(FakeRestore(oAnimal)); } if(GetIsObjectValid(oFamiliar)) { ActionDoCommand(FakeRestore(oFamiliar)); } if(GetIsObjectValid(oDominated)) { ActionDoCommand(FakeRestore(oDominated)); } if(GetIsObjectValid(oSummoned)) { ActionDoCommand(FakeRestore(oSummoned)); } ActionResumeConversation(); } void FakeRestore(object oTarget) { effect eVisual = EffectVisualEffect(VFX_IMP_RESTORATION_GREATER); effect eBad = GetFirstEffect(oTarget); //Search for negative effects while(GetIsEffectValid(eBad)) { if (GetEffectType(eBad) == EFFECT_TYPE_ABILITY_DECREASE || GetEffectType(eBad) == EFFECT_TYPE_AC_DECREASE || GetEffectType(eBad) == EFFECT_TYPE_ATTACK_DECREASE || GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_DECREASE || GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_IMMUNITY_DECREASE || GetEffectType(eBad) == EFFECT_TYPE_SAVING_THROW_DECREASE || GetEffectType(eBad) == EFFECT_TYPE_SPELL_RESISTANCE_DECREASE || GetEffectType(eBad) == EFFECT_TYPE_SKILL_DECREASE || GetEffectType(eBad) == EFFECT_TYPE_BLINDNESS || GetEffectType(eBad) == EFFECT_TYPE_DEAF || GetEffectType(eBad) == EFFECT_TYPE_CURSE || GetEffectType(eBad) == EFFECT_TYPE_DISEASE || GetEffectType(eBad) == EFFECT_TYPE_POISON || GetEffectType(eBad) == EFFECT_TYPE_PARALYZE || GetEffectType(eBad) == EFFECT_TYPE_NEGATIVELEVEL) { //Remove effect if it is negative. RemoveEffect(oTarget, eBad); } eBad = GetNextEffect(oTarget); } if(GetRacialType(oTarget) != RACIAL_TYPE_UNDEAD) { //Apply the VFX impact and effects int nHeal = GetMaxHitPoints(oTarget) - GetCurrentHitPoints(oTarget); effect eHeal = EffectHeal(nHeal); // if (nHeal > 0) // ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget); // Mar 2, 2004: Always heal at least one hp. Otherwise, if you have the wounding effect // but are at max hp (because of regeneration or whatever), the wounding will not // be removed. if(nHeal<1) nHeal=1; ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget); } ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual, oTarget); }

I admit I'm stumped: I have no idea how to make it also restore spells. Any ideas?
Post edited by Dark_Ansem on

Comments

  • DazDaz Member Posts: 125
    Could probably use the ForceRest function for that.
  • Dark_AnsemDark_Ansem Member Posts: 992
    edited September 2018
    Daz said:

    Could probably use the ForceRest function for that.

    Thank you, so where should I put that? I mean where in the script, and I should probably replicate it for Pc, henchmen etc?
    Post edited by Dark_Ansem on
  • GM_ODAGM_ODA Member Posts: 177
    Add it near the end like this....


    ... ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget); } ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual, oTarget); ForceRest(oTarget); }






  • Dark_AnsemDark_Ansem Member Posts: 992
    GM_ODA said:

    Add it near the end like this....


    ... ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget); } ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual, oTarget); ForceRest(oTarget); }






    Thank you: will this cover henchmen and summoned creatures?
  • GM_ODAGM_ODA Member Posts: 177
    edited October 2018
    You are very welcome. It should work for all - the idea is, it is located in a place in the script where if all the conditions are met to be given healing, the next line will then execute too (this being your forced rest line). There is nothing in those conditionals to filter out NPCs (or henchies)... so you're good to go.
  • Dark_AnsemDark_Ansem Member Posts: 992
    GM_ODA said:

    You are very welcome. It should work for all - the idea is, it is located in a place in the script where if all the conditions are met to be given healing, the next line will then execute too (this being your forced rest line). There is nothing in those conditionals to filter out NPCs (or henchies)... so you're good to go.

    That it does, it also unsummons creatures.
Sign In or Register to comment.