Code3Arena

PlanetQuake | Code3Arena | Tutorials | << Prev | Tutorial 2 | 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 2 - UP 'N RUNNING
    by SumFuka

    (Or, HOW TO GET THAT DAMN COMPILER TO WORK !)

    Ok, time to get our hands dirty. Visit fileplanet.com if you haven't already got the stuff below :

    • quake3 (cd)
    • Q3PointRelease_Jan1300.exe
    • Q3AGameSource.exe
    You'll also need a compiler. I highly recommend MSVC6... it's an industrial standard IDE and the game source comes with project workspaces for MSVC so that you can get started right away. If you're a student try your college bookshop for a cheap price on MSVC. Or get one from work, or whatever. We'll have "MSVC in da house" for these tutorials. (Check out the great articles 4 and 5 by HypoThermia on how to compile with other compilers).

    1. CONFIGURE MSVC

    Your system needs to be configured to run MSVC. Open your autoexec.bat. Add the following line to the end :

     C:\MICROSOFT VISUAL STUDIO\VC98\BIN\VCVARS32.BAT
    
    If your VCVARS32.BAT is located somewhere else then modify accordingly. If you haven't got a VCVARS32.BAT then re-install MSVC. Next, we need to add something to our path - this is where the tools for creating qvm's are located. Add the following line in your autoexec.bat (at the end of the file, or directly below the other lines that define your path if you want to keep it neat!) :
     SET PATH= C:\QUAKE3\BIN_NT;%PATH%
    
    Reboot.

    2. INSTALLATION

    Make sure quake3 AND the point release are installed and work fine (yes, you MUST have the point release installed... Neither Version 1.11 nor a cracked quake3.exe will work). Install to the c:\quake3 directory if you can (the Q3AGameSource only likes installing to C:\Quake3... otherwise you'll need to do some directory renaming).

    Next install the q3a source (by running Q3AGameSource.exe, DUH!). You should now see a quake3\source directory.

    3. OPEN THE PROJECT

    If you have MSVC installed then let's jump right in - double click on quake3\source\q3agame.dsw. You should see the project open in MSVC. If you're NOT using MSVC then you'll need to create your own project definition using the source files under quake3\source.

    Ok, if you're new to MSVC, here's some pointers. Click the 'FileView' tab on the left pane - you'll see a tree there. Notice that there are three projects here. 'game' is the most interesting project - it defines how the server runs the game. 'cgame' contains client code, whilst 'ui' contains stuff for the in-game user interface (e.g. menus).

    We will be making most of our modifications to the 'Source files' and 'Header files' in the 'game' project. Double click on a source file in the tree to open it in the editor window. Open some of the source files and have a browse (don't worry if they seem daunting at first!). Here's an excerpt from one of the more interesting files, g_weapon.c :

    /*
    ======================================================================
    
    ROCKET
    
    ======================================================================
    */
    
    void Weapon_RocketLauncher_Fire (gentity_t *ent) {
    	gentity_t	*m;
    
    	m = fire_rocket (ent, muzzle, forward);
    	m->damage *= s_quadFactor;
    	m->splashDamage *= s_quadFactor;
    
    //	VectorAdd( m->s.pos.trDelta, ent->client->ps.velocity, m->s.pos.trDelta );
    	// "real" physics
    }
    
    Yes, this is the code that fires a rocket every time you click mouse1! This function essentially 'passes the buck' to another function called fire_rocket. Then it adjusts the damage amount for quad. Go and find the fire_rocket function if you want to see how it works in more detail... (hint: in MSVC you can do a 'Find in Files' with 'fire_rocket' to find where the function is defined... a function definition will always have 'void' or a return type such as 'gentity_t*' in front of it... can you find it ok ?).

    4. SET THE DIRECTORY WHERE THE .DLL APPEARS

    We want the .dll to appear in our quake3\source directory. By default gamex86.dll is compiled in the quake3\source\Debug directory (which we need to change).

    Ok, still in MSVC, go to the "Project" menu and choose "Settings (ALT-F7)". Single-click on 'game' in the list of projects on the left hand side. We're going to change where the qagamex86.dll file is built. Click the "Link" tab and have a look at the "Output file name" - by default it's set to "..\Debug/qagamex86.dll". Change it to "..\qagamex86.dll".

    5. COMPILE THE PROJECT

    Ok. In MSVC, go to the "Project" menu and choose "Set Active Project -> 2 game".

    To compile the 'game' project, let's choose "Build qagamex86.dll (F7)" from the "Build" menu. MSVC will tell you the progress in the bottom pane. You should finish with "0 error(s), 0 warning(s)" (since you havent modified anything yet... right ?). The qagamex86.dll file should appear in your quake3\source directory.

    6. TEST THE .DLL

    Ok, let's run quake3\quake3.exe +set fs_game source +map q3dm1. Hit tilde (the top left key on your keyboard) and use the pageup and pagedown keys to scroll through the log... you should see a message somewhere that the .dll file was successfully found and loaded! If you see a message saying that no .dll was found then your .dll is in the wrong place... if quake can't find your .dll then obviously your mod can't run.

    7. CREATE A QVM

    A .qvm, or 'quake virtual machine' is fairly easy to create (assuming your environment was set up correctly). What is a .qvm ? I like to think of it a as a 'safe' substitute for a .dll. It's safer than a .dll because a .qvm isn't able to do nasty things that .dll's can (wipe your hard drive, for example). Not to say that they are 100% safe (remember when people broke the security on Java applets by overflowing the virtual machine's stack ??) but qvm's are certainly safer.

    Let's make a .qvm now. Open a DOS shell and go to the quake3\source\game directory. Then run game.bat. Voila - You'll see a .qvm file appear in the quake3\source\vm directory! We can run cgame.bat and ui.bat (in their respective directories) to make two more .qvm's. You can distribute these .qvm files to other people so that they can run your mod.

    Ok, now you're up and running. "Ree-spect". Now let's make our first modification...

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