Home   Help Search Login Register  

Author Topic: creating vehicles/units mid air?!  (Read 3542 times)

0 Members and 1 Guest are viewing this topic.

creating vehicles/units mid air?!
« on: 08 Jul 2014, 03:55:52 »
Hi there,

I'm trying to add some challenge to a mission im working on - but can't seem to get it to work  :dunno:

Ideally I'd like to spawn a chinook flying at position1, then tell it to follow an enemy. Once it's within 150 feet of enemy I' like it to be able to have the chinook spawn 12 ai units (west) that para down to enemy and then pursue them on foot .... BUT those west units need to use the Civilian11 skin! (police.)

Once units have spawned script should stop and wait for at least 6 of the spawned units to die before dropping another 6 via para from chinook.

I've also had problems with telling a police ai unit who to follow... there are 2 east players - killer1 and killer2... is there a way to tell a ai police unit to follow either killer1 or killer2? (sometimes people will only use killer2 slot... other times they may select killer1 slot... or both!)  struggle to know how to tell ai to persue either or both!  :confused:

Any help would be greatly appreciated and thanks in advance! By myself and those who will play and face this onslaught!  :D

Offline savedbygrace

  • Intel Depot
  • Administrator
  • *****
  • Be swift to hear...slow to speak...slow to wrath.
Re: creating vehicles/units mid air?!
« Reply #1 on: 08 Jul 2014, 22:29:21 »
Out of curiosity only, do you have a clan or group of friends you play MP with? If not, why not just create some scenarios for SP?

Have you checked out our COMREF yet?

Re: creating vehicles/units mid air?!
« Reply #2 on: 09 Jul 2014, 05:29:02 »
Hey there sbg,

Thanks for the reply! Firstly, you have a unique name - are you a practicing christian or is that a metal song? lol (you don't have to answer this obviously :whistle: )
 
In regards to your reply - I host †veterans of destruction† server for cwa 1.99 which still (amazingly!) has players! Last weekend had 12 in a game which is pretty darn good for ofp  :D That and my brother overseas still plays this game with me once in a while... so mp is kind of essential! THis mission does have sp elements... such as the script im trying to get working. IF there are only 1 or 2 killers playing - it activates other ai to attack and defend the civilians :)

I know the comref well but am more of an artist and musician than computer programmer lol. I can post what have scripted (or failed at scripting lol) but usually it's as useless to the person replying as it is to me lol... i understand some principles but every time I try read tutorials i get confused and my head hurts lol.  :-[
Imo the comrel is like a dictionary - it has great snippets... and hints...  but won't teach you how to speak the language! ...for me anyway!

Code: [Select]
#drop

?!(alive hELI4): EXIT  ; heli4 is the name of the chinook
?(botcops > 6) : goto "search" ; checks to see how many ai are still alive and whether it should spawn more
?((POLHELI4pilot Distance KILLER1) or (POLHELI4pilot Distance KILLER2) < 150) : goto "PARA" ; tells chinook to spawn ai if close to either Killer1 or Killer2

goto "search"

#PARA
pOLHELI4PILOT setSpeedMode "LIMITED" ;slows down chopper?
pOLHELI4 setSpeedMode "LIMITED" ; slows down chopper?
?(botcops > 6) : goto "search"; checks to see how many ai are still alive
botcops = botcops + 1 ;adds a unit to the police counter
PublicVariable "botcops" ; as above
_unit1 ="civilian11" createUnit [position AI1, group Polheli4pilot] ;spawns civilian police ai at pad AI1 and groups with pilot
_unit1 setskill 1; makes this ai unit meaner
_unit1 action ["eject", Polheli4] ;tells ai unit to eject from heli4
_unit1 AddEventHandler ["killed",{_unit1 exec "botkilled.sqs"}] ; adds EH to removed dead body once killed
?(botcops < 6) : goto "para" ; checks to see how many ai are still alive and whether it should spawn more


