Skip to content

Commit

Permalink
Split enemy drop rando from enemy drop chance rando
Browse files Browse the repository at this point in the history
fixes #169
  • Loading branch information
LagoLunatic committed Dec 4, 2022
1 parent 7755949 commit 71ce746
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 78 deletions.
3 changes: 2 additions & 1 deletion constants/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

randomize_enemies: "Randomizes which non-boss enemies appear where.",
randomize_bosses: "Randomizes which bosses appear where.",
randomize_enemy_drops: "Randomizes the items, souls, and glyphs dropped by non-boss enemies, as well as their drop chances.",
randomize_enemy_drops: "Randomizes the items, souls, and glyphs dropped by non-boss enemies.",
randomize_enemy_drop_chances: "Randomizes the drop chances of items, souls, and glyphs dropped by non-boss enemies.",
randomize_enemy_stats: "Randomizes enemy attack, defense, HP, EXP given, and other stats.",
randomize_enemy_anim_speed: "Randomizes the speed at which each enemy's animations play at, which affects their attack speed.",
randomize_enemy_tolerances: "Randomizes enemy elemental weaknesses and resistances.",
Expand Down
7 changes: 7 additions & 0 deletions randomizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,13 @@ def randomize
randomize_enemy_drops()
options_completed += 1
end

if options[:randomize_enemy_drop_chances]
yield [options_completed, "Randomizing enemy drop chances..."]
reset_rng()
randomize_enemy_drop_chances()
options_completed += 1
end
end

