Way of Martial Arts

In Progress Way of Martial Arts 0.5

No permission to download
The project is currently under development.
maxman said:
Courtesy of Damon Caskey for the button diagonals...

Thanks, but that code is ancient, and horrible. And even then it was meant as a template, not really for production code. Here's an updated version that breaks down the IF logic to make it readable, removes all the unused variables, and offloads forward facing key logic to a support function.

Code:
void main()
{
    void target;        // Target entity for action.
    int player_index;   // Player index triggering event.
        
    // Key status.
    int key_hold;
    int key_forward;
    
    // Get the player index and target entity.
    player_index    = getlocalvar("player");
    target          = getplayerproperty(player_index, "entity");       
    
    // Get key hold status.
    key_hold    = getplayerproperty(player_index, "keys");    
    
    // Holding the down key?
    if(key_hold & openborconstant("FLAG_MOVEDOWN"))
    {
        // Check to see if current hold key has a forward match.
        key_forward = dc_check_key_forward(key_hold, target);
    
        if(key_forward)
        {
            performattack(target, openborconstant("ANI_FOLLOW1"));
        }
    }
}
        
// Caskey, Damon V.
// 2018-08-13
// 
// Return true if key status includes a "forward"
// direction key in relation to target entity facing.
int function dc_check_key_forward(int key_status, void target)
{
    int result;
    
    // Default false.
    result = 0;
    
    // Which direction are we facing?
    direction = getentityproperty(target, "direction");
    
    // Facing right?
    if(direction == openborconstant("DIRECTION_RIGHT"))
    {
        // Does the current key status contain a match
        // to the right direction key? If so result is true.
        if(key_status & openborconstant("FLAG_MOVERIGHT"))
        {
            result = 1;
        }        
    }
    else
    {
        // Same as above, but for left.
        if(key_status & openborconstant("FLAG_MOVELEFT"))
        {
            result = 1;
        }
    }
    
    return result;
}

HTH,
DC
 
Thanks Maxman and Damon Caskey, so if I understand well, I must call the script for the roll anim with this way:
anim freespecial @cmd {name of the script}? Sorry to bother you :)
 
Oh, I didn't see how you were applying it. Well, first thing is you need to give it a name besides "main". Main is a built in function that autoruns when a script file is executed. Give it a name that makes sense to you.

Next, you need to save it as an animation script - OR add it into an existing animation script if you already have one.

DC
 
@Damon Caskey:
I've got an error:  Can't compile script

Sorry but I need to understand how to link an animation with one script. So, I have the anim follow1:
Code:
anim 	follow1 #roll
	offset	42 104
	bbox.position.x 27
  	bbox.position.y 29
	bbox.size.x 29
	bbox.size.y 75
	delay	8
	subentity	dust
	spawnframe	0 0 0 0 0
	frame	data/chars/karategi/roll1.gif
	frame	data/chars/karategi/roll2.gif
	delay	10
	@cmd	dasher 5 0 0 1
	frame	data/chars/karategi/roll3.gif
	delay	20
	frame	data/chars/karategi/roll4.gif
	delay	10
	frame	data/chars/karategi/roll5.gif
	delay	8
	@cmd	dasher 0 0 0 1
	bbox.position.x 27
	bbox.position.y 29
	bbox.size.x 29
	bbox.size.y 75
	frame	data/chars/karategi/roll6.gif
I have also a player.c for the animation script. Then, how can I assign the part of code you submit to me (thanks for it!) with the animation that we call follow1?
I'm not very familiar with scripts yet and it's important to me to know what I'll do :)
 
Ok here it is:
Code:
#include "data/scripts/library/spawn.h"
#include "data/scripts/library/basic.h"

void mpcost( int Cost)
{// Spend some MP
    void self = getlocalvar("self");
    int MP = getentityproperty(self,"mp");

    changeentityproperty(self, "mp", MP-Cost); //Spend!
}

void limiter(int Limit)
{// Prevents hero from performing the animation if his/her MP is less than Limit
    void self = getlocalvar("self");
    int MP = getentityproperty(self,"mp"); //Get entity's MP
    int y = getentityproperty(self,"a"); //Get entity's altitude
    int b = getentityproperty(self, "base"); //Get entity's base

   if(MP<=Limit) // Don't have enough MP?
   {
     if(y > b) // Mid air?
     {
       changeentityproperty(self, "animation", openborconstant("ANI_JUMP") );
     } else{
       setidle(self); //Don't play the animation
     }
   }
}

