Home | What's New | Communities | Contact Us  
Search:   
Home >> Computers >> Genres >> Shooter >> Quake series >> Quake 3 >> Editing >> Coding

   Q3SEEK

   Main
   About
   Playing
   Multiplay
   Console
   Technical
   Hardware
   Files
   Editing
      Modding
      Shaders
      Coding
      Mapping
      Modelling
      Skinning
      Texturing
   Cheats
   Ergonomics

   Contact


   SUBMISSIONS

   Submit Articles
   Submit News
   Submit a Site
   Submit a Bug


   HOSTED SITES

   Fightclub
   Genocidal
   LeafNode
   Q3 Bot Designer
   Q3 Post
   QUCT
   Weaponmod

 
image by Septik septik@home.com and Decayed the_decayed@hotmail.com
Coding

    Tutorial 1: Vampire Mod Tutorial

contributed by: Vulgrin

Ok, now that we've got our environment setup, its time to actually do something with it. To do this we're going to put together a VERY simple server side mod. I decided that instead of changing a weapon to shoot faster and so on, we'd start with something simple but more interesting. We're going to do a simple Vampire mod.

Vampire:
Everytime a client shoots another player and causes damage, we will give the shooter an equal amount of health back. To keep it from getting too crazy, we'll cap it off at a maximum of 500 points. Plus we'll leave in the code to slowly decrement the health back to the normal level of 100.

Project(s) involved:
game

Files(s) involved:
g_combat.c

Functions involved:
G_Damage()

There's a lot of stuff being done in G_Damage() to calculate exactly how many points of damage to be done. Since all we care about is the final number of points done, lets skip down the function to around this point:

// do the damage
if (take) {
     targ->health = targ->health - take;
     if ( targ->client ) {
         targ->client->ps.stats[STAT_HEALTH] = targ->health;
     }

     if ( targ->health <= 0 ) {
         if ( client )
            targ->flags |= FL_NO_KNOCKBACK;
         if (targ->health < -999)
            targ->health = -999;
         targ->enemy = attacker;
         targ->die (targ, inflictor, attacker, take, mod);
         return;
     } else if ( targ->pain ) {
         targ->pain (targ, attacker, take);
     }
}

take is the amount of damage that is going to be done to the target, as shown in this IF statement. Basically the line "targ->health = targ->health - take;" decrements the targets health. The next if statement checks to see if the target is a client and tells the client that it took the damage. The next IF statement then checks to see if the target is toast and to act appropriately.

So, lets add a few lines in after the client is updated and before we check to see if the target is now a chunky stew:

// Vampire mod
attacker->health = attacker->health + take;
if (attacker->health > 500) {
        attacker->health = 500;
}
// end Vampire

First thing to notice is that I wrapped my code in comments. THIS IS VERY IMPORTANT. It is my personal method to NEVER delete a line of Id's code, but rather to comment it out and put my code right next to it.

In this case we are only adding new code, so save yourself the headache later and wrapper it in comments. This will make it easier to find out what the hell you changed in a mad fit of debugging. (On an aside, I often add a comment of // ##VULGRIN around the code I change, so I have a constant string I can search for later.)

So, the bottom line is that this mod is pretty easy to code for a first time coder. We ADD the take value to the attacker's health value and then do a simple IF statement to keep the maximum health at 00. After all, we don't want any 1000 point vampire's running around our mods now do we?

Now let's actually test this puppy out. To test, we need to compile everything and run it. So, in your menu go to Build...Build qagamex86.dll. This will compile any changed files and create the DLL in your Quake III Arena directory. (Providing you set it up properly in the Prologue tutorial.)

Once the DLL is compiled, run the mod by selecting Build...Execute quake3.exe from your menu. Quake 3 should start up as normal. Go jump into a single player game and see if you can Vampire the bot. Oh, and since this is server side, and it modifies the health of ANY client that takes damage, the bots will benefit from this mod as well.

Well, that wraps up the first tutorial and setup. Keep checking back for our next tutorial or tell us about what you would like to see in future chapters of Quake 3 Coding for Utter Morons!

Post a Comment | Next Section  >> 
Related Q3Seek.com Links:

What is ANSI C?
Do you have an ANSI C Guide?
What is the Quake 3 VM (virtual machine)?
What preparations do I have to make to start compiling?
How do I compile with Microsoft Visual C?
My code wont compile, what's wrong?
Why does MSVC give me a 'not enough enviroment space' message?
Why do I get an "User interface version 4..." error?
    Tutorial Introduction
    Tutorial Prologue
    Tutorial 2: 3-Way Plasma Weapon
    Tutorial 3: Making a Laserbeam
    Tutorial 4: Model-Manager Tutorial
    Tutorial 5: Fun With Explosives
    Tutorial 6: Q3 Weapons 101
 

Related Internet Links:

The Hobgoblins Realm
Character Stats
http://www.geocities.com/TimesSquare/Realm/6249/

GameFAQs
"FAQS, walthroughs, codes and more for all video and computer games."
http://www.gamefaqs.com

GameSpot's videogames.com
"Information on Sega Saturn, Sony Playstation and Nintendo 64 video game products."
http://www.videogamespot.com

Sega (Japan)
Sega's Japanese website
http://www.sega.co.jp/

Sega (Japan)
Sega's Japanese website (english)
http://www.sega.co.jp/home_e.html

 
Not sure how to edit portions of the game? The Editing Section will help you understand how to edit all apects of the game.
Home Contact
 © 1996-2000 Seek Internet Publishing. All Rights Reserved. See our Privacy Statement