From c03fc1ffd0427ad8ec84872b89726dafca2a2a71 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Sat, 18 Mar 2023 11:26:13 +0100 Subject: [PATCH] [MIRROR] Fixes some incorrect uses of `rand()` [MDB IGNORE] (#19910) * Fixes some incorrect uses of `rand()` (#74032) ## About The Pull Request `Rand` only takes integers ![image](https://user-images.githubusercontent.com/51863163/225454770-bdb70aca-ed43-4c17-a943-2ec99720b53d.png) ![image](https://user-images.githubusercontent.com/51863163/225454784-8f9cc053-8e7d-46fd-b6b2-42efb0751d5e.png) ## Why It's Good For The Game Less misleading code ## Changelog :cl: Melbert fix: Lead batteries now start partially drained as intended. /:cl: * Fixes some incorrect uses of `rand()` --------- Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> --- code/game/objects/items/maintenance_loot.dm | 3 ++- .../mob/living/basic/lavaland/bileworm/bileworm_actions.dm | 4 ++-- code/modules/mob/living/emote.dm | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/code/game/objects/items/maintenance_loot.dm b/code/game/objects/items/maintenance_loot.dm index 1df9c861a32..bfdc53ea916 100644 --- a/code/game/objects/items/maintenance_loot.dm +++ b/code/game/objects/items/maintenance_loot.dm @@ -41,4 +41,5 @@ /obj/item/stock_parts/cell/lead/Initialize(mapload) AddElement(/datum/element/update_icon_blocker) . = ..() - charge = rand(0.2,0.8) * maxcharge + var/initial_percent = rand(20, 80) / 100 + charge = initial_percent * maxcharge diff --git a/code/modules/mob/living/basic/lavaland/bileworm/bileworm_actions.dm b/code/modules/mob/living/basic/lavaland/bileworm/bileworm_actions.dm index 0669a39d3ec..0be00961bfb 100644 --- a/code/modules/mob/living/basic/lavaland/bileworm/bileworm_actions.dm +++ b/code/modules/mob/living/basic/lavaland/bileworm/bileworm_actions.dm @@ -23,7 +23,7 @@ burrower.invisibility = INVISIBILITY_MAXIMUM burrower.forceMove(unburrow_turf) //not that it's gonna die with godmode but still - SLEEP_CHECK_DEATH(rand(0.75 SECONDS, 1.25 SECONDS), burrower) + SLEEP_CHECK_DEATH(rand(0.7 SECONDS, 1.2 SECONDS), burrower) playsound(burrower, 'sound/effects/break_stone.ogg', 50, TRUE) new /obj/effect/temp_visual/mook_dust(unburrow_turf) burrower.status_flags &= ~GODMODE @@ -108,7 +108,7 @@ devourer.invisibility = INVISIBILITY_MAXIMUM devourer.forceMove(devour_turf) //not that it's gonna die with godmode but still - SLEEP_CHECK_DEATH(rand(0.75 SECONDS, 1.25 SECONDS), devourer) + SLEEP_CHECK_DEATH(rand(0.7 SECONDS, 1.2 SECONDS), devourer) playsound(devourer, 'sound/effects/break_stone.ogg', 50, TRUE) new /obj/effect/temp_visual/mook_dust(devour_turf) devourer.status_flags &= ~GODMODE diff --git a/code/modules/mob/living/emote.dm b/code/modules/mob/living/emote.dm index c63944c1c85..1a4b5b4b415 100644 --- a/code/modules/mob/living/emote.dm +++ b/code/modules/mob/living/emote.dm @@ -519,7 +519,7 @@ if(!recently_examined && !prob(YAWN_PROPAGATE_CHANCE_BASE - (YAWN_PROPAGATE_CHANCE_DECAY * dist_between))) continue - var/yawn_delay = rand(0.25 SECONDS, 0.75 SECONDS) * dist_between + var/yawn_delay = rand(0.2 SECONDS, 0.7 SECONDS) * dist_between addtimer(CALLBACK(src, PROC_REF(propagate_yawn), iter_living), yawn_delay) /// This yawn has been triggered by someone else yawning specifically, likely after a delay. Check again if they don't have the yawned recently trait