Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (AndrewAMD, TipmyPip), 13,353 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
The problem on Hitzone system! It can't work in bone animation! #406563
08/24/12 02:17
08/24/12 02:17
Joined: Sep 2011
Posts: 9
H
hallohope Offline OP
Newbie
hallohope  Offline OP
Newbie
H

Joined: Sep 2011
Posts: 9
Hi fellow GameStudioers, I am new to GameStudio and I have a few questions regarding Hitzone system scripts of AUM103.
As you see, the demo is using the Vertex animation. but when the Vertex animation was displaced by bone animation, the hizone system can't work normally. Is there any way to edit these scripts for bone animation?

[code]:

//////////////////////////////
// hitzone.c
// by Hendrik Felix Pohl aka Superku
// 22.10.2011
// free-to-use, credit would be nice but is not necessary
//////////////////////////////
// configurable:

#define HZ_ENEMY_SORT_MAX 20
#define HZ_ENEMY_SORT_UPDATE 3 // number of maximal c_hullupdates
#define hitzone_ent_size skill98
#define hitzone_skin skill99 // the default skin may already be in use by a shader
var hitzone_skin_default = 2; // default skin number of hitzone mask

// call this function at entity creation
void hitzone_enemy_add(ENTITY* ent);

// call this function before entity removal
void hitzone_enemy_remove(ENTITY* ent);

// call this function before you c_trace
// v1: start (i.e. camera.x)
// v2: target
// mode: if mode is 0 (default), only enemies that are not CLIPPED will be used for calculation
void hitzone_update(VECTOR* v1, VECTOR* v2, var mode);

// call this function after c_trace
var hitzone_get_damage();

//////////////////////////////

ENTITY* hitzone_enemy_sort[HZ_ENEMY_SORT_MAX];

var hitzone_enemy_sort_dist[HZ_ENEMY_SORT_MAX];
var hitzone_enemies_sorted = 0;
var hitzone_initialized = 0;

VECTOR hitzone_color;

//////////////////////////////

typedef struct HITZONE_LINK {
ENTITY* ent;
struct HITZONE_LINK *next;
} HITZONE_LINK;

HITZONE_LINK* hitzone_enemy_first = NULL;

//////////////////////////////

// call this function on entity creation
void hitzone_enemy_add(ENTITY* ent)
{
var eflag;
VECTOR vmin,vmax;
HITZONE_LINK *link,*new;

if(!hitzone_initialized)
{
hitzone_initialized = 1;
on_ent_remove = hitzone_enemy_remove;
}

new = (HITZONE_LINK*)sys_malloc(sizeof(HITZONE_LINK));
new->ent = ent;
new->next = NULL;

if(!hitzone_enemy_first) hitzone_enemy_first = new;
else
{
link = hitzone_enemy_first;
while(link->next) link = link->next;
link->next = new;
}
// initialize entity
ent.hitzone_skin = hitzone_skin_default;
eflag = ent.eflags;
vec_set(vmin,ent.min_x);
vec_set(vmax,ent.max_x);
c_setminmax(my);
ent.hitzone_ent_size = vec_length(vector(maxv(ent.max_x,-ent.min_x),maxv(ent.max_y,-ent.min_y),maxv(ent.max_z,-ent.min_z)));
ent.eflags = eflag;
vec_set(ent.min_x,vmin);
vec_set(ent.max_x,vmax);
}

// call this function before entity removal
void hitzone_enemy_remove(ENTITY* ent)
{
HITZONE_LINK *link,*prev,*next;

if(!hitzone_enemy_first || !ent) return;

prev = NULL;
link = hitzone_enemy_first;
while(ent != link->ent)
{
prev = link;
link = link->next;
if(!link) break;
}
if(link)
{
next = link->next;
if(!prev) hitzone_enemy_first = next;
else
{
if(prev != link) prev->next = next;
}
sys_free(link);
}
}

