Merge pull request 'Fixes to mobs' (#1618) from jordan4ibanez/MineClone2:mineclone5 into mineclone5
Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/1618mineclone5
commit
7faf2460b7
|
@ -45,6 +45,7 @@ local math_floor = math.floor
|
||||||
|
|
||||||
-- localize vector functions
|
-- localize vector functions
|
||||||
local vector_new = vector.new
|
local vector_new = vector.new
|
||||||
|
local vector_add = vector.add
|
||||||
local vector_length = vector.length
|
local vector_length = vector.length
|
||||||
local vector_direction = vector.direction
|
local vector_direction = vector.direction
|
||||||
local vector_normalize = vector.normalize
|
local vector_normalize = vector.normalize
|
||||||
|
@ -328,8 +329,13 @@ function mobs:register_mob(name, def)
|
||||||
attacking = nil,
|
attacking = nil,
|
||||||
visual_size_origin = def.visual_size or {x = 1, y = 1, z = 1},
|
visual_size_origin = def.visual_size or {x = 1, y = 1, z = 1},
|
||||||
punch_timer_cooloff = def.punch_timer_cooloff or 0.5,
|
punch_timer_cooloff = def.punch_timer_cooloff or 0.5,
|
||||||
projectile_cooldown = def.projectile_cooldown or 2,
|
|
||||||
death_animation_timer = 0,
|
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
|
--end j4i stuff
|
||||||
|
|
||||||
-- MCL2 extensions
|
-- MCL2 extensions
|
||||||
|
@ -353,10 +359,6 @@ function mobs:register_mob(name, def)
|
||||||
ignited_by_sunlight = def.ignited_by_sunlight or false,
|
ignited_by_sunlight = def.ignited_by_sunlight or false,
|
||||||
eye_height = def.eye_height or 1.5,
|
eye_height = def.eye_height or 1.5,
|
||||||
defuse_reach = def.defuse_reach or 4,
|
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
|
-- End of MCL2 extensions
|
||||||
|
|
||||||
on_spawn = def.on_spawn,
|
on_spawn = def.on_spawn,
|
||||||
|
@ -478,9 +480,7 @@ function mobs:register_arrow(name, def)
|
||||||
if self.timer > 150
|
if self.timer > 150
|
||||||
or not mobs.within_limits(pos, 0) then
|
or not mobs.within_limits(pos, 0) then
|
||||||
mcl_burning.extinguish(self.object)
|
mcl_burning.extinguish(self.object)
|
||||||
print("removing 1")
|
|
||||||
self.object:remove();
|
self.object:remove();
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -489,8 +489,10 @@ function mobs:register_arrow(name, def)
|
||||||
and def.tail == 1
|
and def.tail == 1
|
||||||
and def.tail_texture then
|
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({
|
minetest.add_particle({
|
||||||
pos = pos,
|
pos = new_pos,
|
||||||
velocity = {x = 0, y = 0, z = 0},
|
velocity = {x = 0, y = 0, z = 0},
|
||||||
acceleration = {x = 0, y = 0, z = 0},
|
acceleration = {x = 0, y = 0, z = 0},
|
||||||
expirationtime = def.expire or 0.25,
|
expirationtime = def.expire or 0.25,
|
||||||
|
|
|
@ -2,6 +2,7 @@ local vector_direction = vector.direction
|
||||||
local minetest_dir_to_yaw = minetest.dir_to_yaw
|
local minetest_dir_to_yaw = minetest.dir_to_yaw
|
||||||
local vector_distance = vector.distance
|
local vector_distance = vector.distance
|
||||||
local vector_multiply = vector.multiply
|
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
|
--do this to not load data into other mobs
|
||||||
if not self.projectile_timer then
|
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
|
end
|
||||||
|
|
||||||
--run projectile timer
|
--run projectile timer
|
||||||
|
@ -218,7 +219,7 @@ mobs.projectile_attack_walk = function(self,dtime)
|
||||||
--shoot
|
--shoot
|
||||||
if self.projectile_timer <= 0 then
|
if self.projectile_timer <= 0 then
|
||||||
--reset timer
|
--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)
|
mobs.shoot_projectile(self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -291,7 +292,7 @@ mobs.projectile_attack_fly = function(self, dtime)
|
||||||
|
|
||||||
--do this to not load data into other mobs
|
--do this to not load data into other mobs
|
||||||
if not self.projectile_timer then
|
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
|
end
|
||||||
|
|
||||||
--run projectile timer
|
--run projectile timer
|
||||||
|
@ -301,7 +302,7 @@ mobs.projectile_attack_fly = function(self, dtime)
|
||||||
--shoot
|
--shoot
|
||||||
if self.projectile_timer <= 0 then
|
if self.projectile_timer <= 0 then
|
||||||
--reset timer
|
--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)
|
mobs.shoot_projectile(self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -39,7 +39,7 @@ mobs.collision = function(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
for _,object in ipairs(minetest_get_objects_inside_radius(pos, radius*1.25)) do
|
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
|
--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 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
|
--(not self.object:get_attach() or (self.object:get_attach() and self.object:get_attach() ~= object)) then
|
||||||
|
|
Loading…
Reference in New Issue