PlanetQuake | Code3Arena | Tutorials | << Prev | Tutorial 37 | Next >>


  • Home/News
  • ModSource
  • Compiling
  • Help!!!
  • Submission
  • Contributors
  • Staff
  • Downloads

    < Index >
    1. Mod making 101
    2. Up 'n running
    3. Hello, QWorld!
    4. Infinite Haste
    5. Armor Piercing Rails
    6. Bouncing Rockets
    7. Cloaking
    8. Ladders
    9. Favourite Server
    10. Flame Thrower
    11. Vortex Grenades
    12. Grapple
    13. Lightning Discharge
    14. Locational Damage
    15. Leg Shots
    16. Weapon Switching
    17. Scoreboard frag-rate
    18. Vortex Grenades II
    19. Vulnerable Missiles
    20. Creating Classes
    21. Scrolling Credits
    22. Weapon Dropping
    23. Anti-Gravity Boots
    24. HUD scoreboard
    25. Flashlight and laser
    26. Weapon Positioning
    27. Weapon Reloading
    28. Progressive Zooming
    29. Rotating Doors
    30. Beheading (headshot!)
    31. Alt Weapon Fire
    32. Popup Menus I
    33. Popup Menus II
    34. Cluster Grenades
    35. Homing Rockets
    36. Spreadfire Powerup
    37. Instagib gameplay
    38. Accelerating rockets
    39. Server only Instagib
    40. Advanced Grapple Hook
    41. Unlagging your mod

    < Index >
    1. Entities
    2. Vectors
    3. Good Coding
    4. Compilers I
    5. Compilers II
    6. UI Menu Primer I
    7. UI Menu Primer II
    8. UI Menu Primer III
    9. QVM Communication, Cvars, commands
    10. Metrowerks CodeWarrior
    11. 1.27g code, bugs, batch


  • Quake3 Files
  • Quake3 Forums
  • Q3A Editing Message Board
  • Quake3 Editing


  • SumFuka
  • Calrathan
  • HypoThermia
  • WarZone

    Site Design by:
    ICEmosis Design

    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:

    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) 
    	....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:

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

    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:

    void Touch_Item (gentity_t *ent, gentity_t *other, trace_t *trace) {
    	int			respawn;
    	qboolean	predict;
    	....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) )
    //              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;

    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.


    Open up the file cg_predict.c. Go to the function CG_TouchItem and ADD the lines of code in red:

    static void CG_TouchItem( centity_t *cent ) {
           gitem_t              *item;
           if ( !cg_predictItems.integer ) {
           ....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.

    PlanetQuake | Code3Arena | Tutorials | << Prev | Tutorial 37 | Next >>