void limiterSub()
{// Prevents hero from performing the animation if he/she doesn't have any subweapon
   void self = getlocalvar("self");
   int iPI = getentityproperty(self,"playerindex"); //Get player index
   int SubWeapon = getglobalvar(iPI+"0");
   int y = getentityproperty(self,"a"); //Get entity's altitude
   int b = getentityproperty(self, "base"); //Get entity's base

   if( SubWeapon == NULL() ) // Don't have subweapon?
   {
     if(y > b) // Mid air?
     {
       changeentityproperty(self, "animation", openborconstant("ANI_JUMP") );     
     } else{
       setidle(self); //Don't play the animation
     }
   }
}

void floater( int Time )
{// Floats in Time centiseconds
    void self = getlocalvar("self");
    int eTime = openborvariant("elapsed_time");

    changeentityproperty(self, "tosstime", eTime + 2*Time);
}

void keyint(void Ani, int Frame, void Key, int Hflag)
{// Change current animation if proper key is pressed or released
// Animation is changed to attack mode

    void self = getlocalvar("self");
    int Dir = getentityproperty(self, "direction");
    int iPIndex = getentityproperty(self,"playerindex"); //Get player index
    void iRKey;

      if (Key=="U"){ //Up Required?
        iRKey = playerkeys(iPIndex, 0, "moveup"); // "Up"
      } else if (Key=="D"){ //Down Required?
        iRKey = playerkeys(iPIndex, 0, "movedown"); // "Down"
      } else if (Key=="L"){ //Left Required?
        iRKey = playerkeys(iPIndex, 0, "moveleft"); // "Left"
      } else if (Key=="R"){ //Right Required?
        iRKey = playerkeys(iPIndex, 0, "moveright"); // "Right"
      } else if (Key=="F"){ //Forward Required?
        if (Dir == 0){ // Facing Left?
          iRKey = playerkeys(iPIndex, 0, "moveleft"); // "Left"
        } else { // Facing Right
          iRKey = playerkeys(iPIndex, 0, "moveright"); // "Right"
        }
      } else if (Key=="B"){ //Backward Required?
        if (Dir == 1){ // Facing Right?
          iRKey = playerkeys(iPIndex, 0, "moveleft"); // "Left"
        } else { // Facing Left
          iRKey = playerkeys(iPIndex, 0, "moveright"); // "Right"
        }
      } else if (Key=="J"){ //Jump Required?
        iRKey = playerkeys(iPIndex, 0, "jump"); // "Jump"
      } else if (Key=="A"){ //Attack Required?
        iRKey = playerkeys(iPIndex, 0, "attack"); // "Attack"
      } else if (Key=="S"){ //Special Required?
        iRKey = playerkeys(iPIndex, 0, "special"); // "Special"
      }

      if (Hflag==1){ //Not holding the button case?
        iRKey = !iRKey; //Take the opposite condition
      }

      if (iRKey){
        if (Ani=="ANI_IDLE"){ // Going idle?
          setidle(self, openborconstant("ANI_IDLE")); //Be idle!
        } else {
          performattack(self, openborconstant(Ani)); //Change the animation
        }
        updateframe(self, Frame); //Change frame
      }
}

