SunLikeModLib - custom skill, skill combo and character town button


How to make custom skill:

1. This time we make a skill, that will replace existing skill - AngelDemon's Shift skill. How it works originally? You press skill, AngelDemon lose 5 hp and transforms into something succubus-like. But if you somehow place this skill on non-AngelDemon, the skill will fail, writing game console that "This unit should not have this". That's because the Effect.Transformed tries to get character.stats.secondForm, which are empty for everyone except AngelDemon and Phoenix.

So, let's fix that. And make Shift skill into useful shapeshifting ability. First, we should fill SunLikeModLib.ModSkills.skillStruct value

customHL is a function that will highlight battle tiles when we click the skill, but before we cast it.

customRequire is a function that checks targeted battle tile for valid target. For simple conditions, Skill.Base.TargetType is enough.

customSelfRequire check caster's stats and tells if skill can be used.

2. Original "Shift" skill had only one line: addEffect(). Here we must check if caster targets self or other character, and assign secondForm stats. And to save target form somewhere, so unit could transform into that form later. For this purpose I made new passive, that does nothing, but saves last target's species name (hasTransformPassive() and addTransformPassive() functions)


3. Those functions


4. Adding this passive will be enough, but it will look ugly, showing "No tooltip for passive" in game. Let's fix that and properly register new passive type. Here I added passive name with a template - an "*" asterisk in its name and description.


That all we need for this skill to work. Let's add some additional features.

Adding new skill combos:

The Shift skill is uninheritable, so let's add some combinations to make it possible this skill to appear on other units through fusion and farm.


It is that easy.  Now BloodShield + Drain will give us Shift.


Adding a character town button:

1. Okay, so we've used Shift skill on many different units, even on Vine plant for lulz, but now want to go back to original AngelDemon's succubus-like alt form. Let's add a button, that will reset remembered form.

2. Here we have two delegate methods: check - the function that will get character's stats and say if the button should ever appear; and buttonEffect - the actual effect after button press.


3. And that's how it will look in game


Bonus: changing effect icon:

1. At first, I tried to call replaceIcon() in the Awake() method - the moment the game loads, game starting menu. But at that time, ImageManager.instance does not exists, and Exception is written in Unity log. Thats why I've added AfterLoadGame hooks, so a method will be executed after the player loaded a save.


2. This is how it looks in game

That's all for today. Have fun.

Files

AngelDemonShift_mod.zip 17 kB
Jun 30, 2023
AngelDemonShift_src.zip 2.5 kB
Jun 30, 2023

Get Portals of Phereon BepInEx mods

Leave a comment

Log in with itch.io to leave a comment.