Jump to content
Sign in to follow this  
Bon

AI Recruitment

Recommended Posts

Hi all,

as there were some threads started recently regarding to AI Recruitment and due to some positive feedback on my own script (used in one of my missions) to provide this functionality, I decided to extract it and share it with the rest of you.

The script handles deletion of dead AI bodies as well as cleanup in case the player disconnects.

All in all its a very simple script with no other features than that, however, simplicity is the way of the genius, and maybe it comes in handy for some of you.

Screenshot:

screenshot_unitrecruitment.jpg

Download:

fh-warzone.de

armaholic.com <- thx to Foxhound.

hf.

Edited by Bon
updated downloadlinks

Share this post


Link to post
Share on other sites

Thank you! ive been looking for scripts all night/morning and this was one of them :D

Share this post


Link to post
Share on other sites

Thank you! I was just thinking about doing this in a new mission/campaign I'm making.

Share this post


Link to post
Share on other sites

Hi Bon,

got used to this with the TFor missions and its very nice.

I wanted to implement for off-line use in SP and I wondered could there be an option/var for limiting the amount of times you can select the option before it doesnt show anymore. I kind of wanted it so it was like Tfor mission attached to a tent at base but with say only 3 times it could be used for mission purposes (say SF units and only limited amount of members).

Also how can it be set so it will only recruit a specified size? Like in Tfor you can set server settings and limit to recruit of only 4 or 8 or 12 men size teams at a time.

If this is yet another sub script to do this then any pointers would be great.

BTW I haven't had time to test this script off-line so I might be missing the obvious :)

Share this post


Link to post
Share on other sites

Hi mrcash,

I wanted to implement for off-line use in SP and I wondered could there be an option/var for limiting the amount of times you can select the option before it doesnt show anymore. I kind of wanted it so it was like Tfor mission attached to a tent at base but with say only 3 times it could be used for mission purposes (say SF units and only limited amount of members).

Also how can it be set so it will only recruit a specified size? Like in Tfor you can set server settings and limit to recruit of only 4 or 8 or 12 men size teams at a time.

Set maximum allowed group size in the bon_recruit_units\init.sqf.

For the access limitation, do the following:

In the bon_recruit_units\init.sqf you put in the line

bon_recruit_limitation = -1;

which is the number of times you can access the menu (-1 for unlimited).

In the file bon_recruit_units\open_dialog.sqf you append the following piece of code:

bon_recruit_limitation = bon_recruit_limitation - 1;
if(bon_recruit_limitation == 0) then{
(_this select 0) removeAction (_this select 2);
};

That does the trick. But it's only supposed to be used in SP, as one only has to disconnect and connect again to "refill" his account. To make it MP suitable it becomes way more complicated.

hf.

Share this post


Link to post
Share on other sites

Thanks Bon,

I should have dug a little deeper before asking to be honest, but thats great, and yes its SP only purpose.

Thanks again for info and sharing :)

Share this post


Link to post
Share on other sites

I wonder I you could modify that script so I can recruit both EAST and WEST troops in separate scripts (some use for PvP gameplay)?

Share this post


Link to post
Share on other sites

Hi,

I wonder I you could modify that script so I can recruit both EAST and WEST troops in separate scripts (some use for PvP gameplay)?

it all comes down modifiying the file recruitable_units.sqf.

Atm it looks like this:

bon_recruit_recruitableunits = [
"US_Soldier_AA_EP1",
"US_Soldier_AAT_EP1",
"US_Soldier_AHAT_EP1",
"US_Soldier_AAR_EP1",
"US_Soldier_AMG_EP1",
"US_Soldier_AT_EP1",
"US_Soldier_HAT_EP1",
"US_Soldier_AR_EP1",
"US_Soldier_Engineer_EP1",
"US_Soldier_GL_EP1",
"US_Soldier_MG_EP1",
"US_Soldier_Marksman_EP1",
"US_Soldier_Medic_EP1",
"US_Soldier_EP1",
"US_Soldier_LAT_EP1",
"US_Soldier_B_EP1",
"US_Soldier_SL_EP1"
];

