1 registered members (AndrewAMD),
1,089
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Several entities with the same pointer/c_scan pointer madness
#263947
05/03/09 12:47
05/03/09 12:47
|
Joined: Dec 2007
Posts: 34
Luzifer
OP
Newbie
|
OP
Newbie
Joined: Dec 2007
Posts: 34
|
Hello everyone, right now I'm trying to get a rather simple shooter system to work. For my enemies I'm using a modified AI from the AUM 57 and even though it seemed to work fine in the beginning, I'm running into a lot of problems with it. First of all the enemy looks for you = player and by testing I know that even though the c_scan finds my player, the enemy randomly does not recognize the player entity. Sometimes I can jump up and down in front of it, sometimes it will see me right the second I step into the scan cone. C_scan seems to do fine, it's just that the player pointer is not recognized half the time. Here's the code:
if ((c_scan(my.x, my.pan, vector(160, 60, 1000), ignore_me) > 0) && (you == player))
{
my.skill1 = attacking; // then attack the player
}
On a different note: When I shoot an enemy, I want there to be some effects (blood obviously) and it works just fine this way:
if (you == ent_enemy)
{
if (hitvertex > 450 && hitvertex < 800) {
you.skill3 -= 100; //headshot kills instantly
}
effect(blood_hit,55,target,nullvector);
}
Problem: If I create two enemy entities with the same action the pointer only works for one, the other does not get any blood effects or headshots. How do I work around that problem, so that both enemies work the same? (without creating seperate actions for each enemy) Thanks in advance! Edit: Okay this is seriously weird. The c_scan cone works fine (event_scan of player is activated inside the cone) but the enemy only recognizes "you" as "player" if I'm on the far left side of his vision field.
Last edited by Luzifer; 05/03/09 13:52.
|
|
|
Re: Several entities with the same pointer/c_scan pointer madness
[Re: Luzifer]
#263968
05/03/09 14:45
05/03/09 14:45
|
Joined: Aug 2007
Posts: 1,922 Schweiz
Widi
Serious User
|
Serious User
Joined: Aug 2007
Posts: 1,922
Schweiz
|
is "ent_enemy" a Pointer? A Pointer can point only to one Entity! Use one skill to identify the enemy:
#define Art skill21; #define Art_enemy 1;
action enemy_action() { ... my.Art = Art_enemy; }
then if you want to know if the hit is a enemy:
if (you.Art == Art_enemy) { ... }
Edit: This is lite-C, but it is no problem to convert...
Last edited by Widi; 05/03/09 14:55.
|
|
|
Re: Several entities with the same pointer/c_scan pointer madness
[Re: Luzifer]
#263992
05/03/09 17:49
05/03/09 17:49
|
Joined: Apr 2005
Posts: 4,506 Germany
fogman
Expert
|
Expert
Joined: Apr 2005
Posts: 4,506
Germany
|
Wenn der Spieler von einem Gegner-Scan getroffen wird, sollte er einen Trace zu diesem Gegner schicken.
Wenn der Tracestahrl durchkommt, ist der "Blick" zum Spieler frei und es darf geballert werden.
Praktischerweise zeigt dann "you" in der Event Funktion des Gegners auf den Spieler.
Nur mit c_scan wird das nix, weil c_scan alle Entities findet und "you" auf die nächstgelegene setzt. Das ist natürlich nicht immer der Spieler, sondern auch mal ein anderes Objekt.
no science involved
|
|
|
Re: Several entities with the same pointer/c_scan pointer madness
[Re: Luzifer]
#264885
05/08/09 16:06
05/08/09 16:06
|
Joined: Nov 2002
Posts: 792 Berne, Switzerland
elsewood
User
|
User
Joined: Nov 2002
Posts: 792
Berne, Switzerland
|
In deinem Code machst du EINEN Scan und fragst dann ob es den Spieler getroffen hat. Wenn ja dann setzt du den Flag, wenn NEIN, dann machst du einfach gar nichts... ALso geht das nur, wenn der Spieler das nächstgelegene Objekt ist und sonst findest du ihn nicht...
A bus station is where the bus stops. A train station is where the train stops. On my desk I have a workstation...
|
|
|
Re: Several entities with the same pointer/c_scan pointer madness
[Re: elsewood]
#264998
05/09/09 13:02
05/09/09 13:02
|
Joined: Dec 2007
Posts: 34
Luzifer
OP
Newbie
|
OP
Newbie
Joined: Dec 2007
Posts: 34
|
Ahhh, der Groschen ist gefallen! Danke! Ich habs jetzt so probiert wie fogman vorgeschlagen hat, aber ich es funktioniert noch nicht so recht, bzw. garnicht. Wenn ich im Code temp.x verwendet habe, hat der Gegner den Player nur auf der x-Achse des Levels gefunden, also das war schonmal falsch. Da der scan laut Tests weiterhin tadellos funktioniert muss es wohl mein c_trace sein. In der aktuellen Form passiert garnichts:
if (event_type == EVENT_SCAN)
{
vec_set(temp,your.x);
c_trace(player.x,temp,ignore_passable|ignore_me|activate_sonar|use_box);
}
Ohne use_box hab ichs auch schon probiert. Wo liegt der Fehler?
|
|
|
|