Skip to content

Commit

Permalink
Fixed gruz, NKG, sly, PV, zote, zote bgm, ghost warrior hu, infected …
Browse files Browse the repository at this point in the history
…knight and some boss flags got removed from their corpses
  • Loading branch information
Kerr1291 committed Jun 29, 2023
1 parent 4ef5ec9 commit adf3158
Show file tree
Hide file tree
Showing 18 changed files with 644 additions and 171 deletions.
2 changes: 1 addition & 1 deletion EnemyRandomizerDll/EnemyRandomizer/Mod/EnemyRandomizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public static string GetModAssetPath(string filename)
public EnemyRandomizerPlayerSettings OnSaveLocal() => PlayerSettings;

const string defaultDatabaseFilePath = "EnemyRandomizerDatabase.xml";
static string currentVersionPrefix = Assembly.GetAssembly(typeof(EnemyRandomizer)).GetName().Version.ToString() + "[Alpha 9.2.2]";
static string currentVersionPrefix = Assembly.GetAssembly(typeof(EnemyRandomizer)).GetName().Version.ToString() + "[Alpha 9.2.3]";
static string currentVersion = currentVersionPrefix;
//Assembly.GetAssembly(typeof(EnemyRandomizer)).GetName().Version.ToString() + $" CURRENT SEED:[{GlobalSettings.seed}] -- TO CHANGE SEED --> MODS > ENEMY RANDOMIZER > ENEMY RANDOMIZER MODULES";

Expand Down
18 changes: 18 additions & 0 deletions EnemyRandomizerDll/EnemyRandomizer/Mod/EnemyReplacer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,24 @@ public GameObject OnObjectLoaded(GameObject loadedObjectToProcess)
}
}
}
else //skipping for logic
{
var key = loadedObjectToProcess.GetDatabaseKey();
if (!string.IsNullOrEmpty(key))
{
//get the spawner
var spawner = EnemyRandomizerDatabase.GetDatabase().GetSpawner(key);
if (spawner != null)
{
//hacky fix for now
if (key == "Giant Fly")
{
//apply the spawner's logic to this gruz mother to set it up correctly
spawner.ConfigureObject(objectToModifyAndActivate, objectToSourceAndDestroy);
}
}
}
}

