Greetings all!
I have made a semi-functioning script that will order a unit to place a mine, rearm, and then place another mine (I think, did not test the ability to place mines after rearming). It uses a preplaced marker set to "empty" and named "minezone" (without quotes). It still has some problems that I need help with:
1) It needs to check if unit has a mine and if so, count the number of mines, and if none are available then exit (preferably with a sidechat message).
2) It needs to place all of the mines carried in an area close to the target point in a random fashion.
3) After placing all mines carried, it needs to rearm and either continue to place mines as described above until ammo storage is depleted or place more mines when the scipt is called again (not sure which I like better, your comments are welcomed on this part).
4) I would like to have it MP compatible, but if we can get it working correctly here, I will then move it to the MP board and make sure it will work in MP.
Most of my problem is probably due to my lack of understanding of the count sequence (the i = 0, i = a + 1 kind of command). I believe this is why I cannot get the unit to place multiple mines nor can I get them to pick up multiple mines. It could aslo be that I am not sure if a mine is a weapon or if it is ammo so I am not sure how to count it.
Thanks in advance for looking into my problem!
Here is the script:
; Place mine script by Wadmann
; Called using onSingleMapClick but could be used in other ways
; [position to place mines (position), unit to place mines (unit), ammocrate to rearm from (object)]
; exec "place mineIIIa.sqs"
onMapSingleClick {}
1 setRadioMsg "Null"
;2 setRadioMsg "Null"
;3 setRadioMsg "Null"
_pos = _this select 0
_sapper = _this select 1
_ammocrt = _this select 2
_sappos = getpos _sapper
"minezone" setMarkerPos _pos
"minezone" setMarkerType "destroy"
; This is not working correctly!
#minecheck
?(_sapper hasweapon "mine") : goto "placemine"
;?!(sapper1 hasweapon "mine") : goto "nomine"
#placemine
;Should work but commented out for testing purposes
;_rand1 = random 10
;_rand2 = _rand1 - 10
;_movepos = [(_pos select 0)+ _rand2,(_pos select 1)+ _rand2 ,0]
_sapper commandmove _pos
_sapper setspeedmode "Full"
; Not sure if delays are needed, but it worked
~3
?_sapper distance gl1 <= 2 : goto "mined"
~3
#mined
@UnitReady _sapper
_sapper fire ["put", "mine"]
~3
_sapper domove (getpos _ammocrt)
@UnitReady _sapper
?_sapper distance _ammocrt <= .5 : goto "rearm"
; This did not work either (used unit name instead of variable to test)!
;?(sapper1 ammo "mine") == 0 : goto "nomine"
;goto "minecheck"
#nomine
; Did not work. Need help with this part also!
;if (_ammocrt ammo "mine" > 0) then {_sapper commandmove (getpos _ammocrt)} else {sapper1 sidechat "Negative, I am all out of mines."}; exit
#rearm
_sapper action ["Rearm", _ammocrt]
#exit
1 setRadioMsg "Place mine"
; Used during testing.
;2 setRadioMsg "Place mine II"
;3 setRadioMsg "Place mine III"
"minezone" setMarkerType "empty"
exit
Wadmann