How to make Combos for enemies

DFGHTENNIS

New member
Hey everyone

I'm using cancel in order to make different combo opportunities for player, but is there any similar ways for enemies? i want enemies to be able to perform at least 2 different combo chains.

Thanks in advance
 
DFGHTENNIS said:

The AI ignores Cancel, so without script you are confined to giving it canned combos. You can add some range settings that will change things up a little, but ultimately when X happens you'll always get Y.

If you are willing to look into scripted animation switching (which happens to be one of the simplest script methods) and attach that to a random % chance of your choice, then you can have the AI really mix things up like a human player.

DC
 
Currently, what I'm doing for that is create an array containing the following animations identifers on the first frame of each comboable animation.

Code:
anim attack1 # LP
	@script
	if(frame == 0){
		void data = createNPCCancelData(3);
		set(data, 0, "ANI_attack1");
		set(data, 1, "ANI_attack2");
		set(data, 2, "ANI_attack3");
		setentityvar(getlocalvar("self"), "cancelData", data);
	}
	@end_script
	delay 5
	offset 100 100
	frame data/chars/...

Then when animation reaches a certain frame I call a continueCombo method which randomly pick one of the array entry and change entity animation to the matching animation identifier.

Then you can set additional flags with the usage of didhitscript so that the combo continues only if hit, or hit and not blocked, etc.
 
Thanks a lot guys. the problem is that i'm not in to writing scripts at all. yeah i've read through script tutorials but i don't know where to start? how should i write a script without messing things up!?
 
Then you need to at least understand how animationscript works and start with simple behavior.

For example you can put this function in enemy animationscript :

Code:
void startSecondAttack(){

	void vEnt = getlocalvar("self");
	void aniID = openborconstant("ANI_attack2");
	performattack(vEnt, aniID, 1);
	
}

When called, it makes entity switch to attack2 animation.

Thus you need to call this function in a proper place, for example at the end of attack1 animation, in entity's model file.

Code:
anim attack1 # Light punch
	bbox	35 4 89 161
	delay 3
	offset 83 159
	frame data/chars/name/189.gif
	frame data/chars/name/190.gif
	frame data/chars/name/191.gif
	delay 5
	attack	142 72 60 30 4 0 0 0 3 0
	frame data/chars/name/192.gif
	delay 4
	attack 0
	frame data/chars/name/193.gif
	@cmd startSecondAttack
	frame data/chars/name/194.gif

With this, entity will always initiate attack2 at the end of attack1.
When you have understood how this simple script works, you can start adding more parameters to create a more complex behavior.
 
@ DFGHTENNIS: If you want less script method, you can use followup system like this:

anim attack1
range 15 115
delay 1
offset 120 97
followanim 1
followcond 3
bbox 102 36 36 61
frame data/chars/machao/idle1.png
delay 8
hitfx data/sounds/Slash1.wav
frame data/chars/machao/slash1.png
delay 15
frame data/chars/machao/slash2.png
delay 4
attack 134 8 90 106 20 0 0 0 20
frame data/chars/machao/slash3.png
frame data/chars/machao/slash4.png
attack 0
frame data/chars/machao/slash5.png
frame data/chars/machao/slash6.png
frame data/chars/machao/slash7.png
delay 25
frame data/chars/machao/slash5.png

anim follow1
delay 4
followanim 2
followcond 3
offset 120 97
bbox 102 36 36 61
hitfx data/sounds/Slash1.wav
frame data/chars/machao/slash4.png
@cmd dasher 0 0 0
frame data/chars/machao/slash5.png
frame data/chars/machao/slash6.png
frame data/chars/machao/slash7.png
delay 15
frame data/chars/machao/Bslash1.png
delay 6
attack 150 15 90 70 20 0 0 0 20
frame data/chars/machao/Bslash2.png
frame data/chars/machao/Bslash3.png
attack 0
frame data/chars/machao/Bslash4.png
frame data/chars/machao/Bslash5.png
delay 25
frame data/chars/machao/Bslash6.png

anim follow2
delay 6
offset 120 97
bbox 102 36 36 61
hitfx data/sounds/Slash1.wav
frame data/chars/machao/Bslash3.png
frame data/chars/machao/Bslash4.png
frame data/chars/machao/Bslash5.png
delay 10
frame data/chars/machao/Bslash6.png
delay 12
frame data/chars/machao/Pslash1.png
delay 6
frame data/chars/machao/Pslash2.png
attack 180 5 90 104 20 1 0 0 20
dropv 2 4 0
frame data/chars/machao/Pslash3.png
frame data/chars/machao/Pslash4.png
attack 0
frame data/chars/machao/Pslash5.png
frame data/chars/machao/Pslash6.png
frame data/chars/machao/Pslash7.png
delay 12
frame data/chars/machao/Pslash8.png
frame data/chars/machao/Pslash9.png

In this example, Ma Chao (enemy that is) performs ATTACK1 animation if player is within 15 to 115 pixels range in front of him. If ATTACK1 connects, he will followup to FOLLOW1 otherwise he just plays the former to end. In FOLLOW1 there's similar followup setting which followups to FOLLOW2

Now, if you want randomness you need to use script like this:

anim attack1
@script
    if(frame == 0){
      void self = getlocalvar("self");
      int r = rand()%30;

      if(r > 0){
        changeentityproperty(self, "animation", openborconstant("ANI_ATTACK2"));
      }
    }
@end_script
...

When ATTACK1 is performed, there's 50% chance it will change to ATTACK2. You can declare this script in FOLLOW animation too to set alternate combo ;)
 
Back
Top Bottom