Jump to content
Sign in to follow this  
deadlyhabit

Dynamic Guarded Hostage Rescue

Recommended Posts

I'm not fully sure I know what your after but this may get you going a little.

/////////////////////////////////////////////////////////
// Randomize placement of a group within 6 spots
// gue_random6.sqf
/////////////////////////////////////////////////////////

if (! isServer) exitwith {}; // NOTE: in multiplayer, only server should create random numbers.

// Create Group for units to be spawned into; must have group created BEFORE spawning units in.
_SideHQ = createCenter east;
_SideHQ1 = createCenter west;
groupAlpha = createGroup east;
groupHostage = createGroup west;

// Pick Location ///////////////////////////////////////////////////////////////////////
_posHostage = [Hostage1, Hostage2, Hostage3, Hostage4, Hostage5, Hostage6] call BIS_fnc_selectRandom;
_extraction = getMarkerPos "Extraction";

// Show Enemy Spawn Location as a GPS Coord in Hint
_gridPos = mapGridPosition _posHostage;

hint format ["Position %1", _gridPos];

//Generate Hostages
H1 = groupHostage createUnit ["B_recon_F", _posHostage, [], 0, "FORM"];
H2 = groupHostage createUnit ["B_recon_TL_F", _posHostage, [], 0, "FORM"];
H3 = groupHostage createUnit ["B_recon_exp_F", _posHostage, [], 0, "FORM"];
H4 = groupHostage createUnit ["B_recon_M_F", _posHostage, [], 0, "FORM"];

{
// _x setcaptive true; // enable if you don't want them killed
removeAllWeapons _x;
removeallweapons _x;
removeallassigneditems _x;
removeVest _x;
removebackpack _x;
removeheadgear _x;
removegoggles _x;
nul = [_x] execVM "Hostage_male.sqf";
} foreach [H1,H2,H3,H4];

//Generate Soldiers using dynamic naming
_i=1;
{
_unit = groupAlpha createUnit [_x, _posHostage, [], 0, "FORM"];
_unit setdir 360;
missionNamespace setVariable ["G" + str(_i),_unit];
_i=_i+1;
} foreach  ["O_Soldier_AR_F","O_soldier_M_F","O_Soldier_GL_F","O_Soldier_lite_F","O_recon_M_F","O_recon_LAT_F","O_recon_TL_F","O_recon_medic_F"];

//Triggers

//Victory
_trgVic = createTrigger ["EmptyDetector" , getMarkerPos "Extraction"];
_trgVic setTriggerArea [50, 50, 0, false];
_trgVic setTriggerType "END1";
_trgVic setTriggerActivation ["WEST", "PRESENT", false];
_trgVic setTriggerTimeout [10, 10, 10, false ];
_trgVic setTriggerStatements ["{_x in thislist} foreach  [H1,H2,H3,H4]", "", ""];

//Loss
_trgLoss = createTrigger["EmptyDetector", getPos H1];
_trgLoss setTriggerArea [0, 0, 0, false];
_trgLoss setTriggerType "LOOSE";
_trgLoss setTriggerActivation ["NONE", "PRESENT", false];
_trgLoss setTriggerTimeout [10, 10, 10, false ];
_trgLoss setTriggerStatements ["{alive _x} count  units groupHostage != 4 ", "'", ""];

This works great, NICE JOB, in testing, I am able to add more AI units, my question is....

How much more work would it be to have guarding AI spawn around the hostages in more a random circle or spread out manner? I ask because at this point they spawn in wedge formation with _unit setdir 360

and when I change it too _unit setdir 359 they all line up in formation.

What I was thinking on doing is adding some transport trunk, I figure may be in the array or just narrow _posHostage to 1 or 2 with trunk nearby.

But what's involved with changing the spawning radius of guard units? I have added 16 guards with 8 hostages.

Thanks for your time!

Share this post


Link to post
Share on other sites

It should be very easy just change a couple of lines in the script

_unit = groupAlpha createUnit [_x, _posHostage, [], 0, "FORM"];
_unit setdir 360;

100 would be the random Radius

"NONE" = no formation

dostop _unit; stop them from running back to player or group leader

change to this

_unit = groupAlpha createUnit [_x, _posHostage, [], 100, "NONE"];
dostop _unit;
_unit setdir (random 360);

Share this post


Link to post
Share on other sites

Thanks guy... so I am using another AI behavior script for all the other units and this command allows units to not be under that AIbehavior script, is this how it would be placed?

_this setVariable ["NOAI",1,false];

_unit = groupAlpha createUnit [_x, _posHostage, [], 100, "NONE"];

_this setVariable ["NOAI",1,false];

dostop _unit;

_unit setdir (random 360);

Again, thanks!!

Share this post


Link to post
Share on other sites

Not exactly as it will depend on the variables in the other script.

It may not know what _x or _posHostage are and _unit would be _this

Post the script so we have more info.

Share this post


Link to post
Share on other sites
Not exactly as it will depend on the variables in the other script.

It may not know what _x or _posHostage are and _unit would be _this

Post the script so we have more info.

VcomAI

http://forums.bistudio.com/showthread.php?176244-AI-Overhaul-Reactive-Squads

_this setVariable ["NOAI",1,false];

this command tells the units to not follow the AI script

Share this post


Link to post
Share on other sites

Ok I'm a little lost now.

If you want to tune off Vcom AI for units spawned in Guard script then it would be

_unit = groupAlpha createUnit [_x, _posHostage, [], 100, "NONE"];
_unit  setVariable ["NOAI",1,false];
dostop _unit;
_unit setdir (random 360);

That should do it I think.

Share this post


Link to post
Share on other sites

[/color]Hey thanks man I will give it a go and let you know. Sry, that AIbehavior script is kind of a new one that is usually on the 1st page of this editing/scripting info. If you haven't yet, check it out its pretty cool. I tried to give you the info, wasn't 100% sure what you needed.

Share this post


Link to post
Share on other sites

In DS the option to untie hostages doesnt work. Do I need to add

if (! isServer) exitwith {};

to beginning of hostage.sqf?

Share this post


Link to post
Share on other sites

Has anyone been able to use this script with MP? I am not getting the option to "untie" the hostages in MP on my server.

the hostages follow the commands leading upto this point, but no addaction option in MP. It works fine in SP/editor.

_hostageact1 = _man addaction ["Untie","Hostagevars.sqf"];

Share this post


Link to post
Share on other sites

I had a thought, see if changing the hostage_male.sqf to the following works

fnc_addact = {
   _man = _this;
   hint "action added";// debug 
   _man addAction ["Untie", "Hostagevars.sqf"];
};
// _null = [this] execVM "Hostage_male.sqf"
// hostage
_CivnotRescued = true;
_man = _this select 0;
_man setcaptive true;

//_hostageact1 = _man addaction ["Untie","Hostagevars.sqf"];
[_man, "fnc_addact", nil, true] spawn BIS_fnc_MP; 
// rest of the code >>

Share this post


Link to post
Share on other sites

hey that didnt work, it also looks like this whole script needs to be worked on for MP. The trigger for all hostages dead didn't go either in server.

May be someone out there who knows more about MP scripting then me can look at this and try to fix it for MP.

thanks for your time.

Share this post


Link to post
Share on other sites

Is there anyway to get the soldiers closer together? If I place the object in a house two of the guards are always outside unless the building is big. Just for knowledge I used pens for object markers. That way I dont run into the same problem with helicopter pick ups.

Share this post


Link to post
Share on other sites
It should be very easy just change a couple of lines in the script

_unit = groupAlpha createUnit [_x, _posHostage, [], 0, "FORM"];
_unit setdir 360;

100 would be the random Radius

"NONE" = no formation

dostop _unit; stop them from running back to player or group leader

change to this

_unit = groupAlpha createUnit [_x, _posHostage, [], 100, "NONE"];
dostop _unit;
_unit setdir (random 360);

this should help you out. keep in mind this script is not working in MP. Anyone want to look at it I would greatly appreciate it.

Share this post


Link to post
Share on other sites

Has anybody been able to make this work in MP yet?

Share this post


Link to post
Share on other sites
Has anybody been able to make this work in MP yet?

No, to help out, the AI units do go into captive mode, the addaction does not work for MP. I don't even get the option to "untie" the units when on the ground. So not sure if the units join silent once released.

If anyone wants to dig through this, please do, its a cool script for HVT.

Share this post


Link to post
Share on other sites

I have some issues with my script for addaction to hostage rescue.

This is what was working before but for some reason now it doesn't work.

God_fnc_addAction = {

object = _this select 0;

script = _this select 1;

object addAction script;

};

civgrp = createGroup WEST;

rescuer = civgrp createUnit ["C_journalist_F", getPos uniter, [], 0, "NONE"];

[[rescuer, ["<t color=#ffff00'>Rescue Hostages</t>", "rescuer join player]], "God_fnc_addAction", true, true, true] spawn BIS_fnc_MP;

[[[],"rescue.sqf"],"BIS_fnc_execVM",true,true,true] spawn BIS_fnc_MP;

[{rescuer addAction ["<t color='#ffff00'>Rescue Hostage</t>","[rescuer,rescuer1] join player"]},'BIS_fnc_call',true,true,true] spawn BIS_fnc_MP;

the first one works in multiplayer on the server but the unit doesn't join my group and the second two will not show the action on the menu when you get near the hostage. Please advise, why won't it join me? this is spawned via a script file.

It was working before but now it doesn't work anymore probably since they did another update recently.

Please advise, thank you in advance.

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  

×