void keymove(float Vx)
{// Move hero if direction button is pressed
      void self = getlocalvar("self");
      int iPIndex = getentityproperty(self,"playerindex"); //Get player index
	float xdir = 0;

      if (playerkeys(iPIndex, 0, "moveleft")){// Left is pressed?
	  xdir = -Vx;
	} else if(playerkeys(iPIndex, 0, "moveright")){// Right is pressed?
	  xdir = Vx;
      }

	changeentityproperty(self, "velocity", xdir);
 
I'm certain you have dasher in basic.h which is #included in player.c. You do have a library folder as a sub-folder of scripts folder. Check it out.

Wow! This is the first time I edited the code by adding 2 anims such as anim duckrise and anim ducking for anim duck! anim ducking is a transition between standing and crouching. anim duckrise is for getting up from ducking. So this concludes you can have a single frame (or a little more for transition) for anim duck if you use both. It's worth it, but I personally like to go with scripts without using duckrise and ducking. Try adding those two and test them. :)

Damon Caskey said:
Thanks, but that code is ancient, and horrible. And even then it was meant as a template, not really for production code. Here's an updated version that breaks down the IF logic to make it readable, removes all the unused variables, and offloads forward facing key logic to a support function.

That template was quite useful for some mods I have and it's workable, but that updated version seems a lot better. Though I haven't tried it, I can be sure it works. I can make some edits off of that. Thanks for that code, DC. Kudos.

 
I've got an error Script compile error: can't find function 'dc_check_key_forward'

Yes, you are right basic.h:
Code:
//Library scripts for basic functions

void platform(int Flag)
{// Turns subject's platform status
    void self = getlocalvar("self");
    changeentityproperty(self, "Subject_to_Platform", Flag);
}

void offscreenkill( float dx, int E )
{// Check position relative to screen. If enemy is offscreen, suicide!
//  dx : Distance to screen edge
//  E  : Edge selection, 0 = left, 1 = right

    void self = getlocalvar("self");
    int x = getentityproperty(self,"x"); //Get character's x coordinate
    int XPos = openborvariant("xpos"); //Get screen edge's position

    if( (x > XPos + 320 + dx) && (E == 1) ){ // Offscreen to the right?
      killentity(self); //Suicide!
    } else if( (x < XPos - dx) && (E == 0) ){ // Offscreen to the left?
      killentity(self); //Suicide!
    }
}

void beidle()
{// Go to IDLE animation!
    void self = getlocalvar("self");

    setidle(self, openborconstant("ANI_IDLE"));
}

void suicide()
{ // Suicide!!
    void self = getlocalvar("self");

    killentity(self); //Suicide!
}

void move(int dx, int dz, int da)
{ // Moves entity freely or ignores obstacles
    void self = getlocalvar("self");
    int x = getentityproperty(self,"x"); //Get character's x coordinate
    int z = getentityproperty(self,"z"); //Get character's z coordinate
    int a = getentityproperty(self,"a"); //Get character's a coordinate
    int dir = getentityproperty(self,"direction"); //Get character's facing direction

     if(dir==0){ // Facing left?
      changeentityproperty(self, "position", x-dx, z+dz, a+da); //Move
     }
     else if(dir==1){ // Facing right?
      changeentityproperty(self, "position", x+dx, z+dz, a+da); //Move
     }
}

void flip()
{// Flip to opposite direction
    void self = getlocalvar("self");
    int dir = getentityproperty(self,"direction");

    if(dir==0){ // Facing left?
      changeentityproperty(self, "direction", 1);
    } else {
      changeentityproperty(self, "direction", 0);
    }
}

void anichange(void Ani)
{ // Animation changer
    void self = getlocalvar("self");

    changeentityproperty(self, "animation", openborconstant(Ani)); //Change the animation
}

void looper(int Frame, int Limit)
{// Loops current animation
    void self = getlocalvar("self");
    void loop = getlocalvar("Loop" + self);

    if(loop==NULL()){ // Localvar empty?
      setlocalvar("Loop" + self, 0);
      loop = 0;
    } 
   
    if(loop < Limit){ // loops reach limit?
      updateframe(self, Frame); //Change frame
      setlocalvar("Loop" + self, loop+1); // Increment number of loops
    } else if(loop==Limit){ // loops reach limit?
      setlocalvar("Loop" + self, NULL());
    }
}

void degravity(int Ratio)
{// Changes antigravity effect
    void self = getlocalvar("self");
    changeentityproperty(self, "antigravity", Ratio);
}

void clearL()
{ // Clears all local variables
     clearlocalvar();
}

void dasher( float Vx, float Vy, float Vz, int Flip)
{// Dash with desired speed!
    void self = getlocalvar("self");
    int dir = getentityproperty(self,"direction");

    if(dir==0 && Flip==1){ // Facing left?
      Vx = -Vx ;
    }

    changeentityproperty(self, "velocity", Vx, Vz, Vy); //Move!
}

void leaper( float Vx, float Vy, int Flip)
{// Leap with desired speed!
    void self = getlocalvar("self");
    int dir = getentityproperty(self,"direction");

    if(dir==0 && Flip==1){ // Facing left?
      Vx = -Vx ;
    }

    tossentity(self, Vy, Vx); //Leap!
}

void stop()
{// Stop enemy's movement!
    void self = getlocalvar("self");
    changeentityproperty(self, "velocity", 0, 0, 0); //Stop moving!
}
spawn.h:
Code:
//Library scripts for spawning

void spawn01(void vName, float fX, float fY, float fZ)
{
	//spawn01 (Generic spawner)
	//Damon Vaughn Caskey
	//07/06/2007
	//
	//Spawns entity next to caller.
	//
	//vName: Model name of entity to be spawned in.
	//fX: X location adjustment.
	//fY: Y location adjustment.
      //fZ: Z location adjustment.

	void self = getlocalvar("self"); //Get calling entity.
	void vSpawn; //Spawn object.
	int  iDirection = getentityproperty(self, "direction");

	clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", vName); //Acquire spawn entity by name.

	if (iDirection == 0){ //Is entity facing left?                  
          fX = -fX; //Reverse X direction to match facing.
	}

      fX = fX + getentityproperty(self, "x"); //Get X location and add adjustment.
      fY = fY + getentityproperty(self, "a"); //Get Y location and add adjustment.
      fZ = fZ + getentityproperty(self, "z"); //Get Z location and add adjustment.
	
	vSpawn = spawn(); //Spawn in entity.

	changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
	changeentityproperty(vSpawn, "direction", iDirection); //Set direction.
    
	return vSpawn; //Return spawn.
}

void spawn02(void vName, float fX, float fY, float fZ)
{
	//Spawns entity based on left screen edge
	//
	//vName: Model name of entity to be spawned in.
	//fX: X distance relative to left edge
	//fY: Y height from ground
      //fZ: Z location adjustment

	void self = getlocalvar("self"); //Get calling entity.
	void vSpawn; //Spawn object.
        int XPos = openborvariant("xpos"); //Get screen edge's position

	clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", vName); //Acquire spawn entity by name.

      fZ = fZ + getentityproperty(self, "z"); //Get Z location and add adjustment.

	vSpawn = spawn(); //Spawn in entity.

	changeentityproperty(vSpawn, "position", fX + XPos, fZ, fY); //Set spawn location.
	return vSpawn; //Return spawn.
}

void spawner(void vName, float fX, float fY, float fZ)
{	//Spawns entity next to caller and set them as child.
	//
	//vName: Model name of entity to be spawned in.
	//fX: X location adjustment.
	//fY: Y location adjustment.
      //fZ: Z location adjustment.

	void self = getlocalvar("self"); //Get calling entity.
	void vSpawn; //Spawn object.
	
	vSpawn = spawn01(vName, fX, fY, fZ); //Spawn in entity.

	changeentityproperty(vSpawn, "parent", self); //Set caller as parent.
    
	return vSpawn; //Return spawn.
}

void spawner2(void vName, float fX, float fY, float fZ)
{//Spawns entity next to caller with same remap as spawner's.
	//
	//vName: Model name of entity to be spawned in.
	//fX: X location adjustment.
	//fY: Z location adjustment.
        //fZ: Y location adjustment.

	void self = getlocalvar("self"); //Get calling entity.
	void vSpawn; //Spawn object.
	int  iMap = getentityproperty(self, "map");
	
	vSpawn = spawn01(vName, fX, fY, fZ); //Spawn in entity.

	changeentityproperty(vSpawn, "map", iMap); //Use same remap as spawner's.
	return vSpawn; //Return spawn.
}

void spawner3(void vName, float fX, float fY, float fZ)
{//Spawns entity based on left screen edge and sets it ownership
	//
	//vName: Model name of entity to be spawned in.
	//fX: X location adjustment.
	//fY: Z location adjustment.
        //fZ: Y location adjustment.

	void self = getlocalvar("self"); //Get calling entity.
	void vSpawn; //Spawn object.
	int  iMap = getentityproperty(self, "map");
	
	vSpawn = spawn02(vName, fX, fY, fZ); //Spawn in entity

        changeentityproperty(vSpawn, "owner", self);
}

void shooter2(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);
   changeentityproperty(vShot, "velocity", Vx, 0, Vy);
   changeentityproperty(vShot, "owner", self);
   return vShot;
}

