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 → Simulating deactivated message when letting go of key on normal hotkey
Simulating deactivated message when letting go of key on normal hotkey
2003-03-20, 5:59 PM #1
Basically, I want the deactivated message to be triggered in my COG for my hotkey when the actual key is let go. I don't recall this ever happening for regular hotkeys, and all the other flags I try in items.dat either make it stop working completely or crash the game. So how else can I achieve this effect of shutting something off when letting go of a key?

------------------
Bassoon, n. A brazen instrument into which a fool blows out his brains.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2003-03-20, 10:57 PM #2
Depends on what the hotkey is doing.

------------------
"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)
2003-03-21, 1:44 AM #3
I want to be able to press and hold a key to make a parachute come out, when I let go it should go go back (like MDK's parachute).

------------------
Bassoon, n. A brazen instrument into which a fool blows out his brains.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2003-03-21, 2:34 AM #4
Hmm. Look at force jump:
Code:
items.dat
---------

f_jump                  21              0       4.0     0x108   cog=force_jump.cog

Code:
force_jump.cog
--------------

activated:
   if(IsInvActivated(player, 21)) Return;

   SetInvActivated(player, 21, 1);
   mana = GetInv(player, 14);
   if(mana >= cost)
   {
      // Must be attached to a world surface or thing face or on the surface of water.
      attachFlags = GetAttachFlags(player);
      if((attachFlags & 1) || (attachFlags & 2) || (GetPhysicsFlags(player) & 0x100000))
      {
         channel = PlaySoundThing(jumpSound, player, 1.0, -1, -1, 0x80);
      }
      ActivateBin(player, 0, 21);
      SetPulse(0.5);
   }

   Return;

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

deactivated:
   duration = DeactivateBin(player, 21);
   if(duration < soundduration)
   {
      StopSound(channel, 0.1);
      channel = -1;
   }

   rank = GetInv(player, 21);
   maxDuration = rank * 0.35;

   // Must be attached to a world surface or thing face or on the surface of water.
   attachFlags = GetAttachFlags(player);
   if((attachFlags & 1) || (attachFlags & 2) || (GetPhysicsFlags(player) & 0x100000))
   {
      mana = GetInv(player, 14);
      if(mana >= cost)
      {
         PlaySoundThing(jumpSound2, player, 1.0, -1, -1, 0x80);
         if((GetInv(player, 64) != 1) && (GetInv(player, 65) != 1)) ChangeInv(player, 14, -cost);

         // If we tap or hold to max, then do max jump.
         if((duration < 0.15) || (duration > maxDuration))
            duration = maxDuration;

         // Flash the twinkling stars effect
         if(!(jkGetFlags(player) & 0x20))
         {
            jkSetPersuasionInfo(player, 14, 22);
            jkSetFlags(player, 0x20);
            SetTimerEx(0.33, player, 0, 0);
         }

         jump = duration + 2.5;
         upVel = VectorSet(0.0, 0.0, jump);

         playerVel = GetThingVel(player);
         newVel = VectorAdd(upVel, playerVel);
         DetachThing(player);
         SetThingVel(player, newVel);

         ClearPhysicsFlags(player, 0x100000);
         SetBinWait(player, 21, 1.0);
      }
   }
   SetPulse(0);

   SetInvActivated(player, 21, 0);

   Return;

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

pulse:
   if(GetThingHealth(player) < 1)
   {
      if(channel != -1) StopSound(channel, 0.1);
      SetPulse(0);
   }

   Return;

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

The pulse doesn't matter, it's just needed to stop the "charge sound" when the player dies while charging. As you can see, the deactivated message gets called when the player releases the hotkey. Hope that helps.


------------------
"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)
2003-03-21, 12:26 PM #5
I don't think my COG's a problem. For my items.dat entry, I can only use flags 0x120. 0x100 makes it not work, and adding the 0x2 flag for items or 0x8 for Force (where deactivated in the COG would be called), make the game crash on the level load.

I know I've done this before, and it's in the game, but it doesn't want to work for me. What's going on here?

------------------
Bassoon, n. A brazen instrument into which a fool blows out his brains.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2003-03-21, 12:30 PM #6
The items.dat entry:

Code:
parachute			118		    1		1	  0x120   cog=parachute.cog


The COG:

Code:
# Jedi Knight COG Script
#
# Script.COG
#
# Created by Emon.
# Feel free to use this COG as long as credit is given in the readme file.
#
# Parachute COG.
# 
#
# This COG is not supported by LucasArts Entertainment Co.

symbols
thing        player                             local                         

flex         velX=0                             local                         
flex         velY=0                             local                         
flex         velZ=0                             local                         
flex         pulseCount=1.0                     local                         

message      startup
message      activated                                                        
message      deactivated                                                      
message      pulse       
message      newplayer                                                     


end                                                                           

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

code

startup:

	player = GetLocalPlayerThing();
	SetPulse(0);
	SetInvActivated(player, 118, 0);

	Return;

activated:

	If (IsInvActivated(player, 118) || GetThingHealth(playeR) < 1) Return;
	
	SetInvActivated(player, 118, 1);

	Print("Activated");

	pulseCount = pulseCount + 0.01;

	SetPulse(.1);
	
	Return;


pulse:
	If (GetThingHealth(playeR) < 1) Return;

	Print("Pulse");

	velX = VectorX(GetThingVel(player));
	velY = VectorY(GetThingVel(player));
	velZ = VectorZ(GetThingVel(player));

	velX = velX / (pulseCount); 
	velY = velY / (pulseCount);
	velZ = velZ / (pulseCount);

	SetThingVel(player, VectorSet(velX, velY, velZ));

	pulseCount = pulseCount + 0.1;

	Return;


deactivated:

	Print("Deactivated");

	SetInvActivated(player, 118, 0);
	
	SetPulse(0);

	Return;


newplayer:

	SetPulse(0);
	SetInvActivated(player, 118, 0);

	Return;

end


------------------
Bassoon, n. A brazen instrument into which a fool blows out his brains.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2003-03-21, 12:52 PM #7
Do you have a .bm for your item? The name in items.dat, in this case 'parachute' needs to have a corrisponding 8bit and 16bit bm named icparac8.bm and icparac16.bm respectivly. However you could name it one of the other force powers like f_jump and it'll have the force jump icon. This is more than likely why it's crashing on level load when it's a force or item.

------------------
-Hell Raiser
Remember kiddies, trial and error.
Without struggles there is no progress
DBZ: The Destruction is Real
-Hell Raiser
2003-03-21, 1:28 PM #8
I don't know why I didn't think of a missing BM. Works perfectly now, thanks HR!

------------------
Bassoon, n. A brazen instrument into which a fool blows out his brains.
Bassoon, n. A brazen instrument into which a fool blows out his brains.

↑ Up to the top!