Jump to content
Sign in to follow this  
cookies2432

Need help with mission script

Recommended Posts

So what i wanna do is to make an ai join my group when i'm at a certain distance away from him. Problem is, it could be random where he is. I've tried the "Attatch To" script but it doesn't seem to work for me and i've also tried to use "if (_x distance <5) but that doesn't work either. I'm not very good at scripting : /. Any help with this would be appriciated.

Share this post


Link to post
Share on other sites

we could script it for you but you need to be more specify about that scenario

Share this post


Link to post
Share on other sites

Well. A pilot is ejecting from a plane and then the player needs to find him and when he does, the pilot will join his group. Thing is, he could parachute out anywhere.

Share this post


Link to post
Share on other sites

Ok there are marker for pilot

waitUntil {(getPos pilot select 2) < 2 };
		
	_markerpilot = createMarker ["pilotmarker", getPos pilot];
	_markerpilot setMarkerType "hd_objective";
	_markerpilot setMarkerColor "ColorGrey";
	_markerpilot setMarkerText "PILOT";
	_markerpilot setMarkerSize [0.5,0.5];
	
	_pilotpos = [] spawn {
	
		while {alive pilot} do {
	
				"pilotmarker" setMarkerPos getpos pilot;
				sleep 2;
		};
	};

Next is the ask is that for MP or SP?

Share this post


Link to post
Share on other sites

SP and wow, thanks! I understand what the script does but i don't like, understand the scripting language.

Share this post


Link to post
Share on other sites

I gotta learn arma scripting at some point, it's just the fact that there are around 1700 scripting commands O____O

Share this post


Link to post
Share on other sites
waitUntil{sleep 0.5; ((player distance PILOTNAME) < 2)};
[PILOTNAME] join player; 
//at the end of your init.sqf (easiest way)

You could also use a trigger for that

 

Condition:(player distance PILOTNAME) < 2

OnActivation: [PILOTNAME] join player;

 

 

Replace PILOTNAME with the name you gave the pilot in the editor.

 

https://community.bistudio.com/wiki/join

 

 

 

I gotta learn arma scripting at some point, it's just the fact that there are around 1700 scripting commands O____O

 

 

Don't get intimidated by the amount of script commands, the language is mostly very simple, and most of the command you'll never use.

Share this post


Link to post
Share on other sites
private ["_markerpilot", "_pilotpos", "_pilot"];
		
waitUntil {(getPos pilot select 2) < 2 };
		
	_markerpilot = createMarker ["pilotmarker", getPos pilot];
	_markerpilot setMarkerType "hd_objective";
	_markerpilot setMarkerColor "ColorGrey";
	_markerpilot setMarkerText "PILOT";
	_markerpilot setMarkerSize [0.5,0.5];
	
	_pilotpos = [] spawn {
	
		while {alive pilot} do {
	
				"pilotmarker" setMarkerPos getpos pilot;
				sleep 2;
		};
	};
	
waitUntil {({isPlayer _x AND (_x distance pilot) < 10} count switchableUnits) != 0};

[_pilot] joinSilent (group player);
terminate _pilotpos;
deleteMarker _markerpilot;

Test it!!

Share this post


Link to post
Share on other sites

if you're like me (a scripting noob) and use the editor triggers alot this is what I do for SP;

 

Give the pilot a name then just make a trigger with the condition...

Player distance INSERT_NAME_HERE < 5

 

in the ACT of the trigger paste this...

INSERT_NAME_HERE joinAsSilent [player, 2];

 

works every time in SP even if you have 10 teammates already.

Good luck! :)

Share this post


Link to post
Share on other sites
waitUntil {({isPlayer _x AND (_x distance pilot) < 10} count switchableUnits) != 0};

This make no sense. In SP there is only ONE Player. And if the player in game, switchableUnits more the 0. You can use this code in MP. But you have to change switchable to playable

 

Btw: Waituntil checks per frame. Slow it down and use sleep-command inside. You do not need frame checks in this case

 

For singleplayer is this enough:

waituntil {sleep 1; player distance pilotname < 10};
[pilotname] joinsilent group player;

Or use a trigger. R3vo wrote a example

Share this post


Link to post
Share on other sites

I will try them all. Thanks a lot people!  :D

Bohemia has such a nice community, that's a big reason why i love this game!

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  

×