Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → AI player detection...
AI player detection...
2004-04-12, 3:42 PM #1
Descent_pilot was nice enough to whip up something of an AI patrol cog for part of LoG 02, but the detection bit doesn't work all that well. The player is supposed to skulk around without being noticed. My theory is that the two guards (mover and mover1) detect one another, but whatever it is, the Spotted message is called as soon as the pulse begins. At this point, however, the theory doesn't hold true, as the guards don't see me until I come out into the open... but this happens even if they're looking in the opposite direction.

Code:
Pulse:
   If(HasLOS(mover, GetLocalPlayerThing()) && ThingViewDot(mover, GetLocalPlayerThing()) < dotView)
      call spotted;
      
   If(HasLOS(mover1, GetLocalPlayerThing()) && ThingViewDot(mover1, GetLocalPlayerThing()) < dotView1)
      call spotted;
   Return;
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2004-04-12, 6:13 PM #2
HasLOS() returns 1 even if the AI weren't actually looking AT the player; HasLOS() asks: "If the AI were looking at the player's direction, could the AI see him?"

Try doing a FirstThingInView()/NextThingInView() check in a pulse message (there's a tutorial on this and it can also be found in the targeting force powers like Pull and Blind [edit]added a code script for ya to try below \/ \/ \/[/edit]).
On a side note, FTIV apparently doesn't work with an FOV greater than 180 degrees (I needed one for a 360 degree check and it didn't work), so if, later, you want an FOV check for greater than 180 degrees for something, you can try firing a temporary template in the opposite look direction and get its fov check as well as the AI's fov check.

Hope I have helped a bit. [http://forums.massassi.net/html/smile.gif]

[edit] Oops, didn't see the ViewDot stuff; that might void some of what I said [http://forums.massassi.net/html/redface.gif]
But from what I see, FTIV/NTIV is probably a better choice for what you're trying to do.

BTW, is this a stealth mission you're working on?

------------------
Bond, Power, CA, The Force, Saber, IC, Epic, Oily Mexican Food, BG, /\ |> /\ /\/\, Sentences.
Now you know where I've been.

[This message has been edited by Darth Slaw (edited April 12, 2004).]

[This message has been edited by Darth Slaw (edited April 12, 2004).]
May the mass times acceleration be with you.
2004-04-12, 6:41 PM #3
Try this code in the pulse instead. It should work, unless I did something horribly wrong.
Code:
pulse:
	player = FirstThingInView(mover, fov, maxdist, 0x400);
	while(player != -1)
	{
		if(HasLOS(mover, player) && (VectorDist(GetThingPos(player), GetThingPos(mover)) <= maxdist) && !(GetThingFlags(player) & 0x200) && (player == GetLocalPlayerThing()))
		{			
			call spotted;
		}
		player = NextThingInView();
	}
	player = FirstThingInView(mover1, fov1, maxdist1, 0x400);
	while(player != -1)
	{
		if(HasLOS(mover1, player) && (VectorDist(GetThingPos(player), GetThingPos(mover1)) <= maxdist) && !(GetThingFlags(player) & 0x200) && (player == GetLocalPlayerThing()))
		{			
			call spotted;
		}
		player = NextThingInView();
	}
	return;

SYMBOLS USED:
player - player things in the view of the AI guys
mover - first AI
mover1 - second AI
fov - field of view for first AI
fov1 - field of view for second AI
maxdist - maximum distance between first AI and player
maxdist2 - max dist between second AI and player

[This message has been edited by Darth Slaw (edited April 12, 2004).]
May the mass times acceleration be with you.
2004-04-13, 3:14 AM #4
Yes, I am making a stealth segment in my level, and yes, your code works perfectly. [http://forums.massassi.net/html/biggrin.gif] Thanks a lot, Darth Slaw.

------------------
Rites of Xanthus

The TC that exacted a terrible toll on my time and eyesight.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2004-04-13, 5:52 AM #5
Grismath, all ya gotta do is reverse the < signs to >. Stupid typo and no double check. My code will work then.

------------------
Major projects working on:
SATNRT
JK Pistol Mod
Aliens TC
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2004-04-13, 8:47 AM #6
Well the new code works well enough, so I'm not changing anything. :]

------------------
Rites of Xanthus

The TC that exacted a terrible toll on my time and eyesight.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.

↑ Up to the top!