UTCheats.net - Unreal Tournament & Tactical Ops cheats and hacks

Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome to UTCHEATS.NET

Author Topic: New UT2004 Spammer  (Read 3481 times)

xdemic

  • Newbie
  • *
  • Posts: 4
    • View Profile
New UT2004 Spammer
« on: June 10, 2012, 01:47:30 AM »

something silly i wrote up last week when i got bored.

a game of tictactoe within ut2004 chat.

Chat Tic Tac Toe:

I replaced Engine.u, so I'm storing my global variables in Engine.HUDOverlay like this:

Code: [Select]
class HudOverlay extends Actor;

//==========================================================================
// Chat Tic Tac Toe located in ENGINE.PLAYERCONTROLLER

     var int squares[9]; //stores square data 0 = empty, 1 = o, 2 = x
var PlayerReplicationInfo pTurn; //Player whos turn it is to pick a square

var PlayerReplicationInfo PlayerOne;
var PlayerReplicationInfo PlayerTwo;

var bool bGameStarted;
var bool bWaitingForPlayer; //Waiting for playertwo to join.

var int CountDown;
var TicTacToeTimer TicTacTimer;
//==========================================================================

^^thats not necessary obviously if your going to hook PC.TeamMessage() (which is a event that receives incoming text from players and broadcasts)  instead of replace packages.

Then I replaced Engine.Playercontroller.TeamMessage() to check incoming chat like this:

Code: [Select]
event TeamMessage( PlayerReplicationInfo PRI, coerce string S, name Type  ) // Modified by xdemic
{
local string c;

     local string chatCmd;
     local int pix;
     
     // Chat Tic Tac Toe
     
    if ( class'HUDOverlay'.default.TicTacTimer == None )
       class'HUDOverlay'.default.TicTacTimer = Spawn(class'TicTacToeTimer');
   
     
if ( Type == 'Say' && PRI != None && CAPS(Left(S,2)) == "X " && class'HUDOverlay'.default.TicTacTimer != None )
{
          chatCmd = Right(S, Len(S) - 2);
         
          if ( class'HUDOverlay'.default.bGameStarted && PRI != class'HUDOverlay'.default.PlayerOne && PRI != class'HUDOverlay'.default.PlayerTwo )
          {
               ServerSay("You can't use commands when you are not part of the current game"@PRI.PlayerName$".");
               return;
          }
          if ( chatCmd ~= "tictactoe" && !class'HUDOverlay'.default.bWaitingForPlayer )
          {
               if ( class'HUDOverlay'.default.bGameStarted ) {
                 ServerSay("You are already in a game "$PRI.PlayerName$"!"); return;
               }
               
               class'HUDOverlay'.default.PlayerOne = PRI;
               ServerSay(class'HUDOverlay'.default.PlayerOne.PlayerName@"wants to play Tic Tac Toe. Type 'x joingame' (without quotes) in 'Say' chat to play with him.");
               class'HUDOverlay'.default.bWaitingForPlayer = true;
               
               class'HUDOverlay'.default.TicTacTimer.GotoState('WAITINGFORPLAYER');
          }
          if ( chatCmd ~= "joingame" && class'HUDOverlay'.default.bWaitingForPlayer && !class'HUDOverlay'.default.bGameStarted && PRI != class'HUDOverlay'.default.PlayerOne )
          {
               class'HUDOverlay'.default.PlayerTwo = PRI;
               class'HUDOverlay'.default.bWaitingForPlayer = False;
               
               ServerSay("Welcome"@class'HUDOverlay'.default.PlayerTwo.PlayerName$"."@class'HUDOverlay'.default.PlayerOne.PlayerName@"vs"@class'HUDOverlay'.default.PlayerTwo.PlayerName$".");
               ServerSay("Starting Game . . .");
               class'HUDOverlay'.default.TicTacTimer.GotoState('STARTINGGAME');
               //SetTimer(1, True);
          }
          if ( chatCmd ~= "endgame" )
          {
               if ( PRI == class'HUDOverlay'.default.PlayerOne )
               {
                  ServerSay("The game starter '" @class'HUDOverlay'.default.PlayerOne.PlayerName @ "' has ended the game.");
                  ClearGame();
               } else {
                  ServerSay(PRI.PlayerName @ "you must be the game starter to end the game.");
               }
          }
          if ( Left(chatCmd,Len("pick ")) ~= "pick " && class'HUDOverlay'.default.bGameStarted )
          {
            if ( PRI == class'HUDOverlay'.default.pTurn )
            {
               pix = int( Right(chatCmd, Len(chatCmd) - Len("pick ")) );
               
               if ( pix <= 0 || pix > 9 )
               {
                    ServerSay(PRI.PlayerName @ "please input a proper number from 1-9, example: x pick 1");
                    return;
               }
               if ( class'HUDOverlay'.default.squares[pix-1] != 0 )
               {
                    ServerSay(PRI.PlayerName @ "that square is already taken! Please pick an empty space.");
                    return;
               }
               if ( class'HUDOverlay'.default.pTurn == class'HUDOverlay'.default.PlayerOne )
               {
                    class'HUDOverlay'.default.squares[pix-1] = 1;
                    class'HUDOverlay'.default.pTurn = class'HUDOverlay'.default.PlayerTwo;
               }
               else if ( class'HUDOverlay'.default.pTurn == class'HUDOverlay'.default.PlayerTwo ) //Just an additional paranoid check
               {
                    class'HUDOverlay'.default.squares[pix-1] = 2;
                    class'HUDOverlay'.default.pTurn = class'HUDOverlay'.default.PlayerOne;
               }

               BroadCastGameData();
               
               if ( CheckGame() > 0 )
               {
                    GameOver(CheckGame());
                    return;
               }
               
               ServerSay("Its your turn to pick"@class'HUDOverlay'.default.pTurn.PlayerName$". Type 'x pick #' (without quotes 1-9) in chat to choose");
               
           } else {
               ServerSay("It isn't your turn to pick" @ PRI.PlayerName $ "!");
           }     
         }
     }

// Wait for player to be up to date with replication when joining a server, before stacking up messages
if ( Level.NetMode == NM_DedicatedServer || GameReplicationInfo == None )
return;

if( AllowTextToSpeech(PRI, Type) )
TextToSpeech( S, TextToSpeechVoiceVolume );
if ( Type == 'TeamSayQuiet' )
Type = 'TeamSay';

if ( myHUD != None )
myHUD.Message( PRI, c$S, Type );

if ( (Player != None) && (Player.Console != None) )
{
if ( PRI!=None )
{
if ( PRI.Team!=None && GameReplicationInfo.bTeamGame)
{
    if (PRI.Team.TeamIndex==0)
c = chr(27)$chr(200)$chr(1)$chr(1);
    else if (PRI.Team.TeamIndex==1)
        c = chr(27)$chr(125)$chr(200)$chr(253);
}
S = PRI.PlayerName$": "$S;
}
Player.Console.Chat( c$s, 6.0, PRI );
}
}

