PDA

View Full Version : JKZombie host crashing



Lord_Grismath
03-31-2005, 04:07 PM
I've been working on a new gametype for JK, where one player randomly begins as a zombie and the rest as gunslingers, until everyone becomes zombies and the round ends. The game begins in a lobby, until someone pulls a switch that lets everyone into the arena and spirits the zombie off to his hiding place.

Here's the code for the switch:



activated:
if(GetSenderRef()==switch && swatch==0) {
swatch=1;
SetWallCel(switch, 1);
PlaySoundGlobal(flip, 1, 0, 0x0);

playercount = GetNumPlayers();
player = (Rand() * playercount) * playercount;
player = player - (player % 1);
Print("1");
// zombie initialization
SetThingModel(GetPlayerThing(player), zmodel);
SetActorExtraSpeed(GetPlayerThing(player), 0.5);
SetInv(GetPlayerThing(player), 121, 1);
SetInv(GetPlayerThing(player), 131, 0); // Saber
SetInv(GetPlayerThing(player), 122, 0);
SetInv(GetPlayerThing(player), 123, 0);
SetInv(GetPlayerThing(player), 11, 0);
SendTrigger(player, 99, player, 1, 0, 0);
TeleportThing(GetPlayerThing(player), zspawn); // <- doesn't work :\
Print("2");
for(i=0; playercount; i=i+1) {
if(i!=player) {
// Set all non-zombie players as gunslingers.
SetThingModel(GetPlayerThing(i), gmodel);
SetActorExtraSpeed(GetPlayerThing(i), -0.5);
SetInv(GetPlayerThing(i), 121, 0);
SetInv(GetPlayerThing(i), 131, 0); // Saber
SetInv(GetPlayerThing(i), 122, 1);
SetInv(GetPlayerThing(i), 123, 1);
SetInv(GetPlayerThing(i), 11, 500);
}
}
Print("3");
MoveToFrame(doora, 1, 3);
MoveToFrame(doorb, 1, 3);
PlaySoundLocal(buzzer, 1, 0, 0x0);
Print("4");
//SetPulse(3);
}
return;


I removed the pulse (which checks for victory conditions, i.e. all players zombified) to see if that were the problem, but it still crashes.

I've never done c/s scripting before, but I gave this a shot (with 0x240), in a clientside cog:



trigger:
//if(GetSourceRef()==99) {
if(GetParam(1)==0) { // Gunslinger
num_sects=GetSectorCount();
for(i=0; i<num_sects; i=i+1) {
SetSectorLight(i, 0, 0);
SetSectorTint(i, '0 0 0');
}
SetMapModeFlags(0x0);
ClearActorFlags(GetParam(0), 0x800000);
}
if(GetParam(1)==1) { // Zombie
num_sects=GetSectorCount();
for(i=0; i<num_sects; i=i+1) {
SetSectorLight(i, 1, 1);
SetSectorTint(i, '200 0 00');
}
num_surfs=GetSurfaceCount();
for(i=0; i<num_surfs; i=i+1) {
SetFaceType(i, 0x2);
}
SetMapModeFlags(0x4);
SetActorFlags(GetParam(0), 0x800000);
}
//}


This handles the local view effects for when you become a zombie or gunslinger. For zombies, all sectors become fullbright (so you can see in the dark), red, and blurry, plus you lose your HUD.

For some reason, however, whenever somebody pulls the switch, the host's machine freezes up. Any possible solutions? Thanks.

Edward
03-31-2005, 04:39 PM
OK. I'm gonna take a stab in the dark (and probebly get half eaten and turn into a Zombie) and ask if the model is ok? Does it use the same keyframe animations as the default player? Are the nodes the same as the def player? Any "single colored" mats you forgot to change the Geo on?

If this is wrong, then consider me a Zombie and name the Zombie Leader after me. :p

/Edward

darthslaw
03-31-2005, 05:06 PM
I don't see anything that would stand out as crashing code, but here's a few debugging ideas...
[list=1]
comment out the SendTrigger() lines in your switch cog... if it still freezes, you know your problem is the switch cog and not the c/s one. If it doesnt crash, it's probably the c/s cog.
[pre-edit] Now that I look at it again, I think I'm understanding what you're trying to do there now... try doing 'player = rand() * playercount;' instead; rand() * playercount * playercount will often result in a value greater than the player count, which can essentially be called an 'out of bounds' array index call... uh, thing... which could potentially cause JK lockups.
[/list=1]

Lord_Grismath
04-02-2005, 02:06 AM
Answer:

the for statement was for(i=0;playercount;i=i+1) {, hence infinite loop.

Thanks, SniperWolf!