Daimao Cancel System

Daimao Cancel System 1.0

No permission to download

Piccolo

Well-known member
Daimao Cancel is an advanced cancel system for creating combos that works for all types of entities (player, enemy, npc) and attacks (normal attacks, projectiles, slams). It was built to create The Bruiser Brigade gameplay and overcome some limitations of the core cancel system.
 
Last edited by a moderator:
Thanks Piccolo for the tutorial but there is one problem. I tried your script but it crashes.

Here is the log:
Code:
Total Ram: 4168376320 Bytes
 Free Ram: 310702080 Bytes
 Used Ram: 3063808 Bytes

debug:nativeWidth, nativeHeight, bpp  1366, 768, 32

0 joystick(s) found!
OpenBoR v3.0 Build 3967, Compile Date: Jul 17 2013

Game Selected: ./Paks/mybor.pak

FileCaching System Init......	Disabled
Initializing video............
Reading video settings from 'data/video.txt'.
Initialized video.............	480x272 (Mode: 1, Depth: 32 Bit)

Loading menu.txt.............	Done!
Loading fonts................	1 2 3 4 7 Done!
Timer init...................	Done!
Initialize Sound..............	
Loading sprites..............	Done!
Loading level order..........	Done!
Loading model constants......	Done!
Loading script settings......	Done!
Loading scripts..............	Done!
Loading models...............

Cacheing 'Flash' from data/chars/misc/flash.txt
Cacheing 'VF' from data/sprites/VF.txt
Cacheing 'Billy' from data/chars/billy/billy.txt
Cacheing 'Jimmy' from data/chars/jimmy/jimmy.txt
Cacheing 'Lynn' from data/chars/lynn/lynn.txt
Cacheing 'Ren' from data/chars/renidagawa/renidagawa.txt
Cacheing 'Mpack' from data/chars/misc/mpack.txt
Cacheing '1up' from data/chars/misc/1up.txt
Cacheing 'hamburger' from data/chars/misc/hambur.txt
Cacheing 'Money' from data/chars/misc/money.txt
Cacheing 'Meat' from data/chars/misc/meat.txt
Cacheing 'Knife' from data/chars/misc/knife.txt
Cacheing 'Box' from data/chars/misc/box.txt
Cacheing 'Buntaro' from data/chars/buntaro/buntaro.txt
Cacheing 'Shintaro' from data/chars/shintaro/shintaro.txt
Cacheing 'Jack' from data/chars/jack/jack.txt
Cacheing 'Chinnen' from data/chars/chinnen/chinnen.txt
Cacheing 'Olof' from data/chars/olof/olof.txt
Cacheing 'Flogger' from data/chars/flogger/flogger.txt
Cacheing 'Empty' from data/chars/misc/empty.txt
Cacheing 'Wong' from data/chars/cheng/cheng.txt
Cacheing 'Kulio' from data/chars/yun/yun.txt
Cacheing 'Dingo' from data/chars/dingo/dingo.txt
Cacheing 'Iggy' from data/chars/iggy/iggy.txt
Cacheing 'Eagle' from data/chars/eagle/eagle.txt
Cacheing 'Duck' from data/chars/duck/duck.txt
Cacheing 'Abubo' from data/chars/abubo/abubo.txt
Cacheing 'Burnov' from data/chars/burnov/burnov.txt
Cacheing 'Sonia' from Data/Chars/Sonia/Sonia.txt
Cacheing 'Sonia2' from Data/chars/Sonia/Sonia2.txt
Cacheing 'Captain_Commando' from Data/chars/capcom/CapCom.txt
Cacheing 'Baby_Head' from Data/chars/BabyCommando/babyhead.txt
Cacheing 'cvsryu' from data/chars/cvsryu/cvsryu.txt
Cacheing 'Shadow_Stg3' from data/chars/misc/shdwstg3.txt
Cacheing 'Eliza' from data/chars/Eliza/Eliza.txt
Cacheing 'Ralf' from data/chars/ralf/ralf.txt
Cacheing 'Kula' from data/chars/kula/kula.txt
Cacheing 'Lesus' from data/chars/lesus/lesus.txt
Cacheing 'Gale' from data/chars/lesus/lesus2.txt
Cacheing 'Thunder' from data/chars/lesus/lesus3.txt
Cacheing 'Petir' from data/chars/lesus/lesuss.txt
Cacheing 'Bao' from data/chars/bao/bao.txt
Cacheing 'Maxima' from data/chars/maxima/maxima.txt
Cacheing 'Athena' from data/chars/athena/athena.txt
Cacheing 'zedd' from data/chars/zedd/zedd.txt
Cacheing 'fadeoutwhite' from data/chars/misc/fade/fadeoutwhite.txt
Cacheing 'idlezedd1' from data/chars/misc/idlezedd1.txt
Cacheing 'idlezedd2' from data/chars/misc/idlezedd2.txt
Cacheing 'lightning' from data/chars/misc/lightning/lightning.txt
Cacheing 'Jimmy-E' from data/chars/jimmy/jimmye.txt
Cacheing 'EMPTY_WEAP' from data/chars/misc/empty_weap.txt
Cacheing 'endlevel_empty' from data/chars/misc/endlevel_empty.txt
Cacheing 'lenny' from data/chars/lenny/lenny.txt
Cacheing '1spawn' from data/chars/misc/1spawn.txt
Cacheing 'wsample' from Data/chars/Misc/wsample.txt
Cacheing 'wsample2' from data/chars/misc/wsample2.txt
Cacheing 'wsample1' from data/chars/misc/wsample1.txt
Cacheing 'wsample3' from data/chars/misc/wsample3.txt
Cacheing 'fronside' from data/chars/misc/fronside.txt
Cacheing 'wsample4' from data/chars/misc/wsample4.txt
Cacheing 'wsample5' from data/chars/misc/wsample5.txt
Cacheing 'wsample6' from data/chars/misc/wsample6.txt
Cacheing 'sideway' from data/chars/misc/sideway.txt
Cacheing 'halfplat' from data/chars/misc/halfplat.txt
Cacheing 'plat1' from data/chars/misc/plat1.txt
Cacheing '25plat' from data/chars/misc/25plat.txt
Cacheing 'plathalf' from data/chars/misc/plathalf.txt
Cacheing 'plata' from Data/chars/Misc/plata/plata.txt
Cacheing 'hplat1' from data/chars/misc/plata/hplat1.txt
Cacheing 'hplat2' from data/chars/misc/plata/hplat2.txt

