Jump to content
Sign in to follow this  
anthonyfromtheuk

Simple reinforcement script

Recommended Posts

Here is my Simple Reinforcement Script.





https://www.youtube.com/watch?v=3HQfHb-2dDI

Example Mission

Usage

Create a marker on your map where you want the reinforcements to spawn named: reinforce

Activate the script with a trigger put this in to your triggers ON ACT

nul = execVM "reinforcement.sqf";

Put this script below in your mission folder, name it reinforcement.sqf

//Change the reinforcement units side on line 11 for example change it to:
//_side = createcenter east; for Opfor.
//Change the reinforcement units type on line 12 for example change it to:
//_reinforce = [getMarkerPos "reinforce", _side, ["B_medic_F"], [], [], [0.3, 0.6]] call BIS_fnc_spawnGroup; for a Blufor Medic as your reinforcement.
//You can add more units by including more classnames in the same place for example:
//_reinforce = [getMarkerPos "reinforce", _side, ["B_medic_F","B_soldier_AR_F"], [], [], [0.3, 0.6]] call BIS_fnc_spawnGroup; Will spawn a Blufor medic and an AR man as your reinforcement.
//Change how close the unit has to be to join the player on line 35.

if (!isServer) exitwith {};
private ["_side", "_reinforce", "_leaderblue", "_text"];
_side = createcenter west;
_reinforce = [getMarkerPos "reinforce", _side, ["B_soldier_AR_F","B_Soldier_A_F","B_Soldier_GL_F","B_medic_F"], [], [], [0.3, 0.6]] call BIS_fnc_spawnGroup;
_text= {
    [ format["<t size='0.75' color='#FFFFFF'>Reinforcements are inbound, Check the map.</t>",_this], 0,1,5,0,0,301] spawn bis_fnc_dynamicText;

};

call _text;

_leaderblue = leader _reinforce;
_leaderblue move (getPosATL player);
_reinforce setCombatMode "RED";
_reinforce setBehaviour "Aware";

0 = _reinforce spawn {

   _reinforceMrk = createMarker ["Reinforcements",getPosATL (leader _this)];
   "Reinforcements" setMarkerType "mil_dot";
   "Reinforcements" setMarkerColor "ColorGreen";
   "Reinforcements" setMarkerText "Reinforcements";

   while {true} do {
       sleep 0.5;

       if ((player distance (leader _this)) < 15) exitWith {
           {
               [_x] joinsilent player;
           } forEach (units _this);

           deleteMarker _reinforceMrk;

       };

       _reinforceMrk setMarkerPos getPosATL (leader _this);
   };
};
while {true} do {
   sleep 2;

   _leaderblue = leader _reinforce;
   if ((unitReady _leaderblue) && {(alive _leaderblue)}) then {
       sleep 2;
       if (({ alive _x} count (units _reinforce)) != 0) then {
           _leaderblue = leader _reinforce;
           _leaderblue move (getPosATL player);
           _reinforce setCombatMode "RED";
           _reinforce setBehaviour "Aware";


       };
   };
};



//Big thanks to the two main guys on the BIS forums that helped me get original script working (a hunter script effectively the same as above but for the AI to hunt the player instead of join)- Cobra4v320 and Zenophon.
//Also Credit to Lappihuan & Larrow on the BIS forums for thier assistance in improving this script.
//Hope you enjoy this - Anthonyfromtheuk.


//included below are unit Classnames for some Blufor and Opfor units.
//BluFor - NATO
//Men: B_Soldier_A_F, B_soldier_AR_F, B_medic_F, B_crew_F, B_engineer_F, B_soldier_exp_F, B_Soldier_GL_F, B_helicrew_F, B_Helipilot_F, B_soldier_M_F, B_soldier_AA_F, B_soldier_AT_F, B_officer_F, B_soldier_PG_F, B_Pilot_F, B_soldier_repair_F, B_Soldier_F, B_soldier_LAT_F, B_Soldier_lite_F, B_Soldier_SL_F, B_Soldier_TL_F, B_soldier_UAV_F
//Men (Diver): B_diver_F, B_diver_exp_F, B_diver_TL_F
//Men (Recon): B_recon_exp_F, B_recon_JTAC_F, B_recon_M_F, B_recon_medic_F, B_recon_F, B_recon_LAT_F, B_recon_TL_F
//Men (Sniper): B_sniper_F, B_spotter_F
//Men (Story): B_Competitor_F, B_Story_Colonel_F, B_Story_Tank_Commander_F, B_Story_Protagonist_F, B_Story_Pilot_F, B_Story_SF_Captain_F, B_Story_Engineer_F, B_RangeMaster_F
//Opfor - CSAT
//Men: O_Soldier_A_F, O_Soldier_AR_F, O_medic_F, O_crew_F, O_engineer_F, O_soldier_exp_F, O_Soldier_GL_F, O_helicrew_F, O_helipilot_F, O_soldier_M_F, O_Soldier_AA_F, O_Soldier_AT_F, O_officer_F, O_soldier_PG_F, O_Pilot_F, O_soldier_repair_F, O_Soldier_F, O_Soldier_LAT_F, O_Soldier_lite_F, O_Soldier_SL_F, O_Soldier_TL_F, O_soldier_UAV_F
//Men (Diver): O_diver_F, O_diver_exp_F, O_diver_TL_F
//Men (Recon): O_recon_exp_F, O_recon_JTAC_F, O_recon_M_F, O_recon_medic_F, O_recon_F, O_recon_LAT_F, O_recon_TL_F
//Men (Sniper): O_sniper_F, O_spotter_F
//Men (Story): O_Story_CEO_F, O_Story_Colonel_F

