OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Joiner on 12 Dec 2008, 18:33:35
-
Hello everyone!
First, a description of the situation:
In my mission, I have an area with a marker on it. When an East soldier enters the area, the marker becomes red, when a West soldier enters it, the marker becomes blue, when both East and West guys are inside, the marker becomes yellow. If East kills all West soldiers inside the area, and at least one East soldier stays in the area, the marker becomes red after being yellow, and vice versa, if West wins the duel.
All this is done by the following triggers:
1. A trigger activated by East. On activation: activeEast = true;
2. A trigger activated by West. On activation: activeWest = true;
3. A trigger with the condition "activeEast". On activation: "marker1" setMarkerColor "ColorRed";
4. A trigger with the condition "activeWest". On activation:"marker1" setMarkerColor "ColorBlue";
5. A trigger with the condition "activeEast and activeWest". On activation: "marker1" setMarkerColor "ColorYellow";
6. A trigger with the condition "activeEast and west countSide list trigger1 < 1;". On activation: "marker1" setMarkerColor "ColorRed";
7. A trigger with the condition "activeWest and east countSide list trigger1 < 1;". On activation: "marker1" setMarkerColor "ColorBlue";
Now the problem:
Everything works fine except for one thing: the marker does not become red after beying yellow (that is, after West soldiers are eliminated in the area, provided that East is still in the area). Any idea can be wrong? Please help.
P.S. The marker does become blue after East is eliminated and West is still in the area.
-
These two trigger conditions...
6. A trigger with the condition "activeEast and west countSide list trigger1 < 1;". On activation: "marker1" setMarkerColor "ColorRed";
7. A trigger with the condition "activeWest and east countSide list trigger1 < 1;". On activation: "marker1" setMarkerColor "ColorBlue";
...are both counting the list from the same trigger: trigger1
Is that right? Should trigger 6 be counting the list form a different trigger?
-
You should be able to do it with fewer triggers, if you add a few more conditions
1. A trigger activated by East. On activation: activeEast = true; On de-activation: activeEast = false;
2. A trigger activated by West. On activation: activeWest = true; On de-activation: activeWest = false;
3. A trigger with the conditions: "activeEast && !activeWest". On activation: "marker1" setMarkerColor "ColorRed";
4. A trigger with the conditions: "activeWest && !activeEast". On activation: "marker1" setMarkerColor "ColorBlue";
5. A trigger with the conditions: "activeEast && activeWest". On activation: "marker1" setMarkerColor "ColorYellow";
PS. Make sure all triggers activate Repeatedly, and that the initialisation sets both activeWest and activeEast to false.
-
Instead of messing with 1968178629729 triggers just put one trigger activated by "Anyone" instead of a specific side and then use the following script passing the thisList variable and the marker name as parameter:
//USAGE: [unit array, marker] execVM "checkSide.sqf"
//local function used to check how many units are alive in an array
_areAlive =
{
_count = 0;
{
if (alive _x) then {_count = _count + 1};
}
forEach _this;
_count
};
_unitArray = _this select 0;
_marker = _this select 1;
_currentAliveUnits = _unitArray call _areAlive; //store the current number of alive units who activated the trigger
//execute the script until all the units that activated it are alive
while {_currentAliveUnits > 0} do
{
_countEast = 0;
_countWest = 0;
//check what kind of units have activated the script (east and/or west)
{
if (side _x == east and alive _x) then {_countEast = _countEast + 1};
if (side _x == west and alive _x) then {_countWest = _countWest + 1};
}
forEach _unitArray;
if (_countEast > 0 and _countWest > 0) then {_marker setMarkerColor "ColorYellow"}
else
{
if (_countEast > 0) then
{
_marker setMarkerColor "ColorRed";
};
if (_countWest > 0) then
{
_marker setMarkerColor "ColorBlue";
};
};
//if someone is killed need to recheck the units side and eventually reset the marker color
waitUntil{_unitArray call _areAlive != _currentAliveUnits};
//update the number of alive units
_currentAliveUnits = _unitArray call _areAlive;
};
basically you make a trigger activated repeatedly and activated by "Anyone". In the activation field write
call{[thisList, "marker1"] execVM "checkSide.sqf"}
I tested it and it should work, anyway if you experience any bugs tell me and I will try to fix them.
EDIT: I forgot to say that this is a general purpose script so if you have more than one marker of that kind you have just to put a trigger of the same kind of the one above and just change the marker name in the call arguments (example: if you have another marker called "marker2" create another activation trigger for that marker and write call{[thisList, "marker2"] execVM "checkSide.sqf"}). Also do not copy/paste the script from the forum cause sometimes it messes up with lines if there are script comments (those lines starting with // ) so just write it by yourself (if you copy/paste and it gives you some syntax errors when you run it, it means the forum has messed it up).
-
Thanks a lot for your hints guys, I achieved the needed effect with your help!
-
You gotta love this site. 3 helpful replies within 2 hours! :D
-
I'm just curious: did you try the script or you used the trigger solution?
-
You gotta love this site.
Yeah, sure! :)
did you try the script or you used the trigger solution?
I used triggers - the first hint helped me fix the problem, the second helped me reduce the number of triggers. The script is a very smart solution - I will use it as well, but not in this mission. Thanks again! :)
-
I asked that because I think that the trigger solution doesn't work for a situation like this: the player gets rid of all the enemies and the marker becomes blue, but after that other enemies enters the area and the marker has to become yellow again. But I might mistake.
-
the player gets rid of all the enemies and the marker becomes blue, but after that other enemies enters the area and the marker has to become yellow again
Yeah, that's what I need. I need the marker to become yellow each time there are both sides in the area.
-
If you use the script that stuff works. I tried it.
-
OK, thanks.