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 → 'go sleep!'
'go sleep!'
2002-01-21, 12:04 PM #1
I'm pretty sure this is possible but not entirely positive. I'm in need of a Force Power cog. If any of you know how to do this I would greatly appretiate it. I need a Force Power that is targetable like any other. When you use it on enemies it will have an efffect similiar to the aisleep.cog, (enemy would stand still and not notice you) The effect will last 3 seconds per star. If it is used on people in multiplayer it would just stun them. If this is possible and you know how it can be accomplished please let me know. Thanks!

------------------
Ohh Crap! - Darien Fawkes (The Invisible Man)
Ohh Crap! - Darien Fawkes (The Invisible Man)
2002-01-22, 3:00 AM #2
What do you mean by "stunning" opponents? They should stand still like with Force Grip? In that case you can just copy the entire cog and comment out the lines where it hurts other people. Probably you have also to modify KYLE.COG to handle immunities and so on.

------------------
"May the SourceCode be with you..."
Nemios, MOD developer.
"May the SourceCode be with you..."
Nemios, MOD developer.
2002-01-22, 6:36 AM #3
Yes, it would stun human players like that but as for AI, they would just stand still as normal and not see you. Can this be done? I know how to do the kyle.cog immunities and stuff but I need the actual power. Thanks.

------------------
Ohh Crap! - Darien Fawkes (The Invisible Man)
Ohh Crap! - Darien Fawkes (The Invisible Man)
2002-01-22, 8:18 AM #4
it can be done yes, all you have to do is put this code in the deactivated part of the cog, if you are using the standard targeting code.
Code:
SetActorFlags(victim, 0x200000);
if (GetThingType(victim) == 2)
{
   // set the AiSleep stuff here
}
SetTimer(3*rank);

and then make sure in the timer to clear all the ActorFlags and the AiSleep stuff
2002-01-22, 11:11 AM #5
So that's all the deactivated message will be? Just that? And will that work on human players, too?

------------------
Ohh Crap! - Darien Fawkes (The Invisible Man)
Ohh Crap! - Darien Fawkes (The Invisible Man)
2002-01-22, 1:40 PM #6
er... not exactly, what i mean is edit the force blinding cog (or any other targeting cog) so that it's just the bare bones targeting code, then add that into the correct place of deactivated.

[edit]and when i say // put AISleep stuff here, i mean copy the relevant code from AISleep[/edit]

[This message has been edited by Coconut Boy (edited January 22, 2002).]
2002-01-24, 11:33 AM #7
The code you gave me just causes the victim to sink into the ground. They still shoot and everything. Can you actually write out the Force power to see if this works?

------------------
Ohh Crap! - Darien Fawkes (The Invisible Man)
Ohh Crap! - Darien Fawkes (The Invisible Man)
2002-01-24, 10:39 PM #8
Add SetActorFlags(victim, 0x800) to blind them or modify SetActorFlags(victim, 0x200000) to SetActorFlags(victim, 0x200800).
Remember to clear those flags when you want to stop those effects with ClearActorFlags(victim, 0x200800).
See other flags values in JKSpecs if you want to try other effects.

------------------
"May the SourceCode be with you..."
Nemios, MOD developer.
"May the SourceCode be with you..."
Nemios, MOD developer.
2002-01-27, 9:00 AM #9
That set of flags just blinds the enemy. it doesn't make them "sleep."

------------------
Ohh Crap! - Darien Fawkes (The Invisible Man)
Ohh Crap! - Darien Fawkes (The Invisible Man)
2002-01-29, 6:35 AM #10
Eeh?

------------------
Ohh Crap! - Darien Fawkes (The Invisible Man)
Ohh Crap! - Darien Fawkes (The Invisible Man)
2002-02-01, 3:43 AM #11
Certainly it's possible. The two cogs below should do what you want. I'm not sure what you want to happen to multiplayer opponents, but you should be able to change the effects to what you want.

This replaces force_blinding:
Code:
# force_sleep.cog
#
# Make an actor sleep when the power is used on him.
#
# [SM]
#=======================================================================#
symbols

thing		player		local
thing		victim		local
thing		target		local
thing		dummy		local

flex		mana		local
flex		cost=50		local

int		rank			local
int		count		local

flex		dot			local
flex		maxdot		local
flex		timefactor=10	local
flex		distfactor=1	local

sound	blindingSound=ForceBlind01.WAV		local

template	cone_tpl=+force_blind				local

