Code3Arena

PlanetQuake | Code3Arena | Tutorials | << Prev | Tutorial 12 | 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 12 - Grapple
    by Matt Ownby

    1/15/99, 5:12 AM

    Ok the Q3 source code was just released a few hours ago and I have had my eyes pouring over the contents ever since. Fortunately, much of it is similar to Quake 2. There is also a lot of new stuff.

    As many of you know, the grappling hook was added into the code, but removed later in development. Therefore, it is just a matter of patching the code a little bit to unlock the grappling hook for general use < evil grin >. Here is a quick (very quick) tutorial on how to patch your source code to turn on the grappling hook.

    NOTE: Due to my small modifications, line numbers will be different from the stock source. All my modifications begin with "// start MATT" and "// end MATT".

    1. Modify g_client.c (part of the "game" DLL)

    Go to about line 939
     client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_GAUNTLET ); 
     // start MATT 
     client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_GRAPPLING_HOOK); 
     // end MATT 
     client->ps.ammo[WP_GAUNTLET] = -1; 
     client->ps.ammo[WP_GRAPPLING_HOOK] = -1; 
    
    Go to about line 991

      // start MATT 
      for ( i = WP_NUM_WEAPONS - 2 ; i > 0 ; i-- ) { 
       // changed the -1 to a -2 so the grapple isn't selected by default 
       // end MATT 
      
       if ( client->ps.stats[STAT_WEAPONS] & ( 1 << i ) ) { 
        client->ps.weapon = i; 
        break; 
       } 
      } 
    

    2. Modify ui_controls2.c (part of the "ui" DLL)

    Go to about line 105 and insert this value for ID_WEAPON10. The array g_bindings[] uses these values as an index for all MTYPE_ACTION controls. If they don't match their order in g_bindings[] then errors will arise.

    The remaining values need to be bumped up by one as well, to retain uniqueness.

    #define ID_CHAT3		32
    #define ID_CHAT4		33
    // start MATT 
    #define ID_WEAPON10  34  // grappling hook 
    
    // all others
    #define ID_FREELOOK		35
    #define ID_INVERTMOUSE	36
    #define ID_ALWAYSRUN	37
    #define ID_AUTOSWITCH	38
    #define ID_MOUSESPEED	39
    #define ID_JOYENABLE	40
    #define ID_JOYTHRESHOLD	41
    #define ID_SMOOTHMOUSE	42
    // end MATT 
    
    
    Go to about line 170

     menuaction_s  bfg; 
     // start MATT 
     menuaction_s  hook; 
     // end MATT 
     menuaction_s  attack; 
    
    Go to about line 245

     {"messagemode4", "chat - attacker", ID_CHAT4, ANIM_CHAT, -1, -1, -1, -1},
     // start MATT 
     {"weapon 10",  "grappling hook", ID_WEAPON10, ANIM_WEAPON10, '0',   -1,  -1, -1}, 
     // stop MATT 
     {(char*)NULL, (char*)NULL, 0, 0, -1, -1, -1, -1},
    
    Go to about line 299

     (menucommon_s *)&s_controls.bfg, 
     // start MATT 
     (menucommon_s *)&s_controls.hook, 
     // end MATT 
     NULL, 
    
    Go to about line 1386

     s_controls.bfg.generic.type      = MTYPE_ACTION; 
     s_controls.bfg.generic.flags     =
    QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; 
     s_controls.bfg.generic.callback  = Controls_ActionEvent; 
     s_controls.bfg.generic.ownerdraw = Controls_DrawKeyBinding; 
     s_controls.bfg.generic.id        = ID_WEAPON9; 
      
     // start MATT 
     s_controls.hook.generic.type      = MTYPE_ACTION; 
     s_controls.hook.generic.flags     =
    QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; 
     s_controls.hook.generic.callback  = Controls_ActionEvent; 
     s_controls.hook.generic.ownerdraw = Controls_DrawKeyBinding; 
     s_controls.hook.generic.id        = ID_WEAPON10; 
     // end MATT 
      
     s_controls.attack.generic.type     = MTYPE_ACTION; 
     s_controls.attack.generic.flags     =
    QMF_LEFT_JUSTIFY|QMF_PULSEIFFOCUS|QMF_GRAYED|QMF_HIDDEN; 
     s_controls.attack.generic.callback  = Controls_ActionEvent; 
     s_controls.attack.generic.ownerdraw = Controls_DrawKeyBinding; 
     s_controls.attack.generic.id        = ID_ATTACK; 
    
    That's it! And yes, this patch _does_ work for CTF (I tested it briefly).

    Contact Information:

    I can be found on irc.enterthegame.com in #JUN at all times, although sometimes I will obviously be away. My nick is JB[JUN]. I am not going to post my email address on this page because I am sick of getting spam every day.

    Here are other programming projects I am working on (you can get my email address from these pages hehe):

    http://daphne.rulecity.com/
    Balance of Power (look for the Quake 3 version soon muwahaha)

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