if options[:randomize_pickups]
Expand Down
140 changes: 82 additions & 58 deletions randomizer.ui
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,26 @@
<string>Progression randomization options</string>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="2">
<widget class="QWidget" name="widget_3" native="true">
<widget class="QCheckBox" name="randomize_portraits">
<property name="geometry">
<rect>
<x>20</x>
<y>0</y>
<width>185</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Portraits</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="randomize_pickups">
<property name="text">
Expand All @@ -109,23 +129,6 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="randomize_red_walls">
<property name="text">
<string>Red Soul Walls</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="randomize_world_map_exits">
<property name="text">
<string>World Map Exits</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="randomize_boss_souls">
<property name="text">
Expand All @@ -136,7 +139,7 @@
</property>
</widget>
</item>
<item row="1" column="2">
<item row="0" column="3">
<widget class="QCheckBox" name="randomize_villagers">
<property name="text">
<string>Villagers</string>
Expand All @@ -146,10 +149,10 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="randomize_portraits">
<item row="1" column="0">
<widget class="QCheckBox" name="randomize_red_walls">
<property name="text">
<string>Portraits</string>
<string>Red Soul Walls</string>
</property>
<property name="checked">
<bool>true</bool>
Expand All @@ -165,20 +168,27 @@
<string>Room randomization options</string>
</property>
<layout class="QGridLayout" name="gridLayout_9">
<item row="0" column="2">
<item row="0" column="3">
<widget class="QWidget" name="widget" native="true"/>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="randomize_starting_room">
<property name="text">
<string>Starting Room</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="randomize_maps">
<property name="text">
<string>Maps</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="randomize_starting_room">
<item row="0" column="2">
<widget class="QCheckBox" name="randomize_world_map_exits">
<property name="text">
<string>Starting Room</string>
<string>World Map Exits</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -225,17 +235,27 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="randomize_enemy_anim_speed">
<property name="text">
<string>Enemy Animation Speed</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="randomize_enemy_tolerances">
<property name="text">
<string>Enemy Tolerances</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="randomize_enemy_anim_speed">
<item row="0" column="3">
<widget class="QCheckBox" name="randomize_enemy_drop_chances">
<property name="text">
<string>Enemy Animation Speed</string>
<string>Enemy Drop Chances</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
Expand All @@ -255,35 +275,35 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="randomize_weapon_behavior">
<item row="1" column="0">
<widget class="QCheckBox" name="randomize_equipment_stats">
<property name="text">
<string>Weapon Behavior</string>
<string>Equipment Stats</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="randomize_skill_behavior">
<item row="0" column="1">
<widget class="QCheckBox" name="randomize_weapon_behavior">
<property name="text">
<string>Skill Behavior</string>
<string>Weapon Behavior</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="randomize_equipment_stats">
<item row="1" column="1">
<widget class="QCheckBox" name="randomize_skill_stats">
<property name="text">
<string>Equipment Stats</string>
<string>Skill Stats</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="randomize_skill_stats">
<item row="0" column="2">
<widget class="QCheckBox" name="randomize_skill_behavior">
<property name="text">
<string>Skill Stats</string>
<string>Skill Behavior</string>
</property>
</widget>
</item>
<item row="1" column="2">
<item row="0" column="3">
<widget class="QCheckBox" name="randomize_weapon_and_skill_elements">
<property name="text">
<string>Weapon and Skill Elements</string>
Expand All @@ -299,17 +319,17 @@
<string>Non-progress item location randomization options</string>
</property>
<layout class="QGridLayout" name="gridLayout_12">
<item row="0" column="0">
<widget class="QCheckBox" name="randomize_shop">
<item row="0" column="2">
<widget class="QCheckBox" name="randomize_weapon_synths">
<property name="text">
<string>Shop Items</string>
<string>Weapon Synthesis</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="randomize_weapon_synths">
<item row="0" column="0">
<widget class="QCheckBox" name="randomize_shop">
<property name="text">
<string>Weapon Synthesis</string>
<string>Shop Items</string>
</property>
</widget>
</item>
Expand All @@ -320,6 +340,9 @@
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QWidget" name="widget_2" native="true"/>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -984,35 +1007,28 @@
<tabstop>generate_seed_button</tabstop>
<tabstop>randomize_pickups</tabstop>
<tabstop>randomize_boss_souls</tabstop>
<tabstop>randomize_world_map_exits</tabstop>
<tabstop>randomize_red_walls</tabstop>
<tabstop>randomize_portraits</tabstop>
<tabstop>randomize_villagers</tabstop>
<tabstop>randomize_red_walls</tabstop>
<tabstop>randomize_maps</tabstop>
<tabstop>randomize_starting_room</tabstop>
<tabstop>randomize_world_map_exits</tabstop>
<tabstop>randomize_enemies</tabstop>
<tabstop>randomize_bosses</tabstop>
<tabstop>randomize_enemy_drops</tabstop>
<tabstop>randomize_enemy_drop_chances</tabstop>
<tabstop>randomize_enemy_stats</tabstop>
<tabstop>randomize_enemy_anim_speed</tabstop>
<tabstop>randomize_enemy_tolerances</tabstop>
<tabstop>randomize_consumable_behavior</tabstop>
<tabstop>randomize_weapon_behavior</tabstop>
<tabstop>randomize_skill_behavior</tabstop>
<tabstop>randomize_weapon_and_skill_elements</tabstop>
<tabstop>randomize_equipment_stats</tabstop>
<tabstop>randomize_skill_stats</tabstop>
<tabstop>randomize_weapon_and_skill_elements</tabstop>
<tabstop>randomize_shop</tabstop>
<tabstop>randomize_weapon_synths</tabstop>
<tabstop>randomize_wooden_chests</tabstop>
<tabstop>load_seed_info_button</tabstop>
<tabstop>paste_seed_info_button</tabstop>
<tabstop>save_options_preset_button</tabstop>
<tabstop>load_options_preset_button</tabstop>
<tabstop>about_button</tabstop>
<tabstop>reset_settings_to_default</tabstop>
<tabstop>num_seeds_to_create</tabstop>
<tabstop>randomize_button</tabstop>
<tabstop>difficulty_level</tabstop>
<tabstop>enable_glitch_reqs</tabstop>
<tabstop>rebalance_enemies_in_room_rando</tabstop>
Expand Down Expand Up @@ -1049,6 +1065,14 @@
<tabstop>experimental_options_enabled</tabstop>
<tabstop>randomize_enemy_sprites</tabstop>
<tabstop>randomize_boss_sprites</tabstop>
<tabstop>load_seed_info_button</tabstop>
<tabstop>paste_seed_info_button</tabstop>
<tabstop>save_options_preset_button</tabstop>
<tabstop>load_options_preset_button</tabstop>
<tabstop>about_button</tabstop>
<tabstop>reset_settings_to_default</tabstop>
<tabstop>num_seeds_to_create</tabstop>
<tabstop>randomize_button</tabstop>
<tabstop>tabWidget</tabstop>
</tabstops>
<resources/>
Expand Down
51 changes: 32 additions & 19 deletions randomizers/drop_randomizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,31 @@ def randomize_enemy_drops
enemy["Item 2"] = 0
end

