From a0a30a4a0cc5f5da37ef2001e542aa1a7e565afd Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Mon, 17 Nov 2025 16:57:17 +0000 Subject: [PATCH] add punch_interval setting --- api.lua | 11 ++++++++--- api.txt | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/api.lua b/api.lua index 4a109fb..36af64a 100644 --- a/api.lua +++ b/api.lua @@ -18,7 +18,7 @@ end -- global table mobs = { - mod = "redo", version = "20251011", + mod = "redo", version = "20251117", spawning_mobs = {}, translate = S, node_snow = has(core.registered_aliases["mapgen_snow"]) or has("mcl_core:snow") or has("default:snow") or "air", @@ -2321,9 +2321,13 @@ function mob_class:do_states(dtime) self:set_velocity(0) - if self.timer > 1 then + self.punch_timer = (self.punch_timer or 0) + dtime - self.timer = 0 + if self.punch_timer >= self.punch_interval then + + self.punch_timer = 0 + +-- self.timer = 0 -- no custom attack or custom attack returns true to continue if not self.custom_attack or self:custom_attack(self, p) then @@ -3316,6 +3320,7 @@ function mobs:register_mob(name, def) randomly_turn = def.randomly_turn ~= false, ignore_invisibility = def.ignore_invisibility, messages = def.messages, + punch_interval = def.punch_interval or 1, on_rightclick = def.on_rightclick, on_die = def.on_die, diff --git a/api.txt b/api.txt index 47ea393..1f0f88f 100644 --- a/api.txt +++ b/api.txt @@ -153,6 +153,7 @@ functions needed for the mob to work properly which contains the following: 'shoot_offset' holds the y position added as to where the arrow/fireball appears on mob. 'homing' When True arrows will follow player when visible. + 'punch_interval' the number of seconds between punches (default: 1) 'specific_attack' has a table of entity names that mob can also attack e.g. {"player", "mobs_animal:chicken"}. 'friendly_fire` when set to false, mobs will not be able to harm other