message	startup
message	activated
message	deactivated
message	pulse
message	timer
message	killed
message	deselected
message	selected

end
#=======================================================================#
code
#-------------------------------------------------------------------------
startup:
	player = GetlocalPlayerThing();

Return;
#-------------------------------------------------------------------------
activated:
	if(active) Return;

	mana = GetInv(player, 14);
	rank = GetInv(player, 27);

	if(mana >= cost)
	{
		active=1;
		SetInvActivated(player, 27, 1);
		SetPulse(0.1);
	}

Return;
#-------------------------------------------------------------------------
pulse:
	victim=-1;
	maxdot=0;

	target = FirstThingInView(player, 30 + 15 * rank, 8, 0x404);
	while(target != -1)
	{
		// This condition was too long for the forums.
		//Put it back together when you paste it into your .cog.
		if(HasLOS(player, target)
&& (target != player)
&& (VectorDist(GetThingPos(player), GetThingPos(target)) <= (distfactor + rank))
&& !(GetThingFlags(target) & 0x200)
&& !(GetActorFlags(target) & 0x100)
&& !((jkGetFlags(target) & 0x20)
&& !IsInvActivated(player, 23)))
		{
			dot = ThingViewDot(player, target);
			if(dot > maxdot)
			{
				victim = target;
				maxdot = dot;
			}
		}
		target = NextThingInView();
	}

	if(victim != -1)
	{
		jkSetTargetColors(1, 2, 3);
		jkSetTarget(victim);
	}
	else jkEndTarget();

Return;
#-------------------------------------------------------------------------
deactivated:
	if(victim == -1 || GetThingHealth(player) < 1)
	{
		call stop_power;
		Return;
	}

	SetPulse(0);
	jkEndTarget();

	mana = GetInv(player, 14);
	if(mana >= cost)
	{
		if(GetInv(player, 65) != 1) ChangeInv(player, 14, -cost);
		SetBinWait(player, 27, 0.2);
		rank = GetInv(player, 27);

		if(HasLOS(player, victim) && (victim != player))
		{
			PlayMode(player, 24);
			PlaySoundThing(blindingSound, player, 1.0, -1, -1, 0x80);
			dummy=CreateThingAtPosNR(cone_tpl, GetThingSector(player), VectorAdd(GetThingPos(player), '0 0 0.04'), '0 0 0');
			SetThingLook(dummy, VectorSub(GetThingPos(victim), GetThingPos(player)));

			if(GetThingType(victim) == 10)		// PLAYER
			{
				if(!(GetThingFlags(victim) & 0x200)) SkillTarget(victim, player, 27, rank);
			}
			else		// AI
			{
				if(!(AIGetMode(victim) & 0x200))
				{
					KillTimerEx(victim);			// If this actor is already sleeping, kill his timer and sleep him again.
				}
				AIClearMode(victim, 0x2ff);
				SetTimerEx(rank * timefactor, victim, GetThingSignature(victim), 0);	// Sleep victim for 5 seconds per rank
			}
		}
	}

	active = 0;
	SetInvActivated(player, 27, 0);

Return;
#-------------------------------------------------------------------------
timer:
	victim=GetSenderID();
	if(GetThingSignature(victim) == GetParam(0)) AISetMode(victim, 0x2ff);

Return;
#-------------------------------------------------------------------------
selected:
	jkStringClear();
	jkStringConcatAsciiString("Force Sleep");
	jkStringOutput();

Return;
#-------------------------------------------------------------------------
deselected:
killed:
	call stop_power;

Return;
#-------------------------------------------------------------------------
stop_power:
	SetPulse(0);
	SetInvActivated(player, 27, 0);
	active=0;
	jkEndTarget();

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


The cog has to replace for blinding only because each force power uses its own bin number. If you want to replace a different power, you'd have to replace all the references to the 27th bin - including the ones in SkillTarget() and below in kyle.cog.

The new kyle.cog:
Code:
# Jedi Knight Cog Script
#
# KYLE.COG
#
# Main script for the player. Handles things like saber info,
# saber blocking animations, invulnerability at respawn, etc.
#
# [YB & CYW]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved

symbols

thing       player                           local

int         nextBlock=0                      local
int         bin                              local
int         rank                             local

int         sleeping=0                 local
int         effect_handle=-1          local
int         PulledWeapon                     local

int         playersector                     local
vector      playerpos                        local
int         bub                              local