void tosser2(void Bomb, float dx, float dy, float Vx, float Vy)
{ // Tossing special bomb with desired speed
   void self = getlocalvar("self");
   int Direction = getentityproperty(self, "direction");
   void Shot;

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

   Shot = spawn01(Bomb, dx, dy, 0);
   tossentity(Shot, Vy, Vx);
   changeentityproperty(Shot, "owner", self);
   return Shot;
}

void shoot(void Shot, float dx, float dy, float dz)
{ // Shooting projectile
   void self = getlocalvar("self");
   int Direction = getentityproperty(self, "direction");
   int x = getentityproperty(self, "x");
   int y = getentityproperty(self, "a");
   int z = getentityproperty(self, "z");

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

   projectile(Shot, x+dx, z+dz, y+dy, Direction, 0, 0, 0);
}

void shooter(void Shot, float dx, float dy, float dz, float Vx, float Vy, float Vz)
{ // Shooting projectile with speed control
   void self = getlocalvar("self");
   int Direction = getentityproperty(self, "direction");
   int x = getentityproperty(self, "x");
   int y = getentityproperty(self, "a");
   int z = getentityproperty(self, "z");
   void vShot;

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

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

void toss(void Bomb, float dx, float dy, float dz)
{ // Tossing bomb
   void self = getlocalvar("self");
   int Direction = getentityproperty(self, "direction");
   int x = getentityproperty(self, "x");
   int y = getentityproperty(self, "a");
   int z = getentityproperty(self, "z");

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

   projectile(Bomb, x+dx, z+dz, y+dy, Direction, 0, 1, 0);
}

void tosser(void Bomb, float dx, float dy, float dz, float Vx, float Vy, float Vz)
{ // Tossing bomb with desired speed
   void self = getlocalvar("self");
   int Direction = getentityproperty(self, "direction");
   int x = getentityproperty(self, "x");
   int y = getentityproperty(self, "a");
   int z = getentityproperty(self, "z");
   void Shot;

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

   Shot = projectile(Bomb, x+dx, z+dz, y+dy, Direction, 0, 1, 0);
   tossentity(Shot, Vy, Vx, Vz);
   changeentityproperty(Shot, "speed", Vx); 
}

void tosserM(void Bomb, float dx, float dy, float Vx, float Vy)
{ // Tossing special bomb with speed control and same remap
   void self = getlocalvar("self");
   int  iMap = getentityproperty(self, "map");
   void vShot;

   vShot = tosser2(Bomb, dx, dy, Vx, Vy);
   changeentityproperty(vShot, "map", iMap);
}
and target.h:
Code:
//Library scripts for targetting

void target0(float Velx, float Vely, float Tx, float Ty, float dx, float dy, void Vel, int Flip)
{// Basic Targetting certain coordinate before dashing
// Velx = Desired x Velocity
// Vely = Desired y Velocity
// Tx = target x coordinate
// Ty = target y coordinate
// dx = x added distance
// dy = y added distance
// Vel = Desired output

    void self = getlocalvar("self");
    int dir = getentityproperty(self, "direction");
    float x = getentityproperty(self, "x");
    float y = getentityproperty(self, "a");
    float Vx;
    float Vy;

    if(Flip == 1){
      if(Tx < x){
        changeentityproperty(self, "direction", 0);
      } else {
        changeentityproperty(self, "direction", 1);
      }
    }

    x = x+dx;
    y = y+dy;
    float Disx = Tx - x;
    float Disy = Ty - y;

//Set both distance as positive value
    if(Disx < 0){
      Disx = -Disx;
    }

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

// Calculate velocity for targetting
    if(Disy < Disx)
    {
      if(Tx < x){
        Vx = -Velx;
      } else { Vx = Velx; }

      Vy = Velx*(Ty-y)/Disx;
    } else {
      if(Ty < y){
        Vy = -Vely;
      } else { Vy = Vely; }

      Vx = Vely*(Tx-x)/Disy;
    }

    if(Vel == "x"){
      return Vx;
    }
    if(Vel == "y"){
      return Vy;
    }
}

void target1(void Target, float Velx, float Vely, float dx, float dy, int Stop, void Vel, int Flip)
{// Targetting certain entity before dashing
// Target = Targetted entity
// Velx = Desired x Velocity
// Vely = Desired y Velocity
// dx = x added distance
// dy = y added distance
// Stop = flag to stop moving if there's no target

    void self = getlocalvar("self");
    int dir = getentityproperty(self, "direction");
    float x = getentityproperty(self, "x");
    float y = getentityproperty(self, "a");
    float Vx;
    float Vy;

    if (dir == 0){ //Is entity facing left?                  
      dx = -dx; //Reverse X direction to match facing
    }

    if( Target != NULL()){
      float Tx = getentityproperty(Target, "x");
      float Ty = getentityproperty(Target, "a");

      Vx = target0(Velx, Vely, Tx, Ty, dx, dy, "x", Flip);
      Vy = target0(Velx, Vely, Tx, Ty, dx, dy, "y", Flip);
    } else {
      if(Stop == 1)
      {
        Vy = 0;
        Vx = 0;
      } else {
        Vy = 0;
        if(dir==0){
          Vx = -Velx;
        } else { Vx = Velx; }
      }
    }

    if(Vel == "x"){
      return Vx;
    }
    if(Vel == "y"){
      return Vy;
    }
}

void target0T(float Time, float Tx, float Ty, float dx, float dy, void Vel, int Flip)
{// Basic Targetting certain coordinate before dashing
// Produced velocity will be required speed to get to target within specified time
// Time = specified time
// Tx = target x coordinate
// Ty = target y coordinate
// dx = x added distance
// dy = y added distance
// Vel = Desired output

    void self = getlocalvar("self");
    int dir = getentityproperty(self, "direction");
    float x = getentityproperty(self, "x");
    float y = getentityproperty(self, "a");
    float Vx;
    float Vy;

    if(Flip == 1){
      if(Tx < x){
        changeentityproperty(self, "direction", 0);
      } else {
        changeentityproperty(self, "direction", 1);
      }
    }

    x = x+dx;
    y = y+dy;
// Calculate velocity for targetting

    Vx = (Tx-x)/Time;
    Vy = (Ty-y)/Time;

    if(Vel == "x"){
      return Vx;
    }
    if(Vel == "y"){
      return Vy;
    }
}

void target1T(void Target, float Time, float dx, float dy, void Vel, int Flip)
{// Targetting certain entity before dashing
// Produced velocity will be required speed to get to target within specified time
// Target = Targetted entity
// Time = Specified time
// dx = x added distance
// dy = y added distance

    void self = getlocalvar("self");
    int dir = getentityproperty(self, "direction");
    float x = getentityproperty(self, "x");
    float y = getentityproperty(self, "a");
    float Vx;
    float Vy;

    if (dir == 0){ //Is entity facing left?                  
      dx = -dx; //Reverse X direction to match facing
    }

    if( Target != NULL()){
      float Tx = getentityproperty(Target, "x");
      float Ty = getentityproperty(Target, "a");

      Vx = target0T(Time, Tx, Ty, dx, dy, "x", Flip);
      Vy = target0T(Time, Tx, Ty, dx, dy, "y", Flip);
    } else {
      Vy = 0;
      Vx = 0;
    }

    if(Vel == "x"){
      return Vx;
    }
    if(Vel == "y"){
      return Vy;
    }
}

void target(float Velx, float Vely, float dx, float dy, int Stop, int Flip)
{// Targetting opponent before leaping or dashing.
// Velx = x Velocity
// Vely = y Velocity
// dx = x added distance
// dy = y added distance
// Stop = flag to stop moving if no target is found

    void self = getlocalvar("self");

    setlocalvar("T"+self, findtarget(self)); //Get nearest player

    void target = getlocalvar("T"+self);
    setlocalvar("x"+self, target1(target, Velx, Vely, dx, dy, Stop, "x", Flip) );
    setlocalvar("y"+self, target1(target, Velx, Vely, dx, dy, Stop, "y", Flip) );
    setlocalvar("T"+self, NULL()); //Clears variable
}

void targetT(float Time, float dx, float dy, int Flip)
{// Targetting opponent before leaping or dashing.
// Time = specified time
// dx = x added distance
// dy = y added distance

    void self = getlocalvar("self");

    setlocalvar("T"+self, findtarget(self)); //Get nearest player

    void target = getlocalvar("T"+self);
    setlocalvar("x"+self, target1T(target, Time, dx, dy, "x", Flip) );
    setlocalvar("y"+self, target1T(target, Time, dx, dy, "y", Flip) );
    setlocalvar("T"+self, NULL()); //Clears variable
}

void targetB(float Time, float dx, float dy, int Flip)
{// Targetting opponent before tossing bomb
// Time = specified time
// dx = x added distance
// dy = y added distance
// Flip = flip flag

    void self = getlocalvar("self");
    int dir = getentityproperty(self, "direction");
    float x = getentityproperty(self, "x");
    float y = getentityproperty(self, "a");
    float Vx;

    setlocalvar("T"+self, findtarget(self)); //Get nearest target
    void Target = getlocalvar("T"+self);

    if( Target != NULL()){
      float Tx = getentityproperty(Target, "x");
      float Ty = getentityproperty(Target, "a");
      float C;
      float Sy = y + dy - Ty;

      if (Sy < 0){ //Negative?
        Sy = -Sy; //Invert to positive
      }

      C = 0.5*(x-Tx)*(y+dy-Ty)/(Time+Sy);

      if (dir == 0){ //Is entity facing left?                  
        dx = -dx; //Reverse X direction to match facing
      }

      Vx = target0T(Time, Tx, Ty, dx-C, 0, "x", Flip);

    } else {
      Vx = 0;
    }

    setlocalvar("x"+self, Vx );
    setlocalvar("T"+self, NULL()); //Clears variable
}

void dash(int X, int Y)
{// Dash with previously attained speed!
    void self = getlocalvar("self");
    float Vx = getlocalvar("x"+self);
    float Vy = getlocalvar("y"+self);

    if( X==1 ){
      Vy = 0;
    } else if( Y==1 ){
      Vx = 0;
    }

    changeentityproperty(self, "velocity", Vx, 0, Vy);
}

void leap(float Vely)
{// Leap with previously attained speed!
    void self = getlocalvar("self");
    float Vx = getlocalvar("x"+self);
    if( Vx!=NULL() ){
      tossentity(self, Vely, Vx); //Leap towards target!
    }
}

void shoot2(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 = shooter2(Shot, dx, dy, Vx, Vy);
     changeentityproperty(vShot, "velocity", Vx, 0, 2*Vy); //Move projectile towards target!
   }
}

