lfnetwork.com mark read register faq members calendar

Thread: game and cgame
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 09-15-2011, 04:19 PM   #1
LightNinja
The Ninjonator
 
LightNinja's Avatar
 
Join Date: Sep 2003
Location: Somewhere-Spain Status: Ninjonator
Posts: 1,998
game and cgame

Hi guys. I want to find the conection between game and cgame. I thought I had, but nope.

I have a code at game (inside G_RunFrame->WP_SpellUpdate) which is:
self->s.userInt1 = 1;

That should set usrInt1 to 1 so then, in cgame I have a conditional inside CG_Player:
cent->playerState->userInt1 == 1

And it doesn't work. What I'm doing wrong?




~JA MP Total Conversion~
LightNinja is offline   you may: quote & reply,
Old 09-15-2011, 04:23 PM   #2
Tinny
 
Tinny's Avatar
 
Join Date: Apr 2002
Posts: 1,188
Are you certain that Wp_SpellUpdate is run to set that value?


Redeemed!

An old school mod for jedi academy.
Tinny is offline   you may: quote & reply,
Old 09-15-2011, 06:31 PM   #3
LightNinja
The Ninjonator
 
LightNinja's Avatar
 
Join Date: Sep 2003
Location: Somewhere-Spain Status: Ninjonator
Posts: 1,998
I'm sure - I mean, at least when I put a breakpoint inside WP_SpellUpdate, execution always stops there.

Your answer makes me wonder that you are suggesting that it should work. Here's the code where the value is set:
Code:
	
if ( ucmd->buttons & BUTTON_CAST_SPELL )
	{
		self->s.userInt1 = 1;
		// want it to be: self->client->ps.isCasting=1;
		if (BG_CanUseSpellsNow(&self->client->ps, S_DIVINEBUSTER ))
		{
			self->client->ps.forceHandExtend = HANDEXTEND_FORCE_HOLD;
		}
	}
When I press the button, the code goes inside the if plus the animation of the player is changed which means that it should work




~JA MP Total Conversion~
LightNinja is offline   you may: quote & reply,
Old 09-15-2011, 10:45 PM   #4
-=*Raz0r*=-
Rookie
 
-=*Raz0r*=-'s Avatar
 
Join Date: Oct 2006
Location: Australia
Posts: 243
Is the cent you're reading from your own player, or someone else?
IIRC you only receive a partial playerState_t of each player (or none at all, but it will be constructed from their entityState_t)

-=*Raz0r*=- is offline   you may: quote & reply,
Old 09-16-2011, 04:36 AM   #5
LightNinja
The Ninjonator
 
LightNinja's Avatar
 
Join Date: Sep 2003
Location: Somewhere-Spain Status: Ninjonator
Posts: 1,998
It should be the cent of my player, but how would I know? I've tryed:

if (cent->currentState.userInt1 == 1){
...
}

But it doesn't work. userInt1 is never 1 though I set it at game. But I don't understand why it does works for forcepowers. Forcepowers are set at game with this code:

Code:
	case FP_LIGHTNING:
		hearable = qtrue;
		hearDist = 512;
		duration = overrideAmt;
		overrideAmt = 0;
		self->client->ps.fd.forcePowersActive |= ( 1 << forcePower );
		self->client->ps.activeForcePass = self->client->ps.fd.forcePowerLevel[FP_LIGHTNING];
		break;
and then the gfx of the lightning is drawn with this code at cgame:

Code:
		if ( cent->currentState.activeForcePass > FORCE_LEVEL_2 )
		{//arc
			//trap_FX_PlayEffectID( cgs.effects.forceLightningWide, efOrg, fxDir );
			//trap_FX_PlayEntityEffectID(cgs.effects.forceLightningWide, efOrg, axis, cent->boltInfo, cent->currentState.number, -1, -1);
			trap_FX_PlayEntityEffectID(cgs.effects.forceLightningWide, efOrg, axis, -1, -1, -1, -1);
		}
Why mine doesn't work? It is set the same way than forcepowers in game and cgame.




~JA MP Total Conversion~
LightNinja is offline   you may: quote & reply,
Old 09-16-2011, 07:17 AM   #6
-=*Raz0r*=-
Rookie
 
-=*Raz0r*=-'s Avatar
 
Join Date: Oct 2006
Location: Australia
Posts: 243
Check out ext_data/MP/psf_overrides.txt from assets*.pk3
Change userInt1 to 16 or 32, depends what you want.

Sounds like it's just not being networked. I thought it networked at-least 1 bit though..

-=*Raz0r*=- is offline   you may: quote & reply,
Old 09-16-2011, 08:24 AM   #7
LightNinja
The Ninjonator
 
LightNinja's Avatar
 
