Hi, another stupid question, I looked around here and tried some different stuff out, but can't get this working, heres the problem:
I'm making this rather large co-op mission designed for play on a LAN with a dedicated server. The west spawn at the airfield at the far east end of Tonal island, and work their way west until the entire island is cleared. The enemies are only grouped around the dwellings and bases, so it shouldn't be too hard to complete it.
The only problem I could forsee is if 2 hours into this, someone on the LAN crashed, we could either restart the WHOLE thing from scratch or just go on without them, which wouldn't be too fun =(
So I figured I would divide the island by the 14 larger map columns (the single letter ones, starting at D and going to Q) and added a parameter "Clear To:" then all the columns. I have the parameter working, and I have the markers (14 large 675x8100 default red-transparent markers, slightly overlapping) and triggers (same size, set for repeatedly when resistance is not present) set up and working as far as I know. The only real difficult bit of scripting is the actual clearing of the units when the clear to zone is selected. For now I am only testing with zones D and E, and have placed a single enemy unit down the airfield facing away from me, but within sight of my player. In his init field I have the following:
unitsInZoneD = unitsInZoneD + units this
figuring for each unit I place in whichever zone I'll add them to an array with alll the other units in the zone, then when it is time to delete them, do a little "deleteVehicle _x" forEach unitsInZoneD and be done with it. WRONG!
My test setup:
Myself as player, on init:
[] exec "init.sqs"
resistance government HD soldier within sight of me, on init:
unitsInZoneD = unitsInZoneD + units this
file description.ext:
respawn=3;
respawndelay=5;
titleParam1 = "Clear To:";
valuesParam1[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14};
defValueParam1 = 1;
textsParam1[] = {"D","E","F","G","H","I","J","K","L","M","N","O","P","Q"};
file init.sqs:
? param1 == 1 : goto "clearZoneD"
? param1 == 2 : goto "clearZoneE"
? param1 == 3 : goto "clearZoneF"
? param1 == 4 : goto "clearZoneG"
? param1 == 5 : goto "clearZoneH"
? param1 == 6 : goto "clearZoneI"
? param1 == 7 : goto "clearZoneJ"
? param1 == 8 : goto "clearZoneK"
? param1 == 9 : goto "clearZoneL"
? param1 == 10 : goto "clearZoneM"
? param1 == 11 : goto "clearZoneN"
? param1 == 12 : goto "clearZoneO"
? param1 == 13 : goto "clearZoneP"
? param1 == 14 : goto "clearZoneQ"
#clearZoneE
[unitsInZoneE] exec "removeunits.sqs"
[2, 1, 0] exec "setzone.sqs"
#clearZoneD
[unitsInZoneD] exec "removeunits.sqs"
[1, 1, 0] exec "setzone.sqs"
#mainLoop
? getMarkerColor "markD" == "ColorGreenAlpha" : [unitsInZoneD] exec "removeunits.sqs"
? getMarkerColor "markE" == "ColorGreenAlpha" : [unitsInZoneE] exec "removeunits.sqs"
~2
goto "mainLoop"
file setzone.sqs:
_zone = _this select 0
; zone table:
; D E F G H I J K L M N O P Q
; 1 2 3 4 5 6 7 8 9 10 11 12 13 14
_state = _this select 1
; 0 is enemy-occupied, 1 is cleared
_report = _this select 2
; 0 is 'silent mode', 1 hints the change
? _zone == 1 : goto "zoneD"
? _zone == 2 : goto "zoneE"
? _zone == 3 : goto "zoneF"
? _zone == 4 : goto "zoneG"
? _zone == 5 : goto "zoneH"
? _zone == 6 : goto "zoneI"
? _zone == 7 : goto "zoneJ"
? _zone == 8 : goto "zoneK"
? _zone == 9 : goto "zoneL"
? _zone == 10 : goto "zoneM"
? _zone == 11 : goto "zoneN"
? _zone == 12 : goto "zoneO"
? _zone == 13 : goto "zoneP"
? _zone == 14 : goto "zoneQ"
#zoneD
? _state == 1 : "markD" setMarkerColor "ColorGreenAlpha"
? _state == 1 : if (_report == 1) then {hint "Zone D clear."}
? _state == 0 : "markD" setMarkerColor "ColorRedAlpha"
? _state == 0 : if (_report == 1) then {hint "Enemies detected in Zone D."}
exit
#zoneE
? _state == 1 : "markE" setMarkerColor "ColorGreenAlpha"
? _state == 1 : if (_report == 1) then {hint "Zone E clear."}
? _state == 0 : "markE" setMarkerColor "ColorRedAlpha"
? _state == 0 : if (_report == 1) then {hint "Enemies detected in Zone E."}
exit
file removeunits.sqs:
; removeunits.sqs
; takes in an array of units and destroys them all
"deleteVehicle _x" forEach _this select 0
exit
When I test it, I first manually delete Invasion of Tonal.bas_i1.pbo to ensure I'm not running an old version of the mission, then I launch OFP, open the mission editor, export to MP missions with the same name, exit the editor, host a local server, set Clear To to E, and play. I know the scripts are working period because the markers change from the default transparent red to transparent green, signifying that they are clear (I have not yet put triggers down that would set enemy-containing zone D to red again, waiting until i get this working).
The actual problem comes when I start the mission, and that enemy guy is STILL THERE. No errors are displayed or anything.
And if you see any ways I can further optimize this process, please let me know, this is the first time I've ever scripted something except for some camera stuff a year ago.
Thanks,
-Kyle