It would be great to have a plugin that uses engineering items from your inventory (rockets, shields, boots, glider, etc.) appropriately. In the old days, I would have found some source and given it a go myself but with the new buddy store, it's difficult to get a hold of source examples to help non-coding people like me from making it happen. Hoping somebody more knowledgeable can take this on.
Easiest way to get started is this:
https://www.thebuddyforum.com/honor...4k-resolution-skinned-form-plugin-sample.html
Here's what I would do after you get that.
1. Download / Install VS 2015 Community
https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx
2. Open the Solution file (.sln) for HBPlugin.
3. Add all of the references that you need:
- Honorbuddy.exe (From Honorbuddy folder - For logic)
- PresentationCore (From .NET assemblies - For logging)
4. Rename everything you want renamed to whatever plugin you want. For example if I want it changed from "HBPlugin" to "MyPlugin" then you would do the following. Most of this can be done by global search/replace, but listing it all to show you what changed:
- Go to Project Properties and rename Assembly Name and Default namespace to "MyPlugin".
- Plugin.cs - Change "namespace PluginSample {" to "namespace MyPlugin {"
- Plugin.cs - Change "public class HBPlugin: Styx.Plugins.HBPlugin {" to "public class MyPlugin : Styx.Plugins.HBPlugin {"
- Plugin.cs - Change "public static string PluginName="My Plugin";" to "public static string PluginName="Something Different";"
- Plugin.cs - If you want settings, then leave this alone. No settings button then change "public static string PluginSettingsButton="Settings...";" to "public static string PluginSettingsButton="";"
- Settings.cs - Rename "namespace PluginSample {" to "namespace MyPlugin {"
- Settings.Designer.cs - Rename "namespace PluginSample {" to "namespace MyPlugin {"
- Settings.cs - Rename "Version ver = PluginSample.MyPlugin.PluginVersion;" to "Version ver = MyPlugin.PluginVersion;"
- Settings.cs - Comment out the line "rtfAbout.Rtf=HBPlugin.Properties.Resources.About;" until you add your own recource RTF and then you can put it there.
5. Now finishing it up the setup process we need to change the Target .NET Framework.
- Go to Project Properties and make sure the Target Framework is 4.6.1. (honestly it doesn't matter, but my OCD requires me to make sure I'm using the right stuff)
6. Now set the CPU architecture to 32 bit
- Go to Project Properties and click on Build tab and change the Platform Target to x86 (32 bit). Honestly it doesn't matter, but my OCD requires me to change this.
7. Now hit Build and see if you get a build succeed.
-------------------------------------
Now that you are here, you can just add stuff to the Pulse() method. I had some issues getting it to see it (not sure why), so I changed mine from:
Code:
/// <summary>
/// This function is called as soon as this assembly is loaded into memory, and thus a great place to initialize any events.
/// </summary>
public MyPlugin() {
BotEvents.OnBotStopped += BotEvents_OnBotStopped;
BotEvents.OnBotStarted += BotEvents_OnBotStarted;
BotEvents.OnBotChanged += BotEvents_OnBotChanged;
BotEvents.OnBotStartRequested += BotEvents_OnBotStartRequested;
BotEvents.OnBotStopRequested += BotEvents_OnBotStopRequested;
}
/// <summary>
/// This gets called shortly after the function using the same name as your plugin class is called.
/// </summary>
static public void Initialize() {
}
/// <summary>
/// Honorbuddy core sends a Pulse event which occurs similar to a heartbeat. You can use this when you need to work with events as they happen to the player.
/// </summary>
public override void Pulse() {
}
to me creating my own method and setting the event for pulse (not sure if that changed at some point or something was just screwed up when I was working on it). Theoretically, both of these *should* work. Remember that you still need the original Pulse() and Initialize() events, but there doesn't have to be anything in them.
Code:
/// <summary>
/// This function is called as soon as this assembly is loaded into memory, and thus a great place to initialize any events.
/// </summary>
public MyPlugin()
{
BotEvents.OnBotStopped += BotEvents_OnBotStopped;
BotEvents.OnBotStarted += BotEvents_OnBotStarted;
BotEvents.OnBotChanged += BotEvents_OnBotChanged;
BotEvents.OnBotStartRequested += BotEvents_OnBotStartRequested;
BotEvents.OnBotStopRequested += BotEvents_OnBotStopRequested;
BotEvents.OnPulse += BotEvents_OnPulse; // just says when pulse happens, call this method below.
}
private void BotEvents_OnPulse(object sender, EventArgs e)
{
// logic goes here
}
Now you can do whatever logic you want and you get some help from the fact that VS will pre-fill stuff for you that is in the references.
This is a very brief example of what you might be able to do. Replace this with all of the items you want and you should be good to go.
Code:
private void BotEvents_OnPulse(object sender, EventArgs e)
{
// logic goes here
var item1 = Me.Inventory.Backpack.Items.FirstOrDefault(i => i.SafeName == "Your Item Name");
if (item1 != null)
{
if (item1.Usable && item1.CooldownTimeLeft.Milliseconds <= 0)
{
item1.Use();
}
}
}
Hope that helps! Sorry it's kind of long-winded. Once you get one of them down, it's pretty easy to pick it up from there. I was in the same boat as you and had to do a lot of research and trial and error on my own.