PDA

View Full Version : Trouble with Classes


Brandon
06-04-2002, 11:08 PM
I've been having some trouble with following this tutorial http://www.planetquake.com/code3arena/tutorials/tutorial20.shtml I was wondering if some knowledgable coder would be so kind as to take a quick look at it and tell me what I need to change to get the tutorial to work with Jedi Outcast. Thanks for reading.

Da MaN
06-04-2002, 11:44 PM
Umm they tell you what to add there already...

If you dont know what they're doing, then you need to sit down and look around and try to understand wtf they're doing.

Brandon
06-05-2002, 02:31 PM
Well, I followed the tutorial step by step, but nothing changed for me in the game. I'm assuming the reason for failure has something to do with the differences between Quake 3 and Jedi Outcast. Sitting down and trying to figure out wtf they're doing hasn't seemed to help me much. Generally, I try to follow tutorials to figure out how things get done.

MadScientist
06-06-2002, 01:43 AM
Well the names of the weapons, ammo, and models are different of course. look in the various files for like WP_BOWCASTER or somthing for the list and AMMO_POWERCELL etc I don't remember where they were and use like "jan/blue" or whatever instead of "biker/blue" and you can call your classes PCLASS_BFG if you want but it doesn't make much sense if the BFG doesn't exist but it will work.

Brandon
06-06-2002, 02:14 PM
Thanks for the reply MadScientist. I replaced the Quake 3 model references with JO models like "reborn/red." I figure I'll change the class names whenever I get the mod to actually work. Right now I can go in the game and select the reborn model, but nothing different happens. I suppose I'll have to go back in and see if there are any references to a certain gametype that I have to have activated for the mod to work. I would assume something like TeamFFA, because the code specifies colors of the characters.

Wiebbe
06-07-2002, 01:28 PM
Your lucky ;)
i was messing around with the "classes" too, and found out that, the jk II does something diffrent with if-statements, (or the code on the page is faulry, what happened with me, was this:

i had three classes for testing: Shadowtrooper first, then Storm trooper then Rebel, and if the model wasnt any three, they they became the Rebel, but when you enter the game, your always rebel.

Now what ok is this:

// set model
if( g_gametype.integer >= GT_TEAM ) {
Q_strncpyz( model, Info_ValueForKey (userinfo, "team_model"), sizeof( model ) );
} else {
Q_strncpyz( model, Info_ValueForKey (userinfo, "model"), sizeof( model ) );
if (!Q_stricmp (model, "shadowtrooper/default")) {
client->pers.newplayerclass = PCLASS_SHADOW;
} else if (!Q_stricmp (model, "stormtrooper/default")) {
client->pers.newplayerclass = PCLASS_STORMTROOPER;
} else if (!Q_stricmp (model, "rebel/default")) {
client->pers.newplayerclass = PCLASS_REBEL;
} else {
client->pers.newplayerclass = PCLASS_REBEL;
Q_strncpyz(model, "REBEL/default", sizeof( model ) ); //wiebbe edit
}


(dont look at the wiebbe edit, it helps me find what i changed.
what wasnt done with the code on the site, is didnt finish the if-statements, here after each else if, and else, there needs to be a
{ and } to show where the If statements ends. When i addes those bracked, it worked!

Just compare my code with the code on the site..
Good luck!

Brandon
06-07-2002, 05:02 PM
Thanks for the info, Wiebbe. I'll try that fix and let you know how it goes.

Brandon
06-07-2002, 05:20 PM
Okay, I just tried out the fix. I can switch my character class without a problem, but for some reason the weapon effects don't work. All the classes start out with the Bryar Pistol and Saber regardless. Now I'm assuming there might be some line of code that over rides my spawning with certain weapons changes.

DiscoFever
06-08-2002, 04:44 AM
I tried creating classes with the same thing, but it doesn't work for me...

I've followed the tutorial, and only changed the Q3 parts to match JKII but it still doesn't work.

Can someone help me?

Wiebbe
06-08-2002, 10:11 AM
well. what i guess you did wrong is this: Firstly your if function may be wrong? dont know for sure, cuzz you didnt post it :P
(would be alot more helpfull, so i can see what is wrong (or if you dont want to post it, mail it if you want) Check all the strings it searches for, dont know if C is case sensitive, but just make sure, its all the same captital letter.
lets take a look at the code from the site:


//assign weapons according to class
switch (client->pers.playerclass){
case PCLASS_BFG:
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_BFG );
client->ps.ammo[WP_BFG] = 20;
break;
case PCLASS_LIGHTNING:
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_LIGHTNING );
client->ps.ammo[WP_LIGHTNING] = 60;
break;
case PCLASS_RAILGUN:
default:
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_RAILGUN );
client->ps.ammo[WP_RAILGUN] = 20;
break;
}

If we look at this line: client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_RAILGUN );
Its kinda easy, so i guess that i dont even have to explain, but i will try, the client->ps.stats, just says (its my guess, dunno for sure) Get from the client (self! :P ) the stats, and then go to the weapons stats (the [STAT_WEAPONS]) then is says, add to the stats! (very important, the |= means add, not replace or something, so if you would like to have them only use the Disruptor and the bryar pistol, you would get this:


case PCLASS_REBEL:
default:
client->ps.stats[STAT_WEAPONS] = ( 1 << WP_BRYAR_PISTOL ); // keep it clean here, best to follow the order its in the code (or in game..)
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_DISRUPTOR );
client->ps.ammo[AMMO_BRYAR] = 100; // i know this is wrong, (the AMMO_bryar, but didnt feel like checking it)
client->ps.ammo[AMMO_POWERCELL] = 150;
break;
}

