PenUltima Online Forum Index Official Core: 096.7
Official Core: 097 2008-02-26
Donate towards the POL web hosting bill!
 POL Home   FAQ   Search    Memberlist   Usergroups    Register    Profile   Log in to check your private messages   Log in
Healing Command
Goto page 1, 2  Next
 
Post new topic   Reply to topic    PenUltima Online Forum Index -> General Help (095)
Display posts from previous:   

Author Message
Damien



Joined: 15 Apr 2006
Posts: 65

PostPosted: Thu Jun 22, 2006 3:54 pm    Post subject: Healing Command Reply with quote

Yay! Hello!

Of Course it don't feel good to ask for scripts...
but i need someone to help me.

So if you feel like sharing your talent with this script i would be awesome happily.
Or else just do nothing :]

The script im talking about is a command that automaticcly target bandages in your backpack and start to heal yourself.

like typing .heal (command) and you start to heal yourself.

If someone wants to share this script with me please post it here.

Code:
Thanks.

Author Message
Damien



Joined: 15 Apr 2006
Posts: 65

PostPosted: Sat Jun 24, 2006 5:18 am    Post subject: Reply with quote

Hello, this is the farest i can go.
I would appreciate if someone could help me to modify the rest.Very Happy

Code:
use uo;

program healme( who, character, text )

   var patient := Target(who);
  foreach item in EnumerateItemsInContainer(character.backpack)
    if(item.objtype == 0x0e21)
    Start_Script(":healing:dohealing", parms);
   else
SendSysMessage(who, "You don't got any bandages in your backpack." );
    endif
endforeach

endprogram


Thanks.

Author Message
CWO



Joined: 04 Feb 2006
Posts: 691
Location: Chicago, IL USA

PostPosted: Sat Jun 24, 2006 6:57 am    Post subject: Reply with quote

what params are used in the program for :healing:dohealing? I'm assuming
program healing(parms)
var who := parms[1];
var bandage := parms[2];
var patient := parms[3];

A little edit to your code (parms is passed to the script assuming what I said above is true for the program and first few lines)
Code:

use uo;
use os;

program healme(who)      // Read comment 1 below
  SendSysMessage(who, "Who do you want to heal?");
  var patient := Target(who);
  var check;
  foreach item in EnumerateItemsInContainer(who.backpack) // Comment 2
    if(item.objtype == 0x0e21)
      var parms := array{who, item, patient}; // Comment 3
      Start_Script(":healing:dohealing", parms);
      check := 1;  // Comment 4
      break; // Comment 5
    endif
  endforeach
  if (!check)
    SendSysMessage(who, "You dont have any bandages in your backpack.");
  endif
endprogram

Comments about your script: (not blasting your script, just showing you why I did some things differently)
1. Was (who, character, item) changed to (who)... Where are these coming from? You werent using them and I dont see how they would be there in the first place so no need to pass 'character' or 'item'.

2. Was character.backpack changed to who.backpack... if 'who' is healing 'patient', then why is 'character''s pack being checked Wink also removed character.

3. This variable is set assuming what I said above is exactly how your script works. If it doesnt, then please post what it says in your dohealing script.

4. Dont do if (objtype...) else SendSysMessage... Because that will do SendSysMessage... for every item in the pack thats not a bandage. Instead, I declared a variable near the beginning 'check'. It only gets set if the objtype is a bandage (its just below the start_script...). This then gets handled by the IF just after the ENDFOREACH.

5. If you only need to find one bandage and you're done, its very essential to BREAK out of the foreach. This way, after the bandange is found and the script is started, it wont still be checking the possibly 100 or so items still left in the pack it hasnt looked at yet which puts unnecessary strain on the server. It also keeps the script from being started twice if theres more than 1 stack of bandages in the pack.

Author Message
Damien



Joined: 15 Apr 2006
Posts: 65

