Slothman/Slothbot

From Multi Theft Auto: Wiki
Revision as of 04:01, 4 April 2010 by Slothman (talk | contribs)
Jump to navigation Jump to search

Slothbot

This is a resource designed to allow scripts or gamemodes to insert a ped into the game that roughly simulates combat with a player.

FEATURES:

Teamplay: The bot is capable of identifying friend from foe

Map Navigation: When the bot is placed in a map that has suitable pathways marked out (see below on how to do that) the bot will navigate the map, seeking out enemies. Without pathways, a bot can still think for itself, but wont move around as profficiently.

Cooperation: Bots can automatically team up with teammates (either player or bot) by meeting up with them and sticking together

Advanced movement: If theres obstacles blocking a bot's path, the bot will attempt to get around or over it instead of just walking into a wall for eternity

Multiple modes of playing:

  • "hunting" - travel pathways untill finding an enemy or teammate
  • "waiting" - stand still untill an enemy of teammate comes into view
  • "guarding" - the bot will attack any enemy that comes within sight, but not move from its spawn position
  • "following" - the bot will follow a player or bot while attacking enemies
  • "chasing" - the bot will attack an anemy bot or player

Gamemode/Script integration: This script provides several functions and events to allow other resources to see and control what the bot's are doing, and even take control of certain behaviour.


SERVER EVENTS

onBotFindEnemy

This triggers when a bot locates an enemy, This event can be cancelled.

Parameters

element enemy
  • enemy: The Player or Ped the bot has spotted

Source

The source of this event is the Bot that has found an enemy


onBotWasted

This triggers when a bot is killed.

Parameters

element attacker, float weapon, float bodypart
  • attacker: The Element that killed the bot
  • weapon: The weapon id used to kill the bot
  • bodypart: The bodypart id that was hit to kill the bot

Source

The source of this event is the Bot that died


onBotSpawned

This triggers when a bot is spawned.

Source

The source of this event is the Bot that spawned


onBotFollow

This triggers when a bot starts following a teammate

Parameters

element leader
  • leader: The Player or Ped the bot has started following

Source

The source of this event is the Bot that starts following a teammate


SERVER FUNCTIONS

spawnBot

This function spawns a bot ingame

Syntax

bool spawnBot ( element theBot, float x, float y, float z, [ int rotation = 0, int skinID = 0, int interior = 0, int dimension = 0, team theTeam = nil, int weapon = nil, string theMode = "hunting", string theModesubject = nil ] )

Required Arguments

  • x: The x co-ordinate to spawn the bot at
  • y: The y co-ordinate to spawn the bot at
  • z: The z co-ordinate to spawn the bot at

Optional Arguments

  • rotation: rotation of the bot on spawn
  • skinID: bots skin on spawn
  • interior: interior the bot will spawn into
  • dimension: The ID of the dimension that the bot should be in
  • theTeam: the team the bot will join
  • theMode: the action the bot will be performing when spawned (see "modes of playing" above)
  • theModeSubject: if theMode is "chasing" or "hunting" this arg is needed to tell the bot what opponent to chase or teammate to follow


setBotHunt

This function sets the bot operating mode to "hunting"

Syntax

bool setBotHunt ( element theBot )

Required Arguments

  • theBot: The bot you want to hunt




setBotHunt (theped)- makes the bot travel pathways untill finding an enemy or teammate

setBotWait (theped)- makes the bot stand still untill an enemy of teammate comes into view

setBotChase(theped, target)- makes the bot attack an anemy bot or player (target)

setBotFollow(theped, leader)- makes the bot follow a teammate bot or player (leader

setBotGuard(theped, x, y, z)- makes the bot move to the xyz coords and stay there while attacking any enemies

setBotTeam (theped, team) - sets the bot's team (handy if you want to change their loyalties after spawning)

getBotAttackEnabled(theped) - returns true if the bot is allowed to shoot, false otherwise.

setBotAttackEnabled(theped, bool) - controls if a bot is allowed to shoot or should hold its fire

getBotMode(theped) - returns the mode the bot is in (chasing, waiting, guarding, hunting, following) if the bot is chasing or following, it will return the mode and the modesubject

ispedbot(theped) - returns true if the ped is a bot, false otherwise.