Author Sticky: Post Working Scripts Here
NWC Snake Posted: Thursday, 27 June 05:38PM
Hail! Here is a script for Temple Priests that lets them charge a PC for healing. To use it, create a conversation in which the Priest offers the PC healing services for a chosen sum of money. The PC response will trigger the script, so you want to select it as Action Taken for the PC's response, not for the Priest's offer. This script does a full heal and removes negative battle consequences, but only if the PC has enough to pay the requested price. I've also created versions that perform other types of healing services, so that the PC has a menu of choices when s/he visits the Temple for healing. This script is a modified version of an onRespawn script that is listed on pages 31-33 of the World Builder Guide.

Here's the script:

Code:
void main()

{

////////////////////////////////////////////////////

//Temple Priest Heal for Money Script: Full Healing

//Created by: NWC Snake

//Created on: June 25, 2002

////////////////////////////////////////////////////

//declare and initialize script variables

object oTarget = GetPCSpeaker();

effect eVisual = EffectVisualEffect(VFX_IMP_RESTORATION);

int bValid;

int nAmount = 5000; //Full healing is expensive!

int nMoney;

int nTalkVolume = TALKVOLUME_TALK;

string sStringToSpeak = "You don't have enough gold!";

//check to make sure PC has enough money

nMoney = GetGold(oTarget);

if(nMoney < nAmount)

{

SpeakString(sStringToSpeak, nTalkVolume);

}

else

{

//Take payment and destroy it

AssignCommand(oTarget,TakeGoldFromCreature(nAmount, oTarget,TRUE));

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_PARALYZE ||

   GetEffectType(eBad) == EFFECT_TYPE_NEGATIVELEVEL)

   {

   //remove effect if it is negative

   RemoveEffect(oTarget, eBad);

   }

   eBad = GetNextEffect(oTarget);

}

   //fire cast spell at event for specified target

   SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_RESTORATION, FALSE));

   ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual, oTarget);

   //fire healing event at specified target

   ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectHeal(GetMaxHitPoints(oTarget)), oTarget);

}

}



Happy scripting!

Your Humble Serpent,

Snake
Neverwinter Consortium