void toss2(void Shot, float dx, float dy, float Vy)
{ // Tossing targetted bombs
   void self = getlocalvar("self");
   float Vx = getlocalvar("x"+self);
   int Direction = getentityproperty(self, "direction");

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

   if( Vx!=NULL() && Vy!=NULL() ){
     tosser2(Shot, dx, dy, Vx, Vy);
   }
}
Do you know where is the script conflict?
Here is the actual demo:
https://drive.google.com/open?id=15x9Qe9tiBtSJTeW2A7kEqK_CiVH24qbY

@maxman: ducking and duckrise will be useful for me as crouchhit, crouchblock if I can integer them.
 
Here is the 0.2 version:
https://drive.google.com/open?id=1x0U7aB3uYy_U4SPfwObmyf7_nTLuloWs
What's new?
- 13 oufits, 11 colours
- New Tournament Mode
- Custom Lifebar wip
Next to come:
- More non fighting animations to make characters more lively
- 3 Bonus stages integrated to tournament
- Story mode
- A total of 10 Weapons:
2s0xw84.jpg
 
Looks cool, but something got my attention - the way the animations are aligned.
Take a look:
2s0xw84.jpg


Notice that just the lower part is moving up and down, but not the upper part. Also, his head stands still, like it was the anchor point of the animation - which looks very strange.
It would be better if you move the upper area (and the head) too.
 
