Jump to content
Sign in to follow this  
=Odin=

eject a specific AI from my squad

Recommended Posts

G'day, I am using a Recruit dialog and, am have trouble understanding how to delete a chosen Ai out of my squad.

I can eject the entire squad no problem using this;

Quote[/b] ]{[_x] join grpNull;} forEach units (group player);

After looking at the wiki and searching the forums, I tried to understand how Dr Eyball did it, in his TeamStatus Dialog. I really have know idea on what commands to use, to find who is in my squad, and eject that one AI layabout who would rather watch Two elephants play a piano while a seal bangs a kipper on a table, than stick with his squad!

Could someone please help me on this?

Thx

Odin

Share this post


Link to post
Share on other sites

There's a few ways to match the player to remove.

Either:

- construct an array of player objects

- match the player's (vehicleVarName) string - this is used in example below

- match the player's name string (risky, especially for AI)

- possibly via an index into the units array, not sure if order is consistent though

- probably more ways

It sounds like you've already got a dialog, presumably with a listBox containing the player names and maybe the data field contains the player's (vehicleVarName) string.

This example should be safe since the player string is used client side only.

It's not tested, but should be close to working as is.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">RemoveAIOrPlayerFromYourGroup =

{

_playerToFind = _this select 0;

_CheckIfPlayerMatches =

{

private['_player'];

_player = _this select 0;

if (format["%1", _player] == _playerToFind) then

{

[_player] join grpNull;

if (isPlayer _player) then

{

player groupChat format['Player %1 was kicked from the group.', name _player]; // only seen by caller, not group

}

else

{

player groupChat format['A.I. %1 soldier was removed from group.', typeOf _player]; // only seen by caller, not group

// optional - delete AI

deleteVehicle _player;

};

};

};

{

private['_unit', '_isVehicle'];

_unit = _x;

if (group _unit == group player) then

{

_isVehicle = ((_unit isKindOf "LandVehicle") || (_unit isKindOf "Air") || (_unit isKindOf "Ship"));

if (_isVehicle) then

{

// process vehicle crew list

{

[_x] call _CheckIfPlayerMatches;

} forEach crew _unit;

}

else

{

[_unit] call _CheckIfPlayerMatches;

};

};

} forEach (units player);

};

Call with something like:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private['_player'];

_player = lbData [IDC_PlayerListBox, lbCurSel IDC_PlayerListBox];

[format['%1', _player]] call RemoveAIOrPlayerFromYourGroup;

If you were browsing the latest Team Status dialog code, look at the function TSD9_RemoveAIOrPlayerFromYourGroupByName, which basically does the same things as the code above.

Share this post


Link to post
Share on other sites

Thx for the Help Dr Eyeball, I have not yet made a listbox for my Dialog, been at it all morning getting a bit lost with what controls to add to the dialog, hehe I do have a rather handsome looking black rectangle but, if only I could get it to reveal some text wink_o.gif

On the naming of AI with the vehicleVarName string do I name them Via a seperate script as I recruit them or from within my RecruitAI script that I call from the dialog?

Thx For the script mate, one question about using it do I use

Quote[/b] ]private['_player'];

_player = lbData [iDC_PlayerListBox, lbCurSel IDC_PlayerListBox];

[format['%1', _player]] call RemoveAIOrPlayerFromYourGroup;

This in the Init? srry for all the questions hehe I am only a Tradesman

Thx again

well back to my Listbox making

Share this post


Link to post
Share on other sites

I don't think you need to name them at all. If you don't name them, vehicleVarName uses some default name. (Might be West-1-2:3 or something?).

Or instead of vehicleVarName, just use format['%1', _player]. I think it's the same result.

Regarding that block of code, that goes somewhere after you create the dialog and accept input. Or just attach it to a 'Kick' button action.

dialog hpp code:

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

class KickButton: RscButton

{

//idc = IDC_KickButton;

x = 0.1;

y = 0.1;

// etc

text = "Kick";

action = "[format['%1', lbData [IDC_PlayerListBox, lbCurSel IDC_PlayerListBox]]] call RemoveAIOrPlayerFromYourGroup";

};

Send me the pbo or dialog files if you need. Use http://dump.no/ to upload.

I presume you've seen this dialog framework topic. Be done in 20 minutes.

Share this post


Link to post
Share on other sites

Thanx Doc, I have uploaded the files My Dialog It is only for the West side, but I am still working on revamping the East and indipendent, also I left my attempt at a Listbox in the file just so you can have a chuckle(its a mess) but the actual Recruit Dialog works fine.

Thanx alot for haveing a look at this much appreciated.

That dialog framework topic was what made me want to try my hand at doing this, but I have never tried to alter your original seeing as it works well as is.

Well got to go mow me lawn now crazy_o.gif

Cya

Share this post


Link to post
Share on other sites

Here's a tidied up version of your mission: listbox_war2.Intro.zip

All it does is make it work, not make it presentable.

- keep the messy crap like dialog control class definitions separate from your dialog description files. It makes it 1 10th of the size and much more readable.

Purpose?

What's your motivation for creating this dialog? There's already a few recruit/disband scripts out there (but maybe not combined with full functionality) - 3 were done by me (Evolution recruit dialog, Team Status dialog, popup menu for recruit & airdrops), so I presume there must be more in other missions, although I can't think of any off hand.

Is there any need for a (general public version) of a recruit/disband dialog?

What functionality would it require? (Probably a player list, join button, disband button, AI soldier types list & recruit button).

I might consider doing a more detailed and flexible version . It could also be simply added to the Team Status dialog though.

Share this post


Link to post
Share on other sites

Excellent, Thank-you so much mate,

I see what you mean about keeping dialog control class definitions separate from your dialog description files, I can read it with ease now biggrin_o.gif Its Awsome.

My motivation came after seeing the EVO version of RecruitingAI, I was haveing trouble modifying the Rank system, so I did a lot of searching and made my own Dialog.

Originally I made this just as a basic Recruit dialog, being able to only spawn the basic grunts for my own use.

Then a local mate of mine used it and said I should release it for public use primarily because of its simplicity. After its release I recieved a few Emails and PM's asking me to fix MP issues, could I add SF forces, NCO's and an Officer. Then half way thru that conversion someone suggested I add the Kick from squad function as they were experiencing the usual AI problems (shooting POW's, leaving formation, refusing to Move) so I tried my best and failed, But thanks to you it is a go'er.

I love your work and have the whole collection in my missions folder. ICE is amazing, and your work in EVO really helps make it such a great mission in my honest opinion.

Doc I really do owe you a Carton for this so if you are ever in Toowoomba QLD give us a Oi mate, drinks are on me

Cheers

Odin

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  

×