Home   Help Search Login Register  

Author Topic: check if unit can see another unit  (Read 663 times)

0 Members and 1 Guest are viewing this topic.

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
check if unit can see another unit
« on: 11 Jul 2005, 22:22:48 »
how do you check in a script if a unit is looking at another unit, like the same thing they use to make an AI target sombody else.

so like if  unit1 knows about  unit2 and then unit2 ran behind a house then if the script checked at that moment it would return false but if unit2 ran back out into unit1s view then it would return true. does anything like that exist.

nevermind i solved that part but i have another problem,

i made a script that has an AI man wait until he knows about the player and the if the players distance is less the 35m he will run over to the players position, i tried it with the player being friendly to the AI and it works perfect, but when i tried to do it as the enemy(what it was intended for) and pop out around a corner into the AIs view and then go back around the corner so he couldnt shoot me he just stands there looking for me, he dosent run around the corner to my position? i dont know whats wrong.
here it is.


Code: [Select]
_unit = _this select 0

#check1
?_unit knowsabout player > .2:goto"check2"
~.5
goto"check1"


#check2
_dist = _unit distance player
?_dist < 35: goto"next"
~.5
goto "check2"

#next
_unit setbehaviour"combat"
_unit setunitpos"UP"
_unit domove [(getpos player select 0)+5,(getpos player select 1)+0,getpos player select 2]
exit

thanks
« Last Edit: 11 Jul 2005, 23:30:20 by penguinman »

CopyrightPhilly

  • Guest
Re:check if unit can see another unit
« Reply #1 on: 12 Jul 2005, 12:40:45 »
try to ungroup the unit that you want to move, I remember trying to make a script for MP with the domove command and if the unit was part of a group it didnt work...

add the following to your 'next' section
Code: [Select]
[_unit] join grpNull
OR, if you want the unit to kill the player then rejoin the group that he was in...

Code: [Select]
#next
_grp = group _unit
[_unit] join grpNull
_unit setbehaviour"combat"
_unit setunitpos"UP"
_unit domove [(getpos player select 0)+5,(getpos player select 1)+0,getpos player select 2]
@!(alive player)
[_unit] join _grp
exit
« Last Edit: 12 Jul 2005, 12:41:11 by CopyrightPhilly »

Offline penguinman

  • Contributing Member
  • **
  • Money is worthless, just paper, ink, and threads
Re:check if unit can see another unit
« Reply #2 on: 13 Jul 2005, 02:27:15 »
no hes not grouped,  ???

thanks though

Offline Blanco

  • Former Staff
  • ****
Re:check if unit can see another unit
« Reply #3 on: 13 Jul 2005, 03:19:25 »
Not sure if this helps, but Mapfact has released an AI addon for that kind of stuff

http://www.mapfact.gamigo.de/include.php?path=content/download.php&contentid=433
It seems to be a complete alarmsystem...
I haven't tried it yet, but it looks extremely interesting :)

One of the features is...

Code: [Select]
Unites (even vehicles) can find bodies and call an alarm ( depending on the units abilities, the distance and the terrain).

So there must be a line of sight script? (...and the terrain)




« Last Edit: 13 Jul 2005, 03:31:57 by Blanco »
Search or search or search before you ask.