Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
shabbywu committed Apr 14, 2022
2 parents 69f2547 + a186cf0 commit 03253a6
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 36 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Expand Up @@ -47,3 +47,6 @@ jobs:
bin/michangsheng/CollectGains.dll
bin/michangsheng/ForgetWuDaoSkill.dll
bin/michangsheng/FriendlyLianDan.dll
bin/michangsheng/StrengthenDongfu.dll
bin/michangsheng/BetterTooltips.dll
6 changes: 5 additions & 1 deletion README.md
Expand Up @@ -22,6 +22,7 @@ dotnet new bepinex5plugin -T netstandard2.0 -U 2018.4.36 -n {Your-Mod-Name}
### BattleGains(提高战斗收益)

调整战斗胜利后的收益, 例如物品掉落倍率, 金钱掉落倍率, 装备掉落倍率。
- minor: 降低默认倍率至 2, 任务物品、丹方等类型的物品只掉落1份。

### BetterShoppingExperience(更好的商店体验)

Expand All @@ -38,14 +39,16 @@ dotnet new bepinex5plugin -T netstandard2.0 -U 2018.4.36 -n {Your-Mod-Name}
### ShoterLearnTime(缩短学习时间)

调整学习、突破功法的耗时,可在配置中调整倍率
- fix: 修复稳定版本 0.9.1.130 后功能不可用的问题, 并增加一种根据悟性动态控制缩短倍率的方案

### WuDaoGains(悟道收益调整)

调整悟道的收益, 悟道点的获取倍率、降低感悟灵感的时间消耗、提高灵感提供的经验值

### ForgetWuDaoSkill(遗忘悟道技能)

