Home   Help Search Login Register  

Author Topic: CreateUnit/set waypoint Question  (Read 4444 times)

0 Members and 1 Guest are viewing this topic.

Offline IGWedge

  • Members
  • *
  • Internal Coordinator @ www.ic-arma.com
    • International Conflict Armed Assault
CreateUnit/set waypoint Question
« on: 06 May 2007, 18:55:48 »
Hi Guys

Just wondering if someone can tell me what im doing wrong :scratch:

Very basic stuff im sure but as im trying to learn these things come up.

Im just trying to create a group of downed pilots via a script with a downed blackhawk. I also want to disarm the pilots and stop them from moving.
I currently have something like this.

_posmarker = [7975,7286,0];
_grpilot = createGroup (west);


_heli = createVehicle ["BlackhawkWreck", _posmarker, [], 0, "NONE"];

"SoldierWPilot" createUnit [_posmarker, _grpilot];
"SoldierWPilot" createUnit [_posmarker, _grpilot];

_pilot1 = (units _grpilot select 0);
_pilot1 disableAI "MOVE";
_pilot1 allowfleeing 0;
_pilot1 setBehaviour "Careless";
removeallweapons _pilot1;
_pilot1 setCaptive true;
commandStop _pilot1;

_pilot2 = (units _grpilot select 1);
_pilot2 disableAI "MOVE";
_pilot2 allowfleeing 0;
_pilot2 setBehaviour "Careless";
removeallweapons _pilot2;
_pilot2 setCaptive true;
commandStop _pilot2;

Im not gettin any joy..it just isnt doin anything.

Many thanks

Wedge

« Last Edit: 08 May 2007, 18:52:58 by IGWedge »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: CreateUnit Question
« Reply #1 on: 06 May 2007, 19:32:14 »
Try this to create your pilots
Code: [Select]
_posmarker = [7975,7286,0];
_grpilot = createGroup west;

_heli = createVehicle ["BlackhawkWreck", [(_posmarker select 0)+10,(_posmarker select 1)+10,0], [], 0, "NONE"];


_pilot1 = _grpilot createUnit ["SoldierWPilot",_posmarker, [], 0, "FORM"];
_grpilot selectLeader _pilot1;
_pilot1 disableAI "MOVE";
_pilot1 allowfleeing 0;
_pilot1 setBehaviour "Careless";
removeallweapons _pilot1;
commandStop _pilot1;

_pilot2 = _grpilot createUnit ["SoldierWPilot",[(_posmarker select 0)+2,_posmarker select 1,0], [], 0, "FORM"];
_pilot2 disableAI "MOVE";
_pilot2 allowfleeing 0;
_pilot2 setBehaviour "Careless";
removeallweapons _pilot2;
commandStop _pilot2;

_pilot1 setCaptive true;
_pilot2 setCaptive true;

Make sure there are more west units in the map, else you need
Code: [Select]
center = createCenter west; before executing
Code: [Select]
_grpilot = createGroup west;

Offline 456820

  • Contributing Member
  • **
Re: CreateUnit Question
« Reply #2 on: 06 May 2007, 19:34:11 »
What doesnt work about this script?

This could be it. Instead of

"SoldierWPilot" createUnit [_posmarker, _grpilot];
"SoldierWPilot" createUnit [_posmarker, _grpilot];

change it to...

_pilot1 = "SoldierWPilot" createUnit [_posmarker, _grpilot];
_pilot2 = "SoldierWPilot" createUnit [_posmarker, _grpilot];

Because you arent naming the pilots, the script will just create the pilots but wont do anything you told them to do.

