RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

What I need to write plugin for Krrios Client?

Dralon

Wanderer
Writing plugins for Krrios

Writing Krrios Client Plugins

Please note that all information here may or may not be correct. The information here is compiled based on my observations of the contents of the contents of the Exposer.dll and Macros.dll under the .NET reflector. Use this information at your own risk. If you'd like more information on the plugins, it would be a good idea to download the reflector and crack the dll's open in it. I will try and publish further findings later, but this should provide a good starting point. Also, since the client is still in development and all of the internals may changed without any notification. Its currently very limited, but with a little work Krrios could become a very wonderful client to develop and customize!

The tools that you'll need to write plugins are a c# compiler(the free one is fine, but I find visual studio.net is a wonderfully easy tool if you can afford it), a good c# book or knowledge of c# and the .net platform, Krrios client(for the IExposer.dll), a good text editor(or vs.net), and finally the .NET reflector(optional but very very useful)


Prepare for the plugin by including the following references in your project:
System.Windows.Forms.dll
System.Drawing.dll
Exposer.dll (located in the Plugins directory of your Krrios install)

Also, add the following name spaces:
using System;
using System.Windows.Form;
using Client;

Plugins for the Krrios Client are .net dll's that contain one or more classes inheriting the Plugin class. When they are loaded, the member method Run is executed and passed an IExposed object as its only parameter. At this time, the plugin may register its self as a macro by calling the IExposed.RegisterAsMacro function. It is also advised that a reference to the IExposed object be saved on the plugin object because the other functions won't pass it back.

Packets are passed to plugins via the OnPacketRecv method and may be modified before sending via the OnPacketSend method. When a key is pressed the OnKeyDown method is invoked with the key information. When a macro is fired, the OnMacroAction method is invoked. When the plugin is loaded, the Run method is invoked with the reference to the IExposed interface.

Finally, once you have compiled the plugin as a dll file, you'll have to modify the Plugins.def to reflect the new plugin's that the dll contains. The format is very simple, first there is a line which contains '#<dllfile>' followed by a list of each plugin class contained in the plugin dll that you wish to use. Each plugin should be on a seperate line.

The Plugin class is defined as follows:

public class Plugin
{
// Methods
public Plugin();
public virtual bool OnCommandEntered(string s);
public virtual bool OnKeyDown(KeyEventArgs e);
public virtual bool OnMacroAction(string parms);
public virtual bool OnPacketRecv(byte[] data);
public virtual bool OnPacketSend(byte[] data);
public virtual void Run(IExposed e);

// Properties
public virtual string Description { get; }
public virtual string Name { get; }
}




The IExposed interface is defined as follows:

public interface IExposed
{
// Methods
void Ability(string type);
void AddTextMessage(string TextMessage);
void AddTextMessage(string TextMessage, TimeSpan Length);
void AddTextMessage(string TextMessage, TimeSpan Length, int WhichFont);
void AllNames();
bool Attack(string what);
bool BandageSelf();
void CastSpell(int SpellID);
void CastSpell(string Name);
void ClearLastTarget();
void ClearScreen();
void ClearTargetQueue();
void Count(string what);
void Dequip();
void DoAction(string Action);
void Equip(int index);
Bitmap GetGump(int GumpID, int HueUID);
Bitmap GetItem(int ItemID, int HueUID);
Bitmap GetLand(int LandID, int HueUID);
void Last(string what);
void Open(string What);
void Paste();
void Paste(string ToPaste);
void Quit();
void RegisterAsMacro(string action);
void RegisterAsMacro(string action, ParamNode[] options);
void RegisterAsMacro(string action, string[] list);
void RegisterAsMacro(string action, string[,] list);
bool Resync();
void Say(string Text);
void SetEquip(int index);
void SetText(string text);
bool SmartPotion();
void StopMacros();
void Target(string What);
bool UsePotion(PotionType type);
void UseSkill(string Name);
bool WrestleMove(WrestleType type);

// Properties
bool CanTargetLast { get; }
bool ContainerGrid { get; set; }
bool FPS { get; set; }
bool Grid { get; set; }
bool Halos { get; set; }
bool HasTarget { get; }
bool LastTargetIsDynamic { get; }
bool LastTargetIsLand { get; }
bool LastTargetIsMobile { get; }
bool LastTargetIsSelf { get; }
bool LastTargetIsStatic { get; }
bool MiniHealth { get; set; }
bool ParticleCount { get; set; }
bool Ping { get; set; }
int Player { get; }
bool PumpFPS { get; set; }
bool RegCounter { get; set; }
bool Screenshots { get; set; }
bool Temperature { get; set; }
bool Transparency { get; set; }
bool Warmode { get; set; }
}





Now for an example plugin. Our goal for this plugin is very simple, any time the F10 key is pressed the character will say "Hello World!"


Source code:
-------------------------------------------------------------------------------------------------------------------

using System;
using Client;
using System.Windows.Forms;

namespace TestPlugins
{
public class Plugin1:plugin
{
IExposed m_Exposed;

public Plugin1()
{
}
public override void Run(IExposed e)
{
this.m_Exposed = e;
}
public override bool OnKeyDown(KeyEventArgs e)
{
if (e.KeyCode == Keys.F10)
m_Exposed.Say("Hello World!");
return true;
}

}
}


-------------------------------------------------------------------------------------------------------------------


And finally, i'd just like to say thanks to Krrios for the wonderful client and the work he has put into it. Ultima Online has been a great concept but one that has also been limited by the protocol that its original creators, Origin, first implemented. Now that we have software such as RunUO and the Krrios client which may soon allow us to potentially modify the protocol into something much more powerful, we can open the worlds we create up and allow them to evolve into a wonderful experience for all of our players.


Daniel E. Fulford, (aka Sethor from the old Kaerdoth shard)
 
Top