For having different lists depending on, lets say, the player's side, you could write this:

if(side player == WEST) then {
   bon_recruit_recruitableunits = [
"US_Soldier_AA_EP1",
"US_Soldier_AAT_EP1",
"US_Soldier_AHAT_EP1",
"US_Soldier_AAR_EP1",
"US_Soldier_AMG_EP1",
       .....
   ];
};

if(side player == EAST) then {
   bon_recruit_recruitableunits = [
       "TK_Soldier_Medic_EP1",
       "TK_Soldier_Officer_EP1",
       "TK_Soldier_EP1",
       .....
   ];
};

This is just a quick example, actually there's lots and lots of other approaches for this, just try customizing it yourself.

Hf.

Share this post


Link to post
Share on other sites

If I launch that script in init field of a static unit (barracks) won't it be started globally. Should that way work in this case if there are players on both sides.

Share this post


Link to post
Share on other sites

Hi im getting an error everytime i try to use this in my mission. "Resource RecruitUnitsDailog not found" anyone know why this is?

Share this post


Link to post
Share on other sites
Hi im getting an error everytime i try to use this in my mission. "Resource RecruitUnitsDailog not found" anyone know why this is?

Are you sure you have the following lines in your mission's description.ext?

#include "bon_recruit_units\dialog\common.hpp"
#include "bon_recruit_units\dialog\recruitment.hpp"

Share this post


Link to post
Share on other sites
Guest

How do I call the script? Everything I try doesn't seem to work...

Nevermind, figured it out :)

Edited by Guest

Share this post


Link to post
Share on other sites

Hey Bon!

I was searching for a better way to recruit units than what I already have (add action type) and noticed this. I downloaded the example and to my dismay found out it was made for Arma 2 OA... I am in no way an expert script writer but, I took a look at your scripts and didn't see anything that would keep me from using it in Arma 2 vanilla besides the unit names. I am at work now and will try this out later tonight, but figured I would ask if this is even possible. I have to say I am a fan of your work. I used the weapons preset script of yours and it is awsome! I believe it is alot better than refilling ammo boxes. Keep up the great work!

EDIT:

Ok, I have extracted the bon_recruit_units folder from the downloadable mission and this works very well. Step by step I (for those who may want to know):

1. Extract the bon_recruit_units folder into a preexisting mission folder.

2. Change the types of units in the recruitable_units.sqf to Arma 2 friendly types (from US_Soldier_AA_EP1 to USMC_Soldier).

3. Create any inanimate object like a barracks, as I did and name it, for this example, brk.

4. Create a trigger with the following parameters:

Condition -> player distance brk < 20

On Activation -> recruit = player addAction ["Recruit Units","bon_recruit_units\open_dialog.sqf"];

On Deactivation -> player removeAction recruit;

And that should be it!!!

It took me a minute to find out how the dismissing worked but all you do is look at the soldier you want to dismiss and select Dismiss from the Action Menu (so if anyone wants to know).

My only real problem is that once you get within 20 meters of the barrack I named brk the Action will not go away, even if I go outside of the trigger. removeAction for some reason does not work. Any help with this will be great, it is kind of annoying having the "Recruit Units" action up all the time.

Also, is there a way to create vehicles like hummers and tanks with this? I tried adding "HMMWV" as a unit type in the recruitable_units.sqf file but it only displayed an error message. Thanks for the hard work Bon!!!

LAST EDIT:

I just got the action to go away. I placed this addAction ["Recruit Units","bon_recruit_units\open_dialog.sqf"]; into the Init of a Barracks and it works when you are within about 5 meters and looking at it, then disappears if you look away or move further than 5 meters or so away. Hope this helps!

Still if anyone has an Idea of how to get removeAction to work I would like that more. I find it a hassle to have to look at the barrack in just the right way. I would rather just be near it to call the recruit script.

