mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-07-24 11:00:24 +02:00
Compare commits
3 Commits
412066fc07
...
be7b6bc5fe
Author | SHA1 | Date | |
---|---|---|---|
be7b6bc5fe | |||
68076c7626 | |||
099d15d810 |
108
api.lua
108
api.lua
@ -14,7 +14,7 @@ local use_vh1 = minetest.get_modpath("visual_harm_1ndicators")
|
||||
-- Global
|
||||
mobs = {
|
||||
mod = "redo",
|
||||
version = "20231120",
|
||||
version = "20231205",
|
||||
translate = S,
|
||||
invis = minetest.global_exists("invisibility") and invisibility or {},
|
||||
node_snow = minetest.registered_aliases["mapgen_snow"]
|
||||
@ -2657,7 +2657,6 @@ function mob_class:do_states(dtime)
|
||||
|
||||
local v = ent.velocity or 1 -- or set to default
|
||||
|
||||
ent.switch = 1
|
||||
ent.owner_id = tostring(self.object) -- add unique owner id to arrow
|
||||
|
||||
-- setup homing arrow and target
|
||||
@ -3570,6 +3569,7 @@ minetest.register_entity(":" .. name, setmetatable({
|
||||
|
||||
name = name,
|
||||
type = def.type,
|
||||
_nametag = def.nametag,
|
||||
attack_type = def.attack_type,
|
||||
fly = def.fly,
|
||||
fly_in = def.fly_in,
|
||||
@ -4161,7 +4161,7 @@ function mobs:register_arrow(name, def)
|
||||
|
||||
initial_properties = {
|
||||
|
||||
physical = def.physical or false,
|
||||
physical = def.physical,
|
||||
collide_with_objects = def.collide_with_objects or false,
|
||||
static_save = false,
|
||||
visual = def.visual,
|
||||
@ -4181,7 +4181,6 @@ function mobs:register_arrow(name, def)
|
||||
drop = def.drop or false, -- drops arrow as registered item when true
|
||||
timer = 0,
|
||||
lifetime = def.lifetime or 4.5,
|
||||
switch = 0,
|
||||
owner_id = def.owner_id,
|
||||
rotate = def.rotate,
|
||||
|
||||
@ -4196,7 +4195,7 @@ function mobs:register_arrow(name, def)
|
||||
|
||||
local pos = self.object:get_pos()
|
||||
|
||||
if self.switch == 0 or self.timer > self.lifetime then
|
||||
if self.timer > self.lifetime then
|
||||
|
||||
self.object:remove() ; -- print("removed arrow")
|
||||
|
||||
@ -4218,29 +4217,6 @@ function mobs:register_arrow(name, def)
|
||||
})
|
||||
end
|
||||
|
||||
if self.hit_node then
|
||||
|
||||
local node = node_ok(pos).name
|
||||
|
||||
if minetest.registered_nodes[node].walkable then
|
||||
|
||||
self:hit_node(pos, node)
|
||||
|
||||
if self.drop == true then
|
||||
|
||||
pos.y = pos.y + 1
|
||||
|
||||
self.lastpos = (self.lastpos or pos)
|
||||
|
||||
minetest.add_item(self.lastpos, self.object:get_luaentity().name)
|
||||
end
|
||||
|
||||
self.object:remove() ; -- print("hit node")
|
||||
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- make homing arrows follow target if seen
|
||||
if self._homing_target then
|
||||
|
||||
@ -4258,48 +4234,90 @@ function mobs:register_arrow(name, def)
|
||||
end
|
||||
end
|
||||
|
||||
if self.hit_player or self.hit_mob or self.hit_object then
|
||||
-- raycasting
|
||||
self.lastpos = self.lastpos or pos
|
||||
|
||||
for _,player in pairs(minetest.get_objects_inside_radius(pos, 1.0)) do
|
||||
local cast = minetest.raycast(self.lastpos, pos, true, true)
|
||||
local thing = cast:next()
|
||||
|
||||
if self.hit_player and is_player(player) then
|
||||
-- loop through things
|
||||
while thing do
|
||||
|
||||
self:hit_player(player)
|
||||
-- if inside object that isn't arrow
|
||||
if thing.type == "object" and thing.ref ~= self.object
|
||||
and tostring(thing.ref) ~= self.owner_id then
|
||||
|
||||
self.object:remove() ; -- print("hit player")
|
||||
if self.hit_player and is_player(thing.ref) then
|
||||
|
||||
self:hit_player(thing.ref)
|
||||
|
||||
self.object:remove()
|
||||
|
||||
--print("hit player", thing.ref:get_player_name())
|
||||
|
||||
return
|
||||
|
||||
end
|
||||
|
||||
local entity = player:get_luaentity()
|
||||
local entity = thing.ref:get_luaentity()
|
||||
|
||||
if entity
|
||||
and self.hit_mob
|
||||
and entity._cmi_is_mob == true
|
||||
and tostring(player) ~= self.owner_id
|
||||
and entity.name ~= self.object:get_luaentity().name then
|
||||
and entity._cmi_is_mob == true then
|
||||
|
||||
self:hit_mob(player)
|
||||
self:hit_mob(thing.ref)
|
||||
|
||||
self.object:remove() ; -- print("hit mob")
|
||||
self.object:remove()
|
||||
|
||||
--print("hit mob", entity.name)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if entity
|
||||
and self.hit_object
|
||||
and (not entity._cmi_is_mob)
|
||||
and tostring(player) ~= self.owner_id
|
||||
and entity.name ~= self.object:get_luaentity().name then
|
||||
and (not entity._cmi_is_mob) then
|
||||
|
||||
self:hit_object(player)
|
||||
self:hit_object(thing.ref)
|
||||
|
||||
self.object:remove() ; -- print("hit object")
|
||||
self.object:remove()
|
||||
|
||||
--print("hit object", entity.name)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- if inside node
|
||||
if thing.type == "node" and self.hit_node then
|
||||
|
||||
local node = minetest.get_node(pos)
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
|
||||
if def and def.walkable then
|
||||
|
||||
self:hit_node(pos, node)
|
||||
|
||||
if self.drop == true then
|
||||
|
||||
pos.y = pos.y + 1
|
||||
|
||||
minetest.add_item(self.lastpos,
|
||||
self.object:get_luaentity().name)
|
||||
end
|
||||
|
||||
self.object:remove()
|
||||
|
||||
--print("hit node", node.name)
|
||||
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
thing = cast:next()
|
||||
|
||||
end -- end thing loop
|
||||
|
||||
self.lastpos = pos
|
||||
end
|
||||
|
3
api.txt
3
api.txt
@ -539,7 +539,6 @@ This function registers a arrow for mobs with the attack type shoot.
|
||||
'visual' same is in minetest.register_entity()
|
||||
'visual_size' same is in minetest.register_entity()
|
||||
'textures' same is in minetest.register_entity()
|
||||
'physical' same is in minetest.register_entity() [default: false]
|
||||
'collide_with_objects' same as above
|
||||
'velocity' the velocity of the arrow
|
||||
'drop' if set to true any arrows hitting a node will drop as item
|
||||
@ -562,7 +561,7 @@ This function registers a arrow for mobs with the attack type shoot.
|
||||
0 for no glow)
|
||||
'rotate' integer value in degrees to rotate arrow
|
||||
'on_step' is a custom function when arrow is active, nil for
|
||||
default.
|
||||
default. (self, dtime, moveresult)
|
||||
'on_punch' is a custom function when arrow is punched, nil by default
|
||||
'collisionbox' is hitbox table for arrow, {-.1,-.1,-.1,.1,.1,.1} by default.
|
||||
'lifetime' contains float value for how many seconds arrow exists in
|
||||
|
Reference in New Issue
Block a user