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 → On... On... On... Where's Off?
On... On... On... Where's Off?
2001-11-07, 1:17 PM #1
I'm making the sabers leave a little trail in my patch since I've realized some of you like them here at Massassi. I've made the cog. It's exactly how I want it to be. No problems. I was wondering if somebody could make me a cog for a hotkey so I could turn them on/off. You can modify this cog if you need to or you could just make the hotkey. This would be greatly appretiated. Here's the cog. Thanks again!

Code:
# Jedi Knight Missions Cog Script
#
# WEAP_SABER.COG
#
# WEAPON Script - Lightsaber w/ saber trail coding and color switching  -Deathbane27
#
# [CYW] + [RF] + [YB]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
# ========================================================================================

symbols

message  startup
message  activated
message  deactivated
message  selected
message  deselected
message  newplayer
message  autoselect
message  timer
message  fire
message  killed
message  user4			# Change Color
message  user6			# Controls light motion trails for blocking
message  user7			# Handles Lightsaber On/Off switch
message  user1			# Controls light motion trails for flipping


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

model    povModel=sabv.3do             	local
model    saberMesh=sabg.3do            	local
model    fistMesh=fistg.3do            	local

model    povsaber=sabv-g.3do             	local
model    povsaber1=sabv-y.3do             local
model    povsaber2=sabv-o.3do             local
model    povsaber3=sabv-dr.3do            local
model    povsaber4=sabv-b.3do             local
model    povsaber5=sabv-p.3do             local
model    povsaber6=sabv-r.3do             local
model    povsaber7=sabv-lb.3do            local
model    povsaber8=sabv-dp.3do            local
model    povsaber9=sabv-s.3do             local

model	saber=sabg-g.3do  			local
model	saber1=sabg-y.3do   			local
model	saber2=sabg-o.3do   			local
model	saber3=sabg-dr.3do   			local
model	saber4=sabg-b.3do   			local
model	saber5=sabg-p.3do   			local
model	saber6=sabg-r.3do   			local
model	saber7=sabg-lb.3do   			local
model	saber8=sabg-dp.3do   			local
model	saber9=sabg-s.3do   			local

model    Fan1=sabfan-g.3do 			local
model    Fan11=sabfan-y.3do 			local
model    Fan12=sabfan-o.3do 			local
model    Fan13=sabfan-dr.3do 			local
model    Fan14=sabfan-b.3do 			local
model    Fan15=sabfan-p.3do 			local
model    Fan16=sabfan-r.3do 			local
model    Fan17=sabfan-lb.3do 			local
model    Fan18=sabfan-dp.3do 			local
model    Fan19=sabfan-s.3do 			local

model    Fan2=sabfan-g1.3do 			local
model    Fan21=sabfan-y1.3do 			local
model    Fan22=sabfan-o1.3do 			local
model    Fan23=sabfan-dr1.3do 		local
model    Fan24=sabfan-b1.3do 			local
model    Fan25=sabfan-p1.3do 			local
model    Fan26=sabfan-r1.3do 			local
model    Fan27=sabfan-lb1.3do 		local
model    Fan28=sabfan-dp1.3do 		local
model    Fan29=sabfan-s1.3do 			local

# --- Material List --- #

material    mat0=sabergreen0.mat  	local
material    mat01=sabergreen1.mat   	local
material    mat02=saberyellow0.mat   	local
material    mat03=saberyellow1.mat   	local 
material    mat04=saberorange0.mat   	local
material    mat05=saberorange1.mat   	local
material    mat06=saberdred0.mat   	local
material    mat07=saberdred1.mat   	local
material    mat08=saberblue0.mat   		local
material    mat09=saberblue1.mat   		local
material    mat010=saberpurple0.mat   	local
material    mat011=saberpurple1.mat   	local
material    mat012=saberred0.mat   		local
material    mat013=saberred1.mat   		local
material    mat014=saberlblue0.mat   	local
material    mat015=saberlblue1.mat   	local
material    mat016=saberdpurple0.mat   	local
material    mat017=saberdpurple1.mat   	local
material    mat018=sabersilver0.mat  	local
material    mat019=sabersilver1.mat   	local

# --- Spark templates for jkSetSaberInfo --- #

template    tpl_wall=+ssparks_wall           local
template    tpl_blood=+ssparks_blood         local
template    tpl_saber=+ssparks_saber         local

# ........................................................................................
# POV animations

keyframe mountAnim=SabVmnt.key         local
keyframe dismountAnim=SabVdis.key      local
keyframe holdAnim=SabVhold.key         local

keyframe povSnapAnim1=SabVf1.key       local
keyframe povSnapAnim2=SabVf2.key       local
keyframe povSnapAnim3=SabVf1.key       local

