How to make a shield? Created 6 years ago2017-07-11 18:55:10 UTC by abbadon abbadon

Created 6 years ago2017-07-11 18:55:10 UTC by abbadon abbadon

Posted 6 years ago2017-07-11 18:55:10 UTC Post #335992
Hi people.

My question is simple, but let me explain myself. I want to add a secondary fire for the "crowbar" weapon on which if you press the right button you can protect yourself from damage.

How can this be done?, I have tried to make that the player turns into a hologram but it does not work, in fact, game crashed. Other intent was to make the damage when the secondary fire is pressed reurn a zero value, but it does not work either. Any ideas? :/
Posted 6 years ago2017-07-11 19:42:19 UTC Post #335993
Haven't been coding too much for Half-Life so I can't really help you with it, but I always was curious how they did that in counter-strike. Perhaps their shield had a hitbox on model and it had invincibility like g-man?

(As I said, never been coding too much fo HL, that's only my most probably hacky pondering).
Posted 6 years ago2017-07-11 19:46:33 UTC Post #335994
Yes, I think of that, I made a big HitBox in the qc file, but what I have obtained is the thirdperson camera worked bad. :(
Posted 6 years ago2017-07-12 16:21:29 UTC Post #335997
You have 2 methods :

A) Counter-Strike method: you add a hitbox in "player.mdl", reference it in the code, and each time a trace attack is done, you check the hitbox being hit and nullify the damage. You can apply other conditions as well (damage type for example).

B) Code method (used for the Cavalry Saber in Half-Rats: Parasomnia): have a variable on the weapon (in your case the crowbar) called "m_bBlocking" and update it accordingly. Each time the player is hurt, check if the attacker is facing the victim AND if the victim's weapon is the crowbar AND check if that blocking variable is true.

EDIT : if you choose method A, look at "CBarney::TraceAttack", shooting his helmet "nullify" the damage done and play some extra effect.
Posted 6 years ago2017-07-12 20:30:20 UTC Post #335999
Will try, thanks!! :)
Posted 6 years ago2017-07-13 02:42:30 UTC Post #336006
theres a mod with a barney that holds a shield, coincidentally. It's pretty cool. Theres also a model of the human grunt with a shield too
Posted 6 years ago2017-07-14 09:24:45 UTC Post #336025
Is there the sourcecode for that? :|
You must be logged in to post a response.