multiple primary ammo types for a weapon

C++ Got ya down? Half-Life 2 Coding Related.
Post Reply
User avatar
dormantlemom
Polygon
Polygon
Posts: 38
Joined: Wed Mar 16, 2011 6:24 pm
Location: peterborough, england
Contact:

multiple primary ammo types for a weapon

Post 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
Image
MaestraFénix
Team Member
Team Member
Posts: 2470
Joined: Mon May 10, 2010 11:50 am
Location: Spain
Contact:

Re: multiple primary ammo types for a weapon

Post 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.
Click on my photo to add me into your friends in Steam
Image
Steam photos | Steam videos

Image
User avatar
z33ky
Former Developer
Former Developer
Posts: 69
Joined: Wed Oct 29, 2008 5:27 pm

Re: multiple primary ammo types for a weapon

Post 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.

Code: Select all

while(!bugQueue.Empty())
{
	featureList.Insert(bugQueue.Pop());
}
Post Reply