Jump to content
Sign in to follow this  
ZZEZ

AI/addAction behavior on dedicated

Recommended Posts

Hey.

I'm having a problem with a mission I am working on, it evolves arresting 4 HVTs - this is working fine in local server but as soon as I enter dedicated the problems start mounting, I use this script to arrest the HVTs and get them to follow the player:

In the init.con

I did that because I learned that addaction is local

//===================ADD ARREST HVT ACTIONS SERVER
if (isServer) then {
[-1, {POWS = [hvt1]; hvt1 addAction ["Arrest HVT","rescuePows.sqf",[POWS],1,false,true,"","(_target distance _this) < 3"];POWS2 = [hvt2]; hvt2 addAction ["Arrest HVT","rescuePows.sqf",[POWS2],1,false,true,"","(_target distance _this) < 3"];POWS3 = [hvt3]; hvt3 addAction ["Arrest HVT","rescuePows.sqf",[POWS3],1,false,true,"","(_target distance _this) < 3"];POWS4 = [hvt4]; hvt4 addAction ["Arrest HVT","rescuePows.sqf",[POWS4],1,false,true,"","(_target distance _this) < 3"];}] call CBA_fnc_globalExecute;
};

The script itself:

//////////////////////////////////////////////////////////////////
// Function file for Armed Assault
// Created by: kylania
//////////////////////////////////////////////////////////////////

_per = _this select 0;  // Person who had the addAction
_ldr = _this select 1;  // Person who used the addAction
_act = _this select 2;  // ID of the addAction

// Group given in the arguments section (ie: [POWS]
_grp = _this select 3 select 0;

// Remove the rescue option - disabled for now
//_per removeAction _act;

// Join preselected units (POWS) to callers group, silently.
{[_x] joinSilent _ldr} forEach _grp;

Now this is all working fine and dandy in local server, I can walk up to the HVTs and the action pops up on all of em, I can arrest all of them and put them inside a Humvee and drive away.

When I try doing that in Dedicated..where do I start - I don't even get the addAction option to arrest them, I can fix it by leaving or renaming my group using another script[i disabled it to test it if was causing it and nope] but its annoying that the players have to rename their groups to get that action.

After that - when 1 ai gets in to the Humvee the rest will refuse to enter it and if that ai gets in to the gunner seat he will start gunning down the other HVTs even that they are in my group....

So..what the heck?how can I fix the addaction and stop the hvts from gunning down the other hvts?

Oh I forgot to mention - the addaction actually appears without leaving the group on the HVTs only if they are dead so...its not really being useful

Edited by ZZEZ

Share this post


Link to post
Share on other sites

No comment on the shooting stuff, but seems to me that you are trying to make it a bit too complicated. It only takes something like this, assuming the HVTs are placed in editor:

HVTs' init field:

this addaction ["Arrest HVT","rescuePows.sqf",[],1,false,true,"","(_target distance player) < 3"];

rescuepows.sqf:

_t = _this select 0;
[_t] joinsilent group player;
_t removeaction (_this select 2);

Share this post


Link to post
Share on other sites

The effect of addaction is not broadcast over the network and remain local to the client the command is executed on.

So you're addaction is local to the servers session, try changing the (isServer) to (local player) in the init.sqf

Share this post


Link to post
Share on other sites

Thanks shk, I'll try that

@fencr0c - I use the CBA command "call CBA_fnc_globalExecute" so its actually executing on all clients and I know that it works because no where else is the arrest option is executed but I get that option after renaming/leaving my group or looking at the corpse of the hvt, its weird..the game is letting me arrest dead hvt but not a living one unless I abandon my group

Share this post


Link to post
Share on other sites

Yeah, but he's using CBA_fnc_globalExecute, which, I assume because of the name, runs it on all machines.

Share this post


Link to post
Share on other sites

ok I just finished testing in dedicated and all I can say is great success!

borat.jpg

Anyway, I just copied over shk's code so it looks like this:

init.con

//===================ARREST HVT ACTIONS SERVER
if (isServer) then {
[-1, {hvt1 addaction ["Arrest HVT","rescuePows.sqf",[],1,false,true,"","(_target distance player) < 3"]; hvt2 addaction ["Arrest HVT","rescuePows.sqf",[],1,false,true,"","(_target distance player) < 3"]; hvt3 addaction ["Arrest HVT","rescuePows.sqf",[],1,false,true,"","(_target distance player) < 3"]; hvt4 addaction ["Arrest HVT","rescuePows.sqf",[],1,false,true,"","(_target distance player) < 3"];}] call CBA_fnc_globalExecute;
};

rescuepows.sqf

_t = _this select 0;
[_t] joinsilent group player;
//_t removeaction (_this select 2);

To get around the ai shooting each other I set them as captive if they are unarmed, the script gives them 50% chance to be unarmed or not[they must be armed opfor as standard] and then accordingly broadcast objective complete/failed.

bla4 is public variable thats declared false, hvt1 is the dude in question..when you want the script to end just declare it as true.

if(isServer) then
{
If (!bla4) then {
           _rand1 = round(random 1);
           if (_rand1 == 0) then {
               while {!bla4} do {
                   if (!alive hvt1) then {
                      [-1, {"1" objStatus "DONE"; tskobj_1 setTaskState "SUCCEEDED"; objective2 = true; publicvariable "objective2";}] call CBA_fnc_globalExecute;
                   };
                   sleep 1;
               };

           };

           if (_rand1 == 1) then {
               removeallweapons hvt1;
               hvt1 setCaptive true;
               while {!bla4} do {
                   if (!alive hvt1) then {
                       [-1, {"1" objStatus "FAILED"; tskobj_1 setTaskState "FAILED"; objective2 = true; publicvariable "objective2";}] call CBA_fnc_globalExecute;
                   };
                   sleep 1;
               };
           };
};
};

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  

×