Home   Help Search Login Register  

Author Topic: ?can a unit detects an enemy with out a trigger ?  (Read 540 times)

0 Members and 1 Guest are viewing this topic.

redfox

  • Guest
?can a unit detects an enemy with out a trigger ?
« on: 21 Aug 2003, 00:06:00 »
Hello,

Is there a way to make a unit detect a enemy with a script without using a trigger and assign it to a value. The sqs is run from the unit.

Here is what I thought would work.

...................................................
_unit = _this
_enemy = enemy
_unit domove (getpos _enemy)
...................................................

Can someone shed some light. I've looked around at other codes and can find anything



Harkonin

  • Guest
Re:?can a unit detects an enemy with out a trigger ?
« Reply #1 on: 21 Aug 2003, 04:45:21 »
Heres a script from the BAS team used in their demo missions -

; SentryAI.sqs
; by Nagual

_AI = _this select 0

#knows
; hint format ["AI Knows : %1", _AI knowsAbout player]
?!alive _AI : exit
? _AI knowsAbout player < .5                               : goto "knows0"
? _AI knowsAbout player > .5 && _AI knowsAbout player < .9 : goto "knows1"
? _AI knowsAbout player > .5 && _AI knowsAbout player < .9 : goto "knows1"
? _AI knowsAbout player > .9 && _AI knowsAbout player < 2  : goto "knows2"
? _AI knowsAbout player > 2 && _AI knowsAbout player < 2.9 : goto "knows3"
? _AI knowsAbout player > 3 && _AI knowsAbout player <= 4  : goto "knows4"
~6
goto "knows"

#knows0
~1
goto "knows"

#knows1
; Is Alert
; _AI say "rus6"
~1
goto "knows"

#knows2
; Knows Something is around
_AI dowatch getpos player
~4
goto "knows"

#knows3
_AI dotarget player
~4
goto "knows"

#knows4
; Alarm Raised
_AI dofire player
~4
goto "knows"

Harkonin

  • Guest
Re:?can a unit detects an enemy with out a trigger ?
« Reply #2 on: 21 Aug 2003, 04:46:39 »
Heres another BAS script

; guardAI.sqs
; by Nagual
; ***************************************************************************
_AI = _this select 0
_Type = _this select 1
_POS = [(getpos _AI select 0),(getpos _AI select 1),(getpos _AI select 2)]
; ***************************************************************************
?(_type == "static") : goto "static"
?(_type == "staticc") : goto "staticc"
?(_type == "guard") : goto "guard"

; ***************************************************************************
#static
_ai setBehaviour "safe"
_ai setCombatMode "yellow"
dostop _ai
_ai setUnitPos "up"

#knows
; hint format ["AI Knows : %1", _AI knowsAbout player]
?!alive _AI : exit
? _AI knowsAbout player < .5                               : goto "knows0"
? _AI knowsAbout player > .5 && _AI knowsAbout player < .9 : goto "knows1"
? _AI knowsAbout player > .5 && _AI knowsAbout player < .9 : goto "knows1"
? _AI knowsAbout player > .9 && _AI knowsAbout player < 2  : goto "knows2"
? _AI knowsAbout player > 2 && _AI knowsAbout player < 2.9 : goto "knows3"
? _AI knowsAbout player > 3 && _AI knowsAbout player <= 4  : goto "knows4"
~6
goto "knows"

#knows0
~1
goto "knows"

#knows1
_AI domove _POS
~1
goto "knows"

#knows2
_AI dowatch getpos player
~4
goto "knows"

#knows3
_AI dotarget player
~4
goto "knows"

#knows4
; Alarm Raised
_AI dofire player
dostop _ai
~4
goto "knows"
; ***************************************************************************
#staticc
_ai setBehaviour "safe"
_ai setCombatMode "yellow"
dostop _ai
_ai setUnitPos "up"
_ai switchmove "crouch"
#knowsc
; hint format ["AI Knows : %1", _AI knowsAbout player]
?!alive _AI : exit
? _AI knowsAbout player < .5                               : goto "knows0c"
? _AI knowsAbout player > .5 && _AI knowsAbout player < .9 : goto "knows1c"
? _AI knowsAbout player > .5 && _AI knowsAbout player < .9 : goto "knows1c"
? _AI knowsAbout player > .9 && _AI knowsAbout player < 2  : goto "knows2c"
? _AI knowsAbout player > 2 && _AI knowsAbout player < 2.9 : goto "knows3c"
? _AI knowsAbout player > 3 && _AI knowsAbout player <= 4  : goto "knows4c"
~6
goto "knowsc"

#knows0c
~1
goto "knowsc"

#knows1c
_AI dowatch getpos player
~1
goto "knowsc"

#knows2c
_AI dowatch getpos player
~4
goto "knowsc"

#knows3c
_AI dotarget player
~4
goto "knowsc"

#knows4c
; Alarm Raised
_AI dofire player
dostop _ai
~4
goto "knowsc"
; ***************************************************************************
#guard
_ai setBehaviour "safe"
_ai setCombatMode "yellow"
#knowsg
; Checking What AI knows
; hint format ["AI Knows : %1", _AI knowsAbout player]
?!alive _AI : exit
? _AI knowsAbout player < .5                               : goto "knows0g"
? _AI knowsAbout player > .5 && _AI knowsAbout player < .9 : goto "knows1g"
? _AI knowsAbout player > .5 && _AI knowsAbout player < .9 : goto "knows1g"
? _AI knowsAbout player > .9 && _AI knowsAbout player < 2  : goto "knows2g"
? _AI knowsAbout player > 2 && _AI knowsAbout player < 2.9 : goto "knows3g"
? _AI knowsAbout player > 3 && _AI knowsAbout player <= 4  : goto "knows4g"
~6
goto "knowsg"

#knows0g
; Is Alert
; _AI say "rus6"
_AI domove _POS
~4
goto "knowsg"

#knows1g
; _AI say "rus6"
~4
goto "knowsg"

#knows2g

; _AI say "rus14"
_AI dowatch player
~4
goto "knowsg"

#knows3g
; _AI say "rus15"
_AI domove getpos player
_AI dotarget player
~4
goto "knowsg"

#knows4g
_AI domove getpos player
_AI dofire player
_AI setbehaviour "combat"
~4
goto "knowsg"