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 → Railgun modification.
Railgun modification.
2004-06-01, 7:16 PM #1
This will be easier to understand if youve played ut but id like to alter the railgun slightly so that when you go to shoot (primary and secondary) then you can load bullets to your gun. For instance if you hold down fire for 1 second then relese it shoots 2 bullets instead of 1 and if you hold it for 2 seconds it shoots 3. But if you just click the mouse it only shoots the one bullets.

Here are the specifics for the cog:

-When you hold down fire (primary and secondary) it doesnt play a sound but after one second of holding it down it plays a sound and there are now two rockets loaded.

-And the same thing after two seconds but with 3 rokets.

-When the rockets shoot they dont shoot inside each other they shoot slighty to the left or right of each other (like in ut).

-You can only load 3 rockets in so it goes first second: 2 rockets second second: 3 rokets third second: fire (if you havent already relesed it).

If you need a copy of the rail det cog just say.

Thanks.

------------------
Nightfire Mod

[This message has been edited by a_person (edited June 01, 2004).]
Spoting an error in post will result in a $100 reward.
Offer expires on 6/6/06. Valid one per customer, per day.

Rangi
2004-06-02, 10:49 AM #2
That doesn't seem too hard, I could get one going, but I don't have JK installed, or in my house, for that matter. If you post the Rail and Bowcaster cogs, that would be a good start.

------------------
-There are easier things in life than finding a good woman, like nailing Jello to a tree, for instance

-Tazz
-There are easier things in life than finding a good woman, like nailing Jello to a tree, for instance

Tazz
2004-06-02, 6:16 PM #3
Raildet:

Code:
# Jedi Knight Cog Script
#
# WEAP_RAILDET.COG
#
# WEAPON 7 Script - Rail Detonator Gun
#
# This is a missile launcher type of weapon. It sends out an explosive device with
#  two options, impact or trigger explosion. The charge with the trigger option will
#  stick to a wall.
#
# - Not affected by MagSealed sectors/surfaces.
#
# [YB & CYW]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved


symbols

model       povModel=rldv.3do                   local
model       weaponMesh=rldg.3do                 local
sound       mountSound=RailChargeArm01.WAV      local
sound       dismountSound=PutWeaponAway01.wav   local
sound       fireSound=RailChargeFire01.WAV      local
sound       outSound=RailChargeEmpty01.WAV      local

thing       player                              local

keyframe    mountAnim=RldVmnt.key               local
keyframe    dismountAnim=RldVdis.key            local
keyframe    povfireAnim=RldVpst1.key            local
keyframe    holsterAnim=kyhlstr.key             local

template    projectile=+raildet                 local
template    projectile2=+raildet2               local

thing       rail                                local

flex        fireWait=1.0                        local
flex        powerBoost                          local
flex        autoAimFOV=25                       local
flex        autoAimMaxDist=5                    local
flex        holsterWait                         local

keyframe    railAnim=rld0anim.key               local

int         trackID=-1                          local
int         mode                                local
int         holsterTrack                        local

int         selectMode=1                        local

message     activated
message     deactivated
message     selected
message     deselected
#message     newplayer
message     autoselect
message     fire
message     timer

end

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

code

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

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

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

   jkPlayPOVKey(player, povfireAnim, 1, 0x38);
   SetPOVShake('0.0 -.01 0.0', '4.0 0.0 0.0', .05, 80.0);

   rail = FireProjectile(player, projectile[mode], fireSound, 18, '0.0214 0.15 0.00', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimFOV*2);
   if((mode == 1) && (rail != -1))
   {
      PlayKey(rail, railAnim, 1, 20);
   }

   // Provide a kick backwards
   ApplyForce(player, VectorScale(GetThingLVec(player), -40));

   ChangeInv(player, 15, -1.0);

   powerBoost = GetInv(player, 63);
   ChangeFireRate(player, fireWait/powerBoost);

   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();
   mode = GetSenderRef();
   jkSetWaggle(player, '10.0 7.0 0.0', 350);
   DeactivateWeapon( player, mode );
   Return;

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

selected:
   player = GetSourceRef();

   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, 7);

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

   Return;

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

deselected:
   player = GetSourceRef();

   PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80);
   jkPlayPOVKey( player, dismountAnim, 0, 18 );

   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;

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