Edit - Too late  >:(
 :D

Offline IGWedge

  • Members
  • *
  • Internal Coordinator @ www.ic-arma.com
    • International Conflict Armed Assault
Re: CreateUnit Question
« Reply #3 on: 07 May 2007, 10:22:39 »
Ok i tried doing as you said but its still not working
Its just not creating the units,

I did try this method as it is
Code: [Select]
unit = group player createUnit ["SoldierWB", position player, [], 0, "FORM"]
and it worked but because i hadnt changed anything within this line it created the pilots and put them in my group.
The thing is, i am on the independant side. The pilots are on the west.

Make sure there are more west units in the map, else you need
Code: [Select]
center = createCenter west; before executing
Code: [Select]
_grpilot = createGroup west;

Im really not too sure what you mean, i tried placing a west unit out of play somewhere and still nothing. This is obviously where my problems are

A quick explanation... i am making a training map in which you can select the missions you want to try... so really there is nothing else on the map other than the players group...everything else i wanted to create via the script which is executed when the player selects that mission.

So what im unsure of is how to create an existing group that enables the pilots to createunit.

Thanks
« Last Edit: 07 May 2007, 11:03:06 by IGWedge »

Offline Eymerich

  • Members
  • *
Re: CreateUnit Question
« Reply #4 on: 07 May 2007, 13:52:12 »
I've used create group and it runs fine.

Try to attach the function to a global variable.

Group1 = creategroup West

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: CreateUnit Question
« Reply #5 on: 07 May 2007, 14:42:19 »
The problem with createGroup is that it only works if the corresponding center already exists. Placing units of one side in the editor activates the corresponding center (west, east, civilian ...), but if no units of one side are already present in the map, the center of that side will not exist and createGroup for that side will fail. This is why center = createCenter west; may be necesary.

As an example, if you create a mission where there are only civilians (placed on the map from the editor), any createGroup west or east will fail.

Offline IGWedge

  • Members
  • *
  • Internal Coordinator @ www.ic-arma.com
    • International Conflict Armed Assault
Re: CreateUnit Question
« Reply #6 on: 07 May 2007, 20:50:23 »
Ok

I tried it again usnig west and guerilla, seeing as it is training for the independant ive tried to keep it as this....
I created a group of independant guys to test the other theory...but still no joy

Im assuming the line
Code: [Select]
_grppilot = createGroup (guerilla); is ok but correct me if im wrong please.

this is what i have now

Code: [Select]
_user = _this;
_usergroup = (group _user);


hint format ["CSAR: Combat Search And Rescue\nYour mission is to find and rescue 2 downed chopper pilots\nfrom the enemy\n \n \n GOOD LUCK!"];

_grppilot = createGroup (guerilla);
_posmarker = [7975,7286,0];
_pilpos = [7978,7286,0];


_search = createMarkerLocal ["Search", _posmarker];
_search setMarkerColorLocal "ColorGreen";
_search setMarkerShapeLocal "RECTANGLE";
_search setMarkerSizeLocal [400, 100];
_search setMarkerBrushLocal "FDiagonal";


_heli = createVehicle ["BlackhawkWreck", [(_posmarker select 0)+1,(_posmarker select 1)+1,0], [], 0, "NONE"];


"SoldierWPilot" createUnit [_posmarker, _grpilot];
"SoldierWPilot" createUnit [_posmarker, _grpilot];


maybe someone could take a quick look and maybe tell me whats wrong
Ive attached a small example... the script is triggered by radio alpha

many thanks

Wedge



« Last Edit: 07 May 2007, 20:52:07 by IGWedge »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: CreateUnit Question
« Reply #7 on: 07 May 2007, 21:17:58 »
Did you create a center named guerrilla? Or is that what you want is to use resistance? If so, AFAIK, the side name is resistance.

Offline IGWedge

  • Members
  • *
  • Internal Coordinator @ www.ic-arma.com
    • International Conflict Armed Assault
Re: CreateUnit Question
« Reply #8 on: 07 May 2007, 21:41:07 »
Ahh cool thats good to know

yes i am using resistance.

Unfortunatly it still does not help me.

When you say
Code: [Select]
center = createCenter west; i presume this changes to
Code: [Select]
center = createCenter resistance;
Do i put this in the script or in the editor?? i have it in the script and it makes no differance.

did you take a look at that map??

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: CreateUnit Question
« Reply #9 on: 07 May 2007, 22:09:28 »
Now it works:

Code: [Select]
_user = _this;
_usergroup = (group _user);

hint format ["CSAR: Combat Search And Rescue\nYour mission is to find and rescue 2 downed chopper pilots\nfrom the enemy\n \n \n GOOD

LUCK!"];

_grppilot = createGroup resistance;
_posmarker = [7975,7286,0];
_pilpos = [7978,7286,0];


_search = createMarkerLocal ["Search", _posmarker];
_search setMarkerColorLocal "ColorGreen";
_search setMarkerShapeLocal "RECTANGLE";
_search setMarkerSizeLocal [400, 100];
_search setMarkerBrushLocal "FDiagonal";


_heli = createVehicle ["BlackhawkWreck", _posmarker, [], 0, "NONE"];


_pilot1 = _grppilot createUnit ["SoldierWPilot",[_posmarker select 0,(_posmarker select 1)-12,0], [], 0, "FORM"];
_pilot1 setDir random 360;
_grppilot selectLeader _pilot1;
_pilot1 disableAI "MOVE";
_pilot1 allowfleeing 0;
_pilot1 setBehaviour "Careless";
removeallweapons _pilot1;
commandStop _pilot1;

_pilot2 = _grppilot createUnit ["SoldierWPilot",[(_posmarker select 0)+2,(_posmarker select 1)-12,0], [], 0, "FORM"];
_pilot2 setDir random 360;
_pilot2 disableAI "MOVE";
_pilot2 allowfleeing 0;
_pilot2 setBehaviour "Careless";
removeallweapons _pilot2;
commandStop _pilot2;

_pilot1 setCaptive true;
_pilot2 setCaptive true;

Offline IGWedge

  • Members
  • *
  • Internal Coordinator @ www.ic-arma.com
    • International Conflict Armed Assault
Re: CreateUnit Question
« Reply #10 on: 07 May 2007, 22:40:27 »
Thats awesome Mate thanks

works a treat.

I have 1 more question.....

i presume if i wanna make the spawn point of the created unit random this will appear differently on everyones system.

Is there an easy way to make it the same for everyone?
« Last Edit: 07 May 2007, 22:42:37 by IGWedge »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: CreateUnit Question
« Reply #11 on: 07 May 2007, 22:51:32 »
So is it MP?

If so, place in the map a gamelogic named server. execute the script only if
Code: [Select]
?local server: execute your script.

This way the script would be executed only in the server, for example placing that in the init.sqs. If you do so, the position may be random but the created units will have the very same position for all the clients.

Offline IGWedge

  • Members
  • *
  • Internal Coordinator @ www.ic-arma.com
    • International Conflict Armed Assault
Re: CreateUnit Question
« Reply #12 on: 07 May 2007, 23:10:43 »
ok i understand what your saying...yes its MP
So i have my "server" gamelogic.
the mission script is called "p_rescue.sqf"
just to clarify I only want the mission script to be run when the team leader wants to (ie radio alpha)...
I also have an init.sqs, is this where i should put it??  ?local server: "p_rescue.sqf"

also...
I am trying to give my enemy some waypoints within the same script it looks something like this.

Code: [Select]
_patrol1 = _enemy addWaypoint [_wp1, 0];
_patrol2 = _enemyaddWaypoint [_wp2, 0];
_patrol3 = _enemy addWaypoint [_wp3, 0];
_patrol4 = _enemy addWaypoint [_wp4, 0];
_patrol5 = _enemy addWaypoint [_wp1, 0];
[_enemy, 5] setWaypointType "CYCLE";

I keep getting an error saying .....

Code: [Select]
_wp5 = _enemy |#| addwaypoint [_wp1,0]
error 0 elements provided, 3 expected

Any ideas

Sorry to keep askin stuff but as i sort something somethin else pops up.....gotta learn somehow  :confused:
« Last Edit: 08 May 2007, 00:34:08 by IGWedge »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: CreateUnit Question
« Reply #13 on: 08 May 2007, 00:16:11 »
Then you dont really need the server check, as you only would execute it in leader machine.

In the radio trigger condition put:

this && (player == leader group player)

In the activation execute your script. That should work.

Offline IGWedge

  • Members
  • *
  • Internal Coordinator @ www.ic-arma.com
    • International Conflict Armed Assault
Re: CreateUnit Question
« Reply #14 on: 08 May 2007, 00:18:41 »
many thanks for that...

i just edited my post above   not sure if you saw it

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: CreateUnit Question
« Reply #15 on: 08 May 2007, 00:29:43 »
What is __enemy with two "_"?

Offline IGWedge

  • Members
  • *
  • Internal Coordinator @ www.ic-arma.com
    • International Conflict Armed Assault
Re: CreateUnit Question
« Reply #16 on: 08 May 2007, 00:34:48 »
Quote
What is __enemy with two "_"?

lol sorry bout that, that was not the problem

that is my tired little fingers workin away

its not supposed to be there i edited the typo

Code: [Select]
_patrol1 = _enemy addWaypoint [_wp1, 0];
_patrol2 = _enemyaddWaypoint [_wp2, 0];
_patrol3 = _enemy addWaypoint [_wp3, 0];
_patrol4 = _enemy addWaypoint [_wp4, 0];
_patrol5 = _enemy addWaypoint [_wp1, 0];
[_enemy, 5] setWaypointType "CYCLE";
« Last Edit: 08 May 2007, 00:36:29 by IGWedge »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: CreateUnit Question
« Reply #17 on: 08 May 2007, 01:19:55 »
Did you try:
Code: [Select]
_patrol5 setWaypointType "CYCLE";?

Offline IGWedge

  • Members
  • *
  • Internal Coordinator @ www.ic-arma.com
    • International Conflict Armed Assault
Re: CreateUnit Question
« Reply #18 on: 08 May 2007, 18:52:30 »
It doesnt seem to matter what i do i keep getting

Code: [Select]
error 0 elements provided, 3 expected
Does anyone know what it means/how i can fix it....

I even tried executing it as a seperate "patrol.sqf" but i stil got the same error

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: CreateUnit/set waypoint Question
« Reply #19 on: 08 May 2007, 19:31:31 »
What is for example _wp1?

addWaypoint requires a position and the placement radius
Code: [Select]
somesoldier/group addWaypoint [position,radius (in meters)]If _wpX is not a position it will cause an error..
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.