Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → This is both strange and has me stumped
This is both strange and has me stumped
2005-08-04, 10:26 AM #1
The problem is as follows, whenever the host does not have the menu weapon (weapon #9) selected, and a client joins, that clients computer crashes. Now when a 3rd person joins, and the host has weap 9 selected, but not the client, the joining person is fine, NO crash, however, when reveresed, the host does NOT has the menu selected, the joiner does crash. (This was tested by running multiple JKs at one time on my computer, but on this I suspect this is irrelevent, but also note the 1st problem was tested using multiple IPs) I can't figure it out, need some help.
The menu cog
Code:
# Jedi Knight Cog Script
#
# WEAP_MENU.COG
#
# WEAPON Script - The great menu cog
#
# [DP]
#
flags=0x240

symbols
keyframe    holsterAnim=kyhlstr.key             local

sound       mountSound=df_rif_ready.wav         local
sound       dismountSound=PutWeaponAway01.wav   local

flex        holsterWait                         local

thing       player                              local
int         mode                                local
int         holsterTrack                        local
int         weapon                              local
int         weapon1=0                           local
int         weapon2=0                           local
int         weapon3=0                           local
int         weapon4=0                           local
int         weapon5=0                           local
int         weapon6=0                           local
int         weapon7=0                           local
int         weapon8=0                           local
int         weapon9=0                           local
int         category=1                          local
int         starting=1                          local
int         canFire                             local
int         i                                   local

vector      vel                                 local
vector      pos                                 local

message     startup
message     newplayer
message     pulse
message     activated
message     deactivated
message     selected
message     deselected
message     autoselect
message     timer
message     user0
message     user1

end

# ========================================================================================

code

Startup:
   starting = 1;
   player = GetLocalPlayerThing();
   SetInv(player, 9, 1);
   category = 1;
   For(i=2; i<=9; i=i+1)
      weapon = 0;
   weapon1 = 1;
   Return;

# ........................................................................................

Newplayer:
   player = GetLocalPlayerThing();
   SetInv(player, 129, weapon1);
   SetInv(player, 123, weapon2);
   SetInv(player, 124, weapon3);
   SetInv(player, 130, weapon4);
   SetInv(player, 125, weapon5);
   SetInv(player, 126, weapon6);
   SetInv(player, 127, weapon7);
   SetInv(player, 131, weapon8);
   For(i=1; i<=8; i=i+1)
   {
      If(weapon > 0)
      {
         SetInv(player, i, 1);
         // SendMessage is a *****, well perhaps....
         // SendMessage(GetInvCog(player, i), newplayer);
         SendTrigger(GetPlayerNum(player), 9, 0, 0, 0, 0);
      }
   }
   If(weapon9 <= 0) SetInv(player, 60, 0);
   If(weapon9 == 1) SetInv(player, 60, 50);
   If(weapon9 == 2) SetInv(player, 60, 100);
   If(weapon9 == 3) SetInv(player, 60, 200);
   If(weapon9 == 4) SetInv(player, 40, 5);
   If(weapon9 == 5) SetInv(player, 44, 1);
   Return;

# ........................................................................................

Pulse:
   SetThingPos(player, pos);
   vel = GetThingThrust(player);
   If(VectorLen(vel) == 0)
   {
       canFire = 1;
       Return;
   }
   If(!canFire) Return;
   If(VectorX(vel) > 0)
   {
      category = category + 1;
      weapon = 1;
   }
   Else If(VectorX(vel) < 0)
   {
      category = category - 1;
      weapon = 1;
   }
   Else If(VectorY(vel) > 0) weapon = weapon - 1;
   Else If(VectorY(vel) < 0) weapon = weapon + 1;

   If(category > 9) category = 1;
   If(category < 1) category = 9;

   If(category == 1) Print("Pistols");
   If(category == 2) Print("Machine-Pistols");
   If(category == 3) Print("Sub-Machine Guns");
   If(category == 4) Print("Grenades");
   If(category == 5) Print("Assault-Rifles");
   If(category == 6) Print("Large Caliber Guns");
   If(category == 7) Print("Heavy Weapons");
   If(category == 8) Print("Mines and Charges");
   If(category == 9) Print("Equipment");

   If(category == 1 && weapon > 6)  weapon = 1;
   If(category == 1 && weapon < 1)  weapon = 6;
   If(category == 2 && weapon > 3)  weapon = 1;
   If(category == 2 && weapon < 1)  weapon = 3;
   If(category == 3 && weapon > 7)  weapon = 1;
   If(category == 3 && weapon < 1)  weapon = 7;
   If(category == 4 && weapon > 3)  weapon = 1;
   If(category == 4 && weapon < 1)  weapon = 3;
   If(category == 5 && weapon > 7)  weapon = 1;
   If(category == 5 && weapon < 1)  weapon = 7;
   If(category == 6 && weapon > 3)  weapon = 1;
   If(category == 6 && weapon < 1)  weapon = 3;
   If(category == 7 && weapon > 5)  weapon = 1;
   If(category == 7 && weapon < 1)  weapon = 5;
   If(category == 8 && weapon > 4)  weapon = 1;
   If(category == 8 && weapon < 1)  weapon = 4;
   If(category == 9 && weapon > 5)  weapon = 1;
   If(category == 9 && weapon < 1)  weapon = 5;

   If(category == 1 && weapon == 1) Print("Sig Sauer p228");
   If(category == 1 && weapon == 2) Print("Beretta 92fs");
   If(category == 1 && weapon == 3) Print("colt 1911");
   If(category == 1 && weapon == 4) Print("H&K Mark23");
   If(category == 1 && weapon == 5) Print("FN Five Seven");
   If(category == 1 && weapon == 6) Print("IMI Desert Eagle");

   If(category == 2 && weapon == 1) Print("Glock 18");
   If(category == 2 && weapon == 2) Print("Ingram Mac10");
   If(category == 2 && weapon == 3) Print("IMI Micro-Uzi");

   If(category == 3 && weapon == 1) Print("Styer TMP");
   If(category == 3 && weapon == 2) Print("H&K MP5K");
   If(category == 3 && weapon == 3) Print("IMI Uzi");
   If(category == 3 && weapon == 4) Print("H&K MP5DS");
   If(category == 3 && weapon == 5) Print("H&K MP5");
   If(category == 3 && weapon == 6) Print("H&K UMP");
   If(category == 3 && weapon == 7) Print("FN P90");

   If(category == 4 && weapon == 1) Print("Smoke Grenades");
   If(category == 4 && weapon == 2) Print("Flashbangs");
   If(category == 4 && weapon == 3) Print("Frag Grenades");

   If(category == 5 && weapon == 1) Print("H&K G36K");
   If(category == 5 && weapon == 2) Print("FAMAS");
   If(category == 5 && weapon == 3) Print("FN F2000");
   If(category == 5 && weapon == 4) Print("XM8");
   If(category == 5 && weapon == 5) Print("M4 - KAC MasterKey");
   If(category == 5 && weapon == 6) Print("M16 - M203");
   If(category == 5 && weapon == 7) Print("OICW");

   If(category == 6 && weapon == 1) Print("H&K G3A3");
   If(category == 6 && weapon == 2) Print("AK47");
   If(category == 6 && weapon == 3) Print("H&K 21E");

   If(category == 7 && weapon == 1) Print("SPAS12");
   If(category == 7 && weapon == 2) Print("HK 69");
   If(category == 7 && weapon == 3) Print("H&K PSG1");
   If(category == 7 && weapon == 4) Print("Barnett M82A1");
   If(category == 7 && weapon == 5) Print("RPG Launcher");

   If(category == 8 && weapon == 1) Print("Remote Charge");
   If(category == 8 && weapon == 2) Print("Claymores");
   If(category == 8 && weapon == 3) Print("Proximity Mine");
   If(category == 8 && weapon == 4) Print("Satchel Charge");

   If(category == 9 && weapon == 1) Print("Light Body Armor");
   If(category == 9 && weapon == 2) Print("Medium Body Armor");
   If(category == 9 && weapon == 3) Print("Heavy Body Armor");
   If(category == 9 && weapon == 4) Print("Medical Supplies");
   If(category == 9 && weapon == 5) Print("Repair Kit");
   canFire = 0;
   Return;

# ........................................................................................

Activated:
   mode = GetSenderRef();

   jkSetWaggle(player, '0.0 0.0 0.0', 0);

   Print("Weapon Selected");
   //If(category == 1) weapon1 = weapon;
   //If(category == 2) weapon2 = weapon;
   //If(category == 3) weapon3 = weapon;
   //If(category == 4) weapon4 = weapon;
   //If(category == 5) weapon5 = weapon;
   //If(category == 6) weapon6 = weapon;
   //If(category == 7) weapon7 = weapon;
   //If(category == 8) weapon8 = weapon;
   weapon[category] = weapon;
   If((category != 4 || category != 8) && !IsMulti()) SetInv(player, category, 1);

   ActivateWeapon(player, 0, mode);
   Return;

# ........................................................................................

Deactivated:
   mode = GetSenderRef();

   jkSetWaggle(player, '10.0 7.0 0.0', 350);
   DeactivateWeapon( player, mode );

   Return;

# ........................................................................................

Selected:
   player = GetLocalPlayerThing();
   pos = GetThingPos(player);
   SetActorFlags(player, 0x8);

   // Play external mounting animation
   PlayMode(player, 41);
   SetArmedMode(player, 1);

   // Play mounting sound.
   PlaySoundThing(mountSound, player, 1.0, -1.0, -1.0, 0x80);

   // Play the animation (NOLOOP + UNIQUE + ENDPAUSE).
   // The animation is held at the last frame after it is played.

   // Clear saber flags, and allow activation of the weapon
   jkClearFlags(player, 0x5);
   SetCurWeapon(player, 9);

   SetInv(player, 12, 0);
   SetPulse(.003);
   SetInv(player, 14, 0);
   Return;

# ........................................................................................

Deselected:
   PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80);

   holsterWait = GetKeyLen(holsterAnim);
   SetMountWait(player, holsterWait);
   holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
   SetTimerEx(holsterWait, 2, 0.0, 0.0);
   jkSetWaggle(player, '0.0 0.0 0.0', 0);
   If(starting == 1 || !IsMulti())
   {
      SetInv(player, 129, weapon1);
      SetInv(player, 123, weapon2);
      SetInv(player, 124, weapon3);
      SetInv(player, 130, weapon4);
      SetInv(player, 125, weapon5);
      SetInv(player, 126, weapon6);
      SetInv(player, 127, weapon7);
      SetInv(player, 131, weapon8);
      For(i=1; i<=8; i=i+1)
      {
         If(weapon > 0)
         {
            SetInv(player, i, 1);
            // SendMessage(GetInvCog(player, i), newplayer);
            SendTrigger(GetPlayerNum(player), 9, 0, 0, 0, 0);
         }
      }
      If(weapon9 <= 0) SetInv(player, 60, 0);
      If(weapon9 == 1) SetInv(player, 60, 50);
      If(weapon9 == 2) SetInv(player, 60, 100);
      If(weapon9 == 3) SetInv(player, 60, 200);
      If(weapon9 == 4) SetInv(player, 40, 5);
      If(weapon9 == 5) SetInv(player, 44, 1);
   }
   SetPulse(0);
   ClearActorFlags(player, 0x8);
   starting = 0;

   Return;

