From 16cc7e37d2fc83e50d4e2c380cef05224dbbed38 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Fri, 23 Apr 2021 14:34:59 -0400 Subject: [PATCH] Randomize projectile cooldown timer --- mods/ENTITIES/mcl_mobs/api/api.lua | 11 ++++++----- .../api/mob_functions/attack_type_instructions.lua | 9 +++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api/api.lua b/mods/ENTITIES/mcl_mobs/api/api.lua index c7d92c1e66..b1ea2d1e97 100644 --- a/mods/ENTITIES/mcl_mobs/api/api.lua +++ b/mods/ENTITIES/mcl_mobs/api/api.lua @@ -328,8 +328,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 +358,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, diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/attack_type_instructions.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/attack_type_instructions.lua index ac5561adbf..7907f8c47d 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/attack_type_instructions.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/attack_type_instructions.lua @@ -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