From 313382dcaa72816c0edba6d922e723d588b20444 Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Sat, 25 May 2024 07:50:16 +0100 Subject: [PATCH] increase go_to time to 20 and add force flag to do_attack --- api.lua | 11 ++++++----- api.txt | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/api.lua b/api.lua index 4a10073..10893e6 100644 --- a/api.lua +++ b/api.lua @@ -14,7 +14,7 @@ local use_vh1 = minetest.get_modpath("visual_harm_1ndicators") -- Global mobs = { mod = "redo", - version = "20240524", + version = "20240525", translate = S, invis = minetest.global_exists("invisibility") and invisibility or {}, node_snow = minetest.registered_aliases["mapgen_snow"] @@ -225,9 +225,9 @@ end -- attack player/mob -function mob_class:do_attack(player) +function mob_class:do_attack(player, force) - if self.state == "attack" then + if self.state == "attack" and not force then return end @@ -1872,11 +1872,12 @@ minetest.register_entity("mobs:_pos", { visual = "sprite", texture = "", hp_max = 1, physical = false, static_save = false, pointable = false, is_visible = false }, health = 1, _cmi_is_mob = true, + on_step = function(self, dtime) self.counter = (self.counter or 0) + dtime - if self.counter > 10 then + if self.counter > 20 then self.object:remove() end end @@ -1888,7 +1889,7 @@ function mob_class:go_to(pos) local obj = minetest.add_entity(pos, "mobs:_pos") if obj and obj:get_luaentity() then - self:do_attack(obj) + self:do_attack(obj, true) end end diff --git a/api.txt b/api.txt index 6f5972a..6590a35 100644 --- a/api.txt +++ b/api.txt @@ -402,7 +402,8 @@ Each mob contains a set of functions that can be called for use internally or fr another mod entirely, replace mob_class with the mob entity variable: mob_class:mob_sound(sound) -- play sound at mob position -mob_class:do_attack(player) -- if not already attacking, attack object given +mob_class:do_attack(player [, force]) -- if not already attacking, attack object given, +forced being true stops attacking current target and focuses on one given mob_class:stop_attack() -- stops mob attacking mob_class:collision() -- checks for player collision with mob and returns {x, z} vector mob_class:set_velocity(velocity) -- move at velocity in the facing direction