Edited by fro

Share this post


Link to post
Share on other sites

Hi fro,

you can just add the action to the player and use the last parameter of the addaction command defining the condition that must be true to use the action:

player addAction ["Recruit Units","bon_recruit_units\open_dialog.sqf",[],-1,false,true,"",[color="Red"]"player distance brk < 5"[/color]];

This script is supposed to create AI units, not vehicles. Therefore it uses the createUnit command and not the createVehicle command. In fact, both commands are more different to each other than common.

What you could try is this:

In the recruit.sqf there is the line

_unit = group player createUnit [_unittype,_spawnpos,[],0,"FORM"];

Replace it by:

if(_unittype isKindOf "Man") then {
   _unit = group player createUnit [_unittype,_spawnpos,[],0,"FORM"];
} else {
   _unit = _unittype createVehicle _spawnpos;
};

I might work, however, no guarantees - as I said, the intention of this script is to spawn AI soldiers as recruits. A menu to spawn vehicles is something else, and I wouldn't mix it. Rather search for another "vehicle spawn script" which is out there for sure.

hf.

Share this post


Link to post
Share on other sites

Thank you for the fantastic script, but I'm having a problem that I can't seem to resolve...

I have in my Init

[] execVM "bon_recruit_units\init.sqf"; 

and I have in my Description

#include "bon_recruit_units\dialog\common.hpp
#include "bon_recruit_units\dialog\recruitment.hpp"

I also have my trigger setup perfect, and I've also tried to copy over the flag from your example mission, but only the option to recruit comes up. Then when I use that action the dialog comes up, but it doesn't build the unit list.

I guess I'm just extra anxious because I have a friend over today and this script is exactly what we need to PvP over LAN in Zargabad.

Again, thank you very much! :]

I'm running ARMA:CO btw

Share this post


Link to post
Share on other sites
Then when I use that action the dialog comes up, but it doesn't build the unit list.

I had this at first too, when I converted the recruitable units list over to PMC guys, to match my current mission. Turns out the reason my list wasn't being built was because I forgot to put commas after each unit in the list. Maybe you did same thing?

Good luck.

I now have the unit list created with PMC guys, but now when I click on the 'recruit' button, nobody appears. :confused: Still trying to figure it out.

Great script, thank you for sharing.

Share this post


Link to post
Share on other sites

If you provide me your code I will check what's the problem.

hf.

Share this post


Link to post
Share on other sites

Hey Bon,

Everything worked out! I was also able to create vehicles with your recomendation. The only minor problem was that at first the script said it had spawned the vehicle but hadn't, so I changed the spawn position to a marker and now it works great!

I changed this line from your previous post:

_unit = _unittype createVehicle _spawnpos;

to:

_unit = _unittype createVehicle (getMarkerPos "vehspawn");

I didn't have much time to see what else I could do, but maybe later. For now it works great for me.

Thanks!

Edited by fro

Share this post


Link to post
Share on other sites
If you provide me your code I will check what's the problem.

That is extremely generous of you. Thank you Bon. But since I posted that we figured out that for some reason simply by putting the recruitunit line higher up in our init.sqf (above DAC and UPSMON and whatnot), it worked for us. :icon_wink:

I am interested in learning how to further take advantage of this so we can use it in different ways, but I don't understand how to do this part;

"put initialization commands for recruited units into bon_recruit_units\init_newunit.sqf;"

If you have a moment one day, can you (or anyone else who might like to help out of course) please post just one example of how a person might do that? Like say, could you use it to give a recruit one of the large backpack full of ammo, so I could get ammo from him during mission. Or a tripod backpack on one guy the other half on another guy, so I could use them to build a gun.

Or really just any example would be great, so we can learn from that how to do others.

Thanks again, very kind of you.

Share this post


Link to post
Share on other sites

Thanks Bon for sharing your hard work.

This looks awesome.

