Decided to give making an airstrike script a go, but I keep getting this error. goto|#|:"Check"': Error invalid number in expression
The code is this...I'll try to make it as quick and easy to understand as possible (bolded indicates the new code I implemented that started to cause problems, italics has been tested to be fine):
?(airstrikecounter>=3): hint "Negative, no assets available are available at the moment"; exit
_keep = airstrikecounter+1
airstrikecounter = 3
This part tries to keep OFP from running the script a second time as a previous one is running. The global airstrikecounter variable is changed to 3 so that if the player decides to run the script again, the script will exit after the first line. Instead of airstrikecounter, the script uses the local variable _keep instead.
[i]
_pos = _this select 0
a = 0
b = 0
c = 1000
hint "AIR SUPPORT\n\nSingle-click on the map to set the enemy's position for friendly strike fighters"
onMapSingleClick {a = (_pos select 0); b = (_pos select 1); c = (_pos select 2); hint "AIR SUPPORT\n\nGPS co-ordinates uploaded, vectoring strike fighters to your position - weapons hot, ETA 30 seconds"}
~30
? (c > 999) : hint "AIR SUPPORT\n\nUnable to comply, airstrike cancelled"; [b]airstrikecounter=_keep[/b]; exit[/i]
Cancellation of airstrike, with the penalty of one airstrike.
[i]goto "Strike"
#Strike
playsound "Flyby"
_amount = 86 [/i] (is the number of cluster bomblets, to be used later on)[i]
_randomX = 90
_randomY = 90
_offsetX = _randomX / 2
_offsetY = _randomY / 2
; X,Y co-ordinates for CBU-103 CEM
_tX = a
_tY = b
[/i]
Some targeting details, getting the position of the mapclick and some cluster munition details. The script is to choose between either a laser-guided bomb strike, or a cluster bomb strike, depending on whether the closest target within 50m of the Mapclick point is a tank or not. If it is a tank, then the script checks 4 spots around the Mapclick point, and if any tank is close enough to each of these positions, an LGB gets dropped onto it (I know, JDAMs are more realistic since they can be multi-targeted....)
If the closest target isn't a tank, then the airstrike is supposed to execute a cluster bomb attack, to take out softer targets.
[i]; Finding armored target for laser-guided bombs
_Target = NearestObject [a,b,c]
_Tank = "Tank" CountType [_Target]
? (_Tank > 0) : _TargetPos = GetPos _Target; _tX = _TargetPos Select 0; _tY = _TargetPos Select 1; goto "LGB"
? (_Tank < 1) : goto "CEM"
; GBU-12D Paveway II release
#LGB
_Target = NearestObject [(a+45),(b+5),c]
_Tank = "Tank" CountType [_Target]
? (_Tank > 0) : _TargetPos = GetPos _Target; _tX = _TargetPos Select 0; _tY = _TargetPos Select 1;_obj = "DSL_a10_GBUBomb" camcreate [(_tX+Random 2),(_tY-Random 2),c+180]
~0.3
_Target = NearestObject [(a-42),(b-10),c]
_Tank = "Tank" CountType [_Target]
? (_Tank > 0) : _TargetPos = GetPos _Target; _tX = _TargetPos Select 0; _tY = _TargetPos Select 1;_obj = "DSL_a10_GBUBomb" camcreate [(_tX+Random 2),(_tY-Random 2),c+180]
~0.3
_Target = NearestObject [(a+8),(b+45),c]
_Tank = "Tank" CountType [_Target]
? (_Tank > 0) : _TargetPos = GetPos _Target; _tX = _TargetPos Select 0; _tY = _TargetPos Select 1;_obj = "DSL_a10_GBUBomb" camcreate [(_tX+Random 2),(_tY-Random 2),c+180]
~0.3
_Target = NearestObject [(a-10),(b-40),c]
_Tank = "Tank" CountType [_Target]
? (_Tank > 0) : _TargetPos = GetPos _Target; _tX = _TargetPos Select 0; _tY = _TargetPos Select 1;_obj = "DSL_a10_GBUBomb" camcreate [(_tX+Random 2),(_tY-Random 2),c+180]
~10
hint "AIR SUPPORT\n\nStrikers report hits in target area, returning back to CAP station. Standby."
[b]goto: "Check"[/b]
#CEM
~3
; Bomblet release
#Loop2
_obj = "BLU97" camcreate [(_tX+Random _randomX-Random _offsetX),(_tY+Random _randomY-Random _offsetY),c+200]
_amount = _amount - 1
~0.005
? (_amount > 0 ) : goto "Loop2"
~10
hint "AIR SUPPORT\n\nStrikers report hits in target area, returning back to CAP station. Standby."
[b]goto: "Check"[/b][/i]
Unfortunately, after the new code was written in, the script doesn't work as described above anymore. The goto: "Check" line seems to be screwing things up - both attacks are executed when only laser guided bombs are supposed to.
The following is the "Check" section...
#Check
~10
airstrikecounter = _keep
?(_keep>=3): hint "AIR SUPPORT\n\nStrikers now winchester on weapons and returning to base. Good luck."; exit
?(_keep<3): hint "AIR SUPPORT\n\nStrikers back on station, ready for another run. Awaiting instructions."; exit
Any help would be greatly appreciated.
Try to enclose code between code tags please, it makes it easier to read if you separate normal text from the code. Planck