Jump to content
Sign in to follow this  
Foxhound4444

Evolution type Recruit AI script

Recommended Posts

I am almost done with completing a mission but I need to do one more thing. I want to add an area where ai can be recruited into your own squad. However, I have not been able to find a script to do that. Does anyone know where I can get my hands on one?

Share this post


Link to post
Share on other sites

I'm currently using this via a Popup menu dialog. Pull parts out or adjust it to suit, if you want.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">// Desc: Spawn a new AI unit into your group

// I.C.E. module

//-----------------------------------------------------------------------------

_role = _this select 0;

_group = group player;

_groupCount = (count units _group);

// Count AI players in group

_AICount = 0;

{

if (!(isPlayer _x)) then { _AICount = _AICount + 1 };

} forEach (units _group);

// must be leader

if (player != (leader player)) exitWith { hint "You must be a leader to recruit" };

// limit group size

if (_groupCount >= 6) exitWith { hint "You are already at your ideal squad size." };

if (_AICount >= 3) exitWith { hint "You have reached your group''s AI limit." };

//_role="SoldierWB"; // debug

_AI = _group createUnit [_role, position player, [], 5.0, "NONE"];

_AI setRank "PRIVATE";

//nul=[_AI] execVM 'Scripts\SoldierWInit.sqf'; // perform standard spawn initialisation

//[_AI, format["Private %1, reporting for duty, sir!", name _AI]] call fn_groupChat; // broadcast

_AI groupChat format["Private %1, reporting for duty, sir!", name _AI]; // client only

/*

"SoldierWAA": "AA"

"SoldierWAT": "AT"

"SoldierWAR": "Auto Rifleman"

"BISCamelPilot": "Camel Pilot"

"SoldierWCrew": "Crewman"

"SoldierWMiner": "Engineer"

"SoldierWG": "Grenadier"

"SoldierWMG": "MG"

"SoldierWMedic": "Medic"

"OfficerW": "Officer"

"SoldierWPilot": "Pilot"

"SoldierWB": "Rifleman"

"SoldierWSaboteurAssault": "SF Assault"

"SoldierWSaboteurMarksman": "SF Marksman"

"SoldierWSaboteurRecon": "SF Recon"

"SoldierWSaboteur": "SF Saboteur"

"SoldierWSaboteurPipe": "SF Saboteur Pipe"

"SoldierWSniper": "Sniper"

"SquadLeaderW": "SL"

"TeamLeaderW": "TL"

*/

Call via:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">nul=['SoldierWAT'] execVM 'Scripts\ICE\RecruitAI.sqf';

Share this post


Link to post
Share on other sites

Thanks a lot Dr_Eyeball! This script looks like what I'm looking for. How do you integrate this via popup menu? With the call script, is it possible to attach that to a building like in evolution?

Share this post


Link to post
Share on other sites

The popup menu I'm refering to looks like this screenshot using an updated version of Dialog Framework. I'll release that project in the coming weeks.

th_ICE_RecruitSoldier1.jpg

If you just want to use Action menu's attached to a building, try something like this:

Modify the first 2 lines of (RecruitAI.sqf) code above to obtain a different set of "action"-related param's:

RecruitAI.sqf:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_actionParams = _this select 3;

_role = _actionParams select 0;

...

init.sqf: (for example only)

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_building = nearestBuilding player; // change this to suit. eg: use a marker or similar idea

_action = _building addAction ['Recruit AT soldier', "Scripts\ICE\RecruitAI.sqf", ['SoldierWAT'], 0, false, false, ''];

_action = _building addAction ['Recruit Sniper', "Scripts\ICE\RecruitAI.sqf", ['SoldierWSniper'], 0, false, false, ''];

Share this post


Link to post
Share on other sites

How can I add this to the radio menu by selecting say "Recruit AI" as the radio selection then the next radio menu that comes up asking what class and then they spawn when selected.

Share this post


Link to post
Share on other sites

You can't. You would instead need a dialog to do that. The lack of nested radio option menus is the reason I created the popup menus.

For simplicities sake, you could have up to 10 Radio options or a long list of Action Menu items. For anything more than that, you need a dialog.

If you want to use the actual Recruit AI dialog I created for Evolution (see image), you can grab the original source from here: Download dialog source files ver 1b and modify to suit.

But it's too detailed to explain how to incorporate that. Good luck.

Share this post


Link to post
Share on other sites

Eyeball, I've been testing out the sample mission from your dialog framework and it is pretty impressive. I was wondering how I could incorporate it in my own mission? I've tried the simple copy and paste of the necessary files, but it seems that it won't work.

EDITED: Sorry, got it working. Just kept pressing T key waiting for something to happen but in fact the T key wasn't working like in the template. Have to get into dialog through action menu. How did you get the dialog to work through T key?

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _Action = _soldier addAction ["I.C.E.", "Scripts\ICE\ActivatePopupMenuViaAction.sqf", [ /* params */ ], 0, false, false, "teamSwitch" ];

In that example the 'T' key works because addAction uses the extended syntax which allows for a 'shortcut' parameter, using 'teamSwitch' in this case.

I tried to use a shortcut which would not clash in MP: teamSwitch, teamNext, teamPrev are unused in MP. However, you may have noticed when testing in a SP environment, that sometimes pressing 'T' will activate the original SP teamSwitch operation, so it's only realiable in MP (for that particular shortcut). Need to make a list of what could be suitable shortcut's.

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  

×