1
0
Fork 0

Randomize projectile cooldown timer

This commit is contained in:
jordan4ibanez 2021-04-23 14:34:59 -04:00
parent 8eb9ba12ce
commit 16cc7e37d2
2 changed files with 11 additions and 9 deletions

View File

@ -328,8 +328,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 +358,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,

View File

@ -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