Make occurences in code that obv want floating p results use mcl_util.float_random

This commit is contained in:
cora 2024-08-20 06:38:55 +02:00
parent 53622c7339
commit 113d9abbb5
No known key found for this signature in database
10 changed files with 24 additions and 23 deletions

View File

@ -92,7 +92,7 @@ function mcl_charges.wind_burst(pos, radius)
local dist = math.max(1, vector.distance(pos, obj_pos))
if obj:is_player() then
obj:add_velocity(vector.multiply(vector.normalize(vector.subtract(obj_pos, pos)), math.random(1.8, 2.0) / dist * RADIUS))
obj:add_velocity(vector.multiply(vector.normalize(vector.subtract(obj_pos, pos)), mcl_util.float_random(1.8, 2.0) / dist * RADIUS))
else
local luaobj = obj:get_luaentity()
if luaobj then

View File

@ -1,5 +1,4 @@
name = mcl_charges
description = Adds Code to easily register throwable charges like the wind charge
depends = mcl_mobs, mcl_doors, mcl_fences
optional_depends = mobs_mc
depends = mcl_util, mcl_mobs, mcl_doors, mcl_fences, mobs_mc
title = MCL Charges

View File

@ -899,7 +899,7 @@ function mob_class:do_states_stand()
yaw = yaw + math.pi
end
else
yaw = yaw + math.random(-YAW_RAD, YAW_RAD)
yaw = yaw + mcl_util.float_random(-YAW_RAD, YAW_RAD)
end
self:set_yaw(yaw, 8)
--[[ else
@ -1161,7 +1161,7 @@ function mob_class:turn_away(delay)
end
local yaw = self.object:get_yaw() or 0
local turn = math.random(YAW_RAD / 2, YAW_RAD)
local turn = mcl_util.float_random(YAW_RAD / 2, YAW_RAD)
if math.random() < 0.5 then
turn = -turn
end

View File

@ -97,11 +97,14 @@ mcl_mobs.register_mob("mobs_mc:blaze", {
mcl_burning.set_on_fire(self.attack, 5)
end
local pos = self.object:get_pos()
if not self:check_timer("blaze_particles", mcl_util.float_random(0.5, 2)) then return end
minetest.add_particle({
pos = {x=pos.x+math.random(-0.7,0.7)*math.random()/2,y=pos.y+math.random(0.7,1.2),z=pos.z+math.random(-0.7,0.7)*math.random()/2},
velocity = {x=0, y=math.random(1,1), z=0},
pos = {x = pos.x+mcl_util.float_random(-0.7,0.7) * math.random()/2, y = pos.y+mcl_util.float_random(0.7,1.2), z = pos.z+mcl_util.float_random(-0.7,0.7) * math.random()/2},
velocity = {x=0, y = mcl_util.float_random(0.5, 2), z=0},
expirationtime = math.random(),
size = math.random(1, 4),
size = mcl_util.float_random(1, 4),
collisiondetection = true,
vertical = false,
texture = "mcl_particles_smoke_anim.png^[colorize:#2c2c2c:255",
@ -113,10 +116,10 @@ mcl_mobs.register_mob("mobs_mc:blaze", {
},
})
minetest.add_particle({
pos = {x=pos.x+math.random(-0.7,0.7)*math.random()/2,y=pos.y+math.random(0.7,1.2),z=pos.z+math.random(-0.7,0.7)*math.random()/2},
velocity = {x=0, y=math.random(1,1), z=0},
pos = {x = pos.x+mcl_util.float_random(-0.7,0.7)* math.random()/2, y = pos.y+mcl_util.float_random(0.7,1.2), z = pos.z+mcl_util.float_random(-0.7,0.7) * math.random()/2},
velocity = {x=0, y = mcl_util.float_random(0.5, 2), z=0},
expirationtime = math.random(),
size = math.random(1, 4),
size = mcl_util.float_random(1, 4),
collisiondetection = true,
vertical = false,
texture = "mcl_particles_smoke_anim.png^[colorize:#424242:255",
@ -128,10 +131,10 @@ mcl_mobs.register_mob("mobs_mc:blaze", {
},
})
minetest.add_particle({
pos = {x=pos.x+math.random(-0.7,0.7)*math.random()/2,y=pos.y+math.random(0.7,1.2),z=pos.z+math.random(-0.7,0.7)*math.random()/2},
velocity = {x=0, y=math.random(1,1), z=0},
pos = {x = pos.x+mcl_util.float_random(-0.7,0.7)*math.random()/2, y = pos.y+mcl_util.float_random(0.7,1.2), z = pos.z+mcl_util.float_random(-0.7,0.7)*math.random()/2},
velocity = {x=0, y = mcl_util.float_random(0.5,2), z=0},
expirationtime = math.random(),
size = math.random(1, 4),
size = mcl_util.float_random(1, 4),
collisiondetection = true,
vertical = false,
texture = "mcl_particles_smoke_anim.png^[colorize:#0f0f0f:255",

View File

@ -208,7 +208,7 @@ minetest.register_abm({
while minetest.get_node(vector.new(pos.x, posy, pos.z)).name == "mcl_core:cactus" do
local pos = vector.new(pos.x, posy, pos.z)
minetest.remove_node(pos)
minetest.add_item(vector.offset(pos, math.random(-0.5, 0.5), 0, math.random(-0.5, 0.5)), "mcl_core:cactus")
minetest.add_item(vector.offset(pos, mcl_util.float_random(-0.5, 0.5), 0, mcl_util.float_random(-0.5, 0.5)), "mcl_core:cactus")
posy = posy + 1
end
break

View File

@ -1,4 +1,3 @@
name = mcl_core
description = Core items of MineClone 2: Basic biome blocks (dirt, sand, stones, etc.), derived items, glass, sugar cane, cactus, barrier, mining tools, hand, craftitems, and misc. items which don't really fit anywhere else.
depends = mcl_autogroup, mcl_init, mcl_sounds, mcl_util, mcl_worlds, doc_items, mcl_enchanting, mcl_colors, mcl_stairs, mcl_fences, mcl_flowerpots, mcl_trees, mcl_dyes, mcl_player
optional_depends = doc
depends = mcl_autogroup, mcl_init, mcl_sounds, mcl_util, mcl_worlds, doc_items, mcl_enchanting, mcl_colors, mcl_stairs, mcl_fences, mcl_flowerpots, mcl_trees, mcl_dyes, mcl_player, doc

View File

@ -243,7 +243,7 @@ local function spawn_mobs(pos)
end
-- Spawn attempt done. Next spawn attempt much later
timer:start(math.random(10, 39.95))
timer:start(mcl_util.float_random(10, 39.95))
end

View File

@ -1,2 +1,2 @@
name = mcl_mobspawners
depends = mcl_sounds, mcl_mobs
depends = mcl_sounds, mcl_mobs, mcl_util

View File

@ -76,8 +76,8 @@ mcl_player.register_globalstep(function(player, dtime)
pos = fly_pos,
velocity = {x = 0, y = 0, z = 0},
acceleration = {x = 0, y = 0, z = 0},
expirationtime = math.random(0.3, 0.5),
size = math.random(1, 2),
expirationtime = mcl_util.float_random(0.3, 0.5),
size = mcl_util.float_random(1, 2),
collisiondetection = false,
vertical = false,
texture = "mcl_particles_bonemeal.png^[colorize:#bc7a57:127",

View File

@ -2,4 +2,4 @@ name = playerphysics
author = Wuzzy
title = Player Physics API
description = This mod makes it possible for multiple mods to modify player physics (speed, jumping strength, gravity) without conflict.
depends = mcl_player
depends = mcl_player, mcl_util