Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Port over functionality from the single-player randomizer (#11)
Browse files Browse the repository at this point in the history
* WIP started merging the archipelago and standalone mod

* Ported over the options in RandomizerSettings.cs
* Updated the Quick Settings menu to be able to toggle between the single player and archipelago menus
* Updated OptionsGUIPatches.cs to add the single player logic options
* Added Translations.cs, copied from the standalone mod

* More stuff ported from the standalone mod

* Single player entrance randomizer now works.
* Updated item interaction patches to work with both archipelago and single player modes.
* Updated FairyTargets to work in both archipelago and single player modes.

* Added more options to the quick settings menu

* Added a separate window for advanced logic options to the quick settings menu for single player options

* Update InteractionPatches.cs

* Switching to nighttime resets your spawn point to overworld to prevent softlocks

* Made Swamp gate open after dropping Overworld fuse

* Updated ModelSwaps.cs

* Item Model and Chest Texture Swaps now work in both single player and multiworld modes
* Fool Traps work in single player mode, and have been added to the options menu
* Possibly fixed a bug with the laurels hint not displaying correctly if it resides in a non-tunic player's world

* Added single player mailbox/grave hints

* Single player mode now has hints at the mailbox, sealed temple, and hero graves
* Spoiler log populates for single player mode

* Ghost hints work in single player mode

* Updated ending stats to work in single player mode

* Created helper functions for determining if file is single player or archipelago

* Fixed spoiler log formatting

* Check if file is archipelago before calling data storage

* Fixed hero relic item models not swapping

* Hero relic model swaps work in single player mode
* Fixed text casing for certain hints

* Update ModelSwaps.cs

* Fixed models not swapping for siege engine or the hexagon pickups in single player mode

* Added missing parenthesis

* Fixed fairy targets in single player mode

* Small option text formatting

* Entrance Seeker spell (#9)

* Adds an entrance seeker spell to the entrance randomizer, pointing out entrances you haven't gone into yet in the current scene

---------

Co-authored-by: Silent <110704408+silent-destroyer@users.noreply.github.com>

* Refactored new fairy target stuff, added clear buttons to quick settings

* Entrance seeker spell only works in entrance rando now
* Fixed incorrect portal names being set in MarkPortals
* Also added Clear buttons for editing player name, hostname, and slot

* Update FairyTargets.cs

* Remove extra call to CreateEntranceTargets

* Fix for entrance spell? (#10)

* Updated AP Mailbox Hints

* If the mailbox hint doesn't find a local item for the player, it will search for a local item for another tunic player before searching for a generic non-tunic progression item

* Create fool traps on item randomization in single player

* Changed when fool trap items are created during single player item randomization so that they are recorded in the spoiler log

* Small changes

* Changed port to string to make editing easier
* Added check for spoiler log setting before creating it

* Add Lanternless and Maskless logic options to single player

* (WIP) Started adding Mystery Seed toggle

* Implemented basic mystery seed setting

* Added a toggle to randomly pick logic settings on new game
* Fixed a bug with the laurels placement option value not being read from the save file during generation, causing it to sometimes fail.

* Readded option to display hints in only trunic

* Works for certain hints in AP

* Reduced collision box size on coffee tables

* This lets you walk/roll around them in most situations where they would otherwise block you entirely

* More Enemy Rando changes

* Added a few more specific spots to exclude coffee tables from
* Fixed a few enemies from Fortress and Frog's Domains that weren't being randomized

* Fixed a bug with model swapping non-tunic items

* Forgot to change red hex pickup in previous commit

* Enemy Rando additions and a small bugfix

* Added enemy variants from the Librarian bossfight and the Cathedral Gauntlet into the random enemy pool
* Fixed a crash that would occur if you toggled "use custom texture" while on the title screen

* Update Translations.cs

* Set last campfire to old house when switching to nighttime

* Default cape color to pink

* Update QuickSettings.cs

* Added additional settings to the settings string for the copy/paste settings buttons

* Added first set of race options

* Added master Race Mode toggle (must be on to use other race settings)
* The spoiler log does not get created with race mode on
* Added race mode option to prevent west bell from being hit from long distances
* Added race mode option to prevent icebolt from being used in the Heir fight

* Renamed ice rod ability to icebolt

* Fixed spoiler log not always updating after opening a check

* Update EnemyRandomizer.cs

* Disabled miasma in monastery that was getting activated as a sideeffect of the extra enemies option

* Potential fix for fairy targets not working properly after a save and quit

* Fixed bug with creating the item pool on hex quest

* Some enemy randomizer rebalancing

* Moved big crabs and cube crabs to the medium tier difficulty
* Lowered the saturation of certain enemies with multiple variants
* Reduced centipede aggro distance

* Slight changes to mystery seed settings generation

* Switch to local Random object for item randomization

* Added mystery seed info to spoiler log

* More Race Mode Updates

* Added toggles for disabling ladder storage and ice grappling enemies

* Add heir fast travel teleporter in overworld

* Spawns a teleporter in the overworld to go to the heir arena after you have died to her at least once.

* Update README.md

* Fixes for disabling ladder storage and ice grapples

* Update README.md

* Several bugfixes

* Fixed a crash when entering the shop
* Added the other two race options to the settings string
* Fixed a bug with gold hexagons being able to be picked up infinite times
* Pasting a settings string will now turn off enemy rando if it is missing from the string

* Update ladder storage toggle

* Add race option for turning off upgrade stealing

* Fix bush softlock in forest grave path

* Update EnemyRandomizer.cs

* Entrance Rando Refactor (#12)

* Update ItemStatsHUD.cs

* Some logging cleanuop

* Change Custom Seed to string

* Custom seed for quick settings menu is now string type, allowing seed 0 to be used

* Fixed Archipelago Entrance Rando

scipio broke it again /s

* Update logic for quarry/ziggurat to include sword and wand

* Add more things to be translated with the trunic option

* Clear button works when editing field on ap config editor

* Fixed some trunic messages

* Fix Heir fast travel for entrance rando

* Update ItemListJson.cs

* Exclude Turrets from certain spots in enemy rando

* Moved around some options in the options menu

* Update apworld and yaml template

---------

Co-authored-by: Scipio Wright <scipiowright@gmail.com>
  • Loading branch information
silent-destroyer and ScipioWright authored Feb 16, 2024
1 parent 2c1814e commit 3802e0e
Show file tree
Hide file tree
Showing 41 changed files with 8,008 additions and 1,883 deletions.
179 changes: 96 additions & 83 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Tunic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
#
name: Ruin Seeker
description: tunc
game: Tunic
game: TUNIC
requires:
version: 0.4.4
Tunic:
TUNIC:
# Play with sword upgrades enabled.
sword_progression: 'true'
# Start with a sword.
Expand Down
6 changes: 4 additions & 2 deletions TunicArchipelago.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TunicArchipelago</RootNamespace>
<AssemblyName>TunicArchipelago</AssemblyName>
<AssemblyName>TunicRandomizer</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
Expand Down Expand Up @@ -166,11 +166,13 @@
<Compile Include="src\Data\PortalCombo.cs" />
<Compile Include="src\Data\RandomizerSettings.cs" />
<Compile Include="src\Data\SaveFlags.cs" />
<Compile Include="src\Data\VanillaCheck.cs" />
<Compile Include="src\Data\Translations.cs" />
<Compile Include="src\Data\Check.cs" />
<Compile Include="src\Patches\EnemyRandomizer.cs" />
<Compile Include="src\Patches\FairyTargets.cs" />
<Compile Include="src\Patches\GhostHints.cs" />
<Compile Include="src\Patches\CustomItemBehaviors.cs" />
<Compile Include="src\Patches\ItemRandomizer.cs" />
<Compile Include="src\Util\HeroGraveToggle.cs" />
<Compile Include="src\Patches\InteractionPatches.cs" />
<Compile Include="src\Patches\ItemPatches.cs" />
Expand Down
4 changes: 3 additions & 1 deletion src/Archipelago/Archipelago.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public void ActivateCheck(string LocationId) {
}

public void UpdateDataStorage(string Key, object Value) {
integration.UpdateDataStorage(Key, Value);
if (SaveFlags.IsArchipelago()) {
integration.UpdateDataStorage(Key, Value);
}
}

public void Release() {
Expand Down
20 changes: 16 additions & 4 deletions src/Archipelago/ArchipelagoIntegration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public class ArchipelagoIntegration {
private int ItemIndex = 0;

public void Update() {
if ((SceneManager.GetActiveScene().name == "TitleScreen" && TunicArchipelago.Settings.Mode != RandomizerSettings.RandomizerType.ARCHIPELAGO) || SaveFile.GetInt("archipelago") == 0) {
return;
}

if (!connected) {
return;
}
Expand All @@ -64,7 +68,6 @@ public void Update() {
if (SpeedrunData.gameComplete != 0 && !sentCompletion) {
sentCompletion = true;
SendCompletion();
SpeedrunFinishlineDisplayPatches.SetupCompletionStatsDisplay();
}

}
Expand All @@ -81,7 +84,11 @@ public void TryConnect() {
return;
}
if (session == null) {
session = ArchipelagoSessionFactory.CreateSession(TunicArchipelago.Settings.ConnectionSettings.Hostname, TunicArchipelago.Settings.ConnectionSettings.Port);
try {
session = ArchipelagoSessionFactory.CreateSession(TunicArchipelago.Settings.ConnectionSettings.Hostname, int.Parse(TunicArchipelago.Settings.ConnectionSettings.Port));
} catch (Exception e) {
Logger.LogInfo("Failed to create archipelago session!");
}
}
incomingItemHandler = IncomingItemHandler();
outgoingItemHandler = OutgoingItemHandler();
Expand Down Expand Up @@ -285,6 +292,11 @@ public void ActivateCheck(string LocationId) {
if (Locations.VanillaLocations.Keys.Where(key => Locations.VanillaLocations[key].Location.SceneName == SceneLoaderPatches.SceneName && !Locations.CheckedLocations[key]).ToList().Count == 0) {
FairyTargets.CreateLoadZoneTargets();
}

if (TunicArchipelago.Settings.CreateSpoilerLog && !TunicArchipelago.Settings.RaceMode) {
ItemTracker.PopulateSpoilerLog();
}

session.Locations.ScoutLocationsAsync(location)
.ContinueWith(locationInfoPacket =>
outgoingItems.Enqueue(locationInfoPacket.Result.Locations[0]));
Expand All @@ -303,15 +315,15 @@ public void SendCompletion() {
}

public void Release() {
if (sentCompletion && !sentRelease) {
if (connected && sentCompletion && !sentRelease) {
session.Socket.SendPacket(new SayPacket() { Text = "!release" });
sentRelease = true;
Logger.LogInfo("Released remaining checks.");
}
}

public void Collect() {
if (sentCompletion && !sentCollect) {
if (connected && sentCompletion && !sentCollect) {
session.Socket.SendPacket(new SayPacket() { Text = "!collect" });
sentCollect = true;
Logger.LogInfo("Collected remaining items.");
Expand Down
82 changes: 82 additions & 0 deletions src/Data/Check.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TunicArchipelago {

public struct Location {
public string LocationId;
public string Position;
public List<Dictionary<string, int>> RequiredItems;
public List<Dictionary<string, int>> RequiredItemsDoors;
public int SceneId;
public string SceneName;

public bool reachable(Dictionary<string, int> inventory) {
List<Dictionary<string, int>> itemsRequired;
if (SaveFile.GetInt("randomizer entrance rando enabled") == 1) {
itemsRequired = this.RequiredItemsDoors;
} else {
itemsRequired = this.RequiredItems;
}

//if there are no requirements, the location is reachable
if (itemsRequired.Count == 0) {
return true;
}

//if there are requirements, loop through each requirement to see if any are fully met
foreach (Dictionary<string, int> req in itemsRequired) {
//ensure req and items use same terms
if (SaveFile.GetInt("randomizer sword progression enabled") != 0) {
if (req.ContainsKey("Stick")) {
req["Sword Progression"] = 1;
req.Remove("Stick");
}
if (req.ContainsKey("Sword")) {
req["Sword Progression"] = 2;
req.Remove("Sword");
}
}

//check if this requirement is fully met, otherwise move to the next requirement
int met = 0;
foreach (string item in req.Keys) {
//Logger.LogInfo(item);
if (!inventory.ContainsKey(item)) {
break;
} else if (inventory[item] >= req[item]) {
met += 1;
}
}
if (met == req.Count) {
return true;
}
}
//if no requirements are met, the location isn't reachable
return false;
}
}
public struct Reward {
public int Amount;
public string Name;
public string Type;
}
public class Check {
public Location Location;
public Reward Reward;

public Check() { }

public Check(Location location, Reward reward) {
Location = location;
Reward = reward;
}
public Check(Reward reward, Location location) {
Location = location;
Reward = reward;
}
}
}
6 changes: 3 additions & 3 deletions src/Data/ConnectionSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public string Hostname {
set;
}

public int Port {
public string Port {
get;
set;
}
Expand All @@ -29,9 +29,9 @@ public string Password {
}

public ConnectionSettings() {
Player = "Player";
Player = "Ruin Seeker";
Hostname = "localhost";
Port = 38281;
Port = "38281";
Password = "";
}
}
Expand Down
Loading

0 comments on commit 3802e0e

Please sign in to comment.