arrow entity check, glow and expire added to arrows

This commit is contained in:
TenPlus1 2017-01-20 09:32:51 +00:00
parent 6eb6e458af
commit 52a2355954
3 changed files with 24 additions and 3295 deletions

52
api.lua
View File

@ -1,5 +1,5 @@
-- Mobs Api (19th January 2017) -- Mobs Api (20th January 2017)
mobs = {} mobs = {}
mobs.mod = "redo" mobs.mod = "redo"
@ -1893,19 +1893,21 @@ local do_states = function(self, dtime)
p.y = p.y + (self.collisionbox[2] + self.collisionbox[5]) / 2 p.y = p.y + (self.collisionbox[2] + self.collisionbox[5]) / 2
local obj = minetest.add_entity(p, self.arrow) local obj = minetest.add_entity(p, self.arrow)
local ent = obj:get_luaentity() if obj then
local amount = (vec.x * vec.x + vec.y * vec.y + vec.z * vec.z) ^ 0.5 local ent = obj:get_luaentity()
local v = ent.velocity or 1 -- or set to default local amount = (vec.x * vec.x + vec.y * vec.y + vec.z * vec.z) ^ 0.5
ent.switch = 1 local v = ent.velocity or 1 -- or set to default
ent.owner_id = tostring(self.object) -- add unique owner id to arrow ent.switch = 1
ent.owner_id = tostring(self.object) -- add unique owner id to arrow
-- offset makes shoot aim accurate -- offset makes shoot aim accurate
vec.y = vec.y + self.shoot_offset vec.y = vec.y + self.shoot_offset
vec.x = vec.x * (v / amount) vec.x = vec.x * (v / amount)
vec.y = vec.y * (v / amount) vec.y = vec.y * (v / amount)
vec.z = vec.z * (v / amount) vec.z = vec.z * (v / amount)
obj:setvelocity(vec) obj:setvelocity(vec)
end
end end
end end
end end
@ -2886,25 +2888,15 @@ function mobs:register_arrow(name, def)
and def.tail == 1 and def.tail == 1
and def.tail_texture then and def.tail_texture then
-- effect(pos, 1, def.tail_texture, minetest.add_particle({
-- def.tail_size or 5, pos = pos,
-- def.tail_size or 10, velocity = {x = 0, y = 0, z = 0},
-- 0, 0) -- 0 radius and 0 gravity to just hover acceleration = {x = 0, y = 0, z = 0},
expirationtime = def.expire or 0.25,
minetest.add_particlespawner({ collisiondetection = false,
amount = 1,
time = 0.25,
minpos = pos,
maxpos = pos,
minvel = {x = 0, y = 0, z = 0},
maxvel = {x = 0, y = 0, z = 0},
minacc = {x = 0, y = 0, z = 0},
maxacc = {x = 0, y = 0, z = 0},
minexptime = 0.1,
maxexptime = 1,
minsize = def.tail_size or 5,
maxsize = def.tail_size or 10,
texture = def.tail_texture, texture = def.tail_texture,
size = def.tail_size or 5,
glow = def.glow or 0,
}) })
end end

File diff suppressed because it is too large Load Diff

View File

@ -194,6 +194,8 @@ This function registers a arrow for mobs with the attack type shoot.
'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
'tail_texture' texture string used for above effect 'tail_texture' texture string used for above effect
'tail_size' has size for above texture (defaults to between 5 and 10) 'tail_size' has size for above texture (defaults to between 5 and 10)
'expire' contains float value for how long tail appears for (defaults to 0.25)
'glow' has value for how brightly tail glows 1 to 10 (default is 0, no glow)
'on_step' is a custom function when arrow is active, nil for default. 'on_step' is a custom function when arrow is active, nil for default.