forked from mtcontrib/mobs_redo
added attack_chance to mob definition
This commit is contained in:
parent
6bf6e8fbd8
commit
e17f8811b1
7
api.lua
7
api.lua
@ -6,7 +6,7 @@ local use_cmi = minetest.global_exists("cmi")
|
|||||||
|
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20180928",
|
version = "20181001",
|
||||||
intllib = S,
|
intllib = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {},
|
invis = minetest.global_exists("invisibility") and invisibility or {},
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ local get_distance = function(a, b)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- collision function based on similar from jordan4ibanez' open_ai mod
|
-- collision function based on jordan4ibanez' open_ai mod
|
||||||
local collision = function(self)
|
local collision = function(self)
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
@ -1447,7 +1447,7 @@ local general_attack = function(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- attack closest player or mob
|
-- attack closest player or mob
|
||||||
if min_player then
|
if min_player and random(1, 100) > self.attack_chance then
|
||||||
do_attack(self, min_player)
|
do_attack(self, min_player)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -3030,6 +3030,7 @@ minetest.register_entity(name, {
|
|||||||
follow = def.follow,
|
follow = def.follow,
|
||||||
jump = def.jump ~= false,
|
jump = def.jump ~= false,
|
||||||
walk_chance = def.walk_chance or 50,
|
walk_chance = def.walk_chance or 50,
|
||||||
|
attack_chance = def.attack_chance or 5,
|
||||||
passive = def.passive or false,
|
passive = def.passive or false,
|
||||||
knock_back = def.knock_back ~= false,
|
knock_back = def.knock_back ~= false,
|
||||||
blood_amount = def.blood_amount or 5,
|
blood_amount = def.blood_amount or 5,
|
||||||
|
1
api.txt
1
api.txt
@ -74,6 +74,7 @@ functions needed for the mob to work properly which contains the following:
|
|||||||
'docile_by_day' when true has mobs wandering around during daylight
|
'docile_by_day' when true has mobs wandering around during daylight
|
||||||
hours and only attacking player at night or when
|
hours and only attacking player at night or when
|
||||||
provoked.
|
provoked.
|
||||||
|
'attack_chance' 0 to 100 chance the mob will attack (default is 5).
|
||||||
'attack_monsters' when true mob will attack monsters.
|
'attack_monsters' when true mob will attack monsters.
|
||||||
'attack_animals' when true mob will attack animals.
|
'attack_animals' when true mob will attack animals.
|
||||||
'attack_npcs' when true mob will attack npcs within range.
|
'attack_npcs' when true mob will attack npcs within range.
|
||||||
|
Loading…
Reference in New Issue
Block a user