# ........................................................................................

Autoselect:
   If(starting)
   {
      ReturnEx(1000);
   }
   Else ReturnEx(50);

   Return;

# ........................................................................................

Timer:
   If(GetSenderID() == 2)
   {
      StopKey(player, holsterTrack, 0);
   }
   Return;

# ........................................................................................

User0:
   If(category == 1)
   {
      Print("Can't remove pistol");
      Return;
   }
   weapon[category] = 0;
   Print("Weapon Removed");
   Return;

# ........................................................................................

User1:
   Return;

end

one of the normal weapons
Code:
# Jedi Knight Cog Script
#
# WEAP_MP.COG
#
# WEAPON Script - Machine-pistols
#
# [DP]
#
flags=0x240

symbols

model       povModel=mac10v.3do                 local
model       weaponMesh=macg.3do                 local

keyframe    mountAnim=macVmnt.key               local
keyframe    dismountAnim=macVdis.key            local
keyframe    povfireAnim=macVpst1.key            local
keyframe    chamberAnim=macVmnt.key             local
keyframe    reloadAnim=macVmnt.key              local
keyframe    holsterAnim=kyhlstr.key             local

sound       mountSound=df_rif_ready.wav         local
sound       dismountSound=PutWeaponAway01.wav   local
sound       fireSound=mac10_fire.wav            local
sound       outSound=concuss1.wav               local
sound       chamberSound=chamber.wav            local
sound       reloadSound=reload.wav              local

