Home   Help Search Login Register  

Author Topic: Place mines, rearm, place more mines?!?  (Read 916 times)

0 Members and 1 Guest are viewing this topic.

Offline Wadmann

  • OFPEC Patron
  • ****
  • I'm the next evolutionary step after a llama!
Place mines, rearm, place more mines?!?
« on: 19 Apr 2005, 17:26:40 »
Greetings to anyone that has bothered to read my request! :P

I am trying to get an AI unit to place mines in an area defined by onsingleMapclick, rearm at an ammo crate and place more mines until the crate is empty.

All that I have been able to accomplish on my own was to get the unit to place a single mine and nothing more!

Basically, either by hardcoding into the script (global variable e.g. sapper1) or by an element of an array (local variable e.g. _sapper = _this select 1), define an AI unit to place as many mines as he currently carries at/near/around an area determined by an "onsingleMapclick", rearm at an ammocrate (again either by local or global variable), and then place more mines in the same general area until there are no more mines available.

I would have posted the script that I made, but as it does not work properly I would like to see if someone takes a different approach to the problem without being distracted by my failed attempt! ;D

BTW, I am aware that this concept is already ingame if you are the commander of the group, but I wanted this to work if I am not the leader of the group or if I wanted to have a unit from another group do the dirty work.

As if I were not asking enough already, the script should be MP compatible.

Any takers?

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

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:Place mines, rearm, place more mines?!?
« Reply #1 on: 19 Apr 2005, 18:05:43 »
Ugh. Was just about to post I could do it, shouldn't be too hard untill I saw the MP compatible thingy. :-\

:beat: *Gets Shot* :beat:

Offline Wadmann

  • OFPEC Patron
  • ****
  • I'm the next evolutionary step after a llama!
Re:Place mines, rearm, place more mines?!?
« Reply #2 on: 20 Apr 2005, 00:06:12 »
@dmakatra

I did say should be MP compatible, so if you think you could knock out the basic script, I will worry about the MP part. ;)

I would like to see what I did wrong (could be that I have no clue how to use the count command so no i = 0, _var = i -1 when trying to determine the number of mines the unit has).

Quite honestly, I rarely think about MP compatiblilty when making missions, but they all seem to work when I play on a LAN with me bro. I just figured if I was asking for something, I may as well ask for it on served on fine china instead of a paper plate! ;D

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

Offline Wadmann

  • OFPEC Patron
  • ****
  • I'm the next evolutionary step after a llama!
Re:Place mines, rearm, place more mines?!?
« Reply #3 on: 20 Apr 2005, 18:17:16 »
As no one else rose to the challenge, I had to work it out myself (at the expense of studying my "Reporting & Analyzing Stockholders' Equity  :().

Here is a semi-functioning version. I am going to move this to the General board to fix some commented problems and then, if necessary, on to MP Scripting to ensure that it will work in MP.

Here it is:

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"
;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 Roni

  • Members
  • *
  • Play the Game !
Re:Place mines, rearm, place more mines?!?
« Reply #4 on: 26 Apr 2005, 01:36:34 »
Hi W !

Have you considered simply faking it ?  The loon doesn't actually have to place the mine, all he has to do is move to the box, crouch, move to the click point, crouch, (create a mine at that point), back to the box etc for "x" cycles.

You could even make the "click point" a little different each time so that he places all the mines around the target spot and not all at the same point.  If you really wanted to link it to the number of mines in the box then you could use a count command and take away one mine each time the loon moves next to the box.

Not perfect I know but should be pretty easy to implement.

Just my two cents.



roni