This is the weirdest problem I have ever come across. So bare with my descriptions etc. Unfortunatly you will be unable to test the cog without the rest of Team Battle. So if someone(s) thinks they know a reason but need to test the cog further I will need to upload Team Battle for them. (Will be about an 8mb download)
Anyways here goes:
The cog runs correctly the first 2 times or so. And then after running the roundend code, it calls ghost mode. Within ghost mode a trigger is sent to everyone to notify of a change to ky.3do (which is the ghost model)
Now normally, the trigger is sent and recieved correctly, and the ghostmode module continues to run. However, after the second round, after calling the trigger, the ghostmode module stops running after the trigger is sent. And the end of round module continues as if the ghostmode module just returned.
This also occurs on the spawned module which is called 3 seconds later. The first trigger causes the spawned module to return, and the roundend module continues.
But, triggers sent that are recieved outside of this cog do not cause this problem. (like the dismount trigger under the ghostmode module)
I have spent alot of time trying to define the player in different ways, trying to work out why its stopping etc. And short of re-writing that part of the cog to make it somehow different I'm not sure what to do.
It may be something really simple, or thats what I'm hoping.
Here is the cog, its got a few comments to show you whats happening alittle better.
If anyone needs anymore detail please dont hesitate to post!!
Thanks for any posts.
------------------
Team Battle.
Anyways here goes:
The cog runs correctly the first 2 times or so. And then after running the roundend code, it calls ghost mode. Within ghost mode a trigger is sent to everyone to notify of a change to ky.3do (which is the ghost model)
Now normally, the trigger is sent and recieved correctly, and the ghostmode module continues to run. However, after the second round, after calling the trigger, the ghostmode module stops running after the trigger is sent. And the end of round module continues as if the ghostmode module just returned.
This also occurs on the spawned module which is called 3 seconds later. The first trigger causes the spawned module to return, and the roundend module continues.
But, triggers sent that are recieved outside of this cog do not cause this problem. (like the dismount trigger under the ghostmode module)
I have spent alot of time trying to define the player in different ways, trying to work out why its stopping etc. And short of re-writing that part of the cog to make it somehow different I'm not sure what to do.
It may be something really simple, or thats what I'm hoping.
Here is the cog, its got a few comments to show you whats happening alittle better.
Code:
#=======================================================================# # # Jedi Knight Cog Script # # gameplay.COG # # This cog controls all the gameplay scripting in Team Battle. # # [Hellcat] # # This Cog is Not supported by LucasArts Entertainment Co #=======================================================================# flags=0x240 #=======================================================================# symbols thing player local thing sp_ct0 thing sp_ct1 thing sp_ct2 thing sp_ct3 thing sp_ct4 thing sp_ct5 thing sp_ct6 thing sp_ct7 thing sp_t0 thing sp_t1 thing sp_t2 thing sp_t3 thing sp_t4 thing sp_t5 thing sp_t6 thing sp_t7 int idp=0 local int team=0 local int playmdl=0 local int shotgun=0 local int rifle=0 local int machine_gun=0 local int round_time=300 int timer=0 local int ct=0 local int ct2=0 local int t=0 local int t2=0 local model CTpa=kyX0.3do local model CTpb=kyT0.3do local model CTpc=kyV0.3do local model CTpd=kyA19.3do local model CTpe=kyW0.3do local model Tpa=kyY0.3do local model Tpb=kyA17.3do local model Tpc=kyU0.3do local model Tpd=kyU0.3do local model Tpe=kyA18.3do local model neutral_mdl=ky.3do local template teleport_particles=+telesparks local message trigger message timer message startup message newplayer message pulse message roundend message spawned message ghostmode end #=======================================================================# code trigger: if(GetSourceRef() == 55) { // Trigger to accept all info needed for respanwing etc team = GetParam(0); playmdl = GetParam(1); } else if(GetSourceRef() == 57) { // Trigger to accept all info needed for respawning etc shotgun = GetParam(0); smg = GetParam(1); rifle = GetParam(2); machine_gun = GetParam(3); call spawned; } //Player model and team Syncranization else if(GetSourceRef() == 163) { SetThingCollideSize(player, 0.065000); SetThingMoveSize(player, 0.065000); If(GetParam(0) == 1) { SetPlayerTeam(GetSenderRef(), 1); If(GetParam(1)==1) SetThingModel(GetSenderRef(), CTpa); If(GetParam(1)==2) SetThingModel(GetSenderRef(), CTpb); If(GetParam(1)==3) SetThingModel(GetSenderRef(), CTpc); If(GetParam(1)==4) SetThingModel(GetSenderRef(), CTpd); If(GetParam(1)==5) SetThingModel(GetSenderRef(), CTpe); } else If(GetParam(0) == 2) { SetPlayerTeam(GetSenderRef(), 2); If(GetParam(1)==1) SetThingModel(GetSenderRef(), Tpa); If(GetParam(1)==2) SetThingModel(GetSenderRef(), Tpb); If(GetParam(1)==3) SetThingModel(GetSenderRef(), Tpc); If(GetParam(1)==4) SetThingModel(GetSenderRef(), Tpd); If(GetParam(1)==5) SetThingModel(GetSenderRef(), Tpe); } else { // First make the player a transperent 3do SetThingModel(GetSenderRef(), neutral_mdl); // Now make him have no collide SetThingCollideSize(GetSenderRef(), 0.00001); SetThingMoveSize(GetSenderRef(), 0.065000); } } else if(GetSourceRef() == 58) { If(GetParam(0) == 1) { If(GetParam(1) == 1) { ct = ct + 1; ct2 = ct2 + 1; } else { ct = ct - 1; } } else if(GetParam(0) == 2) { If(GetParam(1) == 1) { t = t + 1; t2 = t2 + 1; } else { t = t - 1; } } //THIS IS PRINTED Print("PASSED!!!!!!!!!!!!!!!!!!!"); } else if(GetSourceRef() == 59) { timer = GetParam(0); PrintInt(timer); } else if(GetSourceRef() == 60) //Recieve host's round end trigger { ct = GetParam(0); t = GetParam(1); call roundend; } else if(GetSourceRef() == 1688) { victor = GetSenderRef(); //sleep(5.0); Print("Points gained for winning the round!!!"); SetPlayerScore(victor, GetPlayerScore(victor) + GetParam(0)); SyncScores(); } return; #=======================================================================# timer: return; #=======================================================================# startup: player = GetLocalPlayerThing(); // Sleep so then we dont interupt the loading process. Sleep(0.25); // Lets start ghost mode, thats what the player starts in // call ghostmode; // Check to see what the rountime is set to in the level cog. timer=round_time; // If we're the host then start the clock. We let the server control as much as possible. Also remove ff If(IsServer()) { SetPulse(1); SetMultiModeFlags(0x3); } return; #=======================================================================# newplayer: player = GetLocalPlayerThing(); // Sleep so then we dont interupt the loading process. Sleep(0.25); // Lets start ghost mode, thats what the player starts in after dying call ghostmode; return; #=======================================================================# pulse: //Count down the timer timer = timer - 1; SendTrigger(-1, 59, timer, 0, 0, 0); //Check to see if one team is dead or the timer ran out: If(ct == 0 || t == 0 || timer == 0) { //Check to see if the team is acctually all dead or if there are //none of the other team in the game. But if there are none in //the game and we get time 0 then we want to go to the next round If(ct == 0 && ct2 == 0 && timer !=0 && t == t2) return; If(t == 0 && t2 == 0 && timer !=0 && ct == ct2) return; //Set the pulse back to 0 so then we dont count down. setpulse(0); //Server sends round winning info to all players SendTrigger(-1, 60, ct, t, 0, 0); } return; #=======================================================================# roundend: //End of the round code If(ct == 0 && t == 0) Print("Round Draw"); //If theres no special ops left If(ct == 0) { Print("Terrorists Win, Special Operations are eliminated."); //if(GetThingTeam(player) == 2) SendTrigger(-1, 1688, 2, 0, 0, 0); } //If all the terrorists are dead If(t == 0 && timer != 0) { Print("Special Operations Win, terrorists eliminated."); //if(GetThingTeam(player) == 1) SendTrigger(-1, 1688, 2, 0, 0, 0); } // Time is 0 and the hostages are still in trouble?? If(timer == 0) Print("Terrorists Win, hostages have not been rescued"); //Set the time back to our original time timer=round_time; //Lets tell the user whats happening Print("End of Round!"); Print("Next Round will start in 3 seconds!"); //If the player is still choosing their team or if their in ghostmode then make sure they dont do any of the following If(team == 0) { //Set all the essentials back to 0 ct = 0; t = 0; ct2 = 0; t2 = 0; //If we're the server set the timer going again If(IsServer()) SetPulse(1); //return so we dont end up doing everything again. return; } //Call the ghost mode call ghostmode; //Sleep 3 seconds before respawning players Sleep(3.0); //Set all the essentials back to 0 ct = 0; t = 0; ct2 = 0; t2 = 0; //Set the spawned to 0 to allow players who have died this round spawn again spawned = 0; //Call the player to spawn for next round call spawned; //Server goes back to its counting position If(IsServer()) SetPulse(1); return; #=======================================================================# spawned: player = GetLocalPlayerThing(); //Player can only spawn in the first 60secs, and make sure he doesnt try to re-join a team and spawn. If((round_time - timer) > 60 || spawned == 1) { Print("You will spawn in the next round.(60 seconds has passed, or you have died this round.)"); return; } //Set spawned to 1 so players cant just re-spawn spawned = 1; //Inform player Print("Spawned"); //Stop the player so he doesnt have speed from ghost mode StopThing(player); //Make the player NOT able to float SetPhysicsFlags(player, 0x1); ClearPhysicsFlags(player, 0x2000); //Print("CHECKING!!!!!!!!!!!!!!!!!!!"); // Send a trigger to say we have joined SendTrigger(-1, 58, team, 1, 0, 0); //Print("PASSED!!!!!!!!!!!!!!!!!!!"); // Give pistol and knife to the player (80 pistol shots) SetInv(player, 1, 1.0); SetInv(player, 2, 1.0); SetInv(player, 151, 80.0); //If the num is 0, then they didnt buy If(shotgun != 0) { SetInv(player, 3, 1.0); SetInv(player, 152, 32.0); } If(smg != 0) { SetInv(player, 4, 1.0); SetInv(player, 4, 120.0); } If(rifle != 0) { SetInv(player, 5, 1.0); SetInv(player, 12, 120.0); } If(machine_gun != 0) { SetInv(player, 6, 1.0); SetInv(player, 12, 250.0); } //Give the their grenades, currently not implemented // If(playmdl == 1 || playmdl == 2 || playmdl == 3 || playmdl == 4 || playmdl == 5) SetInv(player, 7, 1.0); // If(playmdl == 1 || playmdl == 2 || playmdl == 3 || playmdl == 4 || playmdl == 5) SetInv(player, 8, 1.0); //Cant change teams ingame, only in respawn mode. May change in future. Also 10 (lightsaber) will indicate a host only bot control. SetInv(player, 9, 1.0); SetInv(player, 10, 0.0); // Now set the respawn point by doing a random number. //In later version the host may set these for the player //Need to fix the random so it evenly produces collisions, so we do this budgetly idp = Rand() * 8; If (idp <= 1) idp = 1; else if (idp <= 2) idp = 2; else if (idp <= 3) idp = 3; else if (idp <= 4) idp = 4; else if (idp <= 5) idp = 5; else if (idp <= 6) idp = 6; else if (idp <= 7) idp = 7; else if (idp <= 8) idp = 0; //Now lets spawn them. Set their player model and team. //Use teleport player as a sneaky trick as spawning=) If(team == 1) { //Because we are only running locally. Send trigger to all the players SendTrigger(-1, 163, team, playmdl, 0, 0); TeleportThing(player, sp_ct0[idp]); } else If(team == 2) { //Because we are only running locally. Send trigger to all the players SendTrigger(-1, 163, team, playmdl, 0, 0); TeleportThing(player, sp_t0[idp]); } //Set up player speeds etc. If(playmdl == 1) { SetInv(player, 60, 100); ParseArg(player, "maxthrust=1.25 jumpspeed=1.25"); //Give player Night vision ChangeInv(player, 41, 1.0); SetInvAvailable(player, 41, 1); //Give him battery charge ChangeInv(player, 13, 100.0); } If(playmdl == 2) { SetInv(player, 60, 200); ParseArg(player, "maxthrust=1.0 jumpspeed=1.0"); } If(playmdl == 3) { SetInv(player, 60, 120); ParseArg(player, "maxthrust=1.15 jumpspeed=1.15"); } If(playmdl == 4) { SetInv(player, 60, 80); ParseArg(player, "maxthrust=1.3 jumpspeed=1.3"); } If(playmdl == 5) { SetInv(player, 60, 200); ParseArg(player, "maxthrust=0.9 jumpspeed=0.9"); //Give player Night vision ChangeInv(player, 41, 1.0); SetInvAvailable(player, 41, 1); //Give him battery charge ChangeInv(player, 13, 100.0); } // Do respawn effects - temporaraly disabled //dummy = CreateThingAtPos(teleport_particles, GetThingSector(player), GetThingPos(player), '0 0 0'); // dummy = PlaySoundThing(teleportsnd, player, 1.0, -1, -1, 0x180); //Set our wait SetFireWait(player, -1); SetMountWait(player, 0); SetCurInvWeapon(player, 0); //SelectWeapon(player, AutoSelectWeapon(player, 1)); SelectWeapon(player, 2); return; #=======================================================================# ghostmode: player = GetLocalPlayerThing(); Print("Ghost mode"); //THIS IS PRINTED Print("CHECKING!!!!!!!!!!!!!!!!!!!"); //Send to host that we died. SendTrigger(-1, 58, team, 0, 0, 0); //THIS IS NOT PRINTED Print("PASSED!!!!!!!!!!!!!!!!!!!"); //Change players model and movesize etc. SendTrigger(-1, 163, 0, 0, 0, 0); //Sendtrigger to dismount weapon (Only if we have one out I spose... let the weapon cogs handle that) SendTrigger(player, 62, 0, 0, 0, 0); // Set guns. Give them ability to change teams SetInv(player, 1, 0.0); SetInv(player, 2, 0.0); SetInv(player, 3, 0.0); SetInv(player, 4, 0.0); SetInv(player, 5, 0.0); SetInv(player, 6, 0.0); SetInv(player, 7, 0.0); SetInv(player, 8, 0.0); SetInv(player, 9, 1.0); SetInv(player, 10, 0.0); //Make the player able to float - flying mode ClearPhysicsFlags(player, 0x1); SetPhysicsFlags(player, 0x2000); return; #=======================================================================# end
If anyone needs anymore detail please dont hesitate to post!!
Thanks for any posts.
------------------
Team Battle.