No announcement yet.

AI Capture Script

  • Filter
  • Time
  • Show
Clear All
new posts

  • AI Capture Script

    Hey, I was wondering if anybody had a good capture script that I could use to replace the current one that I have for Operation Black Falcon. The current one that I am using only works when the AI is captured only by a player who has a command interface (But for some reason, the newest version of my mission doesn't seem to work even still with that condition, whereas previous versions did). If the AI was captured by a player without a command interface, then it gets bugged and can't move. The reason is that I have the AI in a building (so I set it to [this disableAI "MOVE"]), and after it becomes captured, then a trigger sets off so that the "MOVE" function is enabled again (again, this isn't working in the newest version for some reason). Then the AI get teleported at outside the building. Here is the current structure of the script:

    AI = prisoner:
    this setPos [2879.96, 3538.38, 3.5065]; removeAllWeapons this;this setUnitPos "UP";this disableAI "MOVE";capture=this addAction ["Capture Queen of Hearts","trigger5.sqs"]

    ?!(alive prisoner): goto exit
    prisoner setCaptive true;
    [prisoner] join group player;
    prisoner setPos [2866.36,3529.96,1.88];
    commandStop prisoner;
    publicVariable "target7";
    titletext ["The Queen of Hearts has been escorted outside the building entrance","plain"];

    trigger with target7 condition:
    prisoner removeAction capture;prisoner enableAI "MOVE";hint "The Queen of Hearts has been captured"

    I was hoping someone might be able to find a way so that anybody, regardless of who has the command interface, could capture the AI and make it join that player's group.

  • #2
    Re: AI Capture Script

    Maybe instead of the line:

    commandStop prisoner;


    prisoner doMove (getPos prisoner);


    • #3
      Re: AI Capture Script

      In multiplayer the action code is not being run on the server which would explain why nothing happens.

      The client cannot effect anything on the prisoner because the code needs to be on the server to get the prisoner to do anything. Im guessing the times it worked you were not running a dedicated server but running a local server and the leader was able to capture the prisoner in that case.

      The solution: there needs to be a script running on the server to listen for a variable to change and then run the code from your script. The problem is that the player who reaches the prisoner needs to be recognized on the server as well.

      So in this example I set up an array of all the players for this:
      in init.sqs-
      allplayers =[0,player1,player2]
      so all your players need names and need to be listed in the array
      (its important to have that zero in there....)
      Then make a variable something like this
      rescuedby= 0
      put this line in the init as well...
      [] exec "service.sqs"

      there needs to be a "service" script on the server to listen for rescuedby variable to change and then do what is needed when the variable changes.....

      ?! isserver:exit
      ? rescuedby != 0:goto "Captured"
      goto "Start"


      _player = allplayers select rescuedby

      [_player] exec "trigger5.sqs"


      in trigger5.sqs

      _player = this select 0
      then the rest of your script should work but use the _player local variable instead of the player global value.

      Your action needs to point to another script also:

      action.sqs (so make this script and point to it in the prisoners init code in the editor)

      _counter = 1

      ? _counter > count allplayers + 1:goto "Error"
      ? player != allplayers select _counter: goto "Skip"
      rescuedby = _counter
      publicvariable "rescuedby"


      _counter = _counter + 1
      goto "Start"

      hint "error, could not find player in list....."

      So now im using publicvariable to get the server to run a script like an on off switch, but also in that variable Im telling the server which player to use as _player by giving the publicvariable a check against the player list.

      I probably made some mistakes in the above code but the principle is sound. Let me know if you need more help or clarification. Theres also different ways to do the same thing but this is my preferred method.




      TeamSpeak 3 Server


      Twitter Feed