template    tpl=+FPBryarPistol               local
template    tpl1=+FPBryarPistol              local
template    tpl2=+FPBryarPistol              local
template    tpl3=+FPSTrifle                  local
template    tpl4=+FPDetonator                local
template    tpl5=+FPCrossbow                 local
template    tpl6=+FPRepeaterGun              local
template    tpl7=+FPRailGun                  local
template    tpl8=+FPSeqCharge                local
template    tpl9=+FPConcRifle                local

template    smoke_tpl=+heavysmoke            local
int         smoke                            local

template    teleport_particles=+telesparks   local
sound       teleportsnd=ForceThrow01.WAV     local

template    bubble_tpl=bubble                local
template    bubble_tpl2=bubble2              local
template    bubble_tpl3=bubble3              local

template    splash_tpl=+watersplash          local
template    splash_tpl2=+watersplash2        local
int         a_splash                         local
int         sender                           local
int         source                           local

keyframe    povBlockAnim0=SabVblk0.key       local
keyframe    povBlockAnim1=SabVblk1.key       local
keyframe    povBlockAnim2=SabVblk2.key       local

keyframe    blockAnim0=KYblock0.key          local
keyframe    blockAnim1=KYblock1.key          local
keyframe    blockAnim2=KYblock2.key          local

int         dummy=0                          local
int         blockPOVTrack=-1                 local
int         blockTrack=-1                    local

int         griptrackID=-1                   local

message     startup
message     killed
message     newplayer
message     timer
message     blocked
message     skill
message     damaged
message     splash
message     user0

end

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

code

startup:
   player = GetLocalPlayerThing();

   if(!IsMulti()) call init_kyle;

   // Bubbles
   if(IsMulti())
      SetTimerEx(4 + 5 * rand(), 2, 0, 0);
   else
      SetTimerEx(2 + 5 * rand(), 2, 0, 0);

   Return;

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

killed:
   if(player != GetSenderRef()) Return;

   if(IsMulti())
   {
      CreateBackpack(player);
      ClearActorFlags(player, 0x2000);
   }

   // clean up force powers stuff
   if(effect_handle!=-1)
   {
      freeColorEffect(effect_handle);
      effect_handle = -1;
   }
   ClearActorFlags(player, 0x800);
   KillTimerEx(27);
   sleeping = 0;

   ClearActorFlags(player, 0x40000);

   if(griptrackID != -1)
   {
      StopKey(player, griptrackID, 0.1);
      griptrackID = -1;
   }

   Return;

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

damaged:
   if(GetParam(1) == 32) call make_bubbles;

   ReturnEx(GetParam(0));
   Return;

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

make_bubbles:
   playersector = GetThingSector(player);
   playerpos    = VectorAdd(GetThingPos(player), '0 0 0.075');

   for(bub = 1; bub < 1 + 3 * rand(); bub = bub + 1)
   {
      CreateThingAtPosNR(bubble_tpl[3 * rand()], playersector, VectorAdd(playerpos, VectorScale(VectorNorm(VectorSet(rand()-0.5, rand()-0.5, rand()-0.5)), 0.05)), '0 0 0');
      Sleep(0.05);

      // Don't create too many bubbles over the network...
      if(!IsMulti())
      {
         CreateThingAtPos(bubble_tpl3, playersector, VectorAdd(playerpos, VectorScale(VectorNorm(VectorSet(rand()-0.5, rand()-0.5, rand()-0.5)), 0.05)), '0 0 0');
         Sleep(0.05);
      }
   }

   Return;

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

newplayer:

   call init_kyle;

   // If it's multiplayer
   if(IsMulti()) call init_multi_kyle;

   // Start Bubbles
   SetTimerEx(2 + 5 * rand(), 2, 0, 0);

   Return;

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

timer:
   if(GetSenderId() == 1)                    // Invulnerable for a while
   {
      // jkSetInvulnerable(GetParam(0), 0);
      ClearActorFlags(GetParam(0), 8);
      Return;
   }
   else
   if(GetSenderId() == 2)                    // Bubbles check
   {
      if(GetThingHealth(player) < 1) Return;

      if((GetThingFlags(player) & 0x2000000) && !(GetPhysicsFlags(player) & 0x100000))
         call make_bubbles;

      if(IsMulti())
         SetTimerEx(4 + 5 * rand(), 2, 0, 0);
      else
         SetTimerEx(2 + 5 * rand(), 2, 0, 0);

      Return;
   }
   else
   if(GetSenderId() == 24)
   {
      // A pulled weapon must be made takeable again
      SetCollideType(GetParam(0), 1);
      Return;
   }
   else
	if(GetSenderID() == 27)
	{
		if(effect_handle != -1)
		{
			freeColorEffect(effect_handle);
			effect_handle=-1;
		}
		AddDynamicTint(player, 1, 0, 0);
		ClearActorFlags(player, 0x200000);
		sleeping=0;
		Return;
	}
   else
   if(GetSenderId() == 31)
   {
      if(griptrackID != -1)
      {
         StopKey(player, griptrackID, 0.1);
         griptrackID = -1;
      }
      ClearActorFlags(player, 0x40000);
      Return;
   }

   Return;

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

