Slothman/Slothbot: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
 
(25 intermediate revisions by 10 users not shown)
Line 1: Line 1:
='''Slothbot'''=
<pageclass class="resource" subcaption="Resource"></pageclass>
This is a resource designed to allow scripts or gamemodes to insert a ped into the game that roughly simulates combat with a real player. gamemodes can implement the bots as opponents to actual players or as teammates.


==FEATURES:==
This is a resource designed to allow scripts or gamemodes to insert a ped into the game that roughly simulates combat with a real player. Gamemodes can implement the bots as opponents to actual players or as teammates.<br>
Download can be found at [https://community.multitheftauto.com/index.php?p=resources&s=details&id=672 MTA Community - Slothbot]
 
=Features=
'''Teamplay:'''
'''Teamplay:'''
The bot is capable of identifying friend from foe
The bot is capable of identifying friend from foe


'''Map Navigation:'''
'''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.
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 proficiently.


'''Aggressiveness:'''
'''Aggressiveness:'''
Bots will attack any ped, player or bot thats not on it's team.
Bots will attack any ped, player or bot that's not on it's team.


'''Cooperation:'''
'''Cooperation:'''
Line 16: Line 18:


'''Advanced movement:'''
'''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
If there's obstacles blocking a bots path, the bot will attempt to get around or over it instead of just walking into a wall for eternity


'''Multiple modes of playing:'''
'''Multiple modes of playing:'''
*"hunting" - travel pathways untill finding an enemy or teammate
*"hunting" - travel pathways until finding an enemy or teammate
*"waiting" - stand still untill an enemy of teammate comes into view
*"waiting" - stand still until 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
*"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
*"following" - the bot will follow a player or bot while attacking enemies
*"chasing" - the bot will attack an anemy bot or player
*"chasing" - the bot will attack an enemy bot or player


'''Gamemode/Script integration:'''
'''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.
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 behavior.


'''EDF for map path creation:'''
'''EDF for map path creation:'''
Integrated into the map editor, map designers can easily place paths for bots to follow along in their maps. this greatly increased the bots ability to simulate true playing.
Integrated into the map editor, map designers can easily place paths for bots to follow along in their maps. this greatly increased the bots ability to simulate true playing.


==SERVER EVENTS==
=Server Events=


===onBotFindEnemy===
==onBotFindEnemy==
This triggers when a bot locates an enemy, This event can be cancelled to prevent the bot from chasing players
This triggers when a bot locates an enemy, This event can be cancelled to prevent the bot from chasing players
====Parameters====
 
<big>'''Parameters'''</big>
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
element enemy
element enemy
</syntaxhighlight>
</syntaxhighlight>
*'''enemy''': The Player or Ped the bot has spotted
*'''enemy''': The Player or Ped the bot has spotted
====Source====
<big>'''Source'''</big>
 
The [[event system#Event source|source]] of this event is the Bot that has found an enemy
The [[event system#Event source|source]] of this event is the Bot that has found an enemy


==onBotWasted==
This triggers when a bot is killed.


 
<big>'''Parameters'''</big>
===onBotWasted===
This triggers when a bot is killed.
====Parameters====
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
element attacker, float weapon, float bodypart
element attacker, float weapon, float bodypart
Line 54: Line 57:
*'''weapon''': The weapon id used to kill the bot
*'''weapon''': The weapon id used to kill the bot
*'''bodypart''': The bodypart id that was hit to kill the bot
*'''bodypart''': The bodypart id that was hit to kill the bot
====Source====
<big>'''Source'''</big>
 
The [[event system#Event source|source]] of this event is the Bot that died
The [[event system#Event source|source]] of this event is the Bot that died


==onBotSpawned==
This triggers when a bot is spawned.


 
<big>'''Source'''</big>
===onBotSpawned===
This triggers when a bot is spawned.
====Source====
The [[event system#Event source|source]] of this event is the Bot that spawned
The [[event system#Event source|source]] of this event is the Bot that spawned


==onBotFollow==
This triggers when a bot starts following a teammate


 
<big>'''Parameters'''</big>
===onBotFollow===
This triggers when a bot starts following a teammate
====Parameters====
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
element leader
element leader
</syntaxhighlight>
</syntaxhighlight>
*'''leader''': The Player or Ped the bot has started following
*'''leader''': The Player or Ped the bot has started following
====Source====
<big>'''Source'''</big>
 
The [[event system#Event source|source]] of this event is the Bot that starts following a teammate
The [[event system#Event source|source]] of this event is the Bot that starts following a teammate


=Server Functions=
All of these functions will have to be used through the [[call]] function, otherwise they won't work


==SERVER FUNCTIONS==
==spawnBot==
All of these funtions will have to be used through the [[call]] function, otherwise they won't work
This function spawns a bot ingame, will return the bot element, or false if there was a problem.


===spawnBot===
<big>'''Syntax'''</big>
This function spawns a bot ingame
====Syntax====
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
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 ] )
element spawnBot ( float x, float y, float z, int rotation = 0, [ int skinID = 0, int interior = 0, int dimension = 0, team theTeam = nil, int weapon = 0, string theMode = "hunting", element theModesubject = nil ] )
</syntaxhighlight>
</syntaxhighlight>
====Required Arguments====
 
<big>'''Required Arguments'''</big>
*'''x:''' The x co-ordinate to spawn the bot at
*'''x:''' The x co-ordinate to spawn the bot at
*'''y:''' The y 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
*'''z:''' The z co-ordinate to spawn the bot at
====Optional Arguments====
*'''rotation:''' Rotation of the bot on spawn
*'''rotation:''' rotation of the bot on spawn
 
*'''skinID:''' bots skin on spawn
<big>'''Optional Arguments'''</big>
*'''interior:''' interior the bot will spawn into
*'''skinID:''' Bots skin on spawn
*'''interior:''' Interior the bot will spawn into
*'''dimension:''' The ID of the [[dimension]] that the bot should be in
*'''dimension:''' The ID of the [[dimension]] that the bot should be in
*'''theTeam:''' the team the bot will join
*'''theTeam:''' The team the bot will join. Set ''false'' to the bot not join a team.
*'''theMode:''' the action the bot will be performing when spawned (see "modes of playing" above)
*'''weapon:''' The weapon the ped will carry
*'''theModeSubject:''' if theMode is "chasing" or "hunting" this arg is needed to tell the bot what opponent to chase or teammate to follow
*'''theMode:''' The action the bot will be performing when spawned (see "modes of playing" above)
 
*'''theModeSubject:''' If theMode is "chasing" or "following" this arg is needed to tell the bot what opponent to chase or teammate to follow


==setBotHunt==
makes the bot travel pathways until finding an enemy or teammate


===setBotHunt===
<big>'''Syntax'''</big>
makes the bot travel pathways untill finding an enemy or teammate
====Syntax====
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setBotHunt ( element theBot )
bool setBotHunt ( element theBot )
</syntaxhighlight>
</syntaxhighlight>
====Required Arguments====
 
<big>'''Required Arguments'''</big>
*'''theBot:''' The bot you want to hunt
*'''theBot:''' The bot you want to hunt


==setBotWait==
makes the bot stand still until an enemy of teammate comes into view


 
<big>'''Syntax'''</big>
===setBotWait===
makes the bot stand still untill an enemy of teammate comes into view
====Syntax====
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setBotWait ( element theBot )
bool setBotWait ( element theBot )
</syntaxhighlight>
</syntaxhighlight>
====Required Arguments====
 
<big>'''Required Arguments'''</big>
*'''theBot:''' The bot you want to wait
*'''theBot:''' The bot you want to wait


==setBotChase==
makes the bot attack an anemy bot or player


 
<big>'''Syntax'''</big>
===setBotChase===
makes the bot attack an anemy bot or player
====Syntax====
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setBotChase ( element theBot, element theTarget )
bool setBotChase ( element theBot, element theTarget )
</syntaxhighlight>
</syntaxhighlight>
====Required Arguments====
 
<big>'''Required Arguments'''</big>
*'''theBot:''' The bot that you want to do the chasing
*'''theBot:''' The bot that you want to do the chasing
*'''theTarget:''' The bot or player you want to be chased
*'''theTarget:''' The bot or player you want to be chased


==setBotFollow==
makes the bot follow a teammate bot or player


 
<big>'''Syntax'''</big>
===setBotFollow===
makes the bot follow a teammate bot or player
====Syntax====
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setBotFollow( element theBot, element theTarget )
bool setBotFollow( element theBot, element theTarget )
</syntaxhighlight>
</syntaxhighlight>
====Required Arguments====
 
<big>'''Required Arguments'''</big>
*'''theBot:''' The bot that you want to do the following
*'''theBot:''' The bot that you want to do the following
*'''theTarget:''' The bot or player you want to be followed
*'''theTarget:''' The bot or player you want to be followed


==setBotGuard==
makes the bot move to the specific coords and stay there while attacking any enemies


 
<big>'''Syntax'''</big>
===setBotGuard===
makes the bot move to the specific coords and stay there while attacking any enemies
====Syntax====
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setBotGuard( element theBot, float x, float y, float z, [ bool priority = false ] )
bool setBotGuard( element theBot, float x, float y, float z, [ bool priority = false ] )
</syntaxhighlight>
</syntaxhighlight>
====Required Arguments====
 
<big>'''Required Arguments'''</big>
*'''theBot:''' The bot you want to do the guarding
*'''theBot:''' The bot you want to do the guarding
*'''x:''' The X coords you want the bot to guard
*'''x:''' The X coords you want the bot to guard
*'''y:''' The Y coords you want the bot to guard
*'''y:''' The Y coords you want the bot to guard
*'''z:''' The Z coords you want the bot to guard
*'''z:''' The Z coords you want the bot to guard
====Optional Arguments====
 
<big>'''Optional Arguments'''</big>
*'''priority:''' Set to true only if you want the bot to only shoot once it has reached the location to guard
*'''priority:''' Set to true only if you want the bot to only shoot once it has reached the location to guard


==getBotTeam==
returns the Team the bot is on, false if no team


 
<big>'''Syntax'''</big>
===getBotTeam===
returns the Team the bot is on, false if no team
====Syntax====
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
string getBotTeam ( element theBot)
string getBotTeam ( element theBot)
</syntaxhighlight>
</syntaxhighlight>
====Required Arguments====
 
<big>'''Required Arguments'''</big>
*'''theBot:''' The bot you want to check the team of
*'''theBot:''' The bot you want to check the team of


==setBotTeam==
changes the bot's team and loyalties


 
<big>'''Syntax'''</big>
===setBotTeam===
changes the bot's team and loyalties
====Syntax====
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setBotTeam ( element theBot, team theTeam )
bool setBotTeam ( element theBot, team theTeam )
</syntaxhighlight>
</syntaxhighlight>
====Required Arguments====
 
<big>'''Required Arguments'''</big>
*'''theBot:''' The bot you want to change the team of
*'''theBot:''' The bot you want to change the team of
*'''theTeam:''' The team the bot should join
*'''theTeam:''' The team the bot should join


==getBotAttackEnabled==
returns true if the bot is allowed to attack, false otherwise


 
<big>'''Syntax'''</big>
===getBotAttackEnabled===
returns true if the bot is allowed to attack, false otherwise
====Syntax====
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool getBotAttackEnabled( element theBot)
bool getBotAttackEnabled( element theBot)
</syntaxhighlight>
</syntaxhighlight>
====Required Arguments====
*'''theBot:''' The bot you want to check if it can atack


<big>'''Required Arguments'''</big>
*'''theBot:''' The bot you want to check if it can attack


==setBotAttackEnabled==
allow or disallow the bot to attack (press fire)


===setBotAttackEnabled===
<big>'''Syntax'''</big>
allow or disallow the bot to attack (press fire)
====Syntax====
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setBotAttackEnabled( element theBot, bool enabled)
bool setBotAttackEnabled( element theBot, bool enabled)
</syntaxhighlight>
</syntaxhighlight>
====Required Arguments====
 
*'''theBot:''' The bot you want to set if it can atack
<big>'''Required Arguments'''</big>
*'''theBot:''' The bot you want to set if it can attack
*'''enabled:''' set to false to remove the bots ability to attack, true to allow it
*'''enabled:''' set to false to remove the bots ability to attack, true to allow it


==getBotMode==
returns the mode the bot is in ("chasing", "waiting", "guarding", "hunting", "following") or if the bot is chasing or following, it will return the mode and the target


 
<big>'''Syntax'''</big>
===getBotMode===
returns the mode the bot is in ("chasing", "waiting", "guarding", "hunting", "following") or if the bot is chasing or following, it will return the mode and the target
====Syntax====
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
string getBotMode( element theBot)
string getBotMode( element theBot)
</syntaxhighlight>
</syntaxhighlight>
====Required Arguments====
 
<big>'''Required Arguments'''</big>
*'''theBot:''' The bot you want to check the status of
*'''theBot:''' The bot you want to check the status of


==isPedBot==
returns true if the ped is a bot, false otherwise


 
<big>'''Syntax'''</big>
===isPedBot===
returns true if the ped is a bot, false otherwise
====Syntax====
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool ispedbot( element thePed)
bool isPedbot( element thePed)
</syntaxhighlight>
</syntaxhighlight>
====Required Arguments====
 
<big>'''Required Arguments'''</big>
*'''thePed:''' The ped you want to check if its a bot
*'''thePed:''' The ped you want to check if its a bot


==setBotWeapon==
sets the bots weapon id (ammo is always infinite)


 
<big>'''Syntax'''</big>
===setBotWeapon===
allow or disallow the bot to attack (press fire)
====Syntax====
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool setBotWeapon( element theBot, float weapon)
bool setBotWeapon( element theBot, float weapon)
</syntaxhighlight>
</syntaxhighlight>
====Required Arguments====
 
<big>'''Required Arguments'''</big>
*'''theBot:''' The bot you want to set the weapon of
*'''theBot:''' The bot you want to set the weapon of
*'''weapon:''' the weapon id you want to give the bot
*'''weapon:''' the weapon id you want to give the bot


 
=Credits=
==CREDITS:==
*'''Slothman:''' Bot creator, main scripter
*'''Slothman:''' Bot creator, main scripter
*'''Gamesnert:''' EDF creator, scripting, testing
*'''Gamesnert:''' EDF creator, scripting, testing
Line 248: Line 254:
*'''EvGeniz:''' early testing, mapping
*'''EvGeniz:''' early testing, mapping
'''Thanks to Everyone else who made suggestions, tested the script, helped when i was stuck, etc'''
'''Thanks to Everyone else who made suggestions, tested the script, helped when i was stuck, etc'''
[[Category:Resource]]
[[ru:Slothbot]]

Latest revision as of 15:37, 7 August 2021

This is a resource designed to allow scripts or gamemodes to insert a ped into the game that roughly simulates combat with a real player. Gamemodes can implement the bots as opponents to actual players or as teammates.
Download can be found at MTA Community - Slothbot

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

Aggressiveness: Bots will attack any ped, player or bot that's not on it's team.

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

Advanced movement: If there's obstacles blocking a bots 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 until finding an enemy or teammate
  • "waiting" - stand still until 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 enemy 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 behavior.

EDF for map path creation: Integrated into the map editor, map designers can easily place paths for bots to follow along in their maps. this greatly increased the bots ability to simulate true playing.

Server Events

onBotFindEnemy

This triggers when a bot locates an enemy, This event can be cancelled to prevent the bot from chasing players

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

All of these functions will have to be used through the call function, otherwise they won't work

spawnBot

This function spawns a bot ingame, will return the bot element, or false if there was a problem.

Syntax

element spawnBot ( float x, float y, float z, int rotation = 0, [ int skinID = 0, int interior = 0, int dimension = 0, team theTeam = nil, int weapon = 0, string theMode = "hunting", element 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
  • rotation: Rotation of the bot on spawn

Optional Arguments

  • 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. Set false to the bot not join a team.
  • weapon: The weapon the ped will carry
  • theMode: The action the bot will be performing when spawned (see "modes of playing" above)
  • theModeSubject: If theMode is "chasing" or "following" this arg is needed to tell the bot what opponent to chase or teammate to follow

setBotHunt

makes the bot travel pathways until finding an enemy or teammate

Syntax

bool setBotHunt ( element theBot )

Required Arguments

  • theBot: The bot you want to hunt

setBotWait

makes the bot stand still until an enemy of teammate comes into view

Syntax

bool setBotWait ( element theBot )

Required Arguments

  • theBot: The bot you want to wait

setBotChase

makes the bot attack an anemy bot or player

Syntax

bool setBotChase ( element theBot, element theTarget )

Required Arguments

  • theBot: The bot that you want to do the chasing
  • theTarget: The bot or player you want to be chased

setBotFollow

makes the bot follow a teammate bot or player

Syntax

bool setBotFollow( element theBot, element theTarget )

Required Arguments

  • theBot: The bot that you want to do the following
  • theTarget: The bot or player you want to be followed

setBotGuard

makes the bot move to the specific coords and stay there while attacking any enemies

Syntax

bool setBotGuard( element theBot, float x, float y, float z, [ bool priority = false ] )

Required Arguments

  • theBot: The bot you want to do the guarding
  • x: The X coords you want the bot to guard
  • y: The Y coords you want the bot to guard
  • z: The Z coords you want the bot to guard

Optional Arguments

  • priority: Set to true only if you want the bot to only shoot once it has reached the location to guard

getBotTeam

returns the Team the bot is on, false if no team

Syntax

string getBotTeam ( element theBot)

Required Arguments

  • theBot: The bot you want to check the team of

setBotTeam

changes the bot's team and loyalties

Syntax

bool setBotTeam ( element theBot, team theTeam )

Required Arguments

  • theBot: The bot you want to change the team of
  • theTeam: The team the bot should join

getBotAttackEnabled

returns true if the bot is allowed to attack, false otherwise

Syntax

bool getBotAttackEnabled( element theBot)

Required Arguments

  • theBot: The bot you want to check if it can attack

setBotAttackEnabled

allow or disallow the bot to attack (press fire)

Syntax

bool setBotAttackEnabled( element theBot, bool enabled)

Required Arguments

  • theBot: The bot you want to set if it can attack
  • enabled: set to false to remove the bots ability to attack, true to allow it

getBotMode

returns the mode the bot is in ("chasing", "waiting", "guarding", "hunting", "following") or if the bot is chasing or following, it will return the mode and the target

Syntax

string getBotMode( element theBot)

Required Arguments

  • theBot: The bot you want to check the status of

isPedBot

returns true if the ped is a bot, false otherwise

Syntax

bool isPedbot( element thePed)

Required Arguments

  • thePed: The ped you want to check if its a bot

setBotWeapon

sets the bots weapon id (ammo is always infinite)

Syntax

bool setBotWeapon( element theBot, float weapon)

Required Arguments

  • theBot: The bot you want to set the weapon of
  • weapon: the weapon id you want to give the bot

Credits

  • Slothman: Bot creator, main scripter
  • Gamesnert: EDF creator, scripting, testing
  • Dragon: Gamemode creator, testing, scripting help
  • EvGeniz: early testing, mapping

Thanks to Everyone else who made suggestions, tested the script, helped when i was stuck, etc