@John_Kuey: Thanks, that's good to read and keeps me motivated  ;)
@O Ilusionista: Is it better like this?
15hlc0m.jpg
2jdj3nk.jpg
 
Here are the 10 weapons in the game:
9a0mr9.jpg

In order: tonfa, nunchaku, yumi, shuriken, kusarigama, tanto, ken, jo, naginata and yari.
I will add them when the bare hand fight runs smoothly (need help with jump attack).
 
wow, nice!
But how different some weapons are from each other? For example, naginata and yari?
Both are medium ranged cutting weapons.
 
I will implement a custom mp bar (as soon as I know how to script it) for releasing a special punch combo (weapon replaces punch) and a special kick combo:
16lljde.jpg

I don't know if it's possible that custom hp and mp image can have the palette character.
As you mention, naginata will have one big slash and yari multi hits.
 
Another way to make custom HUD is by using entities to display the HUD. One entity for each player. When respective player is active, the HUD entity reveals itself but if player isn't active, the entity hides

By using HUD entity, you can use alternate palettes to match respective player's palette
 
Thanks Bloodbane for your suggestion, your HUD script system is exactly what I needed for HP and MP bar :).
I know that DC have tried to make an accessory system, I'd like later add a wandering merchant where we can choose one accessory after having selected player:
122hvn6.jpg
sws7k1.jpg

