Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,486 guests, and 10 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Detection does not work as it should be (c_trace code fail?) #326383
05/31/10 19:31
05/31/10 19:31
Joined: May 2010
Posts: 23
Germany
h34dl4g Offline OP
Newbie
h34dl4g  Offline OP
Newbie

Joined: May 2010
Posts: 23
Germany
I'm trying to create a hit detection with c_trace. The idea is, that I want to look for a enemy standing in front or behind me. I can't find my mistake in the code, because everytime I use it, my c_trace calls a hit, even if I stay far away. Here is my code:

Code:
action enemy_with_pointer()
{
	enemy = my;
	c_updatehull(my, 1);
}

-------------------------------------

action guard_with_pointer()
{ 
	guard1 = my;	
	c_updatehull(my, 1);	
	while (1)
	{
		while (key_t == OFF) {wait (1);} 
		while (key_t == ON) {wait (1);}
		c_trace (guard1.x, enemy.x, IGNORE_ME + USE_BOX); // trace to the enemy
		if (you == enemy) // got the enemy?
		{
			guard_life -= 10;
		}
		else
		{
			guard_life += 10;
		}	
		wait (1);
	}
}



Last edited by h34dl4g; 05/31/10 19:49.

1338, beyond leet.
Re: Detection does not work as it should be (c_trace code fail?) [Re: h34dl4g] #326390
05/31/10 20:00
05/31/10 20:00
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
"c_trace (guard1.x, enemy.x,...)" <=> that I want to look for a enemy standing in front or behind me

I think you did not understand c_trace yet (if you have a look at c_trace in the manual you will see that it is correct that you always hit something/ the enemy), you may be looking for c_scan instead or trace from your guard1 position to a temporary vector in front or behind him.

Last edited by Superku; 05/31/10 20:01.

"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: Detection does not work as it should be (c_trace code fail?) [Re: Superku] #326461
06/01/10 09:23
06/01/10 09:23
Joined: May 2010
Posts: 23
Germany
h34dl4g Offline OP
Newbie
h34dl4g  Offline OP
Newbie

Joined: May 2010
Posts: 23
Germany
Solved!
Thx Superku, I read a few things and now I unsderstand c_scan. It works fine.

Here is my finished code:

Code:
function event_scan_attack1_damage()
{
	if (event_type == EVENT_SCAN)
	{
		my.health -= 10;
	}
}

action enemy_with_pointer()
{
	var death_percentage;
	enemy = my;
	c_updatehull(my, 1);
	my.emask |= ENABLE_SCAN;
	my.event = event_scan_attack1_damage;
	while(1)
	{
		if (my.health <= 0) // Check life
		{
			ent_animate(my, "death", death_percentage, 0);
			death_percentage += 3 * time_step; // Animationspeed
		} 	
	wait (1);	
	}
	
}

--------> c_scan(guard1.x, guard1.pan, vector(45, 60, 50), IGNORE_ME);





Last edited by h34dl4g; 06/01/10 13:19.

1338, beyond leet.

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