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