function BroadCastGameData() // Draws the game in chat.
{
ServerSay("["$sInt(class'HUDOverlay'.default.squares[0])$"]" $ "["$sInt(class'HUDOverlay'.default.squares[1])$"]" $ "["$sInt(class'HUDOverlay'.default.squares[2])$"]");
ServerSay("["$sInt(class'HUDOverlay'.default.squares[3])$"]" $ "["$sInt(class'HUDOverlay'.default.squares[4])$"]" $ "["$sInt(class'HUDOverlay'.default.squares[5])$"]");
ServerSay("["$sInt(class'HUDOverlay'.default.squares[6])$"]" $ "["$sInt(class'HUDOverlay'.default.squares[7])$"]" $ "["$sInt(class'HUDOverlay'.default.squares[8])$"]");
}

exec function EndGame()
{
  ClientMessage("Clearing game data");
  ClearGame();
}

function GameOver( int Winner )
{
  if ( Winner == 1 )
     ServerSay("Congradulations" @ class'HUDOverlay'.default.PlayerOne.PlayerName @ "! You Win ! ! !");
  if ( Winner == 2 )
     ServerSay("Congradulations" @ class'HUDOverlay'.default.PlayerTwo.PlayerName @ "! You Win ! ! !");
  if ( Winner == 3 )
     ServerSay("! ! ! ! ! TIE GAME ! ! ! ! !");
     
  ClearGame();
}

function ClearGame()
{
 local int i;
 
  for ( i = 0; i < 9; i ++ )
     class'HUDOverlay'.default.squares[i] = 0;
     
  class'HUDOverlay'.default.PlayerOne = None;
  class'HUDOverlay'.default.PlayerTwo = None;
  class'HUDOverlay'.default.pTurn = None;
  class'HUDOverlay'.default.bGameStarted = false;
  class'HUDOverlay'.default.bWaitingForPlayer = false;
  class'HUDOverlay'.default.CountDown = 5;
  class'HUDOverlay'.default.TicTacTimer.Destroy();
}

