News: SMF - Just Installed!
 
Welcome, Guest. Please login or register.
+  AnthraxBio
|-+  Quake 3
| |-+  Coding Tutorials
| | |-+  HOW TO MAKE A SMALL MOD
« previous next »
Pages: [1] Print
Author Topic: HOW TO MAKE A SMALL MOD  (Read 579 times)
SkreamerVirii
Administrator
Full Member
*****
Posts: 133


View Profile
« on: October 01, 2008, 10:53:01 PM »

Getting your code up and running and adding player classes.



(Important)
(DO NOT COPY AND PASTE THIS CODE IN THIS TUTORIAL OR IT MAY NOT COMPILE)


red is the code im adding along with important notes and file names
green is the code that you either need to replace or its original code(same thing)
purple is my thoughts


I'm not one to talk about what i am going to do unless details are truly needed this is my first tutorial
so im going to start off with the basics.
How to get msvc 6.0 to compile your code and use the qvm method to optimise it so we can run our mod in the q3 game it self
*plus add new player classes to the mod and use them*.

(STEP ONE)
A)goto your startbar click it
B) click run a dialogue box pops up
C) type msconfig for the path name, a dialogue box will pop up
D)click the config.sys tab(its the second tab on the left)

 

E)click the New button and put this in in the box
shell = C:\COMMAND.COM C:\ /E:2048 /P
this will allow you to have enough enviroment space to compile the qvms further down the road
"then reboot your machine"
 


(Make sure you installed quake3 the game at the foot of your directory
c:/quake3/ or
d:/quake3/
whatever suits your needs)
(or you will get errors)

(STEP TWO)
A) Now go into your quake3 directory and right click
B) click new
C) then click new folder
D) Rename the folder to what you want your mod to be called, something like this
   D:\Quake3\testmod1
E) Inside the testmod1 folder create a new folder call it vm to place your compiled qvm's in
   D:\Quake3\testmod1\vm

(STEP THREE)

A) Now go ahead and install the quake3 source
(when you install the source
it will automatically install in to the quake3/source directory)

B) Now open up the bin_nt directory (its in the quake3 folder)

C) Copy both the lcc and q3asm programs

D) Now go into the the source folder
and clik on the game folder, then in the game/vm/ folder paste those files into that folder.

Repeat this process with the cgame and ui folder.
 
(if you donot do this then you wont be able to compile the qvms
after you do this copy the source folder and paste it somewhere safe like on your desktop
so you can have a back up of the folder and not have to go thru the whole process of reinstalling the source)

(STEP FOUR)

A)Now go into the source folder in your quake 3 folder and double clik on the quake3.dsw icon this will load the q3 source
enviroment workspace into the msvc compiler.
(NOTES)
if i tell you to search for something like a function
then just copy what i want you to find then go into msvc
and find the binoculars  and clik on them)
 
this is the screen you want when you clik the binoculars
 
hmmm
also make sure you you clik the project tab on the top tool bar
 
and go to set active project and make sure game is selected
 
and none of the others
You only select the others when you mess with that folder and you need to compile it)

OK!
Lets do something fancy, yet simple, for all you newbies out there.

Were going to make Playerclasses ala q3f .
We will just make one class and you can figure out the rest
for adding more.


B) First open up g_local.h if you cant find it then clik the headers folder(check the file view tab on the bottom left hand corner
 and its in there
 
after you open up this file scroll down a bit and find this

#define   FL_GODMODE               0x00000010
#define   FL_NOTARGET               0x00000020
#define   FL_TEAMSLAVE                        0x00000400   // not the first on he 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
 
C) Right under these defintions we are going to create our own definition
so type this

#define FL_MYGUY 1 directly underneath the #define FL_NO_HUMANS

dont worry about typing the 0x000000000 after ward

(if you want more classes just repeat this last step and add a 2 for the second one then a 3 for the 3rd one and so on
but make sure that the names are different for each class
like so)

#define FL_MYGIRL 2 (the FL_means its a flag)

it should look like this
#define   FL_GODMODE                  0x00000010
#define   FL_NOTARGET                  0x00000020
#define   FL_TEAMSLAVE                         0x00000400   // not the first on he 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_MYGUY 1
#define    FL_MYGIRL 2

D) Now scroll down the page till you find this

qboolean botDelayBegin (do a search)

and insert this

int playerclass;

right underneath this qboolean botDelayBegin
but before this

};

(or you will have errors)

so it should look lke this

qboolean botDelayBegin
int playerclass;
};

"okay what did i just do"
I told the engine I was adding new players to it
thats what #define FL_MYGUY does
then when we added

int playerclass;

It made the new player class usable (to the best of my recollection)
hopefully that is blunt enough.

E) Now open up g_client.c
and scroll down to find this function

void ClientSpawn(gentity_t *ent) {      (do a search)

then directly underneath that line of code place this code

if(!ent->playerclass)
{
client->sess.sessionTeam = TEAM_SPECTATOR;
client->sess.spectatorState = SPECTATOR_FREE;
trap_SendServerCommand(ent-g_entities, va("print \"Please use chooseclass to choose a class\n\""));
}

"Now you probably want to no what this does"
Well it puts us in spectator mode when we load up the map so that we can pull the console down and choose our new class we added to the mod.

F) Now scroll down inside of this same function you will find this block of code

//client->ps.stats[STAT_WEAPONS] = ( 1 << WP_MACHINEGUN );
//if ( g_gametype.integer == GT_TEAM )
//{
//client->ps.ammo[WP_MACHINEGUN] = 50;
//}
//else
//{
//client->ps.ammo[WP_MACHINEGUN] = 100;
//}

