PDA

View Full Version : [Tutorial]Example RedOrchestra Uscript


alien56
10th November 2007, 01:21
Hello,

Here is a Little Example for people that want to Create their own UScript Bots for RedOrchestra and Dont know where to begin. I will Post a Hook, and a Sample PostRender, PawnRelated, and sample function. With all of the Support in the America's Army Section on UScript and the Unreal Wiki, and of course the RO SDK you should have no problem creating more functions.

FIRST Thing you need to do is Install the RedOrchestra SDK Beta. Obviously if you dont UCC.exe then using a UCC Command is not going to be recognized? To do this Log into your Steam Account. Go to the Tools Tab. Find RedOrchestra SDK Beta. Double Click it and Let it Install just like you do with a Normal game. Once it is Finished you Should Now be able to Compile your Bot.

Second thing you need to do is go to Your RO Folder. It should be located in your Steam/Common Folder. Default Path = C:\Program Files\Steam\steamapps\common\RedOrchestra.

Now in that Folder Create a NewFolder and Name it whatever you want your Bot Name to Be. I will call it ROBST. Inside the new folder Make another Folder called Classes. Now inside of the Classes Folder Create 2 New Text Documents and Name them Whatever you want with the Extension .uc(dont name them the same). I will use NewbInteraction.uc and ROBoting.uc. NewbInteraction.uc will contain the code to Load the Bots interaction into the Game and ROBoting.uc will contain all of the Bots actual function code. Again name them whatever you want(if you use these Steam may update and cause the game to give a GPF if these class names are found in the Process like they did with my other Pub Release).

Now open NewbInteraction with Notepad and Put this Into it:

//================================================== ===================================

// Loader Class

//================================================== ===================================
Class NewbInteraction extends ExtendedConsole; //Our loader class name, change to whatever you named this file.

var PlayerController MyController;
var ROBoting ROBoting; //Our Interaction Class Name(the Class with our bot functions) change this to whatever you named that file.

event Tick(float Delta)
{
Super.Tick(Delta);
MyController = ViewportOwner.Actor;
if(ROBoting == None)
{
ROBoting = ROBoting(MyController.Player.InteractionMaster.Add Interaction("ROBST.ROBoting", MyController.Player));
ROBoting.NewbInteraction = self;
}
if (ROBoting != None)
{
ROBoting.bActive = true;
ROBoting.bVisible = true;
ROBoting.bRequiresTick = false;
}
}
defaultproperties
{
}


Now save the File again.

Open up ROBoting.uc or whatever you named it and put in this to get you started.

//================================================== ===================================

// BOT START.

//================================================== ===================================
class ROBoting extends Interaction Config(ROHack); //change ROHack to whatever you want the name of your .ini file to be(make sure you change it)

var PlayerController MyController;
var Pawn Me;
var NewbInteraction NewbInteraction; //change to whatever you named your Loader file

var bool botactive;
var config bool crosshair;
var config float xhairsize;

event PostRender(Canvas Canvas)
{
MyController = ViewportOwner.Actor;
Me = MyController.Pawn;

Canvas.Font = Font'Engine.Defaultfont';

if(!botactive || MyController == None || Me.PlayerReplicationInfo == None)
{
Return;
}
PawnRelated(Canvas);
}
function PawnRelated(Canvas Canvas)
{
DrawCrossHair(Canvas);
}
function DrawCrossHair(Canvas Canvas)
{
if(crosshair)
{
Canvas.Style = 3;
Canvas.bCenter = False;
Canvas.bNoSmooth = True;

//Main Cross
Canvas.SetDrawColor(0, 255, 0, 25);
//xHair Right Side
Canvas.SetPos((Canvas.SizeX / 2) + 1, (Canvas.SizeY / 2));
Canvas.DrawTile(Texture'Engine.WhiteSquareTexture' , xhairsize, 2, 0, 0, 2, 2);
//xHair Left Side
Canvas.SetPos((Canvas.SizeX / 2) - xhairsize, (Canvas.SizeY / 2));
Canvas.DrawTile(Texture'Engine.WhiteSquareTexture' , xhairsize - 0.6, 2, 0, 0, 2, 2);
//xHair Down
Canvas.SetPos((Canvas.SizeX / 2), (Canvas.SizeY / 2) + 1);
Canvas.DrawTile(Texture'Engine.WhiteSquareTexture' , 2, xhairsize, 0, 0, 2, 2);
//xHair Up
Canvas.SetPos((Canvas.SizeX / 2), (Canvas.SizeY / 2) - xhairsize);
Canvas.DrawTile(Texture'Engine.WhiteSquareTexture' , 2, xhairsize, 0, 0, 2, 2);
}
}
function Msg(string Message)
{
if ( Me != None )
{
Me.ClientMessage(Message);
}
}
exec function SetXSize(float NewXHairSize)
{
if(NewXHairSize > 25.0 || NewXHairSize < 6)
{
xhairsize = 7;
Msg("CrossHair Set to Default Size");
}
else
{
xhairsize = NewXHairsize;
Msg("CrossHair Size Set to"$xhairsize);
}
}
exec function Save()
{
SaveConfig();
StaticSaveConfig();
Msg("Settings Saved");
}
defaultproperties
{
botactive=True;
crosshair=True;
xhairsize=7;
}