When the script is triggered the units defined in the script will spawn at the marker and move towards the player following him wherever he may go until they are within 15m of the player (can be changed) when they will silently join his group and become under his command. The update includes a dynamic marker showing where the reinforcements are on the map. Included at the bottom of the script are unit classnames for Blufor and Opfor.

DYNAMIC MARKER ADDED with help from Larrow, thanks!

Edited by Anthonyfromtheuk
Script updated to include working marker, example mission link updated, updated video

Share this post


Link to post
Share on other sites

I know how to attach a marker to a unit using a seperate script I was using this to do that

_unit = _this select 0;
_marker = _this select 1;

_marker setMarkerColor "ColorGreen";

while{alive _unit}do{
 _marker setMarkerPos (getPos _unit);
 _marker setMarkerDir (getDir _unit);
 sleep 0.1;
};

just dont know how to intergate that in to this script, i have tried and just do not know how to do it correctly.

this is what i was trying it makes the marker but doesn't follow the reinforcement.

_leaderblue = leader _reinforce;
_leaderblue move (getPosATL player);
_reinforce setCombatMode "RED";
_reinforce setBehaviour "Aware";
_marker1 = createMarker["Marker",getPosATL _leaderblue];
"Marker" setMarkerType "group_0";
"Marker" setMarkerColor "ColorGreen";
"Marker" setMarkerText "Reinforce";


};

0 = _reinforce spawn {

   while {true} do {
           _marker1 setMarkerPos (getPos _leaderblue);
           _marker1 setMarkerDir (getDir _leaderblue);
 sleep 0.1;
       if ((player distance (leader _this)) < 15) exitWith {
           {
                [_x] joinsilent player;
           } forEach (units _this);
           deletemarker "Marker";
       };
   };
};

Edited by Anthonyfromtheuk

Share this post


Link to post
Share on other sites

You already have yourself a separate thread there looking after the reinforcements up until they join the players group, why not place it in there?

0 = _reinforce spawn {

_reinforceMrk = createMarker ["Reinforcements",getPosATL (leader _this)];
//other marker commands brush or icon and text etc

while {true} do {
	sleep 3;

	if ((player distance (leader _this)) < 15) exitWith {
		{
			[_x] joinSilent player;
		} forEach (units _this);

		deleteMarker _reinforceMrk;

	};

	_reinforceMrk setMarkerPos getPosATL (leader _this);
};
};

Before you enter the while loop create your marker and set it up with colour , text etc

Whilst in the loop update its position every iteration. You could also update the text here aswell with the distance to player.

When the reinforcements join the player, delete the marker.

The only other thing you may want todo is reduce the sleep in that loop ?

_____________________________________

The loop you are putting the marker in is a separate thread as you spawn it, so _marker1 and _leaderblue are unknown either pass them along to the thread along with _reinforce or create them in that spawned thread like ive shown above. _leaderBlue is not actually needed as you are already passing _reinforce to be able to get a reference from.

Edited by Larrow

Share this post


Link to post
Share on other sites

Thank you Larrow, that works perfectly.

After messing about for the past 45 mins I now know I know nothing lol, cannot figure out the text thing either.

This is my biggest problem with arma 3 editor think "I'll just do that...." spend 4 hours trying... give up. LOSE all interest. Where can I learn more so I can actually understand what I am doing instead of pure trial and error. Is it just using literally PHP like you would use for a webpage?

  • Like 1

Share this post


Link to post
Share on other sites

while {alive player} do{
_distance = player distance getPosATL (leader _this);
hintSilent["Distance: %1",_distance];
sleep 0.5;
};

make sure you spawn that (because of the sleep) and to answer your question:

