Difference between revisions of "Programming robots"

From Bitfighter
Line 2: Line 2:
  
 
Robot coding is still fluid, and everything is subject to change, but here is a list of commands implemented in the current alpha release (see forums for the URL):
 
Robot coding is still fluid, and everything is subject to change, but here is a list of commands implemented in the current alpha release (see forums for the URL):
 +
 +
 +
== Navigation, configuration, and combat ==
  
 
<b>getZoneCenterXY( x, y )</b> - Return point representing center of zone containing point x,y<br>
 
<b>getZoneCenterXY( x, y )</b> - Return point representing center of zone containing point x,y<br>
Line 35: Line 38:
 
<br>
 
<br>
 
<b>logprint(msg)</b> - Print msg to game logfile<br>
 
<b>logprint(msg)</b> - Print msg to game logfile<br>
 +
 +
 +
== Game Information ==
 +
 +
You can get information about the current game with the GameInformation object. 
 
<br>
 
<br>
<u>Game info</u><br>
+
Example:
 +
<pre>
 +
game = GameInfo()         -- Create the GameInfo object
 +
levelname = game:getLevelName()
 +
</pre>
 +
 
 +
Methods available:<br>
 
<br>
 
<br>
 
<b>getGameType()</b><br>
 
<b>getGameType()</b><br>

Revision as of 08:22, 25 April 2009

Starting with release 011, server admins will be able to program their own robots in addition to designing their own levels. Robots will be coded in Lua, and will will have a number of special functions available to them.

Robot coding is still fluid, and everything is subject to change, but here is a list of commands implemented in the current alpha release (see forums for the URL):


Navigation, configuration, and combat

getZoneCenterXY( x, y ) - Return point representing center of zone containing point x,y
getGatewayFromZoneToZone( a, b ) - Return point representing fastest way from zone a to zone b. If zones a & b are not neighbors, returns nil
getZoneCount() - Return number of zones
getCurrentZone() - Return current zone that robot is in

getAngle() - Return angle robot is currently facing
getPosXY() - Return x, y of robot

setAngle(ang) - Set robot's angle
setAngleXY(x, y) - Point robot at point x,y
getAngleXY(x, y) - Return angle to point x, y
hasLosXY(x, y) - Return whether or not robot can see point x, y

hasFlag() - Return whether or not robot currently has the flag


Navigation

findObjects(ObjectType)
getWaypoint(x, y)


Ship control
setThrustAng(angle)
setThrustXY(x, y)

fire()
setWeapon(weapon number)
globalMsg(msg) - Send a message to all players
teamMsg(msg) - Send a message to players on the same team

logprint(msg) - Print msg to game logfile


Game Information

You can get information about the current game with the GameInformation object.
Example:

game = GameInfo()	        -- Create the GameInfo object 
levelname = game:getLevelName()

Methods available:

getGameType()
getFlagCount()
getWinningScore()
getGameTimeTotal()
getGameTimeRemaining()
getLeadingScore()
getLeadingTeam()

getLevelName()
getGridSize()
getIsTeamGame()

getEventScore(event)


Some constants available in game:

Game Objects
ShipType
BarrierType
MoveableType
BulletType
ItemType
ResourceItemType
EngineeredType
ForceFieldType
LoadoutZoneType
MineType
TestItemType
FlagType
TurretTargetType
SlipZoneType
HeatSeekerType
SpyBugType
NexusType
BotNavMeshZoneType
RobotType
TeleportType
GoalZoneType
AsteroidType

Game Types
BitmatchGame
CTFGame
HTFGame
NexusGame
RabbitGame
RetrieveGame
SoccerGame
ZoneControlGame

Scoring Events
KillEnemy
KillSelf
KillTeammate
KillEnemyTurret
KillOwnTurret
CaptureFlag
CaptureZone
UncaptureZone
HoldFlagInZone
RemoveFlagFromEnemyZone
RabbitHoldsFlag
RabbitKilled
RabbitKills
ReturnFlagsToNexus
ReturnFlagToZone
LostFlag
ReturnTeamFlag
ScoreGoalEnemyTeam
ScoreGoalHostileTeam
ScoreGoalOwnTeam

Modules
ModuleShield
ModuleBoost
ModuleSensor
ModuleRepair
ModuleEngineer
ModuleCloak

Weapons
WeaponPhaser
WeaponBounce
WeaponTriple
WeaponBurst
WeaponMine
WeaponSpyBug