keyframe povPreFireAnim=SabVrdy.key    local
keyframe povFireAnimF1=SabVsnp1.key    local
keyframe povFireAnimF2=SabVsnp2.key    local
keyframe povFireAnimB1=SabVb1.key      local
keyframe povFireAnimB2=SabVb2.key      local
keyframe povFireAnimL1=SabVl1.key      local
keyframe povFireAnimR1=SabVr1.key      local
keyframe povChargeAnim=SabVch.key      local

keyframe povPreBlockAnim=SabVblk.key   local

# ........................................................................................
# External animations

keyframe preFireAnimL=KYreadyl.key     local
keyframe preFireAnimR=KYreadyr.key     local
keyframe fireAnimF1=KYsnap1.key        local
keyframe fireAnimF2=KYsnap2.key        local
keyframe fireAnimB1=KYsabrb1.key       local
keyframe fireAnimB2=KYsabrb2.key       local
keyframe fireAnimL1=KYsabrl1.key       local
keyframe fireAnimR1=KYsabrr1.key       local

keyframe snapAnim1=KYsabrf1.key        local
keyframe snapAnim2=KYsabrf2.key        local
keyframe snapAnim3=KYsabrf3.key        local
keyframe chargeAnim=KYcharge2.key      local
keyframe chargeAnim2=KYcharge.key      local
keyframe chargeAnim3=KYcharge3.key     local
keyframe stabAnim=KYstab2.key		   local
keyframe spinL=spinl.key		   local
keyframe spinR=spinr.key		   local

keyframe preBlockAnim=KYblock.key      local
keyframe holsterAnim=kyhlstr.key       local

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

sound    dismountSound=LtSaberOff01.WAV         local
sound    mountSound=LtSaberOn01.WAV             local
sound    hitSound01=LtSaberHit01.WAV            local
sound    hitSound02=LtSaberHit02.WAV            local
sound    hitSound03=LtSaberHit03.WAV            local
sound    hitSound12=LtSaberHit12.WAV            local
sound    hitSound14=LtSaberHit14.WAV            local
sound    swingSound01=LtSaberSwing01.WAV        local
sound    swingSound02=LtSaberSwing02.WAV        local
sound    swingSound03=LtSaberSwing03.WAV        local
sound    swingSound04=LtSaberSwing04.WAV        local
sound    swingSound05=LtSaberSwing05.WAV        local
sound    swingSound06=LtSaberSwing06.WAV        local
sound    swingSound07=LtSaberSwing07.WAV        local
sound    swingSound08=LtSaberSwing08.WAV        local
sound    swingSoundDbl01=LtSaberSwingDbl01.WAV  local
sound    swingSoundDbl02=LtSaberSwingDbl02.WAV  local
sound    swingSoundDbl03=LtSaberSwingDbl03.WAV  local
sound    humSound01=LtSaberLp01.WAV             local

# ........................................................................................
# Animation tracks

int      mountAnimID=-1                         local
int      preAnimID=-1                           local
int      povPreAnimID=-1                        local
int      slashAnimID=-1                         local
int      povSlashAnimID=-1                      local

# ........................................................................................
# Normal Variables

thing    player                                 local

flex     damage                                 local
flex     holsterWait                            local

int      mode                                   local
int      slash                                  local
int      nextAttack                             local
int      humChannel=-1                          local
int      holsterTrack=-1                        local
int      slashSound=-1                          local
int      assign                                 local
int      nosaber=1                              local

vector   thrust                                 local
vector   shakePos                               local
vector   shakeAngle                             local

# ------------- Begin custom variables ----------------

sound    sabcolorSound=lvrclik1.wav       local

int	active=0					local
int	color=0					local

flex	bladelen=0.123				local
flex	keylen					local
flex	fanwait					local

int	fanindex					local
int	volume=1.0
int	crap=-1
int	curAnim=-1					local
int	curPOVAnim=-1				local

cog   kyleCog					local

# -------------- End custom variables -----------------

end

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

code

startup:

   player = GetLocalPlayerThing();

   kyleCog = GetThingClassCog(player);

   // Clear parameters
   ClearActorFlags(player, 0x2000);
   jkDisableSaber(player);
   KillTimerEx(0);
   KillTimerEx(1);
   KillTimerEx(2);
   KillTimerEx(3);
   KillTimerEx(4);
   KillTimerEx(5);
   KillTimerEx(6);
   KillTimerEx(7);
   KillTimerEx(8);
   KillTimerEx(9);
   KillTimerEx(10);
   active = 0;
   slash = 0;
   nextAttack = 0;
   slashAnimID = -1;
   povSlashAnimID = -1;

   return;

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

