Jump to content

Recommended Posts

I am creating a cooperative mission to play in multiplayer where me and my friends can assume the role of pilots and rescue medics, so what I need is a script or a way that when starting the mission a unit (civilian wounded) appears in a random place and you have to go rescue him, kinda medevac missions. Ideally, as a requirement to complete the mission, the civilian should be left in a hospital or at the main base. I've been editing missions for a long time, but I'm very new to scripts and things like that. I need your help guys. Thanks!

Share this post


Link to post
Share on other sites

I just did made this mission at weekend. (Not injured civilian, but a fighting squad and you have to extract them from the battle), but I use many scripts for this: creating a random battle, order the squad to get in your heli if you land, order the squad to get out from your heli when you bring them back to base.... etc.

 

So you have to specify what you need. Because you just describe a whole mission, not a script. What do you need?

Creating an injured civilian in a random place?

  • Like 2

Share this post


Link to post
Share on other sites

If you just want to place a wounded guy at a random position, you could use this in your init.sqf:

 

if (isServer) then
{
  _location=floor(random 4);
  switch (_location) do
  {
    case 0 : {guy setPos getMarkerPos "marker1";};
    case 1 : {guy setPos getMarkerPos "marker2";};
    case 2 : {guy setPos getMarkerPos "marker3";};
    case 3 : {guy setPos getMarkerPos "marker4";};
  };
};

guy is the name of the wounded, marker1-4 are empty markers on the map where he should appear.

 

For the "check if in hospital", create a trigger which covers the area and make the wounded the owner of that trigger.

  • Like 3

Share this post


Link to post
Share on other sites

short version of above script:

if (isServer) then
{
 _markers = ["marker1", "marker2", "marker3",  "marker4"];
 guy setPos ( getMarkerPos ( selectRandom _markers ) );
};

 

  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites
1 hour ago, bardosy said:

I just did made this mission at weekend. (Not injured civilian, but a fighting squad and you have to extract them from the battle), but I use many scripts for this: creating a random battle, order the squad to get in your heli if you land, order the squad to get out from your heli when you bring them back to base.... etc.

 

So you have to specify what you need. Because you just describe a whole mission, not a script. What do you need?

Creating an injured civilian in a random place?

ohhh.... That's mission sound coool. May I ask how did you do the AI Squad to get in your heli and order them out when back to base? 

Share this post


Link to post
Share on other sites

I have a trigger what checks if the heli1 is close enough to the landing zone AND the altitude is less then 1 meter. Then runs this script:

 

{
	_x setBehaviour "AWARE";
	_x setDamage 0;
	_x enableAI "MOVE";
	_x setUnitPos "UP";
	_x assignAsCargo heli1;
	[_x] orderGetIn true;
	_x setSpeedMode "FULL";
	sleep 2;
} forEach _units;

waitUntil { ({_x in heli1 and alive _x} count _units) == ({alive _x} count _units) };

(leader pgrp) sideChat "OK. Let's get out of here...";

 

And I have an other trigger what checks if the heli1 is close enough to the base AND the altitude is less then 1 meter. Then runs this script:

 

(leader pgrp) sideChat "Hurry! We need other grunts to save!";

sleep 1;
  {
    unassignVehicle _x; 
    _x action ["EJECT",heli1];
    sleep 1;
	_x doMove getPos glBase;
  } forEach vedok;

waitUntil { ({_x in heli1 and alive _x} count vedok) == 0 };

sleep 2;

(leader pgrp) sideChat "Let's get back to work!";

 

  • Like 2

Share this post


Link to post
Share on other sites
13 hours ago, PabloSalto said:

I am creating a cooperative mission to play in multiplayer where me and my friends can assume the role of pilots and rescue medics, so what I need is a script or a way that when starting the mission a unit (civilian wounded) appears in a random place and you have to go rescue him, kinda medevac missions. Ideally, as a requirement to complete the mission, the civilian should be left in a hospital or at the main base. I've been editing missions for a long time, but I'm very new to scripts and things like that. I need your help guys. Thanks!

This is what I use for the wounded rescue target from nomadd:

:

I haven't tried this yet, check last entry from wogz187: 

 

 

  • Like 2

