Skip to content

Commit cce4691

Browse files
author
UserR00T
committed
Improved readme
1 parent bfa17b8 commit cce4691

1 file changed

Lines changed: 41 additions & 29 deletions

File tree

README.md

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Build Status](https://travis-ci.org/DeathByKorea/UniversalUnityHooks.svg?branch=master)](https://travis-ci.org/DeathByKorea/UniversalUnityHooks)
1+
[![Build Status](https://travis-ci.org/UserR00T/UniversalUnityHooks.svg?branch=master)](https://travis-ci.org/UserR00T/UniversalUnityHooks)
22

33
## Synopsis
44

@@ -7,59 +7,71 @@ UniversalUnityHooks aims to bring a adaptable modding API to any unity game. Thi
77
## Code Example
88

99
```cs
10-
public class printStartPlugin
10+
public class YourClass
1111
{
12-
[Hook("SvNetMan.StartServerNetwork")]
13-
public static void startServerNetwork(SvNetMan man)
12+
[Hook("SvManager.StartServer")]
13+
public static void StartServer(SvManager man)
1414
{
1515
Debug.Log("Plugin Loaded!");
1616
}
17-
1817
}
1918
```
2019

21-
In this example the game hooks the examples ServerStartNetwork method in the SvNetMan Class, and prints Plugin Loaded when the server connects to the network
20+
In this example the game hooks the examples ``StartServer`` method in the ``SvManager`` Class, and prints Plugin Loaded when the server starts.
2221
## Motivation
2322

24-
The inital motivation behind the project was to provide a way for server owners to develop plugins for the game Broke Protocol (https://brokeprotocol.com). But due to the way unity games are made, this program can be ported to any other game relatively easily
23+
The inital motivation behind the project was to provide a way for server owners to develop plugins for the game Broke Protocol (https://brokeprotocol.com). But due to the way unity games are made, this program can be used on other games very easily.
2524

2625
## Installation
27-
28-
Assuming Linux (x64)
29-
30-
For windows:
31-
32-
* Build the files from Visual Studio or under Bash For Windows
33-
34-
Prerequites:
35-
* mono-complete
36-
* mono.cecil.inject (https://github.com/denikson/Mono.Cecil.Inject/releases)
37-
38-
To build the files from source and install them simply:
39-
* If you need to add the references to Mono, they're in the Mono folder.
40-
* Build HookAttribute with `xbuild HookAttribute.csproj` and place the HookAttribute.dll in $Gamedir/Game_Data/Managed
41-
* Build Hooks Injector with `xbuild HooksInjector.csproj` and place HooksInjector.exe along with the `Mono.Cecil` & `CommandLine` dll's in $Gamedir
42-
43-
To run the program do `mono HooksInjector.exe`(linux) or just run the (windows)
44-
45-
Write your scripts and place them in the plugins directory of $Gamedir (Created after running HooksInjector)
26+
Goto [Releases](https://github.com/UserR00T/UniversalUnityHooks/releases).
27+
Download the latest version.
28+
Reference the .dll into your class library project. Make sure that the class that contains all the hooks is public as well as the hook methods themselfs.
29+
Put your compiled DLLs in your ``root/Plugins`` folder. You may need to run ``UniversalUnityHooks.exe`` first to create that folder.
30+
(Optional) I suggest adding this command to ``Post build event``: ``copy /Y "$(TargetFileName)" "..\..\..\..\Plugins\"``, assuming you keep your solution in ``root/Scripts``.
4631

4732
## API Reference
4833

4934
The program is fairly straight forward, to hook a method, simply put
5035
`[Hook("Class.Method")]`
51-
Then supply the instance as the first variable, and the rest of the variables as refs.
52-
So if I were to want to modify Damage of the SvPlayer Class with variables DamageIndex, Amount, Attacker, and Collider, That would become
36+
Then supply the instance as the first variable, and the rest of the variables as ``refs``.
37+
So if I were to want to modify the ``Damage`` methid inside of the ``SvPlayer`` class with variables ``DamageIndex``, ``Amount``, ``Attacker`` and ``Collider``, that would become
5338
```cs
39+
public class YourClass
40+
{
5441
[Hook("SvPlayer.Damage")]
5542
public static bool Damage(SvPlayer player, ref DamageIndex type, ref float amount, ref ShPlayer attacker, ref Collider collider)
43+
{
44+
if (/*Your check for whatever here*/)
45+
return true; // Blocks the rest of the method
46+
else if (/*other check here*/)
47+
amount *= 2 // Multiply number by two.
48+
return false; // Allows the rest of the method to continue
49+
}
50+
}
51+
```
52+
It'd compile it like this:
53+
```cs
54+
// Token: 0x06000425 RID: 1061 RVA: 0x00018A38 File Offset: 0x00016C38
55+
public override void Damage(global::DamageIndex type, float amount, global::ShPlayer attacker, Collider collider)
56+
{
57+
if (YourClass.Damage(this, ref type, ref amount, ref attacker, ref collider))
58+
{
59+
return;
60+
}
61+
// Rest of damage method's code.
62+
}
5663
```
5764

5865
## License
5966

60-
This code is licenced under the MIT Licence, Information can be found by clicking on it at the top of the repository.
67+
This code is licenced under the MIT Licence, [Information can be found here.](https://github.com/UserR00T/UniversalUnityHooks/blob/master/LICENSE)
6168

69+
## Limitations
70+
Unfortunately there are some limitations;
71+
- You can only inject your code at the start or end of the method. Nowhere in between. (To inject at the end, type ``[Hook("Class.Method", true)]``
72+
- Injecting in a method of type IEnumerator does not work properly.
6273

6374
## Credits
6475

6576
Ardivaba: https://github.com/Ardivaba
77+
DeathByKorea: https://github.com/DeathByKorea

0 commit comments

Comments
 (0)