I hope this is not something difficult to code as all players and enemies can benefit on it.
I'm open to all suggestion, I'm trying to make something original :)
 
DC, I made a mistake about the diagonals. I realized he wanted it with special key button. I should've input a special key button long ago for showing you.

OK. I just modified DC's diagonal script by adding a special key for it. I found out "void direction;" under dc_check_key_forward was missing which I believe DC missed putting it. I edited it so it wouldn't crash. This should work. But I made this one for memory sake.

diagonal.c:

Code:
#import "data/scripts/diagonal_actual.c"

void main(){
    actual_main();
}

diagonal_actual.c:

Code:
void actual_main()
{
    void target;        // Target entity for action.
    int player_index;   // Player index triggering event.
	int special_press;	// Special key press for action
       
    // Key status.
    int key_hold;
    int key_forward;
   
    // Get the player index and target entity.
    player_index    = getlocalvar("player");
    target          = getplayerproperty(player_index, "entity");   
	special_press	= playerkeys(player_index, 1, "special");
   
    // Get key hold status.
    key_hold    = getplayerproperty(player_index, "keys");   
   
    // Holding the down key?
    if(key_hold & openborconstant("FLAG_MOVEDOWN"))
    {
        // Check to see if current hold key has a forward match.
        key_forward = dc_check_key_forward(key_hold, target);
   
        if(key_forward)
        {
			if(special_press){
				performattack(target, openborconstant("ANI_FOLLOW1"));
			}
        }
    }
}
       