timer:
   id = GetSenderId();

   	if (id == 0)
   	{
		// Only play the hum sound if we still have the saber up.
		if ((GetCurWeapon( player ) == 10) && !nosaber)
		{
			// Play mounting sound.
			PlaySoundThing(mountSound, player, 1.0, -1, -1, 0x80);
	
			// Stop humming sound
			if(humChannel != -1)
			{
				StopSound( humChannel, 0.5 );
				humChannel = -1;
			}
			jkSetFlags(player, 0x5);
			jkSetFlags(player, 0x80);
			humChannel = PlaySoundThing(humSound01, player, 1.0, -1, -1, 0x81);
		}

   		// Turn on saber physically
   		active = 1;
		jkEnableSaber( player, 60, 0.123, 1.0 );
   		jkSetPOVModel(player, povsaber
        );
   		mountAnimID = jkPlayPOVKey( player, holdAnim, 0, 0x14 );

		// Check if we're dead, lost the saber, or inactive
      	if(GetThingHealth(player) < 1) Return;
		if(GetInv(player, 10) == 0) Return;
		if (active == 0) Return;

		// Change to stationary saber blade
		jkSetWeaponMesh(player, saber
    
        );
   	}
	else
	if (id == 1)
	{
		// Check if we're dead, lost the saber, or inactive
      	if(GetThingHealth(player) < 1) Return;
		if(GetInv(player, 10) == 0) Return;
		if (active == 0) Return;

		if (nosaber == 0)
		SetActorFlags(player, 0x2000);
		jkEnableSaber( player, 60, 0.123, 1.0 );
	}
	else
	if (id == 2)
	{
		StopKey(player, holsterTrack, 0.0);
   }
   else
   if (id == 3)
   {
      SetInv(player, 89, 0);
   }
	else
	if (id == 4)  //This is the trail control
	{
		// Begin trail array, checking each step if we're dead, throwing the saber, or inactive
		KillTimerEx(0);
      	if(GetThingHealth(player) < 1) Return;
      	if(GetInv(player, 10) == 0) Return;
		if (active == 0) Return;

		// Change to first fan
		jkSetWeaponMesh(player, Fan1
    
        );
		sleep(fanwait);

		KillTimerEx(0);
      	if(GetThingHealth(player) < 1) Return;
      	if(GetInv(player, 10) == 0) Return;
		if (active == 0) Return;

		// Change to second fan
		jkSetWeaponMesh(player, Fan2
    
        );
		sleep(fanwait*5);

		KillTimerEx(0);
      	if(GetThingHealth(player) < 1) Return;
      	if(GetInv(player, 10) == 0) Return;
		if (active == 0) Return;

		// Change to first fan
		jkSetWeaponMesh(player, Fan1
    
        );
		sleep(fanwait);

		KillTimerEx(0);
      	if(GetThingHealth(player) < 1) Return;
      	if(GetInv(player, 10) == 0) Return;
		if (active == 0) Return;

		// Change to stationary saber blade
		jkSetWeaponMesh(player, saber
    
        );
	}
	else
	if(id == 5)
	{
	jkSetWeaponMesh(player, fistMesh);  // Switch to fists
	}
	else
	if(id == 6)  // Special timer for DOUBLE slash
	{
		// Stop first trail sequence
		KillTimerEx(4);

		KillTimerEx(0);
      	if(GetThingHealth(player) < 1) Return;
      	if(GetInv(player, 10) == 0) Return;
		if (active == 0) Return;

		jkSetWeaponMesh(player, saber
    
        );

		KillTimerEx(0);
      	if(GetThingHealth(player) < 1) Return;
      	if(GetInv(player, 10) == 0) Return;
		if (active == 0) Return;

 		// Commence second trail sequence
		fanwait=(GetKeyLen(chargeAnim)/18);
		SetTimerEx(fanwait, 4, 0, 0);
	}
	else
	if (id == 7)  // Trails with only the smaller fan (underwater, block, stab, flip)
	{
		KillTimerEx(0);
      	if(GetThingHealth(player) < 1) Return;
      	if(GetInv(player, 10) == 0) Return;
		if (active == 0) Return;

		// Change to first fan
		jkSetWeaponMesh(player, Fan1
    
        );
		sleep(fanwait*7);

		KillTimerEx(0);
      	if(GetThingHealth(player) < 1) Return;
      	if(GetInv(player, 10) == 0) Return;
		if (active == 0) Return;

		// Change to stationary saber blade
		jkSetWeaponMesh(player, saber
    
        );
	}
	else
	if (id == 8)
	{
		active=1;
	}
	else
	if (id == 9)
	{
	   // if the mount anim is still playing stop it
	   if (mountAnimID != -1)
	   {
	      jkStopPOVKey( player, mountAnimID, 0 );
	      mountAnimID = -1;
	   }
		// Kill saber trail timers and change to saber handle
		KillTimerEx(0);
		KillTimerEx(4);
		KillTimerEx(6);
		KillTimerEx(7);
		jkSetWeaponMesh(player, saberMesh);
		jkSetPOVModel(player, povModel);

		// Turn off lightsaber
		jkSetFlags(player, 0x8);
		SendTrigger(-1, 131, player, volume, crap, 0);
		SetInv(player, 89, 1);
		SetTimerEx(0.2, 3, 0, 0);

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

		// Clear slash variables
		slash = 0;
		nextAttack = 0;
		slashAnimID = -1;
		povSlashAnimID = -1;

	      // Stop humming sound
	      if(humChannel != -1)
	      {
	         StopSound( humChannel, 0.5 );
	         humChannel = -1;
	      }
	}
	else
	if (id == 10)
	{
		//Make sure we don't have the saber on when dead
		jkSetWeaponMesh(player, saberMesh);

		// Clear parameters
		jkDisableSaber(player);
		nosaber = 1;
		active = 0;
		ClearActorFlags(player, 0x2000);
		jkDisableSaber(player);
		KillTimerEx(0);
		KillTimerEx(1);
   		KillTimerEx(2);
   		KillTimerEx(3);
   		KillTimerEx(4);
  		KillTimerEx(5);
   		KillTimerEx(6);
   		KillTimerEx(7);
   		KillTimerEx(8);
   		KillTimerEx(9);
   		KillTimerEx(10);
	}

   Return;

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

