Home   Help Search Login Register  

Author Topic: Detecting if a unit is selected or slotted as a human player or AI?  (Read 1682 times)

0 Members and 1 Guest are viewing this topic.

Offline Marto

  • Members
  • *
I have a mission with 12 units available to select in in the slotting screen.

How do I detect if a human player or AI is selected/slotted?

I have a script that runs on startup that shows each unit and types a message about them like this:

Code: [Select]
_cam camsettarget m72
_cam camsetrelpos [4,4,2]
_cam camcommit 3
@camcommitted _cam
titletext [ format["%1 as the M72 cat - wannabe Aussie...", name m72],"plain down"];
m72 switchmove "EffectWeaponPanic";
~5

_cam camsettarget dragon
_cam camsetrelpos [0,5,4]
_cam camcommit 3
@camcommitted _cam
titletext [ format["%1 as the Dragon operator - he couldn't operate a can opener...", name

dragon],"plain down"];
dragon switchmove "FXStandhip";
~5

_cam camsettarget dragass
_cam camsetrelpos [0,5,4]
_cam camcommit 3
@camcommitted _cam
titletext [ format["%1 as the Dragon ammo bearer - lug that missile you dipstick...", name

dragass],"plain down"];
dragass switchmove "FXdismay";
~5

_cam camsettarget r1
_cam camsetrelpos [0,5,4]
_cam camcommit 3
@camcommitted _cam
titletext [ format["%1 as the Arse End Arnold - haha!", name r1],"plain down"];
r1 switchmove "FXangel";
~5

but if a human or AI is not selected it still shows the text. How do I get it to not show the text if there is no human or AI slotted to that unit?

I have tried 
Code: [Select]
?(alive dude1) like this but it doesnt work:

Code: [Select]
?(alive dude1) : goto "player1"
?(!alive dude2) : goto "player2"

#player1
_cam camsettarget dude1
_cam camsetrelpos [0,5,4]
_cam camcommit 3
@camcommitted _cam
titletext [ format["%1 as the scab-lifter medic", name dude1],"plain"];
dude1 playmove "FXstanddip";
~5

?(alive law) : goto "player2"
?(!alive law) : goto "player3"

#player2
_cam camsettarget law
_cam camsetrelpos [4,4,2]
_cam camcommit 3
@camcommitted _cam
titletext [ format["%1 as the Javelin anti-armour guy - what a tosser...", name law],"plain

down"];
law playmove "lyingstillv1";
~5

#player3
_cam camsettarget dude3
_cam camsetrelpos [0,4,2]
_cam camcommit 3
@camcommitted _cam
titletext [ format["%1 as the Javelin ammo bearer", name dude3],"plain down"];
dude3 playmove "effectstandsalute";
~3

etc....


Should I be using
Code: [Select]
?not local dude1: goto "player1"
or

Code: [Select]
?dude1 == player : goto "player1"
or something else???

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
something like this will check if the unit is the player..

? (player dude1) : goto player1

gawd I hate sqs :D
Xbox Rocks

Offline Marto

  • Members
  • *
Thanks hoz,

Ok figured it out, in the script:

Code: [Select]
?(Player == radio): radio_Alive = true; Publicvariable "radio_Alive"
?(Player == m136): m136_Alive = true; Publicvariable "m136_Alive"
?(Player == m72): m72_Alive = true; Publicvariable "m72_Alive"
?(Player == dragon): dragon_Alive = true; Publicvariable "dragon_Alive"
etc etc.....

#player6x

?(radio_Alive) : goto "player6"
goto "player7x"

#player6
_cam camsettarget radio
_cam camsetrelpos [4,4,2]
_cam camcommit 3
@camcommitted _cam
radio playmove "combattotreated";
titletext [ format["%1 as the radio operator - this guy couldn't get bombs on target...", name radio],"plain down"];
~5

#player7x

?(m136_Alive) : goto "player7"
goto "player8x"

#player7
_cam camsettarget m136
_cam camsetrelpos [4,4,2]
_cam camcommit 3
@camcommitted _cam
radio playmove "combattotreated";
titletext [ format["%1 as the anti-armour specialist - what a norbert...", name m136],"plain down"];
~5

#player8x

?(m72_Alive) : goto "player8"
goto "player9x"

#player8
_cam camsettarget m72
_cam camsetrelpos [4,4,2]
_cam camcommit 3
@camcommitted _cam
titletext [ format["%1 as the M72 cat...", name m72],"plain down"];
m72 switchmove "EffectWeaponPanic";
~5

etc etc...

And in the init.sqs:

Code: [Select]
radio_Alive=false
m136_Alive=false
m72_Alive=false
dragon_Alive=false
etc etc...