flex        powerBoost                          local
flex        autoAimFOV=30                       local
flex        autoAimMaxDist=5                    local
flex        holsterWait                         local
flex        fireWait                            local
flex        acc                                 local
flex        stability                           local

int         dummy                               local

template    projectile=+bullet9mm               local

thing       player                              local
thing       weapthing                           local
int         trackID=-1                          local
int         mode                                local
int         holsterTrack                        local
int         selectMode=1                        local
int         reloading                           local
int         clipsize                            local
int         chambered                           local
int         rounds                              local
int         firemodes                           local
int         canFire                             local
int         selector                            local
int         mult                                local

vector      randvect                            local
template    weapdummy=+weapdummy                local
template    ldummy=+chdummy                     local

int         gunnum=2                            local
int         display=11                          local

model       povModel1=glockv.3do                local
model       weaponMesh1=glockg.3do              local
keyframe    mountAnim1=glockVmnt.key            local
keyframe    dismountAnim1=glockVdis.key         local
keyframe    povfireAnim1=glockVfire.key         local
keyframe    reloadAnim1=glockVreload.key        local
keyframe    chamberAnim1=glockVchamber.key      local
sound       fireSound1=glock.wav                local
template    projectile1=+bullet9mm              local

model       povModel2=mac10v.3do                local
model       weaponMesh2=macg.3do                local
keyframe    mountAnim2=microVmnt.key            local
keyframe    dismountAnim2=microVdis.key         local
keyframe    povfireAnim2=microVpst1.key         local
keyframe    reloadAnim2=microVreload.key        local
keyframe    chamberAnim2=microVchamber.key      local
sound       fireSound2=mac10_fire.wav           local
template    projectile2=+bullet9mm              local

model       povModel3=microv.3do                local
model       weaponMesh3=macg.3do                local
keyframe    mountAnim3=microVmnt.key            local
keyframe    dismountAnim3=microVdis.key         local
keyframe    povfireAnim3=microVpst1.key         local
keyframe    reloadAnim3=microVreload.key        local
keyframe    chamberAnim3=microVchamber.key      local
sound       fireSound3=micro_fire.wav           local
template    projectile3=+bullet9mm              local

message     trigger
message     pulse
message     activated
message     deactivated
message     selected
message     deselected
message     autoselect
message     fire
message     timer
message     user0
message     user1

end

# ========================================================================================

code

Trigger:
   player = GetLocalPlayerThing();
   If(GetSourceRef() != 9) Return;
   SetInv(player, 115 + gunnum, 300);
   call setgun;
   Return;

# ........................................................................................

Pulse:
   If(GetThingHealth(player) <= 0)
   {
      If(weapThing != -1) DestroyThing(weapThing);
      weapThing = -1;
      SetPulse(0);
      Return;
   }
   If(GetCurrentCamera())
   {
      SetThingCurGeoMode(weapThing, 0);
      Return;
   }
   SetThingCurGeoMode(weapThing, GetThingGeoMode(weapThing));
   SetThingPos(weapThing, GetThingPos(player));
   dummy = FireProjectile(player, ldummy, -1, -1, '0 0 0', '0 0 0', 0,0,0,0);
   SetThingLook(weapThing, GetThingLvec(dummy));
   DestroyThing(dummy);
   Return;

# ........................................................................................

