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 → Thermal det client cog help wanted.
Thermal det client cog help wanted.
2004-08-23, 8:27 PM #1
Ok because im using a custom projectile in my thermadet cog I need to make a client cog for it so it works in mp. I managed to do it with my other weapons but when i do it with the thermaldet one it just drops to the ground. I want to make it so you can still charge up the thow like normal.

Here is the cog.
Code:
# Jedi Knight Cog Script
#
# WEAP_THERMDET.COG
#
# WEAPON 4 Script - Thermal Detonator
#
# Fun to use and handy for clearing some elbow room.  Not recommending
#  for those with noodle arms. The longer you hold down the fire key
#  (CTRL/Z) the farther you throw the detonator.
#
# The primary fire throws the detonator with the 3 second delay, the
#  secondary makes it explode on impact.
#
# - Not affected by MagSealed sectors/surfaces.
#
# [YB & CYW]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
# ========================================================================================

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=+therm1          local
template    projectile1=+therm2         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, 4, -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, 4) < 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, 4);
   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, 4) != 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



And here is the current client cog which is handleing the two weapons ive made so far. Id like it if you could implement it into the same client cog please.

Code:
# Jedi Knight Cog Script
#
# Client_Rangi.COG
#
# Description
# 
#
# This Cog is Not supported by LucasArts Entertainment Co

# This flag makes the cog act locally, no broadcasting, less lag.
flags=0x240

symbols

flex         autoAimFOV=30                      local                         
flex         autoAimMaxDist=5                   local                         
template     projectile=+flarebolt              local                         
template     projectile2=+tribolt               local                         

vector       randVec                            local          

thing        player                             local               

message      trigger                                                          

end                                                                           

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

code

trigger:

   // Get random aiming error
      randVec = VectorSet((Rand()-0.5)*5, (Rand()-0.5)*5, 0.0);
      randVec2 = VectorSet((Rand()-0.5)*5, (Rand()-0.5)*5, 0.0);
      randVec3 = VectorSet((Rand()-0.5)*5, (Rand()-0.5)*5, 0.0);

	if( (GetSourceRef() == 20) || (GetSourceRef() == 21) )
	{
		FireProjectile(GetParam(0), projectile, -1, -1, '0.0135 0.1624 0.0', '0 0 0', 1, 0x20, autoAimFOV, autoAimFOV*2);
	}
       else
	if( (GetSourceRef() == 30) || (GetSourceRef() == 31) )
	{
    FireProjectile(GetParam(0), projectile2, -1, -1, '0.02 0.15 0.0', randVec1, 1.0, 0x20, autoAimFOV, autoAimMaxDist);
     FireProjectile(GetParam(0), projectile2, -1, -1, '0.02 0.15 0.0', randVec2, 1.0, 0x20, autoAimFOV, autoAimMaxDist);
     FireProjectile(GetParam(0), projectile2, -1, -1, '0.02 0.15 0.0', randVec3, 1.0, 0x20, autoAimFOV, autoAimMaxDist);
	}
       else

return;

end


Thanks.

------------------
~Nightfire Mod~
~T3h L0st tut0rialz~
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-08-23, 8:58 PM #2
This should do it:

Here is the cog.
Code:
# Jedi Knight Cog Script
#
# WEAP_THERMDET.COG
#
# WEAPON 4 Script - Thermal Detonator
#
# Fun to use and handy for clearing some elbow room.  Not recommending
#  for those with noodle arms. The longer you hold down the fire key
#  (CTRL/Z) the farther you throw the detonator.
#
# The primary fire throws the detonator with the 3 second delay, the
#  secondary makes it explode on impact.
#
# - Not affected by MagSealed sectors/surfaces.
#
# [YB & CYW]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
# ========================================================================================

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=+therm1          local
template    projectile1=+therm2         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);
   SendTrigger(-1, 40+mode, player, 0, 0, delaytime);
   ChangeInv(player, 4, -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, 4) < 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, 4);
   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, 4) != 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



And here is the current client cog which is handleing the two weapons ive made so far. Id like it if you could implement it into the same client cog please.

Code:
# Jedi Knight Cog Script
#
# Client_Rangi.COG
#
# Description
# 
#
# This Cog is Not supported by LucasArts Entertainment Co

# This flag makes the cog act locally, no broadcasting, less lag.
flags=0x240

symbols

