mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-19 20:20:19 +02:00
big ass modding update
This commit is contained in:
+14
-3
@@ -3,10 +3,21 @@
|
||||
-- rand(0..255) < map encounter rate; the slot is picked with the original
|
||||
-- probability buckets.
|
||||
|
||||
local FieldDefaults = require("src.world.FieldDefaults")
|
||||
|
||||
local Encounter = {}
|
||||
|
||||
-- cumulative slot thresholds out of 256 (engine/battle/wild_encounters.asm)
|
||||
local SLOT_BUCKETS = { 51, 102, 141, 166, 191, 216, 229, 242, 253, 256 }
|
||||
-- Cumulative slot thresholds out of 256 (engine/battle/wild_encounters.asm),
|
||||
-- now constants.encounterBuckets. An encounter def may also carry its own
|
||||
-- `buckets` of any length, as long as the last entry is 256 and there are
|
||||
-- as many slots as buckets.
|
||||
local buckets = FieldDefaults.CONSTANTS.encounterBuckets
|
||||
|
||||
-- Collision.load's idiom: the overworld hands the dataset over on entry so
|
||||
-- the pure roll stays free of a Data reference.
|
||||
function Encounter.load(data)
|
||||
buckets = FieldDefaults.constant(data, "encounterBuckets")
|
||||
end
|
||||
|
||||
function Encounter.roll(encounterDef, rng)
|
||||
rng = rng or love.math.random
|
||||
@@ -15,7 +26,7 @@ function Encounter.roll(encounterDef, rng)
|
||||
if not grass or grass.rate == 0 then return nil end
|
||||
if rng(0, 255) >= grass.rate then return nil end
|
||||
local pick = rng(0, 255)
|
||||
for i, threshold in ipairs(SLOT_BUCKETS) do
|
||||
for i, threshold in ipairs(grass.buckets or buckets) do
|
||||
if pick < threshold then
|
||||
local slot = grass.slots[i]
|
||||
if slot then
|
||||
|
||||
Reference in New Issue
Block a user