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

Commit

Permalink
Merge pull request #62 from amadare42/main
Browse files Browse the repository at this point in the history
Localizable text and small updates
  • Loading branch information
KosmosisDire authored Dec 4, 2022
2 parents 1e9b884 + 6acf214 commit 4bb7239
Show file tree
Hide file tree
Showing 22 changed files with 380 additions and 88 deletions.
8 changes: 7 additions & 1 deletion TeammateRevive/Configuration/PluginConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,16 @@ static BindCollection BindRuleValues(ConfigFile configFile, ReviveRuleValues val
defaultValue: values.CutReviveeHp)
.Bind(
key: "Death Curse chance",
description: "[Only with Death Curse enabled] Chance to receive Death Curse on revival (Range: 0-100%)",
description: "[Only with Death Curse enabled] Chance to receive Death Curse on revival for revivee (Range: 0-100%)",
set: v => values.DeathCurseChance = v,
defaultValue: values.DeathCurseChance,
metadata: new FloatMetadata(0, 100, 1))
.Bind(
key: "Reviver Death Curse chance",
description: "[Only with Death Curse enabled] Chance to receive Death Curse on revival for reviver (Range: 0-100%)",
set: v => values.ReviverDeathCurseChance = v,
defaultValue: values.ReviverDeathCurseChance,
metadata: new FloatMetadata(0, 100, 1))
.Bind(
key: "Post revive regeneration time",
description: "After reviving, 40% of revivee and linked revivers HP is restored. This value specify how long regeneration buff is active in seconds. If set to 0 - revive regen is disabled.",
Expand Down
7 changes: 0 additions & 7 deletions TeammateRevive/Content/Artifact/ArtifactBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,11 @@ namespace TeammateRevive.Artifact
{
public abstract class ArtifactBase
{
public abstract string ArtifactName { get; }
public abstract string ArtifactLangTokenName { get; }
public abstract string ArtifactDescription { get; }
public abstract Sprite ArtifactEnabledIcon { get; }
public abstract Sprite ArtifactDisabledIcon { get; }
public ArtifactDef ArtifactDef;
public bool ArtifactEnabled => RunArtifactManager.instance?.IsArtifactEnabled(ArtifactDef) ?? false;
protected void CreateLang()
{
LanguageAPI.Add("ARTIFACT_" + ArtifactLangTokenName + "_NAME", ArtifactName);
LanguageAPI.Add("ARTIFACT_" + ArtifactLangTokenName + "_DESCRIPTION", ArtifactDescription);
}

public abstract void Init();

Expand Down
12 changes: 4 additions & 8 deletions TeammateRevive/Content/Artifact/DeathCurseArtifact.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using RoR2;
using TeammateRevive.Common;
using TeammateRevive.Localization;
using TeammateRevive.Logging;
using TeammateRevive.Resources;
using TeammateRevive.Revive.Rules;
Expand All @@ -8,19 +9,14 @@
namespace TeammateRevive.Artifact
{
public class DeathCurseArtifact : ArtifactBase
{
public override string ArtifactName => "Artifact of Death Curse";
{
public override string ArtifactLangTokenName => "DEATH_CURSE";

public override string ArtifactDescription =>
"Adds Death Curse on revive, but also adds Charon's Obol item that will make revive easier.";

public override Sprite ArtifactEnabledIcon => CustomResources.DeathCurseArtifactEnabledIcon;
public override Sprite ArtifactDisabledIcon => CustomResources.DeathCurseArtifactDisabledIcon;

public override void Init()
{
CreateLang();
CreateArtifact();
}

Expand All @@ -34,7 +30,7 @@ public void EnsureEnabled(ReviveRules rules)
RunArtifactManager.instance.SetArtifactEnabledServer(ArtifactDef, false);
Chat.SendBroadcastChat(new Chat.SimpleChatMessage
{
baseToken = TextFormatter.Yellow("Artifact of Death Curse is disabled because run started in single player.")
baseToken = TextFormatter.Yellow(Language.GetString(LanguageConsts.ARTIFACT_DEATH_CURSE_DISABLED))
});
return;
}
Expand All @@ -46,7 +42,7 @@ public void EnsureEnabled(ReviveRules rules)
&& !ArtifactEnabled
&& NetworkHelper.IsServer
) {
var message = "Artifact of Death Curse is enforced by server.";
var message = Language.GetString(LanguageConsts.ARTIFACT_DEATH_CURSE_ENFORCED_BY_SERVER);
RunArtifactManager.instance.SetArtifactEnabledServer(ArtifactDef, true);
Log.Info(message);
Chat.SendBroadcastChat(new Chat.SimpleChatMessage
Expand Down
19 changes: 7 additions & 12 deletions TeammateRevive/Content/CharonsObol.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
using R2API;
using RoR2;
using TeammateRevive.Localization;
using TeammateRevive.Resources;
using UnityEngine;
using static TeammateRevive.Common.TextFormatter;

namespace TeammateRevive.Content
{
public class CharonsObol : ContentBase
{
public static string Name = "ITEM_CharonsObol";
public static string NameToken = "Charon's Obol";
public static string NameToken = LanguageConsts.ITEM_CHARONS_OBOL_NAME;
public static ItemIndex Index;

public override void Init()
{
var full =
$"- Reduces {Yellow("revival time")}. " +
$"\n- Can be consumed for {Yellow("instant")} revival without Death Curse. " +
$"\n- {Yellow("Removes")} additional {Red("Death Curse")} on stage change." +
$"\n- Increase {Yellow("range")} and decrease {Yellow("damage")} for your revival.";

var generalScale = new Vector3(0.05f, 0.05f, 0.05f);
var rules = new ItemDisplayRuleDict(new ItemDisplayRule[]
{
Expand All @@ -34,10 +28,11 @@ public override void Init()
}
});

ItemAPI.Add(DeprecatedCustomItem.Create(Name, NameToken,
full,
full,
"Makes revival easier. Can be consumed for instant revival.",
ItemAPI.Add(DeprecatedCustomItem.Create(Name,
NameToken,
LanguageConsts.ITEM_CHARONS_OBOL_DESCRIPTION,
LanguageConsts.ITEM_CHARONS_OBOL_DESCRIPTION,
LanguageConsts.ITEM_CHARONS_OBOL_PICKUP,
CustomResources.CharonsObolItemIcon,
CustomResources.CharonsObolItemPrefab, ItemTier.Tier2, new[]
{
Expand Down
17 changes: 7 additions & 10 deletions TeammateRevive/Content/DeadMansHandItem.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
using R2API;
using RoR2;
using TeammateRevive.Localization;
using TeammateRevive.Resources;
using static TeammateRevive.Common.TextFormatter;

namespace TeammateRevive.Content
{
public class DeadMansHandItem : ContentBase
{
public static string Name = "ITEM_ReviveEverywhere";
public static string NameToken = "Dead Man's Hand";
public static string NameToken = LanguageConsts.ITEM_REVIVE_EVERYWHERE_NAME;
public static ItemIndex Index;

public override void Init()
{
var full =
$"- {Yellow("Revive")} dead teammates {Yellow("everywhere")} on map." +
$"\n- First item {Red("increases")} {Yellow("revival time")} by x2." +
$"\n- Every subsequent item decreases {Yellow("revival time")} when you are reviving";

ItemAPI.Add(DeprecatedCustomItem.Create(Name, NameToken,
full, "Revive death teammates everywhere on map.",
"Revive death teammates everywhere on map",
ItemAPI.Add(DeprecatedCustomItem.Create(Name,
NameToken,
LanguageConsts.ITEM_REVIVE_EVERYWHERE_DESCRIPTION,
LanguageConsts.ITEM_REVIVE_EVERYWHERE_LORE,
LanguageConsts.ITEM_REVIVE_EVERYWHERE_PICKUP,
CustomResources.LunarHandIcon,
CustomResources.HandItemPrefab, ItemTier.Lunar, new[]
{
Expand Down
10 changes: 6 additions & 4 deletions TeammateRevive/Content/DeathCurse.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using R2API;
using RoR2;
using TeammateRevive.Common;
using TeammateRevive.Localization;
using TeammateRevive.Resources;
using TeammateRevive.Revive.Rules;
using UnityEngine;
Expand All @@ -16,7 +17,6 @@ public class DeathCurse : ContentBase

public static string ItemName = "ITEM_DeathCurse";
public static string BuffName = "BUFF_DeathCurse";
public static string NameToken = "Death curse";

public static ItemIndex ItemIndex;
public static BuffIndex BuffIndex;
Expand Down Expand Up @@ -48,9 +48,11 @@ public override void Init()

static void CreateDeathCurseHiddenItem()
{
ItemAPI.Add(DeprecatedCustomItem.Create(ItemName, NameToken,
"Reduces your max HP/Shield. Removed on next stage.", "Reduces your max HP/Shield. Removed on next stage.",
"ITEM_REDUCEHP_PICK",
ItemAPI.Add(DeprecatedCustomItem.Create(ItemName,
LanguageConsts.ITEM_DEATH_CURSE_NAME,
LanguageConsts.ITEM_DEATH_CURSE_DESCRIPTION,
LanguageConsts.ITEM_DEATH_CURSE_LORE,
LanguageConsts.ITEM_DEATH_CURSE_PICKUP,
CustomResources.DeathCurseBuffIcon,
CustomResources.CharonsObolItemPrefab, ItemTier.NoTier, new[]
{
Expand Down
9 changes: 6 additions & 3 deletions TeammateRevive/Content/RevivalToken.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using R2API;
using RoR2;
using TeammateRevive.Localization;
using TeammateRevive.Resources;
using UnityEngine;
using CharacterBody = On.RoR2.CharacterBody;
Expand All @@ -13,9 +14,11 @@ public class RevivalToken : ContentBase

public override void Init()
{
var description = "Reduces chance to receive curse";
ItemAPI.Add(DeprecatedCustomItem.Create(Name, "Revival Token",
description, description, description,
ItemAPI.Add(DeprecatedCustomItem.Create(Name,
LanguageConsts.ITEM_REVIVAL_TOKEN_NAME,
LanguageConsts.ITEM_REVIVAL_TOKEN_DESCRIPTION,
LanguageConsts.ITEM_REVIVAL_TOKEN_DESCRIPTION,
LanguageConsts.ITEM_REVIVAL_TOKEN_DESCRIPTION,
CustomResources.ReviveLinkBuffIcon,
CustomResources.CharonsObolItemPrefab, ItemTier.NoTier, new[]
{
Expand Down
12 changes: 7 additions & 5 deletions TeammateRevive/ContentManager.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using System;
using System.Collections.Generic;
using On.RoR2;
using RoR2;
using TeammateRevive.Artifact;
using TeammateRevive.Content;
using TeammateRevive.Localization;
using TeammateRevive.Logging;
using TeammateRevive.Resources;
using TeammateRevive.Revive.Rules;
using BuffCatalog = On.RoR2.BuffCatalog;
using ItemCatalog = On.RoR2.ItemCatalog;
using RoR2Content = RoR2.RoR2Content;

namespace TeammateRevive
Expand All @@ -24,16 +26,16 @@ public ContentManager(ReviveRules rules, RunTracker run, DeathCurseArtifact deat
this.rules = rules;
this.run = run;
this.deathCurseArtifact = deathCurseArtifact;
Language.SetStringByToken += LanguageOnSetStringByToken;
On.RoR2.Language.SetStringByToken += LanguageOnSetStringByToken;
On.RoR2.ItemCatalog.Init += ItemsOnInit;
On.RoR2.BuffCatalog.Init += BuffsOnInit;
}

private void LanguageOnSetStringByToken(Language.orig_SetStringByToken orig, RoR2.Language self, string token, string localizedstring)
private void LanguageOnSetStringByToken(On.RoR2.Language.orig_SetStringByToken orig, RoR2.Language self, string token, string localizedstring)
{
if (RoR2Content.Items.ShieldOnly && token == RoR2Content.Items.ShieldOnly.descriptionToken)
{
localizedstring += " Teammate reviving will damage shield instead of health.";
localizedstring += Language.GetString(LanguageConsts.TEAMMATE_REVIVAL_SHIELD_ONLY_POSTFIX);
}
orig(self, token, localizedstring);
if (RoR2Content.Items.ShieldOnly && token == RoR2Content.Items.ShieldOnly.descriptionToken)
Expand Down
2 changes: 0 additions & 2 deletions TeammateRevive/Death Totem/DeathTotemTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ void CreateInteraction(GameObject gameObject)

meshGo.AddIfMissing<EntityLocator>().entity = gameObject;

// game object need's collider in order to be interactible
// gameObject.AddIfMissing<MeshCollider>().sharedMesh = AddedAssets.CubeMesh;
Log.DebugMethod("done");
}

Expand Down
12 changes: 8 additions & 4 deletions TeammateRevive/Debugging/ConsoleCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,25 +102,29 @@ private void OnChatChanged()
}
DebugHelper.DamageTargetIndex = idx;
AddLog($"Target set to {PlayersTracker.instance.All[DebugHelper.DamageTargetIndex].networkUser.userName}");
}
},
helpText = "Damage player with entered index"
}
},
{
"trv_tglbuff", new RoR2.Console.ConCommand()
{
action = args => DebugHelper.ToggleRegenBuff()
action = args => DebugHelper.ToggleRegenBuff(),
helpText = "Toggle post-revive regen buff"
}
},
{
"trv_give_item", new RoR2.Console.ConCommand()
{
action = args => PlayersTracker.instance.All.ForEach(p => p.GiveItem(ItemCatalog.FindItemIndex(args.GetArgString(0))))
action = args => PlayersTracker.instance.All.ForEach(p => p.GiveItem(ItemCatalog.FindItemIndex(args.GetArgString(0)))),
helpText = "Give all players item by name"
}
},
{
"trv_remove_item", new RoR2.Console.ConCommand()
{
action = args => PlayersTracker.instance.All.ForEach(p => p.master.master.inventory.RemoveItem(ItemCatalog.FindItemIndex(args.GetArgString(0))))
action = args => PlayersTracker.instance.All.ForEach(p => p.master.master.inventory.RemoveItem(ItemCatalog.FindItemIndex(args.GetArgString(0)))),
helpText = "Remove item by name from all players"
}
}
};
Expand Down
7 changes: 4 additions & 3 deletions TeammateRevive/Integrations/BetterUiModIntegration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Runtime.CompilerServices;
using RoR2;
using TeammateRevive.Content;
using TeammateRevive.Localization;
using TeammateRevive.Logging;

namespace TeammateRevive.Integrations
Expand All @@ -27,9 +28,9 @@ void RegisterBuffs()
{
try
{
BetterUI.Buffs.RegisterBuffInfo(BuffCatalog.GetBuffDef(DeathCurse.BuffIndex), "Death Curse", "Reduces your max HP/Shield.");
BetterUI.Buffs.RegisterBuffInfo(BuffCatalog.GetBuffDef(ReviveLink.Index), "Revive Link", "Marks that character will receive Death curse when dead character is revived. Removed after some time.");
BetterUI.Buffs.RegisterBuffInfo(BuffCatalog.GetBuffDef(ReviveRegen.Index), "Revive Regeneration", "Rapidly regenerates 40% of your HP after revival.");
BetterUI.Buffs.RegisterBuffInfo(BuffCatalog.GetBuffDef(DeathCurse.BuffIndex), LanguageConsts.ITEM_DEATH_CURSE_NAME, LanguageConsts.BUFF_DEATH_CURSE_DESCRIPTION);
BetterUI.Buffs.RegisterBuffInfo(BuffCatalog.GetBuffDef(ReviveLink.Index), LanguageConsts.BUFF_REVIVE_LINK_NAME, LanguageConsts.BUFF_REVIVE_LINK_DESCRIPTION);
BetterUI.Buffs.RegisterBuffInfo(BuffCatalog.GetBuffDef(ReviveRegen.Index), LanguageConsts.BUFF_REVIVE_REGEN_NAME, LanguageConsts.BUFF_REVIVE_REGEN_DESCRIPTION);
Log.Info($"Better UI integration: OK!");
}
catch (Exception e)
Expand Down
20 changes: 14 additions & 6 deletions TeammateRevive/Integrations/ItemsStatsModIntegration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using TeammateRevive.Content;
using TeammateRevive.Logging;
using TeammateRevive.Revive.Rules;
using static TeammateRevive.Localization.LanguageConsts;

namespace TeammateRevive.Integrations
{
Expand All @@ -28,7 +29,9 @@ public ItemsStatsModIntegration(ReviveRules rules)
}
};
}


string Format(string key, string value) => string.Format(Language.GetString(key), value);

[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
void AddToItemStats()
{
Expand All @@ -44,19 +47,23 @@ void AddToItemStats()
{
new(
(itemCount, ctx) => rules.GetReviveIncrease((int)itemCount),
(value, ctx) => $"Revive speed increased by {value.FormatPercentage(signed: true, decimalPlaces: 1)}"
(value, ctx) =>
Format(ITEM_STAT_CHARON_OBOL_REVIVE_SPEED_INCREASE, value.FormatPercentage(signed: true, decimalPlaces: 1))
),
new(
(itemCount, ctx) => rules.GetReviveTime((int)itemCount, ctx.CountItems(DeadMansHandItem.Index)),
(value, ctx) => $"Time to revive alone: {value.FormatInt(postfix: "s", decimals: 1)}"
(value, ctx) =>
Format(ITEM_STAT_CHARON_OBOL_REVIVE_TIME_ALONE, value.FormatInt(postfix: "s", decimals: 1))
),
new(
(itemCount, ctx) => rules.CalculateDeathTotemRadius((int)itemCount, 1),
(value, ctx) => $"Revive circle range: {value.FormatInt(postfix: "m", decimals: 1)}"
(value, ctx) =>
Format(ITEM_STAT_CHARON_OBOL_REVIVE_CIRCLE_RANGE, value.FormatInt(postfix: "m", decimals: 1))
),
new(
(itemCount, ctx) => rules.GetReviveReduceDamageFactor((int)itemCount, 0) - 1,
(value, ctx) => $"Damage from your circle: {value.FormatPercentage(decimalPlaces: 1, signed: true)}"
(value, ctx) =>
Format(ITEM_STAT_CHARON_OBOL_REVIVE_CIRCLE_DAMAGE, value.FormatPercentage(decimalPlaces: 1, signed: true))
)
}
});
Expand All @@ -67,7 +74,8 @@ void AddToItemStats()
{
new(
(itemCount, ctx) => rules.GetReviveTimeIncrease(ctx.CountItems(CharonsObol.Index), (int)itemCount),
(value, ctx) => $"Revive time increase: {value.FormatPercentage(decimalPlaces: 1, signed: true)}"
(value, ctx) =>
Format(ITEM_STAT_REVIVE_EVERYWHERE_REVIVE_CIRCLE_DAMAGE,value.FormatPercentage(decimalPlaces: 1, signed: true))
)
}
});
Expand Down
Loading

0 comments on commit 4bb7239

Please sign in to comment.