//Activate and The Replacement or Loaded Object and Remove The Original============================
objectToModifyAndActivate.FinalizeReplacement(objectToSourceAndDestroy);
Expand Down
41 changes: 32 additions & 9 deletions EnemyRandomizerDll/EnemyRandomizerDB/Library/BattleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void Update()
//special logic for this
if (StateMachine != null && StateMachine.Value != null)
{
if (!StateMachine.Value.battleStarted)
if (!StateMachine.Value.battleStarted && StateMachine.Value.useBoxToForceStart)
{
bool isColo = BattleManager.Instance.Value.gameObject.scene.name.Contains("Room_Colosseum_");
if (!isColo)
Expand Down Expand Up @@ -248,6 +248,20 @@ public static void PlayZoteTheme(bool gramaphone = false, float volume = .8f)

public static void StopZoteTheme()
{
var musicControl2 = GameObject.Find("Atmos Cave Wind");
if (musicControl2 == null)
return;

var globalAudioSource2 = musicControl2.GetComponent<AudioSource>();

if (globalAudioSource2 != null)
{
globalAudioSource2.Stop();

var normal = globalAudioSource2.outputAudioMixerGroup.audioMixer.FindSnapshot("Silence");
normal.TransitionTo(1f);
}

if (zmusic == null)
return;

Expand All @@ -267,6 +281,7 @@ public static void SilenceMusic()
if (globalAudioSource != null)
{
globalAudioSource.Stop();

var normal = globalAudioSource.outputAudioMixerGroup.audioMixer.FindSnapshot("Silence");
normal.TransitionTo(1f);
}
Expand All @@ -277,6 +292,7 @@ public static void DoSpecialSceneFixes(GameObject sceneObject)
Scene currentScene = sceneObject.scene;
}

public static bool startedZoteTheme = false;
public static void DoSceneCheck(GameObject sceneObject)
{
BattleManager.DidSceneCheck = true;
Expand Down Expand Up @@ -351,18 +367,23 @@ public static void DoSceneCheck(GameObject sceneObject)
}
}

if (EnemyRandomizerDatabase.GetGlobalSettings().allowEnemyRandoExtras)
try
{
//allow zote theme to play on these maps
if (currentScene.name != "Ruins1_27"
&& currentScene.name != "Fungus3_50"
&& currentScene.name != "Room_Colosseum_Bronze"
&& currentScene.name != "Room_Colosseum_Silver"
&& currentScene.name != "Room_Colosseum_Gold")
if (EnemyRandomizerDatabase.GetGlobalSettings().allowEnemyRandoExtras)
{
StopZoteTheme();
//allow zote theme to play on these maps
if (currentScene.name != "Ruins1_27"
&& currentScene.name != "Fungus3_50"
&& currentScene.name != "Room_Colosseum_Bronze"
&& currentScene.name != "Room_Colosseum_Silver"
&& currentScene.name != "Room_Colosseum_Gold")
{
if (startedZoteTheme)
StopZoteTheme();
}
}
}
catch (Exception e) { Dev.LogError($"Caught exception when trying to stop the zote theme? {e.Message}\n{e.StackTrace}"); }


//TODO: move this into a better spot for generating our custom content
Expand All @@ -371,6 +392,7 @@ public static void DoSceneCheck(GameObject sceneObject)
{
if (EnemyRandomizerDatabase.GetGlobalSettings().allowEnemyRandoExtras)
{
startedZoteTheme = true;
var center = GameObject.Find("_0083_fountain");
var back = GameObject.Find("_0082_fountain");
var right = GameObject.Find("_0092_fountain");
Expand Down Expand Up @@ -464,6 +486,7 @@ public static void DoSceneCheck(GameObject sceneObject)
{
if (EnemyRandomizerDatabase.GetGlobalSettings().allowEnemyRandoExtras)
{
startedZoteTheme = true;
try
{
GameObject go = new GameObject("Wall");
Expand Down
110 changes: 64 additions & 46 deletions EnemyRandomizerDll/EnemyRandomizerDB/Library/BattleStateMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class BattleStateMachine : IDisposable

public bool isCustomArena = false;
public bool isMiniArena = false;

public bool useBoxToForceStart = false;

public virtual Vector2 topLeft => Vector2.zero; //override these
public virtual Vector2 botRight => Vector2.zero;//override these
Expand All @@ -61,6 +61,12 @@ public virtual bool IsHeroInBattleArea()

public void ForceBattleStart()
{
if(SceneName == "Crossroads_04")
{
FSM.SetState("Detect");
FSM.SendEvent("START");
}

OnBattleStarted();
}

Expand Down Expand Up @@ -100,52 +106,52 @@ public virtual void Setup(Scene scene, PlayMakerFSM fsm)
On.HutongGames.PlayMaker.FsmState.OnEnter += FsmState_OnEnter;
}

IEnumerator FixFlyCorpse()
{
GameObject burster;
for (; ; )
{
yield return new WaitForEndOfFrame();
if (SceneName != "Crossroads_04")
yield break;

burster = GameObject.Find("Corpse Big Fly Burster(Clone)");
if (burster != null && burster.LocateMyFSM("burster").enabled)
break;
}

if (SpawnedObjectControl.VERBOSE_DEBUG)
Dev.Log("Found burster corpse");
if (SceneName != "Crossroads_04")
yield break;

var fsm = burster.LocateMyFSM("burster");
var spawn = fsm.GetState("Spawn Flies 2");
spawn.AddCustomAction(() => {
SpawnerExtensions.SpawnEnemyForEnemySpawner(burster.transform.position, true, "Fly");
SpawnerExtensions.SpawnEnemyForEnemySpawner(burster.transform.position, true, "Fly");
SpawnerExtensions.SpawnEnemyForEnemySpawner(burster.transform.position, true, "Fly");
SpawnerExtensions.SpawnEnemyForEnemySpawner(burster.transform.position, true, "Fly");
SpawnerExtensions.SpawnEnemyForEnemySpawner(burster.transform.position, true, "Fly");
SpawnerExtensions.SpawnEnemyForEnemySpawner(burster.transform.position, true, "Fly");
GameManager.instance.BroadcastFSMEventAfterTime("END", 4f);
});
if (SpawnedObjectControl.VERBOSE_DEBUG)
Dev.Log("Burster corpse setup complete");
}
//IEnumerator FixFlyCorpse()
//{
// GameObject burster;
// for (; ; )
// {
// yield return new WaitForEndOfFrame();
// if (SceneName != "Crossroads_04")
// yield break;

// burster = GameObject.Find("Corpse Big Fly Burster(Clone)");
// if (burster != null && burster.LocateMyFSM("burster").enabled)
// break;
// }

// if (SpawnedObjectControl.VERBOSE_DEBUG)
// Dev.Log("Found burster corpse");
// if (SceneName != "Crossroads_04")
// yield break;

// var fsm = burster.LocateMyFSM("burster");
// var spawn = fsm.GetState("Spawn Flies 2");
// spawn.AddCustomAction(() => {
// SpawnerExtensions.SpawnEnemyForEnemySpawner(burster.transform.position, true, "Fly");
// SpawnerExtensions.SpawnEnemyForEnemySpawner(burster.transform.position, true, "Fly");
// SpawnerExtensions.SpawnEnemyForEnemySpawner(burster.transform.position, true, "Fly");
// SpawnerExtensions.SpawnEnemyForEnemySpawner(burster.transform.position, true, "Fly");
// SpawnerExtensions.SpawnEnemyForEnemySpawner(burster.transform.position, true, "Fly");
// SpawnerExtensions.SpawnEnemyForEnemySpawner(burster.transform.position, true, "Fly");
// GameManager.instance.BroadcastFSMEventAfterTime("END", 4f);
// });
// if (SpawnedObjectControl.VERBOSE_DEBUG)
// Dev.Log("Burster corpse setup complete");
//}

protected virtual void OnBattleStarted()
{
if (SpawnedObjectControl.VERBOSE_DEBUG)
Dev.Log("BATTLE STARTED");

if (SceneName == "Crossroads_04")
{
if (GameManager.instance.playerData.giantFlyDefeated == false)
{
GameManager.instance.StartCoroutine(FixFlyCorpse());
}
}
//if (SceneName == "Crossroads_04")
//{
// if (GameManager.instance.playerData.giantFlyDefeated == false)
// {
// GameManager.instance.StartCoroutine(FixFlyCorpse());
// }
//}

battleStarted = true;
battleEnded = false;
Expand Down Expand Up @@ -241,6 +247,12 @@ IEnumerator ForceProgressWatchdog(float timer = 10f)

if (!battleStarted)
{
if(SceneName == "Ruins2_09")
{
if (FSM != null)
UnlockCameras(GetCameraLocksFromScene(FSM.gameObject));
}

if (SpawnedObjectControl.VERBOSE_DEBUG)
Dev.Log("WATCHDOG CANCELED");
yield break;
Expand Down Expand Up @@ -318,17 +330,21 @@ private void FsmState_OnEnter(On.HutongGames.PlayMaker.FsmState.orig_OnEnter ori
if (self == null || self.Fsm != FSM.Fsm)
return;

if (self.Actions.OfType<SendEventByName>().Any(x => x.sendEvent != null &&
(x.sendEvent.Value == "BG CLOSE" ||
if (self.Actions.OfType<SendEventByName>().Any(x => x.sendEvent != null && (
x.sendEvent.Value == "BG CLOSE" ||
x.sendEvent.Value == "DREAM GATE CLOSE" ||
x.sendEvent.Value == "FIGHT START" ||
x.sendEvent.Value == "GHOST FIGHT START" ||
x.sendEvent.Value == "BATTLE START")))
x.sendEvent.Value == "BATTLE START"
|| (SceneName == "Crossroads_04" && x.sendEvent.Value == "START")

)))
{
OnBattleStarted();
}

if (self.Actions.OfType<SendEventByName>().Any(x => x.sendEvent != null && (x.sendEvent.Value == "BG OPEN" ||
if (self.Actions.OfType<SendEventByName>().Any(x => x.sendEvent != null && (
x.sendEvent.Value == "BG OPEN" ||
x.sendEvent.Value == "GRIMM DEFEATED" ||
x.sendEvent.Value == "BOSS DEATH" ||
x.sendEvent.Value == "DISSIPATE" ||
Expand All @@ -337,7 +353,9 @@ private void FsmState_OnEnter(On.HutongGames.PlayMaker.FsmState.orig_OnEnter ori
x.sendEvent.Value == "DISSIPATE" ||
x.sendEvent.Value == "KILLED" ||
x.sendEvent.Value == "IK GATE OPEN" ||
x.sendEvent.Value == "BATTLE END")))
x.sendEvent.Value == "BATTLE END"
|| (SceneName == "Crossroads_04" && x.sendEvent.Value == "END")
)))
{
bool isColo = BattleManager.Instance.Value.gameObject.scene.name.Contains("Room_Colosseum_");
if (!isColo)
Expand Down
29 changes: 29 additions & 0 deletions EnemyRandomizerDll/EnemyRandomizerDB/Library/DatabaseInternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,35 @@ IPrefabConfig GetPrefabConfig(string prefabConfigNameToUse, Type defaultType = n
return (IPrefabConfig)Activator.CreateInstance(configType);
}

public ISpawner GetSpawner(string name)
{
string typeName = "EnemyRandomizerMod." + string.Join("", name.Split(' ')) + "Spawner";
Type spawnerType = null;
ISpawner spawnerTypeToUse = null;

try
{
if (DEBUG_VERBOSE_SPAWNER_ERRORS)
Dev.Log($"Trying to get spawner of type {typeName}");
spawnerType = typeof(EnemyRandomizerDatabase).Assembly.GetType(typeName);
}
catch (Exception e)
{
Dev.LogWarning($"No spawner found for {typeName} from the EnemyRandomizerDatabase assembly.");
}

if (spawnerType == null)
{
if (DEBUG_VERBOSE_SPAWNER_ERRORS)
Dev.Log($"No matching spawner type found for {typeName}");

return null;
}

spawnerTypeToUse = (ISpawner)Activator.CreateInstance(spawnerType);
return spawnerTypeToUse;
}

//TODO: fix this to load types from other assemblies/namespaces/etc
bool GetSpawner(PrefabObject p, Type defaultType, out ISpawner spawnerTypeToUse)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ public override void Setup(GameObject other)
protected override void OnHit(int dmgAmount)
{
if(isSuperHusk)
gameObject.SpawnEntity("Shot Markoth Nail", true);
gameObject.SpawnEntity("wp_saw", true);//temporary
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public class SuperSpitterControl : DefaultSpawnedEnemyControl

public AudioSource audio;

public int chanceToSpawnSuperBossOutOf100 = 2; // -> ( 2 / 100 )
public int chanceToSpawnSuperBossOutOf200 = 2; // -> ( 2 / 100 )
public bool isSuperBoss;

public override string customDreamnailText => isSuperBoss ? "Destroy." : base.customDreamnailText;
Expand All @@ -325,7 +325,7 @@ public class SuperSpitterControl : DefaultSpawnedEnemyControl

int[] stageHP = new int[4];

public float spawnCooldown = 10f;
public float spawnCooldown = 20f;
public float spawnTime = 0f;

public bool skipShooting = false;
Expand Down Expand Up @@ -570,7 +570,7 @@ public override void Setup(GameObject objectThatWillBeReplaced = null)

if (!isSuperBoss)
{
isSuperBoss = SpawnerExtensions.RollProbability(out int _, chanceToSpawnSuperBossOutOf100, 100);
isSuperBoss = SpawnerExtensions.RollProbability(out int _, chanceToSpawnSuperBossOutOf200, 200);
}

audio = GetComponent<AudioSource>();
Expand Down
Loading

0 comments on commit adf3158

Please sign in to comment.