Home   Help Search Login Register  

Author Topic: Place mine(s), rearm, and do it again?!?  (Read 1546 times)

0 Members and 1 Guest are viewing this topic.

Offline Wadmann

  • OFPEC Patron
  • ****
  • I'm the next evolutionary step after a llama!
Place mine(s), rearm, and do it again?!?
« on: 20 Apr 2005, 18:40:49 »
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:

Code: [Select]
; 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
Check out my Camouflage Collection! New items added 31 July 2005.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Place mine(s), rearm, and do it again?!?
« Reply #1 on: 20 Apr 2005, 19:27:27 »
1.   Try a hasWeapon or ammo command.

Mines are very peculiar objects and do not respond to some commands.     A mine clearance script is considerably more difficult than a mine placing one:  if you want mine clearance talk to Sui or me, we've each done one using different techniques and giving slightly different results.

When you want to define a variable it must go on the left hand side of the = sign.

_i = 0
#loop
_i = _i + 1        <------ _i + 1 = _i  would not work
? _i > 3 : exit
blah blah
goto "loop"



Plenty of reviewed ArmA missions for you to play

bluehand

  • Guest
Re:Place mine(s), rearm, and do it again?!?
« Reply #2 on: 21 Apr 2005, 00:40:26 »
No idea of the solution, but I certainly admire the problem !

Like you, I couldn't figure out how to count the mines in a crate, or carried by a dude, so I just used a counter - it worked and looked ok, but doesn't deplete the crate.  You could maybe use clearMagazineCargo and just not put any mines in the crate.

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:Place mine(s), rearm, and do it again?!?
« Reply #3 on: 21 Apr 2005, 05:16:08 »
This is your main problem here:

Code: [Select]
; This is not working correctly!
#minecheck
?(_sapper hasweapon "mine") : goto "placemine"
;?!(sapper1 hasweapon "mine") :  goto "nomine"

This is going to sound a bit strange, but as far as OFP is concerned a mine is not a weapon.
The weapon used when you place a mine is called 'put'. (same weapon satchel charges use).

I suggest checking in the magazines instead:
Quote
#minecheck
if ("Mine" in (magazines _sapper)) then {goto "placemine"} else {goto "nomine"}

Note that the "Mine" is case sensitive. Eg. if you try to use "mine" it won't work. (This is one of the few strings in OFP that is case sensitive :P)

Use a smiliar thing when re-arming the guy...
Let us know how you go ;)

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Place mine(s), rearm, and do it again?!?
« Reply #4 on: 21 Apr 2005, 10:22:44 »
Quote
I couldn't figure out how to count the mines in a crate,
Don't worry, nobody has figured out how to discover what's in an ammo crate.
Plenty of reviewed ArmA missions for you to play

Offline Wadmann

  • OFPEC Patron
  • ****
  • I'm the next evolutionary step after a llama!
Re:Place mine(s), rearm, and do it again?!?
« Reply #5 on: 21 Apr 2005, 16:22:00 »
Thanks all for the replies!

As school will keep me busy through the week, I will not be able to test the suggestions posted until the weekend. If anyone else has any suggestions, please keep posting them!

@bluehand
Quote
No idea of the solution, but I certainly admire the problem !

We all know that misery loves company! ;D

I will look at your solution to the problem over the weekend and see about incorporating some of your ideas into my script.

@macguba
Quote
Mines are very peculiar objects and do not respond to some commands.

So true! I searched many times for info on mines and found very little. They seem to be sort of a mystery object to use as very little has been documented about them. A good mine tutorial is about three years overdo if you ask me!

Quote
_i = 0
#loop
_i = _i + 1        <------ _i + 1 = _i  would not work
? _i > 3 : exit
blah blah
goto "loop"

Thanks for that bit of code! I have seen it used but the concept of applying it still eludes me! I think that is what is missing from my script to get multiple mines placed but as with so many other problems in OFP, there may be more than one solution to a problem (Sui's posted code may work instead). I will see which code I can get to work and post my findings later.

@Sui
Quote
if ("Mine" in (magazines _sapper)) then {goto "placemine"} else {goto "nomine"}

Thanks sooo much for that line! All too often I know the commands but I cannot get the syntax right.

Quote
Note that the "Mine" is case sensitive. Eg. if you try to use "mine" it won't work.

Is this a constant truth or are there exceptions to this rule? I seem to remember that little tidbit somewhere but "mine" with a lower case "m" did work in the action commands. ???

Perhaps it only applies when checking for the ammunition "Mine". I will try to check and see where "mine" does and does not work (as opposed to "Mine") and post my findings over the weekend or early next week.  

I better get back to work but thanks again to all that have helped!

Wadmann


Check out my Camouflage Collection! New items added 31 July 2005.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:Place mine(s), rearm, and do it again?!?
« Reply #6 on: 21 Apr 2005, 19:28:48 »
I was playing with action commands a while ago and the lower case 'mine' works ok.

So, it must be only in certain commands that it is case-sensitive.


Planck
I know a little about a lot, and a lot about a little.

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:Place mine(s), rearm, and do it again?!?
« Reply #7 on: 22 Apr 2005, 05:26:53 »
In fact, by general rule OFP is not case sensitive.
The code I posted is one of the very few instances when it is...

I think it's because it's comparing a string to another string... (I guess?).

You have no idea how much hair I pulled out before I worked that out though... :P

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Place mine(s), rearm, and do it again?!?
« Reply #8 on: 22 Apr 2005, 10:06:17 »
In general, even strings are not case sensitive - you can use "m16" or "M16".   However there are exceptions so I always assume strings are case sensitive.

I think - although I'm not absolutely sure - that other commands are not case sensitive.
Plenty of reviewed ArmA missions for you to play