Hi!
I'm changing a STRifle to do a berzerk shot, but something isn't quite working...
        
When I shoot, it is supposed to have a ten second warm up (basically 10 seconds for the bolt to complete its task in spreading death to the level before the next one comes). Now it doesn't always begin the timer or even play the sound, therefore I added this secondary fire to try it again with a less waiting time. But often that doesn't work. I have tried this berzerk shot once before. Works fine when I test it in the testing level, but when I put the pieces together in a folder and in the respective files (JKL templates and stuff) they wouldn't come out, so I try once again without having too much new in the JKL. I tried a ParseArg to add a trail cog, but it didn't work out, so I tried to place it all in one cog. Help!
/Edward
                
                
                    
                
            I'm changing a STRifle to do a berzerk shot, but something isn't quite working...
Code:
        
    # Jedi Knight Cog Script
#
# WEAP_STRIFLE.COG
#
# WEAPON 3 script - Stormtrooper Rifle
#
# The standard rifle used by the stormtroopers.  Not as accurate as the Bryar Pistol.
# This weapon has only one type of fire.
#
# - Affected by MagSealed sectors/surfaces.
#
# [YB & CYW]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
symbols
model       povModel=strv.3do                   local
model       weaponMesh=strg.3do                 local
keyframe    mountAnim=StrVmnt.key               local
keyframe    dismountAnim=StrVdis.key            local
keyframe    povfireAnim=StrVpst1.key            local
keyframe    holsterAnim=kyhlstr.key             local
sound       mountSound=df_rif_ready.wav         local
sound       dismountSound=PutWeaponAway01.wav   local
sound       fireSound=trprsht2.wav              local
sound       outSound=trprout.wav                local
template    projectil=+raildet                 local
template	projectile0=+bryarbolt		local
template	projectile1=+stlaser		local
template	projectile2=+grenade2		local
template	projectile3=+crossbowbolt3	local
template	projectile4=+repeaterball	local
template	projectile5=+raildet2		local
template	projectile6=+seqchrg2		local
template	projectile7=+concbullet		local
template	projectile8=+force_lightning	local
template	projectile9=+force_dest_p1	local
thing       player                              local
vector      randVec                             local
flex        fireWait=0.2                        local
flex        holsterWait                         local
flex        powerBoost                          local
flex        autoAimFOV=25                       local
flex        autoAimMaxDist=5                    local
thing		eegad=-1			local
thing		g				local
int         dummy                               local
int         trackID=-1                          local
int         fireChannel=-1                      local
int         holsterTrack                        local
int         mode                                local
int		busy=0				local
sound		warmup=forcefieldhum01.wav	local
int		chachacha=1			local
message     activated
message     deactivated
message     selected
message     deselected
message     autoselect
message     fire
message     timer
message		pulse
end
# ========================================================================================
code
fire:
   player = GetSourceRef();
   mode = GetSenderRef();
if(mode==0) {
   // Check that the player is still alive.
   if(GetThingHealth(player) <= 0)
   {
      Return;
   }
   // Check Ammo - If we are out, autoselect best weapon.
   // It should always use two energy cells, but -- as in DF --
   // allow the last fire if there is only one left...
   if(GetInv(player, 11) < 100.0)
   {
      PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
      if((GetAutoSwitch() & 1))
         SelectWeapon(player, AutoSelectWeapon(player, 1));
      Return;
   }
   // Get random aiming error
   randVec = VectorSet((Rand()-0.5)*5, (Rand()-0.5)*5, 0.0);
	if(busy==1) { print("Warming up! Please wait..."); return; }
   SetPOVShake('0.0 -.003 0.0', '1.5 0.0 0.0', .05, 80.0);
   eegad = FireProjectile(player, projectil, fireSound, 8, '0.0168 0.1896 0.00', randVec, 1, 0x31, autoAimFOV, autoAimFOV*2);
	busy=1;
	captureThing(eegad);
	chachacha=PlaySoundThing(warmup,player,1,-1,1,0x81);
	ChangeSoundPitch(chachacha,0.01,0.01);
	sleep(0.01);
	SetTimer(10);
	ChangeSoundPitch(chachacha,2,10);
	SetPulse(0.1);
   // SetThingVel(dummy, vectorScale(GetThingVel(dummy), 0.01));
   ChangeInv( player, 11, -100.0 );
   jkPlayPOVKey( player, povfireAnim, 1, 0x38 );
   powerBoost = GetInv(player, 63);
   ChangeFireRate(player, fireWait/powerBoost);
} else { 
print("Instant warm up! Hopefully...");
	chachacha=PlaySoundThing(warmup,player,1,-1,1,0x81);
	ChangeSoundPitch(chachacha,0.01,0.01);
	sleep(0.01);
	SetTimer(1);
	ChangeSoundPitch(chachacha,2,1);
}
   Return;
