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 → Longbow cog *shudder* (RoX TC)
Longbow cog *shudder* (RoX TC)
2002-06-15, 6:23 AM #1
Below is a totally redone version of the infamous longbow cog for the RoX TC.

Not too long a go, bel Iblis e-mailed me a new player model (i.e. playermodel in the symbols section) with the bow in the left hand for added realism, along with 2 keys, armbow (for the firing) and getarrow (for reloading).

Unfortunately, he made several errors. Firstly, the bow replaced the Thermal Detonator, and the 'detg.3do' was replaced with an arrow. However this was built off of the bryar pistol cog, and thus ingame, Tahben appeared with the bow in the left hand and the broadsword (the bryar replacement) in the right. I was able to fix this, but instead of playing the armbow or getarrow keys, Tahben simply swings the arrow around as if it were a broadsword. I checked the keys, and they all look fine, and it is thus that I am at a loss as to what is wrong. I'd write a new one myself, but I've never done weapon cogs before and am thus none too knowledegable about them. [http://forums.massassi.net/html/frown.gif]

Code:
# Jedi Knight Missions Cog Script
#
# WEAP_BRYAR_M.COG
#
# WEAPON 2 Script - Bryar Pistol
#
# Yes I changed it now it changes player model and is an MP nightmare but hey Kyle ain't
# no lefty so I had to do this for the bow to work!
#
# - Affected by MagSealed sectors/surfaces.
#
# [YB & CYW] + [RF]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved


symbols

model       povModel=detv.3do                   local
model       povModel_m=detv_m.3do               local
model       weaponMesh=detg.3do                 local
model       noweaponMesh=fistg.3do              local
model	    playermodel=kkbow.3do		local
model	    playermodelold=kk.3do		local

keyframe    bow1=armbow.key		        local
keyframe    bow2=getarrow.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=Bow_fire.wav              local
sound			failSound=weapfail.wav					local

template    projectileB=+swsparks                 local
template    projectile=+bowarrow               local

thing       player                              local
thing       victim                              local
thing       potential                           local

flex        dot                                 local
flex        maxDot                              local

flex        fireWait=1.5                        local
flex        holsterWait                         local
flex        fireDelay=0.6                       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
int         step=1	                        local
int         key=-1          	                local

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

end

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

code

fire:
   player = GetSourceRef();

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

if(step == 0) {

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

	SendMessageEx(GetThingClassCog(GetLocalPlayerThing()), user1, 3, 0, 0, 0);

	if (GetInv(player, 93) > 0.0)
	{
	Return;
	}
	else
	{

	step=1;

key = PlayKey(player, bow1, 1, 0x14);

	Return;
	}
}
if(step == 1)
{
   ChangeInv(player, 11, -1.0);

StopKey(player, key, 0);
step=0;
PlayKey(player, bow2, 1, 0x2c);
		dummy = FireProjectile(player, projectile, fireSound, 8, '0.0135 0.1624 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimFOV*2);

Return;
}

   Return;

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

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

	if (GetInv(player, 93) > 0.0)
		SendMessageEx(GetThingClassCog(player), skill, 1100, 0, 0, 0);

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

   // Setup the meshes and models.
	if (GetInv(player, 67) == 0.0)
		jkSetPOVModel(player, povModel);		// Kyle hand
	else
		jkSetPOVModel(player, povModel_m);	// Mara Hand

jkSetWeaponMesh(player, weaponMesh);

	//Implementing the bow hand

	SetThingModel(player, playermodel);

   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.
   jkSetWaggle(player, '10.0 7.0 0.0', 350);

   // Clear saber flags, and allow activation of the weapon
   jkClearFlags(player, 0x5);
   SetCurWeapon(player, 2);
   
step=0;
PlayKey(player, bow2, 1, 0x2c);

   Return;

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

deselected:
   player = GetSourceRef();
   weaponIndex = GetSenderRef();

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

	//De-implementing the bow hand

	SetThingModel(player, playermodelold);

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

StopKey(player, key, 0);
step=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
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-06-15, 4:27 PM #2
AAAaaaaaaaaanybody? [http://forums.massassi.net/html/frown.gif]
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-06-15, 6:42 PM #3
you would be better off making a new cog based off the thermal detonator cog. it has everything you need in there, all you have to do is replace the tamplate, 3dos keys and whatnot, but if you really want to you can try to get this one working right.

dummy = FireProjectile(player, projectile, fireSound, 8, '0.0135 0.1624 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimFOV*2);

see the 4th feild? the 8. change that to -1 and it should solve the key problems
I'm just an old man with a skooma problem.
2002-06-16, 12:21 AM #4
Thanks, Gunboy, I'll try that out.

Our original cog (to support the right handed bow), was indeed based off of the thermdet, however, I tried to go back to it, and I find that my lack of experience in weapon cogging disallows m,e from making much headway here. Additionally, we moved to the bryar cog to shunt criticism on 'too much realism' for the bow and being unable to hit much of anything. (perhaps too high of a mass, or bad physflags, but it did have something to do with the cog). Regardless, I don't have enough keys for this. [http://forums.massassi.net/html/tongue.gif]

Code:
# Jedi Knight Cog Script
#
# WEAP_THERMDET.COG
#
# WEAPON 4 Script - Bow
#
# From hell's heart, I shoot at thee!
#
# LightReFractED
#
# This is not endorsed by LucasArts Entertainment Co.
# ========================================================================================

symbols

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

#Int
keyframe    mountAnim=lbowmoupov.key         local
keyframe    dismountAnim=lbowdispov.key      local
keyframe    povFireAnim=lbowfirepov.key      local
keyframe    povAimAnim=lbowaimpov.key  	local
keyframe	povReloadAnim=lbowrelopov.key		local

#Ext
keyframe	extFireAnim=lbowfire.key		local
keyframe	extAimAnim=lbowdraw.key			local
keyframe	extReloadAnim=lbowremou.key		local
keyframe    holsterAnim=kyhlstr.key       local

#Bins
int		bin=124					local
int		ammoBin=124				local

template    projectile=+arrow          local
template    projectile1=+arrow         local
template    projectileB=+arrow       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                     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);
   throwWait    = GetKeyLen(povReloadAnim);

   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, povAimAnim, 1, 0x14);
      preThrowTrack = PlayKey(player, extAimAnim, 1, 0x14);
      ActivateWeapon(player, 0, mode);
   }
   Return;

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

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

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

		// Don't throw if controls are disabled.
   if (!(GetActorFlags(player) & 0x200000))
	{
		// Make sure both keys are up before continuing.
		if (GetCurWeaponMode() != -1)
			Return;
	
		// Set maximum scale factor (2 second hold.)
		if(delayTime > 3)
			delayTime = 3;
	
		// 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;
		}
	
		if (GetInv(player, 93))
		{
			mode = 2;
			SendMessageEx(GetThingClassCog(player), skill, 1100, 0, 0, 0);
		}
	
		// 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);
		SendMessageEx(GetThingClassCog(GetLocalPlayerThing()), user1, 3, 0, 0, 0);
		
		FireProjectile(player, projectile[mode], -1, -1, '0.05 0 0', '0 0 0', delayTime, 0x1, 0.0, 0.0);
		PlayKey(player, extFireAnim, 1, 0x38);

		ChangeInv(player, 4, -1.0);
		jkPlayPOVKey(player, povReloadAnim, 1, 0x38);
		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, GetWeaponBin(AutoSelectWeapon(player, 1)));
			}
			else
			{
				SelectWeapon(player, 1);
			}
		}
	}
	else
	{
		if(preThrowTrack != -1 && prePOVThrowTrack != -1)
		{
			jkStopPOVKey(player, prePOVThrowTrack, 0);
			StopKey(player, preThrowTrack, 0);
			preThrowTrack = -1;
			prePOVThrowTrack = -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();

   // Go to external
   if ((GetCurrentCamera() == 0) && (GetPrimaryFocus(0) == player))
      CycleCamera();

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

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

   // Setup the meshes and models.
	if (GetInv(player, 67) == 0.0)
		jkSetPOVModel(player, povModel);		// Kyle hand
	else
		jkSetPOVModel(player, povModel_m);	// Mara Hand
   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 the weapon
   if(GetInv(player, bin) != 0.0)
   {
      // If the player has ammo
      if(GetInv(player, ammoBin) != 0.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


I'm going to test the cog with these new editations.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-06-16, 12:45 AM #5
[http://forums.massassi.net/html/frown.gif] It didn't work.

I changed the original in the 1st cog, to the following per your instructions...

Code:
dummy = FireProjectile(player, projectile, fireSound, -1, '0.0135 0.1624 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimFOV*2);


... and it still played the same animations. I can't see how this is possible, as I have removed every instance of any semblance of the bryar replacement keys.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-06-16, 7:07 PM #6
Hm... I've written some weapon cogs that used error vectors, and the cogs seem to exagerate those vectors a lot. Is that what you're talking about?

As to the cog itself, the SetCurWeapon is set to 2. Changing that will help a lot.
Cynic (sin'ik) n. One of a sect of ancient Greek philosophers who held that virtue is the ultimate goal of life, their doctrine gradually coming to symbolize insolent self-righteousness.

Drink So-Be, and play longer!
2002-06-18, 1:16 AM #7
Ah-HA! You may have hit the nail on the head! I shall investigate...
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-06-18, 2:21 AM #8
Yes, it worked, thank you very much!
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.

↑ Up to the top!