-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRandomizer.cs
More file actions
157 lines (139 loc) · 5.9 KB
/
Copy pathRandomizer.cs
File metadata and controls
157 lines (139 loc) · 5.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
using Microsoft.VisualBasic;
using RomUtilities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FF1PRAP
{
public class ItemData
{
public int Id { get; set; }
public int Qty { get; set; }
public int Number { get; set; }
public ItemData() { }
public ItemData(int id, int qty, int number = 1)
{
Id = id;
Qty = qty;
Number = number;
}
}
public struct LocationData
{
public int Content;
public int Qty;
public int Id;
public int Flag;
public LocationType Type;
public Regions Region;
public string Name;
public int Script;
public string Map;
//public string Message;
public List<List<AccessRequirements>> Access;
public List<AccessRequirements> Trigger;
}
public struct ApLocationData
{
public string Content;
public int Flag;
public string Name;
public long Id;
}
public struct RegionData
{
public Regions Region;
public List<List<AccessRequirements>> Access;
}
static partial class Randomizer
{
public static Dictionary<string, string> LocationIdToDescription = new Dictionary<string, string>();
public static Dictionary<string, string> LocationDescriptionToId = new Dictionary<string, string>();
public static Dictionary<string, long> LocationIdToArchipelagoId = new Dictionary<string, long>();
public static Dictionary<string, bool> CheckedLocations = new Dictionary<string, bool>();
public static Dictionary<int, ApLocationData> ApLocations = new Dictionary<int, ApLocationData>();
public static List<int> ItemsToIgnore = new();
public static Dictionary<string, string> NewTeleporters = new();
public static bool Teleporting = false;
public static RandomizerData Data { get; set; }
public static void Randomize()
{
bool archipelago = SessionManager.GameMode == GameModes.Archipelago;
uint hash;
string filename;
if (archipelago)
{
hash = SessionManager.CreateApHash(SessionManager.Data.Player + SessionManager.Data.WorldSeed);
filename = "ap_" + SessionManager.Data.Player + "_" + SessionManager.Data.WorldSeed;
}
else
{
hash = SessionManager.CreateHash();
filename = SessionManager.Data.Seed + "_" + SessionManager.Data.Hashstring;
}
// Create seed
RandomizerData randoData = new();
MT19337 rng = new(hash);
// Make sure all options are set, if not apply default values
foreach (var option in Options.Dict)
{
if (!SessionManager.Options.ContainsKey(option.Key))
{
SessionManager.Options[option.Key] = option.Value.Default;
}
}
// Create randomized data
if (!archipelago)
{
bool validplacement = false;
while (!validplacement)
{
LogicData logicdata = Logic.BuildLogic(SessionManager.Options["shuffle_overworld"] == Options.Enable,
(ShuffleEntrancesMode)SessionManager.Options["shuffle_entrances"],
(ShuffleTownsMode)SessionManager.Options["shuffle_towns"],
(EarlyProgressionModes)SessionManager.Options["early_progression"],
SessionManager.Options["northern_docks"] == Options.Enable,
rng);
var placement = ItemPlacement(logicdata.Locations, rng);
if (placement != null)
{
randoData.PlacedItems = placement;
randoData.Entrances = Randomizer.ProcessEntrances(logicdata.Entrances);
validplacement = true;
}
}
}
else
{
randoData.Entrances = Randomizer.ProcessEntrances(Randomizer.NewTeleporters);
}
randoData.GearShops = ShuffleGearShop(SessionManager.Options["shuffle_gear_shops"] == Options.Enable, rng);
randoData.ShuffledSpells = ShuffleSpells(SessionManager.Options["shuffle_spells"] == Options.Enable, rng);
randoData.DungeonEncounterRate = SetEncounterRate(SessionManager.Options["dungeon_encounter_rate"]);
randoData.OverworldEncounterRate = SetEncounterRate(SessionManager.Options["overworld_encounter_rate"]);
randoData.XpBoost = SetVictoryBoost(SessionManager.Options["xp_boost"]);
randoData.GilBoost = SetVictoryBoost(SessionManager.Options["gil_boost"]);
randoData.BoostMenu = SessionManager.Options["boost_menu"] == Options.Enable;
randoData.Entrances = randoData.Entrances.Concat(ShuffleOrdealsMaze(SessionManager.Options["shuffle_trials_maze"] == Options.Enable, rng))
.ToDictionary(x => x.Key, x => x.Value);
randoData.JobPromotion = (JobPromotionModes)SessionManager.Options["job_promotion"];
randoData.EarlyProgression = (EarlyProgressionModes)SessionManager.Options["early_progression"];
randoData.NorthernDocks = SessionManager.Options["northern_docks"] == Options.Enable;
randoData.RequiredCrystals = ProcessCrystals(SessionManager.Options["crystals_required"], rng);
randoData.RequiredTablatures = ProcessLute(SessionManager.Options["lute_tablatures"], rng);
randoData.NerfChaos = SessionManager.Options["nerf_chaos"] == Options.Enable;
randoData.EntrancesShuffled = ProcessEntrancesOptions(SessionManager.Options["shuffle_overworld"] == Options.Enable, (ShuffleEntrancesMode)SessionManager.Options["shuffle_entrances"]);
// This is ugly but it'll do for now
randoData.MonsterParties =
RandomizeMonsterParties(SessionManager.Options["monster_parties"] != Options.Disable, (MonsterPartyRangeModes)SessionManager.Options["monster_parties"], (MonsterPartyCapModes)SessionManager.Options["monsters_cap"], rng)
.Concat(AddBossMinions(SessionManager.Options["boss_minions"] != Options.Disable, (MinionsRangeModes)SessionManager.Options["boss_minions"], (WarmechChance)SessionManager.Options["chaos_minion_warmech_chance"], (WarmechChance)SessionManager.Options["fiend_minion_warmech_chance"], rng))
.ToDictionary(x => x.Key, x => x.Value);
randoData.SmittThingy = rng.PickFrom(new List<string>() { "thingy", "thingamajigger", "gizmo", "whatchamacallit", "gewgaw", "doohickey", "thingumabob", "widget", "whatsit", "hootenanny", "MacGuffin", "doodad" });
Data = randoData;
// Write Rando data file
Serialize(SessionManager.FolderPath, filename);
}
}
}