Skip to content

Commit 3530bff

Browse files
committed
0.1.6, LightHack
1 parent 8c1b883 commit 3530bff

File tree

7 files changed

+67
-1
lines changed

7 files changed

+67
-1
lines changed

HEROsMod.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ public static void LoadAddServices()
351351
ServiceController.AddService(instance.miscOptions);
352352
ServiceController.AddService(new SpawnPointSetter(instance.miscOptions.Hotbar));
353353
ServiceController.AddService(new MapRevealer(instance.miscOptions.Hotbar));
354+
ServiceController.AddService(new LightHack(instance.miscOptions.Hotbar));
354355
ServiceController.AddService(new ItemBanner(instance.miscOptions.Hotbar));
355356
ServiceController.AddService(new ToggleGravestones(instance.miscOptions.Hotbar));
356357
ServiceController.AddService(new GroupInspector(instance.miscOptions.Hotbar));

HEROsMod.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
<Compile Include="HEROsModServices\ItemBrowser.cs" />
8787
<Compile Include="HEROsModServices\ItemClearer.cs" />
8888
<Compile Include="HEROsModServices\KeybindController.cs" />
89+
<Compile Include="HEROsModServices\LightHack.cs" />
8990
<Compile Include="HEROsModServices\Login.cs" />
9091
<Compile Include="HEROsModServices\MapRevealer.cs" />
9192
<Compile Include="HEROsModServices\MobSpawner.cs" />

HEROsModNetwork/Group.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class Group
2121
new PermissionInfo("Flycam", "Fly Camera"),
2222
new PermissionInfo("ClearItems", "Clear Items on Ground"),
2323
new PermissionInfo("RevealMap", "Reveal Map"),
24+
new PermissionInfo("LightHack", "Light Hack"),
2425
new PermissionInfo("SpawnNPCs", "Spawn NPCs"),
2526
new PermissionInfo("Kick", "Kick Players"),
2627
new PermissionInfo("Ban", "Ban Players"),

HEROsModServices/LightHack.cs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
using HEROsMod.UIKit;
2+
using HEROsMod.UIKit.UIComponents;
3+
using Microsoft.Xna.Framework;
4+
using System;
5+
using Terraria;
6+
using Terraria.ModLoader;
7+
8+
namespace HEROsMod.HEROsModServices
9+
{
10+
/// <summary>
11+
/// A service that hacks the lighting values for the player
12+
/// </summary>
13+
class LightHack : HEROsModService
14+
{
15+
internal static int LightStrength;
16+
internal static float[] LightStrengthValues = new float[] { 0, .25f, .5f, 1f };
17+
private static string[] LightStrengthStrings = new string[] { "LightHack: Disabled", "LightHack: 25%", "LightHack: 50%", "LightHack: 100%" };
18+
19+
public LightHack(UIHotbar hotbar)
20+
{
21+
IsInHotbar = true;
22+
HotbarParent = hotbar;
23+
this._name = "Light Hack";
24+
this._hotbarIcon = new UIImage(HEROsMod.instance.GetTexture("Images/lighthack"));
25+
this._hotbarIcon.onLeftClick += (s, e) =>
26+
{
27+
buttonLogic(true);
28+
};
29+
this._hotbarIcon.onRightClick += (s, e) =>
30+
{
31+
buttonLogic(false);
32+
};
33+
this.HotbarIcon.Tooltip = LightStrengthStrings[LightStrength];
34+
_hotbarIcon.Opacity = 0.5f;
35+
}
36+
37+
public override void MyGroupUpdated()
38+
{
39+
this.HasPermissionToUse = HEROsModNetwork.LoginService.MyGroup.HasPermission("LightHack");
40+
}
41+
42+
public void buttonLogic(bool leftMouse)
43+
{
44+
LightStrength = leftMouse ? (LightStrength + 1) % LightStrengthStrings.Length : (LightStrength + LightStrengthStrings.Length - 1) % LightStrengthStrings.Length;
45+
HotbarIcon.Tooltip = LightStrengthStrings[LightStrength];
46+
_hotbarIcon.Opacity = (LightStrengthValues[LightStrength] + 1f) / 2;
47+
}
48+
}
49+
50+
public class LightHackGlobalWall : GlobalWall
51+
{
52+
public override void ModifyLight(int i, int j, int type, ref float r, ref float g, ref float b)
53+
{
54+
if (LightHack.LightStrength > 0)
55+
{
56+
r = MathHelper.Clamp(r + LightHack.LightStrengthValues[LightHack.LightStrength], 0, 1);
57+
g = MathHelper.Clamp(g + LightHack.LightStrengthValues[LightHack.LightStrength], 0, 1);
58+
b = MathHelper.Clamp(b + LightHack.LightStrengthValues[LightHack.LightStrength], 0, 1);
59+
}
60+
}
61+
}
62+
}

HEROsModServices/MiscOptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public override void MyGroupUpdated()
5353
{
5454
this.HasPermissionToUse = HEROsModNetwork.LoginService.MyGroup.HasPermission("ToggleBannedItems") ||
5555
HEROsModNetwork.LoginService.MyGroup.HasPermission("RevealMap") ||
56+
HEROsModNetwork.LoginService.MyGroup.HasPermission("LightHack") ||
5657
HEROsModNetwork.LoginService.MyGroup.IsAdmin ||
5758
HEROsModNetwork.LoginService.MyGroup.HasPermission("ToggleHardmodeEnemies") ||
5859
HEROsModNetwork.LoginService.MyGroup.HasPermission("ToggleGravestones");

Images/lighthack.png

3.04 KB
Loading

build.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
author = HERO, jopojelly
2-
version = 0.1.5.8
2+
version = 0.1.6
33
displayName = HERO's Mod
44
homepage = http://forums.terraria.org/index.php?threads/heros-mod-creative-mode-server-management-and-over-25-tools-1-3-1-1-compatible.44650/
55
buildIgnore = .vs\*, Properties\*, *.csproj, *.user, obj\*, bin\*, *.config, tmod\*, ignore\*, ZVidBuild\*, Images\Old*, Images\AllIcons.psd, .git\*, LICENSE, .gitignore

0 commit comments

Comments
 (0)