Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
air1068 authored Aug 13, 2024
1 parent 8fb851f commit db380c5
Show file tree
Hide file tree
Showing 3 changed files with 183 additions and 0 deletions.
62 changes: 62 additions & 0 deletions Chat+.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{4C3F93AA-AD7D-43DB-85FC-A5A85724A16E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ChatPlus</RootNamespace>
<AssemblyName>chatplus</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony">
<HintPath>ref\0Harmony.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>ref\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>ref\Assembly-CSharp-firstpass.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>ref\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ChatPlus.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
85 changes: 85 additions & 0 deletions ChatPlus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using FairyGUI;
using HarmonyLib;
using XiaWorld;
using System;
using System.Collections.Generic;

namespace ChatPlus {
public class ChatPlus {
[HarmonyPatch(typeof(Wnd_JianghuTalk), "OnInit")]
class ChatPlusPatch {
static void Postfix(ref Wnd_JianghuTalk __instance) {
try {
var talkWindow = __instance;
GButton pryButton;
if (talkWindow.UIInfo.GetChild("ChatPlus.Pry") == null) {
pryButton = (GButton)UIPackage.CreateObjectFromURL("ui://ncbwb41mv9j6ah");
pryButton.name = "ChatPlus.Pry";
pryButton.title = "Pry";
pryButton.text = "Pry";
pryButton.x = 94;
pryButton.y = 204;
talkWindow.UIInfo.AddChild(pryButton);
pryButton.onClick.Add(delegate () {
int NPCid = (int)Traverse.Create(talkWindow).Field("targetseed").GetValue();
List<int[]> prylist = new List<int[]>();
foreach (KeyValuePair<int, JianghuMgr.JHNpcData> KnownNPC in JianghuMgr.Instance.KnowNpcData) {
g_emJHNpcDataType known = JianghuMgr.Instance.CheckNpcKnowOtherOnly(NPCid, KnownNPC.Key, g_emJHNpcDataType.Feature, g_emJHNpcDataType.Secret3);
if (known != g_emJHNpcDataType.None) {
prylist.Add(new int[] {
KnownNPC.Key,
(int)known
});
}
}
if (prylist.Count > 0) {
int[] result = prylist[World.RandomRange(0, prylist.Count, GMathUtl.RandomType.emNone)];
Npc player = (Npc)Traverse.Create(talkWindow).Field("player").GetValue();
Npc target = (Npc)Traverse.Create(talkWindow).Field("target").GetValue();
g_emJHNpcDataType key = GameDefine.JHNpcDataMainType[(g_emJHNpcDataType)result[1]];
talkWindow.AddTalkData(JianghuMgr.Instance.GetRandomTalk("Know", player, target), result[0], GameDefine.JHDataTxts[key], 0);
} else {
talkWindow.SetTxt("(You already know everything this person knows about everyone you've met.)");
}
});
} else {
pryButton = (GButton)talkWindow.UIInfo.GetChild("ChatPlus.Pry");
}

GButton gossipButton;
if (talkWindow.UIInfo.GetChild("ChatPlus.Gossip") == null) {
gossipButton = (GButton)UIPackage.CreateObjectFromURL("ui://ncbwb41mv9j6ah");
gossipButton.name = "ChatPlus.Gossip";
gossipButton.title = "Gossip";
gossipButton.text = "Gossip";
gossipButton.x = 28;
gossipButton.y = 204;
talkWindow.UIInfo.AddChild(gossipButton);
gossipButton.onClick.Add(delegate () {
int NPCid = (int)Traverse.Create(talkWindow).Field("targetseed").GetValue();
List<int> gossiplist = new List<int>();
foreach (KeyValuePair<int, JianghuMgr.JHNpcData> KnownNPC in JianghuMgr.Instance.KnowNpcData) {
if (KnownNPC.Key != NPCid && JianghuMgr.Instance.CheckNpcInterestOther(NPCid, KnownNPC.Key)) {
gossiplist.Add(KnownNPC.Key);
}
}
if (gossiplist.Count > 0) {
int result = gossiplist[World.RandomRange(0, gossiplist.Count, GMathUtl.RandomType.emNone)];
Npc player = (Npc)Traverse.Create(talkWindow).Field("player").GetValue();
Npc target = (Npc)Traverse.Create(talkWindow).Field("target").GetValue();
talkWindow.AddTalkData(JianghuMgr.Instance.GetRandomTalk("Interest", player, target), result, null, 0);
} else {
talkWindow.SetTxt("(You haven't met anyone that this person is interested in.)");
}
});
} else {
gossipButton = (GButton)talkWindow.UIInfo.GetChild("ChatPlus.Gossip");
}
}
catch (Exception e) {
KLog.Dbg("[CHAT+] error" + e.ToString(), new object[0]);
}
}
}
}
}
36 changes: 36 additions & 0 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Chat+")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Chat+")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("4c3f93aa-ad7d-43db-85fc-a5a85724a16e")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

0 comments on commit db380c5

Please sign in to comment.