Skip to content

Commit e6687ba

Browse files
committed
Port Buddha Mode from 1.3
1 parent e6166a1 commit e6687ba

File tree

4 files changed

+36
-3
lines changed

4 files changed

+36
-3
lines changed

HEROsModModPlayer.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,19 @@ public override void SetControls()
5353

5454
public override bool PreHurt(bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource)
5555
{
56-
if (GodModeService.Enabled)
56+
if (GodModeService.Enabled && !GodModeService.BuddhaMode)
57+
{
58+
return false;
59+
}
60+
return true;
61+
}
62+
63+
public override bool PreKill(double damage, int hitDirection, bool pvp, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource)
64+
{
65+
if (GodModeService.Enabled && GodModeService.BuddhaMode)
5766
{
67+
Player.statLife = Player.statLifeMax2;
68+
Player.lifeRegen = 999;
5869
return false;
5970
}
6071
return true;
@@ -64,7 +75,8 @@ public override void PreUpdate()
6475
{
6576
if (GodModeService.Enabled)
6677
{
67-
Player.statLife = Player.statLifeMax2;
78+
if (!GodModeService.BuddhaMode)
79+
Player.statLife = Player.statLifeMax2;
6880
Player.statMana = Player.statManaMax2;
6981
Player.wingTime = Player.wingTimeMax;
7082
}

HEROsModServices/GodModeService.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ internal class GodModeService : HEROsModService
1515

1616
private static bool _enabled = false;
1717

18+
internal static bool BuddhaMode = false; // changes the behavior of god mode, not a separate permission.
19+
1820
public static bool Enabled
1921
{
2022
get { return _enabled; }
@@ -33,10 +35,27 @@ public GodModeService()
3335
this._hotbarIcon = new UIImage(HEROsMod.instance.Assets.Request<Texture2D>("Images/godMode", AssetRequestMode.ImmediateLoad)/*Main.itemTexture[1990]*/);
3436
this.HotbarIcon.Tooltip = HEROsMod.HeroText("ToggleGodMode");
3537
this.HotbarIcon.onLeftClick += HotbarIcon_onLeftClick;
38+
this.HotbarIcon.onRightClick += HotbarIcon_onRightClick;
3639
GodModeToggled += GodModeService_GodModeToggled;
3740
Enabled = false;
3841
}
3942

43+
private void HotbarIcon_onRightClick(object sender, EventArgs e)
44+
{
45+
BuddhaMode = !BuddhaMode;
46+
if (BuddhaMode)
47+
{
48+
Main.NewText(HEROsMod.HeroText("BuddhaModeEnabled"));
49+
this._hotbarIcon.Texture = HEROsMod.instance.Assets.Request<Texture2D>("Images/buddhaMode", AssetRequestMode.ImmediateLoad);
50+
}
51+
else
52+
{
53+
Main.NewText(HEROsMod.HeroText("BuddhaModeDisabled"));
54+
this._hotbarIcon.Texture = HEROsMod.instance.Assets.Request<Texture2D>("Images/godMode", AssetRequestMode.ImmediateLoad);
55+
}
56+
}
57+
58+
4059
private void GodModeService_GodModeToggled(bool enabled, bool prevEnabled)
4160
{
4261
if (enabled)

Images/buddhaMode.png

3.19 KB
Loading

Localization/en-US.hjson

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,11 @@ Mods: {
156156
Groups: Groups
157157
GroupName: Group Name
158158
AreYouSureDeleteGroup: Are you sure you want to delete the {0} group?
159-
ToggleGodMode: Toggle God Mode
159+
ToggleGodMode: Toggle God Mode (RMB: Toggle Receiving Damage)
160160
GodModeEnabled: God Mode Enabled
161161
GodModeDisabled: God Mode Disabled
162+
BuddhaModeEnabled: Damage Will Be Received While In God Mode
163+
BuddhaModeDisabled: Damage Will Not Be Received While In God Mode
162164
FlyCamEnableTooltip: Enable Fly Camera (RMB: Lock Camera)
163165
FlyCamDisableTooltip: Disable Fly Camera (RMB: Lock Camera)
164166
FlyCamInstructions: Arrow Keys to pan, Shift for faster, Alt for slower

0 commit comments

Comments
 (0)