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

Commit

Permalink
[RLR-T-22] Adjust some traits not working with Genetic Lottery.
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePhar committed Oct 26, 2023
1 parent 061bcd9 commit 8e49d86
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 33 deletions.
57 changes: 49 additions & 8 deletions Randomizer/ItemHandler.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
// RogueLegacyRandomizer - ItemHandler.cs
// Last Modified 2023-10-25 9:15 PM
//
// Last Modified 2023-10-26 4:05 PM
//
// This project is based on the modified disassembly of Rogue Legacy's engine, with permission to do so by its
// original creators. Therefore, the former creators' copyright notice applies to the original disassembly.
//
//
// Original Source - © 2011-2018, Cellar Door Games Inc.
// Rogue Legacy™ is a trademark or registered trademark of Cellar Door Games Inc. All Rights Reserved.

using System;
using System.Collections.Generic;
using Archipelago.MultiClient.Net.Models;
using DS2DEngine;
using Microsoft.Xna.Framework;
using Randomizer.Definitions;
using RogueLegacy;
using RogueLegacy.Enums;
using Game = RogueLegacy.Game;

namespace Randomizer;

Expand Down Expand Up @@ -410,14 +408,16 @@ private static void GainItem(NetworkItem item)
break;

case ItemCode.TRAP_GENETIC_LOTTERY:
// Class and HP + MP
var percentHP = Game.ScreenManager.Player.CurrentHealth / (float) Game.ScreenManager.Player.MaxHealth;
var percentMP = Game.ScreenManager.Player.CurrentMana / (float) Game.ScreenManager.Player.MaxMana;
Game.PlayerStats.Class = (byte) ClassExtensions.RandomClass();
Game.ScreenManager.Player.CurrentHealth = (int) Math.Ceiling(Game.ScreenManager.Player.MaxHealth * percentHP);
Game.ScreenManager.Player.CurrentMana = (int) Math.Ceiling(Game.ScreenManager.Player.MaxMana * percentMP);

var spells = ((ClassType) Game.PlayerStats.Class).SpellList();
Game.PlayerStats.Spell = (byte) spells[CDGMath.RandomInt(0, spells.Length - 1)];

var traits = TraitHelper.ReturnRandomTraits();
Game.PlayerStats.Traits = new Vector2((float) traits[0], (float) traits[1]);

var currentlyFemale = Game.PlayerStats.IsFemale;
Game.PlayerStats.IsFemale = CDGMath.RandomInt(0, 1) == 0;
if (currentlyFemale != Game.PlayerStats.IsFemale)
Expand All @@ -426,6 +426,47 @@ private static void GainItem(NetworkItem item)
? Game.PlayerStats.PlayerName.Replace("Sir ", "Lady ")
: Game.PlayerStats.PlayerName.Replace("Lady ", "Sir ");
}

// Validate some of the traits.
do
{
var traits = TraitHelper.ReturnRandomTraits();
Game.PlayerStats.Traits = new((float) traits[0], (float) traits[1]);
} while (TraitHelper.HasAnyTrait(Trait.TheOne));

// Swap health.
if (TraitHelper.HasTrait(Trait.Dextrocardia))
{
Game.ScreenManager.Player.CurrentHealth = (int) Math.Ceiling(Game.ScreenManager.Player.MaxHealth * percentHP);
Game.ScreenManager.Player.CurrentMana = (int) Math.Ceiling(Game.ScreenManager.Player.MaxMana * percentMP);
}

// Sizing
if (TraitHelper.HasTrait(Trait.Gigantism))
{
Game.ScreenManager.Player.Scale = new(3f, 3f);
}
else if (TraitHelper.HasTrait(Trait.Dwarfism))
{
Game.ScreenManager.Player.Scale = new(1.35f, 1.35f);
}
else
{
Game.ScreenManager.Player.Scale = new(2f, 2f);
}

// Ecto / Endo
if (TraitHelper.HasTrait(Trait.Ectomorph))
{
Player.ScaleX *= 0.825f;
Player.ScaleY *= 1.15f;
}
else if (TraitHelper.HasTrait(Trait.Endomorph))
{
Player.ScaleX *= 1.25f;
Player.ScaleY *= 1.175f;
}

break;

#endregion
Expand Down
55 changes: 30 additions & 25 deletions RogueLegacy/Enums/Trait.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// RogueLegacyRandomizer - Trait.cs
// Last Modified 2023-07-30 10:59 AM by
//
// This project is based on the modified disassembly of Rogue Legacy's engine, with permission to do so by its
// original creators. Therefore, the former creators' copyright notice applies to the original disassembly.
//
// Original Source - © 2011-2018, Cellar Door Games Inc.
// Rogue Legacy™ is a trademark or registered trademark of Cellar Door Games Inc. All Rights Reserved.
// RogueLegacyRandomizer - Trait.cs
// Last Modified 2023-10-26 4:05 PM
//
// This project is based on the modified disassembly of Rogue Legacy's engine, with permission to do so by its
// original creators. Therefore, the former creators' copyright notice applies to the original disassembly.
//
// Original Source - © 2011-2018, Cellar Door Games Inc.
// Rogue Legacy™ is a trademark or registered trademark of Cellar Door Games Inc. All Rights Reserved.

using System;
using System.Linq;
Expand All @@ -16,41 +16,41 @@ namespace RogueLegacy.Enums;
public enum Trait
{
None = 0,
ColorBlind = 1,
Gay = 2,
NearSighted = 3,
FarSighted = 4,
ColorBlind = 1, // Good
Gay = 2, // Good
NearSighted = 3, // Good
FarSighted = 4, // Good
Dyslexia = 5,
Gigantism = 6,
Dwarfism = 7,
Gigantism = 6, // Good
Dwarfism = 7, // Good
Baldness = 8,
Endomorph = 9,
Ectomorph = 10,
Alzheimers = 11,
Dextrocardia = 12,
Coprolalia = 13,
Hyperactive = 14,
Hyperactive = 14, // Good
OCD = 15,
Hypergonadism = 16,
Hypogonadism = 17,
Hypergonadism = 16, // Good
Hypogonadism = 17, // Good
StereoBlind = 18,
IBS = 19,
Vertigo = 20,
Vertigo = 20, // Good
TunnelVision = 21,
Ambilevous = 22,
PAD = 23,
Alektorophobia = 24,
Hypochondriac = 25,
Dementia = 26,
Dementia = 26, // Good
Flexible = 27,
EideticMemory = 28,
Nostalgic = 29,
CIP = 30,
EideticMemory = 28, // Good
Nostalgic = 29, // Good
CIP = 30, // Good
Savant = 31,
TheOne = 32,
TheOne = 32, // Not Good
Clumsy = 33,
EHS = 34,
Glaucoma = 35
Glaucoma = 35,

// Hilarious that this is a trait in the game.
// Adopted = 100
Expand Down Expand Up @@ -311,4 +311,9 @@ public static bool HasTrait(Trait trait)
// ReSharper disable line CompareOfFloatsByEqualityOperator
return Game.PlayerStats.Traits.X == (float) trait || Game.PlayerStats.Traits.Y == (float) trait;
}
}

public static bool HasAnyTrait(params Trait[] traits)
{
return traits.Any(HasTrait);
}
}

0 comments on commit 8e49d86

Please sign in to comment.