Home   Help Search Login Register  

Author Topic: Scripted Waypoint = Satchel Placement  (Read 695 times)

0 Members and 3 Guests are viewing this topic.

Offline Wadmann

  • OFPEC Patron
  • ****
  • I'm the next evolutionary step after a llama!
Scripted Waypoint = Satchel Placement
« on: 26 Jun 2003, 08:04:37 »
After reading Chris Death's excellent thread (http://www.ofpec.com/yabbse/index.php?board=6;action=display;threadid=10697) on scripted type waypoints, which should be a tutorial IMHO, I was inspired to attempt my first script! Although I do not know if it is necessary to use a scripted waypoint, with CD being so knowledgable on the subject he may want to chime in. I did not tag on to his thread as I did not want to dilute it's content with my issues.

A quick rundown on the mission so you will understand what I am attempting:

    A seven man squad LALOs in and searches for "hidden" ammo dump. A waypoint at the camp originally was a S&D and I had been searching for a script that would have the (not always human) leader command the remaining troops to go to seven huts and place satchel charges then detonating them at a waypoint a short distance away and again the leader may or may not be AI controlled. Having searched OFPEC for a script that was already made and not finding one, I decided to give it a shot. Although untested, I cannot believe that it will work as is. As I know very little about scripting and even less about scripted waypoints, I have labled what I was attempting to do via a scipted waypoint and I would think (hope) that if this method is not going to work, then a true script could be created from this idea. After the laughter dies down, just rember that even a journey of a thousand miles begins with one step and I see a llllllloooooonnnnnnggggggg road ahead of me! :P

Code: [Select]
;owner of waypoint (group)
_group = _this select 0

;Not sure what I am doing here-copied from CD demo script
_i = 0

; Variable _max equals the number of units in owner of waypoint's group
_max = WEST countside units _group

;Fluff
leader _group sidechat "Take out the the huts with your satchel charges!"

~3

;Here I want to have each man in the group that is left to set a satchel in a hut created by map.
;There are 7 different huts that are potential targets. I want to use objectID to define targets in no
;particular order. Do I make an array of targets ["object12345","object12346","object12347"] or the target
;locations' array [(getpos object12345 select 0),(getpos object12345 ;select1),(getpos ;object12345 select2)]?
;This is where I am lost. Any and all help appreciated here.


#demoloop

;I now want all west units left alive to place a satchel at the appropiate objectID. How do I tell
;each unit left in group to go to any available object and place satchelcharge?

;I think that this breaks group down to individuals
_demoman = units _group select _i

;I was thinking that I would have to create 7 different move to positions but then realized that if I
;do not have enough units left alive, script may crash (as if this script would work anyay)
_move_pos1 = [(getpos object12345)]

;move first unit to first hut
_demoman commandmove _move_pos1


~0.5

;Wait until unit is in position
@UnitReady _demoman

;place satchel charge
_demoman fire ["put","pipebomb"]

;not sure if this is needed
_demoman setbehaviour "COMBAT"

;goes through loop until all units have placed charges then exits
_i = _i + 1
?(_i < _max): goto "demoloop"
?(_i == _max):goto "Exit"

;I was going to use the scripted waypoint method and have my units go a short distance away and then
;detonate the satchels. If not using scripted waypoint, then use the next WP to move away prior to detonation. ;Completely lost now. HELP!

     
#Exit
exit

