Page 1 of 2

Spawnable healthpacks in CoD2

Posted: August 1st, 2010, 10:14 pm
by <LT>YosemiteSam[NL]
Waywaaaard and Rezil already helped me on this one but it doesn't seem to work.
I can "pick up" the healthpack with the script below but it doesn't give me 200 health.
I don't think the command should be maxhealth but something different (tried self.health and givehealth, but those also don't work)

Code: Select all

setupitemForPickup(item_name, item_xmodel, soundalias, delay)
{
precachemodel(item_xmodel);
   trig = getentarray("item_pickup_" +item_name,"targetname");
   org = getentarray("item_origin_" +item_name,"targetname");
   if(org.size == trig.size) //same ammount of origins and triggers, otherwise you get errors
   {
      for(i=0;i<org.size;i++)
      {
         trig[i] thread itemPickup(org[i], item_name, item_xmodel, soundalias, delay);
         
      }
   }
}

itemPickup(o, item, xmodel, sound, delay)
{

   for(;;)
{
   
      o setmodel(xmodel);
      o notsolid(); //already true, just not sure about all script_models
      self waittill("trigger", user);
      self.health = 200;
      
      o playsound("weap_pickup");    
        
      o hide();
      self maps\mp\_utility::TriggerOff();
      wait 10; //to prevent unlimited ammo while staying inside the trigger
      
      if(isdefined(delay))
         wait delay;
         
      self maps\mp\_utility::TriggerOn();
      o playsound("spawnsound");
      o show();
   }
}
Can someone help me out here, I'm at a loss :cry:

Re: Spawnable healthpacks in CoD2

Posted: August 1st, 2010, 10:42 pm
by Rezil
How do you know you don't get 200 health?

Re: Spawnable healthpacks in CoD2

Posted: August 1st, 2010, 11:11 pm
by <LT>YosemiteSam[NL]
When I pick up the healthpack I jump into the poison pool in my map and I die after almost 4 times of hitting the hurt trigger.
And that is normal with 100 health.
+ If I devmap I can set my maxhealth to 200 but still I die exactly the same as I would with 100 health.

Re: Spawnable healthpacks in CoD2

Posted: August 1st, 2010, 11:20 pm
by Rezil
Will do some testing.

Re: Spawnable healthpacks in CoD2

Posted: August 2nd, 2010, 8:45 am
by <LT>YosemiteSam[NL]
Is it maybe possible to adjust the damage you get, to half the value ?
Some sort of work around the health thing.

Re: Spawnable healthpacks in CoD2

Posted: August 2nd, 2010, 10:59 am
by waywaaaard
I am pretty sure that it works that you have 200 health. Just do some debugging and print out your current health. Before and after you picked up a healthpacket.

Re: Spawnable healthpacks in CoD2

Posted: August 2nd, 2010, 11:54 am
by <LT>YosemiteSam[NL]
ok i'll try that m8.

Re: Spawnable healthpacks in CoD2

Posted: August 2nd, 2010, 9:02 pm
by Rezil
Did testing. I was right Lev, any health above 100 gets reset to 100(you get a little breathing sound just before it resets, as though you got hurt). It works short-term though, the user just doesn't keep the health.

Re: Spawnable healthpacks in CoD2

Posted: August 2nd, 2010, 9:38 pm
by waywaaaard
hmmmm how long is the duration?

Re: Spawnable healthpacks in CoD2

Posted: August 2nd, 2010, 9:46 pm
by Rezil
Don't know, a couple of frames I assume.

Re: Spawnable healthpacks in CoD2

Posted: August 2nd, 2010, 10:12 pm
by <LT>YosemiteSam[NL]
I noticed that too but think anything of it.
Like rezil said it's just one breath...few frames not more than a second.

Btw when you open console and type /maxhealth it says 200 (if you set it to 200 hundered) but in reality it's 100...go figure

Re: Spawnable healthpacks in CoD2

Posted: August 2nd, 2010, 10:18 pm
by Rezil
I did an iprintln to print the users health the moment he gets 200 health, it does change to 200 but reverts back to 100 once I check again(different trigger).

Re: Spawnable healthpacks in CoD2

Posted: August 3rd, 2010, 10:14 am
by waywaaaard
Hm it's difficult to change the damage of weapons only for I while. (Atleast i think so) We could make a loop for 20secs that adds always 20 healthpoints to the player so it's harder to kill him.

Re: Spawnable healthpacks in CoD2

Posted: August 3rd, 2010, 11:27 pm
by <LT>YosemiteSam[NL]
That could be a good work around. I'll see i f I can figure it out.

Re: Spawnable healthpacks in CoD2

Posted: August 5th, 2010, 7:55 pm
by Rezil
Hm it's difficult to change the damage of weapons only for I while. (Atleast i think so) We could make a loop for 20secs that adds always 20 healthpoints to the player so it's harder to kill him.
20 seconds = 400 health points, too much in this case. 10 seconds with every second adding 10 health points is fine imo. But again, cod2 has regenerative health so the player would heal and the whole idea falls apart.