TUTORIAL 37 -
Instagib gameplay by
Malcolm Lim
This is my first tutorial for Quake 3, which is an Instagib mod tutorial, everyone's favourite game type/mod.
You can use either the old 1.17 or the new 1.27 source code for this tutorial to work.
In this tutorial, you will learn :
- How to spawn with the railgun only
- How to make the bots roam around properly without any items on the map
- How to increase the railgun's damage to a point that no one will survive a single shot
- How to make sure the railgun is not dropped once you are fragged
- How to have fun :)
Files that you need to modify :
Server Side :
- g_client.c
- g_combat.c
- g_items.c
- g_weapon.c
- bg_pmove.c
Client Side:
- cg_predict.c
Now we'll start off with g_client.c :
1. G_CLIENT.C
Go to the ClientSpawn function and go to somewhere around line # 1158 and add the lines of code in red:
/*
===========
ClientSpawn
Called every time a client is placed fresh in the world:
after the first ClientBegin, and after each respawn
Initializes all non-persistant parts of playerState
============
*/
.... some code
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_GAUNTLET );
client->ps.ammo[WP_GAUNTLET] = -1;
client->ps.ammo[WP_GRAPPLING_HOOK] = -1;
client->ps.stats[STAT_WEAPONS] = (1 << WP_RAILGUN );
client->ps.ammo[WP_RAILGUN] = 999;
.... some code
Those lines will allow you to spawn with the railgun only - and not the
usual machinegun and gauntlet - by adding an "=" sign instead of the usual "|=" (which is normally used to stack up more weapons on your inventory).
The bots don't seem to like an ammo amount of -1 when it
comes to selecting a weapon.
You can now close that file and proceed to the next step.
2. G_COMBAT.C
Open up g_combat.c and go to the TossClientItems function (around line # 56) and add the lines of code in red:
gitem_t *item;
int weapon;
float angle;
int i;
gentity_t *drop;
// drop the weapon if not a gauntlet or machinegun
weapon = self->s.weapon;
if (weapon == WP_RAILGUN)
return;
....some code
What we have done here is to make sure that the railgun is not dropped when a player is fragged. Close that file and move on.
3. G_WEAPON.C
Now open up g_weapon.c and go to the weapon_railgun_fire function (around line # 421) and MODIFY the lines of code in red:
/*
=================
weapon_railgun_fire
=================
*/
....some declarations
damage = 500 * s_quadFactor;
....some code
This line will allow the railgun to kill anyone in one shot, hence the name Instagib. Close that file and proceed to the next step.
4. BG_PMOVE.C
Open up bg_pmove.c and go to the PM_Weapon function and MODIFY the lines of code in red:
/*
==============
PM_Weapon
Generates weapon events and modifes the weapon counter
==============
*/
....some declarations and codes
// take an ammo away if not infinite
if ( pm->ps->ammo[ pm->ps->weapon ] != -1 && pm->ps->ammo[ pm->ps->weapon] != 999 ) {
m->ps->ammo[ pm->ps->weapon ]--;
}
....some code
By changing this file we have to recompile both the client and server
code (cgame and game respectively), otherwise prediction won't work properly.
This change simply allows the railgun to fire unlimited rounds. Close
that file and proceed to the last 3 steps.
5. G_ITEMS.C
Open up the file g_items.c. Go to the function Touch_Item and ADD the lines of code in red:
/*
===============
Touch_Item
===============
*/
void Touch_Item (gentity_t *ent, gentity_t *other, trace_t *trace) {
int respawn;
qboolean predict;
return;
....some code
This will ensure that you cannot pickup any items on the ground. But you will still see them right?Which leaves us to the next step...Don't close the file yet. Move on to the G_SpawnItem function and replace EVERYTHING in that function with this :
void G_SpawnItem (gentity_t *ent, gitem_t *item) {
if (item->giType != IT_TEAM)
{
G_SpawnFloat( "random", "0", &ent->random );
G_SpawnFloat( "wait", "0", &ent->wait );
// RegisterItem( item );
ent->item = BG_FindItemForWeapon( WP_MACHINEGUN );
if ( G_ItemDisabled(item) )
return;
// ent->item = item;
// some movers spawn on the second frame, so delay item
// spawns until the third frame so they can ride trains
ent->nextthink = level.time + FRAMETIME * 2;
ent->think = FinishSpawningItem;
ent->physicsBounce = 0.50; // items are bouncy
ent->s.eFlags |= EF_NODRAW;
if ( item->giType == IT_POWERUP ) {
G_SoundIndex( "sound/items/poweruprespawn.wav" );
G_SpawnFloat( "noglobalsound", "0", &ent->speed);
}
}
#ifdef MISSIONPACK
if ( item->giType == IT_PERSISTANT_POWERUP ) {
ent->s.generic1 = ent->spawnflags;
}
#endif
}
The code that you just saw was the code that will spawn an invisible machinegun on the ground. It is not there at all, but to the bots, it looks as if it's there. So with that piece of code, the bots will be able to roam around the map thinking that there is something on the ground to pickup. The commented out codes will ensure that nothing else spawns besides the invisible machinegun. Now move on to the last step.
6. CG_PREDICT.C
Open up the file cg_predict.c. Go to the function CG_TouchItem and ADD the lines of code in red:
/*
===================
CG_TouchItem
===================
*/
static void CG_TouchItem( centity_t *cent ) {
gitem_t *item;
return;
if ( !cg_predictItems.integer ) {
return;
}
....some code
This small tweak will ensure that even if the player enables item prediction (with CG_PredictItems), the sfx and icons will NOT appear when the player moves to a spot where a weapon is supposed to be there (although invisible).
We have reached the end of the Instagib Tutorial. There's of course plenty of room for future improvement. I'll leave that to your own imagination. Make sure you compile both the server and client sided files.
If you wish to use ANY part of this tutorial in your mod, please give credit to me - Malcolm Lim a.k.a CyberKewl in your credits section OR your readme file. You can reach me here. Check out my mod - Hellfire Arena.
|