Library Of Ruina

Library Of Ruina

Library of Runia Workshop
Custom Head WorkShop_TEST
Learn More
Taroso 11 Jan, 2023 @ 1:31am
Modding Help
Trying to make mod, though having with trouble making a passive. Though I had it but it crash on proc. It is meant to double healing received while it sounds simple to me on paper I seem to missing something. Still learning coding so will appreciate the help.
< >
Showing 1-10 of 10 comments
Taroso 11 Jan, 2023 @ 1:33am 
public class PassiveAbility_taru_hungerH : PassiveAbilityBase
{
public override void OnRecoverHp(int amount)

{
this.owner.RecoverHP(amount * 2);
}


}

Ended up on this after slamming my head keyboard in vain for while. Though this doesn't work.
DoT 19 12 Jan, 2023 @ 9:18am 
The reason it's probably crashing is because this sets up an infinite heal, for instance, public override void OnRecoverHp(int amount) works as an effect that will proc every time you heal,

This means that the above effect this.owner.RecoverHP(amount * 2); will make the character heal twice as much as they were just healed for.

So if the character with the passive recovers 2 hp, the effect will trigger, healing the character for *2 of what they just healed, healing the character an extra 4 hp on top of the 2 hp for a total of 6 hp healed all together, and because they just healed an extra 4 hp, it will trigger again, healing them for another 8, then 16, and so on. It infinitely loops, which is what is causing the crash
Last edited by DoT; 12 Jan, 2023 @ 11:21am
DoT 19 12 Jan, 2023 @ 10:53am 
You Just have to add some sort of roadblock to prevent the effect from healing over itself over and over. My work around for a passive like this would be something like :

public class PassiveAbility_doubleheal : Passiveability_Statue
{
public override void OnWaveStart()
{
this._recoveredAmount = 0;
}
public override void OnRecoverHp(int amount)
{
if (this._recoveredAmount == 0)
{
this._recoveredAmount += amount;
this.owner.RecoverHP(amount);
}
if (this._recoveredAmount > 0)
{
this._recoveredAmount = 0;
}
}
private int _recoveredAmount;

}

This will make the passive have a private number called _recoveredAmount , and at the start of the an act it will equal 0

Then whenever you heal, Lets say you heal 4 hp, the game will check if _recoveredAmount is equal to 0 or not, if its equal to 0, the character will heal for another 4 hp, and also increase the private number _recoveredAmount (whatever this increases by doesn't matter as long as it increases by at least 1, The above code increases it by the amount of hp healed to make it easier)

Now because you healed another 4 hp, the game will check this effect again, but because this time _recoveredAmount isn't equal to 0, it doesn't make the character recover hp again, instead, it changes the amount of whatever _recoveredAmount was, and sets it to 0. Making the double heal effect ready for the next time the character heals.

Also, This doesn't have to be _recoveredAmount either, You can change it to whatever you like as long as the rest matches whatever you put next to Private Int, such as changing _RecoveredAmount ---> healingtimeVeryKewl would make the passive look like :

public class PassiveAbility_doubleheal : Passiveability_Statue
{
public override void OnWaveStart()
{
this.healingtimeVeryKewl = 0;
}
public override void OnRecoverHp(int amount)
{
if (this.healingtimeVeryKewl == 0)
{
this.healingtimeVeryKewl += amount;
this.owner.RecoverHP(amount);
}
if (this.healingtimeVeryKewl > 0)
{
this.healingtimeVeryKewl = 0;
}
}
private int healingtimeVeryKewl;

}
Last edited by DoT; 12 Jan, 2023 @ 11:29am
DoT 19 12 Jan, 2023 @ 11:38am 
On a Side note, the above code might glitch out hard / crash if a character decides to recover 0 hp for whatever reason, or you run into an effect where the code uses this.owner.RecoverHP(-3) as a way to lose hp, I Haven't tested it to see if it would cause any problems but as insurance, you can change the code as following to make it trigger only on instances where at least 1 hp was healed

public class PassiveAbility_doubleheal : Passiveability_Statue
{
public override void OnRoundStart()
{
this.healingtimeVeryKewl = 0;
}
public override void OnRecoverHp(int amount)
{
if (this.healingtimeVeryKewl == 0 && amount >= 1)
{
this.healingtimeVeryKewl += amount;
this.owner.RecoverHP(0);
}
if (this.healingtimeVeryKewl > 0 && amount >= 1)
{
this.healingtimeVeryKewl = 0;
}
}
private int healingtimeVeryKewl;

}
Last edited by DoT; 12 Jan, 2023 @ 11:40am
Taroso 12 Jan, 2023 @ 11:55am 
Thank, friend that does coding also helped out so I might have something as well. Still testing theirs but will give this a shot too. Thank for the help ^^

At the moment a currently also working next passive as well. Haste +1 and Power +1 for every 25% you have. Seeing looking through the game code for what I can example to start from.
DoT 19 12 Jan, 2023 @ 2:59pm 
Originally posted by Taroso:

At the moment a currently also working next passive as well. Haste +1 and Power +1 for every 25% you have.

do you mean that dice gain +1 by 25% of the characters haste?

if that is the case i already have a mod from one of the ones i posted, that does the same thing basically,

it increases the maximum range of dice by half of the characters haste.

I can share it and you can just change the value from 50% to 25%, and make increase power instead of the maximum range
Taroso 12 Jan, 2023 @ 3:04pm 
For every 25% of MaxHP gain haste, and power.
Taroso 12 Jan, 2023 @ 3:08pm 
Sorry for the confusion. Will send friend request to make this go easier.
DoT 19 12 Jan, 2023 @ 5:12pm 
public class PassiveAbility_Withering : PassiveAbilityBase
{
public override void BeforeRollDice(BattleDiceBehavior behavior)
{
int Powerlevel = 4;
if (this.owner.hp < (float)this.owner.MaxHp * 1.00f)
{
Powerlevel = 3;
}
if (this.owner.hp <= (float)this.owner.MaxHp * 0.74f)
{
Powerlevel = 2;
}
if (this.owner.hp <= (float)this.owner.MaxHp * 0.49f)
{
Powerlevel = 1;
}
if (this.owner.hp <= (float)this.owner.MaxHp * 0.24f)
{
Powerlevel = 0;
}
behavior.ApplyDiceStatBonus(new DiceStatBonus
{
power = Powerlevel,
});
}
public override void OnRoundStart()
{
if (this.owner.hp == (float)this.owner.MaxHp * 1.00f)
{
HealthyLevel = 4;
}
else if (this.owner.hp < (float)this.owner.MaxHp * 1.00f && this.owner.hp >= (float)this.owner.MaxHp * 0.75f)
{
HealthyLevel = 3;
}
if (this.owner.hp <= (float)this.owner.MaxHp * 0.74f && this.owner.hp >= (float)this.owner.MaxHp * 0.50f)
{
HealthyLevel = 2;
}
if (this.owner.hp <= (float)this.owner.MaxHp * 0.49f && this.owner.hp >= (float)this.owner.MaxHp * 0.25f)
{
HealthyLevel = 1;
}
if (this.owner.hp <= (float)this.owner.MaxHp * 0.24f)
{
HealthyLevel = 0;
}
}
public override int GetSpeedDiceAdder(int speedDiceResult)
{
return HealthyLevel;
}
private int HealthyLevel;
}
Taroso 13 Jan, 2023 @ 11:43pm 
Okay another question to the universe people here. Anyone know how to add custom map Icons? I know it need harmony but I don't what else is needed.
< >
Showing 1-10 of 10 comments
Per page: 1530 50