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 → COG only works in LEC levels....
COG only works in LEC levels....
2002-09-05, 1:34 PM #1
I have heard of this kind of thing happening a lot, but it hasnt happened to me yet.
Anyway, my kyle.cog for GaSII checks to see if the player is using either of 2 skins, if not, the cog switches the skin to be compatable with the system. I did this because one of my weapons has support for using 2 of that weapon at the same time, and the only way to do this is to make a skin with the left handed gun already there.

SO, This cog works fine in SP and MP LEC levels, but not in any usermade levels. Well, the cog works, but it wont set the models at all. Also, if I start a game using a skin that is supported by the system, it gives me the error message that i coded in for when the skin doesnt work, then switches the skin to ky.3do (default model).

mmodels are the 2 reular supported skins without a gun built in.

wmodels are the 2 supported skins with the left handed gun in place.

I didn't used to document my cogs at all, so there is little or no reference as to what is going on, if you have any questions ask me.

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]
# added support for 2 berettas, shield suit, and jetpack
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved

symbols

thing        player                             local                         

int          nextBlock=0                        local                         
int          bin                                local                         
int          rank                               local                         

int          bin00=62                           local                         

#shield suit shtuff                        

model        Model=-1                           local                         
model        iModel=invis.3do                   local                         

#beretta shtuff                                                           

model        mmodel0=kya18.3do                  local                         
model        mmodel1=kya19.3do                  local                         

model        wmodel0=2gtroop.3do                  local                         
model        wmodel1=bryg2s.3do                 local                         

#gib/blood

template     blood=+bloodstain			local
template     bloodcloud=+bloodcloud		local
template     head=limb1                         local                         
template     torso=limb2                        local                         
template     arm=limb3                          local                         
template     leg=limb4                          local                         

flex         shield                             local                         
flex         damage                             local                         

sound        outsnd=SCAlarm.wav                 local                         

int          pmodel=-1                          local                         
int          force_blinding=0                   local                         
int          blindingEffectHandle=-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                                                            
message      pulse                                                            

end                                                                           

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

code

startup:
   player = GetLocalPlayerThing();
	SetTimerEx(1, 101, -1, -1);
   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;

   SetThingModel(player, wmodel0[pmodel]);
   if(IsMulti()) SendTrigger(-1, 5000, player, 0, 0, 0);
   else  ParseArg(player, "puppet=ky.pup");

   check = 0;
   SetPulse(0);

   //Gibs for multi player + backpack crap
   if(IsMulti())
   {
   SetThingFlags(player, 0x10);
   SendTrigger(-1, 1000, player, GetThingVel(GetSourceRef()), 0, 0);
   CreateBackpack(player);
   ClearActorFlags(player, 0x2000);
   }

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

   ClearActorFlags(player, 0x40000);

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

   Return;

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

damaged:
   	if(GetParam(1) == 32) call make_bubbles;
	damage = GetParam(0);
	if(IsInvActivated(player, bin00) == 1)
 {
	shield = GetInv(player, 117);
		player = GetSenderRef();
   if(shield > 0)
   {
         AddDynamicTint(player, 0, damage/100, damage/100);
         shield = shield - damage;
         if(shield <= 0) {
            	damage = -shield;
		SetInv(player, bin00, 1.0);
      		SetInvActivated(player, bin00, 0);
		Print("Shield Suit has run out of energy");
      		PlaySoundLocal(outsnd, 1.0, 0.0, 0); }
         else {
            damage = 0;
		jkStringClear();
		jkStringConcatAsciiString("Shield Suit at ");
		jkStringConcatFlex(shield);
		jkStringOutput();
		jkStringClear(); }
	SetInv(player, 117, shield);
   }
}
else if(IsMulti()) SendTrigger(-1, 2000, player, 0, 0, 0);
	else {	CreateThingAtPos(bloodcloud, GetThingSector(victim), GetThingPos(victim), '0 0 0');
		CreateThingAtPos(blood, GetThingSector(victim), GetThingPos(victim), '0 0 0'); }
   ReturnEx(damage);
   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(blindingEffectHandle!=-1)
      {
         freeColorEffect(blindingEffectHandle);
         blindingEffectHandle = -1;
      }
      // Get the effect ramping down
      AddDynamicTint(player, 200 + 8 * rank, 210 + 10 * rank, 200 + 8 * rank);
      ClearActorFlags(player, 0x800);
      force_blinding = 0;
      Return;
   }
   else
   if(GetSenderId() == 31)
   {
      if(griptrackID != -1)
      {
         StopKey(player, griptrackID, 0.1);
         griptrackID = -1;
      }
      ClearActorFlags(player, 0x40000);
      Return;
   }
