static void MANAGE_RUN(string inputSeed, bool immediateRestart = false) { SoulsMod mod = new SoulsMod(MOD_PATH, ".smbak"); DSRHook hook = new DSRHook(5000, 5000); hook.Start(); Console.WriteLine("Waiting for game application to start..."); while (!hook.Hooked) { Thread.Sleep(100); } Console.WriteLine("Waiting for game to be loaded..."); while (!hook.Loaded) { Thread.Sleep(100); } Console.WriteLine("Hooked."); Console.WriteLine("Roguelike Souls manager starting..."); RunManager runManager = new RunManager(mod, hook, inputSeed); runManager.RunMainLoop(immediateRestart); }
static void RANDOMIZE_ENEMY_ATTACK_SPEEDS(string inputSeed) { MOD_PATH = GetGameDir(); if (MOD_PATH == null) { Console.WriteLine("No EXE selected. Cancelling attack speed randomization."); return; } Random random; random = inputSeed == "" ? new Random() : new Random(inputSeed.GetHashCode()); SoulsMod mod = new SoulsMod(MOD_PATH, ".rsbak"); mod.LoadNonPlayerCharacters(); EnemyAnimationGenerator animSetup = new EnemyAnimationGenerator(mod, random); #if DEBUG Console.WriteLine("Running animation setup..."); #else Console.WriteLine("Stepping into time vortex..."); #endif animSetup.AddSpeedEffects(noParamEdit: true); // just registers effect IDs in setup animSetup.AddAttackDamageEffects(noParamEdit: true); // just registers effect IDs in setup animSetup.RandomizeAllEnemySpeeds(); mod.InstallAnimations(skipPlayer: true); Thread.CurrentThread.Join(0); Console.WriteLine("\nEnemy attack speeds randomized successfully! Press ENTER to return to the prompt."); Console.ReadLine(); }
public NPCAnimationInfo(TAE.Animation anim, int characterID, SoulsMod mod) { ChrHandler chrHandler = mod[characterID]; if (chrHandler.ID == 0) { throw new ArgumentException("`NPCAnimationInfo` must receive a non-player `chrHandler`."); } InvokeAttackEvent = anim.FindEvent(1); AllInvokeAttackEvents = new List <TAE.Event>(anim.Events.Where(e => e.Type == 1)); InvokeBulletEvent = anim.FindEvent(2); AllInvokeBulletEvents = new List <TAE.Event>(anim.Events.Where(e => e.Type == 2)); PushEvent = anim.FindEvent(307); CurrentAnim = anim; Mod = mod; IsDeath = anim.FindJumpTable(12) != null; IsMove = anim.InRange(200, 599); IsDash = DashIds.Contains(anim.ID); IsThrow = chrHandler.ThrowAnimIds.Contains((int)anim.ID); HasInvokeBehaviorEvent = InvokeAttackEvent != null || InvokeBulletEvent != null || PushEvent != null; IsInjury = anim.InRange(2000, 2299); TAE.Event animationCancelEvent = anim.FindJumpTable(86); if (animationCancelEvent != null) { AnimationCancelEventEnd = animationCancelEvent.EndTime; } if (AllInvokeAttackEvents.Count != 0) { foreach (var invokeAttackEvent in AllInvokeAttackEvents) { int behaviorSubId = Convert.ToInt32(invokeAttackEvent.Parameters["BehaviorSubID"]); long behaviorParamId = 200000000 + 10000 * chrHandler.ID + behaviorSubId; AllAttackBehaviorParamIds.Add(behaviorParamId); } AttackBehaviorParamId = AllAttackBehaviorParamIds[0]; } if (AllInvokeBulletEvents.Count != 0) { foreach (var invokeBulletEvent in AllInvokeBulletEvents) { int behaviorSubId = Convert.ToInt32(invokeBulletEvent.Parameters["BehaviorSubID"]); long behaviorParamId = 200000000 + 10000 * chrHandler.ID + behaviorSubId; AllBulletBehaviorParamIds.Add(behaviorParamId); int behaviorDummyPolyId = Convert.ToInt32(invokeBulletEvent.Parameters["DummyPolyID"]); AllBulletDummyPolyIds.Add(behaviorDummyPolyId); } BulletBehaviorParamId = AllBulletBehaviorParamIds[0]; BulletDummyPolyId = AllBulletDummyPolyIds[0]; } }
public EnemyAnimationGenerator(SoulsMod mod, Random random) { if (MaxSpeedChangePerFrame < QuantizedSpeed) { throw new ArithmeticException("maxSpeedChangePerFrame cannot be less than quantizedSpeed."); } Mod = mod; Rand = random; MaxDifference = (int)(MaxSpeedChangePerFrame / QuantizedSpeed); MaxSpeedPoints = (int)(MaxSpeedMultiplier / QuantizedSpeed); }
static void InstallInterrootFolder(string dir, SoulsMod game) { foreach (string newFile in Directory.GetFiles($@"Package\{dir}")) { string originalFile = $@"{game.GameDir}{dir}\{Path.GetFileName(newFile)}"; if (File.Exists(originalFile)) { game.Backup(originalFile); } File.Copy(newFile, originalFile, true); } }
static void InstallInterrootFolder(string dir, SoulsMod game) { foreach (string newFile in Directory.GetFiles($@"Package\{dir}")) { string originalFile = $@"{game.GameDir}{dir}\{Path.GetFileName(newFile)}"; if (File.Exists(originalFile)) { game.Backup(originalFile); } File.Copy(newFile, originalFile, true); } foreach (string subfolder in Directory.GetDirectories($@"Package\{dir}")) { string subfolderName = subfolder.Split('\\').Last(); InstallInterrootFolder($@"{dir}\{subfolderName}", game); } }
public static float GuessBulletRadius(Bullet bullet, SoulsMod sm) { // Looks for the deepest possible hit radius (preferring "Final" over "Initial") in recursive bullet hierarchy. int childBulletID = bullet.BulletOnHit; if (childBulletID != -1) { return(GuessBulletRadius(sm.GPARAM.Bullets[childBulletID], sm)); } else { if (bullet.FinalHitRadius > 0.0f) { return(bullet.FinalHitRadius); } return(bullet.InitialHitRadius); } }
public RunManager(SoulsMod mod, DSRHook hook, string inputSeed = "") { #if !DEBUG if (DEBUG_MAP != "") { throw new ApplicationException("Debug map must be empty for release version!"); } #endif Mod = mod; Rand = inputSeed == "" ? new Random() : new Random(inputSeed.GetHashCode()); Hook = hook; if (GetFlag(GameFlag.RunStartedFlag)) { Console.WriteLine("Loading existing journey..."); LoadExistingRun(); Console.WriteLine("Journey loaded."); } }
static void INSTALL(string inputSeed, bool skipAnimRandomizer = false) { Random random; if (inputSeed == "") { random = new Random(); } else { random = new Random(inputSeed.GetHashCode()); } if (MOD_PATH == null) { MOD_PATH = AskForDir(); } else { Console.WriteLine("\nUse previously-specified game directory? (Y/N)"); bool yes = ReadKey(ConsoleKey.Y, ConsoleKey.N) == ConsoleKey.Y; if (!yes) { MOD_PATH = AskForDir(); } } if (MOD_PATH == null) { Console.WriteLine("No EXE selected. Cancelling installation."); return; } DateTime startTime = DateTime.Now; Console.WriteLine("\nBeginning installation... This will take about one minute."); Console.WriteLine("\n" + SoyPuns.PopRandomElement(random) + "\n"); SoulsMod mod = new SoulsMod( MOD_PATH, ".smbak", Resources.GameData.GameParam_parambnd, Resources.GameData.paramdef_paramdefbnd, Resources.GameData.item_msgbnd, Resources.GameData.menu_msgbnd); mod.LoadPlayerCharacter(); mod.LoadNonPlayerCharacters(); InstallInterrootFolder("event", mod); InstallInterrootFolder("map", mod); InstallInterrootFolder("script", mod); InstallInterrootFolder("sfx", mod); InstallInterrootFolder("sound", mod); PlayerGenerator playerSetup = new PlayerGenerator(mod); #if DEBUG Console.WriteLine("Running player setup..."); #endif playerSetup.Install(); Thread.CurrentThread.Join(0); TextGenerator textSetup = new TextGenerator(mod); #if DEBUG Console.WriteLine("Running text setup..."); #endif textSetup.Install(); Thread.CurrentThread.Join(0); SpEffectGenerator spEffectSetup = new SpEffectGenerator(mod); #if DEBUG Console.WriteLine("Running SpEffect setup..."); #endif spEffectSetup.Install(); Thread.CurrentThread.Join(0); GoodsGenerator goodsSetup = new GoodsGenerator(mod); #if DEBUG Console.WriteLine("Running goods setup..."); #endif goodsSetup.Install(); Thread.CurrentThread.Join(0); SpellGenerator spellSetup = new SpellGenerator(mod, random); #if DEBUG Console.WriteLine("Running spell setup..."); #endif spellSetup.Install(); Thread.CurrentThread.Join(0); WeaponGenerator weaponSetup = new WeaponGenerator(mod, random); #if DEBUG Console.WriteLine("Running weapon setup..."); #endif weaponSetup.Install(); Thread.CurrentThread.Join(0); ArmorGenerator armorSetup = new ArmorGenerator(mod, random); #if DEBUG Console.WriteLine("Running armor setup..."); #endif armorSetup.Install(); Thread.CurrentThread.Join(0); EnemyGenerator enemySetup = new EnemyGenerator(mod, random, weaponSetup, armorSetup); #if DEBUG Console.WriteLine("Running enemy setup..."); #endif enemySetup.Install(); Thread.CurrentThread.Join(0); MapItemLotsGenerator itemLotsSetup = new MapItemLotsGenerator(mod, weaponSetup, armorSetup, random); #if DEBUG Console.WriteLine("Running item lot setup..."); #endif itemLotsSetup.Install(); Thread.CurrentThread.Join(0); EnemyAnimationGenerator animSetup = new EnemyAnimationGenerator(mod, random); #if DEBUG Console.WriteLine("Running animation setup..."); #endif animSetup.Install(skipAnimRandomizer); Thread.CurrentThread.Join(0); // Must be run AFTER weapon/armor setup. CharacterGenerator chrSetup = new CharacterGenerator(mod, random); #if DEBUG Console.WriteLine("Running chr setup..."); #endif chrSetup.Install(); Thread.CurrentThread.Join(0); Console.WriteLine(SoyPuns.PopRandomElement(random) + "\n"); #if DEBUG Console.WriteLine("Installing mod..."); #endif mod.Install(); Thread.CurrentThread.Join(0); #if DEBUG Console.WriteLine($"Installation time: {(DateTime.Now - startTime).TotalSeconds}"); #endif }
public PlayerGenerator(SoulsMod mod) { Mod = mod; }
public MSBGenerator(RunManager runManager, SoulsMod mod, Random random) { Run = runManager; Mod = mod; Rand = random; }
public TextGenerator(SoulsMod mod) { Mod = mod; }
public AnimHandler(SoulsMod sm, PlayerMoveset m, Animation a) { SM = sm; Moves = m; Anim = a; }
static void INSTALL(string inputSeed) { Random random; random = inputSeed == "" ? new Random() : new Random(inputSeed.GetHashCode()); MOD_PATH = GetGameDir(); if (MOD_PATH == null) { Console.WriteLine("No EXE selected. Cancelling installation."); return; } DateTime startTime = DateTime.Now; Console.WriteLine("\nBeginning installation... This will take about one minute."); Console.WriteLine("\n" + SoyPuns.PopRandomElement(random) + "\n"); SoulsMod mod = new SoulsMod( MOD_PATH, ".rsbak", Resources.GameData.GameParam_parambnd, Resources.GameData.paramdef_paramdefbnd, Resources.GameData.item_msgbnd, Resources.GameData.menu_msgbnd); mod.LoadPlayerCharacter(); mod.LoadNonPlayerCharacters(); InstallInterrootFolder("event", mod); InstallInterrootFolder("map", mod); InstallInterrootFolder("script", mod); InstallInterrootFolder("sfx", mod); InstallInterrootFolder("sound", mod); TextGenerator textSetup = new TextGenerator(mod); #if DEBUG Console.WriteLine("Running text setup..."); #else Console.WriteLine("Studying the ancient texts..."); #endif textSetup.Install(); Thread.CurrentThread.Join(0); PlayerGenerator playerSetup = new PlayerGenerator(mod); #if DEBUG Console.WriteLine("Running player setup..."); #else Console.WriteLine("Putting the party together..."); #endif playerSetup.Install(); Thread.CurrentThread.Join(0); SpEffectGenerator spEffectSetup = new SpEffectGenerator(mod); #if DEBUG Console.WriteLine("Running SpEffect setup..."); #else Console.WriteLine("Channeling the powers that be..."); #endif spEffectSetup.Install(); Thread.CurrentThread.Join(0); GoodsGenerator goodsSetup = new GoodsGenerator(mod); #if DEBUG Console.WriteLine("Running goods setup..."); #else Console.WriteLine("Documenting the artifacts..."); #endif goodsSetup.Install(); Thread.CurrentThread.Join(0); SpellGenerator spellSetup = new SpellGenerator(mod, random); #if DEBUG Console.WriteLine("Running spell setup..."); #else Console.WriteLine("Messing with forces beyond our control..."); #endif spellSetup.Install(); Thread.CurrentThread.Join(0); WeaponGenerator weaponSetup = new WeaponGenerator(mod, random); #if DEBUG Console.WriteLine("Running weapon setup..."); #else Console.WriteLine("Spinning up the whetstone..."); #endif #if SKIP_BEHAVIORS Console.WriteLine("WARNING: Skipping weapon behaviors/attacks!"); weaponSetup.SkipBehaviors = true; #endif weaponSetup.Install(); Thread.CurrentThread.Join(0); ArmorGenerator armorSetup = new ArmorGenerator(mod, random); #if DEBUG Console.WriteLine("Running armor setup..."); #else Console.WriteLine("Polishing the armor..."); #endif armorSetup.Install(); Thread.CurrentThread.Join(0); EnemyGenerator enemySetup = new EnemyGenerator(mod, random, weaponSetup, armorSetup); #if DEBUG Console.WriteLine("Running enemy setup..."); #else Console.WriteLine("Opening the bestiary..."); #endif enemySetup.Install(); Thread.CurrentThread.Join(0); EnemyAnimationGenerator animSetup = new EnemyAnimationGenerator(mod, random); #if DEBUG Console.WriteLine("Modifying enemy animations..."); #else Console.WriteLine("Rousing the rabble..."); #endif animSetup.Install(); Thread.CurrentThread.Join(0); MapItemLotsGenerator itemLotsSetup = new MapItemLotsGenerator(mod, weaponSetup, armorSetup, random); #if DEBUG Console.WriteLine("Running item lot setup..."); #else Console.WriteLine("Burying the treasures..."); #endif itemLotsSetup.Install(); Thread.CurrentThread.Join(0); // Must be run AFTER weapon/armor setup. CharacterGenerator chrSetup = new CharacterGenerator(mod, random); #if DEBUG Console.WriteLine("Running character setup..."); #else Console.WriteLine("Assembling the party..."); #endif chrSetup.Install(); Thread.CurrentThread.Join(0); #if DEBUG Console.WriteLine("Installing mod..."); #else Console.WriteLine("Heading forth..."); #endif mod.Install(); Thread.CurrentThread.Join(0); Console.WriteLine("\nInstallation successful! Press ENTER to return to the prompt."); #if DEBUG Console.WriteLine($"Installation time: {(DateTime.Now - startTime).TotalSeconds} seconds"); #endif Console.ReadLine(); }