//newplayer:
//   player = GetSourceRef();
//
//   // Make sure that if the player is respawning, the old mount isn't playing anymore.
//   if (trackID != -1)
//      jkStopPOVKey(player, trackID, 0);
//
//   Return;

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

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

   // If the player has the weapon
   if(GetInv(player, 7) != 0.0)
   {
      // If the player has ammo
      if(GetInv(player, 15) != 0.0)
      {

         // query for ammo
         if(selectMode == -1)
         {
            ReturnEx(900.0);
            Return;
         }

         if((selectMode == 0) && !(GetAutoPickup() & 2))
         {
            ReturnEx(900.0);
            Return;
         }

         if((selectMode == 1) && !(GetAutoSwitch() & 2))
         {
            ReturnEx(900.0);
            Return;
         }

         if((selectMode == 2) && !(GetAutoPickup() & 2))
         {
            ReturnEx(900.0);
            Return;
         }

         ReturnEx(-2.0);
         Return;

      }
      else
      {
         ReturnEx(-1.0);
         Return;
      }
   }
   else
   {
      ReturnEx(-1.0);
   }

   Return;

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

timer:
   StopKey(player, holsterTrack, 0.0);
   Return;

end


Bowcaster:
Code:
# Jedi Knight Cog Script
#
# WEAP_CROSSBOW.COG
#
# WEAPON 5 Script - Crossbow
#
# - Affected by MagSealed sectors/surfaces.
#
# [YB & CYW]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved


symbols

model       povModel=BowV.3do                   local
model       weaponMesh=BowG.3do                 local

keyframe    mountAnim=BowVmnt.key               local
keyframe    dismountAnim=BowVdis.key            local
keyframe    povfireAnim=BowVpst1.key            local
keyframe    holsterAnim=kyhlstr.key             local

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

sound       chargeSound=BCChargeUp.wav          local
sound       fireSound1=BCFire01.wav             local
sound       fireSound2=BCFire02.wav             local
sound       outSound=trprout.wav                local

template    projectile=+crossbowbolt            local
template    projectile2=+crossbowbolt2          local
template    projectile3=+crossbowbolt3          local

flex        fireWait=0.6                        local
flex        delayTime                           local
flex        error                               local
flex        autoAimFOV=30                       local
flex        autoAimMaxDist=10                   local
flex        powerBoost                          local
flex        holsterWait                         local

vector      errorVec                            local

thing       player                              local

int         trackID=-1                          local
int         channel=-1                          local
int         holsterTrack                        local

message     startup
message     activated
message     deactivated
message     selected
message     deselected
message     newplayer
message     autoselect
message     fire
message     killed
message     timer

end

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

code

startup:
   player = GetLocalPlayerThing();

   Return;

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

activated:
   mode = GetSenderRef();

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

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

      Return;
   }

   if(mode == 0)
   {
      ActivateWeapon(player, 0, mode);

      if(channel == -1)
      {
         channel = PlaySoundThing(chargeSound, player, 0.0, -1, -1, 0x181);

         if(channel != -1)
         {
            ChangeSoundPitch(channel, 0.3, 0.01);
            Sleep(0.03);

            // looks stupid... but if the user taps quickly deactivated:
            // gets called during the sleep, and channel becomes invalid !
            if(channel != -1)
            {
               ChangeSoundVol(channel, 1.0, 0.6);
               ChangeSoundPitch(channel, 1.0, 1.2);
            }
         }
      }
   }
   else
   {
      powerBoost = GetInv(player, 63);
      ActivateWeapon( player, fireWait/powerBoost, mode);
   }

   Return;

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

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

   // Check Ammo - If we are out, autoselect best weapon.
   if(GetInv(player, 12) < 2.0)
   {
      SelectWeapon(player, AutoSelectWeapon(player, 1));
      Return;
   }

   SetPOVShake('0.0 -.01 0.0', '2.0 0.0 0.0', .05, 80.0);
   dummy = FireProjectile(player, projectile3, fireSound2, 18, '0.0207 0.0888 0.00', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimFOV*2);
   ChangeInv(player, 12, -2.0);
   jkPlayPOVKey(player, povfireAnim, 1, 0x38);

   powerBoost = GetInv(player, 63);
   ChangeFireRate(player, fireWait/powerBoost);

   Return;


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

