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);
}
}
}
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: