1
0
mirror of https://codeberg.org/tenplus1/mobs_redo.git synced 2025-08-23 17:50:26 +02:00

Compare commits

..

28 Commits

Author SHA1 Message Date
f576947d41 add nil check for mob eggs 2020-05-08 20:33:41 +01:00
f32b69a654 rename global function 2020-05-07 11:35:29 +01:00
bd06ad8d6e added pos_to_yaw function, added fence function check, cody tidy 2020-05-07 11:15:04 +01:00
8ce8490e78 code tweak and tidy 2020-05-06 21:21:20 +01:00
18906fafeb code tweaks and tidy, hopefully fixed remove_far feature 2020-05-06 10:10:50 +01:00
9928b0e35e add nil check to replace function 2020-05-05 21:32:24 +01:00
99fe3d0ce1 missed local 2020-05-04 20:45:43 +01:00
00e8ac0850 added failsafe for suffocation value (true, false) instead of value 2020-05-02 19:28:13 +01:00
f98d769e15 added 'mob_nospawn_range' setting 2020-05-01 19:30:29 +01:00
928f8c5479 never spawn mobs if player within 12 nodes 2020-05-01 18:48:07 +01:00
32e8d069f7 enable suffocation, add area check when spawning, code tidy and tweaks 2020-05-01 10:29:12 +01:00
e4198b2a21 only force turn when actually blocked 2020-04-30 11:51:44 +01:00
f11b774c95 tweaked jumping and turning when blocked in front 2020-04-30 09:33:46 +01:00
8b25ab4988 add 'keep_flying' flag and random vertical flight changes 2020-04-29 20:15:35 +01:00
064b59f01d Added few sanity checks, higher pitch sounds for child mobs 2020-04-29 15:01:21 +01:00
a934d80631 added some node checks and damage returns 2020-04-27 13:17:20 +01:00
f2cc0446b0 cant attack if running away 2020-04-26 21:16:46 +01:00
bff313267b re-enable raycasting line of sight (should work now) 2020-04-12 12:14:42 +01:00
9b0ff17101 add sanity check to do_punch 2020-04-11 17:51:15 +01:00
dde9896a1a add sanity check to do_jump 2020-04-11 17:46:07 +01:00
92c899e6a4 mob egg sanity checks 2020-04-07 08:41:41 +01:00
4634288124 add falling sanity check 2020-04-07 08:36:57 +01:00
610cef16f4 add some sanity checks 2020-04-06 09:30:50 +01:00
9c60e96336 add value for nil yaw 2020-03-26 19:33:16 +00:00
dc3ed1dfe3 add nil checks 2020-03-12 20:36:23 +00:00
ff4bb540e1 on_blast returns no damage, knockback or items 2020-03-06 19:43:35 +00:00
9f5e6eb85f added missing return value to do_env_damage 2020-03-06 13:23:53 +00:00
ad5b444b65 added do_env_damage flags when hurt and nil check when damaged 2020-03-06 13:17:18 +00:00
6 changed files with 478 additions and 305 deletions

731
api.lua

File diff suppressed because it is too large Load Diff

View File

@ -45,6 +45,7 @@ functions needed for the mob to work properly which contains the following:
'fly' when true allows your mob to fly around instead of walking. 'fly' when true allows your mob to fly around instead of walking.
'fly_in' holds the node name that the mob flies (or swims) around 'fly_in' holds the node name that the mob flies (or swims) around
in e.g. "air" or "default:water_source". in e.g. "air" or "default:water_source".
'keep_flying' when true mobs like birds no longer stop and stand.
'stay_near' when set allows mobs the chance to stay around certain nodes. 'stay_near' when set allows mobs the chance to stay around certain nodes.
'nodes' string or table of nodes to stay nearby e.g. "farming:straw" 'nodes' string or table of nodes to stay nearby e.g. "farming:straw"
'chance' chance of searching for above node(s), default is 10. 'chance' chance of searching for above node(s), default is 10.
@ -67,7 +68,8 @@ functions needed for the mob to work properly which contains the following:
level is between the min and max values below level is between the min and max values below
'light_damage_min' minimum light value when mob is affected (default: 14) 'light_damage_min' minimum light value when mob is affected (default: 14)
'light_damage_max' maximum light value when mob is affected (default: 15) 'light_damage_max' maximum light value when mob is affected (default: 15)
'suffocation' when true causes mobs to suffocate inside solid blocks. 'suffocation' when > 0 mobs will suffocate inside solid blocks and will be
hurt by the value given every second (0 to disable).
'floats' when set to 1 mob will float in water, 0 has them sink. 'floats' when set to 1 mob will float in water, 0 has them sink.
'follow' mobs follow player when holding any of the items which appear 'follow' mobs follow player when holding any of the items which appear
on this table, the same items can be fed to a mob to tame or on this table, the same items can be fed to a mob to tame or
@ -399,6 +401,8 @@ This function registers a arrow for mobs with the attack type shoot.
'hit_mob' a function that is called when the arrow hits a mob; 'hit_mob' a function that is called when the arrow hits a mob;
this function should hurt the mob, the parameters are this function should hurt the mob, the parameters are
(self, player) (self, player)
'hit_object' a function that is called when the arrow hits an object;
this function parameters are (self, player)
'hit_node' a function that is called when the arrow hits a node, the 'hit_node' a function that is called when the arrow hits a node, the
parameters are (self, pos, node) parameters are (self, pos, node)
'tail' when set to 1 adds a trail or tail to mob arrows 'tail' when set to 1 adds a trail or tail to mob arrows
@ -628,6 +632,7 @@ External Settings for "minetest.conf"
'mobs_griefing' when false mobs cannot break blocks when using either 'mobs_griefing' when false mobs cannot break blocks when using either
pathfinding level 2, replace functions or mobs:boom pathfinding level 2, replace functions or mobs:boom
function. function.
'mob_nospawn_range' Minimum range a mob can spawn near player (def: 12)
Players can override the spawn chance for each mob registered by adding a line Players can override the spawn chance for each mob registered by adding a line
to their minetest.conf file with a new value, the lower the value the more each to their minetest.conf file with a new value, the lower the value the more each