deactivated:
   mode = GetSenderRef();

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

   if(mode == 0)
   {
      delayTime = DeactivateWeapon(player, mode);

      if(channel != -1)
      {
         StopSound(channel, 0);
         channel = -1;
      }

      // Set a delay, even if we don't fire here.
      SetMountWait(player, fireWait/powerBoost);

      // Make sure both keys are up before continuing.
      if (GetCurWeaponMode() != -1) Return;

      // make sure we still have ammo
      if(GetInv(player, 12) < 2.0) Return;

      // Always fire one projectile straight-ahead
      SetPOVShake('0.0 -.01 0.0', '2.0 0.0 0.0', .05, 80.0);
      FireProjectile(player, projectile, fireSound2, 18, '0.0207 0.0888 0.00', '0 0 0', 0, 0, autoAimFOV, autoAimFOV*2);

      ChangeInv(player, 12, -2.0);

      if(delayTime > 0.6)
      {
         if(GetInv(player, 12) > 1.0)
         {
            FireProjectile(player, projectile2, -1, 18, '0.0207 0.0888 0.00', '0 6 0', 0, 0, autoAimFOV, autoAimMaxDist);
            FireProjectile(player, projectile2, -1, 18, '0.0207 0.0888 0.00', '0 -6 0', 0, 0, autoAimFOV, autoAimMaxDist);
            ChangeInv(player, 12, -2.0);
         }
      }

      if(delayTime > 1.2)
      {
         if(GetInv(player, 12) > 1.0)
         {
            FireProjectile(player, projectile2, -1, 18, '0.0207 0.0888 0.00', '0 12 0', 0, 0, autoAimFOV, autoAimMaxDist);
            FireProjectile(player, projectile2, -1, 18, '0.0207 0.0888 0.00', '0 -12 0', 0, 0, autoAimFOV, autoAimMaxDist);
            ChangeInv(player, 12, -2.0);
         }
      }

      // Play animation and set delay.
      jkPlayPOVKey(player, povfireAnim, 1, 0x38);
      powerBoost = GetInv(player, 63);
   }
   else
   {
      DeactivateWeapon(player, mode);
   }

   Return;

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

selected:
   // Play external animation
   PlayMode(player, 41);

   // Set up meshes and models.
   jkSetPOVModel(player, povModel);
   SetArmedMode(player, 1);
   jkSetWeaponMesh(player, weaponMesh);
   jkSetWaggle(player, '10.0 7.0 0.0', 350);

   // Play sound and animation.
   PlaySoundThing(mountSound, player, 1.0, -1, -1, 0x80);
   trackID = jkPlayPOVKey(player, mountAnim, 0, 20);
   SetMountWait(player, GetKeyLen(mountAnim));

   // Set flags, etc.
   jkClearFlags(player, 0x5);
   SetCurWeapon(player, 5);

   // Check Ammo - If we are out, autoselect best weapon.
   if(GetInv(player, 12) < 2.0)
   {
      if((GetAutoSwitch() & 1))
         SelectWeapon(player, AutoSelectWeapon(player, 1));
   }

   Return;

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

deselected:
   PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80);
   jkPlayPOVKey(player, dismountAnim, 0, 18);
   
   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);
   
   if(channel != -1)
   {
      StopSound(channel, 0.1);
      channel = -1;
   }

   Return;

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

killed:
   if (player == GetSenderRef())
   {
      if(channel != -1)
      {
         StopSound(channel, 0.1);
         channel = -1;
      }
   }
   Return;

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

newplayer:
//   // Make sure that if the player is respawning, the old mount isn't playing anymore.
//   if (trackID != -1)
//   {
//      jkStopPOVKey(player, trackID, 0);
//      trackID = -1;
//   }

   if(channel != -1)
   {
      StopSound(channel, 0.1);
      channel = -1;
   }

   Return;

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

autoselect:
   // If the player has the weapon
   if(GetInv(player, 5) != 0.0)
   {
      // If the player has ammo
      if(GetInv(player, 12) > 1.0)
      {
         ReturnEx(700.0);
      }
      else
      {
         ReturnEx(-1.0);
      }
   }
   else
   {
      ReturnEx(-1.0);
   }

   Return;

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

timer:
   StopKey(player, holsterTrack, 0.0);
   Return;

end


------------------
Nightfire Mod
Spoting an error in post will result in a $100 reward.
Offer expires on 6/6/06. Valid one per customer, per day.

Rangi
2004-06-03, 11:39 AM #4
Holy cow. I forgot how long weapon cogs were.

Now, what you need to do is look at how the bowcaster cog handles spread fire, and impliment that into the railgun cog. Or better yet, just put the railgun 3d0, animation, projectile, and sound templates into the bowcaster cog, rename that cog weap_raildet.cog, then go from there.