blocked:
   if(player != GetSenderRef()) Return;

   if (blockPOVTrack != -1)
   {
      jkStopPOVKey( player, blockPOVTrack, 0.1 );
      blockPOVTrack = -1;
   }
   if (blockTrack != -1)
   {
      StopKey( player, blockTrack, 0.1 );
      blockTrack = -1;
   }

   // PlaySoundThing(hitSound14, player, 1.0, -1, -1, 0);
   blockPOVTrack = jkPlayPOVKey(player, povBlockAnim0[nextBlock], 2, 0x1a);
   blockTrack = PlayKey(player, blockAnim0[nextBlock], 2, 0x1a);

   nextBlock = nextBlock + 1;
   if(nextBlock > 2)
      nextBlock = 0;

   Return;

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

// This message is sent from the weap_saber.cog
user0:
   if (blockPOVTrack != -1)
   {
      jkStopPOVKey( player, blockPOVTrack, 0.1 );
      blockPOVTrack = -1;
   }
   if (blockTrack != -1)
   {
      StopKey( player, blockTrack, 0.1 );
      blockTrack = -1;
   }
   Return;

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

skill:

   // player might be dead when skill: arrives over the net...
   if(GetThingHealth(player) <= 0) Return;

   // Handle multiplayer force power effects
   bin = GetParam(0);
   rank = GetParam(1);

   if(bin == 24)                             // Force Pull
   {
      ReturnEx(0);
      if(!IsInvActivated(player, 28))        // Absorb makes player immune to Pull
      {
         if((GetCurWeapon(player) != 1) && (GetCurWeapon(player) != 10))
         {
            // Create a powerup corresponding to the current weapon
            PulledWeapon = CreateThingAtPos(tpl[GetCurWeapon(player)], GetThingSector(player), GetThingPos(player), '0 0 0');

            // Make the powerup collide later
            SetTimerEx(0.2, 24, PulledWeapon, 0);

            // Duplicate for internet games
            SetTimerEx(0.25, 24, PulledWeapon, 0);

            // Throw the powerup at the player
            ApplyForce(PulledWeapon, VectorScale(VectorNorm(VectorSub(GetThingPos(GetSourceRef()), GetThingPos(player))), 30));

            // Remove the weapon from the player
            ChangeInv(player, GetCurWeapon(player), -1);

            // Switch to fists
            SelectWeapon(player, 1);

            ReturnEx(1);
         }
      }

      Return;
   }
   else
	if(bin == 27)                            // Force Sleep
	{
		if(!sleeping && !IsInvActivated(player, 23))		// Seeing makes player immune
		{
			sleeping=1;
			effect_handle=NewColorEffect(0, 0, 0, 1, 0, 0, 0, 0, 0, 0.2);
			PlaySoundThing(LoadSound("kyljpa.wav"), player, 1, 2, 5, 0x180); 
			PlayKey(player, LoadKeyframe("kyhit0.key"), 4, 0x20);
			SetTypeFlags(player, 0x200000);
			StopThing(player);
			SetTimerEx(rank, 27, player, 0);
		}
		Return;
	}
   else
   if (bin == 31)                            // Force Grip
   {
      if(!IsInvActivated(player, 29))        // Protection makes player immune to Grip
      {
         griptrackID = PlayMode(player, 25);
         SetActorFlags(player, 0x40000);

         // Print("You are taking Grip damage");
         jkPrintUNIString(player, 300);
         DamageThing(player, 2 * rank, 0x8, GetSourceRef());
         SetTimerEx(0.5, 31, player, 0);
         ReturnEx(1);
      }
      else
      {
         ReturnEx(0);
      }

      Return;
   }
   else
   if (bin == 34)                            // Deadly Sight
   {
      // Print("You are taking Deadly Sight damage");
      jkPrintUNIString(player, 301);
      DamageThing(player, 4 * rank, 0x8, GetSourceRef());
      smoke = CreateThingAtPosNR(smoke_tpl, GetThingSector(player), GetThingPos(player), '0 0 0');
      // Raise the tint above the normal damage tint
      if(GetCurrentCamera() == 0)
         AddDynamicTint(player, 0.15, 0.0, 0.07);
      ReturnEx(1);
      Return;
   }

   ReturnEx(-1);
   Return;

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

