Several entities with the same pointer/c_scan pointer madness

Posted By: Luzifer

Several entities with the same pointer/c_scan pointer madness - 05/03/09 12:47

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:

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:

Code:
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.
Posted By: Widi

Re: Several entities with the same pointer/c_scan pointer madness - 05/03/09 14:45

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...
Posted By: Luzifer

Re: Several entities with the same pointer/c_scan pointer madness - 05/03/09 15:18

Funktioniert super, vielen vielen Dank!

For all potential, English-speaking helpers:
Second problem solved. Out of curiosity I tried to replace the player-pointer in c_scan and hoped this would work better too, but no change. The enemies react exactly the same. Even though the scan-cone seems to be working correctly they do not identify the skill or the pointer until the player is extremely close or on their left side. That is weird.

Any suggestions?
Posted By: fogman

Re: Several entities with the same pointer/c_scan pointer madness - 05/03/09 17:49

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.
Posted By: Luzifer

Re: Several entities with the same pointer/c_scan pointer madness - 05/06/09 18:39

Sorry für die späte Antwort, komme unter der Woche nicht so recht zu was. Ich werde das auf jeden Fall ausprobieren.

Aber eigentlich sollte es doch auch rein mit Scan funktionieren. Dafür fragt die IF-Bedingung ja nach "you == player". Wenn ich diese rausnehme findet er den Player (und natürlich jede andere entity) sofort so wie geplant.

Ich denke deine Methode wird eine gute Umgehung sein, ich werds definitiv testen. Aber eigentlich müsste es doch auch mit der reinen Abfrage "you == player" im c_scan funktionieren, oder?
Posted By: KiwiBoy

Re: Several entities with the same pointer/c_scan pointer madness - 05/06/09 20:18

Give it a unique ID then if (unique ID =insert unique ID numbers)
then do action.
Posted By: elsewood

Re: Several entities with the same pointer/c_scan pointer madness - 05/08/09 16:06

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... grin
Posted By: Luzifer

Re: Several entities with the same pointer/c_scan pointer madness - 05/09/09 13:02

Ahhh, der Groschen ist gefallen! wink 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:

Code:
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?
© 2024 lite-C Forums