Now Save the File again. Now to Compile it.

First Create another Text Document in Your Main Bot Folder. Put this Text into it:

cd..
cd System
Del ROBST.u
ucc make -h
Pause

Now save it as: Anything.bat

name it whatever just make sure the extension .bat. Change the Del ROBST.u to whatever you named your Bot.

Now go into RO system folder and Locate your RedOrchestra.ini file.

First add the Loader Line.

Find the Line: Console = ROInterface.ROConsole
change to: Console = ROBST.NewbInteraction
Of Course that Line would Vary depending on whatever you named your Bot and Your loader file.

Now search again within the RedOrchestra.ini file and Find: EditPackages. Just After the last EditPackages line add.

EditPackages = ROBST
should look lie this:

EditPackages=Core
EditPackages=Engine
EditPackages=Fire
EditPackages=Editor
EditPackages=UnrealEd
EditPackages=IpDrv
EditPackages=UWeb
EditPackages=GamePlay
EditPackages=UnrealGame
EditPackages=XGame
EditPackages=XInterface
EditPackages=XAdmin
EditPackages=XWebAdmin
EditPackages=GUI2K4
EditPackages=xVoting
EditPackages=UTV2004c
EditPackages=UTV2004s
EditPackages=ROEffects
EditPackages=ROEngine
EditPackages=ROGame
EditPackages=ROAmmo
EditPackages=ROInventory
EditPackages=ROInterface
EditPackages=RORoles
EditPackages=ROVehicles
EditPackages=ROBST


Now go ahead and Save RedOrchestra.ini.

Navigate Back to your Bot Folder and Double Click the .bat file(batch file) you created earlier and Watch your bot Compile. When It says Completed 0 Errors 0 Warnings go ahead and hit enter. Now you should have: YourBotsName.u in the system folder. IE: ROBST.u in this case. Now just load the game and open a Map or join a Server to test it. To load a Map, In console type:
Open RO-Danzig for example.
Once you spawn(assuming you made no mistakes) You should see your new Crosshair. To Adjust the Size just type in console: SetXSize "Number between 6 and 100" without Quotes.

To save type in Console: Save
Your settings will be saved into the .ini file that you named at the top of your Bot Class file IE:

class ROBoting extends Interaction Config(ROHack);
would save it as ROHack.ini

Hope this helps somebody, Now you should be able to Compile your Own bot and Not have to worry about steam updating and checking your Class Names(if you dont share them with anybody :))

Also for a Little Bit of Extra Protection. Find your Bot.u (whatever you named your bot) in the RO System Folder. Now change the Extension from .u to .rom. Now Cut the File out and Paste It Into your Maps Folder. Now just load up RO like Normal and it Will Load just fine. Should avoid detection from an Extra .u File in your system folder(witch shouldnt happen anyways since the game allows Mods and they would have to kick anybody with mod files as well :))

Edit: Example Archive Uploaded

Lisa
10th November 2007, 01:28
Let me just thank you for your efforts, both of us know that this probably won't achieve that many replies but even if it helps one person then it certainly will be useful. :)

noobieuk
10th November 2007, 02:37
damn i'm lame i tried this for 2 hours and i cant get it to work
i suck with trying to write scripts like this.