else
if(GetSenderID() == 100) SetPulse(0.01);
else
if(GetSenderID() == 101)
{ 
	Model=GetThingModel(player);
	if((model != mmodel0) && (model != mmodel1))
	{
		SetThingModel(player, mmodel0);
		if(IsMulti()) Print("Error: model not compatabple with GaSII system.");
		Model=GetThingModel(player);
		if(IsMulti()) Print("Error accounted for, please use GaSII skins in the future.");
	}
}
   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 Blinding
   {
      if((!force_blinding) && (!IsInvActivated(player, 23)))   // Seeing makes player immune to Blinding
      {
         force_blinding = 1;
         blindingEffectHandle = newColorEffect(0, 0, 0, 0, 0, 0, 200 + 8 * rank, 210 + 10 * rank, 200 + 8 * rank, 1.0);
         SetActorFlags(player, 0x800);
         SetTimerEx(4 * rank, 27, player, 0);
         ReturnEx(1);
      }
      else
      {
         ReturnEx(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:
   // make sure we can see the player if he was gibbed previously
   ClearThingFlags(player, 0x10);
   
   SetActorFlags(player, 8);

   SetInvAvailable(player, 41, 1);
   SetTimerEx(1.50, 1, player, 0);
   SetTimerEx(2, 100, -1, -1);
   // 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
   SetInv(player, 41, 1);
   SetInvAvailable(player, 41, 1);

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

   jkEndTarget();

   Return;

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

init_multi_kyle:
		SetTimerEx(2, 100, -1, -1);
		   SetInv(player, 41, 1);
   SetInvAvailable(player, 41, 1);
   SetInvActivated(player, 41, 0);
   // Set Weapons
   ClearThingFlags(player, 0x10);
   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);

   SetInvAvailable(player, 40, 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;

#

pulse:
if (GetInv(player, 3) == 2)
	{
	if ((GetCurWeapon(player) == 3) && (check == 0))
		{
		if(GetThingModel(player) == mmodel0) pmodel = 0;
		else
		if(GetThingModel(player) == mmodel1) pmodel = 1;
		PrintInt(pmodel);
		SetThingModel(player, wmodel0[pmodel]);
		check = 1;
		}
	else
	if ((GetInv(player, 3) !=2) || (GetCurWeapon(player) != 3))
		{
			check = 0;
			if (model != -1)
			{
				SetThingModel(player, mmodel0[pmodel]);
			}
	}
}

	if (IsInvActivated(player, bin00) == 1) SetThingModel(player, iModel);
else
	if ((IsInvActivated(player, bin00) == 0) && (GetThingModel(player) == iModel)) SetThingModel(player, Model);
	return;


end


------------------
I'm just an old man with a skooma problem.
I'm just an old man with a skooma problem.
2002-09-05, 2:43 PM #2
I believe, correct me if I'm wrong, any mod you activate, if the level's gob has something that come into conflict with the mod's that level overwrites its. So what I'm saying, any level that has a kyle.cog in it overwrites your kyle.cog. My best guess. *shrugs*

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-09-05, 3:00 PM #3
solved my own problem, and you were close.

Apparantly, the only levels that have the model count in the level.jkl higher than the number of models actually used in the level is LEC's. Any level made in JED will limit the model count in the level's jkl file to the number of different models used in the level. So i upped the count in a test level and it worked! which is perfect for me because for GaSII i plan on having an MP level pack with it. too bad for user made SP levels though, i guess.
I'm just an old man with a skooma problem.
2002-09-06, 8:03 AM #4
So this cog is for a mod? And the mod only works in LEC levels? Then have you defined your custom models in the static.jkl? With the static.jkl you have the option of adding more models by raising its model limit.

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

↑ Up to the top!