Compare commits
No commits in common. "a6363f779fa1169aed5eb1752b5e3cf34cc5b94f" and "b8250e4dcc38df03b5b87a5065d995d5864ba8ca" have entirely different histories.
a6363f779f
...
b8250e4dcc
|
@ -717,8 +717,6 @@ function mcl_util.gen_uuid()
|
|||
return table.concat(u)
|
||||
end
|
||||
function mcl_util.get_entity_id(entity)
|
||||
if entity.object then entity = entity.object end
|
||||
|
||||
if entity:is_player() then
|
||||
return entity:get_player_name()
|
||||
else
|
||||
|
|
|
@ -385,9 +385,7 @@ end
|
|||
function mcl_mobs.register_arrow(name, def)
|
||||
if not name or not def then return end -- errorcheck
|
||||
|
||||
local behaviors = {
|
||||
vl_projectile.has_owner_grace_distance
|
||||
}
|
||||
local behaviors = {}
|
||||
if def.hit_node then
|
||||
table.insert(behaviors, vl_projectile.collides_with_solids)
|
||||
end
|
||||
|
|
|
@ -46,6 +46,7 @@ local arrow_entity = {
|
|||
"last_pos", "startpos", "damage", "is_critical", "stuck", "stuckin", "stuckin_player", "time_in_air", "vl_projectile",
|
||||
},
|
||||
|
||||
_startpos=nil,
|
||||
_damage=1, -- Damage on impact
|
||||
_is_critical=false, -- Whether this arrow would deal critical damage
|
||||
_stuck=false, -- Whether arrow is stuck
|
||||
|
@ -75,10 +76,12 @@ local arrow_entity = {
|
|||
vl_projectile.sticks,
|
||||
vl_projectile.burns,
|
||||
vl_projectile.has_tracer,
|
||||
vl_projectile.has_owner_grace_distance,
|
||||
|
||||
-- Custom arrow behaviors
|
||||
function(self, dtime)
|
||||
local pos = self.object:get_pos()
|
||||
self._allow_punch = self._allow_punch or not self._owner or not self._startpos or pos and vector.distance(self._startpos, pos) > 1.5
|
||||
|
||||
if self._deflection_cooloff > 0 then
|
||||
self._deflection_cooloff = self._deflection_cooloff - dtime
|
||||
end
|
||||
|
@ -88,6 +91,8 @@ local arrow_entity = {
|
|||
vl_projectile.raycast_collides_with_entities,
|
||||
},
|
||||
allow_punching = function(self, entity_def, projectile_def, object)
|
||||
if not self._allow_punch then return false end
|
||||
|
||||
local lua = object:get_luaentity()
|
||||
if lua and lua.name == "mobs_mc:rover" then return false end
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ function mcl_bows.shoot_arrow(arrow_item, pos, dir, yaw, shooter, power, damage,
|
|||
le._source_object = shooter
|
||||
le._damage = damage
|
||||
le._is_critical = is_critical
|
||||
le._startpos = pos
|
||||
le._knockback = knockback
|
||||
le._collectable = collectable
|
||||
le._arrow_item = arrow_item
|
||||
|
|
|
@ -272,8 +272,8 @@ rocket_entity.on_step = function(self, dtime)
|
|||
return
|
||||
end
|
||||
|
||||
-- Perform normal projectile behaviors
|
||||
vl_projectile.update_projectile(self, dtime)
|
||||
-- Perform normal arrow behaviors
|
||||
arrow_entity.on_step(self, dtime)
|
||||
end
|
||||
|
||||
vl_projectile.register("mcl_bows:rocket_entity", rocket_entity)
|
||||
|
|
|
@ -208,7 +208,6 @@ function mcl_potions.register_lingering(name, descr, color, def)
|
|||
pointable = false,
|
||||
_vl_projectile = {
|
||||
behaviors = {
|
||||
vl_projectile.has_owner_grace_distance,
|
||||
vl_projectile.collides_with_entities,
|
||||
vl_projectile.collides_with_solids,
|
||||
},
|
||||
|
|
|
@ -176,7 +176,6 @@ function mcl_potions.register_splash(name, descr, color, def)
|
|||
collisionbox = {-0.1,-0.1,-0.1,0.1,0.1,0.1},
|
||||
_vl_projectile = {
|
||||
behaviors = {
|
||||
vl_projectile.has_owner_grace_distance,
|
||||
vl_projectile.collides_with_entities,
|
||||
vl_projectile.collides_with_solids,
|
||||
},
|
||||
|
|
|
@ -215,13 +215,6 @@ function mod.burns(self, dtime, entity_def, projectile_def)
|
|||
end
|
||||
end
|
||||
|
||||
function mod.has_owner_grace_distance(self, dtime, entity_def, projectile_def)
|
||||
local pos = self.object:get_pos()
|
||||
|
||||
self._allow_punch = self._allow_punch or
|
||||
not self._owner or not self._startpos or
|
||||
pos and vector.distance(self._startpos, pos) > ( projectile_def.grace_distance or 1.5 )
|
||||
end
|
||||
function mod.has_tracer(self, dtime, entity_def, projectile_def)
|
||||
local hide_tracer = projectile_def.hide_tracer
|
||||
if hide_tracer and hide_tracer(self) then return end
|
||||
|
@ -600,11 +593,10 @@ function mod.create(entity_id, options)
|
|||
local luaentity = obj:get_luaentity()
|
||||
if options.owner_id then
|
||||
luaentity._owner = options.owner_id
|
||||
elseif options.owner then
|
||||
else
|
||||
luaentity._owner = mcl_util.get_entity_id(options.owner)
|
||||
end
|
||||
luaentity._starting_velocity = obj:get_velocity()
|
||||
luaentity._startpos = pos
|
||||
luaentity._vl_projectile = {
|
||||
extra = options.extra,
|
||||
}
|
||||
|
@ -614,29 +606,11 @@ function mod.create(entity_id, options)
|
|||
end
|
||||
|
||||
function mod.register(name, def)
|
||||
def_vl_projectile = def._vl_projectile
|
||||
assert(def_vl_projectile, "vl_projectile.register() requires definition to define _vl_projectile")
|
||||
local behaviors = def_vl_projectile.behaviors
|
||||
|
||||
assert(behaviors, "vl_projectile.register() requires definition to define _vl_projectile.behaviors")
|
||||
assert(def._vl_projectile, "vl_projectile.register() requires definition to define _vl_projectile")
|
||||
assert(def._vl_projectile.behaviors, "vl_projectile.register() requires definition to define _vl_projectile.behaviors")
|
||||
local behaviors = def._vl_projectile.behaviors
|
||||
for i = 1,#behaviors do
|
||||
assert(behaviors[i] and type(behaviors[i]) == "function", "def._vl_projectile.behaviors["..i.." is malformed")
|
||||
if behaviors[i] == vl_projectile.has_owner_grace_distance then
|
||||
local old_allow_punching = def_vl_projectile.allow_punching
|
||||
if old_allow_punching then
|
||||
def_vl_projectile.allow_punching = function(self, ...)
|
||||
if not self._allow_punch then return false end
|
||||
|
||||
return old_allow_punching(self, ...)
|
||||
end
|
||||
else
|
||||
def_vl_projectile.allow_punching = function(self, ...)
|
||||
if not self._allow_punch then return false end
|
||||
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not def.on_step then
|
||||
|
|
Loading…
Reference in New Issue