Coding the InputFireUser1 command

Grab your favourite IDE and tinker with the innards of game engines

Coding the InputFireUser1 command

Postby darendal on Tue Jan 25, 2011 8:30 pm

I've been trying to give the pistol in Half-Life 2 the ability to light enemies on fire, like you can do in the console with the ignite command.

I did some digging in the source code, and I think I can do this by passing a command to a point_clientcommand by way of a InputFireUser1 command I add into the code for the pistols PrimaryFire(). However, despite my best efforts, I really can't understand what to do. Anybody know how to make this work, or better yet, an easier way to ignite enemies on fire that wouldn't use the console?
darendal
Dumpling
Dumpling
 
Joined: Tue Jan 25, 2011 8:25 pm

Re: Coding the InputFireUser1 command

Postby zombie@computer on Tue Jan 25, 2011 8:56 pm

change bullet damage to burn ?
When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Re: Coding the InputFireUser1 command

Postby darendal on Tue Jan 25, 2011 8:58 pm

Does that actually ignite enemies, or just deal damage over time or something?

Also, assuming it DOES ignite, how do I change the ammo type to do that?
darendal
Dumpling
Dumpling
 
Joined: Tue Jan 25, 2011 8:25 pm

Re: Coding the InputFireUser1 command

Postby zombie@computer on Tue Jan 25, 2011 10:29 pm

def.AddAmmoType("Pistol", DMG_BULLET, TRACER_LINE_AND_WHIZ, "sk_plr_dmg_pistol", "sk_npc_dmg_pistol", "sk_max_pistol", BULLET_IMPULSE(200, 1225), 0 );

becomes

def.AddAmmoType("Pistol", DMG_BURN, TRACER_LINE_AND_WHIZ, "sk_plr_dmg_pistol", "sk_npc_dmg_pistol", "sk_max_pistol", BULLET_IMPULSE(200, 1225), 0 );


in hl2_gamerules.cpp
When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Re: Coding the InputFireUser1 command

Postby darendal on Wed Jan 26, 2011 1:55 am

Changing the ammo type doesn't make the NPC light on fire, so my problem still stands...

Thanks for the advice though! Now I know how to change the damage type, which is something else I had been wondering about
darendal
Dumpling
Dumpling
 
Joined: Tue Jan 25, 2011 8:25 pm

Re: Coding the InputFireUser1 command

Postby zombie@computer on Wed Jan 26, 2011 10:55 am

well, it works fine for me. Zombies burn like gasoline, no problem. Or do you want to burn other npcs?
When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Re: Coding the InputFireUser1 command

Postby darendal on Wed Jan 26, 2011 3:55 pm

I wanted to burn just about any NPC that has an ignite command in the console, like Combine soldiers, civilians, etc
darendal
Dumpling
Dumpling
 
Joined: Tue Jan 25, 2011 8:25 pm

Re: Coding the InputFireUser1 command

Postby zombie@computer on Wed Jan 26, 2011 4:13 pm

then id study CNPC_BaseZombie::OnTakeDamage_Alive and take the usefull bits of code and move them to CAI_BaseNPC's OnTakeDamage_Alive, though you have to be wary of npcs that derive from CAI_BaseNPC and have their own ontakedamage_alive methods.
When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Re: Coding the InputFireUser1 command

Postby darendal on Wed Jan 26, 2011 6:41 pm

OK, I've changed the pistol to deal DMG_BURN, but I still can't light NPC's on fire, even with the code I've ripped from CNPC_BaseZombie. Hell, it won't even light zombies on fire

Is it possible my mod's not using the code I've edited, but just the default code?

I've been running the code straight through Visual Studios, and then changing to a test map using the developer console, if that changes anything
darendal
Dumpling
Dumpling
 
Joined: Tue Jan 25, 2011 8:25 pm

Re: Coding the InputFireUser1 command

Postby zombie@computer on Wed Jan 26, 2011 7:04 pm

set a few breakpoints (eg in a constructor of a used entity) and you'll soon find out...
When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Re: Coding the InputFireUser1 command

Postby darendal on Fri Jan 28, 2011 6:35 am

OK, so I had a few other problems that I finally got set right, and I found an Ignite command that would do exactly what I wanted, and added it to CAI_BaseNPC's OnTakeDamage_Alive method where I wanted it, but combine soldiers still don't light...

Don't suppose you'd have any idea where their OnTakeDamage command is?

Either way, thanks a ton for the help! At the very least, I'm now on a faaaaar easier track for lighting enemies on fire that wouldn't involve all sorts of crazy coding!
darendal
Dumpling
Dumpling
 
Joined: Tue Jan 25, 2011 8:25 pm

Return to Programming

Who is online

Users browsing this forum: No registered users