Right peeps, here is the first beta of the zone scripting. It's not quite finished and I realise that there are still problems to be sorted out so I will continue to work on them.
I use the island on the south-east corner of Malden for this testing purpose.
I will explain what happens:
init.sqs:
[] exec {me.sqs}
[] exec {zonePlacement.sqs}
[] exec {zoneControl.sqs}
[] exec {dangerZoneCheck.sqs}
exit
Calls four scripts that are covered below.
me.sqs:
#loop
~0.5
{me} setMarkerPos (getPos player)
goto {loop}
Justs moves a marker so it is always above players head for testing purposes. Will also be required in game so players know where they are and don't blindly stumble into a prohibited zone and don't know where to go to get out
zonePlacement.sqs:
triggerH6 setPos [9600,4480]
{markerH6} setMarkerPos [9600,4480]
triggerI6 setPos [10880,4480]
{markerI6} setMarkerPos [10880,4480]
triggerJ6 setPos [12160,4480]
{markerJ6} setMarkerPos [12160,4480]
triggerH7 setPos [9600,3200]
{markerH7} setMarkerPos [9600,3200]
triggerI7 setPos [10880,3200]
{markerI7} setMarkerPos [10880,3200]
triggerI8 setPos [10880,1920]
{markerI8} setMarkerPos [10880,1920]
exit
Moves zone markers & triggers into their exact locations. You will notice that they are a bit off-centre in the editor so this script overrides that.
zoneControl.sqs:
_H6 = [{H6}, triggerH6, {markerH6}]
_I6 = [{I6}, triggerI6, {markerI6}]
_J6 = [{J6}, triggerJ6, {markerJ6}]
_H7 = [{H7}, triggerH7, {markerH7}]
_I7 = [{I7}, triggerI7, {markerI7}]
_I8 = [{I8}, triggerI8, {markerI8}]
_zones1 = [_J6, _I8, _I7, _I6, _H7, _H6]
_zones2 = [_I8, _J6, _I7, _I6, _H7, _H6]
_zones3 = [_J6, _I8, _I7, _H7, _I6, _H6]
_zones4 = [_I8, _J6, _I7, _H7, _I6, _H6]
_zones5 = [_J6, _I8, _I7, _H7, _H6, _I6]
_zones6 = [_I8, _J6, _I7, _H7, _H6, _I6]
_zones7 = [_J6, _I8, _I7, _I6, _H6, _H7]
_zones8 = [_I8, _J6, _I7, _I6, _H6, _H7]
_zones9 = [_I8, _I7, _H7, _H6, _I6, _J6]
_zonesAll = [_zones1, _zones2, _zones3, _zones4, _zones5, _zones6, _zones7, _zones8, _zones9]
_zones = _zonesAll select (random ((count _zonesAll) - 1))
_i = 0
dangerZones = []
~1
hint {Welcome students!\n\nI hope that you are all fit and ready to fight!}
~3
#newZone
hint format [{Warning!\n\nSector Zone %1 will become a forbidden zone in 5 minutes.}, ((_zones select _i) select 0)]
((_zones select _i) select 2) setMarkerColor {colorYellow}
~3
hint format [{Warning!\n\nSector Zone %1 will become a forbidden zone in 20 seconds.}, ((_zones select _i) select 0)]
~3
_k = 10
#loop
hint format [{Warning!\n\nSector Zone %1 will become a forbidden zone in %2 seconds.}, ((_zones select _i) select 0), _k]
~1
_k = _k - 1
? _k > 0 : goto {loop}
hint format [{Warning!\n\nSector Zone %1 is now a forbidden zone.}, ((_zones select _i) select 0)]
((_zones select _i) select 2) setMarkerColor {colorRed}
dangerZones = dangerZones + [(_zones select _i)]
_i = _i + 1
~3
? _i < ((count _zones) -1) : goto {newZone}
hint {There is now only one safe zone remaining. If a winner is not decided in the next 15 minutes, there will be no safe zones and no-one will survive.}
~3
[] exec {killAll.sqs}
exit
First, each grid coordinate (zone) that will be required has the name, trigger and marker stored in their own array.
Then based on this example I have created a number of different orders that the zones can be activated in. I then store all of these in an array and choose one randomly.
Then the newZone loop comes next and is the main bit here. It uses the order of the zones picked randomly above, and tells the player that the next zone will become a danger zone. I specify 5 minutes but change this to whatever length required. You'll notice that it doesn't wait for these times, but I put in 3 seconds just for testing purposes. The zone turns yellow in the map.
It then gives a warning at 20 seconds, then counts down from 10. The zone will then turn red signifying danger zone. This is then added to the global dangerZone array which is made available to another script below.
The script loops until all but one zone remains. The players are then informed that if a winner is not decided in the next 15 minutes then the remaining safe zone will become a danger zone and no-one will win (bye bye neck).
killAll.sqs has not yet be implemented.
Now this next bit is where I am having problems.
dangerZoneCheck.sqs
#wait
~1
? (count dangerZones) == 0 : goto {wait}
#start
~1
_i = 0
victims = []
#collect
~0.1
victims = victims + [list ((dangerZones select _i) select 1)]
_i = _i + 1
? _i < (count dangerZones) : goto {collect}
_i = 0
#death
~0.1
{[_x] exec {dangerZone.sqs}} forEach (victims select _i)
_i = _i + 1
? _i < (count victims) : goto {death}
goto {start}
exit
This basically checks each player for their position. If any are in danger zones then execute dangerZone.sqs for each of them. The problem is that they will keep getting the script executed for them over and over again until they leave the danger zone. I only want it to happen once.
dangerZone.sqs
_unit = _this select 0
hint {Warning!\n\nYou have entered a forbidden zone.\n\nYou have 20 seconds to evacuate or your collar will detonate.}
~10
_i = 10
#countdown
_k = 0
_count = 0
#check
~0.01
? _unit in (victims select _k) : _count = _count + 1
_k = _k + 1
? _k < (count victims) : goto {check}
? _count == 0 : goto {safeZone}
hint format [{%1...}, _i]
~1
_i = _i - 1
? _i > 0 : goto {countdown}
? !(alive _unit) : goto {exit}
_unit setDammage 1
{grenade} camCreate (getPos _unit)
goto {exit}
#safeZone
hint {You have entered a safe zone.}
#exit
exit
This gives a warning and a countdown much like that found when a zone is about to be made dangerous. A check is made during each second of the 10 second countdown to see if the player has entered a safe zone. If not, bye bye player.
This works fine, it is just the repeat calling of this script that is the problem from dangerZoneCheck.sqs.
There also seems to be a problem with the zone detecting for a couple of zones so I'll sort that out. Remember, beta beta beta !!
*edit*edit*edit* stupid stupid me. I had placed the triggers differently to the markers and I just realised. What a monkey. Ok it's just the repeat calls to the dangerZone script that is the problem now.
Also the same zone orders keep getting picked so I'll have to tweak that.