Solved A question about blocks.

Question that is answered or resolved.

DD Tokki

Well-known member
I'm making a defense system by making blues (proto man) this time.
bor - 0033.png

The code is below.

Code:
void block(int Flag)
{
    void self = getlocalvar("self");

    if(Flag == 1)
    {
        changeentityproperty(self, "aiflag", "blocking", 1);
        changeentityproperty(self, "takeaction", "common_block");
    } else {
        changeentityproperty(self, "aiflag", "blocking", 0);
    }
}


com u freespecial5


anim freespecial5
loop 0
delay 30
offset 8 23
bbox 1 0 19 24
@cmd block 1
frame data/sprites/chara/blues/block-01.gif



In this way, I wrote a script to press the command upward to bring out the defense action.
However, as you can see in the screenshot, the result was that the missile penetrated.

What I expected was that the defense would be successful in freespecial5 with the script applied.

Maybe something went wrong?
 
I've sent you a link.
@DD Tokki

I was able to make it work, I think you want the following effect:


An important command was not configured in order to show us if the block is working or not. It is the bflashcommand.

1679796697392.png

And the block only worked after I replaced the spawn01 by the projectile function, and I added the base property on the shootR function to allow diagonal movements, otherwise the engine will think the current height is indeed the ground height.

C:
void shooter(void Shot, float dx, float dy, float Vx, float Vy)
{ // Shooting special projectile with speed control
   void self = getlocalvar("self");
   int Direction = getentityproperty(self, "direction");
   void vShot;

   if (Direction == 0){ //Is entity facing left?                 
      Vx = -Vx; //Reverse Vx direction to match facing
   }

   //vShot = spawn01(Shot, dx, dy, 0);
   int x = getentityproperty(self, "x");
   int y = getentityproperty(self, "y");
   int z = getentityproperty(self, "z");

   vShot = projectile(Shot, x+dx, z, y+dy, Direction, 0, 0, 0);
   changeentityproperty(vShot, "speed", Vx);
   changeentityproperty(vShot, "velocity", Vx, 0, Vy);

   return vShot;
}

C:
void shootR(void Shot, float dx, float dy)
{ // Shooting targetted projectile
   void self = getlocalvar("self");
   float Vx = getlocalvar("x"+self);
   float Vy = getlocalvar("y"+self);
   void vShot;

   if( Vx!=NULL() && Vy!=NULL() ){
     vShot = shooter(Shot, dx, dy, Vx, Vy);
     changeentityproperty(vShot, "base", 0); //Set base to zero to allow diagonal movement
     changeentityproperty(vShot, "velocity", Vx, 0, 2*Vy); //Move projectile towards target!
   }
}

Note that the "pharaoh-C '' passes through the player because the remove command is set to zero, different from the "pharaoh-B" which disappear after hitting the player no matter if it's blocked or not.
Please, apply these changes in your game file and let me know if it solves the problem.
 

Attachments

  • 1679796680928.png
    1679796680928.png
    17.1 KB · Views: 2
@DD Tokki

I was able to make it work, I think you want the following effect:


An important command was not configured in order to show us if the block is working or not. It is the bflashcommand.

View attachment 3489

And the block only worked after I replaced the spawn01 by the projectile function, and I added the base property on the shootR function to allow diagonal movements, otherwise the engine will think the current height is indeed the ground height.

C:
void shooter(void Shot, float dx, float dy, float Vx, float Vy)
{ // Shooting special projectile with speed control
   void self = getlocalvar("self");
   int Direction = getentityproperty(self, "direction");
   void vShot;

   if (Direction == 0){ //Is entity facing left?                
      Vx = -Vx; //Reverse Vx direction to match facing
   }

   //vShot = spawn01(Shot, dx, dy, 0);
   int x = getentityproperty(self, "x");
   int y = getentityproperty(self, "y");
   int z = getentityproperty(self, "z");

   vShot = projectile(Shot, x+dx, z, y+dy, Direction, 0, 0, 0);
   changeentityproperty(vShot, "speed", Vx);
   changeentityproperty(vShot, "velocity", Vx, 0, Vy);

   return vShot;
}

C:
void shootR(void Shot, float dx, float dy)
{ // Shooting targetted projectile
   void self = getlocalvar("self");
   float Vx = getlocalvar("x"+self);
   float Vy = getlocalvar("y"+self);
   void vShot;

   if( Vx!=NULL() && Vy!=NULL() ){
     vShot = shooter(Shot, dx, dy, Vx, Vy);
     changeentityproperty(vShot, "base", 0); //Set base to zero to allow diagonal movement
     changeentityproperty(vShot, "velocity", Vx, 0, 2*Vy); //Move projectile towards target!
   }
}

Note that the "pharaoh-C '' passes through the player because the remove command is set to zero, different from the "pharaoh-B" which disappear after hitting the player no matter if it's blocked or not.
Please, apply these changes in your game file and let me know if it solves the problem.
bor - 0040.png

thank you In my model.txt, bflash was set to 'know', so it couldn't be confirmed. The defense is good now.
Thanks for the additional tidying up of the script.
 
Back
Top Bottom