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:
11
api.lua
11
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,
|
||||
|
||||
1
api.txt
1
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
|
||||
|
||||
Reference in New Issue
Block a user