Page 1 of 1

multiple primary ammo types for a weapon

Posted: Sat Aug 06, 2011 4:16 pm
by dormantlemom
I began programming a small half life 2 singleplayer mod, and was planing on implementing the feature described in the topic title.

Basically a weapon would have multiple ammo types available for it that a player can cycle through on a button press.

So far i have implemented custom ammo types for various guns (although they arent set up to be used in the weapon scripts), and implemented a button to cycle ammo types (that doesnt actually do anything as its not assigned to any code yet). I decided that the best way to do this would be some editing and addition to BaseHlCombatWeapon.cpp, and adding additional variable things to the weapons scripts (such as adding primary_weapon2 and primary_weapon3).

I considered that in order to do this the function would work something like this (in basic terms)
Get primary ammo type.
On press for changeammo, and remaining in clip to remaining ammo, and store this value somewhere.
Switch to predefined 'next ammo type'. By implementing some way of overriding the GetPrimaryAmmo command to a new command i would write, GetNextAmmo.
Then reload.

This is in very basic terms, and i know theres a lot more code to change than just that little bit. Fortuntely lthough ammo types change, they look the same and act the same, just have different strenths and weaknesses, so changing effects and stuff arent necessary, its simply setting ammotypes on the fly.

Maybe i should rewrite the whole GetPrimaryAmmo code


On second thought, maybe this could be done simply via editing the weapon script on the fly, ie on button press set primary_ammo to the new ammo type then refreshing the ammo in the gun. I havent done much with the source engine so i dont know how it would handle something like that

Re: multiple primary ammo types for a weapon

Posted: Fri Aug 12, 2011 7:17 pm
by MaestraFĂ©nix
A multiple weapon. I like how sounds.

If you got working the energy weapons send it to the team, i want my Gluon Cannon.

Re: multiple primary ammo types for a weapon

Posted: Fri Aug 12, 2011 7:39 pm
by z33ky
Isn't it more like the ammo-system in Occupation: CS?

Anyways, the first approach sounds better to me. Rewriting and reloading the script sounds like a long route to take; adapting the current ammo code to allow different bullets with different properties doesn't sound too hard to do.