ADD CUSTOM SPELLS
Adding your mod with TOML
Just create a fiddle/spells.toml and add a spell in this format:
[harvest]
name = "Harvest"
description = "Summons a fierce wind that harvests all fully grown crops on your farm when cast. Harvests may have higher yield."
type = "Farming"
cost = 2
icon_key = "spr_harvest_spell_icon"
upper_icon = "spr_harvest_spell_card_icon"
ribbon = "spr_harvest_spell_card_ribbon"
For the custom icons, make sure you have them under animations/your_mod/ and follow the naming conventions: spr_your_spell_icon_main.png, spr_your_spell_icon_locked.png, spr_your_spell_card_icon.png, spr_your_spell_card_ribbon.png.
The actual spell functionality
For this part you need to familiarize yourself a bit with MMAPI because you need to use hooks for this, and the implementation of what your spell does will have to be done in GML.
The structure, though, is also pretty simple:
function ys_register_callbacks() {
var _rt = __ys_runtime();
if (_rt.registered_hooks != undefined) return;
_rt.registered_hooks = true;
mmapi_on("game.room_changed", ys_room_changed);
mmapi_override("spells.can_cast", ys_can_cast)
mmapi_override("spells.cast", ys_cast)
}
function ys_room_changed(_ctx) {
//LEARN THE SPELL SOMEHOW
ARI.learn_spell(Spell.Harvest);
}
function ys_can_cast(_ctx) {
if (_ctx != Spell.YourSpell) return undefined;
if !instance_exists(obj_ari)
|| obj_ari.is_mounted()
|| ARI.get_mana() < SPELLS[Spell.YourSpell].cost
|| ARI.held_animal_id != undefined
{
return false;
}
//ADD CONDITION WHERE IT CAN BE USED
return true;
}
function ys_cast(_ctx) {
if (_ctx != Spell.YourSpell) return undefined;
//SPELL CAST IMPLEMENTATION
return true;
}