Fire:
   // Check that the player is still alive.
   if(GetThingHealth(player) <= 0)
      Return;

   If(reloading) Return;
   If(!canFire) Return;

   // Check Ammo - If we are out, autoselect best weapon.
   if(GetInv(player, 115 + gunnum) < 1.0)
   {
      PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
      if(GetAutoSwitch() & 1)
         SelectWeapon(player, AutoSelectWeapon(player, 1));
      Return;
   }

   If(rounds <= 0)
   {
      PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
      Return;
   }

   SetPOVShake('0.0 0 0.0', '5 0 0', .05, 80.0);

   mult = VectorLen(GetThingVel(player))*stability;
   randvect = VectorSet((.5-Rand())*(acc+mult), (.5-Rand())*(acc+mult), 0);
   If(IsThingCrouching(player)) randvect = VectorScale(randvect, .9);
   If(selector == 1) randvect = VectorScale(randvect, .7);
   If(selector == 2) randvect = VectorScale(randvect, .8);
   PlayMode(player, 8);
   SendTrigger(-1, 10, 0.0135, 0.12, 0.01, 0);
   SendTrigger(-1, 11, player, projectile, VectorX(randvect), VectorY(randvect));
   // SendTrigger(-1, 10, 0.0135, 0.09, 0.02, 0);
   // SendTrigger(-1, 12, player, case, 0, 0);
   PlayKey(weapThing, povFireAnim, 1, 0x1a);
   PlaySoundThing(fireSound, player, 1, -1, -1, 0x80);
   ChangeInv(player, 115 + gunnum, -1);
   ChangeInv(player, display, -1);
   rounds = rounds - 1;
   SetInv(player, 14, rounds/clipsize*400);

   If(selector == 1) canFire = 0;
   If(selector == 2)
   {
      canFire = 0;
      SetTimerEx(fireWait, 4, 1, 0);
      ChangeFireRate(player, fireWait*3);
      Return;
   }
   ChangeFireRate(player, fireWait);

   Return;

# ........................................................................................

activated:
   player = GetSourceRef();
   mode = GetSenderRef();

   If(reloading) Return;
   If(rounds <= 0)
   {
      PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
      Return;
   }
   If(!canFire) Return;

   jkSetWaggle(player, '0.0 0.0 0.0', 0);

   powerBoost = GetInv(player, 63);
   If(selector == 2)
      ActivateWeapon( player, fireWait*3, mode );
   Else
      ActivateWeapon( player, fireWait, mode );

   Return;

# ........................................................................................

deactivated:
   player = GetSourceRef();
   mode = GetSenderRef();

   If(rounds <= 0 && GetInv(player, 115 + gunnum) > 0)
      call reload;

   canFire = 1;

   jkSetWaggle(player, '10.0 7.0 0.0', 350);
   DeactivateWeapon( player, mode );

   Return;

# ........................................................................................

selected:
   player = GetSourceRef();

   // Play external mounting animation
   PlayMode(player, 41);

   // Setup the meshes and models.
   weapThing = CreateThing(weapdummy, player);
   AttachThingToThingEx(weapThing, player, 0x8);
   SetThingModel(weapThing, povModel);
   SetArmedMode(player, 1);
   jkSetWeaponMesh(player, weaponMesh);

   // Play mounting sound.
   PlaySoundThing(mountSound, player, 1.0, -1.0, -1.0, 0x80);

   // Play the animation (NOLOOP + UNIQUE + ENDPAUSE).
   // The animation is held at the last frame after it is played.
   trackID = PlayKey(weapThing, mountAnim, 0, 0x14);
   SetMountWait(player, GetKeyLen(mountAnim));

   // Clear saber flags, and allow activation of the weapon
   jkClearFlags(player, 0x5);
   SetCurWeapon(player, gunnum);

   // Check Ammo - If we are out, autoselect best weapon.
   if(GetInv(player, 115 + gunnum) < 1.0)
   {
      PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
      if(GetAutoSwitch() & 1)
         SelectWeapon(player, AutoSelectWeapon(player, 1));
   }

   SetInv(player, display, GetInv(player, 115 + gunnum));
   SetPulse(.003);
   reloading = 0;
   SetInv(player, 14, rounds/clipsize*400);
   SetInv(player, 13, 2*selector/7*200);
   If(rounds <= 0) call reload;
   canFire = 1;

   Return;

# ........................................................................................

deselected:
   player = GetSourceRef();

   PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80);
   PlayKey(weapThing, dismountAnim, 0, 0x12);

   holsterWait = GetKeyLen(holsterAnim);
   SetMountWait(player, holsterWait);
   holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
   SetTimerEx(holsterWait, 2, 0.0, 0.0);
   if (trackID != -1)
   {
      StopKey(weapThing, trackID, 0);
      trackID = -1;
   }
   jkSetWaggle(player, '0.0 0.0 0.0', 0);

   Return;

# ........................................................................................

Autoselect:
   selectMode = GetSenderRef();
   player = GetSourceRef();

   // If the player has the weapon
   if(GetInv(player, 123) != 0.0)
   {
      // If the player has ammo
      if(GetInv(player, 115 + gunnum) > 0.0)
      {
            ReturnEx(gunnum*100);
      }
      else
      {
         ReturnEx(-1.0);
      }
   }
   else
   {
      ReturnEx(-1.0);
   }

   Return;

# ........................................................................................