selected:

   assign = GetSenderRef();

   //Set timer for drawing the saber so we can't turn it on for a bit
   SetInv(player, 89, 1);
   SetTimerEx(0.4, 3, 0, 0);

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

   // Setup the meshes and models.
   jkSetPOVModel(player, povModel);
   SetArmedMode( player, 0 );
   jkSetWeaponMesh( player, saberMesh );
   jkSetWaggle(player, '10.0 7.0 0.0', 350);

   if (assign == 0)
   {
      // Play the animation (NOLOOP + UNIQUE + ENDPAUSE).
      // The animation is held at the last frame after it is played.
      PlayMode(player, 40);
      mountAnimID = jkPlayPOVKey( player, mountAnim, 0, 0x14 );
   }
   else
   {
      mountAnimID = jkPlayPOVKey( player, holdAnim, 0, 0x14 );
   }

   SetMountWait(player, GetKeyLen(mountAnim));

   // Set saber flags, and allow activation of the weapon
   SetCurWeapon( player, 10 );

   // Clear parameters
   jkDisableSaber(player);
   nosaber = 1;
   active = 0;

   Return;

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

deselected:
   // Don't allow lightsaber ON/OFF switch
   // SetInv(player, 89, 1);

   // Back to POV
   if ((jkGetSaberCam() == 1) && (GetCurrentCamera() == 1) && (GetPrimaryFocus(1) == player))
      CycleCamera();

   // Shrink saber
   jkSetFlags(player, 0x8);
   jkClearFlags(player, 0x80);

   // If saber is on, play saber off sound
   if (active == 1)
   {
   	PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80);
   }

   // Dismount the Lightsaber.
   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 the mount anim is still playing stop it
   if (mountAnimID != -1)
   {
      jkStopPOVKey( player, mountAnimID, 0 );
      mountAnimID = -1;
   }
	// Kill saber trail timers and get rid of lightsaber blade
	KillTimerEx(4);
	KillTimerEx(6);
	KillTimerEx(7);
	KillTimerEx(0);
	jkSetWeaponMesh(player, saberMesh);

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

   // Clear variables
   slash = 0;
   nextAttack = 0;
   slashAnimID = -1;
   povSlashAnimID = -1;

   // Stop humming sound
   if(humChannel != -1)
   {
      StopSound( humChannel, 0.5 );
      humChannel = -1;
   }
	
   // Waylay any hum sound that hasn't started yet.
   KillTimerEx(0);

   // Disable autoblock
   KillTimerEx(1);
   ClearActorFlags(player, 0x2000);
   jkDisableSaber(player);
   nosaber = 1;
   active = 0;

   Return;

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

activated:
   mode = GetSenderRef();

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

   if (mode > 1)
      return;

   povPreAnimID = -1;
   preAnimID = -1;

   ActivateWeapon( player, 0.5, mode );

   // Set autoblock and damage on
   SetActorFlags(player, 0x2000);
   jkEnableSaber( player, 60, 0.123, 1.0 );

   // Make sure autoblock and saber damage are on
   SetTimerEx(0.5, 1, 0, 0);

   Return;

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