can you please make me one of these again named differently than ROhack please

alien56
10th November 2007, 02:45
http://www.mpcforum.com/showthread.php?t=212311

updated the original post with a Compiled version of the ESP using these class Names.

Anyways with this just Extract the ROBST.rar into the RedOrchestra Folder. Add the EditPackages line into RedOrchestra.ini and Double Click the .Bat file within the ROBST Folder and it will compile Straight away.

ablindman2
10th November 2007, 11:20
keeps say ucc is not a command for the batchfile

noobieuk
10th November 2007, 20:43
C:\Program Files\Steam\steamapps\common\red orchestra\MAPZ\Classes>cd..

C:\Program Files\Steam\steamapps\common\red orchestra\MAPZ>cd System
The system cannot find the path specified.

C:\Program Files\Steam\steamapps\common\red orchestra\MAPZ>Del MAPZ.u
Could Not Find C:\Program Files\Steam\steamapps\common\red orchestra\MAPZ\MAPZ.u


C:\Program Files\Steam\steamapps\common\red orchestra\MAPZ>ucc make -h
'ucc' is not recognized as an internal or external command,
operable program or batch file.

C:\Program Files\Steam\steamapps\common\red orchestra\MAPZ>Pause
Press any key to continue . . .


this is the error i get when i try to compile it.

my Bot folder is named MAPZ
with my loader file name newb.uc and my bot functions file is named nobot.uc

heres whats in my loader file named newb.uc

//================================================== ===================================

// Loader Class

//================================================== ===================================
Class Newb extends ExtendedConsole; //Our loader class name, change to whatever you named this file.

var PlayerController MyController;
var nobot nobot; //Our Interaction Class Name(the Class with our bot functions) change this to whatever you named that file.

event Tick(float Delta)
{
Super.Tick(Delta);
MyController = ViewportOwner.Actor;
if(ROBoting == None)
{
ROBoting = ROBoting(MyController.Player.InteractionMaster.Add Interaction("ROBST.ROBoting", MyController.Player));
ROBoting.NewbInteraction = self;
}
if (ROBoting != None)
{
ROBoting.bActive = true;
ROBoting.bVisible = true;
ROBoting.bRequiresTick = false;
}
}
defaultproperties
{
}



And heres whats in my bot functions file named nobot.uc

//================================================== ===================================

// BOT START.

//================================================== ===================================
class ROBoting extends Interaction Config(MAPZ); //change ROHack to whatever you want the name of your .ini file to be(make sure you change it)

var PlayerController MyController;
var Pawn Me;
var nobot nobot; //change to whatever you named your Loader file

var bool botactive;
var config bool crosshair;
var config float xhairsize;

event PostRender(Canvas Canvas)
{
MyController = ViewportOwner.Actor;
Me = MyController.Pawn;

Canvas.Font = Font'Engine.Defaultfont';

if(!botactive || MyController == None || Me.PlayerReplicationInfo == None)
{
Return;
}
PawnRelated(Canvas);
}
function PawnRelated(Canvas Canvas)
{
DrawCrossHair(Canvas);
}
function DrawCrossHair(Canvas Canvas)
{
if(crosshair)
{
Canvas.Style = 3;
Canvas.bCenter = False;
Canvas.bNoSmooth = True;

//Main Cross
Canvas.SetDrawColor(0, 255, 0, 25);
//xHair Right Side
Canvas.SetPos((Canvas.SizeX / 2) + 1, (Canvas.SizeY / 2));
Canvas.DrawTile(Texture'Engine.WhiteSquareTexture' , xhairsize, 2, 0, 0, 2, 2);
//xHair Left Side
Canvas.SetPos((Canvas.SizeX / 2) - xhairsize, (Canvas.SizeY / 2));
Canvas.DrawTile(Texture'Engine.WhiteSquareTexture' , xhairsize - 0.6, 2, 0, 0, 2, 2);
//xHair Down
Canvas.SetPos((Canvas.SizeX / 2), (Canvas.SizeY / 2) + 1);
Canvas.DrawTile(Texture'Engine.WhiteSquareTexture' , 2, xhairsize, 0, 0, 2, 2);
//xHair Up
Canvas.SetPos((Canvas.SizeX / 2), (Canvas.SizeY / 2) - xhairsize);
Canvas.DrawTile(Texture'Engine.WhiteSquareTexture' , 2, xhairsize, 0, 0, 2, 2);
}
}
function Msg(string Message)
{
if ( Me != None )
{
Me.ClientMessage(Message);
}
}
exec function SetXSize(float NewXHairSize)
{
if(NewXHairSize > 25.0 || NewXHairSize < 6)
{
xhairsize = 7;
Msg("CrossHair Set to Default Size");
}
else
{
xhairsize = NewXHairsize;
Msg("CrossHair Size Set to"$xhairsize);
}
}
exec function Save()
{
SaveConfig();
StaticSaveConfig();
Msg("Settings Saved");
}
defaultproperties
{
botactive=True;
crosshair=True;
xhairsize=7;
}

