mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-01-26 00:50:21 +01:00
add self.attack_patience to add custom times, add self.attack nil check to pathfinding
This commit is contained in:
parent
ac5486cc58
commit
9e27f45663
10
api.lua
10
api.lua
@ -11,7 +11,7 @@ local use_mc2 = minetest.get_modpath("mcl_core")
|
|||||||
-- Global
|
-- Global
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20231105",
|
version = "20231106",
|
||||||
translate = S,
|
translate = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {},
|
invis = minetest.global_exists("invisibility") and invisibility or {},
|
||||||
node_snow = minetest.registered_aliases["mapgen_snow"]
|
node_snow = minetest.registered_aliases["mapgen_snow"]
|
||||||
@ -154,6 +154,7 @@ mobs.mob_class = {
|
|||||||
walk_chance = 50,
|
walk_chance = 50,
|
||||||
stand_chance = 30,
|
stand_chance = 30,
|
||||||
attack_chance = 5,
|
attack_chance = 5,
|
||||||
|
attack_patience = 11,
|
||||||
passive = false,
|
passive = false,
|
||||||
blood_amount = 5,
|
blood_amount = 5,
|
||||||
blood_texture = "mobs_blood.png",
|
blood_texture = "mobs_blood.png",
|
||||||
@ -1685,7 +1686,9 @@ function mob_class:smart_mobs(s, p, dist, dtime)
|
|||||||
s.y = sground.y + 1
|
s.y = sground.y + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
local p1 = self.attack:get_pos()
|
local p1 = self.attack and self.attack:get_pos()
|
||||||
|
|
||||||
|
if not p1 then return end
|
||||||
|
|
||||||
p1.x = floor(p1.x + 0.5)
|
p1.x = floor(p1.x + 0.5)
|
||||||
p1.y = floor(p1.y + 0.5)
|
p1.y = floor(p1.y + 0.5)
|
||||||
@ -2364,7 +2367,7 @@ function mob_class:do_states(dtime)
|
|||||||
|
|
||||||
self.target_time_lost = (self.target_time_lost or 0) + dtime
|
self.target_time_lost = (self.target_time_lost or 0) + dtime
|
||||||
|
|
||||||
if self.target_time_lost > 11 then
|
if self.target_time_lost > self.attack_patience then
|
||||||
self:stop_attack()
|
self:stop_attack()
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -3597,6 +3600,7 @@ minetest.register_entity(":" .. name, setmetatable({
|
|||||||
walk_chance = def.walk_chance,
|
walk_chance = def.walk_chance,
|
||||||
stand_chance = def.stand_chance,
|
stand_chance = def.stand_chance,
|
||||||
attack_chance = def.attack_chance,
|
attack_chance = def.attack_chance,
|
||||||
|
attack_patience = def.attack_patience,
|
||||||
passive = def.passive,
|
passive = def.passive,
|
||||||
knock_back = def.knock_back,
|
knock_back = def.knock_back,
|
||||||
blood_amount = def.blood_amount,
|
blood_amount = def.blood_amount,
|
||||||
|
2
api.txt
2
api.txt
@ -103,6 +103,8 @@ functions needed for the mob to work properly which contains the following:
|
|||||||
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_chance' 0 to 100 chance the mob will attack (default is 5).
|
||||||
|
'attack_patience' Time in seconds before mob gives up attacking if
|
||||||
|
player isn't seen (Defaults to 11).
|
||||||
'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