Jump to content

Home

game and cgame


LightNinja

Recommended Posts

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?

Link to comment
Share on other sites

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:

	
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 :confused:

Link to comment
Share on other sites

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:

 

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:

 

	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.

Link to comment
Share on other sites

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:

 

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:

 

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...:confused:

 

EDIT: And also I've added inside BG_PlayerStateToEntityStateExtraPolate:

 

s->userInt1 = ps->userInt1;

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...