可在学习悟道技能的界面中直接遗忘悟道技能。
可在学习悟道技能的界面中直接遗忘悟道技能。
bugfix: 修复无法查看未达到领悟条件的技能信息(by https://github.com/Cherrysaber)

### FriendlyLianDan(更友好的炼丹体验)

Expand All @@ -54,6 +57,7 @@ dotnet new bepinex5plugin -T netstandard2.0 -U 2018.4.36 -n {Your-Mod-Name}
- 自动计算所有炼丹丹方
- 仅展示可炼制的丹方
- 丹方按药草的价值排序
- 优化炼丹丹方展示逻辑, 延迟加载丹方列表, 减少资源开销。

更新: 1.0.0:
- 修复由于新版的炼丹界面重构导致的挂载点失效的问题
Expand Down
37 changes: 33 additions & 4 deletions michangsheng/BattleGains/Plugin.cs
Expand Up @@ -3,6 +3,7 @@
using BepInEx.Configuration;
using HarmonyLib;
using Fight;
using JSONClass;

namespace BattleGains
{
Expand All @@ -24,9 +25,9 @@ private void Awake()
Logger.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded!");

EquipmentDropMultiplier = Config.Bind("BattleGains", "EquipmentDropMultiplier", 1, "装备掉落倍率");
ItemDropMultiplier = Config.Bind("BattleGains", "ItemDropMultiplier", 5, "物品掉落倍率");
ItemDropMultiplier = Config.Bind("BattleGains", "ItemDropMultiplier", 2, "物品掉落倍率");

MoneyDropMultipiler = Config.Bind("BattleGains", "MoneyDropMultipiler", 5f, "金钱掉落倍率");
MoneyDropMultipiler = Config.Bind("BattleGains", "MoneyDropMultipiler", 2f, "金钱掉落倍率");
Harmony.CreateAndPatchAll(typeof(Plugin));

LogDebug = Logger.LogDebug;
Expand Down Expand Up @@ -103,8 +104,36 @@ static bool dropEquip(ref NpcDrop __instance, ref JSONObject ___npcDate, ref JSO

[HarmonyPatch(typeof(NpcDrop), "buidTempItem")] // Specify target method with HarmonyPatch attribute
[HarmonyPrefix]
static bool multipleDroppedItem(ref int ItemNum){
ItemNum *= ItemDropMultiplier.Value;
static bool multipleDroppedItem(ref int ItemID, ref int ItemNum){
var multiple = ItemDropMultiplier.Value;
try
{
_ItemJsonData itemJsonData = _ItemJsonData.DataDict[ItemID];
var type = (ItemTypes)itemJsonData.type;

switch (type) {
case ItemTypes.武器:
case ItemTypes.衣服:
case ItemTypes.饰品:
multiple = EquipmentDropMultiplier.Value;
break;
case ItemTypes.技能书:
case ItemTypes.功法:
case ItemTypes.任务:
case ItemTypes.丹方:
case ItemTypes.书籍:
case ItemTypes.秘籍:
multiple = 1;
break;
}
}
catch (System.Exception)
{

throw;
}

ItemNum *= multiple;
return true;
}
}
Expand Down
43 changes: 27 additions & 16 deletions michangsheng/BetterTooltips/Plugin.cs
Expand Up @@ -23,7 +23,7 @@ private void Awake()
ShowYaoYin = Config.Bind("Tooltip", "ShowYaoYin", false, "是否展示药草可炼制的丹方");
ShowChandi = Config.Bind("Tooltip", "ShowChandi", false, "是否展示药草的产地");

_harmony = Harmony.CreateAndPatchAll(typeof(Plugin));
_harmony = Harmony.CreateAndPatchAll(typeof(PatchToolTipsMag));
LogDebug = Logger.LogDebug;
}

Expand All @@ -34,26 +34,37 @@ private void Awake()
public delegate void Log(object data);
public static Log LogDebug;

class PatchToolTipsMag{
static bool showed = false;

[HarmonyPatch(typeof(ToolTipsMag), "UpdateSize")]
[HarmonyPrefix]
static public void PatchToolTipsMag(ref ToolTipsMag __instance, ref ToolTipsMag.Direction ____direction, ref Dictionary<int, string> ____qualityNameColordit)
{
Bag.BaseItem item = __instance.BaseItem;
// 只要展示的不是草药, 就都不处理
if (item == null)
[HarmonyPatch(typeof(ToolTipsMag), "UpdateSize")]
[HarmonyPrefix]
static public void PatchUpdateSize(ref ToolTipsMag __instance, ref ToolTipsMag.Direction ____direction, ref Dictionary<int, string> ____qualityNameColordit)
{
LogDebug("item is null");
return;
}
Bag.BaseItem item = __instance.BaseItem;
// 只要展示的不是草药, 就都不处理
if (item == null)
{
LogDebug("item is null");
return;
}

if (item.ItemType == Bag.ItemType.草药)
{
CaoYaoHandler.ShowPossibleDanFang(ref __instance, ref ____direction, ref ____qualityNameColordit);
if (ShowChandi.Value) {
CaoYaoHandler.ShowPossibleChanDi(ref __instance, ref ____direction);
if (item.ItemType == Bag.ItemType.草药 && !showed)
{
CaoYaoHandler.ShowPossibleDanFang(ref __instance, ref ____direction, ref ____qualityNameColordit);
if (ShowChandi.Value) {
CaoYaoHandler.ShowPossibleChanDi(ref __instance, ref ____direction);
}
showed = true;
}
}

[HarmonyPatch(typeof(ToolTipsMag), "UpdateSize")]
[HarmonyPrefix]
static public bool PatchClose() {
showed = false;
return true;
}
}
}
}
9 changes: 4 additions & 5 deletions michangsheng/ForgetWuDaoSkill/Plugin.cs
Expand Up @@ -7,7 +7,7 @@

namespace ForgetWuDaoSkill
{
[BepInPlugin("cn.shabywu.michangsheng.ForgetWuDaoSkill", "遗忘悟道技能", "0.1.0")]
[BepInPlugin("cn.shabywu.michangsheng.ForgetWuDaoSkill", "遗忘悟道技能", "1.0.0")]
public class Plugin : BaseUnityPlugin
{

Expand Down Expand Up @@ -70,7 +70,6 @@ static void Postfix(ref int wudaoId, ref Text ____cost, ref FpBtn ____btn)
____go.GetComponent<Tab.TabListener>().mouseUpEvent.AddListener(delegate()
{
WuDaoTooltip.Show(icon.sprite, -instance.Id, delegate(){
LogDebug("calling Forget");
Forget(instance);
});

Expand All @@ -81,16 +80,16 @@ static void Postfix(ref int wudaoId, ref Text ____cost, ref FpBtn ____btn)
____go.GetComponent<Tab.TabListener>().mouseUpEvent.AddListener(delegate()
{
WuDaoTooltip.Show(icon.sprite, instance.Id, delegate(){
LogDebug("calling Study");
Study(instance);
});
});
break;
case 3:
// 未达到领悟条件
____go.GetComponent<Tab.TabListener>().mouseUpEvent.AddListener(delegate() {
UIPopTip.Inst.Pop("未达到领悟条件", PopTipIconType.叹号);
WuDaoTooltip.Close();
WuDaoTooltip.Show(icon.sprite, instance.Id, delegate(){
Study(instance);
});
});
break;
}
Expand Down
67 changes: 57 additions & 10 deletions michangsheng/ShoterLearnTime/Plugin.cs
@@ -1,17 +1,24 @@
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using System.Collections.Generic;
using UnityEngine;

namespace ShoterLearnTime
{
[BepInPlugin("cn.shabywu.michangsheng.ShoterLearnTime", "缩短功法学习/突破时间", "0.1.0")]
[BepInPlugin("cn.shabywu.michangsheng.ShoterLearnTime", "缩短功法学习/突破时间", "1.0.0")]
public class Plugin : BaseUnityPlugin
{

// 简介:
// 对于稳定版 0.9.1.130 后的版本, 领悟/突破功法的耗时的计算由 Tools.CalcLingWuOrTuPoTime 实现
// 对于之前的版本, 领悟功法的耗时由 Tools.getStudiSkillTime 实现, 突破功法的耗时由 Tools.getStudiStaticSkillTime 实现
static ConfigEntry<int> ShorterStudyMultipiler;

static ConfigEntry<int> ShorterTuPoMultipiler;

static ConfigEntry<float> CoefficientTau;
static ConfigEntry<float> LogisticMaxPercentage;
static ConfigEntry<bool> EnableLogisticFunction;

public delegate void Log(object data);
public static Log LogDebug;

Expand All @@ -22,25 +29,65 @@ private void Awake()

ShorterStudyMultipiler = Config.Bind("ShoterLearnTime", "ShorterStudyMultipiler", 10, "缩短学习时间倍率");
ShorterTuPoMultipiler = Config.Bind("ShoterLearnTime", "ShorterTuPoMultipiler", 3, "缩短突破时间倍率");
Harmony.CreateAndPatchAll(typeof(Plugin));

EnableLogisticFunction = Config.Bind("Logistic-Function", "EnableLogisticFunction", true, "使用 Logistic 方程增强【悟性】对领悟/突破的影响, 关闭则使用简单粗暴的倍率进行控制");
CoefficientTau = Config.Bind("Logistic-Function", "CoefficientTau", 0.05f, "Logistic 方程的时间系数, 该值越大, 【悟性】对学习时间的影响越明显。不建议修改该值。");
LogisticMaxPercentage = Config.Bind("Logistic-Function", "LogisticMaxPercentage", 80f, new ConfigDescription("使用 Logistic 方程时, 【悟性】对学习时间的影响的最大百分比。如果设置成 100, 那么悟性足够的话, 就无需学习时间(影响平衡)", new AcceptableValueRange<float>(0f, 100f)));
Harmony.CreateAndPatchAll(typeof(Plugin));
LogDebug = Logger.LogDebug;
}

// 根据悟性和悟道计算领悟和突破的耗时
[HarmonyPatch(typeof(Tools), "CalcLingWuOrTuPoTime")]
[HarmonyPrefix]
static bool patchCalcLingWuOrTuPoTime(ref int __result, ref int baseTime, ref List<int> wuDao) {
if (!EnableLogisticFunction.Value) {
return true;
}

var player = PlayerEx.Player;
float wuXinFactor = 101 - 100 / (1 + 99 * Mathf.Exp(-CoefficientTau.Value * player.wuXin));
wuXinFactor = Mathf.Clamp(wuXinFactor, 100 - LogisticMaxPercentage.Value, 100) / 100;
float wuDaoFactor = 0f;
if (wuDao.Count > 0)
{
int num3 = wuDao.Count / 2;
for (int i = 0; i < wuDao.Count; i += 2)
{
int wuDaoType = wuDao[i];
int wuDaoLevelByType = player.wuDaoMag.getWuDaoLevelByType(wuDaoType);
float num4 = jsonData.instance.WuDaoJinJieJson[wuDaoLevelByType.ToString()]["JiaCheng"].n;
num4 /= (float)num3;
wuDaoFactor += num4;
}
}
wuDaoFactor = 1f - wuDaoFactor;
wuDaoFactor = Mathf.Clamp(wuDaoFactor, 0f, 1f);
__result = (int)((float)baseTime * wuXinFactor * wuDaoFactor);
LogDebug($"基础时间: {baseTime} 天, 悟性修正系数: {wuXinFactor}, 悟道修正系数: {wuDaoFactor}. 修正结果: {__result}");
return false;
}

// 降低功法突破时间
[HarmonyPatch(typeof(Tools), "getStudiStaticSkillTime")] // Specify target method with HarmonyPatch attribute
[HarmonyPatch(typeof(Tools), "CalcTuPoTime")] // Specify target method with HarmonyPatch attribute
[HarmonyPostfix] // There are different patch types. Prefix code runs before original code
static void patchGetStudiStaticSkillTime(ref int __result){
static void patchCalcTuPoTime(ref int __result){
if (EnableLogisticFunction.Value) {
return;
}
__result /= ShorterTuPoMultipiler.Value;
LogDebug("calling patched Tools::getStudiStaticSkillTime result: " + __result);
LogDebug("calling patched Tools::CalcTuPoTime result: " + __result);
}

// 降低功法学习时间
[HarmonyPatch(typeof(Tools), "getStudiSkillTime")] // Specify target method with HarmonyPatch attribute
[HarmonyPatch(typeof(Tools), "CalcLingWuTime")] // Specify target method with HarmonyPatch attribute
[HarmonyPostfix] // There are different patch types. Prefix code runs before original code
static void patchGetStudiSkillTime(ref int __result){
static void patchCalcLingWuTime(ref int __result){
if (EnableLogisticFunction.Value) {
return;
}
__result /= ShorterStudyMultipiler.Value;
LogDebug("calling patched Tools::getStudiSkillTime result: " + __result);
LogDebug("calling patched Tools::CalcLingWuTime result: " + __result);
}
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 03253a6

Please sign in to comment.