Page 2 of 3

Posted: Tue Apr 05, 2005 11:14 am
by MPowell1944
Also, could I do something like self.health++ if I wanted to heal the player 1 point at a time instead of a fullheal? Then add a if(self.health == 100) check in there to see if they have been totally healed.

Posted: Tue Apr 05, 2005 11:47 am
by MPowell1944
Ok this is what I have. I changed the 70 health to 100, changed the bone to Forearm, added some stuff to the heal area, and I changed the vector_within from 100 to 25. Now, healing does not happen at all. Have a look.

Code: Select all

health_thread:
while(1)
{
   for(local.i=1;local.i<=$player.size;local.i++)
   {
     if($player[local.i].health < 100 && $player[local.i].hasmodel != 1)
     $player[local.i] thread waitheal

   }
waitframe
}
end

waitheal:
self.hasmodel = 1

self attachmodel models/items/item_100_healthbox.tik "Bip01 R Forearm"

while(self.health < 100 && isalive self)
{

   for(local.i=1;local.i<=$player.size;local.i++)
   {
      if($player[local.i] == self)
      continue

      if(vector_within $player[local.i].origin self.origin 25 && $player[local.i].useheld == 1 && 

$player[local.i].dmteam == self.dmteam)
      {

        self fullheal
	self playsound dfr_M1L2_thankyou
	$player[local.i] iprint "YOU GET FULL HEALTH FOR HEALING A TEAMMATE!"
	$player[local.i] fullheal

        break

      }
   }
  waitframe
}

self.hasmodel = 0

self removeattachedmodel "Bip01 R Forearm"

end

Posted: Wed Apr 06, 2005 12:51 am
by Grassy
and I changed the vector_within from 100 to 25. Now, healing does not happen at all. Have a look.
All looks ok, mybe 25 is too short?
Grassy

Posted: Wed Apr 06, 2005 1:50 am
by lizardkid
could I do something like self.health++

Code: Select all

self.health += 5
makes it increment by fives. be careful though, even with ++ numbers go really high really fast.

Posted: Wed Apr 06, 2005 10:09 am
by bdbodger
You can try

self heal .25 // 25%

but it breaks out of the loop after being healed so you might want to try

if(self.heath == 100)
break

instead of just break but even if you don't it will start the loop again if health is less than 100 the way you have it after breaking out of the loop

Posted: Thu Apr 07, 2005 1:41 pm
by MPowell1944
This is very weird. The script didnt work at first. Then out of nowhere it worked. I made a few changes which made it not work again. So I copied and pasted BD's script to the T, and it will not work. This is what I have as of right now.

Code: Select all

health_thread:

while(1)
{
   for(local.i=1;local.i<=$player.size;local.i++)
   {
     if($player[local.i].health < 100 && $player[local.i].hasmodel != 1)
     $player[local.i] thread waitheal

   }
waitframe
}
end

waitheal:
self.hasmodel = 1

self attachmodel models/items/item_100_healthbox.tik "Bip01 R Forearm"

while(self.health < 100 && isalive self)
{

   for(local.i=1;local.i<=$player.size;local.i++)
   {
      if($player[local.i] == self)
      continue

      if(vector_within $player[local.i].origin self.origin 25 && $player[local.i].useheld == 1 && 

$player[local.i].dmteam == self.dmteam)
      {

        self fullheal
	self playsound dfr_M1L2_thankyou
	$player[local.i] iprint "YOU GET FULL HEALTH + 1 GRENADE FOR HEALING A TEAMMATE."
	$player[local.i] fullheal
	$player[local.i] ammo grenade 1

        break

      }
   }
  waitframe
}

self.hasmodel = 0

self removeattachedmodel "Bip01 R Forearm"

end

Posted: Thu Apr 07, 2005 9:49 pm
by bdbodger
all I can see right now is that this line

Code: Select all

      if(vector_within $player[local.i].origin self.origin 25 && $player[local.i].useheld == 1 &&

$player[local.i].dmteam == self.dmteam) 
looks to be two lines and should be one line

Posted: Fri Apr 08, 2005 5:18 am
by MPowell1944
It is 1 line. Just split because of pasting it.

Posted: Fri Apr 08, 2005 7:32 am
by bdbodger
I can't seem to spot the error are you sure the error is in this thread ?

Posted: Fri Apr 08, 2005 9:51 am
by Grassy
Dont forget that it will not happen now unless both players are on the same team... :) Just a thought...
Grassy

Posted: Fri Apr 08, 2005 1:45 pm
by MPowell1944
The error is with this thread because every other script works fine in the mapscript.

Posted: Fri Apr 08, 2005 2:50 pm
by Grassy
Hmmm, this part looks like it contradicts..

for(local.i=1;local.i<=$player.size;local.i++)
{
if($player[local.i] == self) //<--this line
continue //<-- & this line

self is already established, the new $player[local.i] must be on the same team and pressing use key when inside 25 units of self..
Try remming them out and see what it does.

Posted: Fri Apr 08, 2005 2:54 pm
by MPowell1944
I already tried that. It checks to see if the newly defined local.i is the person needing health, not the person giving health. Those 2 lines are ok.

Posted: Fri Apr 08, 2005 3:40 pm
by bdbodger
for(local.i=1;local.i<=$player.size;local.i++)
{
if($player[local.i] == self) //<--this line
continue //<-- & this line
That just keeps you from healing yourself . This thread is run by all the players and in each instance of this thread self it that player who is running this thread so when you check all the players you have to skip yourself .

Posted: Fri Apr 08, 2005 6:13 pm
by MPowell1944
Is there any way that someone can test that script with another person. I can't host from my machine, or else I would do it.