deactivated:
   mode = GetSenderRef();

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

   // Set autoblock and damage on
   SetActorFlags(player, 0x2000);
   jkEnableSaber( player, 60, 0.123, 1.0 );

   // Make sure autoblock and saber damage are on
   SetTimerEx(0.5, 1, 0, 0);

   return;

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

fire:

	// Turn the lightsaber ON if it's off
	if(active == 0) call user7;

	// Kill trail timers and select appropriate saber color
	KillTimerEx(0);
	KillTimerEx(4);
	KillTimerEx(6);
	KillTimerEx(7);
	jkSetWeaponMesh(player, saber
    
        );

   // Stop block animations, by sending a message to kyle.cog.
	SendMessage( kyleCog, user0 );

	// Underwater saber attacks.
	if (GetMajorMode(player) == 5)
	{
		jkEnableSaber( player, 50, 0.15, 0.25 );
		
		if (nextAttack == 0)
		{
			PlayMode( player, 8);
			jkPlayPOVKey( player, povFireAnimR1, 2, 0x38 );
			nextAttack = 1;
		}
		else
		{
			PlayMode( player, 18);
			jkPlayPOVKey( player, povFireAnimL1, 2, 0x38 );
			nextAttack = 0;
		}

		shakePos = VectorScale(RandVec(),.001);
		shakeAngle = VectorScale(RandVec(),.5);
		SetPOVShake(shakePos, shakeAngle, .05, 80.0);
		keylen=(0.8);
		fanwait = (keylen / 10);
		SetTimerEx(fanwait, 7, 0, 0);
		
		SetFireWait(player, 0.90);
		
		slashSound = Rand()*7;
		PlaySoundThing(swingSound01[slashSound], player, 1.0, -1, -1, 0x80);
	}
	else
	{
		mode = GetSenderRef();
		if (mode == 0)
		{
			// If we do another attack, reset the quick slash counter.
			thrust = GetThingThrust( player );
	
			// RIGHT Regular Strike
			if (VectorX(thrust) > 0)
			{
				jkEnableSaber( player, 50, 0.15, 0.25 );
	
				jkPlayPOVKey( player, povFireAnimR1, 2, 0x38 );
				keylen=GetKeyLen(fireAnimR1);
	   			fanwait = (keylen / 11);
				SetTimerEx(fanwait, 4, 0, 0);
				PlayKey(player, fireAnimR1, 1, 0x38);
	
				shakePos = VectorScale(RandVec(),.001);
				shakeAngle = VectorScale(RandVec(),.5);
				SetPOVShake(shakePos, shakeAngle, .05, 80.0);
	
				slashSound = Rand()*7;
				PlaySoundThing(swingSound01[slashSound], player, 1.0, -1, -1, 0x80);
				SetFireWait(player, 0.65);
			}
			else
			// LEFT Regular Strike
			if (VectorX(thrust) < 0)
			{
				jkEnableSaber( player, 50, 0.15, 0.25 );
				keylen=GetKeyLen(fireAnimL1);
	   			fanwait = (keylen / 11);
				SetTimerEx(fanwait, 4, 0, 0);	
				jkPlayPOVKey( player, povFireAnimL1, 2, 0x38 );
				PlayKey(player, fireAnimL1, 1, 0x38);
	
				shakePos = VectorScale(RandVec(),.001);
				shakeAngle = VectorScale(RandVec(),.5);
				SetPOVShake(shakePos, shakeAngle, .05, 80.0);
	
				slashSound = Rand()*7;
				PlaySoundThing(swingSound01[slashSound], player, 1.0, -1, -1, 0x80);
				SetFireWait(player, 0.65);
			}
			else
			// BACKWARDS Strike
			if (VectorY(thrust) < -0.1)
			{
				jkEnableSaber( player, 50, 0.15, 0.25 );
				keylen=GetKeyLen(stabAnim);
	   			fanwait = (keylen / 26);
				SetTimerEx(fanwait, 7, 0, 0);	

				if (nextAttack == 0)
				{
					jkPlayPOVKey( player, povFireAnimB1, 2, 0x38 );
					keylen=GetKeyLen(fireAnimB1);
					PlayKey(player, fireAnimB1, 2, 0x38);
					nextAttack = 1;
				}


				else
				{
					jkPlayPOVKey( player, povFireAnimB2, 2, 0x38 );
					keylen=GetKeyLen(fireAnimB2);
					PlayKey(player, fireAnimB2, 2, 0x38);
					nextAttack = 0;
				}

				shakePos = VectorScale(RandVec(),.001);
				shakeAngle = VectorScale(RandVec(),.5);
				SetPOVShake(shakePos, shakeAngle, .05, 80.0);
	
				slashSound = Rand()*7;
				PlaySoundThing(swingSound01[slashSound], player, 1.0, -1, -1, 0x80);
				SetFireWait(player, 0.6);
			}
			else
			// STANDING Strike
			if (VectorY(thrust) < 0.1)
			{
				jkEnableSaber( player, 50, 0.25, 0.7 );
	
				if (nextAttack == 0)
				{
					jkPlayPOVKey( player, povFireAnimF1, 2, 0x38 );
					keylen=GetKeyLen(fireAnimF1);
	   	      			fanwait = (keylen / 10);
		      			SetTimerEx(fanwait, 4, 0, 0);
					PlayKey(player, fireAnimF1, 2, 0x38);
					nextAttack = 1;
				}


				else
				{
					jkPlayPOVKey( player, povFireAnimF2, 2, 0x38 );
					keylen=GetKeyLen(fireAnimF2);
	   	      			fanwait = (keylen / 10);
		      			SetTimerEx(fanwait, 4, 0, 0);;
					PlayKey(player, fireAnimF2, 2, 0x38);
					nextAttack = 0;
				}

	
				shakePos = VectorScale(RandVec(),.001);
				shakeAngle = VectorScale(RandVec(),.5);
				SetPOVShake(shakePos, shakeAngle, .05, 80.0);
	
				slashSound = Rand()*7;
				PlaySoundThing(swingSound01[slashSound], player, 1.0, -1, -1, 0x80);
				SetFireWait(player, 0.75);
			}
			else
			{
				// QUICK slash.
				if (slash == 0)
				{
					// If after a second, we haven't attacked again, reset slash to 0.
					jkEnableSaber( player, 50, 0.15, 0.25 );
					keylen=GetKeyLen(snapAnim1);
	   	   			fanwait = (keylen / 10);
		   			SetTimerEx(fanwait, 4, 0, 0);		

					povSlashAnimID = jkPlayPOVKey( player, povSnapAnim1, 2, 0x38);
					slashAnimID = PlayKey(player, snapAnim1, 1, 0x38);
					PlaySoundThing(swingSound01, player, 1.0, -1, -1, 0x80);
		
					shakePos = VectorScale(RandVec(),.001);
					shakeAngle = VectorScale(RandVec(),.5);
					SetPOVShake(shakePos, shakeAngle, .05, 80.0);
		
					SetFireWait(player, 0.25);
					slash = 1;
				}
				else
				if (slash == 1)
				{
					// Allow another second for the 3rd attack.
					jkEnableSaber( player, 50, 0.15, 0.25 );
		
					povSlashAnimID = jkPlayPOVKey( player, povSnapAnim2, 2, 0x38 );
					keylen=GetKeyLen(snapAnim1);
	   	   			fanwait = (keylen / 10);
		   			SetTimerEx(fanwait, 4, 0, 0);
					slashAnimID = PlayKey(player, snapAnim2, 1, 0x38);
					PlaySoundThing(swingSound03, player, 1.0, -1, -1, 0x80);
		
					shakePos = VectorScale(RandVec(),.001);
					shakeAngle = VectorScale(RandVec(),.5);
					SetPOVShake(shakePos, shakeAngle, .05, 80.0);
		
					SetFireWait(player, 0.5);
					slash = 2;
				}
				else
				if (slash == 2)
				{
					jkEnableSaber( player, 130, 0.2, 0.25 );
					keylen=GetKeyLen(stabAnim);
	   				fanwait = (keylen / 26);
					SetTimerEx(fanwait, 7, 0, 0);

					povSlashAnimID = jkPlayPOVKey( player, povSnapAnim3, 2, 0x38 );
					slashAnimID = PlayKey(player, snapAnim3, 1, 0x38);
					PlaySoundThing(swingSound02, player, 1.0, -1, -1, 0x80);
		
					shakePos = VectorScale(RandVec(),.001);
					shakeAngle = VectorScale(RandVec(),.5);
					SetPOVShake(shakePos, shakeAngle, .05, 80.0);
		
					SetFireWait(player, 0.5);
					slash = 0;
				}
			}

	   	fanwait = (keylen / 10);
		SetTimerEx(fanwait, 3, 0, 0);


		}
		// mode == 1
		else
		{
			// HEAVY slash.
			{
				thrust = GetThingThrust( player );
				jkEnableSaber( player, 160, 0.3, 1.2 );
				jkPlayPOVKey( player, povChargeAnim, 2, 0x38 );
				keylen=GetKeyLen(chargeAnim2);
				Fanwait=(keylen / 24);
				SetTimerEx(fanwait*2, 4, ((10*color)+1), 0);
				SetTimerEx(keylen*2/5, 6, 0, 0);
				if (VectorY(thrust) > 0.1)
				{
				PlayKey(player, chargeAnim2, 2, 0x38);
				PlaySoundThing(swingSoundDbl01, player, 1.0, -1, -1, 0x80);
				}
				else
				if (VectorY(thrust) < -0.1)
				{
				PlayKey(player, chargeAnim3, 2, 0x38);
				PlaySoundThing(swingSoundDbl03, player, 1.0, -1, -1, 0x80);
				}
				else
				{
				PlayKey(player, chargeAnim, 2, 0x38);
				PlaySoundThing(swingSoundDbl02, player, 1.0, -1, -1, 0x80);
				}
				shakePos = VectorScale(RandVec(),.001);
				shakeAngle = VectorScale(RandVec(),.5);
				SetPOVShake(shakePos, shakeAngle, .05, 80.0);
	
				SetFireWait(player, 1.4);
			}
		}
	}
   return;

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