# ........................................................................................
activated:
   player = GetSourceRef();
   mode = GetSenderRef();
   jkSetWaggle(player, '0.0 0.0 0.0', 0);
   powerBoost = GetInv(player, 63);
   ActivateWeapon(player, fireWait/powerBoost, mode);
   Return;
# ........................................................................................
deactivated:
   player = GetSourceRef();
   jkSetWaggle(player, '10.0 7.0 0.0', 350);
   DeactivateWeapon(player, mode);
   Return;
# ........................................................................................
selected:
   player = GetSourceRef();
	busy=0;
   PlayMode(player, 41);
   PlaySoundThing(mountSound, player, 1.0, -1, -1, 0x80);
   jkSetPOVModel(player, povModel);
   SetArmedMode(player, 1);
   jkSetWeaponMesh(player, weaponMesh);
   jkSetWaggle(player, '10.0 7.0 0.0', 350);
   trackID = jkPlayPOVKey(player, mountAnim, 0, 20);
   SetMountWait(player, GetKeyLen(mountAnim));
   jkClearFlags(player, 0x5);
   SetCurWeapon(player, 3);
   Return;
# ........................................................................................
deselected:
   player = GetSourceRef();
StopSound(chachacha,1);
	SetTimer(0);
   PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80);
   jkPlayPOVKey(player, dismountAnim, 0, 0x18);
   holsterWait = GetKeyLen(holsterAnim);
   SetMountWait(player, holsterWait);
   holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
   SetTimerEx(holsterWait, 2, 0.0, 0.0);
   if (trackID != -1)
   {
      jkStopPOVKey(player, trackID, 0);
      trackID = -1;
   }
   jkSetWaggle(player, '0.0 0.0 0.0', 0);
   Return;
# ........................................................................................
autoselect:
   player = GetSourceRef();
   // If the player has the weapon
   if(GetInv(player, 3) != 0.0)
   {
      // If the player has ammo
      if(GetInv(player, 11) != 0.0)
      {
         ReturnEx(600.0);
      }
      else
      {
         ReturnEx(-1.0);
      }
   }
   else
   {
      ReturnEx(-1.0);
   }
   Return;
# ........................................................................................
timer:
	if(busy==1)
	{
		busy=0;
		StopSound(chachacha,1);
		print("DING! Fries are done!");
	}
	else
	{
   StopKey(player, holsterTrack, 0.0);
	}
   Return;
pulse:
	if(busy==0) return;
	g=CreateThing(projectile0[rand()*9],eegad);
	CaptureThing(g);
	SetThingVel(g,VectorSet((rand()*2.00)-1.00,(rand()*2.00)-1.00,(rand()*2.00)-1.00));
	SetThingLVec(g,VectorSet((rand()*2.00)-1.00,(rand()*2.00)-1.00,(rand()*2.00)-1.00));
return;
endWhen I shoot, it is supposed to have a ten second warm up (basically 10 seconds for the bolt to complete its task in spreading death to the level before the next one comes). Now it doesn't always begin the timer or even play the sound, therefore I added this secondary fire to try it again with a less waiting time. But often that doesn't work. I have tried this berzerk shot once before. Works fine when I test it in the testing level, but when I put the pieces together in a folder and in the respective files (JKL templates and stuff) they wouldn't come out, so I try once again without having too much new in the JKL. I tried a ParseArg to add a trail cog, but it didn't work out, so I tried to place it all in one cog. Help!
/Edward
 
![http://forums.massassi.net/html/smile.gif [http://forums.massassi.net/html/smile.gif]](http://forums.massassi.net/html/smile.gif)
![http://forums.massassi.net/html/wink.gif [http://forums.massassi.net/html/wink.gif]](http://forums.massassi.net/html/wink.gif) 
    ![http://forums.massassi.net/html/tongue.gif [http://forums.massassi.net/html/tongue.gif]](http://forums.massassi.net/html/tongue.gif)
![http://forums.massassi.net/html/biggrin.gif [http://forums.massassi.net/html/biggrin.gif]](http://forums.massassi.net/html/biggrin.gif) ), but for anything requiring some "thinking" rather than a "quick n' dirty fix", then Timers are by far your best shot
), but for anything requiring some "thinking" rather than a "quick n' dirty fix", then Timers are by far your best shot