// Caskey, Damon V.
// 2018-08-13
//
// Return true if key status includes a "forward"
// direction key in relation to target entity facing.
int dc_check_key_forward(int key_status, void target)
{
    int result;
    void direction;
   
    // Default false.
    result = 0;
   
    // Which direction are we facing?
    direction = getentityproperty(target, "direction");
   
    // Facing right?
    if(direction == openborconstant("DIRECTION_RIGHT"))
    {
        // Does the current key status contain a match
        // to the right direction key? If so result is true.
        if(key_status & openborconstant("FLAG_MOVERIGHT"))
        {
            result = 1;
        }       
    }
    else
    {
        // Same as above, but for left.
        if(key_status & openborconstant("FLAG_MOVELEFT"))
        {
            result = 1;
        }
    }
   
    return result;
}

You can put that script in your player header.

Code:
name		 karate
type		 player
health		 80
mp		 100
mprate		 5
speed		 15
running		 30 3 2 1 1
cantgrab	 1
jumpmove	 2
jumpheight	 3
noquake		 1
bounce		 0
backpain 	 1
backfall 	 1
backrise         1
death		 1
nodieblink	 2
icon		 data/chars/karate/icon.gif 1
antigravity	 20
makeinv		 3 0
gfxshadow	 1

animationscript	 data/scripts/player.c
script		 data/scripts/diagonal.c

atchain		 1 

##REMAPS
alternatepal  data/chars/karate/alt1.gif
alternatepal  data/chars/karate/alt2.gif
alternatepal  data/chars/karate/alt3.gif
alternatepal  data/chars/karate/alt4.gif
alternatepal  data/chars/karate/alt5.gif
alternatepal  data/chars/karate/alt6.gif
alternatepal  data/chars/karate/alt7.gif
alternatepal  data/chars/karate/alt8.gif
alternatepal  data/chars/karate/alt9.gif
alternatepal  data/chars/karate/alt10.gif

com	a2	freespecial
com     a3      freespecial6

DC, you can correct me if I'm wrong.

@kimono: You can replace that anim slide with anim follow1 so you wouldn't have to press to slide.
 
@maxman: Thanks for this script, I will see how I can integer it.
The time has come for the 0.3 demo!
https://drive.google.com/open?id=1s_obUHVUvy9Xe6W5vrx9JutND65hi6J6

What's new?
- 1 new colour, alternate colour 6 revised, 3 news outfits: shinobi, kurash and shuai
333hehi.jpg

- New gameplay: jump and roll with directional keys (thanks Bloodbane)
muis2b.jpg

- New custom hp and mp bar (thanks Bloodbane again!)
- Added some animations like backhit, backfall, backrise, ducking, duckrise, turn, punch combo and kick combo
- Some anims were corrected: new idle (thanks O'Ilusionista for the suggestion), front jump punch and kick,
punch and kick combo (Thanks magggas for your patience!)
- Electrising musics composed by Derek and Brandon Fiechter on each stage can be heard
Next to come:
- Some guest characters like Caine, Chuck, Kareem, Jean, and more!
(Jean is inspired by the french movie "Les Bronzés")
2a62k5e.jpg
23lcl4y.jpg

- Masters will show who lead and comment the result of the match
125q0is.jpg

- 3 bonus will break the repetitive pattern (after battle 3, 6 and 9 of 10)
- roll kick and punch will be added, crouchhit, backcrouchhit, crouchturn, crouchturn...

Comments are welcome :)
 
Back
Top Bottom