newplayer:

   // Reset everything
   slash = 0;
   active = 0;
   nextAttack = 0;
   slashAnimID=-1;
   povSlashAnimID=-1;
   ClearActorFlags(player, 0x2000);
   jkDisableSaber(player);

   KillTimerEx(0);
   KillTimerEx(1);
   KillTimerEx(2);
   KillTimerEx(3);
   KillTimerEx(4);
   KillTimerEx(5);
   KillTimerEx(6);
   KillTimerEx(7);
   KillTimerEx(8);
   KillTimerEx(9);
   KillTimerEx(10);

   // Back to POV
   if ((jkGetSaberCam() == 1) && (GetCurrentCamera() == 1) && (GetPrimaryFocus(1) == player))
      CycleCamera();

   Return;

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

autoselect:

   // Return the saber when out of everthing except the fists

   // If the player has the weapon
   if(GetInv(player, GetWeaponBin(10)) != 0.0)
   {
      ReturnEx(200.0);
   }
   else
   {
      ReturnEx(-1.0);
   }

   Return;

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

killed:
   if (GetLocalPlayerThing() == GetSenderRef())
   {
      if (GetCurWeapon(player) == 10)
      {
   		// Reset everything
		ClearActorFlags(player, 0x2000);
		jkDisableSaber(player);
		KillTimerEx(0);
		KillTimerEx(1);
   		KillTimerEx(2);
   		KillTimerEx(3);
   		KillTimerEx(4);
  		KillTimerEx(5);
   		KillTimerEx(6);
   		KillTimerEx(7);
   		KillTimerEx(8);
   		KillTimerEx(9);
   		KillTimerEx(10);

	   if (active == 1)
	   {
		// Change to just saber handle and then make sure all stuff is cleared
		jkSetWeaponMesh(player, saberMesh);
         	PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80);
         	SetCurWeapon( player, GetWeaponBin(1) );
		SetTimerEx(1.0, 10, 0, 0);
	   }
      }
      nosaber = 1;
	active = 0;
   }
   Return;