splash:
   // splash: messages are only sent to the local player's cogs
   // (class cog and capture cog) for performance reasons...

   sender = GetSenderRef();
   source = GetSourceRef();

   // actor or player ?
   if((GetThingType(sender) == 2) || (GetThingType(sender) == 10))
   {
      // whatever source (i.e. enter or leave, don't care)
      a_splash = CreateThingAtPosNR(splash_tpl2, GetThingSector(sender), GetThingPos(sender), '0 0 0');
   }
   // these are mostly the projectiles...
   else
   {
      // on entering only
      if(source == 1)
         // not if player is submerged, but still do it if he's on the surface
         if(!(GetThingFlags(player) & 0x2000000) || (GetPhysicsFlags(player) & 0x100000))
            a_splash = CreateThingNR(splash_tpl, sender);
   }

   Return;

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

init_kyle:
   SetActorFlags(player, 8);
   SetTimerEx(1.50, 1, player, 0);

   // Set Health to full
   SetThingHealth(player, 100);

   // Set Mana to full
   SetInv(player, 14, GetInv(player, 20) * 50);

   // Set Shields to 100 minimum
   if(GetInv(player, 60) < 100) SetInv(player, 60, 100);

   // Set Battery to 100 minimum
   if(GetInv(player, 13) < 100) SetInv(player, 13, 100);

   // Set the power boost to 1.0
   SetInv(player, 63, 1.0);

   // When player starts, give him fists, and a bryar.
   SetInv(player, 1, 1.0);
   SetInv(player, 2, 1.0);

   // Give 50 energy minimum
   if(GetInv(player, 11) < 50) SetInv(player, 11, 50.0);

   // Bacta
   if(GetInv(player, 40) == 0)
      SetInvAvailable(player, 40, 0);
   else
      SetInvAvailable(player, 40, 1);

   // IR Goggles
   if(GetInv(player, 41))
      SetInvAvailable(player, 41, 1);
   else
      SetInvAvailable(player, 41, 0);
   SetInvActivated(player, 41, 0);

   // Field Light
   SetInv(player, 42, 1);
   SetInvAvailable(player, 42, 1);
   SetInvActivated(player, 42, 0);
   ClearActorFlags(player, 4);

   jkEndTarget();

   Return;

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

init_multi_kyle:

   // Set Weapons
   SetInv(player, 1, 1.0);
   SetInv(player, 2, 1.0);
   SetInv(player, 3, 0.0);
   SetInv(player, 4, 0.0);
   SetInv(player, 5, 0.0);
   SetInv(player, 6, 0.0);
   SetInv(player, 7, 0.0);
   SetInv(player, 8, 0.0);
   SetInv(player, 9, 0.0);
   SetInv(player, 10, 1.0);

   // Set Ammo
   SetInv(player, 11, 50.0);
   SetInv(player, 12, 0.0);
   SetInv(player, 15, 0.0);

   // Remove bacta tank and IR goggles
   SetInv(player, 40, 0);
   SetInv(player, 41, 0);
   SetInvAvailable(player, 40, 0);
   SetInvAvailable(player, 41, 0);

   // Set shields to 100
   SetInv(player, 60, 100);

   // Do respawn effects
   dummy = CreateThingAtPos(teleport_particles, GetThingSector(player), GetThingPos(player), '0 0 0');
   dummy = PlaySoundThing(teleportsnd, player, 1.0, -1, -1, 0x180);

   SetFireWait(player, -1);
   SetMountWait(player, 0);
   SetCurInvWeapon(player, 0);
   SelectWeapon(player, AutoSelectWeapon(player, 1));

   Return;

end


This kylecog has the force blinding code in the skill message replaced; so now it stuns the actor for a while instead of blinding him. I would have only posted a part of the skill message, but because I changed the name of a few variables, there were changes to other messages.


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

------------------
Each cog better than the next

[This message has been edited by SaberMaster (edited February 01, 2002).]

[This message has been edited by SaberMaster (edited February 01, 2002).]
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

↑ Up to the top!