Share this post


Link to post
Share on other sites

Thanks a lot lads,

Will take a look at these.

Quick question @bardosy, I see you're using "vedok" array for list of unit which will be unload. May I ask how do you assign those unit to the array? I'm guessing that you are spawning the evac group at the start of the mission.

Share this post


Link to post
Share on other sites

I am spawn enemy and the US squad when the player fly with the helicopter toward the target (created by a trigger). This is how I spawn the US squad (but I do the same with the enemy too). This is a very old script (now there are more modern methodes to spawn, but I am old and use my own scripts since OFP).

 

if (!isServer) exitWith{};

_pCount=count _this;

_creapos = getPos (_this select 0);

_group_i = createGroup WEST;



_creaposloc = [(_creapos select 0) + ((random 100) - 50), (_creapos select 1) + ((random 100) - 50), 0];
_unit = _group_i createUnit ["vn_b_men_army_15",_creaposloc, [], 0, "NONE"];
_unit setCombatMode "RED";
_unit setBehaviour "AWARE";
_unit setRank "SERGEANT";
_unit disableAI "MOVE";
_group_i selectLeader _unit;
_unit setskill 1;
_creaposloc = [(_creapos select 0) + ((random 100) - 50), (_creapos select 1) + ((random 100) - 50), 0];
_unit = _group_i createUnit ["vn_b_men_army_16",_creaposloc, [], 0, "NONE"];
_unit setCombatMode "RED";
_unit setBehaviour "AWARE";
_unit setRank "CORPORAL";
_unit disableAI "MOVE";
_unit setskill 1;
_creaposloc = [(_creapos select 0) + ((random 100) - 50), (_creapos select 1) + ((random 100) - 50), 0];
_unit = _group_i createUnit ["vn_b_men_army_17",_creaposloc, [], 0, "NONE"];
_unit setCombatMode "RED";
_unit setBehaviour "AWARE";
_unit setRank "CORPORAL";
_unit disableAI "MOVE";
_unit setskill 1;
_creaposloc = [(_creapos select 0) + ((random 100) - 50), (_creapos select 1) + ((random 100) - 50), 0];
_unit = _group_i createUnit ["vn_b_men_army_18",_creaposloc, [], 0, "NONE"];
_unit setCombatMode "RED";
_unit setBehaviour "AWARE";
_unit setRank "CORPORAL";
_unit disableAI "MOVE";
_unit setskill 1;
_creaposloc = [(_creapos select 0) + ((random 100) - 50), (_creapos select 1) + ((random 100) - 50), 0];
_unit = _group_i createUnit ["vn_b_men_army_19",_creaposloc, [], 0, "NONE"];
_unit setCombatMode "RED";
_unit setBehaviour "AWARE";
_unit setRank "PRIVATE";
_unit disableAI "MOVE";
_unit setskill 1;
_creaposloc = [(_creapos select 0) + ((random 100) - 50), (_creapos select 1) + ((random 100) - 50), 0];
_unit = _group_i createUnit ["vn_b_men_army_20",_creaposloc, [], 0, "NONE"];
_unit setCombatMode "RED";
_unit setBehaviour "AWARE";
_unit setRank "PRIVATE";
_unit disableAI "MOVE";
_unit setskill 1;
_creaposloc = [(_creapos select 0) + ((random 100) - 50), (_creapos select 1) + ((random 100) - 50), 0];
_unit = _group_i createUnit ["vn_b_men_army_21",_creaposloc, [], 0, "NONE"];
_unit setCombatMode "RED";
_unit setBehaviour "AWARE";
_unit setRank "PRIVATE";
_unit disableAI "MOVE";
_unit setskill 1;

if (!isNil "vedok") then {
	vedok = vedok + (units _group_i);
};

You can see, the last three line put all the units into the array "vedok".

The only parameter of this script is the middle of the LZ (I usualy use a Game Logic). And I randomly spawned them around this Game Logic. I disable their possibility to move, so they will fight without move away. And when the player land with the heli near them, my previous script enable their "move" so they can run into the heli.

 

  • Like 2

Share this post


Link to post
Share on other sites
16 hours ago, bardosy said:

