Medic

Post your scripting questions / solutions here

Moderator: Moderators

User avatar
MPowell1944
Moderator
Posts: 287
Joined: Thu Jan 09, 2003 7:06 am
Location: Woodstock, GA
Contact:

Post 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.
User avatar
MPowell1944
Moderator
Posts: 287
Joined: Thu Jan 09, 2003 7:06 am
Location: Woodstock, GA
Contact:

Post 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
Grassy
First Lieutenant
Posts: 221
Joined: Sun Aug 22, 2004 11:36 am

Post 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
An ambiguous question will get a similar answer...
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post 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.
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post 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
Image
User avatar
MPowell1944
Moderator
Posts: 287
Joined: Thu Jan 09, 2003 7:06 am
Location: Woodstock, GA
Contact:

Post 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
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post 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
Image
User avatar
MPowell1944
Moderator
Posts: 287
Joined: Thu Jan 09, 2003 7:06 am
Location: Woodstock, GA
Contact:

Post by MPowell1944 »

It is 1 line. Just split because of pasting it.
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

I can't seem to spot the error are you sure the error is in this thread ?
Image
Grassy
First Lieutenant
Posts: 221
Joined: Sun Aug 22, 2004 11:36 am

Post by Grassy »

Dont forget that it will not happen now unless both players are on the same team... :) Just a thought...
Grassy
An ambiguous question will get a similar answer...
User avatar
MPowell1944
Moderator
Posts: 287
Joined: Thu Jan 09, 2003 7:06 am
Location: Woodstock, GA
Contact:

Post by MPowell1944 »

The error is with this thread because every other script works fine in the mapscript.
Grassy
First Lieutenant
Posts: 221
Joined: Sun Aug 22, 2004 11:36 am

Post 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.
An ambiguous question will get a similar answer...
User avatar
MPowell1944
Moderator
Posts: 287
Joined: Thu Jan 09, 2003 7:06 am
Location: Woodstock, GA
Contact:

Post 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.
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post 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 .
Image
User avatar
MPowell1944
Moderator
Posts: 287
Joined: Thu Jan 09, 2003 7:06 am
Location: Woodstock, GA
Contact:

Post 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.
Post Reply