------------------
-There are easier things in life than finding a good woman, like nailing Jello to a tree, for instance

-Tazz
-There are easier things in life than finding a good woman, like nailing Jello to a tree, for instance

Tazz
2004-06-03, 1:24 PM #5
Actually, yeah. It's not really that hard at all. Just change the crossbow's model, projectiles, and sounds to the raildets, then change the number of projectiles for secondary fire that it can fire (3) and you'll have exactly what you want, minus the sounds.

JediKirby

------------------
<]-[ellequin> Nothing is quite as satisfying as placing a .177 lead pellet in between the eyes of a cat.
<]-[ellequin> I think I will leave it's corpse there, to warn all the other cats to keep out of my hibiscus patch

Live on, Adam.
ᵗʰᵉᵇˢᵍ๒ᵍᵐᵃᶥᶫ∙ᶜᵒᵐ
ᴸᶥᵛᵉ ᴼᵑ ᴬᵈᵃᵐ
2004-06-03, 11:19 PM #6
Can someone do it plz I hate the cog language.

BTW if anyone is going to do it then a few updates:

-I want all the rails to fire straight ahead not at an angle like bowcaster.

-It has to take the ammo off rails not power cells.

-Theres no charging noise but every time it loads a rocket in it plays a noise and also plays that keyframe that turns the railguns ammo holder thingy.

------------------
Nightfire Mod
Spoting an error in post will result in a $100 reward.
Offer expires on 6/6/06. Valid one per customer, per day.

Rangi
2004-06-04, 3:30 AM #7
I'm not going to promise anything, but maybe I'll see if I can manage something. But if anyone else who's actually familiar with this wants to do it, please. I don't know nearly enough about cog to make this sexy or anything.

JediKirby

------------------
<]-[ellequin> Nothing is quite as satisfying as placing a .177 lead pellet in between the eyes of a cat.
<]-[ellequin> I think I will leave it's corpse there, to warn all the other cats to keep out of my hibiscus patch

Live on, Adam.
ᵗʰᵉᵇˢᵍ๒ᵍᵐᵃᶥᶫ∙ᶜᵒᵐ
ᴸᶥᵛᵉ ᴼᵑ ᴬᵈᵃᵐ
2004-06-05, 1:00 AM #8
Here is a first try:
Code:
# Jedi Knight Cog Script
#
# WEAP_RAILDET.COG
#
# WEAPON 7 Script - Rail Detonator Gun
#
# This is a missile launcher type of weapon. It sends out an explosive device with
#  two options, impact or trigger explosion. The charge with the trigger option will
#  stick to a wall.
#
# - Not affected by MagSealed sectors/surfaces.
#
# [YB & CYW]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved


symbols

model       povModel=rldv.3do                   local
model       weaponMesh=rldg.3do                 local

sound       mountSound=RailChargeArm01.WAV      local
sound       dismountSound=PutWeaponAway01.wav   local
sound       fireSound=RailChargeFire01.WAV      local
sound       outSound=RailChargeEmpty01.WAV      local
sound       loadSound=beep1.wav                 local

thing       player                              local
thing       rail1                               local
thing       rail2                               local
thing       rail3                               local

keyframe    mountAnim=RldVmnt.key               local
keyframe    dismountAnim=RldVdis.key            local
keyframe    povfireAnim=RldVpst1.key            local
keyframe    holsterAnim=kyhlstr.key             local
keyframe    railAnim=rld0anim.key               local

template    projectile=+raildet                 local
template    projectile2=+raildet2               local

flex        fireWait=1.0                        local
flex        powerBoost                          local
flex        autoAimFOV=25                       local
flex        autoAimMaxDist=5                    local
flex        holsterWait                         local

int         trackID=-1                          local
int         mode                                local
int         holsterTrack                        local
int         selectMode=1                        local
int         loaded=0                            local
int         aborted=0                           local
int         i                                   local

message     activated
message     deactivated
message     selected
message     deselected
message     autoselect
message     fire
message     timer
message     pulse
message     killed
message     newplayer

end

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

code

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

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

   powerBoost = GetInv(player, 63);
   ChangeFireRate(player, fireWait/powerBoost);

   Return;

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

activated:
   player = GetSourceRef();
   mode = GetSenderRef();
   jkSetWaggle(player, '0.0 0.0 0.0', 0);
   powerBoost = GetInv(player, 63);
   if(GetInv(player, 15) < 1.0)
   {
      PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
      if(GetAutoSwitch() & 1)
         SelectWeapon(player, AutoSelectWeapon(player, 1));
      Return;
   }
   ActivateWeapon(player, 0, mode);
   SetPulse(1/powerBoost);
   loaded = 0;
   aborted = 0;
   Return;

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

user0:
   aborted = 1;

deactivated:
   if(aborted == 2)
   {
      DeactivateWeapon(player, mode);
      Return;
   }

   player = GetSourceRef();
   mode = GetSenderRef();
   jkSetWaggle(player, '10.0 7.0 0.0', 350);
   DeactivateWeapon(player, mode);
   SetPulse(0);

   jkPlayPOVKey(player, povfireAnim, 1, 0x38);
   SetPOVShake('0.0 -.01 0.0', '4.0 0.0 0.0', .05, 80.0);

   rail1 = FireProjectile(player, projectile[mode], fireSound, 18, '0.0214 0.15 0.00', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimFOV*2);
   if(loaded > 0)
      rail2 = FireProjectile(player, projectile[mode], fireSound, 18, '0.0014 0.15 0.00', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimFOV*2);
   if(loaded > 1)
      rail3 = FireProjectile(player, projectile[mode], fireSound, 18, '0.0414 0.15 0.00', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimFOV*2);
   
   if((mode == 1) && (rail != -1))
   {
      for(i = 0; i <= loaded; i = i + 1)
      {
         PlayKey(rail1, railAnim, 1, 20);
      }
   }

   // Provide a kick backwards
   ApplyForce(player, VectorScale(GetThingLVec(player), -40 * (loaded + 1)));

   ChangeInv(player, 15, -(loaded + 1));

   if(aborted == 1)
   {
      aborted = 2;
      ActivateWeapon(player, 0, mode);
   }

   Return;

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

selected:
   player = GetSourceRef();

   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, 7);

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

   Return;

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

