1
0
mirror of https://codeberg.org/tenplus1/mobs_redo.git synced 2025-07-28 04:50:18 +02:00

Compare commits

...

7 Commits

Author SHA1 Message Date
1271570780 nil check in do_states 2020-07-20 18:10:08 +01:00
ec3c6fb518 update api.txt 2020-07-20 07:36:39 +01:00
c4f56f4204 nill check for follow_flop 2020-07-20 07:32:24 +01:00
4814f53885 nil check for get_distance 2020-07-20 07:27:55 +01:00
f033cd401c add nil check to general_attack 2020-07-18 20:39:49 +01:00
903e81bdab another nil check for entity 2020-07-17 21:12:43 +01:00
81dd3d75c0 add randomly_turn setting to mob definition 2020-07-17 20:58:52 +01:00
2 changed files with 12 additions and 9 deletions

17
api.lua
View File

@ -6,7 +6,7 @@ local use_cmi = minetest.global_exists("cmi")
mobs = {
mod = "redo",
version = "20200701",
version = "20200720",
intllib = S,
invis = minetest.global_exists("invisibility") and invisibility or {}
}
@ -195,7 +195,7 @@ end
-- calculate distance
local get_distance = function(a, b)
if not a or not b then return 50 end -- nil check
local x, y, z = a.x - b.x, a.y - b.y, a.z - b.z
return square(x * x + y * y + z * z)
@ -1013,7 +1013,7 @@ function mob_class:do_env_damage()
self:update_tag()
end
local pos = self.object:get_pos()
local pos = self.object:get_pos() ; if not pos then return end
self.time_of_day = minetest.get_timeofday()
@ -1831,7 +1831,7 @@ function mob_class:general_attack()
return
end
local s = self.object:get_pos()
local s = self.object:get_pos() ; if not s then return end
local objs = minetest.get_objects_inside_radius(s, self.view_range)
-- remove entities we aren't interested in
@ -2001,7 +2001,7 @@ function mob_class:follow_flop()
and self.state ~= "attack"
and self.state ~= "runaway" then
local s = self.object:get_pos()
local s = self.object:get_pos() ; if not s then return end
local players = minetest.get_connected_players()
for n = 1, #players do
@ -2132,11 +2132,11 @@ end
-- execute current state (stand, walk, run, attacks)
function mob_class:do_states(dtime)
local yaw = self.object:get_yaw() or 0
local yaw = self.object:get_yaw() ; if not yaw then return end
if self.state == "stand" then
if random(4) == 1 then
if self.randomly_turn and random(4) == 1 then
local lp
local s = self.object:get_pos()
@ -2224,7 +2224,7 @@ function mob_class:do_states(dtime)
yaw = self:set_yaw(yaw, 8)
-- otherwise randomly turn
elseif random(100) <= 30 then
elseif self.randomly_turn and random(100) <= 30 then
yaw = yaw + random(-0.5, 0.5)
@ -3564,6 +3564,7 @@ minetest.register_entity(name, setmetatable({
owner_loyal = def.owner_loyal,
pushable = def.pushable,
stay_near = def.stay_near,
randomly_turn = def.randomly_turn ~= false,
on_spawn = def.on_spawn,

View File

@ -31,13 +31,15 @@ functions needed for the mob to work properly which contains the following:
'hp_max' has the maximum health value the mob can spawn with.
'armor' holds strength of mob, 100 is normal, lower is more powerful
and needs more hits and better weapons to kill.
'passive' when true allows animals to defend themselves when hit,
'passive' when false allows animals to defend themselves when hit,
otherwise they amble onwards.
'walk_velocity' is the speed that your mob can walk around.
'run_velocity' is the speed your mob can run with, usually when attacking.
'stand_chance' has a 0-100 chance value your mob will stand from walking.
'walk_chance' has a 0-100 chance value your mob will walk from standing,
set to 0 for jumping mobs only.
'randomly_turn' if set to false then mob will not turn to face player or
randomly turn while walking or standing.
'jump' when true allows your mob to jump updwards.
'jump_height' holds the height your mob can jump, 0 to disable jumping.
'stepheight' height of a block that your mob can easily walk up onto,