(just comment out each line so you can keep tabs on what you have removed from the original q3 source and then added
in case you have compile problems)

G)  Then replace it with this.

if(ent->playerclass==MYGUY)
{
client->ps.stats[STAT_WEAPONS] = ( 1 << WP_BFG); client->ps.ammo[WP_BFG] = 200;
}

(you can copy and paste this tidbit of code and use it for each new class you create
just replace the old name with the new one and the name of the weapon
like so)

if(ent->playerclass==MYGIRL)
{
client->ps.stats[STAT_WEAPONS] = ( 1 << WP_ROCKET_LAUNCHER); client->ps.ammo[WP_ROCKET_LAUNCHER] = 200;
}

"What we just did "
We assigned a new starting weapon, instead of the machinegun, to our new class we created and gave it 200 cells of ammo.
(but you can always increase the amount of ammo up to 999)
Here are the other weapons you can put in there place if you dont like the bfg.
you can always have more than one weapon assigned to a player for him to start off with just do the code like i showed you
   
   WP_GAUNTLET
   WP_MACHINEGUN
   WP_SHOTGUN
   WP_GRENADE_LAUNCHER
   WP_ROCKET_LAUNCHER
   WP_LIGHTNING
   WP_RAILGUN
   WP_PLASMAGUN
   WP_BFG
   WP_GRAPPLING_HOOK

H) Now go into g_active.c and find this finction

void ClientThink_real( gentity_t *ent ) {

then scroll down a bit and find this line

if ( client->ps.powerups[PW_HASTE] ) { client->ps.speed *= 1.3; }

and insert this directly underneath

if(ent->playerclass==MYGUY)
client->ps.speed *= 2; (thats fast)

(the max is 3 for speed)

"What we just did"
We told the engine that we want the new player class to be assigned a different speed to make this player unique

I) Now open up g_cmds.c

and scroll down to the bottom of the page or until you find
this

else if (Q_stricmp (cmd, "setviewpos") == 0) Cmd_SetViewpos_f( ent );

then underneath that put this in there

else if (Q_stricmp (cmd, "chooseclass") == 0) ChooseClass(ent);

this is our command so that we can activate the new player class from within the console

J) Now scroll up till you find

/* =================
ClientCommand
================= */
then directly above that place this snippet of code
/*==================
ChooseClass
==================*/
void ChooseClass(gentity_t *ent)
{
char choice[MAX_TOKEN_CHARS];
trap_Argv(1, choice, sizeof(choice));
if(!strlen(choice))
{
trap_SendServerCommand(ent-g_entities, va("print \"Choose from MYGUY or whatever you create\n\""));
return;
}
if(!Q_stricmp(choice, "myguy"))
{
trap_SendServerCommand(ent-g_entities, va("print \"You are now His Guy\n\""));
ent->playerclass = MYGUY;
ent->client->sess.sessionTeam = TEAM_FREE;
ClientSpawn(ent);
return;
}
it should look like this
/*==================
ChooseClass
==================*/
void ChooseClass(gentity_t *ent)
{
char choice[MAX_TOKEN_CHARS];
trap_Argv(1, choice, sizeof(choice));
if(!strlen(choice))
{
trap_SendServerCommand(ent-g_entities, va("print \"Choose from MYGUY or whatever you created \n\""));
return;
}
if(!Q_stricmp(choice, "myguy"))
{
trap_SendServerCommand(ent-g_entities, va("print \"You are now His Guy\n\""));
ent->playerclass = MYGUY;
ent->client->sess.sessionTeam = TEAM_FREE;
ClientSpawn(ent);
return;
}
/* =================
ClientCommand
================= */

"Ok so what does this do"
this is the command that tells the engine that we are requesting a certain playerclass

K) Now compile the source(f7)
(if you succed with no errors continue onto the final step
if you get errors do it all over its the only way to learn)

(STEP FIVE)

A) Open up an msdos command console and
type this
d:/micros~1/vc98/bin/vcvars32
you may need to do it this way
d:
cd micros~1
d:/microsoft visual studio
cd vc98
d:/microsoft visual studio/vc98/
cd bin
d:/microsoft visual studio/vc98/bin/
then type vcvars32
 
this sets up the enviroment and gives us enough enviroment space to create our qvms
after you do that
do a cd ..   (this will take you a back a directory)
until your back to the foot of your directory.

B) Now goto the drive your quake3 game is installed in by typing it in the msdos console
like so
d:/quake3
then type cd source
then type cd game
so the final path should look like so
d:/quake3/source/game
now type game once again
it should compile just fine now
and look something like this as it compiles
 
 
and like the above picture after it finishes compiling the qvm's.

C) Go ahead and close you msdos window.
(note-if you are planning an doing alot of coding then leave it open or you will have to do all the work over in the msdos console)FYI
D) Now after the qvms are done go into your baseq3 folder and then into the vm folder and cut!!!
both the qagame.map and the qagame.qvm files out of there.
E) Now go into your mod folder and place them into your vm folder
F) Now we need to make a short cut to you mod
so right clik on the quake3.exe and click create shortcut
then right click it and click properties and in the target name type this
 
D:\Quake3\quake3.exe +set fs_game testmod1+set sv_pure 0
click apply
and then clik on youir new shortcut and enjoy.
when you load up the map just pull the console down by pressing the ~tilde key and typing /chooseclass

In the next tutorial which im working on now we will learn how to make a model and place it in q3 so we can have a new weapon

Logged
Pages: [1] Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.6 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Free SMF 1.1.5 Forum Theme by Tamuril. © 2008.