case GAME
when "dos"
enemy["Soul"] = get_unplaced_non_progression_skill() - SKILL_GLOBAL_ID_RANGE.begin
when "ooe"
if enemy["Glyph"] != 0
# Only give glyph drops to enemies that originally had a glyph drop.
# Other enemies cannot drop a glyph anyway.

if enemy.name.include?("Fomor") || enemy.name.include?("Demon")
# Fomors and Demons can actually use the glyph you give them, but only if it's a projectile arm glyph.
enemy["Glyph"] = get_unplaced_non_progression_projectile_glyph() - SKILL_GLOBAL_ID_RANGE.begin + 1
else
enemy["Glyph"] = get_unplaced_non_progression_skill() - SKILL_GLOBAL_ID_RANGE.begin + 1
end
end
end

enemy.write_to_rom()
end
end

def randomize_enemy_drop_chances
COMMON_ENEMY_IDS.each do |enemy_id|
enemy = game.enemy_dnas[enemy_id]

item_1_chance = named_rand_range_weighted(:item_drop_chance_range)
item_2_chance = named_rand_range_weighted(:item_drop_chance_range)
skill_chance = named_rand_range_weighted(:skill_drop_chance_range)
Expand All @@ -75,8 +100,6 @@ def randomize_enemy_drops
internal_item_chance = 255 if internal_item_chance > 255
enemy["Item Chance"] = internal_item_chance

enemy["Soul"] = get_unplaced_non_progression_skill() - SKILL_GLOBAL_ID_RANGE.begin

internal_soul_chance = (skill_chance/100.0*512).floor
internal_soul_chance = 1 if internal_soul_chance < 1
internal_soul_chance = 255 if internal_soul_chance > 255
Expand All @@ -102,23 +125,13 @@ def randomize_enemy_drops
internal_item_2_chance = 255 if internal_item_2_chance > 255
enemy["Item 2 Chance"] = internal_item_2_chance

if enemy["Glyph"] != 0
# Only give glyph drops to enemies that original had a glyph drop.
# Other enemies cannot drop a glyph anyway.

if enemy.name.include?("Fomor") || enemy.name.include?("Demon")
# Fomors and Demons can actually use the glyph you give them, but only if it's a projectile arm glyph.
enemy["Glyph"] = get_unplaced_non_progression_projectile_glyph() - SKILL_GLOBAL_ID_RANGE.begin + 1
else
enemy["Glyph"] = get_unplaced_non_progression_skill() - SKILL_GLOBAL_ID_RANGE.begin + 1
end

if enemy["Glyph Chance"] != 100 # Don't set glyph chance if it was originally 100%, because it won't matter for those enemies.
internal_skill_chance = skill_chance
internal_skill_chance = 1 if internal_skill_chance < 1
internal_skill_chance = 255 if internal_skill_chance > 255
enemy["Glyph Chance"] = internal_skill_chance
end
if enemy["Glyph"] != 0 && ![0, 100].include?(enemy["Glyph Chance"])
# Only randomize glyph drop chance if the enemy is capable of dropping a glyph,
# and the original base drop chance was neither 0% nor 100%.
internal_skill_chance = skill_chance
internal_skill_chance = 1 if internal_skill_chance < 1
internal_skill_chance = 255 if internal_skill_chance > 255
enemy["Glyph Chance"] = internal_skill_chance
end
end

Expand Down

0 comments on commit 71ce746

Please sign in to comment.