Announcement

Collapse
No announcement yet.

Civilian Trigger Help

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

  • Civilian Trigger Help

    How can I make a mission end if 2 civilians are killed, its an ROE thing. If any two civvies on a map are killed, then the mission ends.
    |TG|Ghost02
    TG Pathfinder



    "I travel alone through the valley of the shadow of death, yet in my heart I carry no fear, for Gods hands will guide me to Truth and Honor."

  • #2
    Re: Civilian Trigger Help

    You could add this to their init lines:

    Code:
    this addEventHandler ["killed", "endMission 'END2'"];
    It's the quickiest and dirtiest way I can think of doing it, but it should work. Not sure if it'll work outside of a dedicated server though, I've had little luck testing event handlers on listen servers. "END2" in this case would be the mission end you want to execute; typically only a generic "mission successful" ending is used, which is END1. If you use the above code, I suggest creating a debriefing entry for END2 to let people know what happened.

    Comment


    • #3
      Re: Civilian Trigger Help

      Then is would be if any civi was killed, I need it if two are.
      |TG|Ghost02
      TG Pathfinder



      "I travel alone through the valley of the shadow of death, yet in my heart I carry no fear, for Gods hands will guide me to Truth and Honor."

      Comment


      • #4
        Re: Civilian Trigger Help

        Oh, I misread you. In that case, the solution I can come up with is adding the event handler by script to all units on the Civilian side, and monitoring things server-side.

        init.sqf could have something like this:
        Code:
        if(isServer) then {
            civsKilled = 0;
            {
              if(side _x == civilian and _x isKindOf "Man") then {
                    _x addEventHandler ["killed", {execVM "civKilled.sqf"}];
              };
            } forEach allUnits;
        };
        
        "missionFail" addPublicVariableEventHandler {endMission "END2"};
        civKilled.sqf:
        Code:
        civsKilled = civsKilled + 1;
        
        if(civsKilled >= 2) then {
            missionFail = true;
            publicVariable "missionFail";
        };
        If you're using the F2 framework, replace the code in the if(civsKilled >= 2) block with
        Code:
        myEnd = [2] execVM "f\server\f_mpEndBroadcast.sqf";
        , and remove the addPublicVariableEventHandler line from the init.sqf.

        This should work in theory, but I'd have to test it to be sure. Note it won't work if testing from the editor, as public variable event handlers only work on dedicated servers. I can come up with a more refined version in a few hours. I've got the feeling that one of our veteran scripters can probably create a more elegant solution, though.
        Last edited by cctoide; 02-17-2010, 12:52 PM.

        Comment


        • #5
          Re: Civilian Trigger Help

          Ok.
          |TG|Ghost02
          TG Pathfinder



          "I travel alone through the valley of the shadow of death, yet in my heart I carry no fear, for Gods hands will guide me to Truth and Honor."

          Comment


          • #6
            Re: Civilian Trigger Help

            Or:

            1. Give both civies unique names

            2. Create a trigger which is something like:
            Code:
            isServer && !(alive civ_one) && !(alive civ_two)

            |TG-TFP|Jaynus
            Task Force Proteus


            The very existence of flamethrowers proves that sometime, somewhere, someone said to themselves, You know, I want to set those people over there on fire, but Im just not close enough to get the job done."

            Comment


            • #7
              Re: Civilian Trigger Help

              YOU ASSUME, my good man, that there are only two civilians in the map.

              Comment


              • #8
                Re: Civilian Trigger Help

                Theres a whole lot of em.
                |TG|Ghost02
                TG Pathfinder



                "I travel alone through the valley of the shadow of death, yet in my heart I carry no fear, for Gods hands will guide me to Truth and Honor."

                Comment


                • #9
                  Re: Civilian Trigger Help

                  Anyone?
                  |TG|Ghost02
                  TG Pathfinder



                  "I travel alone through the valley of the shadow of death, yet in my heart I carry no fear, for Gods hands will guide me to Truth and Honor."

                  Comment


                  • #10
                    Re: Civilian Trigger Help

                    Originally posted by cctoide View Post
                    Oh, I misread you. In that case, the solution I can come up with is adding the event handler by script to all units on the Civilian side, and monitoring things server-side.

                    init.sqf could have something like this:
                    Code:
                    if(isServer) then {
                        civsKilled = 0;
                        {
                          if(side _x == civilian and _x isKindOf "Man") then {
                                _x addEventHandler ["killed", {execVM "civKilled.sqf"}];
                          };
                        } forEach allUnits;
                    };
                    
                    "missionFail" addPublicVariableEventHandler {endMission "END2"};
                    civKilled.sqf:
                    Code:
                    civsKilled = civsKilled + 1;
                    
                    if(civsKilled >= 2) then {
                        missionFail = true;
                        publicVariable "missionFail";
                    };
                    If you're using the F2 framework, replace the code in the if(civsKilled >= 2) block with
                    Code:
                    myEnd = [2] execVM "f\server\f_mpEndBroadcast.sqf";
                    , and remove the addPublicVariableEventHandler line from the init.sqf.

                    This should work in theory, but I'd have to test it to be sure. Note it won't work if testing from the editor, as public variable event handlers only work on dedicated servers. I can come up with a more refined version in a few hours. I've got the feeling that one of our veteran scripters can probably create a more elegant solution, though.
                    CC already gave you your answer!

                    Comment


                    • #11
                      Re: Civilian Trigger Help

                      Sorry about that, I forgot to test this out earlier. The code above seems to work with no changes, now that I've tried it out on my local server. The only mildly annoying thing is that the game ends practically in the same frame as the second civ is killed, even before the shell casings from the offender hit the ground, which is kind of abrupt. Apart from that, it should work perfectly (on a dedicated server).

                      So, to recap:

                      If you are not using F2

                      Add to init.sqf:
                      Code:
                      if(isServer) then {
                          civsKilled = 0;
                          {
                            if(side _x == civilian and _x isKindOf "Man") then {
                                  _x addEventHandler ["killed", {execVM "civKilled.sqf"}];
                            };
                          } forEach allUnits;
                      };
                      
                      "missionFail" addPublicVariableEventHandler {endMission "END2"};
                      Put into a file called "civKilled.sqf":
                      Code:
                      civsKilled = civsKilled + 1;
                      
                      if(civsKilled >= 2) then {
                          missionFail = true;
                          publicVariable "missionFail";
                      };
                      If you are using F2

                      Add to init.sqf:
                      Code:
                      if(isServer) then {
                          civsKilled = 0;
                          {
                            if(side _x == civilian and _x isKindOf "Man") then {
                                  _x addEventHandler ["killed", {execVM "civKilled.sqf"}];
                            };
                          } forEach allUnits;
                      };
                      Put into a file called "civKilled.sqf":
                      Code:
                      civsKilled = civsKilled + 1;
                      
                      if(civsKilled >= 2) then {
                          myEnd = [2] execVM "f\server\f_mpEndBroadcast.sqf";
                      };
                      (You will have to have the "multiplayer ending controller" part of F2 enabled, see their wiki for more information.

                      Debriefing
                      To let people know why the mission failed, you may want to create a file called "debriefing.html" in the mission folder root, and add the following (this is based on the F2 template):

                      Code:
                      <html>
                      <head>
                      <meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
                      <title>briefing.html/title>
                      </head>
                      
                      <body bgcolor="#FFFFFF">
                      
                      <! --- ----------------------------->
                      <! --- DEBRIEFINGS                -->
                      <! --- ----------------------------->
                      
                      <hr>
                      <br>
                      <h2><a name="Debriefing:End1">Mission success</a></h2>
                      <br>
                      <p>
                      You showed them who's boss!
                      </p>
                      <br>
                      
                      <hr>
                      <br>
                      <h2><a name="Debriefing:End2">Excessive civilian casualties</a></h2>
                      <br>
                      <p>
                      Too many civilians killed!
                      </p>
                      <br>
                      
                      <! --- ----------------------------->
                      <! --- End of DEBRIEFINGS         -->
                      <! --- ----------------------------->
                      
                      </body>
                      </html>
                      You can change the text to your liking, obviously. This is what shows up in the dialog box at the end of a mission. To get the first debriefing to appear properly, make sure whatever you're using to detect mission success triggers the "END1" ending.

                      Comment


                      • #12
                        Re: Civilian Trigger Help

                        Thank you!
                        |TG|Ghost02
                        TG Pathfinder



                        "I travel alone through the valley of the shadow of death, yet in my heart I carry no fear, for Gods hands will guide me to Truth and Honor."

                        Comment

                        Connect

                        Collapse

                        TeamSpeak 3 Server

                        Collapse

                        Advertisement

                        Collapse

                        Twitter Feed

                        Collapse

                        Working...
                        X