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 → Capturing a powerup thing
Capturing a powerup thing
2001-07-23, 11:23 PM #1
Okay, here's the deal. I was just fooling around and thought of making a small mod called "Jawa Tag" - which is basically "Smeer the Queer" for JK. It's similar to KFY in gameplay, (and NO I didn't steal any code) but I'm having one bug. I'm going to replace the power boost with the jawa 'icon' so that this mod can be played in any level. I'm having trouble capturing the icon though. Any ideas? Here is the powerup cog:

Code:
# Jedi Knight Cog Script
#
# POW_POWERBOOST.COG
#
# POWERUP Script - Powerboost
#
# * Modified for Jawa Tag purposes
#
#
#
# [YB]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved


symbols

thing       powerup			local
int         powerup_pos=-1		local

message     touched

end

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

code

touched:

   powerup = GetSenderRef();   
   powerup_pos = GetThingPos(GetSenderRef());

   SendTrigger(-1, 5641, powerup, powerup_pos, -1, -1);

   Return;


end


----------------------------
And also the main game cog:

Code:
# Jedi Knight Cog Script
#
# JT_MAIN.COG
#
# * This script is losely based on CTF_MAIN.COG and KFY_MAIN.COG.
#   No code was directly taken from KFY_MAIN.COG, it was merely 
#   used as a reference.  Extensive code was taken from CTF_MAIN.COG.
#
#
# Copyright 2001 - Tazz - tazztazz@hotmail.com

symbols
                
int          captured=0                         local                         
int          jawa=-1                            local                         
int          verbose=3                          local  # FOR DEBUG                        
int          time_limit=0                       local                         
int          score_limit=0                      local                         
int          level_started=0                    local                         
int          level_ended=0                      local                         
int          game_started=0                     local                         
int          hi_score=-1                        local                         
int          hi_player=-1                       local                         
int          player                             local                         
int          killer                             local                         
int          leaveplayer=0                      local                         
int          senderRef=0                        local                         
int          sourceRef=0                        local                         
int          lock_touch=0                       local                         
int          play_sounds=1                      local                         
int          dummy                              local                         
int          count=0                            local                         

# Scoring Section
int          became_the_jawa=7                  local                         
flex         pulse_score=1.0                    local                         
int          suicide=-2                         local                         
int          kill_jawa=3                        local                         
flex         return_time=60.0                   local                         

# Sounds Section
sound        pickupsnd=ForceThrow01.WAV         local                         
sound        scoresnd=ForceThrow01.WAV          local                         
sound        alarmsnd=00AlarmLoop01.WAV         local                         
sound        successsnd=Accomplish1.WAV         local                         

# New Symbols Secton
model        jawa_mdl=jawa.3do                  local  
model        jawa_icon_mdl=boost.3do		local                       
thing        jawa_icon                          local                
template     jawa_icon_ghost=ghost              local                         
template     jawa_icon_tpl=powerboost           local
int	     jawa_icon_pos			local

message      startup                                                          
message      touched                                                          
message      timer                                                            
message      killed                                                           
message      leave                                                            
message      join                                                             
message      pulse                                                            

# Triggers                                                         
#                                                                             
# 1001 - ICONS#
#
# Misc.
#
# Captured 2=yes, 1=no

end                                                                           

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

code

startup:
  player = GetLocalPlayerThing();
  CaptureThing(player);
  SetMasterCOG(GetSelfCOG());

  if(verbose > 2) Print("Jawa Tag: Startup Evt");

  // SERVER ONLY startup:
  if(IsServer() || !IsMulti())
   {
      // Initialize Time limit
      if(GetMultiModeFlags() & 0x8)
      {
         time_limit = GetTimeLimit();
         if(time_limit > 0) SetTimerEx(time_limit * 60, 9998, 0, 0);
         ClearMultiModeFlags(0x8);
      }

      // Initialize Score limit
      if(GetMultiModeFlags() & 0x10)
      {
         score_limit = GetScoreLimit();
         ClearMultiModeFlags(0x10);
      }
      // Nobody can become the jawa for 30 seconds
      SetTimerEx(30, 9997, 0, 0);
   }

  //Inventory 
  SetInv(player, 63, 0.0);
  SetInvActivated(player, 63, 0);

  //Create ghost at position of jawa icon (to teleport back to later)
  CreateThingAtPos(jawa_icon_ghost, GetThingSector(jawa_icon),GetThingPos(jawa_icon), -1);

  // Send the Welcome information, but delay it by 2 seconds
  SetTimerEx(2, 9996, player, 0);

  Return;

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

pulse:

   // Add score if captured, and display score occasionally
   if(captured == 2)
   {
      SetPlayerScore(jawa, GetPlayerScore(jawa) + pulse_score);
      if(GetPlayerScore(jawa) > hi_score)
      {
         hi_score = GetPlayerScore(jawa);
         hi_player = jawa;

         call check_score_limit;
      }

      //Score display
      count = count + 1;
      if(count > 4)
      {
         count = 0;
         jkStringClear();
         jkStringConcatPlayerName(jawa);
         jkStringConcatSpace();
         jkStringConcatASCIIString(", (the current Jawa) has a score of: ");
         jkStringConcatInt(GetPlayerScore(jawa));
         jkStringOutput(-3, -1);
      }
   }
   Return;

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

join:
   player = GetSenderRef();

   // Send the Welcome information, but delay it by 2 seconds
   SetTimerEx(2, 9996, player, 0);
   Return;

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

leave:
   leaveplayer = GetSenderRef();

   if(GetInv(leaveplayer, 63) > 0.0)
   {
      // Remove the icon
      // Send a TRIGGER_ICON with its parameters
      SendTrigger(leaveplayer, 1001, 63, 0, 0, 0);

      // Remove the jawa power from the player's inventory
      SetInv(leaveplayer, 63, 0.0);

      captured = 1;

      //Return icon to original positon
      SetTimerEx(2, 1, 0, 0);
   }

   Return;

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

//might have to do touched: message in powerup cog, then send a trigger for the FX

touched:

   if(!game_started) Return;

   // Exit if one of the limits has been reached
   if(level_ended != 0) Return;

   player = GetSourceRef();

   // sometimes a dead/dying player can score
   // Health is not synched, so use SITH_TF_DYING instead
   if(GetThingFlags(player) & 0x200) Return;

   senderRef = GetSenderRef();
// If(GetThingModel(senderRef) != jawa_icon_mdl) Return;

   if(senderRef == jawa_icon)
   if(verbose > 2) Print("Jawa Tag: Touched Evt");
   {
      if(level_ended != 0) Return;

      if(play_sounds)
      {
         PlaySoundGlobal(pickupsnd, 1, 0, 4);
         // Play an alarm sound
         KillTimerEx(9995);
         SetTimerEx(1, 9995, 0, 0);
      }

      if(verbose > 0)
      {
         //Broadcast text notification -someone became the jawa
         jkStringClear();
         jkStringConcatPlayerName(player);
         jkStringConcatSpace();
         jkStringConcatASCIIString("is the Jawa!");
         jkStringOutput(-3, -1);
      }

      // Set the player's model to fully lit
      SetThingLightMode(player, 0);

      // Set an icon
      // Send a TRIGGER_ICON with its parameters
      SendTrigger(player, 1001, 63, 1, 0, 0);

      //Destroy original jawa icon
      DestroyThing(jawa_icon);


      jawa = player;

      //Change model and puppet mode
      SetThingModel(jawa, jawa_mdl);
      SetArmedMode(jawa, 6);

      // Increment player score
      SetPlayerScore(jawa, GetPlayerScore(jawa) + became_the_jawa);
      if(GetPlayerScore(jawa) > hi_score)
      {
         hi_score = GetPlayerScore(jawa);
         hi_player = jawa;
         call check_score_limit;
      }

      captured = 2;
   }

   Return;

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

timer:
   // Send the icon back
   if(GetSenderId() == 1)
   {
      if(captured == 1)
      {
         if(play_sounds) dummy = PlaySoundThing(returnsnd, jawa_icon, 1.0, -1, -1, 0);

         CreateThingAtPos(jawa_icon_tpl, GetThingSector(jawa_icon_ghost),GetThingPos(jawa_icon_ghost), -1);

         if(verbose > 0)
         {
            jkStringClear();
            jkConcatASCIIString("The Jawa Icon is up for grabs!");
            jkStringOutput(-3, -1);
         }

         captured = 0;
         Return;
      }
   }
   else
   // unlock touched: messages
   if(GetSenderId() == 9990)
   {
      lock_touch = 0;
   }
   else
   // play success sound
   if(GetSenderId() == 9994)
   {
      PlaySoundGlobal(successsnd, 1, 0, 4);
   }
   else
   // play alarm sound
   if(GetSenderId() == 9995)
   {
      PlaySoundGlobal(alarmsnd, 1, 0, 4);
   }
   else
   // Time to display the welcome info for a new player
   if(GetSenderId() == 9996)
   {
      if(verbose > 1)
      {
         player = GetParam(0);

         jkStringClear();
         jkStringConcatASCIIString("Welcome to Jawa Tag, ");
         jkStringConcatSpace();
         jkStringConcatPlayerName(player);
         jkStringConcatASCIIString("!");
         jkStringClear();
         if(time_limit != 0)
         {
            jkStringConcatASCIIString("Time Limit: ");
            jkStringConcatInt(time_limit);
            jkStringConcatSpace();
            jkStringConcatSpace();
         }

         if(score_limit != 0)
         {
            jkStringConcatASCIIString("Score Limit: ");
            jkStringConcatInt(score_limit);
         }

         jkStringOutput(player, -1);
      }
   }
   else
   // Start the game
   if(GetSenderId() == 9997)
   {
      game_started = 1;
   }
   else
   // The event comes from the level's timelimit being reached
   // Just check that a limit has not been reached before...
   if(GetSenderId() == 9998)
   {
      if(level_ended != 0) Return;

      if(verbose > 2) Print("Time limit reached");
      level_ended = 2;

      call end_level;
   }
   else
   // End the level
   if(GetSenderId() == 9999)
   {
      SyncScores();
      jkEndLevel(1);
   }

   Return;

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

killed:
   if(verbose > 2) Print("Jawa Tag: Killed Evt");

   senderRef = GetSenderRef();
   sourceRef = GetSourceRef();

   // Exit if killed: was sent by anything else than a thing
   if(GetSenderType() != 3) Return;

   // Exit if killed: was sent by one of the flags
   // (powerups send killed: event when taken too...)

   if(senderRef == jawa_icon) Return;

   player = senderRef;

   //Return the icon to its home
   if(GetInv(player, 63) > 0.0)
   {
      // Remove the icon
      // Send a TRIGGER_ICON with its parameters
      SendTrigger(leaveplayer, 1001, 63, 0, 0, 0);

      // Remove the jawa power from the player's inventory
      SetInv(leaveplayer, 63, 0.0);

      captured = 1;

      //Return icon to original positon
      SetTimerEx(2, 1, 0, 0);

      // Set the player's model to Gouraud lit
      SetThingLightMode(player, 3);
      jawa = -1;

         if(killer != player)
         {
            // Increment player score
            SetPlayerScore(killer, GetPlayerScore(killer) + kill_jawa);
         }

      //return the icon immediately
      SetTimerEx(0.5, 1, 0, 0);

      if(verbose > 0)
      {
         jkStringClear();
         jkStringConcatPlayerName(jawa);
         jkStringConcatSpace();
         jkStringConcatASCIIString("died.");
         jkStringOutput(-3, -1);
      }
   }
   else
   {
       //Add 1 to the killer score
       killer = GetThingParent(sourceRef);
       if(killer != player)
         {
            // Increment player score
            SetPlayerScore(killer, GetPlayerScore(killer) + 1);
         }
   }

   Return;

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

trigger:

   // Handle only TRIGGER_JAWA_ICON_POS
   if(GetSourceRef() != 5641) Return;

   jawa_icon           = GetParam(0);
   jawa_icon_pos       = GetParam(1);

   Return;

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

show_end:
   if(verbose > 0)
   {
      // Space
      jkStringConcatSpace();

      if(level_ended == 1)
      {
         jkStringConcatASCIIString("Score Limit Reached!  Ending Game");
      }

      if(level_ended == 2)
      {
         jkStringConcatASCIIString("Time Limit Reached!  Ending Game");
      }

      // Space
      jkStringConcatSpace();
      jkStringOutput(-3,-1);
   }

   Return;

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

end_level:

   SyncScores();

   call show_end;

   // display final scores
   KillTimerEx(9997);
   SetTimerEx(3, 9997, 0, 0);

   // until it is time to quit the level
   SetTimerEx(4, 9999, 0, 0);

   Return;

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

check_score_limit:

   // there must be a score limit
   if(score_limit <= 0) Return;

   if(hi_score >= score_limit)
   {
      level_ended = 1;
      call end_level;
   }

   Return;

end


Things happen in JK, but it just doesn't happen directly when I touch the power boost.

(BTW, I found a way for multiple .pup setups in multiplayer. It's a hack, but it seems to work. --And it's not ParseArg()!!!)

Thanks ahead of time.

-Tazz
-There are easier things in life than finding a good woman, like nailing Jello to a tree, for instance

Tazz
2001-07-24, 7:58 AM #2
I dont even know if this is possible.. but if you are going to title it that.. wouldn't it be a bit cooler if whoever was holding the flag had their skin modified to be say a jawa robe or such? When you set the flag that the item has been aquired slap the new skin on them and when they die assign the pre-power skin back. Just a thought

------------------
~~~~~~~~~~~~~~~~~~~~~~~~~

"That's the Force for you... So much power, so many holes to fall into."


Jedi Master Labri
~~~~~~~~~~~~~~~~~~~~~~~~~

"That's the Force for you... So much power, so many holes to fall into."


Jedi Master Labri
2001-07-24, 8:52 AM #3
Quote:
<font face="Verdana, Arial" size="2">Originally posted by Jedi Master Labri:

</font>


How did you get that!?!?! Could I put that in my sig? PLU-EASE??

------------------
I'm not ashamed to let you know ~ I want this light in me to show ~ I'm not ashamed to speak the name of Jesus Christ ~ ~ What are we sneaking around for? Who are trying to please? Shrugging off sin, apologizing like we're spreading some kinda disease. I'm saying, "No way! No way!"

I may like Stargate, but I am a Christian, and I'm not afraid.

Check out my homepage, which doubles as the homepage for the DTP.


http://www.members.tripod.com/colonel_oneil/
A step to the throne, I stand alone. A vacant mind, and a destined home. Engaging the end in a seamless gaze, like blind I climb thru the tourtured blaze. Raise me up, into white unstained. Eternity gained, only life remains. Forever the scars have been washed away, like blood on the brow of a forgotten day. Life is a path, Death - A destination.
2001-07-24, 1:30 PM #4
First off, it does more than just change into a jawa robe. You actually change into a JAWA! --I'm using the ughnaught's pup file right now since I'm not good at keys.

Anywow...I really could use some help. And I'm sure it's possible.

------------------------

How foolish of me! No 'trigger' message added to symbols section! But, I bet there's more bugs than that!


-Tazz



[This message has been edited by Tazz (edited July 24, 2001).]
-There are easier things in life than finding a good woman, like nailing Jello to a tree, for instance

Tazz
2001-07-26, 8:52 AM #5
Hey Col.. you get the "†" by holding down the alt key and hitting 0-1-3-4 ON THE NUMBER PAD. and letting go of the alt key.. or you can just attempt to copy and paste.. tis up to you.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Sounds like it should be cool man. Will have to see it when it comes out. Do you have it far enough that the keys will change back and forth?

------------------
~~~~~~~~~~~~~~~~~~~~~~~~~

"That's the Force for you... So much power, so many holes to fall into."


Jedi Master Labri
~~~~~~~~~~~~~~~~~~~~~~~~~

"That's the Force for you... So much power, so many holes to fall into."


Jedi Master Labri

↑ Up to the top!