RCBot (HL1)

From Bots-United Wiki

Jump to: navigation, search

RCBot (for HL 1) source @ http://filebase.bots-united.com

RCBot Manual - please contribute!


Source Overview:


(TO COMPLETE)


Contents

RCBot Source

Looking and Moving

I thought about how a human would control a player in a multi-player game. What they typically use is the mouse to look and the keys to move. What I decided to do was separate these two tasks and make them run simultaneously, after all we can move around and look at different places at the same time.

workViewAngles() : works out the viewing angles to face the look target

workMoveDirection() : works out the moving directions to reach move-to target

Look Tasks

Look tasks let us know what a bot wants to look at, do they want to look around, look at a player or look at something he finds interesting? Each task simply has it's own target and we face this target slowly as if we were using a mouse.

m_CurrentLookTask is the current look task

Moving

Since moving and looking are separate, we can look in a different direction than were we want to move, we can move sideways.. which means we are looking ahead and stepping to the left or right. More interesting, we can move in one direction and look anywhere. Moving has it's own target as well, meaning the bot has to move towards it.

SetMoveToVector() : sets the move-to target

Tasks & Schedules

The idea from Lars Liden (Valve), used in Half-life 1 NPCs was used in RCBot. The Tasks and schedules however are currently tightly coupled, but there are ways to couple schedules and tasks, they just aren't very practical as real schedules however they work.

Tasks

Each task is simply an easy task, something that *should* be done with one press of a button or a continuous press of a button for a small length of time. That means that to carry out any form of real task, tasks must be grouped to we can, for example, use a button to open a door and walk through it.

Tasks are given as an enumerated type e.g. the number "3" is given to BOT_TASK_RELOAD and these are checked in a simple switch statement that checks the current task number with these tasks to perform them.

Schedules

The grouping of tasks are called Schedules, we must group tasks in some way if we use more than one task to do something, why? Imagine we try to do these tasks and during one of the tasks we can't complete it, so we fail it by removing the task... what about the other tasks we still have left to complete our goal? We need Schedules to keep track of all tasks used to complete a goal. If we fail one of the tasks, we must fail the whole schedule.

Reputations

All bots have a reputation with other players and bots that join the server they play on. This is so that it adds a little bit more interest into a bot game, where bots can like other players or bots... or detest them. You can improve this to let bots shoot friendly opponents less than hated opponents, and use less weaponry on them. This is something I discovered online, we sometimes join up without talking to each other about joining up in deathmatch games. Maybe this is because we kill their hated opponents a lot and don't touch their friends much. This is the way it is done in RCBot.

How They are Stored

Reputations are in their own CBotReputation class. They store a player's id and their reputation with that player's id. The player id is just a number, so that number is linked to a file where all player names are stored. So bots only know their friends and enemies by their names, we don't usually remember everyone's steam addresses. The player id is simply the line of the file where the play name is, each line has a unique player name that joined the server.

When a bot joins, they update their current stored reputations for every player on the current server. When a new player joins the server, every bot will check the reputation information for that player and load it into their current reputation storage , when the new player leaves, the reputation is saved to the reputation file and removed.

The reputation file is a sequential file of several CBotReputations.

--Cheeseh 20:21, 17 Apr 2005 (CEST)