Home   Help Search Login Register  

Author Topic: createUnit?  (Read 2357 times)

0 Members and 1 Guest are viewing this topic.

tuskawilla

  • Guest
createUnit?
« on: 11 Jul 2006, 05:19:29 »
hi all,

i'm working on a coop map and i would like to have the player/s activate a trigger that then drops russian paratroopers near their location.  i have to admit my understanding of the programming logic is not there but I have researched the commands and tried to get createUnit to work with no results. 

I was hoping to
a. create a trigger point
b. when players activate trigger, put in the "on activation" line a createUnit to make parachutes
c. have paratroopers fall from the sky to attack the person either landing on a marked spot or directly over the players themselves.

anyhelp is appreciated.  I plan on having this happend in many spots as the players move to their objective escape point. I am also wanting them to either be in squads or form squads for search and destroy in an area

thanks!

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: createUnit?
« Reply #1 on: 11 Jul 2006, 21:41:57 »
It would be easier to have a helicopter loaded with enemy at a locked WP synched to a switch trigger.  When I get home tonight I will unpbo a mission I know that does this and make a quick missionette for you. 
urp!

tuskawilla

  • Guest
Re: createUnit?
« Reply #2 on: 12 Jul 2006, 00:12:49 »
much appreciated!  I look forward to it.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: createUnit?
« Reply #3 on: 12 Jul 2006, 03:21:30 »
Here is a missionette. I do not have time at the moment to write a description I will add one to this post tomorrow. Get in the jeep. Drive west to the first flag pole. Get out of the jeep go prone and wait. If you stay in the Jeep the enemy will just go prone and won't advance. Either kill all the enemy or drive around them to the next flag pole further west. Another chopper will dump its load.

This method works by having your choppers already loaded with soldiers somewhere away from the area where the players are.  The choppers start with no fuel to keep them from taking off.  A trigger activated by players is used to fill up the chopper's fuel using the setFuel command.  The chopper then takes off and follows its waypoints.  The first waypoint uses flyInHeight in its Activation field to set the height to 100m (Beware: setting the flyInHeight too high will cause an aircraft to ignore its waypoints).  A second trigger is grouped to the chopper and activates the script eject.sqs. The eject script, after a short pause, also commands the parachute group to advance to a game logic.  The final waypoint for the chopper takes it out of the mission area and uses the deleteVehicle command to remove it. I do not know who the original author of the script is.  I have put a hint in eject.sqs to say when units are advancing. Open eject.sqs in a text editor and remove the line hint "Enemy Advancing" to get rid of it.


Edit: attached mission (test_ejeculate.zip) lost in the crash of 2009 - WEK
« Last Edit: 19 Jan 2011, 23:14:45 by Walter_E_Kurtz »
urp!

tuskawilla

  • Guest
Re: createUnit?
« Reply #4 on: 13 Jul 2006, 03:05:22 »
i tried to load it, i'm missing some addon

cannot load mission, missing addons: Bas_opfor, jam_magazines

i'm gonna try and find it, but if you have it please post it

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: createUnit?
« Reply #5 on: 13 Jul 2006, 15:02:05 »
Ooops sorry, I thought I had edited those out from the mission.sqm.
I have updated the original d/l link.

I suppose it would be possible to use createUnit to silently spawn paratroopers, but I think there are issues will getting the units to start with chutes open.

Another solution would be to create a group of paratroopers in the mission editor, and set their Special to Flying. In their init fields put this setPos [(getPos this) select 0, (getPos this) select 1, 5000]. In the leader's init put grp_para1 = group this ; this setPos [(getPos this) select 0, (getPos this) select 1, 5000]. Starting at 5000m they will take hours to reach the ground and will not be visible. Also put a game logic on your map named server.

Put a trigger on the map and in the On Activation field put [this, grp_para1, thisList select 0,50,200] exec "moveparas.sqs".

Then the script moveparas.sqs:
Code: [Select]
if not (local server) then {exit}
_pos = getPos (_this select 0)
_grp = _this select 1
_target = _this select 2
_range = _this select 3
_height = _this select 4

_posx = _pos select 0
_posy = _pos select 1
{_x setPos [_posx + _range - 2*(random _range),_posy + _range - 2*(random _range),_height - (random 20)]} forEach units _grp

