Announcement

Collapse
No announcement yet.

Help with Capture Script

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with Capture Script

    I made a capturable POW with an addAction that leads to a .sqs file with the following script:
    [target1 = true;
    publicVariable "target1";
    exit;]

    Then I made a trigger with the condition set to [target1], and activation with the actual capture script:
    [prisoner setCaptive true;[prisoner] join group player;prisoner setPos [2876.44,3508.52,1.96];prisoner removeAction capture]

    Would this still allow only the person who intiated the action to take control of the prisoner, or would this broadcast the script to eveyone, and everyone would have control of him?

  • #2
    Re: Help with Capture Script

    Depends how you used the addAction command. If it is put in the init of the unit, everyone gets the action, and (I think) everyone runs the script once it is triggered.

    If you want only one person to capture them, and the POW to be put in their group, consider a loop to check distance to the player, then add the action in there. Can give some example code if you'd like, it would be the same code I use for object placement and stuff, seems to work well, would be even better for stuff that isn't being dynamically created/destroyed.

    Comment


    • #3
      Re: Help with Capture Script

      Originally posted by beita View Post
      Depends how you used the addAction command. If it is put in the init of the unit, everyone gets the action, and (I think) everyone runs the script once it is triggered.

      If you want only one person to capture them, and the POW to be put in their group, consider a loop to check distance to the player, then add the action in there. Can give some example code if you'd like, it would be the same code I use for object placement and stuff, seems to work well, would be even better for stuff that isn't being dynamically created/destroyed.
      Yes, I put the addAction command in the init of the unit. I don't know how to do the loop thing, so yah could you give me an example? Should the capture script itself be in the .sqs file, and I could just delete the trigger? I want the prisoner to be controlled by the group leader of the player that initiates the action.

      Comment


      • #4
        Re: Help with Capture Script

        Here's some code:

        Code:
        //in init.sqf
        _name = format["%1", player];  //get player name
        
        if (_name != "hostage") then
        {
            _trg = createTrigger ["EmptyDetector", getPos player];
            _trg setTriggerArea [0, 0, 0, false];
            _trg setTriggerActivation ["NONE", "PRESENT", true];
            _trg setTriggerStatements ["player distance hostage < 5 && alive hostage", "hostage_action = player addAction ['Capture', 'hostage.sqf', [], -5, true, true, ''];", "player removeAction hostage_action;"];
        };
        Code:
        //in hostage.sqf
        _id = _this select 2;
        
        hostage setCaptive true;
        [hostage] join group player;
        hostage setPos [2876.44,3508.52,1.96];
        player removeAction _id;

        The first code goes into the init.sqf, second code goes into a file hostage.sqf.

        What this will do is add an action to all players to capture the hostage (variable name hostage, can change to whatever you need) when they are within 5m of the hostage, and the hostage isn't dead. When the action is used, it runs the hostage.sqf file. The hostage won't be able to capture himself (if statement in init.sqf).

        The action won't be attached to the hostage, it will simply be available when within range (5m), attaching it to the hostage would required setting inits and can get very messy ...

        Now, if you have more than 1 hostage, this can work, but it will get messier, and if you have more than 4, I'd do it differently for efficiency's sake.
        Last edited by beita; 03-13-2009, 12:52 AM. Reason: Missed a quote

        Comment


        • #5
          Re: Help with Capture Script

          Originally posted by beita View Post
          Here's some code:

          Code:
          //in init.sqf
          _name = format["%1", player];  //get player name
          
          if (_name != "hostage) then
          {
              _trg = createTrigger ["EmptyDetector", getPos player];
              _trg setTriggerArea [0, 0, 0, false];
              _trg setTriggerActivation ["NONE", "PRESENT", true];
              _trg setTriggerStatements ["player distance hostage < 5 && alive hostage", "hostage_action = player addAction ['Capture', 'hostage.sqf', [], -5, true, true, ''];", "player removeAction hostage_action;"];
          };
          Code:
          //in hostage.sqf
          _id = _this select 2;
          
          hostage setCaptive true;
          [hostage] join group player;
          hostage setPos [2876.44,3508.52,1.96];
          player removeAction _id;

          The first code goes into the init.sqf, second code goes into a file hostage.sqf.

          What this will do is add an action to all players to capture the hostage (variable name hostage, can change to whatever you need) when they are within 5m of the hostage, and the hostage isn't dead. When the action is used, it runs the hostage.sqf file. The hostage won't be able to capture himself (if statement in init.sqf).

          The action won't be attached to the hostage, it will simply be available when within range (5m), attaching it to the hostage would required setting inits and can get very messy ...

          Now, if you have more than 1 hostage, this can work, but it will get messier, and if you have more than 4, I'd do it differently for efficiency's sake.
          Okay thanks alot. I do have another mission that has three units to capture. Would I just copy and paste the first code in the init.sqf file three times (while changing the variable name to hostage1, hostage2, and hostage3 in each block), and create three hostage.sqf files for each unit (again changing the variables for each one)?

          Comment


          • #6
            Re: Help with Capture Script

            That would work, yeah. Better ways to do it, but simpler is sometimes better ..

            Comment


            • #7
              Re: Help with Capture Script

              Hmm, I can't seem to get the script to work. At first I got an error message that I didn't know what it meant. I found that the other quote in the string "hostage" was not there in the test block of the if statement (in the init.sqf code). After placing the other quote, I got no error message, but there was no action on the capturable unit with I tested it.

              I think I'm just gonna use the addAction command again, and put the capture script in the .sqs file running privately so that only the player who initiates the action will be able to take control of the capturable unit. I'll leave out the removeAction command so that if the player who originally had control of the captured unit dies, another player can recapture that unit.

              init line of capturable unit (prisoner):
              [this addAction ["Capture Queen of Hearts", "trigger1.sqs"];]

              trigger1.sqs:
              [
              prisoner setCaptive true;
              [prisoner] join group player;
              prisoner setPos [2876.44,3508.52,1.96];
              hint "The Queen of Hearts has been captured";
              target7=true;
              publicVariable "target7";
              ]

              And target7 is the condition needed to set off the repeatable trigger that activates:
              [prisoner enableAI "MOVE";]

              Since the capturable unit is initially set to [disableAI "MOVE"]

              Just wondering if there would be any possible issues with this that would not make it work as planned on a dedicated server. Would doing this remove the player who intiates the capture action from his current group?
              Last edited by aceking; 03-12-2009, 10:45 PM.

              Comment


              • #8
                Re: Help with Capture Script

                Oh wait, just realized this would not work because of the setPos =(... n/m beta, I'll use your script. Can you find the error? Also, is there a way to make a titletext message sent privately to the player who intiates the action to say "Queen of Hearts has been escorted to the building courtayd", while at the same time, output a hint message that said "Queen of Hearts has been captured" sent globally?

                Comment


                • #9
                  Re: Help with Capture Script

                  Make sure the hostage unit has "hostage" in it's variable name. The local text is easy to do, just put in the hostage.sqf: player groupChat "message"; Change group to side, global, etc.

                  The global message is a little more complicated, you could use a trigger that would listen for a variable change, then print the message on it's change ...

                  ie:

                  Code:
                  //in init.sqf
                  if (isNil "messageSent") then {messageSent = true;};
                  
                  //in hostage.sqf
                  messageSent = true; publicVariable "messageSent";
                  
                  //in a trigger
                  Condition: messageSent
                  On activation: player sideChat "message";

                  Comment


                  • #10
                    Re: Help with Capture Script

                    Yah, I switched "prisoner" variable name to "hostage". This is the error I keep getting.

                    Comment


                    • #11
                      Re: Help with Capture Script

                      Ah, missed a quote in the if condition ...

                      Code:
                      if (_name != "hostage") then
                      That is the proper line. Should work after that ..

                      Comment


                      • #12
                        Re: Help with Capture Script

                        Still doesn't seem to work. I don't get any error messages or anything now, but the action option won't show up for some reason. His variable name is "hostage", and he's got this in his init line:
                        removeAllWeapons this;this disableAI "MOVE";this setPos [(getPos this select 0),(getPos this select 1), .1]

                        Plus he's inside a building. Would any of these factors might contribute to the issue?

                        Comment

                        Connect

                        Collapse

                        TeamSpeak 3 Server

                        Collapse

                        Advertisement

                        Collapse

                        Twitter Feed

                        Collapse

                        Working...
                        X