a couple very minor changes to your script and now it should work saying this healing script actually does work.
checks to see if item exists (its impossible to pass "item" on start_script, thats why you passed "parms" as an array. Now "who" is that array in this script and "item" is nothing.) if the item doesnt exist, it assumes that who is an array to be broken up into the 3 parts that I used in Start_Script.
I added an if to check if you already had a patient and skipped the second targeting if you did.
Code: Select all
use uo;
use os;
use npc;
use util;
use cfgfile;
include "include/dist";
include "include/client";
include "include/res";
include "include/resPenalty";
include "include/canAccess";
include "include/attributes";
include ":poisonwatcher:poisons";
var clock := ReadGameClock();
var healing;
var Anatomy;
program use_bandages(who, item)
if (!item)
item := who[2];
patient := who[3];
who := who[1];
endif
healing := GetAttribute(who, "healing");
Anatomy := GetAttribute(who, "anatomy");
EraseObjProperty(who, "IsMeditating");
if(!can_access(who, item))
return;
endif
var Sleeptime;
if (!patient)
SendSysMessage(who, "who would you like to heal?");
var patient := Target(who, TGTOPT_HELPFUL + TGTOPT_CHECK_LOS);
endif
if(!patient)
SendSysMessage(who, "Cancelled.");
return;
endif
var poisons := ListPoisonsByType(patient, "defaultPoisons");
if(dist(who, patient) >= 2)
SendSysMessage(who, "Your patient is too far.");
return;
elseif(!CheckLineOfSight(who,patient))
SendSysMessage(who,"You can't see your patient.");
return;
elseif((GetHp(patient) >= GetMaxHp(patient)) and (poisons.size() == 0))
SendSysMessage(who,"Your patient is at full heath");
return;
endif
detach();
SetObjProperty(who, "HealTimer", clock);
// If we're dealing with a person
if((patient.graphic == 0x190) or (patient.graphic == 0x191) )
// if the patient is the doctor
If(patient == who)
if(poisons.size() > 0)
SendSysMessage(who,"You start to cure yourself.");
if(SubtractAmount(Item , 1))
cure(who, patient, 0);
return;
endif
else
SendSysMessage(who,"You start to heal yourself.");
if(SubtractAmount(Item , 1))
heal(who, patient, 0);
return;
endif
endif
//if the patient is poisoned
elseif(poisons.size() > 0)
if(patient.dead)
if((healing < 60) or (anatomy < 60))
SendSysMessage(who, "You have no chance of reviving your patient.");
else
if(SubtractAmount(Item , 1))
resurrect_pc(who, patient, 0);
endif
endif
elseif(dist(who, patient) > 1)
SendSysMessage(who, "Your patient is too far.");
elseif(!CheckLineOfSight(who, patient))
SendSysMessage(who,"You can't see you patient.");
elseif(SubtractAmount(item, 1))
if((healing < 60) or (anatomy < 60))
SendSysMessage(who, "You have no chance of curing your patient's poison.");
SendSysMessage(patient, who.name + " has stopped curing you.");
else
SendSysMessage(who,"You start to cure " + patient.name + ".");
SendSysMessage(patient,who.name + " starts to cure you.");
cure(who, patient, 0);
endif
else
SendSysMessage(who, "You cannot use those bandages.");
endif
return;
else
// routine heal
if(patient.dead)
if((healing < 80) or (anatomy < 80))
SendSysMessage(who, "You have no chance of reviving your patient.");
else
if(SubtractAmount(Item , 1))
resurrect_pc(who, patient, 0);
endif
endif
elseif(dist(who, patient) > 1)
SendSysMessage(who, "Your Patient is too far");
elseif(!CheckLineOfSight(who, patient))
SendSysMessage(who,"You cant see you patient");
elseif(SubtractAmount(item, 1))
SendSysMessage(who, "You start to heal " + patient.name);
SendSysMessage(patient, who.name + " starts to heal you");
heal(who, patient, 0);
else
SendSysMessage(who, "You cannot use those bandages.");
endif
endif
return;
//if we're dealing with a dead person
elseif(patient.dead)
if((healing < 80) or (anatomy < 80))
SendSysMessage(who, "You have no chance of reviving your patient");
elseif(!CheckLineOfSight(who,patient))
SendSysMessage(who,"You can't see your patient anymore.");
elseif(dist(who, patient) > 1)
SendSysMessage(who, "Your patient is too far.");
elseif(SubtractAmount(item, 1))
resurrect_pc(who, patient, 0);
else
SendSysMessage(who, "You cannot use those bandages.");
endif
return;
// Send the animals to vet.
elseif(patient.npctemplate)
if(dist(who, patient) >= 2)
SendSysMessage(who, "Your patient is too far.");
elseif(SubtractAmount(Item, 1))
var parms := array(patient, who);
start_script(":veterinary:vet", parms);
else
SendSysMessage(who, "You cannot use those bandages.");
endif
else
SendSysMessage(who , "You can't heal that." );
endif
endprogram
function heal(who, patient, counter)
var healamt := Cint(healing / 2) + Cint(anatomy / 5) + 10; // amount to be considered for healing
var basehealamt := healamt;
var cycles;
var count := 0;
// Determine how many attempts are made to heal.
if(patient == who)
var dexcheck := (GetBaseDexterity(who) / 20);
cycles := (15 - dexcheck);
else
if(GetDexterity(who) <= 33)
cycles := 5;
elseif(GetDexterity(who) <= 67)
cycles := 4;
else
cycles := 3;
endif
endif
// This loop has two functions:
// 1- provide wait-states for healing, during which, if it's interrupted, no healing occurs.
// 2- test for fumbles during the healing process and lower the amount of healing
// All healing occurs in the last pass of the loop.
while(counter <= cycles)
var chp := GetHP(who);
sleep(1);
if (counter%4 == 0)
SendSysMessage(patient, who.name + " continues to heal you.");
endif
// break out if anyone does anything that should cause heal to stop.
if(!GetObjProperty(who, "HealTimer"))
SendSysMessage(who, "You stop healing your patient.");
break;
elseif(clock != GetObjProperty(who, "HealTimer"))
break;
elseif(dist(who, patient) > 1)
SendSysMessage(who,"Your patient isn't close enough.");
SendSysMessage(patient, who.name + "has stopped healing you.");
break;
elseif(GetHP(patient) >= GetMaxHP(patient))
SendSysMessage(who, "Your patient is at full health.");
SendSysMessage(patient, who.name + " has stopped healing you.");
break;
elseif((patient.dead) and (patient != who))
SendSysMessage(who, "You start to resurrect " + patient.name + ".");
SendSysMessage(patient, who.name + " starts to resurrect you.");
resurrect_pc(who, patient, counter);
break;
elseif(ListPoisonsByType(patient, "defaultPoison").size() > 0)
// can't heal a patient who is poisoned.
if((healing < 60) or (anatomy < 60))
SendSysMessage(who, "You have no chance of curing your patient's poison.");
SendSysMessage(patient, who.name + " has stopped curing you.");
else
SendSysMessage(who,"You start to cure " + patient.name + ".");
if(patient != who)
SendSysMessage(patient, who.name + " starts to cure you.");
endif
cure(who, patient, counter);
endif
break;
// Testing to see if things are fumbled. If they fumble too badly,
elseif(GetHP(who) < chp)
if((RandomInt(basehealamt) + 1) >= GetDexterity(who))
SendSysMessage(who, "Your fingers slip." );
if(count >= 5)
healamt := -1;
else
healamt := (healamt * 0.90);
count := count + 1;
endif
endif
// The last cycle of the loop. All actual healing is done here.
elseif(counter >= cycles)
var diff := 100 - Cint((GetHP(patient) * 100.0) / GetMaxHP(patient));
if((CheckSkill(who, SKILLID_HEALING, diff, 0)) and (healamt != -1))
var chkamt := Cint(GetMaxHP(patient) - GetHP(patient));
if(healamt > chkamt)
healamt := chkamt;
SendSysMessage(who, "You have healed your patient completely.");
SendSysMessage(patient, who.name + " has healed you completely.");
else
SendSysMessage(who, "You successfully heal " + patient.name);
SendSysMessage(patient, who.name + " has healed you.");
endif
healdamage(patient, healamt);
AwardPoints(who, SKILLID_HEALING, (healamt * 2));
break;
else
// Throw 'em a bone. No chance of gain, though.
SendSysMessage(who,"You finish applying the bandages, but they barely help.");
SendSysMessage(patient, who.name + " has tried to healed you, but has barely helped.");
healdamage(patient, RandomInt(6));
break;
endif
endif
counter := counter + 1;
endwhile
endfunction
function cure(who, patient, counter)
var healamt := Cint(healing / 25) + Cint(anatomy / 50);
var cycles;
var count := 0;
if(patient == who)
var dexcheck := (GetBaseDexterity(who) / 33);
cycles := (15 - dexcheck);
else
if(GetBaseDexterity(who) <= 33)
cycles := 5;
elseif(GetBaseDexterity(who) <= 67)
cycles := 4;
else
cycles := 3;
endif
endif
while(counter <= cycles)
var chp := GetHP(who);
sleep(1);
if(!GetObjProperty(who, "HealTimer"))
SendSysMessage(who, "You stop healing your patient.");
SendSysMessage(patient, who.name + " has stopped healing you.");
break;
elseif(clock != GetObjProperty(who, "HealTimer"))
break;
elseif(dist(who, patient) > 1)
SendSysMessage(who, "Your patient isn't close enough.");
SendSysMessage(patient, who.name + " has stopped healing you.");
break;
elseif((patient.dead) and (patient != who))
SendSysMessage(who, "You start to resurrect " + patient.name + ".");
SendSysMessage(patient, who.name + " starts to resurrect you.");
resurrect_pc(who, patient, counter);
break;
elseif(ListPoisonsByType(patient, "defaultPoison").size() == 0)
SendSysMessage(who,"You start to heal " + patient.name + ".");
if(patient != who)
SendSysMessage(patient, who.name + " starts to heal you.");
endif
heal(who, patient, counter);
break;
elseif(GetHP(who) < chp)
if((RandomInt(100)+1) > GetBaseDexterity(who))
SendSysMessage( who, "Your fingers slip." );
healamt := (healamt - 1);
count := count + 1;
if(count >= 5)
healamt := 0;
endif
endif
endif
if(counter >= cycles)
if(CheckSkill(who, SKILLID_HEALING, 48, 0))
CurePoison(patient, 120, "defaultPoison", healamt);
if (ListPoisonsByType(patient, "defaultPoison").size() == 0)
SendSysMessage(who,"You have cured your patient completely.");
SendSysMessage(patient, who.name + " has cured you completely.");
AwardPoints(who, SKILLID_HEALING, (healamt * 100));
else
SendSysMessage(who, "You have helped but your patient is still poisoned.");
SendSysMessage(patient, who.name + " has tried to cure your poison.");
AwardPoints(who, SKILLID_HEALING, (CInt(healamt/2) * 100));
endif
break;
else
SendSysMessage ( who , "You could not heal him." );
endif
endif
counter := counter + 1;
endwhile
endfunction
function resurrect_pc(who, patient, counter)
var healamt := 90;
SendSysMessage(who,"You start to resurrect " + patient.name + ".");
SendSysMessage(patient, who.name + " starts to resurrect you.");
while(counter <= 10)
var chp := GetHP(who);
sleep(1);
if(!GetObjProperty(who, "HealTimer"))
SendSysMessage(who, "You stop reviving your patient.");
SendSysMessage(patient, who.name + " has stopped reviving you.");
break;
elseif(clock != GetObjProperty(who, "HealTimer"))
break;
elseif(dist(who, patient) > 1)
SendSysMessage(who,"Your patient isn't close enough.");
SendSysMessage(patient, who.name + "has stopped healing you.");
break;
elseif(GetHP(who) < chp)
if((RandomInt(100)+1) > GetBaseDexterity(who))
SendSysMessage(who, "Your fingers slip.");
healamt := healamt + 5;
endif
elseif(!patient.dead)
SendSysMessage(who, "You start to heal " + patient.name + ".");
if(who != patient)
SendSysMessage(patient, who.name + " starts to heal you.");
endif
heal(who, patient, counter);
break;
endif
if(counter >= 10)
if(CheckSkill(who, SKILLID_HEALING, healamt, 0))
AwardPoints(who, SKILLID_HEALING, 400);
if(do_res(who, patient))
SendSysMessage(who, "You have resurrected " + patient.name + ".");
else
SendSysMessage(who, "The patient refused resurrection." );
endif
else
SendSysMessage(who, "You could not resurrect him.");
endif
break;
endif
counter := counter + 1;
endwhile
endfunction
function do_res(who, mobile)
if(GetObjProperty(mobile, "#ResMenu"))
return 0;
else
SetObjProperty(mobile, "#ResMenu", 1);
if(ResNow(mobile) == 1)
Resurrect(mobile);
ResPenalties(mobile);
EraseObjProperty(mobile, "#ResMenu");
return 1;
else
EraseObjProperty(mobile, "#ResMenu");
return 0;
endif
endif
endfunction