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 → What's the score again??
What's the score again??
2002-03-06, 2:42 PM #1
I am working out bugs in Jawa Tag, so I can finally finish off JK editing and get back to real lilfe. It's rolling right along, but every time I commit suicide, my score goes to -1 no matter what I put in there...

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 Tag main cog bin is 85


symbols

int          player=-1                          local                         
int          jawa=-1                            local                         
int          timerID=-1                         local                         
int 	     r 					local
int          num 				local 
int	     oldmodel				local                       

thing        potential                          local                         
thing        randPlayer                         local                         
thing        leaveplayer                        local   
thing	     joinplayer				local                      

model        jawa_mdl=jawa.3do                  local                         

# Scoring Section                       
int          became_the_jawa=7                  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                         
int          pulse_score=1                      local                         

# Sounds Section                       
sound        jawacall=jawa_call.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                                                           

end   
                                                                       
# 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

# ========================================================================================
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);
	SetTimerEx(2, 5001, player, 0);
    }
  SetPulse(15);
  Return;

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

join:
  joinplayer = GetSenderRef();

  // Send the Welcome information, but delay it by 2 seconds
  SetTimerEx(2, 5001, joinplayer, 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 > 2)
    {
	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!!
    {
	//Get a random player
	r = rand();
	num = GetNumplayers();
	jawa = 	GetPlayerNum(r * num);

  	//Transform the player

  	//Change model 
	oldmodel = GetThingModel(jawa);
  	SetThingModel(jawa, jawa_mdl);

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

  	//Broadcast text notification -someone became the jawa
  	jkStringClear();
  	jkStringConcatPlayerName(jawa);
  	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)
    { 
	jkStringClear();
	jkStringConcatASCIIString("Welcome to Jawa Tag, ");
	jkStringConcatSpace();
	jkStringConcatPlayerName(player);
	jkStringConcatASCIIString("!");
	jkStringClear();
	jkStringOutput(player, -1);
    } 
  Else
  If(timerID = 5002)
   {
	//Transform the player

  	//Change model 
	oldmodel = GetThingModel(jawa);
  	SetThingModel(jawa, jawa_mdl);

	// Set the player's model to fully lit
	SetThingLightMode(player, 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");
  killer = GetThingParent(GetSourceRef());

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

  SetInv(player, 87, 0.0);

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

  If(killer != jawa) //Killed by another player
    {
	// Increment player score
	SetPlayerScore(killer, GetPlayerScore(killer) + kill_jawa);

    	//Set killer as new jawa
  	jawa_score_ok = 0;
  	jawa = killer; 
  	SetTimerEx(.1, 5002, 0, 0);
    }
  Else //Suicide
    {
	Print("Suicide");
	//lower player score
	SetPlayerScore(jawa, GetPlayerScore(jawa) -1);
        SetThingModel(jawa, oldmodel);
  	jawa_score_ok = 0;
	jawa = -1;
	SetTimerEx(8, 5000, 0, 0);
   }

  Return;

end


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

Tazz
2002-03-06, 6:39 PM #2
In....

SetPlayerScore(jawa, GetPlayerScore(jawa) -1);

try putting a space between the - and the 1.

If it dont work its probably cause im guessin. ^_^
2002-03-06, 7:06 PM #3
Uhhh, JK takes care of suicides, why would you want to handle it in your code?
-Hell Raiser
2002-03-06, 10:59 PM #4
Hell Raiser --- because I am trying to get rid of the -1 score every time I commit suicide. Maybe I need some special scoring flags.........


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

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

Tazz
2002-03-07, 8:44 AM #5
When you die, your score is refreshed. JK then finds your new score (kills-self_kills) and substitutes it for your overall score.

So, any value that you set with SetPlayerScore() will be overwritten unless you disable JK's regular scoring system with SetMultiModeFlags(0x4). This is done for CTF games.

And BTW, this is all explained in the Score Verbs section of the DataMaster.

------------------
Author of the Jedi Knight DataMaster.
Visit Saber's Domain.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-03-07, 11:06 AM #6
SM, I actually justfound that in DataMaster. BTW, thanks for a great utility.

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

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

Tazz
2002-03-08, 8:32 AM #7
You're welcome. [http://forums.massassi.net/html/wink.gif]

------------------
Author of the Jedi Knight DataMaster.
Visit Saber's Domain.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

↑ Up to the top!