1
0
mirror of https://codeberg.org/tenplus1/mobs_redo.git synced 2024-12-23 09:10:22 +01:00

on_flop and air_damage added

This commit is contained in:
TenPlus1 2020-12-06 09:53:02 +00:00
parent 9489ff6965
commit bf32a09e5e
3 changed files with 31 additions and 2 deletions

27
api.lua
View File

@ -8,7 +8,7 @@ local use_cmi = minetest.global_exists("cmi")
mobs = {
mod = "redo",
version = "20201205",
version = "20201206",
intllib = S,
invis = minetest.global_exists("invisibility") and invisibility or {}
}
@ -112,6 +112,7 @@ local mob_class = {
light_damage_max = 15,
water_damage = 0,
lava_damage = 0,
air_damage = 0,
suffocation = 2,
fall_damage = 1,
fall_speed = -10, -- must be lower than -2 (default: -10)
@ -1100,6 +1101,19 @@ function mob_class:do_env_damage()
end
end
-- air damage
if self.air_damage ~= 0 and self.standing_in == "air" then
self.health = self.health - self.air_damage
effect(pos, 3, "bubble.png", 1, 1, 1, 0.2)
if self:check_for_death({type = "environment",
pos = pos, node = self.standing_in}) then
return true
end
end
-- is mob light sensative, or scared of the dark :P
if self.light_damage ~= 0 then
@ -2084,6 +2098,15 @@ function mob_class:follow_flop()
if not self:attempt_flight_correction() then
self.state = "flop"
-- do we have a custom on_flop function?
if self.on_flop then
if self:on_flop(self) then
return
end
end
self.object:set_velocity({x = 0, y = -5, z = 0})
self:set_animation("stand")
@ -3482,6 +3505,7 @@ minetest.register_entity(name, setmetatable({
owner = def.owner,
order = def.order,
on_die = def.on_die,
on_flop = def.on_flop,
do_custom = def.do_custom,
jump_height = def.jump_height,
drawtype = def.drawtype, -- DEPRECATED, use rotate instead
@ -3505,6 +3529,7 @@ minetest.register_entity(name, setmetatable({
light_damage_max = def.light_damage_max,
water_damage = def.water_damage,
lava_damage = def.lava_damage,
air_damage = def.air_damage,
suffocation = def.suffocation,
fall_damage = def.fall_damage,
fall_speed = def.fall_speed,

View File

@ -64,6 +64,7 @@ functions needed for the mob to work properly which contains the following:
'fall_damage' when true causes falling to inflict damage.
'water_damage' holds the damage per second infliced to mobs when standing in
water.
'air_damage' holds damage per second inflicted to mob when standing in air.
'lava_damage' holds the damage per second inflicted to mobs when standing
in lava or fire or an ignition source.
'light_damage' holds the damage per second inflicted to mobs when light
@ -299,6 +300,9 @@ enhance mob functionality and have them do many interesting things:
is returned normal attack function continued.
'on_die' a function that is called when mob is killed (self, pos), also
has access to self.cause_of_death table.
'on_flop' function called when flying or swimmimng mob is no longer in
air/water, (self) paramater and return true to skip the built
in api flop feature.
'do_custom' a custom function that is called every tick while mob is
active and which has access to all of the self.* variables
e.g. (self.health for health or self.standing_in for node

View File

@ -23,7 +23,7 @@ Lucky Blocks: 9
Changelog:
- 1.54 - Simplified animal breeding function, added editable settings (thanks Wuzzy), Child mobs now take 20 mins to grow up, reverted to simple mob spawning with setting to use area checks.
- 1.54 - Simplified animal breeding function, added editable settings (thanks Wuzzy), Child mobs now take 20 mins to grow up, reverted to simple mob spawning with setting to use area checks, on_flop added, air_damage added.
- 1.53 - Added 'on_map_load' settings to mobs:spawn so that mobs will only spawn when new areas of map are loaded.
- 1.52 - Added 'mob_active_limit' in settings to set number of mobs in game,
(default is 0 for unlimited), removed {immortal} from mob armor, fluid viscocity slows mobs