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 cog won't activate...
This cog won't activate...
2003-02-26, 2:52 PM #1
I can select the weapon, but it won't activate when I press fire or secondary fire...Can weapons only have bins from 0-9, because this weapons bin is 116?
Code:
symbols

model       povModel=detv.3do             local
model       weaponMesh=detg.3do           local

keyframe    mountAnim=detvmnt.key         local
keyframe    dismountAnim=detvdis.key      local
keyframe    povFireAnim=detvpst1.key      local
keyframe    prePOVThrowAnim=detvpre1.key  local
#keyframe   preThrowAnim=kyrthro0.key     local
keyframe    holsterAnim=kyhlstr.key       local

template    projectile=+bang1          local
template    projectile1=+bang2         local

sound       throwSound=ThermalThrow01.wav local
sound       clickSound=ThermClick01.wav   local
sound       clickSound2=ThermClick02.wav  local
sound       loopSound=ThermLoop01.wav     local

flex        delayTime=1.0                 local
flex        throwWait=0.8                 local
flex        mountWait                     local
flex        autoAimFOV=10                 local
flex        autoAimMaxDist=5              local
flex        holsterWait                   local

thing       player                        local

int         preThrowTrack                 local
int         selectTrack                   local
int         prePOVThrowTrack              local
int         mode                          local
int         cocked=0                      local
int         holsterTrack                  local

int         selectMode=1                  local

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

end

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

code

startup:
   // Setup delays and variables.
   mountWait    = GetKeyLen(mountAnim);

   preThrowTrack=-1;
   selectTrack=-1;
   prePOVThrowTrack=-1;

   Return;

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

activated:
   player = GetSourceRef();
   mode = GetSenderRef();
   if (mode > 1)
      Return;

   PlaySoundThing(clickSound[mode], player, 1.0, -1.0, -1.0, 0x80);

   // Cock arm back for throw.
   if(preThrowTrack == -1 && prePOVThrowTrack == -1)
   {
      prePOVThrowTrack = jkPlayPOVKey(player, prePOVThrowAnim, 1, 0x14);
      preThrowTrack = PlayMode( player, 38 );
      ActivateWeapon(player, 0, mode);
   }
   Return;

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

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

   delayTime = DeactivateWeapon(player, mode);        // allow activated messages again.

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

   // Set maximum scale factor (2 second hold.)
   if(delayTime > 2)
      delayTime = 2;

   // Set minimum scale factor
   if(mode == 0)
   {
      if(delayTime < 0.7) delayTime = 0.7;
   }
   else
   {
      if(delayTime < 0.25) delayTime = 0.25;
   }

   if(preThrowTrack != -1 && prePOVThrowTrack != -1)
   {
      jkStopPOVKey(player, prePOVThrowTrack, 0);
      StopKey(player, preThrowTrack, 0);
      preThrowTrack = -1;
      prePOVThrowTrack = -1;
   }

   // Throw the appropriate detonator.
   SetPOVShake('0.0 -.003 0.0', '0.5 0.0 0.0', .05, 40.0);
   jkPlayPOVKey(player, povfireAnim, 1, 0x38);
   PlaySoundThing(throwSound, player, 1.0, 0.5, 2.5, 0x80);
   FireProjectile(player, projectile[mode], -1, 15, '0.05 0 0', '0 0 0', delayTime, 0x1, 0.0, 0.0);
   ChangeInv(player, 116, -1.0);
   SetMountWait(player, throwWait);

   // If out of ammo try to autoswitch to another weapon
   // if autoswitch is enabled else just switch to fists.
   if(GetInv(player, 116) < 1)
   {
      if(GetAutoSwitch() & 1)
      {
         SelectWeapon(player, AutoSelectWeapon(player, 1));
      }
      else
      {
         SelectWeapon(player, 1);
      }
   }

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

   Return;

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

timer:
   if (GetSenderId() == 0)
   {
      // Start waggling after the throw.
      jkSetWaggle(player, '10.0 7.0 0.0', 350);
   }
   else
   if (GetSenderId() == 2)
   {
      StopKey(player, holsterTrack, 0.0);
   }
   Return;

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

selected:
   player = GetSourceRef();

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

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

   // Setup the meshes and models.
   jkSetPOVModel(player, povModel);
   SetArmedMode(player, 0);
   jkSetWeaponMesh(player, weaponMesh);

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

   // Clear Lightsaber flag, and enable activation messages.
   jkClearFlags(player, 0x5);
   SetCurWeapon(player, 166);
   SetMountWait(player, GetKeyLen(mountAnim));

   Return;

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

deselected:
   player = GetSourceRef();

   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(selectTrack != -1)
   {
      jkStopPOVKey(player, selectTrack, 0);
      selectTrack = -1;
   }
   jkSetWaggle(player, '0.0 0.0 0.0', 0);
   KillTimerEx(0);

   if(preThrowTrack != -1 && prePOVThrowTrack != -1)
   {
      jkStopPOVKey(player, prePOVThrowTrack, 0);
      StopKey(player, preThrowTrack, 0);
      preThrowTrack = -1;
      prePOVThrowTrack = -1;
   }

   Return;

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

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

   // If the player has ammo
   if(GetInv(player, 116) != 0)
   {

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

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

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

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

      ReturnEx(-2.0);
      Return;

   }
   else
   {
      ReturnEx(-1.0);
   }

   Return;

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

newplayer:
   if(preThrowTrack != -1 && prePOVThrowTrack != -1)
   {
      jkStopPOVKey(player, prePOVThrowTrack, 0);
      StopKey(player, preThrowTrack, 0);
      preThrowTrack = -1;
      prePOVThrowTrack = -1;
   }
   Return;

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


end


------------------
Last week I cudn't evn spel grajuat, but now I is one.

*Takes out his blaster and fires shots at the wall, the blastmarks leave the words "STROOPER WUZ 'ERE!!!"
2003-02-26, 4:24 PM #2
This is a big error, so big that it can only be caused by one thing. You have no fire message, all of the code for primary and secondary fire is NOT HERE. Look at weap_bryar.cog and check out its fire message.

You are missing all of the code that makes it shoot. That part of the code is located under the 'fire' message.

Ok, I do not want to see you ask where to look. I hope I said it enough times. lol [http://forums.massassi.net/html/wink.gif]

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"

[This message has been edited by SG-fan (edited February 26, 2003).]
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2003-02-26, 4:35 PM #3
This is just an edited weap_thermdet.cog, All I did was change the two templates and the bin numbers in the code.

The weap_thermdet.cog doesn't have a fire message either.

If I'm reading it right, the code that tells it what to throw is in the Activated and Deactivated messages.

------------------
Last week I cudn't evn spel grajuat, but now I is one.

*Takes out his blaster and fires shots at the wall, the blastmarks leave the words "STROOPER WUZ 'ERE!!!"

[This message has been edited by Stormtrooper (edited February 26, 2003).]
2003-02-26, 4:40 PM #4
Oh, my bad [http://forums.massassi.net/html/wink.gif]
I thought you were doing a blaster type thing. I don't have much experience editing the thermal cog, I'll take a look at it.

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2003-02-26, 4:59 PM #5
fire: is only needed if you use ActivateWeapon(player, bin, Value >0) as it will call fire: every 'Value >0' seconds.

------------------
-Hell Raiser
Remember kiddies, trial and error.
Without struggles there is no progress
DBZ: The Destruction is Real
-Hell Raiser

↑ Up to the top!