PostPosted: Sat Jun 24, 2006 9:11 am    Post subject: Reply with quote

Code:

use uo;
use os;

program healme(who)      // Read comment 1 below
  SendSysMessage(who, "Who do you want to heal?");
  var patient := Target(who);
  var check;
  foreach item in EnumerateItemsInContainer(who.backpack) // Comment 2
    if(item.objtype == 0x0e21)
      var parms := array{who, item, patient}; // Comment 3
      Start_Script(":healing:use_bandages", parms);
      check := 1;  // Comment 4
      break; // Comment 5
    endif
  endforeach
  if (!check)
    SendSysMessage(who, "You dont have any bandages in your backpack.");
  endif
endprogram


Thanks i really appreciate your help, but now when i write .healme a Target shows up and i click myself.... fine so far.

But then nothing happends because of this :
Start_Script(":healing:use_bandages", parms);

I changed dohealing to use_bandages but it dont matter because nothing really works. Smile

My problem is to make it start heal.
I use the Healing script as you get with the POL095 core package its not modified or anything.

How should i make it start heal? Sad

I also realized after this "Code" thing been changed on forum i could post the whole healing script :]
Very nice change!
Code:

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)
   healing := GetAttribute(who, "healing");
   Anatomy := GetAttribute(who, "anatomy");
   EraseObjProperty(who, "IsMeditating");
   if(!can_access(who, item))
      return;
   endif
   var Sleeptime;
   SendSysMessage(who, "who would you like to heal?");
   var patient := Target(who, TGTOPT_HELPFUL + TGTOPT_CHECK_LOS);
   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


Hehe just wanted to use the new code thing WinkWink

Appreciate your help, Thanks.

Author Message
CWO



Joined: 04 Feb 2006
Posts: 691
Location: Chicago, IL USA

PostPosted: Sat Jun 24, 2006 10:04 am    Post subject: Reply with quote

a couple very minor changes to your script and now it should work saying this healing script actually does work.

my changes:
program use_bandages(who, item)
if (!item)
item := who[2];
patient := who[3];
who := who[1];
endif

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.

if(!patient)
SendSysMessage(who, "who would you like to heal?");
var patient := Target(who, TGTOPT_HELPFUL + TGTOPT_CHECK_LOS);
endif

I added an if to check if you already had a patient and skipped the second targeting if you did.

Code:


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

Author Message
Damien



Joined: 15 Apr 2006
Posts: 65

PostPosted: Sat Jun 24, 2006 10:37 am    Post subject: Reply with quote

Hello! Your my hero of the week.

But i do get an Error on line 20 and 20 Sad

program use_bandages(who, item)
if (!item) <-- Line 20
item := who[2];
patient := who[3]; <-- Line 22
who := who[1];
endif

And the Error looks like this:

Code:

Compiling: I:/Program/Robin/Pol/pkg/skills/healing/healing.src
Variable patient has not been declared on line 22.
Error compiling statement at I:\Program\Robin\Pol\pkg\skills\healing\healing.src
, Line 22
Error in IF statement starting at File: I:\Program\Robin\Pol\pkg\skills\healing\
healing.src, Line 20
Error compiling statement at I:\Program\Robin\Pol\pkg\skills\healing\healing.src
, Line 20
Error detected in program body.
Error occurred at I:\Program\Robin\Pol\pkg\skills\healing\healing.src, Line 22
Execution aborted due to: Error compiling file

Author Message
CWO



Joined: 04 Feb 2006
Posts: 691
Location: Chicago, IL USA

PostPosted: Sun Jun 25, 2006 2:58 am    Post subject: Reply with quote

ugh missed one thing. Put - var patient; - on the line just after the program so it looks like this...

program use_bandages(who, item)
var patient;
if (!item)
item := who[2];
patient := who[3];
who := who[1];
endif

Author Message
Damien



Joined: 15 Apr 2006
Posts: 65

