Half-Life FlatLine Arena is fast paced first person multiplayer action. The mod has been in development for more than 12 years now. With the release always around the corner, but the time always not being sufficient and the jobs to be done piling up. Never the less I decided to create the page for it and to show the world it exists.

Post tutorial Report RSS Adding New ammo_charge & Separating the ammo for Egon and Gauss in Half-Life 1

I this tutorial I will show you how to create new consumable ammo in Half-Life 1, then how to use it for the ammo for the HL1 weapon Egon. In other words, the egon and gauss will no longer share ammo, thus you can have gauss depleted, but still have egon.

Posted by on - Intermediate Server Side Coding

Adding New ammo_charge & Separating the ammo for Egon and Gauss in Half-Life 1

Some initial words before we start with the fun pat. I always wanted to have separate ammo counters for Egon and Gauss (and Displacer in OP4). It was always annoying that the 2 (3) weapons would all use uranium and get depleted at the same time. Not fun right?

Well, I decided to write a quick tutorial on creating new ammo, and then for the fun of it to separate the Gauss and Egon ammo usage.


ammo charge

Let's the fun begin, now:

Open cbase.h, look for "int ammo_uranium;", and after it add:

int ammo_charge;

I will use this ammo later on for the Egon, that's why I called it charge.

then go to client.cpp look for:

"cd->ammo_rockets = pl->ammo_rockets;"

After it add:

cd->vuser2.y = pl->ammo_charge;


we can also do it like this, the look for:

if ( pl->m_pActiveItem->m_iId == WEAPON_RPG )

the add after the full is statement, another one looking like this:

else if( pl->m_pActiveItem->m_iId == WEAPON_EGON )
{
cd->vuser2.y = pl->ammo_charge;
}

Important: You need to do it either the first or the second way.. you can not have them both ways defined... I hope you understand what I mean, I added this one for completion sake.


Now, go to player.cpp and look for:

ammo_hornets = AmmoInventory( GetAmmoIndex( "Hornets" ) );

add after it:

ammo_charge = AmmoInventory( GetAmmoIndex( "Charge" ) );

now in the same file looking for:

GiveNamedItem( "weapon_tripmine" );

after it add:

GiveNamedItem( "ammo_charge" );

This will add the new ammo under impulse 101 (It's optional, but I know you ;like to cheat...)

now go to weapons.cpp and after:

UTIL_PrecacheOther( "ammo_9mmclip" );

add:

// ammo_charge
UTIL_PrecacheOther( "ammo_charge" );

The next thing we need to do is in weapons.h look for:

#define HIVEHAND_DEFAULT_GIVE 8

after it add add:

#define CHARGE_DEFAULT_GIVE 30

now go to:

#define M203_GRENADE_MAX_CARRY 10

after it add:

#define CHARGE_MAX_CARRY 200

This is the number of pickup ammo the player can have.

Another optional thing would be to add it to func_break.cpp; still I will show you how to add it to the map anyway, so feel free to skip. If you decide to use, make sure it's alleyways the last number, and not overriding another one.

Side note: I'm not sure how many entries this one can have, so use it with caution...

So look for:

const char *CBreakable::pSpawnObjects[] =

then add it as last entry, in my situation it's like this:

"weapon_hornetgun", // 21


Then I add:

"ammo_charge", // 22

All with the new ammo is done. Now we need to modify the weapon code to use it properly.

We also have to add the clip for it.

Now open egon.cpp; all the way at the bottom add:

class CChargeAmmo : public CBasePlayerAmmo
{
void Spawn( void )
{
Precache( );
// TODO: change the model
SET_MODEL(ENT(pev), "models/w_chainammo.mdl");
CBasePlayerAmmo::Spawn( );
}
void Precache( void )
{
// TOD: change the model
PRECACHE_MODEL ("models/w_chainammo.mdl");
PRECACHE_SOUND("items/9mmclip1.wav");
}
BOOL AddAmmo( CBaseEntity *pOther )
{
if (pOther->GiveAmmo( CHARGE_DEFAULT_GIVE, "Charge", CHARGE_MAX_CARRY ) != -1)
{
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM);
return TRUE;
}
return FALSE;
}
};
LINK_ENTITY_TO_CLASS( ammo_charge, CChargeAmmo );

Now, look for:

int CEgon::GetItemInfo(ItemInfo *p)

In here we need to change few things:

p->pszAmmo1 = "uranium";

should be:

p->pszAmmo1 = "Charge";

then this:

p->iMaxAmmo1 = URANIUM_MAX_CARRY;

should be:

p->iMaxAmmo1 = CHARGE_MAX_CARRY;

Go and compile both client and server. There should be no errors or warnings as a result of this modification.

As added bonus, you can add the new ammo to your fgd. Here's the entry, add it after this entry, and don't forget those add the correct model, if you have edited it in the code:

]
@PointClass base(Weapon, Targetx, RenderFields) studio("models/w_gaussammo.mdl") = ammo_gaussclip : "Gauss Gun Ammo"
[

Entry for the new ammo:

]
@PointClass base(Weapon, Targetx, RenderFields) studio("models/w_chainammo.mdl") = ammo_charge : "Egon Charge Ammo"
[

Now if you fire the game, and give yourself the Egon, you will notice that the gun uses different ammo than the Gauss.

Well, this should be it. Now you have separated ammo for Gauss and Egon.

Here's how it will look like ingame:

20220306181857 1

20220306181847 1

For the second tutorial, I will show you how to create new bullet type, and then how to separate the Glock from MP5.

Have fun. Kids.

If you don't like something - Mod it!

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: