Auto dodge

O Ilusionista

Captain 100K
Help a rusty developer get back to programming, lol.

I wanted to recreate an ability of Vision in the game Marvel strike force: there he has a probability of "phasing out" when the enemy attacks him (that is, he becomes intangible).
See the move in action (2:13)

Would it have a take damage or an ondoattack? I think the second one, right?

In the game, when this chance happens, he strikes a pose and the attacker simply passes through him.
So I think it would be a case of calculating a random chance and, if that chance falls, it would simply change animation to one without the bbox and nullify the attack.

Am I right?
 
Solution
@O Ilusionista
Hey buddy, I did some tests with this concept, here's the script using the ondoattack event on Axel:

C:
void main()
{
    //WORKS FOR DEFENDER ONLY
    if(getlocalvar("which")){
        void self    = getlocalvar("self");
        void type    = getentityproperty(self,"type");
        int iR        = rand()%50+50; //AVOID NEGATIVE NUMBERS, COUNT FROM 0 TO 100

        if(type == openborconstant("TYPE_PLAYER")){ //WORKS ONLY FOR PLAYERS
            if(iR > 20){ //CHECK THE CHANCE
                changeopenborvariant("lasthitc", 0); //DISABLE LAST HIT
                performattack(self, openborconstant("ANI_FOLLOW10"), 1); //CHANGE TO DODGE
            }
        }
    }
}

You are correct @O Ilusionista. Doattack is the best way. Here's the video about it to give you a refresher.
THanks! Ah, now I remember - the build I use (6330) uses a reverse logic in some of its components (I can't remember, but I think its "which").
You had helped me setting it (its on your gist on the same video), but I remember it worked on reversal - the entity got hit instead of nullyfing it.

Plus, on Vision case, this should work against EVERY type of attack, not against a specific one.
And I don't want to use the same trick I used on Black Cat (and alternative idle) because I want him to dodge only when the attack is about to hit him.
 
@O Ilusionista
Hey buddy, I did some tests with this concept, here's the script using the ondoattack event on Axel:

C:
void main()
{
    //WORKS FOR DEFENDER ONLY
    if(getlocalvar("which")){
        void self    = getlocalvar("self");
        void type    = getentityproperty(self,"type");
        int iR        = rand()%50+50; //AVOID NEGATIVE NUMBERS, COUNT FROM 0 TO 100

        if(type == openborconstant("TYPE_PLAYER")){ //WORKS ONLY FOR PLAYERS
            if(iR > 20){ //CHECK THE CHANCE
                changeopenborvariant("lasthitc", 0); //DISABLE LAST HIT
                performattack(self, openborconstant("ANI_FOLLOW10"), 1); //CHANGE TO DODGE
            }
        }
    }
}

 
Solution
@Kratus I am customizing your script to not happens when the player is on air neither is hit by a TYPE ITEM.
The first one I already got, but the second one is not working.

What I am doing wrong?
C-like:
void main()
{
    //WORKS FOR DEFENDER ONLY
    if(getlocalvar("which")){
        void self    = getlocalvar("self");
        void type    = getentityproperty(self,"type");
        int iR       = rand()%50+50; //AVOID NEGATIVE NUMBERS, COUNT FROM 0 TO 100
        void alt     = getentityproperty(self, "a"); //Get Y location and add adjustment.
        void other;     // gets the attacker
        char iType = getentityproperty(other, "type"); // gets the attacker type


        if(type == openborconstant("TYPE_PLAYER")){ //WORKS ONLY FOR PLAYERS
            if(iR > 20 && alt == 0 && iType != openborconstant("TYPE_ITEM")){ //CHECK THE CHANCE, ALTITUDE and not ITEM
                changeopenborvariant("lasthitc", 0); //DISABLE LAST HIT
                performattack(self, openborconstant("ANI_FOLLOW16"), 1); //CHANGE TO DODGE
            }
        }
    }
}
 
@Kratus I am customizing your script to not happens when the player is on air neither is hit by a TYPE ITEM.
The first one I already got, but the second one is not working.

What I am doing wrong?
C-like:
void main()
{
    //WORKS FOR DEFENDER ONLY
    if(getlocalvar("which")){
        void self    = getlocalvar("self");
        void type    = getentityproperty(self,"type");
        int iR       = rand()%50+50; //AVOID NEGATIVE NUMBERS, COUNT FROM 0 TO 100
        void alt     = getentityproperty(self, "a"); //Get Y location and add adjustment.
        void other;     // gets the attacker
        char iType = getentityproperty(other, "type"); // gets the attacker type


        if(type == openborconstant("TYPE_PLAYER")){ //WORKS ONLY FOR PLAYERS
            if(iR > 20 && alt == 0 && iType != openborconstant("TYPE_ITEM")){ //CHECK THE CHANCE, ALTITUDE and not ITEM
                changeopenborvariant("lasthitc", 0); //DISABLE LAST HIT
                performattack(self, openborconstant("ANI_FOLLOW16"), 1); //CHANGE TO DODGE
            }
        }
    }
}
@O Ilusionista
At first sight I think the only missing parameter is the "other" entity.

C:
void other = getlocalvar("other");

You can also try to get the attack type instead of the attacker entity, like this:
C:
void main()
{
    //WORKS FOR DEFENDER ONLY
    if(getlocalvar("which")){
        void self        = getlocalvar("self");
        void type        = getentityproperty(self,"type");
        void atkType    = getlocalvar("attacktype"); //GET THE CURRENT ATTACK TYPE
        int iR            = rand()%50+50; //AVOID NEGATIVE NUMBERS, COUNT FROM 0 TO 100
        int alt            = getentityproperty(self, "a"); //Get Y location and add adjustment.
       
        if(type == openborconstant("TYPE_PLAYER")){ //WORKS ONLY FOR PLAYERS
            if(atkType != openborconstant("ATK_ITEM")){ //AVOID TYPE ITEM ATTACKS
                if(iR > 20 && alt == 0){ //CHECK THE CHANCE, ALTITUDE and not ITEM
                    changeopenborvariant("lasthitc", 0); //DISABLE LAST HIT
                    performattack(self, openborconstant("ANI_FOLLOW16"), 1); //CHANGE TO DODGE
                }
            }
        }
    }
}

I'm testing the code right now to confirm if it works.
 
Back
Top Bottom