Jump to content
Sign in to follow this  
Gidcon

Need help on who detects enemy and who is enemy

Recommended Posts

Need some help here..

Came up with this last night but can't get it to work...

In theory I would like to enter 4 inputs

1. West side group.

2. East side soldier

3. East sides backup 1

4. East sides backup 2

Would check to c if East side soldier has seen enemy and when he does see the enemy to assign backup 1 and 2 to him and order them to target the enemy.

Here is the script

;_Wgrp is West group

;_Esold is East soldier

;_BkupA is Backup soldier A

;_BkupB is Backup soldier B

_Wgrp = _this select 0

_Esold = _this select 1

_BkupA = _this select 2

_BkupB = _this select 3

;Count Units

_WgrpVektor = Units _Wgrp

_numWgrp = count _WgrpVektor

_i = 0

;See if _Esold knowsabout units in West group

;and go to selector if so. and if not wait 5 sec

;and Redo

#Update

_WVek = _WgrpVektor select _i

?(_Esold knowsAbout _WVek) > 2 : goto "Selector"

~1

_i = _i + 1

?(_i < _numWgrp) : goto "Update"

~5

_i = 0

goto "Update"

;BkupA and BkupB join _Esold

;_Esold gives commandTarget to target seen

#Selector

_BkupA join _Esold

_BkupB join _Esold

_Esold commandTarget _WgrpVektor select _i

exit

I put it in the initialization field of unit "e1"

and place a member of west sides unit "w1" in front of him

and he just keeps going throught the loop...

Do I have the sytax wrong in this line or what

[/b]?(_Esold knowsAbout _WVek) > 2 : goto "Selector"

Share this post


Link to post
Share on other sites

I tried it an had no problems, though the join command was wrong.

I used this script:

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">

;_Wgrp is West group

;_Esold is East soldier

;_BkupA is Backup soldier A

;_BkupB is Backup soldier B

_Wgrp = thegroup

_Esold = e1

_BkupA = b1

_BkupB = b2

;Count Units

_WgrpVektor = Units _Wgrp

_numWgrp = count _WgrpVektor

_i = 0

;See if _Esold knowsabout units in West group

;and go to selector if so. and if not wait 5 sec

;and Redo

#Update

_WVek = _WgrpVektor select _i

_bob = _Esold knowsAbout _WVek

hint format ["e1 knows about %1 %2", _WVek, _bob]

?(_Esold knowsAbout _WVek) > 1 : goto "Selector"

~1

_i = _i + 1

?(_i < _numWgrp) : goto "Update"

~1

_i = 0

goto "Update"

;BkupA and BkupB join _Esold

;_Esold gives commandTarget to target seen

#Selector

hint "ghg"

[_BkupA] join _Esold

[_BkupB] join _Esold

_Esold commandTarget _WVek

exit<span id='postcolor'>

Note, I modified the names at the top.

RED

Share this post


Link to post
Share on other sites

Ahhh... hint thingy there.. I had my units set wrong... it was sending back (null) for west side...

Can't thank u enuff..

Share this post


Link to post
Share on other sites

Here's a question:

What if I wanted the script to detect any West units, not just a single group? For example if I have 20 groups on the West side, and I want a single East unit to target whatever group approaches, is there a fast way of using "KnowsAbout" ?

Share this post


Link to post
Share on other sites

Name at least one unit in each group (for example leaders of these groups) and exec this script.

[unit,[leader1,leader2,...]] exec "script.sqs"

where unit is detecting soldier

and leaderx are leaders of enemy groups.

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">

;[unit,[leader1,leader2,...]] exec "script.sqs"

; _Es searching soldier

; _Wg array of enemy group leaders

_Es=_this select 0

_Wg=_this select 1

_i=count _Wg

?_i<=0:exit

_groups=[]

#loop

_i=_i-1

_groups=_groups+[group (_Wg select _i)]

?_i>0:goto "loop"

#check

_i=count _groups

#groups

_i=_i-1

;_Wg array of units in selected group

_Wg=units (_groups select _i)

_ii=count _Wg

#units

_ii=_ii-1

?(_Es knowsAbout (_Wg select _ii))>2 :goto "detected"

?_ii>0:goto "units"

?_i>0:goto "groups"

~5

goto "check"

#detected

;add some actions here

exit<span id='postcolor'>

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×