2 registered members (OptimusPrime, AndrewAMD),
14,580
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
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
OP
Newbie
|
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:
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
Senior Expert
|
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
OP
Newbie
|
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:
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.
|
|
|
|