Something I have always wanted.

Can't wait to try this out. Looks simple enough.

PS Anyone care to upload their custom recruit unit config for hiring BAF, PMC, Team Razor, ACE Delta Force that sort of thing? Save the rest from manually repeating it? Like they do in the DAC area? Would save us a lot of time if you would.

Great script

Thanks

Share this post


Link to post
Share on other sites

PMC (+ 2 from BAF, because they look/dress like PMC)

bon_recruit_recruitableunits = [

"CIV_Contractor1_BAF",
"CIV_Contractor2_BAF",
"Soldier_AA_PMC",
"Soldier_AT_PMC",
"Soldier_Bodyguard_AA12_PMC",
"Soldier_Bodyguard_M4_PMC",
"Soldier_Crew_PMC",
"Soldier_Engineer_PMC",
"Soldier_GL_M16A2_PMC",
"Soldier_GL_PMC",
"Soldier_M4A3_PMC",
"Soldier_Medic_PMC",
"Soldier_MG_PKM_PMC",
"Soldier_MG_PMC",
"Soldier_Pilot_PMC",
"Soldier_PMC",
"Soldier_Sniper_KSVK_PMC",
"Soldier_Sniper_PMC",
"Soldier_TL_PMC"

]

Infantry classnames

http://community.bistudio.com/wiki/ArmA_2_OA:_Infantry#PMC_.28DLC.29

It's just a matter of copying/pasting and adding quotes and commas. A person could probably take time one day to create a master list, and just comment out or delete the parts not being used in that certain mission.

I also have a sandbox mission where the airport area has a section for all West. So I might make a trigger situation where you use all West at once in one mission, and which list comes up just depends on which trigger you activate. So, if you approach the BAF barracks, you get the BAF list, if you approach the Marines barracks, you get USMC, etc....

just a neat script to play around with. I just don't understand how to use the newunit.sqf page.

Share this post


Link to post
Share on other sites
PMC (+ 2 from BAF, because they look/dress like PMC)

Infantry classnames

http://community.bistudio.com/wiki/ArmA_2_OA:_Infantry#PMC_.28DLC.29

It's just a matter of copying/pasting and adding quotes and commas.

I also have a sandbox mission where the airport area has a section for all West. So I might make a trigger situation where you use all West at once in one mission, and which list comes up just depends on which trigger you activate. So, if you approach the BAF barracks, you get the BAF list, if you approach the Marines barracks, you get USMC, etc....

just a neat script to play around with. I just don't understand how to use the newunit.sqf page.

R.Flagg

That is Awesome.

The link Rocks and I WANT A COPY OF THAT REALLY AWESOME sound ing sandbox you are making.

PRETTY PLEASE?

Thanks either way for the list, the link and the pointers.

I love this community.

Share this post


Link to post
Share on other sites

The init_newunit.sqf script provides you a place where to put in code to initialize on the newly spawned recruit.

One example extension of the script could be:

/*****************************************************************
Client Stuff
******************************************************************/
_unit addAction ["<t color='#949494'>Dismiss</t>",BON_RECRUIT_PATH+"dismiss.sqf",[],-10,false,true,""];

[color="Blue"]removeBackpack _unit;
_unit addBackpack "CZ_Backpack_EP1";
(unitBackpack _unit) addMagazineCargo ["30Rnd_556x45_Stanag",6];[/color]

This gives the spawned recruit a CZ Backpack with 6 STANAG magazines in it.

The first section of the script is for code that needs to be run on the server machine and shouldn't be of any interest for you.

hf.

Share this post


Link to post
Share on other sites

Cool. Thank you!

To go a step further, what I hope to do is maybe have specific lines for specific units? So I'm going to try to figure out correct syntax, maybe something like...

if (_unit == Soldier_GL_M16A2_PMC) then 
{
removeBackpack _unit;
      _unit addBackpack "CZ_Backpack_EP1";

.... 
};

if (_unit == 

.... 

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  

×