As you can see, I have lifted lines from other scripts without knowing their meaning and have not yet grasped the needed if/then statements to complete this framework of a script. :(

If any one would like to help me and this sad excuse of a script out, I would be sooo thankful for any education that you have to offer me.

Thanks in advance for your help!

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

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:Scripted Waypoint = Satchel Placement
« Reply #1 on: 26 Jun 2003, 11:00:03 »
Hi, actually i'm at work, so i can't be that great help,
but be sure i'll be back home soon  8)

Meanwhile i'm gonna try to help you from here;

Quote
;Here I want to have each man in the group that is left to set a satchel in a hut created by map.
;There are 7 different huts that are potential targets. I want to use objectID to define targets in no
;particular order. Do I make an array of targets ["object12345","object12346","object12347"] or the target
;locations' array [(getpos object12345 select 0),(getpos object12345 ;select1),(getpos ;object12345 select2)]?
;This is where I am lost. Any and all help appreciated here.

Well, it's up to you if you want to let them move to coordinates,
or if you want to let them move to an object. Both should work
fine.

Just one thing:

If you use Object ID you need to take care on that
space between Object and ID. Also you're making a string
out of it by using hiqh qualifiers ("").
Your array should look like:

blow_up_array = [object 12345,object 12346,object 12347]

or:

blow_up_array = [(getpos object 12345),(getpos object 12346),(getpos object 12347)]

Also you will need to create an inner loop inside your demolition
loop, to count through your blow_up_array. Gonna show you that at the end.

Quote
_max = WEST countside units _group

This line is for counting the actual number of living men in
the group.

So if your script is running already that long, that it's possible
having lost some men, just do another count before starting
your satchel placing loop.

Or: you may use just a condition at the top of each loop's
round:

Quote
;not sure if this is needed
_demoman setbehaviour "COMBAT"

This line you only need, if you want to change the unit's behaviour to COMBAT


Quote
?(_i == _max):goto "Exit"

You don't need this line, as if _i is not smaller than _max
it can only be equal or greater - also the next line of your
script would be EXIT, therefore you don't need to use the
goto statement.


Quote
;I was going to use the scripted waypoint method and have my units go a short distance away and then
;detonate the satchels. If not using scripted waypoint, then use the next WP to move away prior to detonation. ;Completely lost now. HELP!

Up to you:

exit the script so they will start moving to their next waypoint
and in the next waypoint's onActivation field you could let
them blow the satchels

or use:

_group domove wherever

~15

bigbada-booooooooooooooooooom

exit


And here's an example of how your script could look like:

Code: [Select]
blow_up_array = [(getpos object 12345),(getpos object 12346),(getpos object 12347)]
;define array for targets to be blown up

_man_left = WEST countside units _group
;count number of men in group

_2bdestroyed = count blow_up_array
;count number of targets to be satchele'd

_i = 0
_ii = 0
;define selector for loop (men) and for loop (targets)

#demoloop

_demoman = units _group select _i
;select individual soldier of the group

?(alive _demoman): goto "do_it"
;if the soldier is alive, go on with his job

goto "skip_it"
;if soldier is alive, this line will have no effect upon the previous
;line - if soldier is dead script goes to "skip_it"

#do_it

_move_pos1 = blow_up_array select _ii
;select target from target array


_demoman commandmove _move_pos1
;move first unit to first hut

~0.5

@UnitReady _demoman
;Wait until unit is in position


_demoman fire ["put","pipebomb"]
;place satchel charge


_ii = _ii + 1
?(_ii == _2bdestroyed): _ii = 0
;increase counter for target loop - if counter has reached
;upper limit of target array, counter will be reset'd to first
;target

#skip_it
;script continues here if actual selected member of group
;is not alive

_i = _i + 1
?(_i < _man_left): goto "demoloop"
;increase counter for  loop through the groupmembers
; if counter has reached the limit - script will not return
;to "demoloop"

exit


When i'm at home, i'll go for testing if i've missed or screwed
summit here.


btw - thanx for the nice feeback on my thread  ;)

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Offline Wadmann

  • OFPEC Patron
  • ****
  • I'm the next evolutionary step after a llama!
Re:Scripted Waypoint = Satchel Placement
« Reply #2 on: 26 Jun 2003, 18:38:53 »
Thanks CD for the detailed reply. I was going to edit my post to inform everyone that another method would be fine as long as it works well in-game. I had attempted to use triggers to spoof the effect but still could not get it to work the way that I wanted it to (detecting if a unit had a satchel charge was the first of several issues the promted me to look into scripting). I took this route as there are obvious limitations to what one can do when not using a script. After watching your demo several times, I realized that you did more in your demo than all of my prior missions combined when I used just some simple triggers and premade scripts! As I am now at work, it will be a while until I get to try your version out so take your time in tinkering with the script. Perhaps with enough forum help, I may feel good enough about one of my missions to have it beta tested here but it ought to be more complex than a demo mission before that will happen! ;)

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