keyint function imput help

NED

Well-known member
Hi,
I have few problem making keyint working.

I use it for a chain throws system.

To avoid consuming freespecials, I use keyint to cancel to follow anims

This is the part(frame) where cancel should occur:

Code:
#-----------------------CANCEL FROM HERE
	delay	9#8
@cmd    keyint "ANI_FOLLOW43" 0 "A" 0 0#{animation} {frame} {key} {hold0/release1} {minhealth}-----Cancel to arm lock
	frame	data/chars/rachel/swingneck11.gif
#-----------------------CANCEL FROM HERE


But is there a way to make it working with just a normal "hit button imput" ? (instead of hold... or release)
Any help is welcome

Thanks



The actual keyint script I used
I edited it a bit with my low skills to allow other buttons imputs A3, A4...

Code:
void keyint(void Ani, int Frame, void Key, int Hflag, int Limit)
{// Change current animation if proper key is pressed or released provided HP is more than limit (J'ai ajouté A3 et A4 dispo)
    void self = getlocalvar("self");
    void Health = getentityproperty(self,"health");    
    int iPIndex = getentityproperty(self,"playerindex"); //Get player index
    void iRKey;

      if (Key=="U"){ //Up Required?
       iRKey = playerkeys(iPIndex, 0, "moveup"); // "Up"
	}

      if (Key=="D"){ //Down Required?
        iRKey = playerkeys(iPIndex, 0, "movedown"); // "Down"
	}

      if (Key=="J"){ //Jump Required?
        iRKey = playerkeys(iPIndex, 0, "jump"); // "Jump"
	}

      if (Key=="A"){ //Attack Required?
        iRKey = playerkeys(iPIndex, 0, "attack"); // "Attack"
	}

      if (Key=="S"){ //Special Required?
        iRKey = playerkeys(iPIndex, 0, "special"); // "Special"
	}

      if (Key=="A2"){ //Attack2 Required?
        iRKey = playerkeys(iPIndex, 0, "attack2"); // "Attack2"
	}

      if (Key=="A3"){ //Attack3 Required?
        iRKey = playerkeys(iPIndex, 0, "attack3"); // "Attack3"
	}

      if (Key=="A4"){ //Attack4 Required?
        iRKey = playerkeys(iPIndex, 0, "attack4"); // "Attack4"
	}

      if (Key=="UJ"){ //Up and Jump Required?
        iRKey = playerkeys(iPIndex, 0, "moveup", "jump"); // "Up" + "Jump"
	}

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

      if ((Health > Limit)&&iRKey){
        changeentityproperty(self, "animation", openborconstant(Ani)); //Change the animation
        changeentityproperty(self, "animpos", Frame);

        if (Key=="UJ"){ 
          // This is copy of dethrown
          changeentityproperty(self, "attacking", 0);
          changeentityproperty(self, "damage_on_landing", 0);
          changeentityproperty(self, "projectile", 0);
        }
      }
}
 
Short answer is no, you can't process new key press with a function such as keyint.

keyint is used in animationscript, which means it is triggered on each frame change (of a certain animation), which means it can't register new key press that happen while frame is not changing.

To create a custom cancel system you need to make use of one of the keyscript (e.g. keyall.c).
 
To start getting the hang of it, you can just write all the logic in keyall.c.

Code:
if(characterName == "thenameyouwant"){
  if(animationID == openborconstant("ANI_freespecialX")){
    if(newAttack1Press && currentFrame > Y){
      performattack(self, openborconstant("ANI_followX"));
    }
  }
}

In my mod I have a fully-fledged custom cancel system, so it might be a bit complex.

Here's how it works :

- cancel options and parameters are defined on animation basis (via inline @script blabla @end_script in entity model file) and stored as entityvar = cancelData
- in keyall, an abstract script checks if the current input match one of the cancelData entry
- if it does and the current frame is greater than or equal to the "start switch" frame and lower than the "end switch" frame then it switches to corresponding animation from here
- if current frame is not "start switch" frame yet, then the input will still be registered and the switch will occur via animationscript, more precisely when current frame will reach "start switch" frame. This allow input flexibility and buffering.

I might share & post some kind of tutorial about this "method" some day, that is if anyone is interested.
 
Thanks Piccolo,
This is where I see my limitations in understanding coding.
Anyway, this is helpful so I take it and try to apply it (à tête reposée)

If you go for a tutorial later, it would be a good thing.

Thanks again
 
This is old, but it might be a good reference for coding this.

Code:
// Script for using 4 attack buttons.

void main(){

	// get variables ready
	int player = getlocalvar("player");
	void self = getplayerproperty(player, "ent");
	int anim = getentityproperty(self, "animationid");
	float a = getentityproperty(self, "a");
	float base = getentityproperty(self, "base");
	
	if(playerkeys(player, 1, "movedown") || playerkeys(player, 1, "moveleft") || playerkeys(player, 1, "moveup") || playerkeys(player, 1, "moveright"))
	{
		setindexedvar(player, openborvariant("elapsed_time"));
	}
	if((anim == openborconstant("ANI_IDLE") || anim == openborconstant("ANI_WALK") || anim == openborconstant("ANI_RUN")) && a == base  && (openborvariant("elapsed_time") - getindexedvar(player) >= 25 || !getindexedvar(player)))
	{
		if(playerkeys(player, 1, "attack2"))
		{
			changeentityproperty(self, "aiflag", "attacking", 1);
			changeentityproperty(self, "aiflag", "idling", 0);
			changeentityproperty(self, "takeaction", "common_attack_proc");
			changeentityproperty(self, "animation", openborconstant("ANI_ATTACK2"), 1);
			changeentityproperty(self, "velocity", 0, 0, 0);
		}
		if(playerkeys(player, 1, "attack3"))
		{
			changeentityproperty(self, "aiflag", "attacking", 1);
			changeentityproperty(self, "aiflag", "idling", 0);
			changeentityproperty(self, "takeaction", "common_attack_proc");
			changeentityproperty(self, "animation", openborconstant("ANI_ATTACK3"), 1);
			changeentityproperty(self, "velocity", 0, 0, 0);
		}
		if(playerkeys(player, 1, "attack4"))
		{
			changeentityproperty(self, "aiflag", "attacking", 1);
			changeentityproperty(self, "aiflag", "idling", 0);
			changeentityproperty(self, "takeaction", "common_attack_proc");
			changeentityproperty(self, "animation", openborconstant("ANI_ATTACK4"), 1);
			changeentityproperty(self, "velocity", 0, 0, 0);
		}
	}
	if(anim == openborconstant("ANI_JUMP"))
	{
		if(playerkeys(player, 1, "attack2"))
		{
			changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW9"), 1);
		}
		else if(playerkeys(player, 1, "attack3"))
		{
			changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW10"), 1);
		}
		else if(playerkeys(player, 1, "attack4"))
		{
			changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW11"), 1);
		}
	}
	if(anim == openborconstant("ANI_FORWARDJUMP"))
	{
		if(playerkeys(player, 1, "attack2"))
		{
			changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW12"), 1);
		}
		else if(playerkeys(player, 1, "attack3"))
		{
			changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW13"), 1);
		}
		else if(playerkeys(player, 1, "attack4"))
		{
			changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW14"), 1);
		}
	}
}
 
Back
Top Bottom