View File

@ -131,6 +131,10 @@ minetest.register_craft({
} }
}) })
-- make sure we can register fences
if default.register_fence then
-- mob fence (looks like normal fence but collision is 2 high) -- mob fence (looks like normal fence but collision is 2 high)
default.register_fence("mobs:fence_wood", { default.register_fence("mobs:fence_wood", {
description = S("Mob Fence"), description = S("Mob Fence"),
@ -177,6 +181,9 @@ minetest.register_craft({
} }
}) })
end
-- items that can be used as fuel -- items that can be used as fuel
minetest.register_craft({ minetest.register_craft({
type = "fuel", type = "fuel",
@ -220,6 +227,7 @@ minetest.register_craft({
burntime = 2 burntime = 2
}) })
-- this tool spawns same mob and adds owner, protected, nametag info -- this tool spawns same mob and adds owner, protected, nametag info
-- then removes original entity, this is used for fixing any issues. -- then removes original entity, this is used for fixing any issues.

View File

@ -131,7 +131,7 @@ function mobs.attach(entity, player)
local rot_view = 0 local rot_view = 0
if entity.player_rotation.y == 90 then if entity.player_rotation.y == 90 then
rot_view = math.pi/2 rot_view = math.pi / 2
end end
attach_at = entity.driver_attach_at attach_at = entity.driver_attach_at
@ -151,11 +151,13 @@ function mobs.attach(entity, player)
} }
}) })
minetest.after(0.2, function() minetest.after(0.2, function(name)
default.player_set_animation(player, "sit" , 30) local player = minetest.get_player_by_name(name)
end) if player then
default.player_set_animation(player, "sit" , 30)
end
end, player:get_player_name())
--player:set_look_yaw(entity.object:get_yaw() - rot_view)
player:set_look_horizontal(entity.object:get_yaw() - rot_view) player:set_look_horizontal(entity.object:get_yaw() - rot_view)
end end
@ -168,11 +170,18 @@ function mobs.detach(player, offset)
local pos = player:get_pos() local pos = player:get_pos()
pos = {x = pos.x + offset.x, y = pos.y + 0.2 + offset.y, z = pos.z + offset.z} pos = {
x = pos.x + offset.x,
y = pos.y + 0.2 + offset.y,
z = pos.z + offset.z
}
minetest.after(0.1, function() minetest.after(0.1, function(name, pos)
player:set_pos(pos) local player = minetest.get_player_by_name(name)
end) if player then
player:set_pos(pos)
end
end, player:get_player_name(), pos)
end end
@ -290,7 +299,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
-- Set position, velocity and acceleration -- Set position, velocity and acceleration
local p = entity.object:get_pos() local p = entity.object:get_pos()
local new_velo = {x = 0, y = 0, z = 0} local new_velo
local new_acce = {x = 0, y = -9.8, z = 0} local new_acce = {x = 0, y = -9.8, z = 0}
p.y = p.y - 0.5 p.y = p.y - 0.5
@ -315,7 +324,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
minetest.sound_play("default_punch", { minetest.sound_play("default_punch", {
object = entity.object, object = entity.object,
max_hear_distance = 5 max_hear_distance = 5
}) }, true)
entity.object:punch(entity.object, 1.0, { entity.object:punch(entity.object, 1.0, {
full_punch_interval = 1.0, full_punch_interval = 1.0,

View File

@ -23,7 +23,8 @@ Lucky Blocks: 9
Changelog: Changelog:
- 1.50 - Added new line_of_sight function that uses raycasting if mt5.0 is found (thanks Astrobe), dont spawn mobs if world anchor nearby (technic or simple_anchor mods), chinese local added - 1.51 - Added some node checks for dangerous nodes, jumping and falling tweaks, spawn area check (thx for idea wuzzy), re-enabled mob suffocation, add 'mob_nospawn_range' setting
- 1.50 - Added new line_of_sight function that uses raycasting if mt5.0 is found, (thanks Astrobe), dont spawn mobs if world anchor nearby (technic or simple_anchor mods), chinese local added
- 1.49- Added mobs:force_capture(self, player) function, api functions now use metatables thanks to bell07 - 1.49- Added mobs:force_capture(self, player) function, api functions now use metatables thanks to bell07
- 1.48- Add mobs:set_velocity(self, velocity) global function - 1.48- Add mobs:set_velocity(self, velocity) global function
- 1.47- Mob damage changes, min and max light level for damage added, ignition sources checked for lava damage - 1.47- Mob damage changes, min and max light level for damage added, ignition sources checked for lava damage

View File

@ -27,3 +27,6 @@ mob_chance_multiplier (Mob chance multiplier) float 1.0
# When false Mob no longer drop items when killed # When false Mob no longer drop items when killed
mobs_drop_items (Mob drops) bool true mobs_drop_items (Mob drops) bool true
#....Sets minimum distance around player that mobs cannot spawn
mob_nospawn_range (Mob no-spawn range) float 12.0