CutText [format["\nPolice officer dispatched! There are %1  active officers hunting killers!", botcops], "Plain"] ; relays officer spawned and amount active (more just to see if it's working lol)


#search
pOLHELI4PILOT setSpeedMode "FULL"; speeds chopper back up
pOLHELI4 setSpeedMode "FULL" ; same as above? Not sure if I need to command the ai I put in the empty chinook or the chinook itself... so did both lol
pOLHELI4PILOT domove (position killer1); tells heli to hunt killer 1 - I'm not sure how to have the heli pick the closest killer to hunt :(
pOLHELI4GUNNER dotarget  killer1; tells heli to target killer 1 -Again I'm not sure how to have the heli pick the closest killer to hunt!
_unit1 domove (position killer1); as above
_unit1 dotarget  killer
_unit2 domove (position killer1); as above
_unit2 dotarget  killer
_unit3 domove (position killer1); as above
_unit3 dotarget  killer
_unit4 domove (position killer1); as above
_unit4 dotarget  killer
_unit5 domove (position killer1); as above
_unit5 dotarget  killer
_unit6 domove (position killer1); as above
_unit6 dotarget  killer

~1
?(botcops < 7) and ((POLHELI4 Distance KILLER1) or (POLHELI4 Distance KILLER2) < 150) : goto "PARA" ; Checks to see how many cops are alive and if to spawn more or go back to loop
goto "drop"

The above simply does not work... Chinook doesn't start flying, only 3 ai spawn and they are on gound next to heli lol. That is all it does so clearly im missing the mark here lol .

botkilled.sqs:
Code: [Select]
_body = _this select 0


botcops = botcops - 1
PublicVariable "botcops"
~60
deleteVehicle _body

exit 

Mission init has
Code: [Select]
botcops = 0
PublicVariable "botcops";

As there are 2 killers (killer1 and killer2)  - I'm not sure how to tell the ai to choose who's closest... or who's killed more civilians... I think I need an array but hell if I know how to implement that!

Oh and please don't laugh at the code i just posted!! :no:  I imagine it's pretty hilarious to an expert :P 
I'm just kidding... laugh away!
« Last Edit: 09 Jul 2014, 10:07:44 by ÐurbanPoison™ »

Offline Rellikki

  • Members
  • *
  • Die-hard OFP player
Re: creating vehicles/units mid air?!
« Reply #3 on: 12 Jul 2014, 19:41:02 »
I'm not particularly fond of these scripts of mine as I find them really messy and I believe there are better ways of doing this, but they should do it.

First you must place two groups of police officers and change their side to West as you wanted by editing the mission.sqm file. I believe you already know how to do this so I won't go into detail on it. Splitting them into two different groups makes this whole thing a lot simpler. Type the following into both of the group leaders' init fields, but make sure to change the variable searchparty1 into searchparty2 for the second group:

searchparty1 = group this; {_x moveInCargo heli4} forEach units this

You also need to have a game logic named server in your mission as these are supposed to be run by the server only.

Add para = 0 into your init.sqs script; it initializes a variable that's used to check when a group has been parachuted, so the helicopter won't parachute them all at once.

Here come the scripts themselves. First off is the script for the helicopter. I set it up so it'll wait at a position named heliWait until there are any units in its cargo, so you'll need a game logic named like that. It then goes to the position of the killer(s) and parachutes the search parties to hunt them. If either one of the killers doesn't exist, it also parachutes the other search party too at the position of the other killer. To activate it, you need to type [] exec "heli.sqs" whenever you want the hunt to begin.

heli.sqs
Code: [Select]
?! local server : exit

#loop
?! alive heli4 : exit
heli4 flyInHeight 150
heli4 move getPos heliWait
@ count crew heli4 > 2

;paradrop1
? format ["%1", killer1] == "scalar bool array string 0xfcffffef" || count crew heli4 <= 2 : goto "paradrop2"
_parapos = "Logic" camCreate [getPos killer1 select 0, getPos killer1 select 1, 150]
heli4 move getPos _parapos
@ heli4 distance _parapos < 150
deleteVehicle _parapos
[units searchparty1] exec "paradrop.sqs"
@ para == 1
para = 0
? format ["%1", killer2] != "scalar bool array string 0xfcffffef" : goto "paradrop2"
[units searchparty2] exec "paradrop.sqs"
@ para == 1
para = 0

#paradrop2
? format ["%1", killer2] == "scalar bool array string 0xfcffffef" || count crew heli4 <= 2 : goto "loop"
_parapos = "Logic" camCreate [getPos killer2 select 0, getPos killer2 select 1, 150]
heli4 move getPos _parapos
@ heli4 distance _parapos < 150
deleteVehicle _parapos
[units searchparty2] exec "paradrop.sqs"
@ para == 1
para = 0
? format ["%1", killer1] != "scalar bool array string 0xfcffffef" : goto "loop"
[units searchparty1] exec "paradrop.sqs"
@ para == 1
para = 0
goto "loop"

This is the parachuting script. It's run by the heli script above:

paradrop.sqs
Code: [Select]
?! local server : exit

_paras = _this select 0

_count = 0
#loop
_para = (_paras select _count)
_para action ["Eject", vehicle _para]
unassignVehicle _para
_count = _count + 1
? _count >= count _paras : goto "end"
~0.5
goto "loop"

#end
para=1
exit

And finally the script for the search parties. It takes care of the search for the killer(s) and respawns them whenever they've been killed. To activate it, you need to type the following for the first group:

[searchparty1, killer1, killer2] exec "search.sqs";

And for the second group:

[searchparty2, killer2, killer1] exec "search.sqs";

The first parameter in the array is the group name obviously. The second parameter is their primary target. If the primary target doesn't exist, then they revert to their secondary target, which is the third parameter. These are reversed for both of the search parties, so in case either one of the killers doesn't exist, both of the groups will go after the same target, and if both killers do exist, then they go after both of them respectively.

search.sqs
Code: [Select]
?! local server : exit

_group = _this select 0
_killer1 = _this select 1
_killer2 = _this select 2
_killer = objNull
_count = 0

if (format ["%1", _killer1] == "scalar bool array string 0xfcffffef") then {_killer = _killer2} else {_killer = _killer1}

#loop
?! alive heli4 : exit
? {alive _x} count units _group == 0 : goto "respawn"
(leader _group) move getPos _killer
~10
goto "loop"

#respawn
"Civilian11" createUnit [getPos heli4, _group, "loon = this"]
loon moveInCargo heli4
loon = nil
_count = _count + 1
? _count >= 6 : goto "loop"
goto "respawn"

I might have overlooked something important, so let me know if there are any problems.
« Last Edit: 12 Jul 2014, 22:32:11 by Rellikki »

Re: creating vehicles/units mid air?!
« Reply #4 on: 18 Jul 2014, 17:12:25 »
Thank you very much Rellikki, this is very helpful but i think im missing something...

Couple questions just to be sure I don't mess it up -

You said create 2 different groups so...

So I did as you said and put 2 west units as leaders, each having 5 ai to command. So in other words 2 teams of 6 units. I then added
Code: [Select]
searchparty1 = group this; {_x moveInCargo heli4} forEach units this
In the first team leaders init field and then
Code: [Select]
searchparty2 = group this; {_x moveInCargo heli4} forEach units this
in the second leaders init field. I then changed them all in the mission.sqs from west soldier to the civilian11.
So teams set up.

I got a little confused with this part...

Quote
To activate it, you need to type the following for the first group:

[searchparty1, killer1, killer2] exec "search.sqs";

And for the second group:

[searchparty2, killer2, killer1] exec "search.sqs";

How would I go about calling/activating the above? Meaning where should I type the above code? In each team leader's init field? In a trigger? I think this may be where I'm missing it.

And in regards to the heli...
Do the pilots Heli4pilot1 and Heli4gunner1 need anything in their init fields? (They moveindriver  & moveingunner of empty chinook named Heli4 at start of mission).

If I change the values of
Code: [Select]
heli4 flyInHeight 150and/or
Code: [Select]
@ heli4 distance _parapos < 150...will this cause the scripts to malfunction or not work? (I realize if they jump too low they will die or if the distance is too little from killer they will not spawn.)

Oh and I also forgot to ask - I modified the mission so that the killer can have a few extra lives... so this the original units named killer1 and killer2 may respawn a few times during the mission... will this mess up the script? Will the created units know to hunt the respawned killer? I hope this isn't a dumb question lol. And thank you again for all the info and help - It's really made this entire process a lot less stressful and the mission a lot more fun! :D
 

*EDIT: I tried and it seems that if the killer stays on the little island he starts on and I call heli.sqs via radio - the script works as it should... however strangely if I teleport to island the heli will come find me but not spawn units. (at least that's how it appears to be happening)

I'll play with it some more this weekend and hopefully get it working  :)

« Last Edit: 18 Jul 2014, 19:46:58 by ÐurbanPoison™ »

Offline Rellikki

  • Members
  • *
  • Die-hard OFP player
Re: creating vehicles/units mid air?!
« Reply #5 on: 19 Jul 2014, 06:57:17 »
Quote
Quote
To activate it, you need to type the following for the first group:

[searchparty1, killer1, killer2] exec "search.sqs";

And for the second group:

[searchparty2, killer2, killer1] exec "search.sqs";
How would I go about calling/activating the above? Meaning where should I type the above code? In each team leader's init field? In a trigger? I think this may be where I'm missing it.
You can type it where ever you want when you want the search to begin. Use it in conjunction with the heli.sqs script. For testing purposes I used a simple trigger.

Quote
Do the pilots Heli4pilot1 and Heli4gunner1 need anything in their init fields? (They moveindriver  & moveingunner of empty chinook named Heli4 at start of mission).
I tested it out and they shouldn't need anything in their init fields, even if they're separate entities from the actual helicopter, just as long as the helicopter is named correctly.

Quote
If I change the values of

Code: [Select]
heli4 flyInHeight 150
and/or

Code: [Select]
@ heli4 distance _parapos < 150
...will this cause the scripts to malfunction or not work? (I realize if they jump too low they will die or if the distance is too little from killer they will not spawn.)

If you modify any of those, you will also need to modify the number at the end of the _parapos camCrate commands in the heli.sqs script accordingly. There are two of them. The height of the parachuting spot should correspond to their flying height, otherwise the helicopter might never parachute the paratroopers out because the spot is too low/high for them to reach.

Quote
I modified the mission so that the killer can have a few extra lives... so this the original units named killer1 and killer2 may respawn a few times during the mission... will this mess up the script? Will the created units know to hunt the respawned killer?
After a quick test, respawning killers seemed to cause some major problems. I don't have a solution for now, but I'll look into it.