XPilot-AI API Documentation
In Xpilot-AI, 0 degrees is to the right and 90 degrees is up.
Bool functions will return 0 for False and 1 for True.
The recommended way of dealing with angles is to use radians, due to python's built in trigonometric functions using it. Xpilot degrees can be used sometimes, as that is the angular measurement that the game uses. Use of Degrees is deprecated, if you want to produce human readable output use the built in functions in the language to convert angles.
Xpilot uses three different coordinate systems. Pixels, which is the most common, radar, which is very imprecise (for big levels) and only used by the Radar functions and blocks, which is what is specified in the map file when constructing the level. Block functions can be found in Map feature functions.
All coordinate systems have origo (x=0, y=0) in the bottom left, with X growing towards the right, and Y growing upwards.
The indexes used by different groups of functions are never the same, and are randomized between ticks. The only way to reliably identify ships is with their server id, which are constant and the same between the functions selfId(), playerId(int i) and shipId(int i).
The API is under development and you might encounter bugs, if you do contact your assistant or send a mail to john.litborn@liu.se with steps to reproduce.
Code from previous years are also likely to break, the main changes are: Separating enemy functions into ship and player. Velocities of objects are no longer approximated by the api and sent directly through the server, giving increased precision. Due to that reason all Age and Alert functions have been removed.
Functions
API control functions
- headlessMode()
- Execute this before start to run windowless.
- start(func, ["listof","args"])
- Initializes the AI interface and starts Xpilot
- switchLoop(function)
- Changes the main loop
- quitAI()
- Quits Xpilot.
- pauseAI()
- Pauses the game for the ship, does not affect other ships.
- version()
- Returns the version and date of release of the AI.
Server functions
- int timeLeftSec()
- Returns the time left of the match.
Player info
These functions handle all players on the server, including paused players, as well as things such as tanks.
- int playerCountServer()
- Returns the number of players on the server.
- int pausedCountServer()
- Returns the number of paused ships on the server.
- int tankCountServer()
- Returns the number of fueltanks on the server.
- int playerId(int i)
- Returns the specified player's server id.
- int playerLives(int i)
- Returns the specified player's remaining lives.
- string playerName(int i)
- Returns the specified player's name.
- string playerScore(int i)
- Returns the specified player's score.
- int playerTeam(int i)
- Returns the specified player's team.
Chat options
- setMaxMsgs(int i)
- Sets maximum amount of messages to be displayed in the top left. Affects both talk messages (on the top) and game message (on the bottom) 1<=i<=15
- int getMaxMsgs()
- Returns the maximum amount of messages to be displayed.
- talk(char* talk_str)
- Sends a message. To send to a specific bot do "name: MSG". Note that this means
is it not possible to have a ":" in messages going to all bots.
- scanTalkMsg(int i)
- Returns the specified talk message. ID 0 is the most recent occurring message.
- removeTalkMsg(int i)
- Removes the specified talk message. Useful for clearing up the screen if you have requested many options. Also use this in a bot to clear messages that you have read. The best way is to read all available messages each tick and clear all the messages. Note that this does not remove the message, merely the content. So accessing the same index again at the same tick will always return an empty message, even if there are more messages at higher id's.
- scanGameMsg(int i)
- Returns the specified game message. ID 0 is the most recent occurring message.
- toggleShowMessage()
- Toggles messages on the bottom on the screen.
- toggleUserName()
- Toggles the displayed information on the HUD on the left of the screen between showing real names and showing the scoreboard.
Ship functions
Ship properties
- int selfX()
- Returns the ship's X position on the map.
- int selfY()
- Returns the ship's Y position on the map.
- double selfVelX()
- Returns the ship's X velocity.
- double selfVelY()
- Returns the ship's Y velocity.
- double selfMass()
- Returns the ship's mass. This is increased as you pick up fuel and items.
- double selfHeadingRad()
- Returns the heading of the ship in radians. This is the direction the ship is pointing in.
- double selfSpeed()
- Returns the ship's speed. Calculated from selfVelX and selfVelY.
- double selfTrackingRad()
- Returns the ship's tracking in radians. This is the direction the ship is travelling in. Returns the ships
heading if not moving. Calculated from selfVelX and selfVelY.
Ship info
- int selfId()
- Returns the server id of the ship.
- bool selfAlive()
- Returns whether the ship is alive.
- int selfLives()
- Returns how many lives are left for the ship.
- string selfName()
- Returns the ship's name.
- double selfScore()
- Returns the ship's score.
- int selfTeam()
- Returns the ship's team.
Movement functions
- thrust()
- Thrusts for one tick.
- double getPower()
- Returns the ship's power level.
- setPower(double s)
- Sets the amount of power the ship will use for thrusting. Valid values are in the range 5 to 55.
Turn functions
- turnRad(double angle)
- Turns the ship the specified number of radians.
- turnToRad(double angle)
- Turns the ship to the specified angle.
- double getMaxTurnRad()
- Returns the maximum allowed angle to turn, in radians.
- setMaxTurnRad(double angle)
- Sets the maximum angle, in radians, the ship is allowed to turn. If you try to turn a bigger angle with any of the (non-deprecated) turn functions it will turn the maximum allowed angle. Default is pi/4. The angle can be between 0 and pi.
Shoot functions
- fireShot()
- Fires a shot from the ship's main cannon.
- int selfReload()
- Returns the ship's reload time remaining. 0 means that the ship is able to fire again.
Misc. functions
- selfDestruct()
- Triggers the ship's self destruct mechanism
Sensors
Radar Functions
The radar index is a separate index from those used by other types of functions, and the id of objects index change at random between ticks.
Several server options control what shows up on the radar.
The radar uses a separate coordinate system, which is much less precise than pixels. You should only use these when handling objects that are far away and not on your screen. Converting from an x radar coordinates to screen coordinate is done by dividing with radarWidth() and multiplying with mapWidthPixels(). Converting an y coordinate is done similarly with height functions.
- int selfRadarX()
- Returns your own radar coordinate.
- int selfRadarY()
- Returns your own radar coordinate.
- int radarCount()
- Returns the number of objects on the radar.
- int radarX(int rID)
- Returns the specified object's X radar coordinate.
- int radarY(int rID)
- Returns the specified object's Y radar coordinate.
- double radarVelX(int rID)
- Returns the specified object's X velocity on the radar.
- double radarVelY(int rID)
- Returns the specified object's Y velocity on the radar.
- int radarType(int rID)
- Returns the type of the specified object.
0 missile
2 ball
3 ship
4 mine
5 nuke
130 small asteroid
131 medium asteroid
132 big asteroid
133 huge asteroid
- double radarDist(int rID)
- Returns the specified object's distance from self on the radar.
- int radarWidth()
- Returns the width of the radar.
- int radarHeight()
- Returns the height of the radar.
Ship properties
These functions handle all the ships on the screen, including yourself. This means that if you want to only use this function for enemy ships you need to subtract 1 from shipCountScreen(), and check that the server id of the ship is not the same as your own.
- int shipCountScreen()
- Returns the number of ships on the screen. Note that you're most likely one of them.
- int shipId(int i)
- returns the server id of the specified ship. Returns -1 if ship doesn't exist.
- int shipX(int i)
- Returns the specified ship's X coordinate on the map.
- int shipY(int i)
- Returns the specified ship's Y coordinate on the map.
- double shipVelX(int i)
- Returns the x velocity of the specified ship.
- double shipVelY(int i)
- Returns the y velocity of the specified ship.
- int shipShield(int i)
- Returns the specified enemy's shield status.
- double shipHeadingRad(int i)
- Returns the specified ship's heading in radians.
- double shipTrackingRad(int i)
- Returns the specified ship's tracking in radians. Returns the ship's
heading if not moving. Calculated from shipVelX and shipVelY.
- double shipDistance(int i)
- Returns the distance between yourself and the specified ship. Calculated from selfX, selfY, shipX and shipY.
- double shipSpeed(int i)
- Returns the speed of the specified ship. Calculated from shipVelX and shipVelY.
Lock functions
You can only change lock once per tick
- toggleCompass()
- Toggles the name of the locked player, distance (or lives) and the dot on the hud.
- int getLockId()
- Returns the server ID of the locked-on ship.
- double lockHeadingRad()
- Returns in radians the direction of the ship's lock-on of an enemy.
- int selfLockDist()
- Returns the distance of the enemy that the ship has locked-on to.
- lockNext()
- Locks onto the next ship in the ship buffer.
- lockPrev()
- Locks onto the prev ship in the ship buffer.
- lockClose()
- Locks onto the closest ship.
- lockNextClose()
- Locks-on to the next closest ship.
- loadLock(int i)
- Loads the locked-on ship at the specified index. 1<=i<=4.
- saveLock(int i)
- Saves the locked-on ship at the specified index. 1<=i<=4.
Shot Functions
- int shotCountScreen()
- Returns the number of shots on the screen.
- int shotX(int i)
- Returns the X coordinate of a shot.
- int shotY(int i)
- Returns the Y coordinate of a shot.
- double shotVelX(int i)
- Returns the X velocity of a shot.
- double shotVelY(int i)
- Returns the Y velocity of a shot.
- double shotDist(int i)
- Returns the distance of a shot from the ship. Calculated from selfX, selfY, shotX and shotY.
- double shotTrackingRad(int i)
- Returns the direction of the velocity of a shot. Calculated from shotVelX and shotVelY.
- double shotSpeed(int i)
- Returns the speed of a shot. Calculated from shotVelX and shotVelY.
Asteroid functions
The ID's of asteroids are not consistent between ticks.
- int asteroidCountScreen()
- Returns the number of asteroids on the screen.
- int asteroidX(int i)
- Returns the x coordinate of the specified asteroid.
- int asteroidY(int i)
- Returns the y coordinate of the specified asteroid.
- int asteroidVelX(int i)
- Returns the X velocity of the specified asteroid.
- int asteroidVelY(int i)
- Returns the Y velocity of the specified asteroid.
- int asteroidType(int i)
- Returns the type of the specified asteroid. The type only determines what model the game uses to paint the asteroid.
- int asteroidSize(int i)
- Returns the size of the specified asteroid.
- int asteroidRotation(int i)
- Returns the rotation of the specified asteroid.
- double asteroidDist(int i)
- Returns the distance to the specified asteroid. Calculated from selfX, selfY, asteroidX and asteroidY.
- double asteroidSpeed(int i)
- Returns the speed of the specififed asteroid. Calculated from asteroidVelX and asteroidVelY.
- double asteroidTrackingRad(int i)
- Returns the tracking, in radians, of the specified asteroid. Calculated from asteroidVelX and asteroidVelY.
Ball functions
- connector()
- Connects the ship to the ball in Capture the Flag Mode.
- dropBall()
- Drops the ball in Capture the Flag Mode.
- int ballCountScreen()
- Returns the number of balls on the screen.
- int ballX(int i)
- Returns the x position of the specified ball.
- int ballY(int i)
- Returns the y position of the specified ball.
- int connectorCountScreen()
- Returns the number of connectors on the screen. A connector is the wire going from a player to a ball.
- int connectorX0(int i)
- Returns the x0 position of the specified connector.
- int connectorX1(int i)
- Returns the x1 position of the specified connector.
- int connectorY0(int i)
- Returns the y0 position of the specified connector.
- int connectorY1(int i)
- Returns the y1 position of the specified connector.
- int connectorTractor(int i)
- Returns the tractor of the specified connector.
Map features
Map properties
- int blockSize()
- Returns the the width/height of a block, in pixels.
- int mapWidthBlocks()
- Returns the width of the map, in blocks.
- int mapHeightBlocks()
- Returns the height of the map, in blocks.
- int mapWidthPixels()
- Returns the height of the map, in pixels.
- int mapHeightPixels
- Returns the height of the map, in pixels.
- int mapData(int x, int y)
- Returns the type of block at the specified block coordinate. See mapdata for output.
- getOption(string option)
- Returns the value of the specified option. The API gets this information by requesting it with "/get" for most options. If you are gonna recieve many options using setMaxMsgs(15) or similar is recommended.
When this function is called with an option that haven't been fetched yet it will return the string "queued", which means the option is queued up. If you call the function again later* you will recieve the value of the option.
The function will return 0 or 1 for booleans, and int/string/double for the respective options.
The option Gravitypoint is unsupported due to a serverbug.
*Depends on the value of maxMsgs and how many options you have queued up. Most of the time it will be available in less than five ticks.
Wall functions
- double wallFeelerRad(double dist, double rad)
- Returns the distance to a wall in the specified angle. If no wall is found within the specified distance it returns -1.
- double wallBetween(double x1, double y1, double x2, double y2)
- Returns the distance from point 1 (x1, y1) to the wall, in the direction of point 2 (x2, y2). Returns -1 if there is no wall.
Note: These wall functions treats triangle blocks as squares and can therefore give false positives.
Base functions
- keyHome()
- Changes the ship's home base or respawn location.
- int baseCount()
- Returns the number of bases.
- int baseX(int i)
- Returns the x coordinate of the specified base.
- int baseY(int i)
- Returns the y coordinate of the specified base.
- int baseTeam(int i)
- Returns the team of the specified base.
- int baseId(int i)
- Returns the id of the specified base. Probably the player's server id.
Fuel station functions
Note: For 2014ht the API uses fuelstation instead!
- refuel()
- Refuels the ship. Needs to be continusly called to keep refueling.
- int fuelstationCount()
- Returns the number of fuel stations on the server.
- int fuelstationX(int i)
- Returns the x coordinate of the specified fuel station.
- int fuelstationY(int i)
- Returns the y coordinate of the specified fuel station.
- int fuelstationBlockX(int i)
- Returns the x block of the specified fuel station.
- int fuelstationBlockY(int i)
- Returns the y block of the specified fuel station.
- int fuelstationFuel(int i)
- Returns the amount of fuel in the specified fuel station.
- int fuelstationTeam(int i)
- Returns which team the fuel station is closest to.
Race/timing functions
- int nextCheckpoint()
- Returns the index of the next checkpoint, for timing mode.
- int checkpointX(int i)
- Returns the x coordinate of the specified checkpoint. Returns 0 if checkpoint doesn't exist.
- int checkpointY(int i)
- Returns the y coordinate of the specified checkpoint. Returns 0 if the checkpoint doesn't exist.
- int checkpointBlockX(int i)
- Returns the x block of the specified checkpoint. Returns 0 if checkpoint doesn't exist.
- int checkpointBlockY(int i)
- Returns the y block of the specified checkpoint. Returns 0 if the checkpoint doesn't exist.
Target functions
- repair()
- Repairs a target.
- int targetCountServer()
- Returns the number of targets (int) on the server.
- int targetX(int i)
- Returns the x coordinate of the specified target.
- int targetY(int i)
- Returns the y coordinate of the specified target.
- int targetAlive(int i)
- Returns whether the specified target is dead.
- int targetDamage(int i)
- Returns the damage on the specified target.
- int targetTeam(int i)
- Returns the closest team base to the specified target.
Wormhole functions
You can find out if wormholes are in, out or in/out with mapData.
- int wormholeCountScreen()
- Returns the number of wormholes on the screen. DOES NOT SEEM TO WORK! A workaround is to use mapData() instead.
- int wormholeX(int i)
- Returns the x coordinate of the specified wormhole.
- int wormholeY(int i)
- Returns the y coordinate of the specified wormhole.
Cannon functions
- int cannonCountServer()
- Returns the amount of cannons on the server.
- int cannonX(int i)
- Returns the x coordinate of the specified cannon.
- int cannonY(int i)
- Returns the y coordinate of the specified cannon.
- int cannonBlockX(int i)
- Returns the x block of the specified cannon.
- int cannonBlockY(int i)
- Returns the y block of the specified cannon.
- int cannonAlive(int i)
- Returns whether the specified cannon is dead.
- int cannonTeam(int i)
- Returns which base is closest to the specified cannon.
Angle handling
Xpilot degree functions.
Xpilot degrees is the angular measurement that xpilot uses, ranging from 0 to 127. It is only possible to turn (and turn to) whole xpilot degrees. For example you cannot turn 5 degrees (1.422 xdeg), so the API will turn 2.8125 (1 xdeg) degrees instead. This is not noticeable most of the time and the API will do all the necessary rounding behind the scenes.
- int selfHeadingXdeg()
- Returns the heading of the ship in xpilot-degrees.
- turnXdeg(double xdeg)
- Turns the ship in the specified number of xdegrees.
- turnToXdeg(double xdeg)
- Turns the ship towards the specified heading, in xdegrees.
- setMaxTurnXdeg(double i)
- Sets the maximum angle, in xpilot degrees, the ship is allowed to turn. If you try to turn a bigger angle with any of the turn functions it will turn the maximum allowed angle. 0<=i<=64
- double getMaxTurnXdeg()
- Returns the maximum allowed angle to turn, in xpilot degrees.
- int shipHeadingXdeg(int i)
- Returns the specified ship's heading in xpilot degrees.
- int lockHeadingXdeg()
- Returns in degrees the direction of the ship's lock-on of an enemy.
- double missileHeadingXdeg(int i)
- Returns the direction of the specified missile in xpilot degrees.
- int laserHeadingXdeg(int i)
- Returns the direction of the specified laser.
Angle conversion functions.
- double xdegToDeg(double xdeg)
- Converts xpilot degrees to degrees.
- double xdegToRad(double xdeg)
- Converts xpilot degrees to radians.
- double degToXdeg(double deg)
- Convers degrees to xpilot degrees.
- double radToXdeg(double rad)
- Converts radians to xpilot degrees.
Item Functions
- toggleShowItems()
- Toggles whether items are displayed on the left side of the ship on the HUD. Items will still show right after you picked them up.
- selectItem()
- Selects the ship's item to be dropped.
- loseItem()
- Drops the ship's selected item.
- Returns the number of items on the screen.
- int selfItem(int i)
- 0<=i<=20, return amount of the specified item. See table for which input yields what item.
| Type |
Item |
| 0 |
energypack/fuel |
| 1 |
wideangle |
| 2 |
rearshot |
| 3 |
afterburner |
| 4 |
cloak |
| 5 |
sensor |
| 6 |
transporter |
| 7 |
tank |
| 8 |
mine |
| 9 |
missile |
| 10 |
ecm |
| 11 |
laser |
| 12 |
emergencythrust |
| 13 |
tractorbeam |
| 14 |
autopilot |
| 15 |
emergencyshield |
| 16 |
itemdeflector |
| 17 |
hyperjump |
| 18 |
phasing |
| 19 |
mirror |
| 20 |
armor |
Powerup tracking functions
- int itemCountScreen()
- Returns the number of items on the screen.
- int itemX(int i)
- Returns the X coordinate of the specified item.
- int itemY(int i)
- Returns the Y coordinate of the specified item.
- int itemVelX(int i)
- Returns the X velocity of the specified asteroid.
- int itemVelY(int i)
- Returns the Y velocity of the specified asteroid.
- int itemType(int i)
- See table for output. If the item is 'random' it's type will cycle through all available types.
- bool itemRandom(int i)
- Returns whether the item is 'random'
- int itemDist(int i>
- Returns the distance to the specified item. Calculated from selfX, selfY, itemX and itemY.
- double itemSpeed(int i)
- Returns the speed of the specififed asteroid. Calculated from itemVelX and itemVelY.
- double itemTrackingRad(int i)
- Returns the tracking, in radians, of the specified asteroid. Calculated from itemVelX and itemVelY.
Fuel and Tank functions
- int selfFuel()
- Returns the total amount of fuel in all tanks.
- int selfFuelMax()
- Returns the max amount of fuel you can take. This is increased if you pick up more tanks.
- int selfFuelCurrent()
- Returns the currently selected tank.
- tankDetach()
- Detaches a fuel tank from the ship.
- nextTank()
- Switches to the ship's next fuel tank.
- prevTank()
- Switches to the ship's previous fuel tank.
Missile functions
- fireMissile()
- Fires a smart missile from the ship. You must lock on an enemy before firing.
- fireTorpedo()
- Fires a torpedo from the ship. The torpedo will go straight and no locking is neccessary. It will explode when near a target.
- fireHeat()
- Fires a heat seeking missile from the ship. The missile will lock onto the closest thrusting player which might be you.
- int missileCountScreen()
- Returns the number of missiles on the screen.
- int missileX(int i)
- Returns the x coordinate of the specified missile.
- int missileY(int i)
- Returns the y coordinate of the specified missile.
- int missileHeadingRad(int i)
- Returns the direction of the specified missile in radians.
- int missileLen(int i)
- Returns the length of the specified missile.
Laser Functions
- fireLaser()
- Fires a laser from the ship.
- int laserCountScreen()
- Returns the number of lasers on the screen.
- int laserX(int i)
- Returns the x coordinate of the specified laser.
- int laserY(int i)
- Returns the y coordinate of the specified laser.
- double laserHeadingRad(int i)
- Returns the direction of the specified laser.
- int laserLen(int i)
- Returns the length of the specified laser.
Mine functions
- dropMine()
- Drops a stationary mine from the ship.
- detachMine()
- Releases a mine from the ship with the same velocity as the ship.
- detonateMines()
- Detonates mines previously released from the ship.
- int mineCountScreen()
- Returns the number of mines on the screen.
- int mineX(int i)
- Returns the x coordinate of the specified mine.
- int mineY(int i)
- Returns the y coordinate of the specified mine.
- bool mineFriendly(int i)
- Returns whether a mine is friendly or not.
- int mineId(int i)
- If close enough, returns the id of the player dropping the mine.
Shield functions
- int selfShield()
- Returns the ship's shield status.
- shield()
- Turn on the ship's Shield. Note that you cannot shield and shoot at the same time.
Phasing functions
- phasing()
- Uses the phasing item to allow the ship to pass through walls.
- int phasingTime()
- Returns time left on the current phasing item. Only returns sensible number if it has been activated.
ECM functions
- ecm()
- Launches an ECM to temporarily blind opponents.
- int ecmCountScreen()
- Returns the number of ECM's on the screen.
- int ecmX(int i)
- Returns the x coordinate of the specified ECM.
- int ecmY(int i)
- Returns the y coordinate of the specified ECM.
Other item functions
- cloak()
- Cloaks the ship from sight.
- tractorBeam()
- Uses the ship's tractor beam to pull in enemy ships.
- pressorBeam()
- Uses the ship's pressor beam to push away enemy ships.
- emergencyShield()
- Uses the emergency shield item to protect your ship from damage for a period of time.
- hyperjump()
- Uses the hyper jump item to warp the ship to a random location on the map.
- toggleAutopilot()
- Uses the autopilot item to stop the ship's movement.
- emergencyThrust()
- Uses the emergency thrust item to increase the ship's movement speed for a period of time.
- deflector()
- Uses the deflector item to push everything away from the ship.
- transporter()
- Uses the transporter item to steal an opponent's item or fuel supply
Modifier functions
- toggleCluster()
- Toggles the option to have the ship fire Cluster weapons instead of regular weapons.
- toggleMini()
- Toggles the option to have the ship fire Mini weapons instead of regular weapons.
- toggleNuclear()
- Toggles the option to have the ship fire Nuclear weapons instead of regular weapons, takes up five mines or seven missiles per shot.
- toggleVelocity()
- Modifies the explosion velocity of mines and missiles.
- togglePower()
- Toggles the power levels of the ship's weapons.
- toggleSpread()
- Toggles the option to have the ship fire Spread weapons instead of regular weapons.
- toggleLaser()
- Toggles between the LS stun laser and the LB blinding laser.
- toggleImplosion()
- Toggle the option to have mines and missiles implode instead of exlode, the explosion will draw in players instead of blowing them away.
- loadModifiers(int i)
- Loads Modifiers at the specified index. 1<=i<=4
- saveModifiers(int i)
- saves Modifiers at the specified index. 1<=i<=4
FAQ/quirks/tips
If your ship starts oscillating (rapidly switching between two or more angles) when you try to turn to a specified direction,
it may be due to latency. Turning is done serverside, so the only thing the client does is send how much the ship should turn. If the server
takes two (or more) ticks to update your heading the client will have sent the instruction to turn the difference to that angle twice, making it overshoot.
The easy solution is to only turn every second (or more) ticks. A more complicated version would be that your bot keeps track on what turn instructions it sends.
Use timeLeftSec together with enabling the serveroption "gameDuration" to calculate average items/deaths/kills per second. This makes it easier to evaluate the performance of your bot, and compete with your friends!
Deprecated functions
You can still use these but it's recommended not to as they may be removed in future releases. If you see a reason these should not be removed send a mail to johli603@student.liu.se with your arguments and intended use.
Degree functions
- double selfTrackingDeg()
- Returns the ship's tracking in degrees.
- double selfHeadingDeg()
- Returns the heading of the ship in degrees. The heading is the direction the ship is pointing to.
- turnDeg(double deg)
- Turns the ship in the specified number of degrees.
- turnToDeg(double deg)
- Turns the ship towards the specified heading in degrees.
- setMaxTurnDeg(double i)
- Sets the maximum angle, in degrees, the ship is allowed to turn. If you try to turn a bigger angle with any of the turn functions it will turn the maximum allowed angle. 0<=i<=180
- double getMaxTurnDeg()
- Returns the maximum allowed angle to turn, in degrees.
- double lockHeadingDeg()
- Returns in degrees the direction of the ship's lock-on of an enemy.
- double shipHeadingDeg(int i)
- Returns the specified ship's heading in degrees.
- double shipTrackingDeg(int i)
- Returns the specified ship's tracking in degrees. Returns the ship's
heading if not moving.
- double shotTrackingDeg(int i)
- Returns the direction of the velocity of a shot.
- double wallFeelerDeg(double dist, double deg)
- Returns if there is a wall or not at the specified angle within the specified distance of the ship. Returns -1 if no wall.
- double missileHeadingDeg(int i)
- Returns the direction of the specified missile in degrees.
- double laserHeadingDeg(int i)
- Returns the direction of the specified laser.
- double asteroidTrackingDeg(int i)
- Returns the tracking, in degrees, of the specified asteroid.
It's better to use the language's built-in angle conversion functions
- double degToRad(double deg)
- Converts degrees to radians.
- double radToDeg(double rad)
- Converts radians to degrees.
Due to all turn functions requiring turnResistance 0 and turnSpeed 64 to work as expected, functions dealing with those are deprecated.
- double getTurnSpeed()
- Returns the ship's turn speed.
- setTurnSpeed(double s)
- Sets the speed the ship will turn by. The minimum power level is 4.0 and the maximum power level is 64.0.
- double getTurnResistance()
- Returns the ship's turn speed.
- setTurnResistance(double s)
- Makes turning smoother for human players, should be 0 for bots. 0.0<=s<=1.0
Use of turnLeft and turnRight is deprecated simply because it's much easier to use turn() and turnTo() functions. Also because they depend on turnSpeed, which both are deprecated. They will also bypass maxTurn.
- turnLeft()
- Turns the ship left. Will turn 'turnSpeed' number of xpilot degrees.
- turnRight()
- Turns the ship right. Will turn 'turnSpeed' number of xpilot degrees.
Deprecated simply because it currently always return 0 (or -1).
- int closestShipIdx()
- Returns the closest ship's index in the internal buffer.
Deprecated for consistency with other objects. radarDist() is offered to easily implement this.
- int closestRadarId()
- Returns the closest object's radarId, not including you.
Using talk() is the recommended (and only sensible) way of chatting.
- talkKey()
- Opens up the chat window.
Worthless as a bot can easily set a specific turnrate and thrustpower.
- swapSettings()
- Swaps between the ship's settings for turn rate and thrusting power.
These values may be useful for a human but kind of worthless for a bot. If it turns out this is useful information the index should be transformed so it's sensible. Atm index 0 can return nothing while index 19 can contain a message, forcing you to loop through all index until you find one that's non-empty.
- string hud(int i)
- Returns the name on the bottom of the HUD, index working in a weird way. Is often who killed you or if you just killed somebody. Includes the score.
- string hudScore(int i)
- Returns the score on the bottom of the HUD. This is (always?) the score change the people getting killed/killin got.
- int hudTimeLeft(int i)
- Returns for how much longer the specified message will be shown.
Savemodifiers and savelock implemented instead.
- reprogram()
- Reprograms a modifier or lock bank.