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 = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20190402",
|
version = "20190430",
|
||||||
intllib = S,
|
intllib = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {},
|
invis = minetest.global_exists("invisibility") and invisibility or {},
|
||||||
}
|
}
|
||||||
@ -106,6 +106,7 @@ local mob_class = {
|
|||||||
jump = true,
|
jump = true,
|
||||||
knock_back = true,
|
knock_back = true,
|
||||||
walk_chance = 50,
|
walk_chance = 50,
|
||||||
|
stand_chance = 30,
|
||||||
attack_chance = 5,
|
attack_chance = 5,
|
||||||
passive = false,
|
passive = false,
|
||||||
blood_amount = 5,
|
blood_amount = 5,
|
||||||
@ -277,15 +278,15 @@ end
|
|||||||
|
|
||||||
|
|
||||||
-- set defined animation
|
-- set defined animation
|
||||||
function mob_class:set_animation(anim)
|
function mob_class:set_animation(anim, force)
|
||||||
|
|
||||||
if not self.animation
|
if not self.animation
|
||||||
or not anim then return end
|
or not anim then return end
|
||||||
|
|
||||||
self.animation.current = self.animation.current or ""
|
self.animation.current = self.animation.current or ""
|
||||||
|
|
||||||
-- only set different animation for attacks when setting to same set
|
-- only set different animation for attacks when using same set
|
||||||
if anim ~= "punch" and anim ~= "shoot"
|
if force ~= true and anim ~= "punch" and anim ~= "shoot"
|
||||||
and string.find(self.animation.current, anim) then
|
and string.find(self.animation.current, anim) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -2070,11 +2071,11 @@ function mob_class:do_states(dtime)
|
|||||||
|
|
||||||
if self.facing_fence == true
|
if self.facing_fence == true
|
||||||
or temp_is_cliff
|
or temp_is_cliff
|
||||||
or random(1, 100) <= 30 then
|
or random(1, 100) <= self.stand_chance then
|
||||||
|
|
||||||
self:set_velocity(0)
|
self:set_velocity(0)
|
||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
self:set_animation("stand")
|
self:set_animation("stand", true)
|
||||||
else
|
else
|
||||||
self:set_velocity(self.walk_velocity)
|
self:set_velocity(self.walk_velocity)
|
||||||
|
|
||||||
@ -3274,6 +3275,7 @@ minetest.register_entity(name, setmetatable({
|
|||||||
follow = def.follow,
|
follow = def.follow,
|
||||||
jump = def.jump,
|
jump = def.jump,
|
||||||
walk_chance = def.walk_chance,
|
walk_chance = def.walk_chance,
|
||||||
|
stand_chance = def.stand_chance,
|
||||||
attack_chance = def.attack_chance,
|
attack_chance = def.attack_chance,
|
||||||
passive = def.passive,
|
passive = def.passive,
|
||||||
knock_back = def.knock_back,
|
knock_back = def.knock_back,
|
||||||
|
3
api.txt
3
api.txt
@ -35,6 +35,7 @@ functions needed for the mob to work properly which contains the following:
|
|||||||
otherwise they amble onwards.
|
otherwise they amble onwards.
|
||||||
'walk_velocity' is the speed that your mob can walk around.
|
'walk_velocity' is the speed that your mob can walk around.
|
||||||
'run_velocity' is the speed your mob can run with, usually when attacking.
|
'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,
|
'walk_chance' has a 0-100 chance value your mob will walk from standing,
|
||||||
set to 0 for jumping mobs only.
|
set to 0 for jumping mobs only.
|
||||||
'jump' when true allows your mob to jump updwards.
|
'jump' when true allows your mob to jump updwards.
|
||||||
@ -632,7 +633,7 @@ mobs:register_mob("mob_horse:horse", {
|
|||||||
visual_size = {x = 1.20, y = 1.20},
|
visual_size = {x = 1.20, y = 1.20},
|
||||||
mesh = "mobs_horse.x",
|
mesh = "mobs_horse.x",
|
||||||
collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.25, 0.4},
|
collisionbox = {-0.4, -0.01, -0.4, 0.4, 1.25, 0.4},
|
||||||
animation = {
|
animation = {
|
||||||
speed_normal = 15,
|
speed_normal = 15,
|
||||||
speed_run = 30,
|
speed_run = 30,
|
||||||
stand_start = 25,
|
stand_start = 25,
|
||||||
|
Loading…
Reference in New Issue
Block a user