deselected:
   player = GetSourceRef();

   PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80);
   jkPlayPOVKey( player, dismountAnim, 0, 18 );

   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;

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

//newplayer:
//   player = GetSourceRef();
//
//   // Make sure that if the player is respawning, the old mount isn't playing anymore.
//   if (trackID != -1)
//      jkStopPOVKey(player, trackID, 0);
//
//   Return;

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

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

   // If the player has the weapon
   if(GetInv(player, 7) != 0.0)
   {
      // If the player has ammo
      if(GetInv(player, 15) != 0.0)
      {

         // query for ammo
         if(selectMode == -1)
         {
            ReturnEx(900.0);
            Return;
         }

         if((selectMode == 0) && !(GetAutoPickup() & 2))
         {
            ReturnEx(900.0);
            Return;
         }

         if((selectMode == 1) && !(GetAutoSwitch() & 2))
         {
            ReturnEx(900.0);
            Return;
         }

         if((selectMode == 2) && !(GetAutoPickup() & 2))
         {
            ReturnEx(900.0);
            Return;
         }

         ReturnEx(-2.0);
         Return;

      }
      else
      {
         ReturnEx(-1.0);
         Return;
      }
   }
   else
   {
      ReturnEx(-1.0);
   }

   Return;

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

timer:
   StopKey(player, holsterTrack, 0.0);
   Return;

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

pulse:
   loaded = loaded + 1;
   if(loaded > 2)
   {
      loaded = 2;
      call user0;
   }
   else
      PlaySoundThing(loadSound, player, 1.0, -1, -1, 0x80);
   if(GetInv(player, 15) <= (loaded + 1))
      call user0;
   Return;

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

newplayer:
killed:
   if(GetSenderRef() == GetLocalPlayerThing())
   {
      DeactivateWeapon(player, mode);
      SetPulse(0);
   }
   Return;

end

There are still a few bugs:
- 1 rocket is fired after respawn, if you die while charging.
- The key of the sticky rockets is not played, when you hold the secondary fire button for more than 3 seconds
- Some problems with charging and not enough ammo...

I'll try to fix these issues later.

