Solved Health regeneration when in charging state

Question that is answered or resolved.

kimono

Well-known member
Hi, I'm wondering how I can make a regeneration that gives 1 health point for 1 magic point every 10 centiseconds when I'm holding the basic attack button.
The player has got basically of 100 max hp and max 100mp. The regeneration can stop when the player is full hp.
Maybye energycost isn't enough to make this kind of mechanism. Any help is appreciated :) .
 
The only way I have in mind right now is to use personal updatescript or ondrawscript to detect attack button holding and regenerate HP per period.

gives 1 health point for 1 magic point every 10 centiseconds

Wait a second, 1 HP per MP? so if there's no MP, no HP regen?
 
Here, I hope this helps:

C:
void ConvertHPMP    (void HPValue, void MPValue, void ExitAnim)
{
    void    Self        getlocalvar("self");
    void    SelfHP        getentityproperty(Self, "health");
    void    SelfMaxHP    getentityproperty(Self, "maxhealth");
    void    SelfMP        getentityproperty(Self, "mp");

    void    FinalHP;
    void    FinalMP;
    void    FinalAnim;



    if    (SelfHP < SelfMaxHP && SelfMP >= MPValue)
    {
        FinalHP = SelfHP+HPValue;
        FinalMP = SelfMP-MPValue;
        changeentityproperty(Self, "health", FinalHP);
        changeentityproperty(Self, "mp", FinalMP);
    }else
        {
            FinalAnim = openborconstant(ExitAnim);
            executeanimation    (Self, FinalAnim,1);       
        }
}

This is a animationscript that you should call on each frame you'd want to convert MP into HP.
If your character runs out of MP, or if they fill their HP completely, they will perform the animation in the last parameter.

Usage example:
Code:
delay    2
        @cmd    ConvertHPMP    1 1 "ANI_FOLLOW10"
frame    data/chars/johndoe/charge_00
        @cmd    ConvertHPMP    1 1 "ANI_FOLLOW10"
frame    data/chars/johndoe/charge_01
        @cmd    ConvertHPMP    1 1 "ANI_FOLLOW10"
frame    data/chars/johndoe/charge_02
        @cmd    ConvertHPMP    1 1 "ANI_FOLLOW10"
frame    data/chars/johndoe/charge_03

In the example above, your character will consume 1 MP, gain 1 HP, and run follow10 when they are with less than 1 MP or with max HP.

I hope this helps, I made this code while on work so I couldn't test it. Lemme know if there are any issues, and I'll do my best to help.
 
Back
Top Bottom