Timer:
   If(GetSenderID() == 2)
   {
      StopKey(player, holsterTrack, 0);
      SetPulse(0);
      If(weapThing != -1) DestroyThing(weapThing);
      weapThing = -1;
   }
   If(GetSenderID() == 3)
   {
      rounds = clipsize + chambered;
      If(GetInv(player, 115 + gunnum) < clipsize + chambered)
         rounds = GetInv(player, 115 + gunnum);
      SetInv(player, 14, rounds/clipsize*400);
      reloading = 0;
   }
   If(GetSenderID() == 4 && GetParam(0) < 3)
   {
      If(GetInv(player, 115 + gunnum) <= 0 || rounds <= 0) Return;
      If(GetThingHealth(player) <= 0) Return;
      mult = VectorLen(GetThingVel(player))*stability;
      randvect = VectorSet((.5-Rand())*(acc+mult)*.8, (.5-Rand())*(acc+mult)*.8, 0);
      If(IsThingCrouching(player)) randvect = VectorScale(randvect, .9);
      PlayMode(player, 8);
      SendTrigger(-1, 10, 0.0135, 0.12, 0.01, 0);
      SendTrigger(-1, 11, player, projectile, VectorX(randvect), VectorY(randvect));
      // SendTrigger(-1, 10, 0.0135, 0.09, 0.02, 0);
      // SendTrigger(-1, 12, player, case, 0, 0);
      PlayKey(weapThing, povFireAnim, 1, 0x1a);
      PlaySoundThing(fireSound, player, 1, -1, -1, 0x80);
      ChangeInv(player, 115 + gunnum, -1);
      ChangeInv(player, display, -1);
      rounds = rounds - 1;
      SetInv(player, 14, rounds/clipsize*400);
      SetTimerEx(fireWait, 4, GetParam(0)+1, 0);
   }
   Return;

# ........................................................................................

User0:
   If(GetCurWeaponMode() != -1) Return;
   call reload;
   Return;

# ........................................................................................

User1:
   If(GetCurWeaponMode() != -1) Return;
   If(reloading) Return;
   If(selector == 1)
   {
      If(fireModes & 0x2) selector = 2;
      Else If(fireModes & 0x4) selector = 3;
   }
   Else If(selector == 2)
   {
      If(fireModes & 0x4) selector = 3;
      Else If(fireModes & 0x1) selector = 1;
   }
   Else If(selector == 3)
   {
      If(fireModes & 0x1) selector = 1;
      Else If(fireModes & 0x2) selector = 2;
   }
   If(selector == 1) Print("Semi-Auto");
   If(selector == 2) Print("3 Round Burst");
   If(selector == 3) Print("Full-Auto");
   SetInv(player, 13, 2*selector/7*200);
   Return;

# ........................................................................................

Reload:
   If(reloading) Return;
   If(GetThingHealth(player) <= 0) Return;
   If(!canFire) Return;
   If(rounds > 0) chambered = 1;
   Else chambered = 0;
   reloading = 1;
   SetInv(player, 14, 0);
   SetMountWait(player, GetKeyLen(chamberAnim[chambered]));
   SetTimerEx(GetKeyLen(chamberAnim[chambered]), 3, 0, 0);
   PlaySoundThing(chamberSound[chambered], player, 1, -1, -1, 0x80);
   PlayKey(weapThing, chamberAnim[chambered], 1, 0x2);
   Return;

# ........................................................................................

Setgun:
   If(GetInv(player, 123) == 0)
   {
      SetInv(player, gunnum, 0);
      Return;
   }
   SetInv(player, gunnum, 1);
   If(GetInv(player, 123) == 1) // Glock 18
   {
      povModel = povModel1;
      weaponMesh = weaponMesh1;
      mountAnim = mountAnim1;
      dismountAnim = dismountAnim1;
      povfireAnim = povfireAnim1;
      reloadAnim = reloadAnim1;
      chamberAnim = chamberAnim1;
      fireSound = fireSound1;
      projectile = projectile1;
      fireWait = 0.12;
      acc = 2.9;
      stability = .8; // number multiplied by movement
      fireModes = 0x5; // 0x1 S - 0x2 3RB - 0x4 F
      clipsize = 32;
   }
   Else If(GetInv(player, 123) == 2) // Mac10
   {
      povModel = povModel2;
      weaponMesh = weaponMesh2;
      mountAnim = mountAnim2;
      dismountAnim = dismountAnim2;
      povfireAnim = povfireAnim2;
      reloadAnim = reloadAnim2;
      chamberAnim = chamberAnim2;
      fireSound = fireSound2;
      projectile = projectile2;
      fireWait = 0.05;
      acc = 4;
      stability = 1; // number multiplied by movement
      fireModes = 0x4; // 0x1 S - 0x2 3RB - 0x4 F
      clipsize = 32;
   }
   Else If(GetInv(player, 123) == 3) // Micro-Uzi
   {
      povModel = povModel3;
      weaponMesh = weaponMesh3;
      mountAnim = mountAnim3;
      dismountAnim = dismountAnim3;
      povfireAnim = povfireAnim3;
      reloadAnim = reloadAnim3;
      chamberAnim = chamberAnim3;
      fireSound = fireSound3;
      projectile = projectile3;
      fireWait = 0.085;
      acc = 3;
      stability = .8; // number multiplied by movement
      fireModes = 0x5; // 0x1 S - 0x2 3RB - 0x4 F
      clipsize = 24;
   }
   If(fireModes & 0x4) selector = 3;
   Else selector = 1;
   rounds = clipsize + 1;
   Return;

end

and Kyle.cog, just incase
Code:
# Jedi Knight Cog Script
#
# KYLE.COG
#
# Main script for the player. Handles things like saber info,
# saber blocking animations, invulnerability at respawn, etc.
#
# [DP]
#