@(((getPos leader _grp) select 2) < 5)
~10
_grp setCombatMode "RED"
_grp setBehaviour "COMBAT"
_grp setSpeedMode "FULL"
_grp setFormation "VEE"
_grp move getPos _target
~10
;again for paranoia's sake
_grp move getPos _target
exit

When the trigger is activated the para units will be moved to random positions around the trigger centre. The 50 sets a scatter of 50m about the trigger centre, and the 200 sets the height of 200m. A random 0-20m is removed from the the height for each unit so that they are not all at the exact same height.  When the units have landed they advance to the last position of one of the units that activated the trigger. Instead of the thisList select 0 in the trigger activation field you could put the name of a game logic, say gl_para1, to which you want the units to advance.
I am "at work" so of course all this new code is untested.
« Last Edit: 13 Jul 2006, 19:23:30 by Mr.Peanut »
urp!

tuskawilla

  • Guest
Re: createUnit?
« Reply #6 on: 18 Jul 2006, 00:05:10 »
Well i tried your script at the bottom using the paratroopers.  It has one problem, their parachutes aren't deployed so they fall to their deaths.  I know if you create a paratrooper and put him in special flying they always have their chutes open.  maybe the move from one height to another is causeing it not to open?  i'll give the other idea, the corrected first one a try next.

perhaps there needs to be another set special 'flying' to put them back in that mode after the move??  just trying to figure it out..

thanks for all the help!

« Last Edit: 18 Jul 2006, 00:21:35 by noah »

tuskawilla

  • Guest
Re: createUnit?
« Reply #7 on: 18 Jul 2006, 00:18:51 »
just tried the fixed mission, got another error..

No Entry 'config.bin/CfgVehicles.BAS_GM18'

guess i'm missing some other vehicle?  i tried looking for it being mentioned in the code but didn't see it to change it.

tuskawilla

  • Guest
Re: createUnit?
« Reply #8 on: 18 Jul 2006, 00:29:35 »
YEP!  I just confirmed it.  When the trigger is sprung, the paratroopers change position but leave their parachutes behind.  so they fall to their deaths.  i changed the start height to 500 instead of 5000 and waited until i saw them the activated the trigger. 

so is there a way to redeploy the parachutes?

Offline Cheetah

  • Former Staff
  • ****
Re: createUnit?
« Reply #9 on: 18 Jul 2006, 10:58:46 »
Added to this post is a litte test mission. Hope it helps you. Didn't make it MP ready.


Edit: attached mission (DropTest.zip) lost in the crash of 2009 - WEK
« Last Edit: 19 Jan 2011, 23:16:02 by Walter_E_Kurtz »
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: createUnit?
« Reply #10 on: 18 Jul 2006, 20:02:44 »
ooops.. lol
Change line:
Code: [Select]
{_x setPos [_posx + _range - 2*(random _range),_posy + _range - 2*(random _range),_height - (random 20)]} forEach units _grpto
Code: [Select]
{(vehicle _x) setPos [_posx + _range - 2*(random _range),_posy + _range - 2*(random _range),_height - (random 20)]} forEach units _grp
Please find link to example missionette below... :)
Of course, this method is best used when player would not see the enemy suddenly appear over their heads i.e. dark or foggy skies or player is in forest or building.  Advantage of this method is that enemy parachute soundlessly in without the player hearing an aircraft approaching.


Edit: attached mission (test_moveparas.zip) lost in the crash of 2009 - WEK
« Last Edit: 19 Jan 2011, 23:17:14 by Walter_E_Kurtz »
urp!

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: createUnit?
« Reply #11 on: 18 Jul 2006, 20:05:12 »
Hmm, oops again.
I have replaced the addon units with plain units and reuploaded to original d/l link . This time I have tested without any addons so I know it works! :)
just tried the fixed mission, got another error..

No Entry 'config.bin/CfgVehicles.BAS_GM18'

guess i'm missing some other vehicle?  i tried looking for it being mentioned in the code but didn't see it to change it.
« Last Edit: 18 Jul 2006, 20:24:33 by Mr.Peanut »
urp!

tuskawilla

  • Guest
Re: createUnit?
« Reply #12 on: 21 Jul 2006, 02:26:31 »
That last post was perfect.  I think it'll do the job just fine.  Thanks for all the help.  I'll be back with more questions as they arise.