Solved: A methold to trigger RAT events from xml

kpro

New member
Mar 26, 2021
11
1
0
75
If any one is interested, with lots of help from the folks in Guppy's discord, I figured out how to trigger RAT events through xml e.g. as a test case I created a new candy in the items.xml that teleports the player back to base when it is eaten. It is implemented in xml as a triggered effect, which issues the custom console command 'ChatAs'. The code for the 'ChatAs' console command is a super simple API mod written in C# and compiled to a dll using visual studio community 2019. No modifications are needed in RAT beyond create whatever events that you want to trigger.

using System.Collections.Generic;
using System.Xml.Linq;

// <triggered_effect trigger="onSelfPrimaryActionEnd" action="ExecuteConsoleCommand, Mods" command="chatas /tele base"/>

namespace ChatAs

{
public class ChatAsCommand : ConsoleCmdAbstract
{
public override string[] GetCommands() => new[] {"ChatAs"};

public override string GetDescription() => "ChatAs from the player who called the command. It is made to interface with the ExecuteConsoleCommand in an xml";

public override void Execute(List<string> _params, CommandSenderInfo _senderInfo)
{
string v = string.Join(" ", _params);
string message = v;
GameManager.Instance.ChatMessageServer(_cInfo: _senderInfo.RemoteClientInfo, _chatType: EChatType.Global, _senderEntityId: _senderInfo.RemoteClientInfo.entityId, _msg: message, _mainName: _senderInfo.RemoteClientInfo.playerName, _localizeMain: false, _recipientEntityIds: null);
}
}
}
 
Last edited:
  • Like
Reactions: Trekkan
Yep, it is my first C# mod. Its pretty simple. I can send you the compiled mod files if you are interested.
 
No need for me personally (I don't write mods), but you can post if it you'd like for those that might not be able to compile the above code themselves but want the functionality. You'd probably have to put it in a ZIP as the website won't allow a DLL though. =)
 
I will definitely do that. I'll post an example also. I'm using it to create a teleportation system using objects instead of chat commands. This will allow me to let RAT keep track of the tele locations.