PDA

View Full Version : Weapon to heal


Shelnutt2
06-25-2007, 08:09 AM
OK, I'm working on a Mod for HL2 Single Player. It basically places you in the position of a doctor/medic. I know I can make a weapon that shoots a heathkit or healthpack, but I want to make it so it heals, not shoots healthpacks. Like a syringe for example, I want to make a syringe that when the player fires, you see the player inject the syringe (push it) and if the player is near an NPC it will give the NPC 10 ro 15 health point.

I haven't been able to figure it out. I tried making a weapons damage negative, but all that did was make the damage 0. I figure I'm going to have to code it from scratch, but I didn't know if anyone has done something like this before.

Marine
06-25-2007, 08:47 AM
Do a traceline in the weapons primary fire (Server side), and then if it hits a combat character (Or NPC), it adds to their health.

Shelnutt2
06-25-2007, 09:03 AM
Do a traceline in the weapons primary fire (Server side), and then if it hits a combat character (Or NPC), it adds to their health.

Ok, let me also mention this is my first time working with C++. I'm a java guy, so if you wouldn't mind explaing a little bit more in detail, I'm sure I can get it and get programming. But how exactly do I get it to add to the player's health? I get the traceline, and that will tell whether I've hit anybody or not, but I don't understand how to add health. Is that server side or client side? I'm guessing client side, since I don't see where in item_healthkit.cpp (serverside) that it adds to the players health. There could be some more commenting in the source code.

Marine
06-25-2007, 10:43 AM
Ok, let me also mention this is my first time working with C++. I'm a java guy, so if you wouldn't mind explaing a little bit more in detail, I'm sure I can get it and get programming. But how exactly do I get it to add to the player's health? I get the traceline, and that will tell whether I've hit anybody or not, but I don't understand how to add health. Is that server side or client side? I'm guessing client side, since I don't see where in item_healthkit.cpp (serverside) that it adds to the players health. There could be some more commenting in the source code.

Health is dealt server side (You can't trust the client). in your traceline,

m_pHitEnt is the entity it hit. Just do a

tr.m_pHitEnt->SetHealth(blah);

razvan252
06-25-2007, 11:30 AM
http://www.gneu.org/wiki/index.php?title=Making_a_weapon_heal_a_player

have fun...