Attack based on proximity

Aerisetta

Active member
I remember seeing this but i dont remember where

I want it so that when a player character attacks, the attack that comes out is based on distance from enemies.

Enemy is close, attack1 > attack2

If enemy is far Attack2

Any example of how this can work?
 
atchain {number} {number} {number} {number} {number} ...

  • Determines the attack chain order for player. The attack chain only starts if the first attack hits though. Also if player takes too long before pressing attack to combo, the attack chain will reset to 1st.
  • The maximum length is 12. How they are used are determined by 'combostyle' below.
  • {number} can be anything from 1 to 12. 1 refers to ATTACK1, 2 to ATTACK2 and so on. Note: before using number 5 to 12, set 'maxattacks' to 12 1st. See 'maxattacks' above.
  • You can repeat the same number if you need to.
  • You don't have to use all of them. Setting something like 'atchain 1 3 2' works.
  • Default combo is 'atchain 1 1 2 3'.

combostyle {bi}

  • Controls how 'atchain' works.
    • 0 = (Default) Static combo system
    • 1 = Dynamic combo system
    • 2 = Free combo system
  • With 'combostyle 1', various attack chain can be set with this command. For instance, 'atchain 1 2 5 0 3 3 6 0 4 0' have 3 kinds of attack chain in it.
  • The attack chains are selected by 'range' specified in respective attack (excluding ATTACK1). In above example, if ATTACK2 can't reach target, attack chain will switch to ATTACK3. If the latter hits, the attack chain becomes '1 3 3 6'. If the latter misses, attack chain will switch to ATTACK4.
  • With 'combostyle 2', attack chain will be performed even if none of the attacks connects (Streets of Rage 3 style)
 
atchain {number} {number} {number} {number} {number} ...

  • Determines the attack chain order for player. The attack chain only starts if the first attack hits though. Also if player takes too long before pressing attack to combo, the attack chain will reset to 1st.
  • The maximum length is 12. How they are used are determined by 'combostyle' below.
  • {number} can be anything from 1 to 12. 1 refers to ATTACK1, 2 to ATTACK2 and so on. Note: before using number 5 to 12, set 'maxattacks' to 12 1st. See 'maxattacks' above.
  • You can repeat the same number if you need to.
  • You don't have to use all of them. Setting something like 'atchain 1 3 2' works.
  • Default combo is 'atchain 1 1 2 3'.

combostyle {bi}

  • Controls how 'atchain' works.
    • 0 = (Default) Static combo system
    • 1 = Dynamic combo system
    • 2 = Free combo system
  • With 'combostyle 1', various attack chain can be set with this command. For instance, 'atchain 1 2 5 0 3 3 6 0 4 0' have 3 kinds of attack chain in it.
  • The attack chains are selected by 'range' specified in respective attack (excluding ATTACK1). In above example, if ATTACK2 can't reach target, attack chain will switch to ATTACK3. If the latter hits, the attack chain becomes '1 3 3 6'. If the latter misses, attack chain will switch to ATTACK4.
  • With 'combostyle 2', attack chain will be performed even if none of the attacks connects (Streets of Rage 3 style)

In this example, can it be determined before the first hit?

The example it states seems to require 1 to hit before a decision is made

I would like the decision to be made for the first hit

If the enemies are far, attack2

If the enemies are close, attack1 > attack2

also how do i set the range? the usual range 0 10 in the attack animation?
 
Look at this here:

Code:
atchain 1

anim    attack #Low punch
    delay    2
    offset    24 99
    bbox 5 0 56 101
    @cmd    makeOpponentBlock
    @cmd    attack1 0 58 0 "ANI_ATTACK4" #attack1 {minx} {maxx} {z} {animation}
    sound data/sounds/common/punch.wav
    frame    data/chars/ryu/161.gif
    attack1 50 6 46 20 7 0 0 0 23 0 0
    bbox 5 0 63 101
    @cmd    makeOpponentBlock
    frame    data/chars/ryu/162.gif
    @cmd    makeOpponentBlock
    frame    data/chars/ryu/163.gif
    attack1 0 0 0 0 0 0 0 0 0 0 0
    bbox 5 0 56 101
    @cmd    makeOpponentUnblock
#    @cmd    makeOpponentBlock
    frame    data/chars/ryu/164.gif
    offset    25 99
#    @cmd    makeOpponentUnblock
    frame    data/chars/ryu/165.gif
#    @cmd    makeOpponentUnblock
#    frame    data/chars/ryu/165.gif

