Skip to content

Bot defines

AiTechEye edited this page Sep 20, 2018 · 5 revisions

Everything is not listed...

Definable properties

create a simple npc With aliveai you dont need any reurses or propertyes to create a bot, all options have defaults so this is enought to create one, but will replace the default one

aliveai.create_bot()

to create another bot you just need to name it:

aliveai.create_bot({name="mybot"})

a stealing bot, with another texture, mute and none-fighting:

aliveai.create_bot({
		name="folk5",
		texture="aliveai_folk5.png",
		stealing=1,
		steal_chanse=2,
		talking=0,
		fighting=0,
})

a dirt monster

aliveai.create_bot({
	name="my-monster",
	team="dirtteam",
	texture="default_dirt.png",
	type="monster",
	talking=0,
	attack_players=1,
	attacking=1,
	building=0,
	hp=50,
	name_color="",
	spawn_on={"default:dirt_with_grass"},
	start_with_items={["default:dirt"]=2},
	on_step=function(self,dtime)
		local pos=self.object:get_pos()

 		--replace grass with dirt, then stand still

		if minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name=="default:dirt_with_grass"
			minetest.set_node({x=pos.x,y=pos.y-1,z=pos.z},{name="default:dirt"})
			aliveai.stand(self)
			return self
		end

	end,
})
Parameter type default Options Description
dmg number 1 0 > punch damage
dropbones number 1 1 or 0 drops bones (self.type="npc" only)
superbuild number 1 1 or 0 can build from unlimited distance
house string "" code generated house code (build path)
creative number 0 1 or 0 creative bot (dont need to get stuff)
leader number 1 1 or 0 can requires members to come
team string Sam name team name
visual string mesh mesh, cube...
basey number 0.7 0 <> check if insde a node and need to jump
damage_by_blocks number 1 1 or 0 damage by nodegroup damage_per_second ( 0> )
kill_deep_falling number 1 1 or 0 if falls out of players range, then become removed
crafting number 6 0 > avoid height
avoidy number 1 1 or 0
drop_dead_body number 1 1 or 0 lays down after death or disappear
type string "npc" npc,monster,, etc... type of bot/mob
distance number 15 0 > range that objects can be detected
start_with_items table "" ["default:apple"]=1,["default:wood"]=4 gets items on spawn
tools table "" tool_name tool to use, using start_with_items is more recomanded
tool_index number 1 0 > used when bots is using a tool
tool_reuse number 1 1 or 0 reusing the tool after use, used with tools that need to be reloaded eg: bows
tool_chance number 5 0 > chance to use the tool
tool_see number 1 1 or 0 using the tool when it detect enimy
tool_near number 0 1 or 0 using the tool when its near a enimy
escape number 1 1 or 0 enable escaping if necessary
fighting number 1 1 or 0 enable fighting if necessary
attack_players number 0 1 or 0 attack players, used by self.type="monster"
attack_chance number 10 0 > chance to attack
smartfight number 1 1 or 0 smartfighting
usearmor number 1 1 or 0 use 3d_armor
building number 1 1 or 0 can build eg houses
pickuping number 1 1 or 0 can pick up items
attacking number 0 1 or 0 attacks by no reason
coming number 1 1 or 0 coming to team members
work_helper number 0 1 or 0 giving stuff to other bots
coming_players number 1 1 or 0 coming if players left click them or says "come"
talking number 1 1 or 0 can talk
stealing number 0 1 or 0 steal from players inventory
steal_chance number 0 0 >= chance to steal from players
self.light number 1 1,0,-1 searching to light 1=light 0=ignore -1=darknes to be in the opposite causing damages
hugwalk number 0 1 or 0 walk animation with arms stretched out
lowestlight number 10 0 <> lowest node-light-level that the bot thrives in inside
lightdamage number 1 1 or 0 hurt by light bot doesn't thrives inside
annoyed_by_staring number 1 1 or 0 loosing mood when someone is near it
drowning number 1 1 or 0 losing breath by nodegroup drowning ( 0> ), then hurts
mindamage number 0 0 >= min damage that can hurt the bot
animation table bot animation
texture table or string "character.png" texture bot texture(s)
spawn_on table spreading_dirt_type
sand, snow
node name or group spawn on nodes
spawn_in table spreading_dirt_type
sand, snow
node name or group spawn in node
no entity number nil nil or number doesn't registry entity, usefull if you are using another entity
no_spawning number nil nil or number doesn't registry a abm
no_spawnitem number item nil or string doesn't registry spawning item or replace

Definable functions

Function Default Incoming parameters return something
to abort run
Description
step self true can control the bot 100%
on_chat self,name,speaker,msg false in coming chat (sub function)
on_spoken_to on_spoken_to self,name,speaker,msg false in coming chat
on_fighting self,target false is fighting
on_escaping self,target false is is escaping
on_punching self,target false is punching
on_punch_hit self,target false hits the target
on_detecting_enemy self false detects target
death self,puncher,pos false death
spawn self false spawn
on_load self false reload after it has been inactive
on_random_walk self false on random walkign
click give_to_bot self,clicker false when something clicks it
punched self,puncher,dmg false
on_meet self,zeal false meet the "come" target
on_dig self,pos,drop_name,count false digs a node
on_blow self false blows up / explotion

Definable tasks

Task Default Incoming parameter
task1 aliveai.task_build self
task2 aliveai.task_stay_at_home self
task3 aliveai.task_farming self
task4 self
task5 self
Clone this wiki locally