Loading 'Flash' from data/chars/misc/flash.txt
Loading 'VF' from data/sprites/VF.txt
Script compile error: can't find function 'createDaimaoCancel'

Script compile error in 'animationscript': createDaimaoCancel line 9, column 24

********** An Error Occurred **********
*            Shutting Down            *

Can't compile script 'animationscript' data/chars/billy/billy.txt
Total Ram: 4168376320 Bytes
 Free Ram: 296656896 Bytes
 Used Ram: 14340096 Bytes

Release level data...........	Done!
Release graphics data........	Done!
Release game data............


Release game data............	Done!
Release timer................	Done!
Release input hardware.......	Done!
Release sound system.........	Done!
Release FileCaching System...	Done!

**************** Done *****************

Can't compile script 'animationscript' data/chars/billy/billy.txt

I dunno what version I can use to make it work. I tried version 4153 and I can't start the game(s) except dantedevil's Mortal Kombat: The Chosen One mod.

I tested one of my chars (though I keep it on-hold).
Code:
name	Billy #name {name}
type	player #type {type}
gfxshadow 1 #gfxshadow {bi}
health	100 #health {int}
speed	10 #speed {int}
running	19 4 2 1 1 #running {speed} {height} {length} {move} {land}
turndelay  1  #turndelay {int}
atchain	1 2 3 #atchain {number} {number} {number} {number} {number} ......
combostyle 1 #combostyle {bool} bool 0 (default); old chain system; max attacks: 5... bool 1; new chain system; max attacks: 12
mp         100 #mp {value}
holdblock 1 #holdblock {bi}
palette	data/chars/billy/cvsmap.png #palette {path}
alternatepal data/chars/billy/idle01.png #alternatepal {path}
projectilehit enemy
jumpmove 2 2 #jumpmove {fx} {fz}
jumpheight 8
com d f a freespecial #com {direction} {direction}..... {action} {freespecial#}
com d b a freespecial2
animationscript data/scripts/script.c
com a2 freespecial3