anim    attack4 #Close LP
    delay    4
    offset    24 97
    @cmd    makeOpponentBlock
    frame    data/chars/ryu/166.gif
    attack 50 2 18 23 6 0 0 0 0 0
    range    0 30
    offset    25 99
    frame    data/chars/ryu/167.gif
    offset    23 99
    frame    data/chars/ryu/168.gif
    attack 0 0 0 0 0 0 0 0 0 0
    offset    23 98
    @cmd    makeOpponentUnblock
    frame    data/chars/ryu/169.gif
    offset    25 99
    frame    data/chars/ryu/170.gif

C:
void attack1(int RxMin, int RxMax, int Rz, void Ani)
{// Attack interruption with range check
    void self = getlocalvar("self");
    void target = findtarget(self); //Get nearest player
    float x = getentityproperty(self, "x");
    float z = getentityproperty(self, "z");
    int dir = getentityproperty(self, "direction");

    if(target!=NULL()){
      float Tx = getentityproperty(target, "x");
      float Tz = getentityproperty(target, "z");
      float Disx = Tx - x;
      float Disz = Tz - z;

      if(Disz < 0){
        Disz = -Disz;
      }

      if( Disx >= RxMin && Disx <= RxMax && Disz <= Rz && dir == 1) // Target within range on right facing?
      {
        performattack(self, openborconstant(Ani)); //Change the animation
      } else if( Disx >= -RxMax && Disx <= -RxMin && Disz <= Rz && dir == 0) // Target within range on left facing?
      {
        performattack(self, openborconstant(Ani)); //Change the animation
      }
    }
}
 
Look at this here:

Code:
atchain 1

anim    attack #Low punch
    delay    2
    offset    24 99
    bbox 5 0 56 101
    @cmd    makeOpponentBlock
    @cmd    attack1 0 58 0 "ANI_ATTACK4" #attack1 {minx} {maxx} {z} {animation}
    sound data/sounds/common/punch.wav
    frame    data/chars/ryu/161.gif
    attack1 50 6 46 20 7 0 0 0 23 0 0
    bbox 5 0 63 101
    @cmd    makeOpponentBlock
    frame    data/chars/ryu/162.gif
    @cmd    makeOpponentBlock
    frame    data/chars/ryu/163.gif
    attack1 0 0 0 0 0 0 0 0 0 0 0
    bbox 5 0 56 101
    @cmd    makeOpponentUnblock
#    @cmd    makeOpponentBlock
    frame    data/chars/ryu/164.gif
    offset    25 99
#    @cmd    makeOpponentUnblock
    frame    data/chars/ryu/165.gif
#    @cmd    makeOpponentUnblock
#    frame    data/chars/ryu/165.gif

anim    attack4 #Close LP
    delay    4
    offset    24 97
    @cmd    makeOpponentBlock
    frame    data/chars/ryu/166.gif
    attack 50 2 18 23 6 0 0 0 0 0
    range    0 30
    offset    25 99
    frame    data/chars/ryu/167.gif
    offset    23 99
    frame    data/chars/ryu/168.gif
    attack 0 0 0 0 0 0 0 0 0 0
    offset    23 98
    @cmd    makeOpponentUnblock
    frame    data/chars/ryu/169.gif
    offset    25 99
    frame    data/chars/ryu/170.gif

C:
void attack1(int RxMin, int RxMax, int Rz, void Ani)
{// Attack interruption with range check
    void self = getlocalvar("self");
    void target = findtarget(self); //Get nearest player
    float x = getentityproperty(self, "x");
    float z = getentityproperty(self, "z");
    int dir = getentityproperty(self, "direction");

    if(target!=NULL()){
      float Tx = getentityproperty(target, "x");
      float Tz = getentityproperty(target, "z");
      float Disx = Tx - x;
      float Disz = Tz - z;

      if(Disz < 0){
        Disz = -Disz;
      }

      if( Disx >= RxMin && Disx <= RxMax && Disz <= Rz && dir == 1) // Target within range on right facing?
      {
        performattack(self, openborconstant(Ani)); //Change the animation
      } else if( Disx >= -RxMax && Disx <= -RxMin && Disz <= Rz && dir == 0) // Target within range on left facing?
      {
        performattack(self, openborconstant(Ani)); //Change the animation
      }
    }
}
Thanks for sharing

Nothing seems to happen atm

NEVERMIND I GOT IT TO WORK YAY THANKS!
(my game resolution was high and i assume your game doesnt have Z axis, just needed higher values everywhere)
 
Last edited:
Back
Top Bottom