PostPosted: Sun Jun 25, 2006 5:32 am    Post subject: Reply with quote

Hello and Thanks. Smile

Everything ecompile succesfully but still same problem :O
When i type the command and click myself nothing happens.

Ima post the Codes one more time. Very Happy

Code:

use uo;
use os;

program healme(who)      // Read comment 1 below

  SendSysMessage(who, "Who do you want to heal?");
  var patient := Target(who);
  var check;
  foreach item in EnumerateItemsInContainer(who.backpack) // Comment 2
    if(item.objtype == 0x0e21)
      var parms := array{who, item, patient}; // Comment 3
      Start_Script(":healing:use_bandages", parms);
      check := 1;  // Comment 4
      break; // Comment 5
    endif
  endforeach
  if (!check)
    SendSysMessage(who, "You dont have any bandages in your backpack.");
  endif
endprogram


and then the top of the healing script.

Code:

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)
var patient;
   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


I really appreciate your helpness Smile Thanks.

Author Message
CWO



Joined: 04 Feb 2006
Posts: 691
Location: Chicago, IL USA

PostPosted: Sun Jun 25, 2006 6:07 am    Post subject: Reply with quote

Are you the GM graphic (the human with the GM robe) or are you just a regular human graphic? It could possibly be that... just suspecting because this line

// If we're dealing with a person
if((patient.graphic == 0x190) or (patient.graphic == 0x191) )

wont be true if you're the GM graphic.

if((patient.graphic == 0x190) or (patient.graphic == 0x191) or (patient.graphic == 0x3DB) )

that would fix it if you were a GM graphic.

Author Message
Damien



Joined: 15 Apr 2006
Posts: 65

PostPosted: Sun Jun 25, 2006 6:46 am    Post subject: Reply with quote

Ive tried the command as a Player and as player with GM graphic.
So i think its something else Sad

Author Message
CWO



Joined: 04 Feb 2006
Posts: 691
Location: Chicago, IL USA

PostPosted: Sun Jun 25, 2006 9:04 am    Post subject: Reply with quote

You get no messages or anything?

First, try doing this in the command script:

Start_Script(":healing:use_bandages", parms);


change that to

var script := Start_Script(":healing:use_bandages", parms);
SendSysMessage(who, CStr(script));

if that doesnt give you any info (basically if this returns Error..... this is where the problem lies) , you can return it back to what it was before and go on...

next, try adding a SendSysMessage near the beginning of the use_bandages script...

program use_bandages(who, item)
var patient;
if (!item)
item := who[2];
patient := who[3];
who := who[1];
endif
SendSysMessage(who, who.name + " is healing " + patient.name + " using " + item.name);


this should give a message like

"Damien is healing CWO with bandage"

if it gives you <uninitialized object> anywhere in that sentence (which I dont see how it will since the refs seem fine) then somehow the variable isnt being passed correctly and we need to look at that a bit. Do these and see what you can find then report back what it says.

Author Message
Damien



Joined: 15 Apr 2006
Posts: 65

PostPosted: Sun Jun 25, 2006 9:32 am    Post subject: Reply with quote

This is extremely wierd:D

Still happens nothing i tried both ways you explained to me.
But when i ecompile they dont give error or anything but
still same thing, you dont start to heal.

Ive tried to heal myself and i tried to heal another player.

but nooothing Very Happy

Also this message:
SendSysMessage(who, who.name + " is healing " + patient.name + " using " + item.name);

Never shows up.

Author Message
CWO



Joined: 04 Feb 2006
Posts: 691
Location: Chicago, IL USA

PostPosted: Sun Jun 25, 2006 8:53 pm    Post subject: Reply with quote

Somehow the script isnt running... did you still put in the

var script := Start_Script(":healing:use_bandages", parms);
SendSysMessage(who, CStr(script));


what did that tell you exactly?

Author Message
Damien



Joined: 15 Apr 2006
Posts: 65

PostP