Code:
anim	attack1
	@script
		if(frame == 0){
			void data = createDaimaoCancel();

			set(data, "switchFrame", 3);

			addCancel(data, "a1", "ANI_attack2");
			addCancel(data, "F a1", "ANI_attack4");
			addCancel(data, "a2", "ANI_FREESPECIAL3");

		} else daimaoCancel();
	@end_script
	bbox	145 98 32 107
	offset	162 202
	delay	6
	frame	data/chars/billy/82.png
	frame	data/chars/billy/83.png
	attack	187 110 40 18 9 0 1 0 0 0
	bbox	149 98 36 107
	frame	data/chars/billy/84.png
	attack	0 0 0 0 0 0 0 0 0 0
	bbox	145 98 32 107
	frame	data/chars/billy/85.png

anim	attack2
	@script
		if(frame == 0){
			void data = createDaimaoCancel();

			set(data, "switchFrame", 3);

			addCancel(data, "a1", "ANI_attack3");
			addCancel(data, "a2", "ANI_freespecial3");

		} else daimaoCancel();
	@end_script
	bbox	147 98 31 106
	offset	162 202
	delay	6
	frame	data/chars/billy/78.png
	frame	data/chars/billy/79.png
	attack	180 103 23 20 5 0 1 0 0 0
	bbox	153 99 32 106
	frame	data/chars/billy/80.png
	attack	0 0 0 0 0 0 0 0 0 0
	bbox	143 99 39 106
	frame	data/chars/billy/81.png

anim	attack3
	bbox	135 98 45 106
	offset	162 202
	delay	6
	frame	data/chars/billy/96.png
	bbox	125 100 50 105
	frame	data/chars/billy/97.png
	frame	data/chars/billy/98.png
	bbox	143 104 41 101
	frame	data/chars/billy/99.png
	bbox	143 107 41 97
	frame	data/chars/billy/100.png
	attack	185 123 52 37 10 0 1 0 0 0
	bbox	150 115 42 89
	frame	data/chars/billy/101.png
	bbox	153 119 47 85
	frame	data/chars/billy/102.png
	bbox	167 126 37 78
	attack	0 0 0 0 0 0 0 0 0 0
	frame	data/chars/billy/103.png
	bbox	169 129 37 75
	frame	data/chars/billy/104.png
	frame	data/chars/billy/105.png
	bbox	150 116 46 88
	frame	data/chars/billy/106.png
	bbox	142 107 52 97
	frame	data/chars/billy/107.png
	bbox	137 103 53 100
	frame	data/chars/billy/108.png

anim	attack4
	bbox	143 101 43 104
	offset	162 202
	delay	6
	frame	data/chars/billy/86.png
	bbox	143 106 43 99
	frame	data/chars/billy/87.png
	attack	180 123 35 26 5 0 1 0 0 0
	bbox	140 106 50 99
	frame	data/chars/billy/88.png
	frame	data/chars/billy/89.png
	attack	0 0 0 0 0 0 0 0 0 0
	frame	data/chars/billy/90.png
	frame	data/chars/billy/91.png
	attack	170 105 48 23 10 0 0 0 0 0
	bbox	134 101 54 104
	frame	data/chars/billy/92.png
	frame	data/chars/billy/93.png
	frame	data/chars/billy/94.png
	attack	0 0 0 0 0 0 0 0 0 0
	frame	data/chars/billy/95.png
 
Ok, I see your character animationscript is "data/scripts/script.c".

Did you add this line :

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

at the top of this file ?

Or you could try with an include

Code:
#include "data/scripts/dcancel.c"


From the log, I don't think it's an engine version problem.
 
I admit that I added #include "data/scripts/anim/direction.c" in script.c which caused the crash.

I just added one of them at the very top of script.c and both of them work well. :) Thanks, Piccolo! ;D It doesn't cause a crash anymore after you explained/asked.
 
Advanced Usage 1 : Global Cancel