#.............................................................................
	
user4:  
   
	if(active == 0) Return;

	PlaySoundThing(sabcolorSound, player, 0.5, -1, -1, 0x80);
	if(color >= 9) color=0;
	else color=(color + 1);

	jkSetWeaponMesh(player, saber
    
        );
	jkSetPOVModel(player, povsaber
    
        );
      jkSetSaberInfo(player, mat0[(2*color)+1], mat0[(2*color)], 0.007, 0.004, bladelen, tpl_wall, tpl_blood, tpl_saber);
	mountAnimID = jkPlayPOVKey( player, holdAnim, 0, 0x14 );

   Return;

#.............................................................................
	
user6:

	keylen=GetKeyLen(snapAnim3);
	fanwait = (keylen / 20);
	SetTimerEx(fanwait, 7, 0, 0);
	slashSound = Rand()*7;
	PlaySoundThing(swingSound01[slashSound], player, 1.0, -1, -1, 0x80);

   Return;

#.............................................................................
	
user7:

   // If lightsaber is ON...
   if (active == 1)
   {
      // If we're drawing the lightsaber, don't do anything
      if (GetInv(player, 89) == 1) Return;

      // Turn OFF lightsaber
      SetArmedMode(player, 0);
      SetTimerEx(0.01, 9, 0, 0);

      // Disable autoblock
      KillTimerEx(1);
      ClearActorFlags(player, 0x2000);
      jkDisableSaber(player);
      nosaber = 1;
      active = 0;
   }
   else
   // If lightsaber is OFF...
   if (active == 0)
   {
	// If we're drawing the lightsaber, don't do anything
	if (GetInv(player, 89) == 1) Return;

	SetInv(player, 89, 1);
	SetTimerEx(1.0, 3, 0, 0);

	// Turn ON lightsaber
	SetArmedMode(player, 2);
  	SetTimerEx(0.00001, 0, 0, 0);

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

	// Set autoblock on and show that we have the saber
	SetActorFlags(player, 0x2000);
	nosaber = 0;
   }

   Return;

