Skip to content

Commit

Permalink
BlinkCV Fix + Elevator CP update
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmgvol committed Apr 22, 2021
1 parent 4e1de3f commit 34091f8
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 29 deletions.
2 changes: 1 addition & 1 deletion GhostrunnerRNG/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public partial class MainWindow : Window {
default:
break;
}
e.Handled = true;
e.Handled = false;
}

//// Log & GlobalLog ////
Expand Down
7 changes: 5 additions & 2 deletions GhostrunnerRNG/MapGen/MapCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,14 @@ public abstract class MapCore {
CheckPlayerMove(true);
}

// player moved?
if(!PlayerMoved)
CheckPlayerMove();

// forced restart?
if(Config.GetInstance().Settings_ForcedRestart && !ForcedCPFlag && CPRequired && GameHook.CP_COUNTER == 0) {
float value = 0;
bool canRestart;
CheckPlayerMove();
GameHook.game.ReadValue(CoreEP.Pointers["CutsceneTimer"].Item2, out value);
GameHook.game.ReadValue(CoreEP.Pointers["CanRestart"].Item2, out canRestart);

Expand Down Expand Up @@ -284,7 +287,7 @@ public abstract class MapCore {
}

// restart disabled? enable it!
if(restartFlag[0] == 0) GameHook.game.WriteBytes(CoreEP.Pointers["RestartFlag"].Item2, new byte[] {1});
if(restartFlag[0] == 0) GameHook.game.WriteBytes(CoreEP.Pointers["RestartFlag"].Item2, new byte[] {1 });

if(mapType == MapType.Awakening) Thread.Sleep(500);
// simulate restart key
Expand Down
95 changes: 74 additions & 21 deletions GhostrunnerRNG/Maps/BlinkCV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,26 @@ class BlinkCV : MapCore {
Room room2 = new Room(new Vector3f(-9458, 18142, -135), new Vector3f(-5490, 14078, 1942));
Room room_3platforms = new Room(new Vector3f(-9025, 10537, -563), new Vector3f(-6563, 7547, 1574));

List<Vector3f> platformDefaultPositions = new List<Vector3f>();

// predefined spawns for platforms
List<PlatformSpawner> platformSpawns = new List<PlatformSpawner>();
List<CVPlatform> platforms = new List<CVPlatform>();

public BlinkCV() : base(GameUtils.MapType.BlinkCV, manualGen:true) {
public BlinkCV() : base(GameUtils.MapType.BlinkCV, manualGen: true) {
if(GameHook.IsHC) return;

Gen_PerRoom();
}

protected override void Gen_PerRoom() {
// get all enemies and create layout & rooms
List<Enemy> AllEnemies = GetAllEnemies(GameHook.game);
//// Sort enemies per room ////

// Sort enemies per room
Enemies_Room1 = room1.ReturnEnemiesInRoom(AllEnemies);
Enemies_Room2 = room2.ReturnEnemiesInRoom(AllEnemies);
Enemies_Room3 = room_3platforms.ReturnEnemiesInRoom(AllEnemies);

// spawn planes for 3 platforms
platformSpawns.Add(new PlatformSpawner() {
p1_start = new Vector3f(-7331, 9542, 803),
Expand Down Expand Up @@ -72,9 +73,20 @@ class BlinkCV : MapCore {
platforms.Add(new CVPlatform(new DeepPointer(0x04609420, 0x30, 0xA8, 0x138)));
platforms.Add(new CVPlatform(new DeepPointer(0x04609420, 0x30, 0xA8, 0x128)));
platforms.Add(new CVPlatform(new DeepPointer(0x04609420, 0x30, 0xA8, 0x130)));

// default pos
platformDefaultPositions.Add(platforms[0].GetMemoryPos(GameHook.game));
platformDefaultPositions.Add(platforms[1].GetMemoryPos(GameHook.game));
platformDefaultPositions.Add(platforms[2].GetMemoryPos(GameHook.game));

// set second patrol to same pos (stop platforms)
for (int i = 0; i < platforms.Count; i++) {
platforms[i].Pos = platformDefaultPositions[i];
platforms[i].EndPoint = platformDefaultPositions[i];
platforms[i].WriteMemory(GameHook.game);
}
}

// Custom Randomizer
public override void RandomizeEnemies(Process game) {
//// Room 1 ////
Vector3f pos1 = new Vector3f(-7550, 23550, 390);
Expand Down Expand Up @@ -102,27 +114,68 @@ class BlinkCV : MapCore {
Enemies_Room2[2].SetMemoryPos(game, new SpawnData(pos6));

//// room 3 - platforms ////
int spawnIndex = Config.GetInstance().r.Next(platformSpawns.Count);
if (FirstPlatformsRngFlag) {
int spawnIndex = Config.GetInstance().r.Next(platformSpawns.Count);

//asign platform values
platforms[0].Pos = platformSpawns[spawnIndex].p1_start;
platforms[0].EndPoint = platformSpawns[spawnIndex].p1_end;
platforms[0].WriteMemory(GameHook.game);

platforms[1].Pos = platformSpawns[spawnIndex].p2_start;
platforms[1].WriteMemory(GameHook.game);

platforms[2].Pos = platformSpawns[spawnIndex].p3_start;
platforms[2].EndPoint = platformSpawns[spawnIndex].p3_end;
platforms[2].WriteMemory(GameHook.game);

// asign enemies based on platform rng
Enemies_Room3[0].SetMemoryPos(game, new SpawnData(platformSpawns[spawnIndex].p1_start + new Vector3f(0, -25, 110)));
Enemies_Room3[1].SetMemoryPos(game, new SpawnData(platformSpawns[spawnIndex].p2_start + new Vector3f(0, -25, 110)));
Enemies_Room3[2].SetMemoryPos(game, new SpawnData(platformSpawns[spawnIndex].p3_start + new Vector3f(0, -25, 110)));
}
}

// asign platform values
platforms[0].Pos = platformSpawns[spawnIndex].p1_start;
platforms[0].EndPoint = platformSpawns[spawnIndex].p1_end;
platforms[0].WriteMemory(GameHook.game);
private bool FirstPlatformsRngFlag = false;
// Trigger Volume for Platforms
private Vector3f cornerA = new Vector3f(-10817, 19596, 1975);
private Vector3f cornerB = new Vector3f(-3712, 21937, -1790);

platforms[1].Pos = platformSpawns[spawnIndex].p2_start;
platforms[1].WriteMemory(GameHook.game);
public override void UpdateMap(Vector3f Player) {
base.UpdateMap(Player);

platforms[2].Pos = platformSpawns[spawnIndex].p3_start;
platforms[2].EndPoint = platformSpawns[spawnIndex].p3_end;
platforms[2].WriteMemory(GameHook.game);
if (!FirstPlatformsRngFlag && PlayerInVolume(Player)) {
FirstPlatformsRngFlag = true;

// rng
int spawnIndex = Config.GetInstance().r.Next(platformSpawns.Count);

//asign platform values
platforms[0].Pos = platformSpawns[spawnIndex].p1_start;
platforms[0].EndPoint = platformSpawns[spawnIndex].p1_end;
platforms[0].WriteMemory(GameHook.game);

platforms[1].Pos = platformSpawns[spawnIndex].p2_start;
platforms[1].WriteMemory(GameHook.game);

platforms[2].Pos = platformSpawns[spawnIndex].p3_start;
platforms[2].EndPoint = platformSpawns[spawnIndex].p3_end;
platforms[2].WriteMemory(GameHook.game);

// asign enemies based on platform rng
Enemies_Room3[0].SetMemoryPos(GameHook.game, new SpawnData(platformSpawns[spawnIndex].p1_start + new Vector3f(0, -25, 110)));
Enemies_Room3[1].SetMemoryPos(GameHook.game, new SpawnData(platformSpawns[spawnIndex].p2_start + new Vector3f(0, -25, 110)));
Enemies_Room3[2].SetMemoryPos(GameHook.game, new SpawnData(platformSpawns[spawnIndex].p3_start + new Vector3f(0, -25, 110)));
}
}

// asign enemies based on platform rng
Enemies_Room3[0].SetMemoryPos(game, new SpawnData(platformSpawns[spawnIndex].p1_start + new Vector3f(0, -25, 110)));
Enemies_Room3[1].SetMemoryPos(game, new SpawnData(platformSpawns[spawnIndex].p2_start + new Vector3f(0, -25, 110)));
Enemies_Room3[2].SetMemoryPos(game, new SpawnData(platformSpawns[spawnIndex].p3_start + new Vector3f(0, -25, 110)));
private bool PlayerInVolume(Vector3f player) {
return (player.X >= Math.Min(cornerA.X, cornerB.X) && player.X <= Math.Max(cornerA.X, cornerB.X) &&
player.Y >= Math.Min(cornerA.Y, cornerB.Y) && player.Y <= Math.Max(cornerA.Y, cornerB.Y) &&
player.Z >= Math.Min(cornerA.Z, cornerB.Z) && player.Z <= Math.Max(cornerA.Z, cornerB.Z));
}

private struct PlatformSpawner{
private struct PlatformSpawner {
public Vector3f p1_start, p1_end;
public Vector3f p2_start;
public Vector3f p3_start, p3_end;
Expand Down
1 change: 1 addition & 0 deletions GhostrunnerRNG/Maps/BreatheIn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class BreatheIn : MapCore {
}

protected override void Gen_PerRoom() {
ModifyCP(new DeepPointer(0x04609420, 0x98, 0x8, 0x128, 0xA8, 0x40, 0x248, 0x1D0), new Vector3f(197550, -49400, 9645), GameHook.game);
List<Enemy> AllEnemies = GetAllEnemies(GameHook.game);
Rooms = new List<RoomLayout>();
RoomLayout layout;
Expand Down
1 change: 1 addition & 0 deletions GhostrunnerRNG/Maps/DharmaCity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class DharmaCity : MapCore {
}

protected override void Gen_PerRoom() {
ModifyCP(new DeepPointer(0x04609420, 0x98, 0x0, 0x128, 0xA8, 0xE8, 0x248, 0x1D0), new Vector3f(104390, -13350, 1745), GameHook.game);
List<Enemy> AllEnemies = GetAllEnemies(GameHook.game, 0, 27);
AllEnemies.AddRange(GetAllEnemies(GameHook.game, 32, 7));

Expand Down
5 changes: 1 addition & 4 deletions GhostrunnerRNG/Maps/Echoes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
using GhostrunnerRNG.Game;
using GhostrunnerRNG.MapGen;
using GhostrunnerRNG.NonPlaceableObjects;
using System;
using System.Collections.Generic;
using System.Linq;
using static GhostrunnerRNG.Enemies.Enemy;

namespace GhostrunnerRNG.Maps {
Expand Down Expand Up @@ -46,8 +44,7 @@ class Echoes : MapCore {
Gen_PerRoom();
}
protected override void Gen_PerRoom() {
//indexes from 0 to 61 without 30 - 31

ModifyCP(new DeepPointer(0x04609420, 0x98, 0x30, 0x128, 0xA8, 0x1280, 0x248, 0x1D0), new Vector3f(67150, -3805.012695f, 6745), GameHook.game);
List<Enemy> AllEnemies = GetAllEnemies(GameHook.game, 0, 30);
AllEnemies.AddRange(GetAllEnemies(GameHook.game, 32, 30));

Expand Down
1 change: 1 addition & 0 deletions GhostrunnerRNG/Maps/ForbiddenZone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class ForbiddenZone : MapCore {
}

protected override void Gen_PerRoom() {
ModifyCP(new DeepPointer(0x04609420, 0x98, 0x8, 0x128, 0xA8, 0x78, 0x248, 0x1D0), new Vector3f(73395, -3290, 1340), GameHook.game);
List<Enemy> AllEnemies = GetAllEnemies(GameHook.game, 0, 26);
AllEnemies.AddRange(GetAllEnemies(GameHook.game, 27, 13));
Rooms = new List<RoomLayout>();
Expand Down
1 change: 1 addition & 0 deletions GhostrunnerRNG/Maps/JackedUp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class JackedUp : MapCore {
Gen_PerRoom();
}
protected override void Gen_PerRoom() {
ModifyCP(new DeepPointer(0x04609420, 0x98, 0x8, 0x128, 0xA8, 0x30, 0x248, 0x1D0), new Vector3f(-6140, -25230, 1645), GameHook.game);
List<Enemy> AllEnemies = GetAllEnemies(GameHook.game);
Rooms = new List<RoomLayout>();
RoomLayout layout;
Expand Down
1 change: 1 addition & 0 deletions GhostrunnerRNG/Maps/ReignInHell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class ReignInHell : MapCore {
}

protected override void Gen_PerRoom() {
ModifyCP(new DeepPointer(0x04609420, 0x98, 0x0, 0x128, 0xA8, 0x58, 0x248, 0x1D0), new Vector3f(-4295, -11605, 2455), GameHook.game);
List<Enemy> AllEnemies = GetAllEnemies(GameHook.game, 0, 36);
Rooms = new List<RoomLayout>();
RoomLayout layout;
Expand Down
1 change: 1 addition & 0 deletions GhostrunnerRNG/Maps/RoadToAmida.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class RoadToAmida : MapCore {
Gen_PerRoom();
}
protected override void Gen_PerRoom() {
ModifyCP(new DeepPointer(0x04609420, 0x98, 0x0, 0x128, 0xA8, 0xD0, 0x248, 0x1D0), new Vector3f(-122000, -39020, -11285), GameHook.game);
List<Enemy> AllEnemies = GetAllEnemies(GameHook.game, 0, 16);
AllEnemies.AddRange(GetAllEnemies(GameHook.game, 20, 22));

Expand Down
2 changes: 1 addition & 1 deletion GhostrunnerRNG/Maps/TYWB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TYWB : MapCore {
}

protected override void Gen_PerRoom() {
// static enemy gap
ModifyCP(new DeepPointer(0x04609420, 0x98, 0x0, 0x128, 0xA8, 0xD0, 0x248, 0x1D0), new Vector3f(33409, -55474, 2309), GameHook.game);
List<Enemy> AllEnemies = GetAllEnemies(GameHook.game, 0, 29);
AllEnemies.AddRange(GetAllEnemies(GameHook.game, 39, 30));
// dynamic gap: bulk search and filter by exact locations
Expand Down

0 comments on commit 34091f8

Please sign in to comment.