flex         autoAimFOV=30                      local                         
flex         autoAimMaxDist=5                   local                         
template     projectile=+flarebolt              local                         
template     projectile2=+tribolt               local                         
template     thermal1=+therm1                   local
template     thermal2=+therm2                   local

vector       randVec                            local          

thing        player                             local               

flex         ThrowForce                         local                         

message      trigger                                                          

end                                                                           

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

code

trigger:

   // Get random aiming error
      randVec = VectorSet((Rand()-0.5)*5, (Rand()-0.5)*5, 0.0);
      randVec2 = VectorSet((Rand()-0.5)*5, (Rand()-0.5)*5, 0.0);
      randVec3 = VectorSet((Rand()-0.5)*5, (Rand()-0.5)*5, 0.0);

      ThrowForce = GetParam(3);

	if( (GetSourceRef() == 20) || (GetSourceRef() == 21) )
	{
		FireProjectile(GetParam(0), projectile, -1, -1, '0.0135 0.1624 0.0', '0 0 0', 1, 0x20, autoAimFOV, autoAimFOV*2);
	}
       else
	if( (GetSourceRef() == 30) || (GetSourceRef() == 31) )
	{
    FireProjectile(GetParam(0), projectile2, -1, -1, '0.02 0.15 0.0', randVec1, 1.0, 0x20, autoAimFOV, autoAimMaxDist);
     FireProjectile(GetParam(0), projectile2, -1, -1, '0.02 0.15 0.0', randVec2, 1.0, 0x20, autoAimFOV, autoAimMaxDist);
     FireProjectile(GetParam(0), projectile2, -1, -1, '0.02 0.15 0.0', randVec3, 1.0, 0x20, autoAimFOV, autoAimMaxDist);
	}
       else
	if(GetSourceRef() == 40)
	{
         FireProjectile(player, thermal1, -1, 15, '0.05 0 0', '0 0 0', ThrowForce, 0x1, 0.0, 0.0);
	}
       else
	if(GetSourceRef() == 41)
	{
         FireProjectile(player, thermal2, -1, 15, '0.05 0 0', '0 0 0', ThrowForce, 0x1, 0.0, 0.0);
	}

return;

end


Untested, but it should work

The thermal throw thing usually happens because you need to send delaytime to the client cog too, because the delaytime variable is used in in FireProjectile(); to scale the projectile's vel based on how long you've been winding up the grenade throw.

------------------
I am __Ace_1__ , and I approve this message.

[This message has been edited by Ace1 (edited August 24, 2004).]
I am _ Ace_1 _ , and I approve this message.
2004-08-23, 11:54 PM #3
Thanks ace that worked great.

------------------
~Nightfire Mod~
~T3h L0st tut0rialz~
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-08-24, 1:56 AM #4
What it does is send the time you held the grenade back before throwing in the trigger (the last parameter in the SendTrigger() verb). The client cog retrieves this value (GetParam(3) to get 4th parameter) from the trigger and uses it to scale the projectiles velocity vector (in the FireProjectile() verb).
Just in case you were interested...

------------------
"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-08-24, 6:10 AM #5
One thing I might mention is that if you calculate the random vector for a projectile in a client cog like that, the vector will be different on everyones machine.

In order to have a random vector sent via trigger to client cogs and have it be the same everywhere, you need to create the vector on the firing machine and then send the vector as a param along with the trigger.

Of course, it isn't that easy either because vectors cannot be sent as params with send trigger...you have to break the vector into its respective parts (vectorX, VectorY) send THOSE as params and reassemble them into a working vector on the other side.

Fun fun fun!
2004-08-24, 10:44 AM #6
Quote:
<font face="Verdana, Arial" size="2">Originally posted by Wave_Of_Mutilation:
One thing I might mention is that if you calculate the random vector for a projectile in a client cog like that, the vector will be different on everyones machine.

In order to have a random vector sent via trigger to client cogs and have it be the same everywhere, you need to create the vector on the firing machine and then send the vector as a param along with the trigger.

Of course, it isn't that easy either because vectors cannot be sent as params with send trigger...you have to break the vector into its respective parts (vectorX, VectorY) send THOSE as params and reassemble them into a working vector on the other side.

Fun fun fun!
</font>


Thank you for confirming this. I had a hunch but I wasn't sure...

------------------
nytfyre m0d || f33l t3h p0w3r || t3h l0st c0gz || OMF > *
May the mass times acceleration be with you.

↑ Up to the top!