yes sometimes you can use knowledge from PHP sometimes you need to learn completly new things ;)

don't give up. I suggest you this page.

Edited by Lappihuan

Share this post


Link to post
Share on other sites

Thanks that gives me something to learn :D

Your code is pretty much what I tried except I was trying to get it to work in the dynamic text.

My problem is where to put it without breaking the rest of the script.

Larrow suggested I do it in the loop where the marker is made and the reinforcements distance to player is checked and I agree that seems the right place but when I try putting anything in there it just doesn't work anymore. If I try and define the text it ruins the code

_distance = player distance getPos(leader _this)
_text= {
    [ format["<t size='0.75' color='#FFFFFF'>["Distance: %1",_distance]</t>",_this], 0,1,5,0,0,301] spawn bis_fnc_dynamicText;

to many quotation marks and if i put

call _text

in to the loop it stops it working at all. The above code is a bit different to what I was actually trying but essentially the same and I have tried that now as well.

---------- Post added at 15:46 ---------- Previous post was at 15:44 ----------

How do I rename this thread not so simple reinforcement script :D

Share this post


Link to post
Share on other sites

I never used BIS_fnc_dynamicText but i think you have some syntax errors and the call _text makes no sense, because you spawned allready the BIS_fnc_dynamicText.

I'm not on my PC so i can't look at how BIS_fnc_dynamicText needs to be called correctly but i try to fix your syntax errors ;)

_distance = player distance getPosATL (leader _this)
[ format["<t size='0.75' color='#FFFFFF'>['Distance: %1']</t>",_distance], 0,1,5,0,0,301] spawn bis_fnc_dynamicText;  

but this is just guessing :)

btw. use allwasy getPosATL it is mutch faster.

Share this post


Link to post
Share on other sites

_meters = player distance _reinforce;
_distance = {
    [ format["<t size='0.75' color='#FFFFFF'>%1</t>",_this], 0,1,5,0,0,301] spawn bis_fnc_dynamicText;
};
      (format["Reinforcements are %1 meters out.", _meters] ) call _distance;

was roughly what I was trying to use but i cannot get that nor your second suggestion to work, I dont know where to place them correctly.

The best I got so far was it showed up on screen [Distance:any]

---------- Post added at 17:53 ---------- Previous post was at 16:17 ----------

Still didn't get this working :(

Share this post


Link to post
Share on other sites

well you try to use _this in the array for the BIS_fnc_dynamicText but that var does not exist at this time.

you would need to do it like that:

_distance = player distance getPosATL (leader _this)
[ format["<t size='0.75' color='#FFFFFF'>'Distance: %1'</t>",_distance], 0,1,5,0,0,301] spawn bis_fnc_dynamicText;  

nothing else.

And again, the call in your last line does nothing becaus you cannot call a variable, you can only call functions but the above example should do the trick.

Share this post


Link to post
Share on other sites
Guest

Release frontpaged on the Armaholic homepage.

===============================================

We have also "connected" these pages to your account on Armaholic.

This means in the future you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have.

When you have any questions already feel free to PM or email me!

Edited by Guest
updated with newest version!

Share this post


Link to post
Share on other sites

Give up on ever getting that dynamic text to work properly... I am going to update the download link and video with the Dynamic marker.

Share this post


Link to post
Share on other sites

great, is it possible to set the reinforce position to be dynamicly bound to the player so if i call for reinforcemts they will spawn lets say somewhere within a 300m radius from my current location ?? and also call reinforcements more than once ???

---------- Post added at 21:58 ---------- Previous post was at 21:55 ----------

i figured out to repeat the call, :)

Share this post


Link to post
Share on other sites

I'm getting an empty variable error when running the script. It says something about a line 14 empty variable. I'm guessing that will be fixed in the next update to the script mod? :)

Share this post


Link to post
Share on other sites

Thanks alot for this "simple" script and sharing it.

It works like a charm.

Simple idea, but a great benefit!! :)

Thanks again.

Cheers

McLupo

Share this post


Link to post
Share on other sites

Isn't there a way to have the script create a marker randomized from players position??

I've been testing with no luck!!

here's what i got which works but they spawn in my lap :)

_marker = createMarker ["reinforcements", position player ];

I've tried random and few other commands without success. Sorry i suck at scripting

Edited by JCae2798

Share this post


Link to post
Share on other sites
Isn't there a way to have the script create a marker randomized from players position??

Try BIS_fnc_relPos for this..

Parameters: [object or position, distance, direction]

"Returns a position that is a specified distance and compass direction from the passed position or object."

_marker = createMarker ["reinforcements", [player, 100, random 360] call BIS_fnc_relPos ];

  • Like 1

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
Sign in to follow this  

×