One quick question- I've been trying to make Jawa Tag versitile so that it can be used on any level. I tried linking it in items.dat, but that didn't seem to work. Any ideas on how to make it work on any level? I believe this is why I can't get the code to work, (not even debugging text) but I'll post the re-written code below. BTW -thanks Hideki. Haven't tested it yet, but we'll soon find out. Also, can I use GetNumPlayers() somehow to make sure it doesn't pick over the number of players in the game?
the items.dat snippet:
-----------------------
the main Jawa Tag cog re-written:
----------------
Once again, thanks in advance.
-Tazz
the items.dat snippet:
Code:
# Item definition file for Jedi Knight # ======================================================================================== # name id min max flags args # ======================================================================================== ##################################################### # Jawa Tag Debug Items (To allow play on any level) # ##################################################### jt_main_cog 85 1 1 0x20 cog=jt_main.cog jt_iconclient_cog 86 1 1 0x20 cog=jt_iconclient.cog jt_icon 87 0 1 0x00
-----------------------
the main Jawa Tag cog re-written:
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 # Jawa bin is 87 symbols int player=-1 local int jawa=-1 local int players0 local int players1 local int players2 local int players4 local int players5 local int players6 local int players7 local int players8 local int players9 local int players10 local int players11 local int timerID=-1 local int x local int ID local int chosen local thing potential local thing randPlayer local thing leaveplayer local model jawa_mdl=jawa.3do local # Scoring Section int became_the_jawa=7 local flex pulse_score=1.0 local int suicide=-2 local int kill_jawa=3 local int jawa_score_ok=0 lcoal int hi_score=-1 local int hi_player=-1 local # Sounds Section sound jawacall=ForceThrow01.WAV local sound scoresnd=ForceThrow01.WAV local sound alarmsnd=00AlarmLoop01.WAV local sound successsnd=Accomplish1.WAV local message startup message timer message join message leave message pulse message killed # Timer IDs # # 5000 = Lock Jawa selection for 30 seconds, then select random jawa # 5001 = Display welcome text/info # 5002 = Person who killed jawa now becomes the jawa end # ======================================================================================== code startup: player = GetLocalPlayerThing(); CaptureThing(player); SetMasterCOG(GetSelfCOG()); if(verbose > 2) Print("Jawa Tag: Startup Begun"); // Nobody can become the jawa for 30 seconds If(IsServer()) SetTimerEx(30, 5000, 0, 0); SetPulse(2); Return; # ........................................................................................ join: player = GetSenderRef(); // Send the Welcome information, but delay it by 2 seconds SetTimerEx(2, 5001, player, 0); Return; # ........................................................................................ leave: leaveplayer = GetSenderRef(); if(GetInv(leaveplayer, 87) > 0.0) { // Remove the icon // Send a TRIGGER_ICON with its parameters SendTrigger(leaveplayer, 1001, 87, 0, 0, 0); SetInv(leaveplayer, 87, 0.0); //Choose a new jawa in 3 seconds SetTimerEx(5000, 3, 0, 0); } Return; # ........................................................................................ pulse: // Add score and display score occasionally //Make sure we have a current jawa FIRST If(jawa_score_ok < 1) Return; 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; # ........................................................................................ timer: timerID = GetSenderID(); If(timerID == 5000) //Choose who is going to be the JAWA!! { //Thanks to Hideki for the following code: For(x=0; x<GetSectorCount(); x=x+1) { potential = FirstThingInSector(x); While(potential != -1) { If(GetThingType(potential) == 0x400) { players[ID] = potential; ID = ID + 1; } potential = NextThingInSector(potential); } } chosen = rand()*ID; if(chosen == ID) chosen = ID - 1; randPlayer = players[chosen]; //End Hideki's code ;-) //Transform the player jawa = randPlayer; //Change model and puppet mode SetThingModel(jawa, jawa_mdl); SetArmedMode(jawa, 6); //Add inventory (easier to keep track) SetInv(jawa, 87, 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, 87, 1, 0, 0); //Broadcast text notification -someone became the jawa jkStringClear(); jkStringConcatPlayerName(player); jkStringConcatSpace(); jkStringConcatASCIIString("is the Jawa!"); jkStringOutput(-3, -1); //Play the "Jawa Call" globally PlaySoundGlobal(jawacall, 1, 0, 4); // 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; } //Unlock pulse (to increment score) jawa_score_ok = 1; Return; } Else If(timerID = 5001) { player = GetParam(0); jkStringClear(); jkStringConcatASCIIString("Welcome to Jawa Tag, "); jkStringConcatSpace(); jkStringConcatPlayerName(player); jkStringConcatASCIIString("!"); jkStringClear(); jkStringOutput(player, -1); } Else If(timerID = 5002) { //Transform the player //Change model and puppet mode SetThingModel(jawa, jawa_mdl); SetArmedMode(jawa, 6); //Add inventory (easier to keep track) SetInv(jawa, 87, 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, 87, 1, 0, 0); //Broadcast text notification -someone became the jawa jkStringClear(); jkStringConcatPlayerName(player); jkStringConcatSpace(); jkStringConcatASCIIString("is the Jawa!"); jkStringOutput(-3, -1); //Play the "Jawa Call" globally PlaySoundGlobal(jawacall, 1, 0, 4); // 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; } //Unlock pulse (to increment score) jawa_score_ok = 1; Return; } Return; # ........................................................................................ killed: if(verbose > 2) Print("Jawa Tag: Killed Begun"); senderRef = GetSenderRef(); killer = GetThingParent(GetSourceRef()); player = senderRef; // Exit if killed: was sent by anything else than a thing if(GetSenderType() != 3) Return; // Remove the icon // Send a TRIGGER_ICON with its parameters SendTrigger(leaveplayer, 1001, 87, 0, 0, 0); SetInv(leaveplayer, 87, 0.0); // Set the player's model to Gouraud lit SetThingLightMode(player, 3); jawa = -1; If(killer == player) { //lower player score SetPlayerScore(player, GetPlayerScore(player) + suicide); } Else { // Increment player score SetPlayerScore(killer, GetPlayerScore(killer) + kill_jawa); } //Set killer as new jawa jawa_score_ok = 0; jawa = killer; SetTimerEx(5002, 3, 0, 0); Return; end
----------------
Once again, thanks in advance.
-Tazz
-There are easier things in life than finding a good woman, like nailing Jello to a tree, for instance
Tazz
Tazz