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 → Grapple cog question
Grapple cog question
2001-11-16, 7:22 AM #1
How do i make this cog fire bullets for primary fire and a hook for secondary? (it currently fires a hook for both modes)

Code:
symbols

model       povModel=bryv.3do                   local
model       weaponMesh=bryg.3do                 local

keyframe    mountAnim=bryvmnt.key               local
keyframe    dismountAnim=bryvdis.key            local
keyframe    povfireAnim=bryvpst1.key            local
keyframe    holsterAnim=kyhlstr.key             local

sound       outSound=pistout1.wav               local
sound       mountSound=df_bry_ready.wav         local
sound       dismountSound=PutWeaponAway01.wav   local
sound       fireSound=pistol-1.wav              local
sound       grapfireSound=remotefire01.wav      local
sound       graphitSound=lvrclik2.wav           local

template    projectile=+bryarbolt               local

thing       player                              local
thing       victim                              local
thing       potential                           local

flex        dot                                 local
flex        maxDot                              local

flex        fireWait=0.1                        local
flex        holsterWait                         local
flex        fireDelay=0.1                       local
flex        powerBoost                          local
flex        autoAimFOV=30                       local
flex        autoAimMaxDist=5                    local

int         weaponIndex                         local
int         trackID=-1                          local
int         dummy=0                             local
int         mode                                local
int         holsterTrack                        local

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


template    grapple=+grapplehook               local

int         hook=0                              local
int	    hooklanded=0                        local

vector      dir                                 local

end

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

code

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

   if(hook == 0)
   {
   SetPOVShake('0.0 -.003 0.0', '1.0 0.0 0.0', .05, 80.0);
   hook = FireProjectile(player, grapple, grapfireSound, 8, '0.0135 0.1624 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimFOV*2);
   jkPlayPOVKey(player, povfireAnim, 1, 0x38);
   SetPulse(0.10);
}

   Return;
# .....................................
pulse:
	if(hooklanded == 0)
      {
	   if((IsThingMoving(hook) == 0) || (GetThingAttachFlags(hook) != 0))	   
	   {
		hooklanded = 1;
   		PlaySoundThing(graphitSound, player, 1.0, -1.0, -1.0, 0x80);
	   }
      }
	else
	{
      dir = VectorScale(VectorNorm(VectorSub(GetThingPos(hook), GetThingPos(player))), 50);
      //have to detach and clearphysics otherwise players 'drags'along floor
     	DetachThing(player);
     	ClearPhysicsFlags(player, 0x1);
      ApplyForce(player, dir);
	}
      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 );

   if(hook != 0)
   {
   SetPulse(0);
   DestroyThing(hook);
   hook = 0;
   hooklanded = 0;
   SetPhysicsFlags(player, 0x1);
   }

   Return;

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

selected:
   player = GetSourceRef();

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

   // Play mounting sound.
   PlayMode(player, 41);
   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 = jkPlayPOVKey(player, mountAnim, 0, 0x14);
   jkSetWaggle(player, '10.0 7.0 0.0', 350);

   // Clear saber flags, and allow activation of the weapon
   jkClearFlags(player, 0x5);
   SetCurWeapon(player, 2);
   SetMountWait(player, GetKeyLen(mountAnim));

   Return;

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

deselected:
   player = GetSourceRef();
   weaponIndex = GetSenderRef();
   
   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, 2) != 0.0)
   {
      // If the player has ammo
      if(GetInv(player, 11) != 0.0)
      {
         ReturnEx(500.0);
      }
      else
      {
         ReturnEx(-1.0);
      }
   }
   else
   {
      ReturnEx(-1.0);
   }

   Return;

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

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

end


Also i am still looking for someone to help me with weapon cogs for Arsenal SE.
2001-11-16, 7:33 AM #2
Something like 'If(Mode == 0)', Im not sure.

You might consider opening up some other weapon cog, the the repeater's, to see how its done.

------------------
Success is the inverse relationship between effort, gain, and loss.
And when the moment is right, I'm gonna fly a kite.
2001-11-16, 8:56 AM #3
The senderref of the activated, fire, and deactivated messages is the mode of fire. This will be 0 for primary and 1 for secondary. So use something like this in the activated message:

if(mode == 0)
{
// Activate the weapon
}
else
{
// Set the grapple's pulse
}

Of course, you'll have to add all of the weapon code to the cog.

------------------
Thank you for sending me a copy of your mod - I'll waste no time playing it.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

↑ Up to the top!