function int CheckGame()
{
local int i;

   if (
   //across
   (class'HUDOverlay'.default.squares[0] == 1 && class'HUDOverlay'.default.squares[1] == 1 && class'HUDOverlay'.default.squares[2] == 1) ||
   (class'HUDOverlay'.default.squares[3] == 1 && class'HUDOverlay'.default.squares[4] == 1 && class'HUDOverlay'.default.squares[5] == 1) ||
   (class'HUDOverlay'.default.squares[6] == 1 && class'HUDOverlay'.default.squares[7] == 1 && class'HUDOverlay'.default.squares[8] == 1) ||
   //down
   (class'HUDOverlay'.default.squares[0] == 1 && class'HUDOverlay'.default.squares[3] == 1 && class'HUDOverlay'.default.squares[6] == 1) ||
   (class'HUDOverlay'.default.squares[1] == 1 && class'HUDOverlay'.default.squares[4] == 1 && class'HUDOverlay'.default.squares[7] == 1) ||
   (class'HUDOverlay'.default.squares[2] == 1 && class'HUDOverlay'.default.squares[5] == 1 && class'HUDOverlay'.default.squares[8] == 1) ||
   //diagonal
   (class'HUDOverlay'.default.squares[0] == 1 && class'HUDOverlay'.default.squares[4] == 1 && class'HUDOverlay'.default.squares[8] == 1) ||
   (class'HUDOverlay'.default.squares[2] == 1 && class'HUDOverlay'.default.squares[4] == 1 && class'HUDOverlay'.default.squares[6] == 1)
   ) return 1; //Player One wins
   
   if (
   //across
   (class'HUDOverlay'.default.squares[0] == 2 && class'HUDOverlay'.default.squares[1] == 2 && class'HUDOverlay'.default.squares[2] == 2) ||
   (class'HUDOverlay'.default.squares[3] == 2 && class'HUDOverlay'.default.squares[4] == 2 && class'HUDOverlay'.default.squares[5] == 2) ||
   (class'HUDOverlay'.default.squares[6] == 2 && class'HUDOverlay'.default.squares[7] == 2 && class'HUDOverlay'.default.squares[8] == 2) ||
   //down
   (class'HUDOverlay'.default.squares[0] == 2 && class'HUDOverlay'.default.squares[3] == 2 && class'HUDOverlay'.default.squares[6] == 2) ||
   (class'HUDOverlay'.default.squares[1] == 2 && class'HUDOverlay'.default.squares[4] == 2 && class'HUDOverlay'.default.squares[7] == 2) ||
   (class'HUDOverlay'.default.squares[2] == 2 && class'HUDOverlay'.default.squares[5] == 2 && class'HUDOverlay'.default.squares[8] == 2) ||
   //diagonal
   (class'HUDOverlay'.default.squares[0] == 2 && class'HUDOverlay'.default.squares[4] == 2 && class'HUDOverlay'.default.squares[8] == 2) ||
   (class'HUDOverlay'.default.squares[2] == 2 && class'HUDOverlay'.default.squares[4] == 2 && class'HUDOverlay'.default.squares[6] == 2)
   ) return 2; //Player Two wins
   
   for ( i = 0; i < 9; i++ ) //Make sure there is empty spots
   {
      if ( class'HUDOverlay'.default.squares[i] == 0 )
        return 0;
   }
   
   return 3; //No empty spots, Tie game.
}
 
//int to x ' s, o ' s, or blank spaces.
function string sInt( int i )
{
 if ( i == 0 )
  return "_";
 if ( i == 1 )
  return "o";
 if ( i == 2 )
  return "x";
}

And heres the class responsible for the Timer stuff:

Code: [Select]
//=====================================================
// class: TicTacToeTimer
// Written by xdemic, not an original Engine class.
//=====================================================
class TicTacToeTimer extends Actor;

state WAITINGFORPLAYER
{
   simulated function BeginState()
   {
     SetTimer(3, True);
   }
   
   simulated function Timer()
   {
      Level.GetLocalPlayerController().ServerSay(class'HUDOverlay'.default.PlayerOne.PlayerName@"wants to play Tic Tac Toe. Type 'x joingame' (without quotes) in 'Say' chat to play with him.");
   }
}

state STARTINGGAME
{
   simulated function BeginState()
   {
     SetTimer(1,True);
   }

   simulated function Timer()
   {
       Level.GetLocalPlayerController().ServerSay(string(class'HUDOverlay'.default.CountDown));
       
       if ( class'HUDOverlay'.default.CountDown == 0 ) //Start Game
       {
               class'HUDOverlay'.default.bGameStarted = True;
               Level.GetLocalPlayerController().BroadCastGameData(); 
               class'HUDOverlay'.default.pTurn = class'HUDOverlay'.default.PlayerOne;
               Level.GetLocalPlayerController().ServerSay("Its your turn to pick"@class'HUDOverlay'.default.PlayerOne.PlayerName$". Type 'x pick #' (without quotes 1-9) in chat to choose");
               class'HUDOverlay'.default.CountDown=5;
               GotoState('ACTIVEGAME');
               SetTimer(3,True);
       }
       
       class'HUDOverlay'.default.CountDown --;
   }
}

state ACTIVEGAME
{
   simulated function Timer()
   {
       Level.GetLocalPlayerController().BroadCastGameData();
       Level.GetLocalPlayerController().ServerSay("Its your turn to pick"@class'HUDOverlay'.default.pTurn.PlayerName$". Type 'x pick #' (without quotes 1-9) in chat to choose");
   }
}

defaultproperties
{
}

Now we have a fully functional tic tac toe game in UT2004 chat.

Screenshot:

HF!

*edit* moved to tutorials section
Logged