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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, SBGuy), 987 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
c_trace and USE_BOX and collision-group problems... #337342
08/10/10 12:40
08/10/10 12:40
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
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.

Code:
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...



Last edited by EvilSOB; 08/10/10 13:29. Reason: typo fixed 9thanks slowglider)

"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: c_trace and USE_BOX and collision-group problems... [Re: EvilSOB] #337343
08/10/10 12:53
08/10/10 12:53
Joined: Apr 2008
Posts: 17
S
slowglider Offline
Newbie
slowglider  Offline
Newbie
S

Joined: Apr 2008
Posts: 17
var results = c_trace(source, targit.x, IGNORE_PASSABLE|USE_BOX|IGNORE_PUSH);

anyway cant you use IGNORE_ME anyway

Re: c_trace and USE_BOX and collision-group problems... [Re: slowglider] #337345
08/10/10 13:05
08/10/10 13:05
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
before setting me = shape, make sure to do me = NULL.
otherwise the pointer to me will be overwritten to be shape (from the function this calls).

same goes for before me = old_me.

hope that was clear, otherwise i'll have to make a drawing that explains what goes wrong... but i somehow feel you dont really need that.

regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: c_trace and USE_BOX and collision-group problems... [Re: Helghast] #337347
08/10/10 13:28
08/10/10 13:28
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Thanks guys, but no joy yet.

slowlider : Simple typo, real code doesnt have it.

Helghast : Not applicable. Fully tested. The line "me = old_me" always
gets executed, which repairs any damage caused by the "me = shape".


But keep at it guys.

Hint : It is mainly the c-tracing issues Ive got the problem with...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: c_trace and USE_BOX and collision-group problems... [Re: EvilSOB] #337361
08/10/10 15:11
08/10/10 15:11
Joined: Dec 2005
Posts: 116
T
tD_Datura_v Offline
Member
tD_Datura_v  Offline
Member
T

Joined: Dec 2005
Posts: 116
Quite possibly, IGNORE_ME is almost mandatory.
Also my manual (,which is out-dated,) doesn't seem to mention anything about IGNORE_PUSH working with c_trace and groups.





Re: c_trace and USE_BOX and collision-group problems... [Re: tD_Datura_v] #337363
08/10/10 15:19
08/10/10 15:19
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
Originally Posted By: tD_Datura_v
Quite possibly, IGNORE_ME is almost mandatory.
Also my manual (,which is out-dated,) doesn't seem to mention anything about IGNORE_PUSH working with c_trace and groups.


That gave me the right idea...

you should try to do c_ignore(30); before the trace, then it will ignore that group wink

regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: c_trace and USE_BOX and collision-group problems... [Re: Helghast] #337364
08/10/10 15:20
08/10/10 15:20
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline
Expert
Rei_Ayanami  Offline
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
c_ignore(30,0);

the last number always must be zero wink

Re: c_trace and USE_BOX and collision-group problems... [Re: Rei_Ayanami] #337386
08/10/10 18:01
08/10/10 18:01
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
tD_Datura_v : Even though my example doesnt show it, I have already
tried with IGNORE_ME, IGNORE_CONTENT, and both together. No change.

quote:from the manual - c_trace entry
IGNORE_PUSH Ignores entities with a lower push or same group value than the given entity.
For ignoring certain entity groups, call c_ignore before c_trace.

TO ME "or same group value" means it ignores whatever entities have the same group-value as the me...
ASSUMING that by "the given entity", it means the "me" entity.


I have also tried with the c_ignore, but I fell in the same hole as Helghast, and tried
c_ignore(30); ... without the trailing zero... I'll try it again.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: c_trace and USE_BOX and collision-group problems... [Re: EvilSOB] #337388
08/10/10 18:11
08/10/10 18:11
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
nah. still no change...

I think I'll need to build a test project just to see whats going on...

Thanks all the same guys..


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: c_trace and USE_BOX and collision-group problems... [Re: EvilSOB] #337479
08/11/10 07:29
08/11/10 07:29
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
Originally Posted By: EvilSOB

quote:from the manual - c_trace entry
IGNORE_PUSH Ignores entities with a lower push or same group value than the given entity.
For ignoring certain entity groups, call c_ignore before c_trace.

TO ME "or same group value" means it ignores whatever entities have the same group-value as the me...
ASSUMING that by "the given entity", it means the "me" entity.


Maybe this is a bug then, or a manual mistake.
I am using push values alot, and can confirm those work, but I only use them in combination with c_move not trace.

good luck.
regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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