mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2024-12-25 02:00:21 +01:00
add stand_chance and animation force flag
This commit is contained in:
parent
55dda6da83
commit
ddbd403285
14
api.lua
14
api.lua
@ -6,7 +6,7 @@ local use_cmi = minetest.global_exists("cmi")
|
||||
|
||||
mobs = {
|
||||
mod = "redo",
|
||||
version = "20190402",
|
||||
version = "20190430",
|
||||
intllib = S,
|
||||
invis = minetest.global_exists("invisibility") and invisibility or {},
|
||||
}
|
||||
@ -106,6 +106,7 @@ local mob_class = {
|
||||
jump = true,
|
||||
knock_back = true,
|
||||
walk_chance = 50,
|
||||
stand_chance = 30,
|
||||
attack_chance = 5,
|
||||
passive = false,
|
||||
blood_amount = 5,
|
||||
@ -277,15 +278,15 @@ end
|
||||
|
||||
|
||||
-- set defined animation
|
||||
function mob_class:set_animation(anim)
|
||||
function mob_class:set_animation(anim, force)
|
||||
|
||||
if not self.animation
|
||||
or not anim then return end
|
||||
|
||||
self.animation.current = self.animation.current or ""
|
||||
|
||||
-- only set different animation for attacks when setting to same set
|
||||
if anim ~= "punch" and anim ~= "shoot"
|
||||
-- only set different animation for attacks when using same set
|
||||
if force ~= true and anim ~= "punch" and anim ~= "shoot"
|
||||
and string.find(self.animation.current, anim) then
|
||||
return
|
||||
end
|
||||
@ -2070,11 +2071,11 @@ function mob_class:do_states(dtime)
|
||||
|
||||
if self.facing_fence == true
|
||||
or temp_is_cliff
|
||||
or random(1, 100) <= 30 then
|
||||
or random(1, 100) <= self.stand_chance then
|
||||
|
||||
self:set_velocity(0)
|
||||
self.state = "stand"
|
||||
self:set_animation("stand")
|
||||
self:set_animation("stand", true)
|
||||
else
|
||||
self:set_velocity(self.walk_velocity)
|
||||
|
||||
@ -3274,6 +3275,7 @@ minetest.register_entity(name, setmetatable({
|
||||
follow = def.follow,
|
||||
jump = def.jump,
|
||||
walk_chance = def.walk_chance,
|
||||
stand_chance = def.stand_chance,
|
||||
attack_chance = def.attack_chance,
|
||||
passive = def.passive,
|
||||
knock_back = def.knock_back,
|
||||
|
1
api.txt
1
api.txt
@ -35,6 +35,7 @@ functions needed for the mob to work properly which contains the following:
|
||||
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.
|
||||
'jump' when true allows your mob to jump updwards.
|
||||
|
Loading…
Reference in New Issue
Block a user