Join Date: Sep 2003
Location: Somewhere-Spain Status: Ninjonator
Posts: 1,998
Ok it doesn't work. I'm desperated so, megapost:

Here is userInt1 in my psf_overrides.txt:
userInt1, 32
32 bits which is the normal int size (or that's what I've seen around google)

Here is my code at game. I made a new .c where I have the function:

Code:
void WP_SpellUpdate( gentity_t *self, usercmd_t *ucmd ){

	if ( !self )
	{
		return;
	}

	if ( !self->client )
	{
		return;
	}

	if ( self->health <= 0 || (self->playerState->groundEntityNum == ENTITYNUM_NONE) )
	{//if is in air, or is death
		return;
	}

	if (self->client->ps.pm_flags & PMF_FOLLOW)
	{ //not a "real" game client, it's a spectator following someone
		return;
	}
	if (self->client->sess.sessionTeam == TEAM_SPECTATOR)
	{
		return;
	}
	
	if ( ucmd->buttons & BUTTON_CAST_SPELL )
	{
		self->s.userInt1 = 1;
			self->client->ps.userInt1 = 1;
		// want it to be: self->client->ps.isCasting=1;
		if (BG_CanUseSpellsNow(&self->client->ps, S_DIVINEBUSTER ))
		{
			self->client->ps.forceHandExtend = HANDEXTEND_FORCE_HOLD;
		}
	}
	else
	{
		self->client->ps.userInt1 = 0;
		self->s.userInt1 = 0;
	}
}
As you can see it's like a copy of WP_ForcePowersUpdate and is also called after it (In G_RunFrame function).
The game loop enters the function and if the player doesn't hold down the button then the variable userInt (I put both because of desperation) are set to 0. That should be fine, but I don't know if they are really set to 0 or if it is the default value. When I press the button, the code enters inside the conditional and I swear it set both values to 1, I've seen it with debug and also the animation of the player changes when I press it which means that it's working.

Then the game loop should enter CG_Player at cgame and when it arrives to this conditional:

Code:
	if ((cent->currentState.userInt1 == 1 || cent->playerState->userInt1==1) && cent->currentState.NPC_class != CLASS_VEHICLE)
	{
		C_DoElements(cent);
	}
It should do C_DoElements, which is the function that draws the gfx. But it doesn't! I've set userInt1 to 32 bits, I've used both userInt1's, what else? have someone done something like this before?

I have two options:
1. Leave
2. Erase forcepowers from the mod and use their variables.

I hope you guys have a solution, I don't know what else to do or where else to look...

EDIT: And also I've added inside BG_PlayerStateToEntityStateExtraPolate:

s->userInt1 = ps->userInt1;




~JA MP Total Conversion~

Last edited by LightNinja; 09-16-2011 at 08:42 AM.
LightNinja is offline   you may: quote & reply,
Old 09-17-2011, 06:38 AM   #8
LightNinja
The Ninjonator
 
LightNinja's Avatar
 
Join Date: Sep 2003
Location: Somewhere-Spain Status: Ninjonator
Posts: 1,998
Could it be that is not networking properly because I'm not using a server when I try the mod? I try it in a "individual game"

EDIT:
Ok this is crazy. It works if I use generic1. Don't ask me why but it does. I'll keep investigating




~JA MP Total Conversion~

Last edited by LightNinja; 09-17-2011 at 06:54 AM.
LightNinja is offline   you may: quote & reply,
Old 09-17-2011, 07:18 AM   #9
-=*Raz0r*=-
Rookie
 
-=*Raz0r*=-'s Avatar
 
Join Date: Oct 2006
Location: Australia
Posts: 243
Then the value isn't being networked. You should be debugging the server separately from the client, and you'll need both to use the psf_overrides.txt for it to work right.

-=*Raz0r*=- is offline   you may: quote & reply,
Old 09-17-2011, 04:07 PM   #10
LightNinja
The Ninjonator
 
LightNinja's Avatar
 
Join Date: Sep 2003
Location: Somewhere-Spain Status: Ninjonator
Posts: 1,998
Ok, thanks. It was that I was doing the debug wrong. userInt1 now working:

http://img215.imageshack.us/img215/4893/shot0003dy.jpg




~JA MP Total Conversion~
LightNinja is offline   you may: quote & reply,
Old 09-17-2011, 11:55 PM   #11
Tinny
 
Tinny's Avatar
 
Join Date: Apr 2002
Posts: 1,188
Sweeeet! That looks pretty epic.


Redeemed!

An old school mod for jedi academy.
Tinny is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > JediKnight Series > Editing Central > JA Coding > game and cgame

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:14 PM.

LFNetwork, LLC ©2002-2011 - All rights reserved.
Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.