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?
 
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?
Is it something like this?


If yes, here's the new code.

takedamage file
Code:
void setJuggle()
{
    void self = getlocalvar("self");
    int damage = getlocalvar("damage");
    int jugglepoints = getentityproperty(self,"jugglepoints");
    int duration = 100; // PUT HOW LONG THE TINT LASTS

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

updatescript file
Code:
void showTint()
{
    void self = getlocalvar("self");
    int time = openborvariant("elapsed_time");
    int duration = getentityvar(self, "juggleTintDuration")/4;
    int intervalStart = duration*3; // RELATED TO 3/4 OF THE ENTIRE DURATION
    int intervalEnd = duration; // RELATED TO 1/4 OF THE ENTIRE DURATION

    if(getentityvar(self, "juggleTint") > time){
        int tintMode = 1;
        int tintColor = rgbcolor(254, 254, 254); // WHITE
        int blinkInterval = (getentityvar(self, "juggleTint") - time > intervalEnd && getentityvar(self, "juggleTint") - time < intervalStart);

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

PS: The interval is automatically adjusted if the duration is changed.
 
@Kratus : Thank you and congrats for finding how to do it!

But I'm frustrated, in my tests I strangely have the same result as the previous scripts. The damaged char is white without interval. I did make the changes for both scripts (and renamed old scripts), by example when I change the duration, it changes in the game.
 
Last edited:
Back
Top Bottom