I just did made this mission at weekend. (Not injured civilian, but a fighting squad and you have to extract them from the battle), but I use many scripts for this: creating a random battle, order the squad to get in your heli if you land, order the squad to get out from your heli when you bring them back to base.... etc.

 

So you have to specify what you need. Because you just describe a whole mission, not a script. What do you need?

Creating an injured civilian in a random place?

Yup, That's exactly what I need

  • Like 1

Share this post


Link to post
Share on other sites

Thanks a lot guys! I'm going to start testing these things in the editor to see what I can achieve

  • Like 1

Share this post


Link to post
Share on other sites

Ok, I have the next problem... I've placed 3 AI civilians (civ1, civ2 and civ3) and 6 invisible helipads (marker1, marker2,... marker6)

 

I ran the following code in the debug console in the SP mission:

if (isServer) then
{ 
 _markers = ["marker1", "marker2", "marker3", "marker4", "marker5", "marker6"] call bis_fnc_selectRandom;
 
 _civ = ["civ1", "civ2", "civ3"] call bis_fnc_selectRandom;

 _civ setPos (getPos _markers);
 
};

And I get "Error Invalid number in expression"

Share this post


Link to post
Share on other sites

1st: dont use a BIS function like BIS_fnc_selectRandom if there is an engine command like selectRandom created already. But this is just a performance thing.

2nd: to get a marker position you have to use getMarkerPos

3rd: read the biki entry for each command you use!

 

if (isServer) then
{ 
 _marker_pos = getMarkerPos selectRandom ["marker1", "marker2", "marker3", "marker4", "marker5", "marker6"];
 
 _civ = selectRandom ["civ1", "civ2", "civ3"];

 _civ setPos _marker_pos;
};

 

  • Like 2

Share this post


Link to post
Share on other sites

@PabloSalto I don't know it helps you or not, but you can use this freely. I added (as a new task) your idea to my Air Bridge mission: players have to fly to a FOB and they found a heavy injured soldier next to a medic.

This is what I put the init field of the injured:

[this, "PRONE_INJURED", "ASIS"] call BIS_fnc_ambientAnim; 

So he agonize on the ground.

When the player arrive I added an action "load the injured" to the injured what triggers this script:

seb1 attachTo [heli1, [0,2.7,-2]]; 
seb1 setDir getDir heli1; 
[seb1] join (group player); 

seb1 is the name of the injured. It looks fantastic if the heli1 is a Huey: the injured still agonize on the floor of the heli.

You don't have to join him to the player, I just did it because in SOG DLC the AI cry "I'm bleeding" if they are injured if they are in the player's group. But he didnt cry (even if I set his health to 70%). So join is useless. If you can make him cry, please share with me!

 

I didnt finish the task, so unload in not implemented yet, but it need "detach" and "setPos" when unload.

 

  • Like 1

Share this post


Link to post
Share on other sites
10 hours ago, sarogahtyp said:

1st: dont use a BIS function like BIS_fnc_selectRandom if there is an engine command like selectRandom created already. But this is just a performance thing.

2nd: to get a marker position you have to use getMarkerPos

3rd: read the biki entry for each command you use!

 


if (isServer) then
{ 
 _marker_pos = getMarkerPos selectRandom ["marker1", "marker2", "marker3", "marker4", "marker5", "marker6"];
 
 _civ = selectRandom ["civ1", "civ2", "civ3"];

 _civ setPos _marker_pos;
};

 

 

_civ setPos _marker_pos;

Error: _civ is read by setPos as a string and not as an object

 

Share this post


Link to post
Share on other sites
_civ = selectRandom [ civ1, civ2, civ3 ];

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Don't use quote marks in civ array.

  • Thanks 1

Share this post


Link to post
Share on other sites
On 6/8/2021 at 11:52 AM, bardosy said:

This is a very old script (now there are more modern methodes to spawn, but I am old and use my own scripts since OFP).

Hahaha.  I know the feeling brother.  Hey, the script works!  If it ain't broke, don't fix it!

Share this post


Link to post
Share on other sites

I have a problem setting the damage to the spawned civilian, I've used the setDamage command but seems like this doesn't work with the ACE damage/medical sistem

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×