Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Quad, VoroneTZ, 1 invisible), 852 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Hitzone system #385688
10/21/11 23:07
10/21/11 23:07
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Free-to-use hitzone system
This method is far superior to my previous hitbox solution, it's very fast, easy to use and is based on polygonal detection, it does not use additional models and does not require any special setup (except painting a hitzone mask). It even works fine with bone animations.



It's based on a simple c_trace+SCAN_TEXTURE+USE_POLYGON approach. Normally, the problem is that the collision mesh is different from the animated visible mesh of a model and thus you have to use c_updatehull to reload all of its vertices. As this function is pretty slow, you want to avoid unnecessary calls at all cost.
Therefore you register every animated enemy on entity creation and the code will then only update enemies close to the ray from c_trace's start to target. If there are more than, f.i. 3-5, close objects, they will be sorted by their distance to the trace source and only those enemies' collision mesh will be refreshed.
Those entities should have a hitzone mask as a separate skin, where the different channels (I chose red for damage, green for body part identification) provide the desired information:



Concerning the green channel you have to lay down your own rules: You have 256 possible body parts, now you take for example 0 (= black) as an indicator for a non-defined body part, 1 (that means you paint (1,1,1) in the green channel) for the face, 2 for the back of the head, 10 for the right hand, 11 for the left hand and so on.

Download here (updated: 22.10.2011):
http://www.superku.de/hitzones.zip
(source + example)

The code uses 2 skills and overwrites "on_ent_remove". Have a look at "hitzone.c", there are some other configurable things, too.



Example shoot function:
Code:
hitzone_update(camera.x,temp,0); // write 1 instead of 0 when CLIPPED entities should be taken into account, too
c_trace(camera.x,temp,IGNORE_PASSABLE | USE_POLYGON | SCAN_TEXTURE);
if(you)
{
	damage = hitzone_get_damage(you); // now the vector "hitzone_color" contains the mask information at hit point
	your.health -= damage;
}


Example enemy action:
Code:
action enemy()
{
	hitzone_enemy_add(me);
	//my.hitzone_skin = 3; // optional, the skin "hitzone_skin_default" may already be in use by a shader
	while(my.health > 0)
	{
		...
		wait(1);
	}
	hitzone_enemy_remove(me);
}



Have fun!

Last edited by Superku; 11/21/11 20:30.

"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Hitzone system [Re: Superku] #385695
10/22/11 10:03
10/22/11 10:03
Joined: Oct 2007
Posts: 5,210
Ä°stanbul, Turkey
Quad Online
Senior Expert
Quad  Online
Senior Expert

Joined: Oct 2007
Posts: 5,210
Ä°stanbul, Turkey
Awesome idea, and awesome execution!


3333333333
Re: Hitzone system [Re: Quad] #385702
10/22/11 10:45
10/22/11 10:45
Joined: Jul 2002
Posts: 5,181
Austria
Blattsalat Offline
Senior Expert
Blattsalat  Offline
Senior Expert

Joined: Jul 2002
Posts: 5,181
Austria
Very nice!
I will have to test this.

Thanks a lot for the contribution.

cheers and have a nice one,


Models, Textures and Levels at:
http://www.blattsalat.com/
portfolio:
http://showcase.blattsalat.com/
Re: Hitzone system [Re: Blattsalat] #385711
10/22/11 13:17
10/22/11 13:17
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
You're welcome!
I've uploaded a small "fix", the old "hitzone.c" said that you have to call the function hitzone_init() at game start but you don't, it was an empty prototype.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Hitzone system [Re: Superku] #387630
11/21/11 19:21
11/21/11 19:21
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline
Expert
alibaba  Offline
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
It´s not possible to use it with A8, isn´t it?


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: Hitzone system [Re: alibaba] #387635
11/21/11 19:51
11/21/11 19:51
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Of course it is, I only use A8. What problems do you encounter?


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Hitzone system [Re: Superku] #387637
11/21/11 20:08
11/21/11 20:08
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline
Expert
alibaba  Offline
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
c_updatehull, the problem is, that i use bone animated models.


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: Hitzone system [Re: alibaba] #387639
11/21/11 20:27
11/21/11 20:27
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
There is no problem with bone animation and/ or combination of bone animations (at least with ANM_ADD and ent_animate, did not try anything else), this works fine.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Hitzone system [Re: Superku] #387642
11/21/11 20:55
11/21/11 20:55
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline
Expert
alibaba  Offline
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
No Problems in A8, but A7 does not support Hull updates with bone animation.


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: Hitzone system [Re: alibaba] #387646
11/21/11 21:12
11/21/11 21:12
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Quote:
It´s not possible to use it with A8, isn´t it?

Hm that question is cleared now, correct? If so, have fun and good luck with your project!


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Page 1 of 2 1 2

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1