could you check what i'm doing wrong please

thanks much appreciated

alien56
10th November 2007, 22:48
EDIT: ok sorry guys, I updated the First post, The First Step is Now To make sure you have the SDK Installed.

Well, The first thought that comes to mind would be to ask if you have even installed the RedOrchestra SDK yet? If you havnt you need to log into your Steam account and go to Tools. Double click on the RedOrchestra SDK Beta and Let it install.

If have the SDK installed then the only other reason for this error is maybe you didnt place Bot Folder in the Right directory so the Batch file dosent find UCC.exe. You need to place it in(default):

C:\Program Files\Steam\steamapps\common\Red Orchestra\YourBotFolder


Also since you changed the Name of the .uc Files you need to also change the Class name.

class ROBoting extends Interaction Config(MAPZ);

Needs to be

class NoBot extends Interaction Config(MAPZ);

This needs to be the Name of your Loader:

var nobot nobot;

Needs to be

var Newb Newb;

and in your loader file You now need to change every Instance of the Old class names to your new Ones:

//================================================== ===================================

// Loader Class

//================================================== ===================================
Class Newb extends ExtendedConsole; //Our loader class name, change to whatever you named this file.

var PlayerController MyController;
var nobot nobot; //Our Interaction Class Name(the Class with our bot functions) change this to whatever you named that file.

event Tick(float Delta)
{
Super.Tick(Delta);
MyController = ViewportOwner.Actor;
if(NoBot == None)
{
NoBot = NoBot(MyController.Player.InteractionMaster.Add Interaction("MAPZ.NoBot", MyController.Player));
NoBot.Newb = self;
}
if (NoBot != None)
{
NoBot.bActive = true;
NoBot.bVisible = true;
NoBot.bRequiresTick = false;
}
}
defaultproperties
{
}

noobieuk
10th November 2007, 23:54
Thanks for all your help
i didnt have SDK beta installed .. doh!

i'm going to try all this again thanks very much for you help
i luv RO :D

ablindman2
11th November 2007, 01:24
well i got the ro sdk and it compiled just fine but it still dont work i went over the steps 2 times

yea for me none of ur hacks work, iv tryed em all at least 2 times i cant get em to work............ with this one it compiles just fine and all that but it just dont work...

Krilliam
11th November 2007, 15:15
I still can't get it to work. I put both ROHack and ROBST in the system folder, run the game via Steam and press Numpad0 when I enter a server and spawn. No menu, no nothing.

noobieuk
11th November 2007, 17:04
Doesnt work :(

alien56
11th November 2007, 21:15
Well if you look at the code I didnt include all of the features in the source. Its just the Crosshair. The point of this is to give People that want to the ability to start to Work on their own hack for RO. A starting point if youve never done it before. Check out the AAO section for Support on more UScript functions. There are many snippets in there that are pretty much the same as RO. Also obviously the SDK will be the Best Resource.

Also make sure you didnt forget to add the Loader line is RedOrchestra.ini. I tested this before I Posted it and it Worked on the First try. Also make sure that you added the EditPackages line. Next make sure that your Bot file is in the System Folder. If it still dosent work then Redownload the attachment and try to Compile it without changing anything and Then Test it and see if it works. If it works then you did something wrong with changing of the class names and so forth.

noobieuk
11th November 2007, 22:20
ok thanks i'm gunnu try this again