hitcheck via script?

dantedevil

Well-known member
Its possible create a hitcheck via script?

I have some characters with a freespecial attack with follow. When the freespecial attack make contact the character perform a combo (follow), if the character only make contact the freespecial attack when the enemy is in the air; the follow shows next hitting the air to the end. The only way to avoid this is create a combo of 1 hit and a follow for the next hit.

With a hitcheck 1 follow be enough for all combo.
 
It most certainly is. The ondoattack event occurs whenever the engine detects a collision, just before all the default hit code is run. You can use this to script your own actions and disable the engine's

This allows you to make your own followups, parry systems, or even go so far as to build a complete hit system from the ground up if you're a maniac.

Here's an example of using it to add parry system. When a hit is detected, my parry function is called. If parry function returns true (parry conditions were met and parry will be executed), then the lasthit system variable is set to false, meaning the engine will ignore its own hit code for that one collision.

Code:
z_datk
	Damon Vaughn Caskey
	2011_02_25

	Universal doattack event function.

	vEnt:	Caller entity.
	*/
		
    int		iAtkID		= getlocalvar("attackid");
	void	vOther		= getlocalvar("other");

	if(!vEnt){	vEnt = getlocalvar("self");	}

	/*
	log("\n z_datk ~ Cuurent ID: " + iAtkID);
	log("\n z_datk ~ Attack ID: " + getentityproperty(vEnt, "attackid"));
	log("\n z_datk ~ Hit By ID: " + getentityproperty(vEnt, "hitbyid"));
	*/

	if(!getlocalvar("which") && (getentityproperty(vEnt, "hitbyid") != iAtkID))
	{
		if (parr0001(vEnt, vOther))
		{		
			changeopenborvariant("lasthitc", 0);
		}		
	}
		
	changeentityproperty(vEnt, "hitbyid", iAtkID);

	//log("\n z_datk ~ Hit By ID (after): " + getentityproperty(vEnt, "hitbyid"));

DC

 
Please stop refreshing your reply or I will lock the thread. What I gave you IS the example. You don't put anything in the model text other than a call to doattack script.

DC
 
DC, so basically ondoattack runs BEFORE all the default hit code runs, and didhit runs AFTER it, right?

This is why you use getlocalvar("other") instead of getlocalvar("target")?
I understand all the code, but I would like to know what these parts means:

•getlocalvar("other")
•lasthitc

Got it: http://www.chronocrash.com/forum/index.php?topic=11.0
"lasthitc" stand for "Last hit check", right?
 
Someone can show me how use this script in a txt attack. How set the parameters, etc.

Thanks.

Code:
z_datk
	Damon Vaughn Caskey
	2011_02_25

	Universal doattack event function.

	vEnt:	Caller entity.
	*/
		
    int		iAtkID		= getlocalvar("attackid");
	void	vOther		= getlocalvar("other");

	if(!vEnt){	vEnt = getlocalvar("self");	}

	/*
	log("\n z_datk ~ Cuurent ID: " + iAtkID);
	log("\n z_datk ~ Attack ID: " + getentityproperty(vEnt, "attackid"));
	log("\n z_datk ~ Hit By ID: " + getentityproperty(vEnt, "hitbyid"));
	*/

	if(!getlocalvar("which") && (getentityproperty(vEnt, "hitbyid") != iAtkID))
	{
		if (parr0001(vEnt, vOther))
		{		
			changeopenborvariant("lasthitc", 0);
		}		
	}
		
	changeentityproperty(vEnt, "hitbyid", iAtkID);

	//log("\n z_datk ~ Hit By ID (after): " + getentityproperty(vEnt, "hitbyid"));
 
Thanks!
Can you show me how works?
I have the script courtesy of Damon Caskey, but i dont know how use it.
 
probabily, you will need to save this code as, lets say z_atk.c