What is a global cancel ? A global cancel is a cancel option that is not linked to a specific animation. For example, in the Bruiser Brigade, break moves are global cancel options : you can use them from any animation. More simply said, global cancel is used for special moves. So if you're creating Ryu from Street Fighter, you might add Hadoken and Shoryuken as global cancel options for this character.

As the DCS creates more powerful cancel options than the built-in cancel system, global cancel is a more powerful alternative to the built-in "com" command.

A good place to declare global cancel option is entity spawn script. Here's an example.

Code:
onspawnscript @script
	#import "data/scripts/dcancel.c"
	void main(){
		
		addGlobalCancel("D F a1", "ANI_freespecial1"); // Hado-Ken
		addGlobalCancel("Air D F a1", "ANI_freespecial2"); // Air Hado-Ken

		addGlobalCancel("HB F a1", "ANI_freespecial3"); // Sonic Boom !
		addGlobalCancel("HB F B F a1", "ANI_freespecial4"); // SONIC HURRICANE !
	
	}

@end_script

As you can note from this example, the system supports additional flags from the core system.

"HB" => Hold Back for 150cs
"HD" => Hold Down for 150cs
"Air" => Character must be in air to use that cancel option
 
Piccolo said:
Advanced Usage 1 : Global Cancel

What is a global cancel ? A global cancel is a cancel option that is not linked to a specific animation. For example, in the Bruiser Brigade, break moves are global cancel options : you can use them from any animation. More simply said, global cancel is used for special moves. So if you're creating Ryu from Street Fighter, you might add Hadoken and Shoryuken as global cancel options for this character.

As the DCS creates more powerful cancel options than the built-in cancel system, global cancel is a more powerful alternative to the built-in "com" command.

A good place to declare global cancel option is entity spawn script. Here's an example.

Code:
onspawnscript @script
	#import "data/scripts/dcancel.c"
	void main(){
		
		addGlobalCancel("D F a1", "ANI_freespecial1"); // Hado-Ken
		addGlobalCancel("Air D F a1", "ANI_freespecial2"); // Air Hado-Ken

		addGlobalCancel("HB F a1", "ANI_freespecial3"); // Sonic Boom !
		addGlobalCancel("HB F B F a1", "ANI_freespecial4"); // SONIC HURRICANE !
	
	}

@end_script

As you can note from this example, the system supports additional flags from the core system.

"HB" => Hold Back for 150cs
"HD" => Hold Down for 150cs
"Air" => Character must be in air to use that cancel option

Great work Piccolo!!  8)
 
This is a nice system - I haven't poured through the code, but I assume this answer is yes: Does this support holding of attack keys as well? I need to replicate the World Heroes style Tap/Press system where a quick touch performs one move and a longer press performs another. No reason to write my own and reinvent the wheel if you've already done it.  :D

DC
 
I have a way to do it but it's not integrated in the uploaded version I think.

Basically it is used like this :
Code:
addCancel(data, "HOLD a1", "ANI_freespecial3");

And when animation reaches switch frame, if the registered key was held from the start then the matching animation is played. So it's a framed based holding switch (not time based).
 
This :

Code:
@script
	if(frame > 0) daimaoCancel();
@end_script

needs to be put around the top of the entity model file (the main entity file with name, type, animations, etc), before any animation, not in a script file. Note that this global @script "event" is different than the "script" event.

Actually it is part of the inline animation script building, alongside @cmd and

Code:
@script
//code...
@end_script

that we use within animations. It is the same thing, but to write code that is not animation specific.


The rest seem ok, but for the keyall.c crash when you grab someone I'll need more information. Probably a conflict with a previous script I guess.
 
You just need to put this line :

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

in that "script.c" file.

Code:
@script
	if(frame > 0) daimaoCancel();
@end_script

This part is in the .txt file (before any animation)


Are the other crash also related to keyall.c ? If so then it's in this file that there might be a conflict.
 
Ok then, I'll do some tests with your mod tomorrow, I have to go now. In the meantime, could you precise what is "changed character" (when you die, when you start next level, etc).
 
I uploaded the last version.

This one does support holding a button, among other things.


Advanced Usage 2 : Holding press,  and option specific switch frames

Code:
atchain 1