symbols

thing       player                           local

int         nextBlock=0                      local
int         bin                              local
int         rank                             local

int         force_blinding=0                 local
int         blindingEffectHandle=-1          local
int         PulledWeapon                     local

int         playersector                     local
vector      playerpos                        local
int         bub                              local

template    tpl=+FPBryarPistol               local
template    tpl1=+FPBryarPistol              local
template    tpl2=+FPBryarPistol              local
template    tpl3=+FPSTrifle                  local
template    tpl4=+FPDetonator                local
template    tpl5=+FPCrossbow                 local
template    tpl6=+FPRepeaterGun              local
template    tpl7=+FPRailGun                  local
template    tpl8=+FPSeqCharge                local
template    tpl9=+FPConcRifle                local

template    smoke_tpl=+heavysmoke            local
int         smoke                            local

template    teleport_particles=+telesparks   local
sound       teleportsnd=ForceThrow01.WAV     local

template    bubble_tpl=bubble                local
template    bubble_tpl2=bubble2              local
template    bubble_tpl3=bubble3              local

template    splash_tpl=+watersplash          local
template    splash_tpl2=+watersplash2        local
int         a_splash                         local
int         sender                           local
int         source                           local

keyframe    povBlockAnim0=SabVblk0.key       local
keyframe    povBlockAnim1=SabVblk1.key       local
keyframe    povBlockAnim2=SabVblk2.key       local

keyframe    blockAnim0=KYblock0.key          local
keyframe    blockAnim1=KYblock1.key          local
keyframe    blockAnim2=KYblock2.key          local

int         dummy=0                          local
int         blockPOVTrack=-1                 local
int         blockTrack=-1                    local

int         griptrackID=-1                   local
flex        intensity                        local
flex        flashwait                        local
int         flashblind                       local
int         flashblind1                      local
int         flashblind2                      local
int         flashblind3                      local

message     startup
message     killed
message     newplayer
message     timer
message     blocked
message     skill
message     damaged
message     splash
message     user0
message     user1

end

# ========================================================================================

code

startup:
   player = GetLocalPlayerThing();
   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);

   if(!IsMulti()) call init_kyle;

   // Bubbles
   if(IsMulti())
      SetTimerEx(4 + 5 * rand(), 2, 0, 0);
   else
      SetTimerEx(2 + 5 * rand(), 2, 0, 0);

   Return;

# ........................................................................................

killed:
   if(player != GetSenderRef()) Return;

   if(IsMulti())
   {
      CreateBackpack(player);
      ClearActorFlags(player, 0x2000);
   }

   // clean up force powers stuff
   if(blindingEffectHandle!=-1)
   {
      freeColorEffect(blindingEffectHandle);
      blindingEffectHandle = -1;
   }
   ClearActorFlags(player, 0x800);
   KillTimerEx(27);
   force_blinding = 0;

   ClearActorFlags(player, 0x40000);
   For(i=0; i<4; i=i+1)
   {
      If(flashBlind != -1) freeColorEffect(flashBlind);
      flashBlind = -1;
   }

   if(griptrackID != -1)
   {
      StopKey(player, griptrackID, 0.1);
      griptrackID = -1;
   }

   Return;

# ........................................................................................

damaged:
   if(GetParam(1) == 32) call make_bubbles;
   If(GetParam(1) == 2)
   {  
      If(VectorZ(VectorSub(GetThingPos(GetSourceRef()), GetThingPos(player))) > .038)
      {
         ReturnEx(1000);
         Return;
      }
   }
   ReturnEx(GetParam(0));
   Return;

# ........................................................................................

make_bubbles:
   playersector = GetThingSector(player);
   playerpos    = VectorAdd(GetThingPos(player), '0 0 0.075');

   for(bub = 1; bub < 1 + 3 * rand(); bub = bub + 1)
   {
      CreateThingAtPosNR(bubble_tpl[3 * rand()], playersector, VectorAdd(playerpos, VectorScale(VectorNorm(VectorSet(rand()-0.5, rand()-0.5, rand()-0.5)), 0.05)), '0 0 0');
      Sleep(0.05);

      // Don't create too many bubbles over the network...
      if(!IsMulti())
      {
         CreateThingAtPos(bubble_tpl3, playersector, VectorAdd(playerpos, VectorScale(VectorNorm(VectorSet(rand()-0.5, rand()-0.5, rand()-0.5)), 0.05)), '0 0 0');
         Sleep(0.05);
      }
   }

   Return;

# ........................................................................................

newplayer:

   // If it's multiplayer
   if(IsMulti()) call init_multi_kyle;
   Else call init_kyle;

   // Start Bubbles
   SetTimerEx(2 + 5 * rand(), 2, 0, 0);

   Return;

# ........................................................................................

