Setting up the reference to the Message Receiver:

Mod tomeOfBattle = ModManager.Instance.GetModFromGUID("a166c215-0a5a-4582-8bf3-8be8df80d5e5");
if (tomeOfBattle != null)
  {
//place messages here
  }


Mod messages:

//returns the KeyCode of the TOB Attack Input
KeyCode swingKeyCode = KeyCode.None;
ModManager.Instance.SendModMessage(tomeOfBattle .Title, "getSwingKeyCode", null, (string message, object data) =>
{
swingKeyCode = (KeyCode)data;
});

//returns the Reach value of the currently equipped weapon
float weaponReach = 0;
ModManager.Instance.SendModMessage(tomeOfBattle .Title, "getWeaponReach", null, (string message, object data) =>
{
weaponReach = (float)data;
});

//Overrides the properties of the succeeding loosed arrows
object[] overrides = new object[8]
{
modelID,//int, model ID of mesh
itemTemplateIndex,//int, item template index of item to be consumed as ammunition
missileSpeed,//float, speed multiplier
missileGravity,//float, gravity multiplier
accuracyBonus,//int, to-Hit additive modifier
damageBonus,//int, damage additive modifier
ammoCounterColor,//Color, color of the ammo counter
ammoAutoReset//bool, reverts to normal arrows if custom ammo is exhausted
}
ModManager.Instance.SendModMessage(tomeOfBattle .Title, "overrideMissile", overrides);

//Reverts any missile overrides
ModManager.Instance.SendModMessage(tomeOfBattle .Title, "resetMissile", overrides);

//EVENTS SUBSCRIBING

//Triggers when a missile override or reset occurs. Passes the item template of the new ammo item.
ModManager.Instance.SendModMessage(tomeOfBattle .Title, "onMissileChange", (Action<int>)OnMissileChange);

//Triggers when a missile is spawned. Passes the missile gameobject, weapon, and draw time of the shot.
ModManager.Instance.SendModMessage(tomeOfBattle .Title, "onMissileSpawn", (Action<GameObject, DaggerfallUnityItem, float>)OnMissileSpawn);

//Triggers when a missile hits something. Passes the missile gameobject, weapon, hit gameobject and the point of impact.
ModManager.Instance.SendModMessage(tomeOfBattle .Title, "onMissileHit", (Action<GameObject, DaggerfallUnityItem ,GameObject, Vector3>)OnMissileHit);

//Triggers when the player readies a spell. Passes the Ready Spell VFX gameobject and EntityEffectBundle of the readied spell.
ModManager.Instance.SendModMessage(tomeOfBattle .Title, "onSpellReady", (Action<GameObject, EntityEffectBundle>)OnSpellReady);

//Triggers when the casting animation begins. Passes the EntityEffectBundle of the cast spell.
ModManager.Instance.SendModMessage(tomeOfBattle .Title, "onSpellCast", (Action<EntityEffectBundle>)OnSpellCast);

//Triggers when the casting animation ends. Passes the EntityEffectBundle of the released spell.
ModManager.Instance.SendModMessage(tomeOfBattle .Title, "onSpellRelease", (Action<EntityEffectBundle>)OnSpellRelease);

//Triggers when a spell missile is spawned. Passes the missile gameobject and EntityEffectBundle of the missile payload.
ModManager.Instance.SendModMessage(tomeOfBattle .Title, "onSpellSpawn", (Action<GameObject, EntityEffectBundle>)OnSpellSpawn);

//Triggers when a spell missile hits something. Passes the missile gameobject, EntityEffectBundle of the missile payload, the hit gameObject and the point of impact.
ModManager.Instance.SendModMessage(tomeOfBattle .Title, "onSpellHit", (Action<GameObject, EntityEffectBundle, GameObject, Vector3>)OnSpellHit);

//Triggers when a spell affects something (like a Touch or AOE). Passes the EntityEffectBundle of the spell and the hit gameObject.
ModManager.Instance.SendModMessage(tomeOfBattle .Title, "onSpellAffect", (Action<EntityEffectBundle, GameObject>)OnSpellAffect);

Event Methods:

void OnMissileChange(int itemTemplate)
{
//do thing here
}

void OnMissileSpawn(GameObject missileObject, DaggerfallUnityItem weapon, float drawTime)
{
//do thing here
}

void OnMissileHit(GameObject missileObject, DaggerfallUnityItem weapon, GameObject hitObject, Vector3 hitPoint)
{
//do thing here
}

void OnSpellReady(GameObject readySpellGameobject, EntityEffectBundle spell)
{
//do thing here
}

void OnSpellCast(EntityEffectBundle spell)
{
//do thing here
}

void OnSpellRelease(EntityEffectBundle spell)
{
//do thing here
}

void OnSpellSpawn(GameObject missileObject, EntityEffectBundle payload)
{
//do thing here
}

void OnSpellHit(GameObject missileObject, EntityEffectBundle payload, GameObject hitObject, Vector3 hitPoint)
{
//do thing here
}

void OnSpellAffect(EntityEffectBundle spell, GameObject affectedObject)
{
//do thing here
}

Article information

Added on

Edited on

Written by

RedRoryOTheGlen