------------------
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2004-06-05, 10:10 AM #9
This should get you going. [http://forums.massassi.net/html/smile.gif]

Code:
# Jedi Knight Cog Script
#
# WEAP_RAILDET.COG
#
# WEAPON 7 Script - Enhanced Rail Detonator Gun
#
# This is a missile launcher type of weapon. It sends out an explosive device with
#  two options, impact or trigger explosion. The charge with the trigger option will
#  stick to a wall.
# Hold down either fire button to load up to 3 rockets into the weapon.
#
# - Not affected by MagSealed sectors/surfaces.
#
# [Darth Slaw] - darthslaw@cox.net
# 6/5/04
# =======================================================================
symbols

model     povModel=rldv.3do                   local
model     weaponMesh=rldg.3do                 local

sound     mountSound=RailChargeArm01.WAV      local
sound     dismountSound=PutWeaponAway01.wav   local
sound     fireSound=RailChargeFire01.WAV      local
sound     outSound=RailChargeEmpty01.WAV      local

thing     player                              local
thing     rail                                local

keyframe  mountAnim=RldVmnt.key               local
keyframe  dismountAnim=RldVdis.key            local
keyframe  povfireAnim=RldVpst1.key            local
keyframe  holsterAnim=kyhlstr.key             local
keyframe  railAnim=rld0anim.key               local

template  projectile=+raildet                 local
template  projectile2=+raildet2               local

flex      fireWait=1.0                        local
flex      powerBoost                          local
flex      autoAimFOV=25                       local
flex      holsterWait                         local

int       trackID=-1                          local
int       mode                                local
int       holsterTrack                        local
int       weap=7                              local
int       ammobin=15                          local
int       selectMode=1                        local
int       loaded=0                            local

message   activated
message   deactivated
message   selected
message   deselected
message   newplayer
message   autoselect
message   timer

end
# =======================================================================
code
# .......................................................................
activated:
	player = GetSourceRef();
	mode = GetSenderRef();
	loaded = 1;
	jkSetWaggle(player, '0.0 0.0 0.0', 0);
	powerBoost = GetInv(player, 63);
	KillTimerEx(10);
	SetTimerEx(1, 10, 0, 0);
	//ActivateWeapon( player, fireWait/powerBoost, mode );

Return;
# .......................................................................
deactivated:
	player = GetSourceRef();
	mode = GetSenderRef();
	KillTimerEx(10);
	if(loaded > 0) SetTimerEx(0.01, 11, 0, 0);
	jkSetWaggle(player, '10.0 7.0 0.0', 350);
	//DeactivateWeapon( player, mode );

Return;
# .......................................................................
selected:
	player = GetSourceRef();
	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, weap);
	// Check Ammo - If we are out, autoselect best weapon.
	if(GetInv(player, ammobin) < 1.0)
	{
		PlaySoundThing(outSound, player, 1.0, -1, -1, 0x80);
		if(GetAutoSwitch() & 1) SelectWeapon(player, AutoselectWeapon(player, 1));
	}

Return;
# .......................................................................
deselected:
	player = GetSourceRef();
	loaded = 0;
	PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80);
	jkPlayPOVKey(player, dismountAnim, 0, 18);
	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:
	selectMode = GetSenderRef();
	player = GetSourceRef();
	// If the player has the weapon
	if(GetInv(player, weap) != 0.0)
	{
		// If the player has ammo
		if(GetInv(player, ammobin) != 0.0)
		{
			// query for ammo
			if(selectMode == -1)
			{
				ReturnEx(900.0);
				Return;
			}
			if((selectMode == 0) && !(GetAutoPickup() & 2))
			{
				ReturnEx(900.0);
				Return;
			}
			if((selectMode == 1) && !(GetAutoSwitch() & 2))
			{
				ReturnEx(900.0);
				Return;
			}
			if((selectMode == 2) && !(GetAutoPickup() & 2))
			{
				ReturnEx(900.0);
				Return;
			}
			ReturnEx(-2.0);
			Return;
		}
		else
		{
			ReturnEx(-1.0);
			Return;
		}
	}
	else
	{
		ReturnEx(-1.0);
	}

Return;
# .......................................................................
timer:
	if(GetSenderID() == 2)
	{
		StopKey(player, holsterTrack, 0.0);
	}
	if(GetSenderID() == 10)
	{
		loaded = loaded + 1;
		if(loaded < 3 && loaded < GetInv(player, ammobin)) SetTimerEx(1, 10, 0, 0);
		PrintInt(loaded);
		PlaySoundThing(outSound, player, 1, -1, -1, 0x0);
		jkPlayPOVKey(player, povfireAnim, 1, 0x38);
	}
	if(GetSenderID() == 11)
	{
		loaded = loaded - 1;
		if(loaded > 0) SetTimerEx(0.1, 11, 0, 0);
		if(GetThingHealth(player) <= 0) Return;
		jkPlayPOVKey(player, povfireAnim, 1, 0x38);
		SetPOVShake('0.0 -.01 0.0', '4.0 0.0 0.0', .05, 80.0);
		rail = FireProjectile(player, projectile[mode], fireSound, 18, '0.0214 0.15 0.00', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimFOV * 2);
		if((mode == 1) && (rail != -1)) PlayKey(rail, railAnim, 1, 20);
		// Provide a kick backwards
		ApplyForce(player, VectorScale(GetThingLVec(player), -10));
		ChangeInv(player, ammobin, -1.0);
	}

Return;
# .......................................................................
newplayer:
	if(GetSenderRef() != GetLocalPlayerThing()) Return;
	KillTimerEx(10);
	KillTimerEx(11);
	loaded = 0;

Return;
# .......................................................................
end


------------------
for(i = 0; i < 00; i = i + 1) Print("massassi is good");
PrintInt(i); //print the integer value of infinity
May the mass times acceleration be with you.
2004-06-05, 7:31 PM #10
Slaw, what language is your signature in? I do say, scope might prevent the integer "i" from having a value, not to mention that the loop wouldn't terminate. You joker!
2004-06-05, 10:06 PM #11
I know it isn't related but Slaw's sig should really be this:

while(1)
{
Print("massassi is good");
PrintInt(i); //print the integer value of infinity
}

...because while loops NEVER break if you don't supply a condition that would never change (condition of 1 is just that. One. That's never going to change, lol)

-- SavageX

------------------
"...and if you don't like that, then you need to be slugged in the face repeatedly, until my hands are soaked in blood. Have a nice day!"
http://geocities.com/savagex378
The cake is a lie... THE CAKE IS A LIE!!!!!
2004-06-05, 10:52 PM #12
I think the two zeros in Slaw's for condition are supposed to be a lying 8, the sign for infinity. If so, it would be correct, in a mathematical point of view. Numbers are limited on computers, though.

[edit]Ok, here is my final try:
Code:
# Jedi Knight Cog Script
#
# WEAP_RAILDET.COG
#
# WEAPON 7 Script - Rail Detonator Gun
#
# This is a missile launcher type of weapon. It sends out an explosive device with
#  two options, impact or trigger explosion. The charge with the trigger option will
#  stick to a wall.
#
# - Not affected by MagSealed sectors/surfaces.
#
# [YB & CYW]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved


symbols

model       povModel=rldv.3do                   local
model       weaponMesh=rldg.3do                 local

sound       mountSound=RailChargeArm01.WAV      local
sound       dismountSound=PutWeaponAway01.wav   local
sound       fireSound=RailChargeFire01.WAV      local
sound       outSound=RailChargeEmpty01.WAV      local
sound       loadSound=beep1.wav                 local

thing       player                              local
thing       rail                                local

keyframe    mountAnim=RldVmnt.key               local
keyframe    dismountAnim=RldVdis.key            local
keyframe    povfireAnim=RldVpst1.key            local
keyframe    holsterAnim=kyhlstr.key             local
keyframe    railAnim=rld0anim.key               local
keyframe    chargeAnim=Rldvpst1.key             local

template    projectile=+raildet                 local
template    projectile2=+raildet2               local

flex        fireWait=1.0                        local
flex        powerBoost                          local
flex        autoAimFOV=25                       local
flex        autoAimMaxDist=5                    local
flex        holsterWait                         local

int         trackID=-1                          local
int         mode                                local
int         holsterTrack                        local
int         selectMode=1                        local
int         aborted=0                           local
int         charged=0                           local

message     startup
message     activated
message     deactivated
message     selected
message     deselected
message     autoselect
message     fire
message     timer
message     user0
message     killed

end

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

code

startup:
   charged = 0;

   Return;

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

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

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

   if((GetInv(player, 15) < (charged + 1)) || (charged > 2))
   {
      call user0;
      Return;
   }

   if(charged > 0)
   {
      //jkPlayPOVKey(player, chargeAnim, 1, 0x38);
      PlaySoundThing(loadSound, player, 1.0, -1, -1, 0x80);
   }

   powerBoost = GetInv(player, 63);
   ChangeFireRate(player, fireWait/powerBoost);

   charged = charged + 1;

   Return;

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

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

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

   jkSetWaggle(player, '0.0 0.0 0.0', 0);
   powerBoost = GetInv(player, 63);
   ActivateWeapon(player, fireWait/powerBoost, mode);

   aborted = 0;

   Return;

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