#.............................................................................
	
user1:

	if (active == 0) Return;
	keylen=GetKeyLen(snapAnim3);
	fanwait = (keylen / 8);
	SetTimerEx(fanwait, 7, 0, 0);
	PlaySoundThing(swingSound08, player, 1.0, -1, -1, 0x80);

   Return;

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

end

    
Ohh Crap! - Darien Fawkes (The Invisible Man)
2001-11-07, 2:18 PM #2
Go to the tutorials section and read 'Adding hotkeys' by Hell Raiser. It's pretty short, so the work shouldn't take too long.
COUCHMAN IS BACK BABY
2001-11-07, 3:24 PM #3
Sorry about that. I must have not been clear. I know how to make hotkeys. It's not that. I want somebody to make a cog FOR the hotkey. The cog should tell the weap_saber.cog to turn the fan blades off.
Ohh Crap! - Darien Fawkes (The Invisible Man)
2001-11-08, 9:47 AM #4
I can't believe I got to this one before GBK. [http://forums.massassi.net/html/biggrin.gif]

Code:
# toggletrail.cog
#
# Send a message to weap_saber to turn the saber trails on/off when hotkey is pressed.
#
# [SM]
#===========================================#
symbols

int		trails	local
thing		player	local
message	activated

end
#===========================================#
code
#--------------------------------------------
activated:
	player=GetSourceRef();
	if(trails)
	{
		SendMessageEx(GetInvCog(player, 10), user0, 0, 0, 0, 0);
		trails=0;
	}
	else
	{
		SendMessageEx(GetInvCog(player, 10), user0, 1, 0, 0, 0);
		trails=1;
	}

Return;
#--------------------------------------------
end


This hotkey sends a message to weap_saber(bin 10) with the first param being the on/off value of the trails.

You'll have to add a user0 message to weap_saber and assign the saber cog's trail variable to the first param. Like this:

Code:
user0:
     trails=GetParam(0);

Return;


There you go. [http://forums.massassi.net/html/wink.gif]

------------------
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.
2001-11-08, 12:26 PM #5
I have no idea what you meant by the "user0" thing. Am I supposed to change the "trails" to something else? Sorry but I'm stupid. Please describe that.
Ohh Crap! - Darien Fawkes (The Invisible Man)
2001-11-10, 12:49 AM #6
Sorry for taking a while to reply. Been busy lately. [http://forums.massassi.net/html/frown.gif]

All the hotkey does is alternately send either a 1 or 0 to weap_saber when the key is
pressed. A user0 message has to recieve the variable in the saber cog.

Just like the user messages that are already in your saber cog, put a "message user0" in
the symbols section. Then, add:

Code:
user0:
     trails=GetParam(0);

Return;


to the end of your code section. -Just like the other user messages that are already
there.

Make sure you define the integer, trails, in the symbols. This int will recieve the on/off
value from the hotkey. To make sure the hotkey is working correctly, you could put
printint(trails); in the user0 message. That should print either 0 or 1 on the screen.

The hotkey was really the easy part. It requires more cogging to go through your
saber cog and make it recognize the option to turn off the sabertrails.

So, go through your saber cog and put in something like this around the code that
makes the sabertrail effect:
Code:
if(trails)
{
   // Do sabertrail effects
}


That will test to see if trails is equal to one. If trails is zero, then the sabertrails
shouldn't be created.

Hope that helps. [http://forums.massassi.net/html/wink.gif]

------------------
Thank you for sending me a copy of your mod - I'll waste no time playing it.

[This message has been edited by SaberMaster (edited November 10, 2001).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2001-11-11, 4:43 PM #7
Would you please modify the saber cog for me. I've tried doing what you have said quite a few times. I still don't have any luck. I know that there isn't anything wrong with the hotkey cog. I just need you to fill in the user0 info. Thanks.

[This message has been edited by LordX-T_IJ (edited November 11, 2001).]
Ohh Crap! - Darien Fawkes (The Invisible Man)
2001-11-13, 8:10 AM #8
I'll email it to you. [http://forums.massassi.net/html/wink.gif]

------------------
Thank you for sending me a copy of your mod - I'll waste no time playing it.

[This message has been edited by SaberMaster (edited November 13, 2001).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2001-11-13, 8:18 AM #9
My email is lordxt_ij@hotmail.com Thanks!
Ohh Crap! - Darien Fawkes (The Invisible Man)
2001-11-13, 2:42 PM #10
*shrinks into chair* Still nothing.
Ohh Crap! - Darien Fawkes (The Invisible Man)

↑ Up to the top!