anim attack1
	@script
		if(frame == 0){
			void data = createDaimaoCancel();
			
			set(data, "switchFrame", 5);
			
			addCancel(data, "a1", "ANI_attack2");
			addCancel(data, "HOLD a1", "ANI_attack3");
			addCancel(data, "a2", "ANI_freespecial1");
		
		}
	@end_script
	offset x y
	delay 10
	frame data/chars/...

With this example entity, if you press attack button from idle, it will play attack1 animation.
If you press the attack button during attack1 animation, the entity will play attack2 animation.
If you hold the press that initiated attack1 animation until switchFrame (here frame 5) then the entity will play attack3 animation.

Note that it is possible to use option specific switchFrame instead of the animation one. To do so, either use addCancelFull instead of addCancel function to create the cancel option, or more simply you can set it afterwards :

Code:
atchain 1

anim attack1
	@script
		if(frame == 0){
			void data = createDaimaoCancel();
			
			set(data, "switchFrame", 5);
			
			addCancel(data, "a1", "ANI_attack2");
			addCancel(data, "HOLD a1", "ANI_attack3");
			set(data, "HOLD a1_switchFrame", 3);
			addCancel(data, "a2", "ANI_freespecial1");
		
		}
	@end_script
	offset x y
	delay 10
	frame data/chars/...

In this example, the "HOLD a1" option will use frame 3 as the switch frame, while the other options will use frame 5.
 
Grab the last dcancel.c in this http://www.mediafire.com/download/6u2fdt7d4vrygga/daimao_cancel.7z and replace the one you have.
 
Advanced Usage 3 : Button combinations

Button combinations (e.g. pressing attack1 + jump) requires the activation of the input preprocessing system.

To do so edit your update.c in your scripts folder (create one if necessary) so it has these lines :

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


void main(){
	if(!openborvariant("in_options")){
		preprocessInputs();
	}	
}

Then in an animation cancel definition you can use :

Code:
anim attack1
	@script
		if(frame == 0){
			void data = createDaimaoCancel();
			
			set(data, "switchFrame", 3);
			
			addCancel(data, "a1+j", "ANI_freespecial5");
			addCancel(data, "a1+a2", "ANI_freespecial6");

		
		}
	@end_script

The order is important : a1, a2, a3, a4, s, j. So for example if you want to trigger an option by pressing both attack1 and jump, you have to use "a1+j" and not "j+a1".

You can define such combinations as global cancels too (see here to learn more about global cancels) :

Code:
onspawnscript @script
	#import "data/scripts/dcancel.c"
	void main(){
		addGlobalCancel("a1+j", "ANI_special");
	
	}
@end_script

(this needs to be put in the entity header, before animations)

That way, when the player will press attack + jump it will trigger "ANI_special" from any animation.
 
nsw you'll have to redownload the system to make use of button combinations : http://www.mediafire.com/download/6u2fdt7d4vrygga/daimao_cancel.7z

As for countering, there are multiple way of handling it, depending on what you intend to do. Here's a quite simple one.

Let's take Rick from your Urban Lockdown game for example. In his model header, set :

Code:
blockpain -1

Then just add a blockpain animation :

Code:
anim blockpain
	@script
		if(frame == 0){
			void data = createDaimaoCancel();
			
			set(data, "switchFrame", 0);
			
			addCancel(data, "a1", "ANI_chargeattack");
			addCancel(data, "a2", "ANI_special");

		
		}
	@end_script
	drawmethod alpha 2
	loop	0
	delay	20
	offset	92 138
	bbox	58 10 73 109
	frame	data/chars/rick/block.gif
	@cmd aniSwitch "ANI_block"
	frame	data/chars/rick/block.gif

With this, blockpain is like a counter window animation. You can change the delay to reduce or increase the counter window.
 
You probably replaced your whole update.c or something, or confused update.c with updated.c (that one is different).

You have to edit update.c so that it contains the lines mentionned, that doesn't mean you have to remove everything you had in there.
 
If you use direction just put a space (" ") as with the default cancel system.

F a1, U a1, etc.

the "+" is only for action buttons combinations

a1+j, F a1+a2, etc.

I'll take a look at your current build to see what's wrong.
 
Back
Top Bottom