Now if it would execute this code, it would give us, a bryar, and a disruptor, but if we would change one character: this client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_DISRUPTOR ); to client->ps.stats[STAT_WEAPONS] = ( 1 << WP_DISRUPTOR );, you would only get the disruptor, so keep a look at the code, 1 minor mistake, and it doestn work well!

Also keep this in mind, in JKII the ammo is done like this: AMMO_POWERCELL, while in Quake3 its done like this: WP_RAILGUN, dont forget to change that.

DiscoFever
06-09-2002, 12:17 AM
This is what I've changed in the code


from the g_client.c

// set model
if( g_gametype.integer >= GT_TEAM ) {
Q_strncpyz( model, Info_ValueForKey (userinfo, "team_model"), sizeof( model ) );
} else {
Q_strncpyz( model, Info_ValueForKey (userinfo, "model"), sizeof( model ) );
if (!Q_stricmp (model, "shadowtrooper/default")) {
client->pers.newplayerclass = PCLASS_SHADOW;
} else if (!Q_stricmp (model, "stormtrooper/default")) {
client->pers.newplayerclass = PCLASS_STORMTROOPER;
} else if (!Q_stricmp (model, "rebel/default")) {
client->pers.newplayerclass = PCLASS_REBEL;
} else {
client->pers.newplayerclass = PCLASS_REBEL;
Q_strncpyz(model, "REBEL/default", sizeof( model ) ); //wiebbe edit
}


from bg_public.h

typedef enum {
PCLASS_SHADOW,
PCLASS_STORMTROOPER,
PCLASS_REBEL,

PCLASS_NUM_CLASSES
} pclass_t;


I have put in the code like this

typedef enum {
TEAM_FREE,
TEAM_RED,
TEAM_BLUE,
TEAM_SPECTATOR,

TEAM_NUM_TEAMS
} team_t;

typedef enum {
PCLASS_SHADOW,
PCLASS_STORMTROOPER,
PCLASS_REBEL,

PCLASS_NUM_CLASSES
} pclass_t;


is that right, or do I have to take the first one out?

and there's something in the g_local.h file, but I can't remember

MadScientist
06-09-2002, 01:53 AM
Well that looks like it would work... but you haven't done anything based on the classes so you will see no difference (at least you didn't post it). There is one more step to doing all of this btw... changing it so you don't switch models until you respawn. as of now you will look like the wrong class if you switch until you respawn.

Wiebbe
06-09-2002, 05:45 AM
hmm,

are you sure you added something like this? :


/assign weapons according to class
switch (client->pers.playerclass){
case PCLASS_SHADOW:
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_DISRUPTOR );
client->ps.ammo[AMMO_POWERCELL] = 100;
break;
case PCLASS_STORMTROOPER:
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_BLASTER );
client->ps.ammo[AMMO_POWERCELL] = 100; break;
case PCLASS_REBEL:
default: // what the hell does this do? Probaly say this is the default case if none aplies? just a guess though
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_BRYAR_PISTOL );
client->ps.ammo[AMMO_BRYAR] = 100; break;
}


This had to be there too ofcourse, when i get home, ill post where i placed it in g_client.c
also dont forget to place these:

client->pers.playerclass = client->pers.newplayerclass;

DiscoFever
06-09-2002, 06:44 AM
yeh, I added that too, forgot to paste it


//assign weapons according to class
switch (client->pers.playerclass){
case PCLASS_BFG:
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_BRYAR_PISTOL );
client->ps.ammo[WP_BRYAR_PISTOL] = 50;
break;
case PCLASS_LIGHTNING:
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_SABER );
client->ps.ammo[WP_LIGHTNING] = 1;
break;
case PCLASS_RAILGUN:
default:
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_BOWCASTER );
client->ps.ammo[WP_RAILGUN] = 20;
break;
}


on closer inspection, I beleive that I left the old PCLASS_RAILGUN in there instead of the new ones....hmm...

edit: ok, I tried it changing the PCLASS but it still didn't work

Wiebbe
06-09-2002, 03:16 PM
dude, you need to give the weapons some ammo?
also, recheck that you changed the classes according to how they are defined in g_local.h.

check bg_weapons.h (i thought it was h, its the file of 3 k) for all the names of everything (ammo, and weapons)

DiscoFever
06-10-2002, 03:34 AM
looking at that code, I can see errors, lots of errors. I guess that'll teach me to code at night

hmmm....

DiscoFever
06-12-2002, 12:24 AM
ok, I've editied the code again, but it still doesn't work


//assign weapons according to class
switch (client->pers.playerclass){
case PCLASS_STROMTROOPER:
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_BRYAR_PISTOL );
client->ps.ammo[AMMO_BLASTER] = 50;
break;
case PCLASS_SHADOW:
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_BLASTER );
client->ps.ammo[AMMO_BLASTER] = 30;
break;
case PCLASS_REBEL:
default:
client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_BOWCASTER );
client->ps.ammo[AMMO_POWERCELL] = 20;
break;
}


all the other parts are the same as what I've pasted before.