1
0
mirror of https://codeberg.org/tenplus1/mobs_redo.git synced 2025-11-18 23:55:30 +01:00

add punch_interval setting

This commit is contained in:
tenplus1
2025-11-17 16:57:17 +00:00
parent 59ae6c6923
commit a0a30a4a0c
2 changed files with 9 additions and 3 deletions

11
api.lua
View File

@@ -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,

View File

@@ -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