SunLikeModLib - equipment abilities


How to add new item skills and new passive effects

1. Let's start by creating a new class, and a static method ItemSkill(). Like consumables' item effects, it returns "true" if it was used successfully, and "false" othwerwise - so no item charge and casting cost would be spent.

So in this example, we are making a Dominator helmet with powerful ability to take control of enemy character for one turn, and then give back control. We can make target switch teams in our item skill effect code, but how can we cancel this effect later? We will add a new passive effect - "SwitchSides1", that at the end of the turn would switch teams again and remove itself. Also I don't want enemy unit have 2 ap at the start of his turn, because we mindcontrolled his 1 ap on our turn. So I add 1 stack of Entangled and 1 stack of Haste to counteract move speed decrease a bit.


2. Unfortunately, the result differs from what we intended to do. Here we set item stats, including its ability cost and description in LoadItem() function.


3. I've made a register() method inside our class, so we won't forget to register all parts of our item inside Awake() method of the plugin. Here: new passive effect, item skill effect and item stats.

The PassiveEffect has "user" - owner of the effect, and "target" for those who triggered passive from onGettingAttacked or target of onAttack (and similar triggers). 


4. Here is how our item will finally look in game. It is based on Helmet, so it has its stat modifiers, looks and cost. But all these can be changed inside our LoadItem function. And it has our new skill and description.


5. Combat test. As you see, it does not highlight valid targets, so we have to check them manually inside ItemSkill function.


6. Here. We took control of enemy centaur and gave it 1 ap to do thing we want him to do.


7. As I mentioned earlier, the effect was not exactly as I wanted it to be. The onTurnEnd passive didn't trigger at our turn, and instead - only on enemy's turn. Perhaps this can be fixed by changing trigger to onTurnStart. BUT! We've got ourself a funny surprise! Our mindcontrolled centaur somehow is still controlled by game's AI and continued to betray his teammates on his turn. I'd say this bug was just promoted to feature. :)



That's all.

Files

Dominator_mod.zip 12 kB
Jun 28, 2023
Dominator_src.zip 2 kB
Jun 28, 2023

Get Portals of Phereon BepInEx mods

Leave a comment

Log in with itch.io to leave a comment.