Tintcolor when jugglepoints reaches 0

16-bit Fighter

Active member
Could you tell me a function in didhitscript to make the hit char tints in white (I mean like for 0.5 sec he gets white and gets normal and gets white and gets normal and so on) when his jugglepoints reaches 0 (and therefore he's not juggleable anymore) please?

I think my script below starts well but I need the parts about duration and tintcolor that I don't master.

Code:
void noJuggleptsTint ()

    {

    void self         = getlocalvar("self");

    int jugglecost        = getentityproperty(self,"jugglecost");

    void damagetaker    = getlocalvar("damagetaker");

    jugglepoints        = getlocalvar(damagetaker,"jugglepoints");

    if (jugglepoints == jugglecost)

    {

    //

}
 
Could you tell me a function in didhitscript to make the hit char tints in white (I mean like for 0.5 sec he gets white and gets normal and gets white and gets normal and so on) when his jugglepoints reaches 0 (and therefore he's not juggleable anymore) please?

I think my script below starts well but I need the parts about duration and tintcolor that I don't master.

Code:
void noJuggleptsTint ()

    {

    void self         = getlocalvar("self");

    int jugglecost        = getentityproperty(self,"jugglecost");

    void damagetaker    = getlocalvar("damagetaker");

    jugglepoints        = getlocalvar(damagetaker,"jugglepoints");

    if (jugglepoints == jugglecost)

    {

    //

}
@16-bit Fighter I suggest using a combination of takedamage + updatescript in the entity who is taking the damage instead of the didhit event.
This is because it's better for each entity to manage himself instead of one attacker managing everyone. It may fail depending on the enemy amount.

To call both takedamage/updatescript in every entity:

Code:
takedamagescript data/scripts/takedamage.c
script data/scripts/updatescript.c

Inside the takedamage file.
Code:
void main()
{
    void self = getlocalvar("self");
    int damage = getlocalvar("damage");
    int jugglepoints = getentityproperty(self,"jugglepoints");
    int duration = 100;

    if(damage > 0){
        if(jugglepoints <= 0){
            setentityvar(self, "juggleTint", openborvariant("elapsed_time")+duration);
        }
    }
}

Inside the updatescript.
Code:
void main()
{
    void self = getlocalvar("self");

    if(getentityvar(self, "juggleTint") > openborvariant("elapsed_time")){
        int tintMode = 1;
        int tintColor = rgbcolor(254, 254, 254);

        changedrawmethod(self, "enabled", 1);
        changedrawmethod(self, "tintmode", tintMode);
        changedrawmethod(self, "tintcolor", tintColor);
    }
    else
    {
        if(getdrawmethod(self, "enabled")){
            setentityvar(self, "juggleTint", NULL());
            changedrawmethod(self, "reset", 1);
            changedrawmethod(self, "enabled", 0);
        }
    }
}

Additionally, you will need an extra step to clear the tint variables because each new level resets the elapsed time to zero. Due to this, you can have weird side effects if they are not cleared.

Inside the level.c
Code:
void main()
{
    void p1 = getplayerproperty(0, "entity");
    void p2 = getplayerproperty(1, "entity");

    if(p1){setentityvar(p1, "juggleTint", NULL());}
    if(p2){setentityvar(p2, "juggleTint", NULL());}
}

This is the code in action.

 
@Kratus : Thank you, it works like a charm‼ 👏

Still, the specific effect I'd like is a blink in white (I don't how to say and I tried probably too approximatively in my first post). I mean the entity who is taking the damage would get white at less twice in row before recovering his colors. IOW for 0.25 sec he's white and then for 0.25 sec he's not and then for 0.5 sec he's white again. Any idea to reach this?

Inside the level.c
Code:
void main()
{
    void p1 = getplayerproperty(0, "entity");
    void p2 = getplayerproperty(1, "entity");

    if(p1){setentityvar(p1, "juggleTint", NULL());}
    if(p2){setentityvar(p2, "juggleTint", NULL());}
}

Would it be necessary if this effect was just for enemies?
 
Back
Top Bottom