Merge pull request 'Fixes to mobs' (#1618) from jordan4ibanez/MineClone2:mineclone5 into mineclone5

Reviewed-on: MineClone2/MineClone2#1618
This commit is contained in:
jordan4ibanez 2021-04-23 18:50:10 +00:00
commit 7faf2460b7
3 changed files with 16 additions and 13 deletions

View File

@ -45,6 +45,7 @@ local math_floor = math.floor
-- localize vector functions
local vector_new = vector.new
local vector_add = vector.add
local vector_length = vector.length
local vector_direction = vector.direction
local vector_normalize = vector.normalize
@ -328,8 +329,13 @@ function mobs:register_mob(name, def)
attacking = nil,
visual_size_origin = def.visual_size or {x = 1, y = 1, z = 1},
punch_timer_cooloff = def.punch_timer_cooloff or 0.5,
projectile_cooldown = def.projectile_cooldown or 2,
death_animation_timer = 0,
hostile_cooldown = def.hostile_cooldown or 15,
tilt_fly = def.tilt_fly,
tilt_swim = def.tilt_swim,
fall_slow = def.fall_slow,
projectile_cooldown_min = def.projectile_cooldown_min or 2,
projectile_cooldown_max = def.projectile_cooldown_max or 6,
--end j4i stuff
-- MCL2 extensions
@ -353,10 +359,6 @@ function mobs:register_mob(name, def)
ignited_by_sunlight = def.ignited_by_sunlight or false,
eye_height = def.eye_height or 1.5,
defuse_reach = def.defuse_reach or 4,
hostile_cooldown = def.hostile_cooldown or 15,
tilt_fly = def.tilt_fly,
tilt_swim = def.tilt_swim,
fall_slow = def.fall_slow,
-- End of MCL2 extensions
on_spawn = def.on_spawn,
@ -478,9 +480,7 @@ function mobs:register_arrow(name, def)
if self.timer > 150
or not mobs.within_limits(pos, 0) then
mcl_burning.extinguish(self.object)
print("removing 1")
self.object:remove();
return
end
@ -489,8 +489,10 @@ function mobs:register_arrow(name, def)
and def.tail == 1
and def.tail_texture then
--do this to prevent clipping through main entity sprite
local new_pos = vector_add(pos, vector_multiply(vector_normalize(vel), -1))
minetest.add_particle({
pos = pos,
pos = new_pos,
velocity = {x = 0, y = 0, z = 0},
acceleration = {x = 0, y = 0, z = 0},
expirationtime = def.expire or 0.25,

View File

@ -2,6 +2,7 @@ local vector_direction = vector.direction
local minetest_dir_to_yaw = minetest.dir_to_yaw
local vector_distance = vector.distance
local vector_multiply = vector.multiply
local math_random = math.random
--[[
_ _ _ _
@ -208,7 +209,7 @@ mobs.projectile_attack_walk = function(self,dtime)
--do this to not load data into other mobs
if not self.projectile_timer then
self.projectile_timer = self.projectile_cooldown
self.projectile_timer = math_random(self.projectile_cooldown_min, self.projectile_cooldown_max)
end
--run projectile timer
@ -218,7 +219,7 @@ mobs.projectile_attack_walk = function(self,dtime)
--shoot
if self.projectile_timer <= 0 then
--reset timer
self.projectile_timer = self.projectile_cooldown
self.projectile_timer = math_random(self.projectile_cooldown_min, self.projectile_cooldown_max)
mobs.shoot_projectile(self)
end
end
@ -291,7 +292,7 @@ mobs.projectile_attack_fly = function(self, dtime)
--do this to not load data into other mobs
if not self.projectile_timer then
self.projectile_timer = self.projectile_cooldown
self.projectile_timer = math_random(self.projectile_cooldown_min, self.projectile_cooldown_max)
end
--run projectile timer
@ -301,7 +302,7 @@ mobs.projectile_attack_fly = function(self, dtime)
--shoot
if self.projectile_timer <= 0 then
--reset timer
self.projectile_timer = self.projectile_cooldown
self.projectile_timer = math_random(self.projectile_cooldown_min, self.projectile_cooldown_max)
mobs.shoot_projectile(self)
end
end

View File

@ -39,7 +39,7 @@ mobs.collision = function(self)
end
for _,object in ipairs(minetest_get_objects_inside_radius(pos, radius*1.25)) do
if object and object ~= self.object and (object:is_player() or object:get_luaentity()._cmi_is_mob == true) then--and
if object and object ~= self.object and (object:is_player() or (object:get_luaentity() and object:get_luaentity()._cmi_is_mob == true)) then--and
--don't collide with rider, rider don't collide with thing
--(not object:get_attach() or (object:get_attach() and object:get_attach() ~= self.object)) and
--(not self.object:get_attach() or (self.object:get_attach() and self.object:get_attach() ~= object)) then