timer:
   if(GetSenderId() == 1)                    // Invulnerable for a while
   {
      // jkSetInvulnerable(GetParam(0), 0);
      ClearActorFlags(GetParam(0), 8);
      Return;
   }
   else
   if(GetSenderId() == 2)                    // Bubbles check
   {
      if(GetThingHealth(player) < 1) Return;

      if((GetThingFlags(player) & 0x2000000) && !(GetPhysicsFlags(player) & 0x100000))
         call make_bubbles;

      if(IsMulti())
         SetTimerEx(4 + 5 * rand(), 2, 0, 0);
      else
         SetTimerEx(2 + 5 * rand(), 2, 0, 0);

      Return;
   }
   else
   if(GetSenderId() == 24)
   {
      // A pulled weapon must be made takeable again
      SetCollideType(GetParam(0), 1);
      Return;
   }
   else
   if(GetSenderId() == 27)
   {
      if(blindingEffectHandle!=-1)
      {
         freeColorEffect(blindingEffectHandle);
         blindingEffectHandle = -1;
      }
      // Get the effect ramping down
      AddDynamicTint(player, 200 + 8 * rank, 210 + 10 * rank, 200 + 8 * rank);
      ClearActorFlags(player, 0x800);
      force_blinding = 0;
      Return;
   }
   else
   if(GetSenderId() == 31)
   {
      if(griptrackID != -1)
      {
         StopKey(player, griptrackID, 0.1);
         griptrackID = -1;
      }
      ClearActorFlags(player, 0x40000);
      Return;
   }
   Else If(GetSenderID() == 50)
   {
      For(i=0; i<4; i=i+1)
      {
         If(flashBlind != -1) freeColorEffect(flashBlind);
         flashBlind = -1;
      }
      intensity = GetParam(0) * 0.99;
      If((intensity <= 0) || (GetThingHealth(player) == 0)) Return;
      For(i=0; i<4; i=i+1)
         flashBlind = NewColorEffect(0, 0, 0, 0, 0, 0, intensity, intensity, intensity, 1);
      SetTimerEx(GetParam(1), 50, intensity, GetParam(1));
   }

   Return;

# ........................................................................................

blocked:
   if(player != GetSenderRef()) Return;

   if (blockPOVTrack != -1)
   {
      jkStopPOVKey( player, blockPOVTrack, 0.1 );
      blockPOVTrack = -1;
   }
   if (blockTrack != -1)
   {
      StopKey( player, blockTrack, 0.1 );
      blockTrack = -1;
   }

   // PlaySoundThing(hitSound14, player, 1.0, -1, -1, 0);
   blockPOVTrack = jkPlayPOVKey(player, povBlockAnim0[nextBlock], 2, 0x1a);
   blockTrack = PlayKey(player, blockAnim0[nextBlock], 2, 0x1a);

   nextBlock = nextBlock + 1;
   if(nextBlock > 2)
      nextBlock = 0;

   Return;

# ........................................................................................

// This message is sent from the weap_saber.cog
user0:
   if (blockPOVTrack != -1)
   {
      jkStopPOVKey( player, blockPOVTrack, 0.1 );
      blockPOVTrack = -1;
   }
   if (blockTrack != -1)
   {
      StopKey( player, blockTrack, 0.1 );
      blockTrack = -1;
   }
   Return;

# ........................................................................................

User1:
   intensity = GetParam(0);
   flashWait = GetParam(1) / 100;
   KillTimerEx(50);
   For(i=0; i<4; i=i+1)
   {
      If(flashBlind != -1) freeColorEffect(flashBlind);
      flashBlind = -1;
      flashBlind = NewColorEffect(0, 0, 0, 0, 0, 0, intensity, intensity, intensity, 1);
   }
   SetTimerEx(flashWait, 50, intensity, flashWait);
   Return;

# ........................................................................................

skill:

   // player might be dead when skill: arrives over the net...
   if(GetThingHealth(player) <= 0) Return;

   // Handle multiplayer force power effects
   bin = GetParam(0);
   rank = GetParam(1);

   if(bin == 24)                             // Force Pull
   {
      ReturnEx(0);
      if(!IsInvActivated(player, 28))        // Absorb makes player immune to Pull
      {
         if((GetCurWeapon(player) != 1) && (GetCurWeapon(player) != 10))
         {
            // Create a powerup corresponding to the current weapon
            PulledWeapon = CreateThingAtPos(tpl[GetCurWeapon(player)], GetThingSector(player), GetThingPos(player), '0 0 0');

            // Make the powerup collide later
            SetTimerEx(0.2, 24, PulledWeapon, 0);

            // Duplicate for internet games
            SetTimerEx(0.25, 24, PulledWeapon, 0);

            // Throw the powerup at the player
            ApplyForce(PulledWeapon, VectorScale(VectorNorm(VectorSub(GetThingPos(GetSourceRef()), GetThingPos(player))), 30));

            // Remove the weapon from the player
            ChangeInv(player, GetCurWeapon(player), -1);

            // Switch to fists
            SelectWeapon(player, 1);

            ReturnEx(1);
         }
      }

      Return;
   }
   else
   if (bin == 27)                            // Force Blinding
   {
      if((!force_blinding) && (!IsInvActivated(player, 23)))   // Seeing makes player immune to Blinding
      {
         force_blinding = 1;
         blindingEffectHandle = newColorEffect(0, 0, 0, 0, 0, 0, 200 + 8 * rank, 210 + 10 * rank, 200 + 8 * rank, 1.0);
         SetActorFlags(player, 0x800);
         SetTimerEx(4 * rank, 27, player, 0);
         ReturnEx(1);
      }
      else
      {
         ReturnEx(0);
      }

      Return;
   }
   else
   if (bin == 31)                            // Force Grip
   {
      if(!IsInvActivated(player, 29))        // Protection makes player immune to Grip
      {
         griptrackID = PlayMode(player, 25);
         SetActorFlags(player, 0x40000);

         // Print("You are taking Grip damage");
         jkPrintUNIString(player, 300);
         DamageThing(player, 2 * rank, 0x8, GetSourceRef());
         SetTimerEx(0.5, 31, player, 0);
         ReturnEx(1);
      }
      else
      {
         ReturnEx(0);
      }

      Return;
   }
   else
   if (bin == 34)                            // Deadly Sight
   {
      // Print("You are taking Deadly Sight damage");
      jkPrintUNIString(player, 301);
      DamageThing(player, 4 * rank, 0x8, GetSourceRef());
      smoke = CreateThingAtPosNR(smoke_tpl, GetThingSector(player), GetThingPos(player), '0 0 0');
      // Raise the tint above the normal damage tint
      if(GetCurrentCamera() == 0)
         AddDynamicTint(player, 0.15, 0.0, 0.07);
      ReturnEx(1);
      Return;
   }

   ReturnEx(-1);
   Return;