Code:
void main()
{
	/*z_datk
	Damon Vaughn Caskey
	2011_02_25

	Universal doattack event function.

	vEnt:	Caller entity.
	*/
		
    int		iAtkID		= getlocalvar("attackid");
	void	vOther		= getlocalvar("other");

	if(!vEnt){	vEnt = getlocalvar("self");	}

	/*
	log("\n z_datk ~ Cuurent ID: " + iAtkID);
	log("\n z_datk ~ Attack ID: " + getentityproperty(vEnt, "attackid"));
	log("\n z_datk ~ Hit By ID: " + getentityproperty(vEnt, "hitbyid"));
	*/

	if(!getlocalvar("which") && (getentityproperty(vEnt, "hitbyid") != iAtkID))
	{
		if (parr0001(vEnt, vOther))
		{		
			changeopenborvariant("lasthitc", 0);
		}		
	}
		
	changeentityproperty(vEnt, "hitbyid", iAtkID);

	//log("\n z_datk ~ Hit By ID (after): " + getentityproperty(vEnt, "hitbyid"));
}

and declare it as ondoattack.

But I haven't tested it
 
Ok, sorry bit i dont know how declare ondoattack and how works.
I understand the part of save as z_atk.c.
Wath next?
Import the z_atk.c to the main script or set the script line in the header player txt?
Then how call the script?
@cmd.....
 
Thanks BeasTie!

After thath i need something more to use it?

And how works this script in game?

I wanna use it to check hits in a combo and no need a lot to freespecials to works fine. Like explain in the first post.
 
Hello,
I never scripted myself but I just read this thread and I think you've been explained all you need. The helpers can't do more than what they did IMHO. Maybe you have to learn what scripting is before asking such a specific question ?
 
O Ilusionista said:
probabily, you will need to save this code as, lets say z_atk.c

Code:
void main()
{
	/*z_datk
	Damon Vaughn Caskey
	2011_02_25

	Universal doattack event function.

	vEnt:	Caller entity.
	*/
		
    int		iAtkID		= getlocalvar("attackid");
	void	vOther		= getlocalvar("other");

	if(!vEnt){	vEnt = getlocalvar("self");	}

	/*
	log("\n z_datk ~ Cuurent ID: " + iAtkID);
	log("\n z_datk ~ Attack ID: " + getentityproperty(vEnt, "attackid"));
	log("\n z_datk ~ Hit By ID: " + getentityproperty(vEnt, "hitbyid"));
	*/

	if(!getlocalvar("which") && (getentityproperty(vEnt, "hitbyid") != iAtkID))
	{
		if (parr0001(vEnt, vOther))
		{		
			changeopenborvariant("lasthitc", 0);
		}		
	}
		
	changeentityproperty(vEnt, "hitbyid", iAtkID);

	//log("\n z_datk ~ Hit By ID (after): " + getentityproperty(vEnt, "hitbyid"));
}

and declare it as ondoattack.

But I haven't tested it

I save the code as zdatk.c and declare the ondoattack in the headers character.
Code:
ondoattackscript data/scripts/z_datk.c
The OpenBor crahs before start.
So i post for help because i can't find the error.

Thanks to all people to ever help me.
 
Your confusing function name with file name. You saved the file as zdatk.c, but then in the model you called for z_datk.c; that won't work.

The model header declaration tells OpenBOR where to get the file, so you can use the functions in it. "main" is just another function that is run immediately in response to the event (in this case, when OpenBOR detects a collision).

IOW, when a collision is detected and the entities in question have an ondohit script file declared, OpenBOR will run the "main" function in that file.

Save the script file using whatever name you want, then declare it in the model as ondoattack <path to your filename here>.

DC
 
Ok, now i save the script with the name hitchk.c and import in header character like this:
Code:
ondoattackscript data/scripts/hitchk.c

The Openbor crashes.
Script compile error in 'ondoattackscript': vEnt line 15, column 8

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

Can't compile script!
Total Ram: 4294967295 Bytes
Free Ram: 4294967295 Bytes
Used Ram: 64045056 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!
 
For sure its giving error - that code uses a variable which wasn't set yet (probabily, its set in other file).

Try this:

void vEnt = getlocalvar("self");
int iAtkID = getlocalvar("attackid");
void vOther = getlocalvar("other");
 
Back
Top Bottom