LightNinja Posted September 15, 2011 Share Posted September 15, 2011 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 More sharing options...
Tinny Posted September 15, 2011 Share Posted September 15, 2011 Are you certain that Wp_SpellUpdate is run to set that value? Link to comment Share on other sites More sharing options...
LightNinja Posted September 15, 2011 Author Share Posted September 15, 2011 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 Link to comment Share on other sites More sharing options...
-=*Raz0r*=- Posted September 16, 2011 Share Posted September 16, 2011 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) Link to comment Share on other sites More sharing options...
LightNinja Posted September 16, 2011 Author Share Posted September 16, 2011 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 More sharing options...
-=*Raz0r*=- Posted September 16, 2011 Share Posted September 16, 2011 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.. Link to comment Share on other sites More sharing options...
LightNinja Posted September 16, 2011 Author Share Posted September 16, 2011 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... EDIT: And also I've added inside BG_PlayerStateToEntityStateExtraPolate: s->userInt1 = ps->userInt1; Link to comment Share on other sites More sharing options...
LightNinja Posted September 17, 2011 Author Share Posted September 17, 2011 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 Link to comment Share on other sites More sharing options...
-=*Raz0r*=- Posted September 17, 2011 Share Posted September 17, 2011 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. Link to comment Share on other sites More sharing options...
LightNinja Posted September 17, 2011 Author Share Posted September 17, 2011 Ok, thanks. It was that I was doing the debug wrong. userInt1 now working: Link to comment Share on other sites More sharing options...
Tinny Posted September 18, 2011 Share Posted September 18, 2011 Sweeeet! That looks pretty epic. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.