# ........................................................................................

splash:
   // splash: messages are only sent to the local player's cogs
   // (class cog and capture cog) for performance reasons...

   sender = GetSenderRef();
   source = GetSourceRef();

   // actor or player ?
   if((GetThingType(sender) == 2) || (GetThingType(sender) == 10))
   {
      // whatever source (i.e. enter or leave, don't care)
      a_splash = CreateThingAtPosNR(splash_tpl2, GetThingSector(sender), GetThingPos(sender), '0 0 0');
   }
   // these are mostly the projectiles...
   else
   {
      // on entering only
      if(source == 1)
         // not if player is submerged, but still do it if he's on the surface
         if(!(GetThingFlags(player) & 0x2000000) || (GetPhysicsFlags(player) & 0x100000))
            a_splash = CreateThingNR(splash_tpl, sender);
   }

   Return;

# ........................................................................................

init_kyle:
   SetActorFlags(player, 8);
   SetTimerEx(1.50, 1, player, 0);

   // Set Health to full
   SetThingHealth(player, 100);

   // Set Shields to 100 minimum
   if(GetInv(player, 60) < 100) SetInv(player, 60, 100);

   // Set the power boost to 1.0
   SetInv(player, 63, 1.0);

   // When player starts, give him fists, and a bryar.
   SetInv(player, 1, 1);
   SetInv(player, 9, 1);
   SetInv(player, 10, 0);

   // Give 50 energy minimum
   if(GetInv(player, 11) < 50) SetInv(player, 11, 50.0);

   // Bacta
   if(GetInv(player, 40) == 0)
      SetInvAvailable(player, 40, 0);
   else
      SetInvAvailable(player, 40, 1);

   // IR Goggles
   if(GetInv(player, 41))
      SetInvAvailable(player, 41, 1);
   else
      SetInvAvailable(player, 41, 0);
   SetInvActivated(player, 41, 0);

   // Field Light
   SetInv(player, 42, 1);
   SetInvAvailable(player, 42, 1);
   SetInvActivated(player, 42, 0);
   ClearActorFlags(player, 4);

   jkEndTarget();

   Return;

# ........................................................................................

init_multi_kyle:

   // Set Weapons
   SetInv(player, 1, 1);
   SetInv(player, 9, 1);
   SetInv(player, 10, 0);

   // Set Ammo
   SetInv(player, 11, 0.0);
   SetInv(player, 12, 0.0);
   SetInv(player, 15, 0.0);

   // Remove bacta tank and IR goggles
   SetInv(player, 40, 0);
   SetInvAvailable(player, 40, 0);
   // SetInv(player, 41, 0);
   // SetInvAvailable(player, 41, 0);

   // Set shields to 100
   // SetInv(player, 60, 100);

   // Do respawn effects
   dummy = CreateThingAtPos(teleport_particles, GetThingSector(player), GetThingPos(player), '0 0 0');
   dummy = PlaySoundThing(teleportsnd, player, 1.0, -1, -1, 0x180);

   SetFireWait(player, -1);
   SetMountWait(player, 0);
   SetCurInvWeapon(player, 0);
   SelectWeapon(player, AutoSelectWeapon(player, 1));

   Return;

end

You can get not quite as recent versions of the cogs in [http://jkhub.massassi.net/project/show.php?projid=71§ion=download]firearms alpha.[/url] The same problem is present in those. I will take almost any idea on why this is happening.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2005-08-04, 10:48 AM #2
Well, I did a quick (heh, took like 15 minutes) scan of your code and I don't see any obvious issues. I'll revisit this again this evening and see if I can come up with any ideas for what could be doing it.

QM

P.S. - Shouldn't the Steyr TMP be in the Machine-Pistols section? I thought TMP stood for Tactical Machine Pistol.
2005-08-04, 12:11 PM #3
TMP does, however, for my machine-pistols, I took only things that could be slid into a holster/1hand controlable.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2005-08-04, 12:48 PM #4
There are many strange crash bugs that seem to come up in cogs. In one cog, I needed to start the pulse in a really short timer or else the game would crash if I reset after dying in Singleplayer. :rolleyes:

Maybe try starting the pulse after a timer?
visit my project

"I wonder to myself. Why? Simply why? Why why? Why do I ask why? Why do I need to find out why? Why do I have to ask why as a question? Why is why always used to find out why? Why is the answer to why always why? Why is there no final answer to why? Simply why not? Holy cow, this is pretty deep, meaningful **** I wrote. Glad I wrote it down. Oh man."
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ [slog], Echoman
2005-08-04, 4:20 PM #5
Could I see this cog in question perhaps, tho that is singleplayer....... *shrugs*
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack

↑ Up to the top!