mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-26 04:21:07 +01:00
Randomize projectile cooldown timer
This commit is contained in:
parent
8eb9ba12ce
commit
16cc7e37d2
2 changed files with 11 additions and 9 deletions
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue