Hi all.
I cant post my 'real' code here, cause its buried in some evil code. So I'll post a re-creation as close as I can.
ENTITY* bullet_template = { type="bullet.mdl"; }
function can_be_hit(VECTOR* source, ENTITY* targit, ENTITY* shape)
{
//backup old "me" info
ENTITY* old_me = me; //save old "me" so it can be restored later.
var old_my_group = my.group; //save old "me" collision group too.
me.group = 30; //set old "me" to a collision group that
// is ignored by this function
//
//backup old "targit" info
var old_targ_group = targit.group; //save "targit" collision group too.
targit.group = 30; //set "targit" to a collision group that
// is ignored by this function
//
//set "me" to collision-hull of choice
me = shape; //set "me" to collision-template for USE_BOX tracing
me.group = 30; //set "me" to ignore-able collision group
//
//do the trace. (IGNORE_PUSH should make it ignore group=30, correct?)
var results = c_trace(source, targit.x, IGNORE_PASSABLE|USE_BOX|IGNORE_PUSH);
//
//restore old "me" and "targit" to the way they were
me = old_me; //restore old me into "me"
me.group = old_me_group; //restore old "me" collision group
targit.group = old_targ_group; //restore old "targit" collision group
//
return(results); //return distance to target
}
action player_act()
{
ENTITY* victim=NULL; //pointer to selected enemy target
...
if((mouse_left)&&(victim))
{
var victim_range = can_be_hit(my.x, victim, bullet_template);
if(victim_range <= bullet_range) { shoot(); }
}
...
}
So what Im trying to do is this...
I want to call a function from an action, that will 'temporarily' replace the ME
with another entity in order to do a USE_BOX trace with its collision-hull,
and then put it back again.
And I NEED to be using the collision-groups system during the trace too,
but i dont know if its working at all.
Can anyone see any flaws in the program flow ?
(be aware there may be some coding bugs in this un-compiled EXAMPLE code)
In my real code I keep getting odd collisions with what I believe to be geometry,
but its so intermittant its hard to pin down... due to the other evil code around it...
Thanks guys...