// helper function
var hitzone_line_dist(VECTOR* vec1, VECTOR* vec2, VECTOR* point)
{
var result,i;
VECTOR dir1,dir2;
float f1,f2;

vec_diff(dir1,vec2,vec1);
vec_diff(dir2,point,vec1);
// f1 equals vec_dot(dir1,dir2) with high precision/ range
f1 = (float)dir1.x*(float)dir2.x+(float)dir1.y*(float)dir2.y+(float)dir1.z*(float)dir2.z;
f2 = (float)dir1.x*(float)dir1.x+(float)dir1.y*(float)dir1.y+(float)dir1.z*(float)dir1.z;
i = f1/f2;

if(i >= 0 && i <= 1)
{
vec_scale(dir1,i);
vec_add(dir1,vec1);
result = vec_dist(dir1,point);
}
else result = -1;

return result;
}

// call this function before you c_trace
void hitzone_update(VECTOR* v1, VECTOR* v2, var mode)
{
var i,j,k,eflag;
VECTOR vmin,vmax;

for(i = 0; i < HZ_ENEMY_SORT_MAX; i++) hitzone_enemy_sort[i] = NULL;

// fetch possible targets
HITZONE_LINK *link = hitzone_enemy_first;
hitzone_enemies_sorted = 0;
vec_set(hitzone_color,nullvector);
i = 1;
while(link)
{
if(!(link->ent.eflags & CLIPPED) || mode)
{
result = hitzone_line_dist(v1,v2,link->ent.x);
if(result != -1 && result < link->ent.hitzone_ent_size)
{
hitzone_enemy_sort[hitzone_enemies_sorted] = link->ent;
hitzone_enemy_sort_dist[hitzone_enemies_sorted] = vec_dist(v1,link->ent.x);
hitzone_enemies_sorted++;
if(hitzone_enemies_sorted >= HZ_ENEMY_SORT_MAX) break;
}
}
link = link->next;
i++;
}
if(hitzone_enemies_sorted > HZ_ENEMY_SORT_UPDATE)
{
// sort possible targets by distance to v1 (i.e. v1 = camera.x)
for(i = 1; i < hitzone_enemies_sorted; i++)
{
k = hitzone_enemy_sort_dist[i];
you = hitzone_enemy_sort[i];
j = i;
while(j > 0 && hitzone_enemy_sort_dist[j-1] > k)
{
hitzone_enemy_sort_dist[j] = hitzone_enemy_sort_dist[j-1];
hitzone_enemy_sort[j] = hitzone_enemy_sort[j-1];
j--;
}
hitzone_enemy_sort_dist[j] = k;
hitzone_enemy_sort[j] = you;
}
}
// update collision hulls for near targets
for(i = 0; i < minv(hitzone_enemies_sorted,HZ_ENEMY_SORT_UPDATE); i++)
{
eflag = hitzone_enemy_sort[i].eflags;
vec_set(vmin,hitzone_enemy_sort[i].min_x);
vec_set(vmax,hitzone_enemy_sort[i].max_x);
c_updatehull(hitzone_enemy_sort[i],hitzone_enemy_sort[i].frame);
hitzone_enemy_sort[i].eflags = eflag;
vec_set(hitzone_enemy_sort[i].min_x,vmin);
vec_set(hitzone_enemy_sort[i].max_x,vmax);
}

}

// call this function after c_trace
var hitzone_get_damage(ENTITY* ent)
{
BMAP* bmp_pointer = bmap_for_entity(ent,ent.hitzone_skin);
var format = bmap_lock(bmp_pointer,0);
var pixel = pixel_for_bmap(bmp_pointer,hit.u1,hit.v1);
pixel_to_vec(hitzone_color,NULL,format,pixel);
bmap_unlock(bmp_pointer);
return hitzone_color.z;
}

Re: The problem on Hitzone system! It can't work in bone animation! [Re: rayp] #406572
08/24/12 06:42
08/24/12 06:42
Joined: May 2009
Posts: 5,377
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,377
Caucasus
If you are using A7, this won't work for you with bone animations:
Originally Posted By: Superku
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.

I fear you have to use models/ hitboxes with bone animation in A7.

Check out this thread:
Hitzone system


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung

Moderated by  HeelX, Spirit 

Gamestudio download | 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