Code3Arena

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

menu

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

    Tutorials
    < 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


    Articles
    < 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


    Links

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


    Feedback

  • SumFuka
  • Calrathan
  • HypoThermia
  • WarZone





    Site Design by:
    ICEmosis Design


  •  
    TUTORIAL 6 - Bouncing Rockets
    by AssKicka

    This tutorial will show you how to make rockets bounce off walls by using a console command to avtivate/deactivate the rocket bounce feature.

    1. ADD A NEW ENTITY FLAG

    Open g_local.h and add the line in red after line 32 :
    // gentity->flags
    #define	FL_GODMODE		0x00000010
    #define	FL_NOTARGET		0x00000020
    #define	FL_TEAMSLAVE		0x00000400	// not the first on the team
    #define FL_NO_KNOCKBACK		0x00000800
    #define FL_DROPPED_ITEM		0x00001000
    #define FL_NO_BOTS		0x00002000	// spawn point not for bot use
    #define FL_NO_HUMANS		0x00004000	// spawn point just for bots
    #define FL_ROCKETBOUNCE		0x00008000
    
    If you're used to working with 'flags' or 'bits' then this stuff should look familiar to you. If it looks like Greek, a bit of an explanation about 'hexadecimal numbers' and 'bitwise operators' might be useful... have a read of our article on flags'n'stuff.

    2. IMPLEMENT A 'RBOUNCE' COMMAND

    Now Open g_cmds.c and add the lines in red after line 1022 :
    /*
    =================
    Cmd_RBounce_f
    =================
    */
    void Cmd_RBounce_f( gentity_t *ent ) {
    
    	char *msg; // message to player
    
    	ent->flags ^= FL_ROCKETBOUNCE;
    
    	if (!(ent->flags & FL_ROCKETBOUNCE))
    		msg = "Rocket Bounce OFF\n";
    	else
    		msg = "Rocket Bounce ON\n";
    	trap_SendServerCommand( ent-g_entities, va("print \"%s\"", msg));
    }
    
    This allows a player to 'toggle' bouncing rockets on and off.

    Now goto line 1155 and add the lines in red :

    	else if (Q_stricmp (cmd, "setviewpos") == 0)
    	Cmd_SetViewpos_f( ent );
    	else if (Q_stricmp (cmd, "rbounce") == 0)
    	Cmd_RBounce_f( ent );
    
    This part simply catches a command that a player enters on the console (type "\rbounce", for example) and calls the function Cmd_RBounce_f(). We like to think of this part of code as our 'hook' to the outside world :)

    3. MODIFY THE ROCKET PHYSICS

    	bolt = G_Spawn();
    	bolt->classname = "rocket";
    	if (self->flags & FL_ROCKETBOUNCE)
    		bolt->nextthink = level.time + 2500;
    	else
    		bolt->nextthink = level.time + 10000;
    	bolt->think = G_ExplodeMissile;
    	bolt->s.eType = ET_MISSILE;
    	bolt->r.svFlags = SVF_USE_CURRENT_ORIGIN;
    	bolt->s.weapon = WP_ROCKET_LAUNCHER;
    	if (self->flags & FL_ROCKETBOUNCE)
    		bolt->s.eFlags = EF_BOUNCE;
    	bolt->r.ownerNum = self->s.number;
    
    The if (self->flags & FL_ROCKETBOUNCE) bit tests if the particular client has FL_ROCKETBOUNCE turned on. If so, the rocket will explode after 2.5 seconds (instead of 10). The magic part is adding EF_BOUNCE to the rocket's eFlags (which I suppose stands for 'effects flags'... browse bg_public.h line 195 for a list of all the EF_ flags).

    Re-Build your game.qvm file and enjoy !

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