user0:
   aborted = 1;

deactivated:
   player = GetSourceRef();

   if(aborted == 2)
   {
      DeactivateWeapon(player, mode);
      Return;
   }

   jkPlayPOVKey(player, povfireAnim, 1, 0x38);
   SetPOVShake('0.0 -.01 0.0', '4.0 0.0 0.0', .05, 80.0);

   Print("Rail 1");
   rail = FireProjectile(player, projectile[mode], fireSound, 18, '0.0214 0.15 0.00', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimFOV*2);
   if((mode == 1) && (rail != -1))
   {
      PlayKey(rail, railAnim, 1, 20);
   }

   if(charged > 1)
   {
      Print("Rail 2");
      rail = FireProjectile(player, projectile[mode], fireSound, 18, '0.0614 0.15 0.00', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimFOV*2);
      if((mode == 1) && (rail != -1))
      {
         PlayKey(rail, railAnim, 1, 20);
      }
   }

   if(charged > 2)
   {
      Print("Rail 3");
      rail = FireProjectile(player, projectile[mode], fireSound, 18, '-0.0186 0.15 0.00', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimFOV*2);
      if((mode == 1) && (rail != -1))
      {
         PlayKey(rail, railAnim, 1, 20);
      }
   }

   ChangeInv(player, 15, - charged);

   // Provide a kick backwards
   ApplyForce(player, VectorScale(GetThingLVec(player), -40 * (loaded + 1)));

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

   aborted = aborted + 1;
   charged = 0;

   Return;

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

selected:
   player = GetSourceRef();

   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, 7);

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

   Return;

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

deselected:
   player = GetSourceRef();

   PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80);
   jkPlayPOVKey( player, dismountAnim, 0, 18 );

   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:
   selectMode = GetSenderRef();
   player = GetSourceRef();

   // If the player has the weapon
   if(GetInv(player, 7) != 0.0)
   {
      // If the player has ammo
      if(GetInv(player, 15) != 0.0)
      {

         // query for ammo
         if(selectMode == -1)
         {
            ReturnEx(900.0);
            Return;
         }

         if((selectMode == 0) && !(GetAutoPickup() & 2))
         {
            ReturnEx(900.0);
            Return;
         }

         if((selectMode == 1) && !(GetAutoSwitch() & 2))
         {
            ReturnEx(900.0);
            Return;
         }

         if((selectMode == 2) && !(GetAutoPickup() & 2))
         {
            ReturnEx(900.0);
            Return;
         }

         ReturnEx(-2.0);
         Return;

      }
      else
      {
         ReturnEx(-1.0);
         Return;
      }
   }
   else
   {
      ReturnEx(-1.0);
   }

   Return;

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

timer:
   StopKey(player, holsterTrack, 0.0);
   Return;

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

killed:
   if(player == GetSenderRef())
   {
      DeactivateWeapon(player, mode);
      aborted = 2;
      charged = 0;
   }

   Return;

end

You can uncomment the line in the fire message, if you want a charge animation to be played.
The direction of the rockets can easily be changed. They could also spread out...
You might also want to delete the Print statements...
[/edit]

------------------
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)

[This message has been edited by zagibu (edited June 06, 2004).]
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2004-06-06, 8:58 AM #13
Yeah, the 00 is supposed to be the lying 8. I tried putting in the actual character, just to see if it would work, but it didn't. I got this... *copy/pastes laying 8 for infinity from character map)
‡

I'm not joking btw, Heb [http://forums.massassi.net/html/wink.gif] It's the code for a cog *OMQ*virus*OMQ* mod I was making for JK [http://forums.massassi.net/html/tongue.gif] [http://forums.massassi.net/html/biggrin.gif]

Hey, SavageX is actually on the Editing forum [http://forums.massassi.net/html/smile.gif] For your version of my sig, I think you'd want to increment the value of i at each iteration...

------------------
for(i = 0; i < 00; i = i + 1) Print("massassi is good");
PrintInt(i); //print the integer value of infinity (if we ever get there)
May the mass times acceleration be with you.
2004-06-06, 3:13 PM #14
Great I didnt try all of them I just tried the last one that was posted last and it worked great so thanks zagibu

------------------
~Nightfire Mod~

[This message has been edited by a_person (edited June 06, 2004).]
Spoting an error in post will result in a $100 reward.
Offer expires on 6/6/06. Valid one per customer, per day.

Rangi

↑ Up to the top!