Jump to content
Soapbox0331

addMissionEventHandler script Locality questions

Recommended Posts

This is a great solution to random intel on AI from @wogz187 that is working for me in MP dedicated:

 

missionNameSpace setVariable ["intel_hints", ["SMALL DIARY", "DOCUMENTS", "UNIT PATCH"]];

 

addMissionEventHandler ["EntityKilled", {    
    params ["_killed", "_killer", "_instigator"];
    
    if ((faction _killed) == "CIV_f" || faction _killer isEqualTo faction _killed) exitWith {false};
        [_killed,
    "Search for intel",
    "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
    "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
    "!alive _target",
    "_caller distance _target <3",
    {_caller playMove "AinvPknlMstpSrasWrflDnon_Putdown_AmovPknlMstpSrasWrflDnon";},
    {},
    {params ["_target", "_caller", "_actionId", "_arguments"];

            _target removeAction _actionID;
            []spawn {
                hint "Searching...";
                sleep 1;

                if ((round random 10) > 7) then {
                    hint selectRandom (missionNameSpace getVariable ["intel_hints", []])
                } else {
                    hint "Nothing found..."
                }
            }
        },
    {},
    [],
    2,
    0,
    false,
    false,
    false
] remoteExec ["BIS_fnc_holdActionAdd", 0, _killed];
}];

 

I am running it from init.sqf: [] execVM "randomIntel.sqf";

 

1) There are multiple "Search for intel" entries on a single AI (looks like one per player). Does running this from initPlayerLocal correct that? 

 

2) For JIP, does having a publicVariable in this script allow players joining late to see this addAction?

Share this post


Link to post
Share on other sites
14 minutes ago, Soapbox0331 said:

init.sqf

 

Forget that it exists.

 

14 minutes ago, Soapbox0331 said:

initPlayerLocal

 

Right forest, wrong tree - you are still adding/updating the MEH/variables/holdAction every time a player joins. Try initServer.sqf.

 

As for JIP, they're in missionNameSpace, so new joins should be receiving their current values.

  • Thanks 1

Share this post


Link to post
Share on other sites
1 hour ago, Harzach said:

 

Right forest, wrong tree - you are still adding/updating the MEH/variables/holdAction every time a player joins. Try initServer.sqf.

 

As for JIP, they're in missionNameSpace, so new joins should be receiving their current values.

 

Thanks @Harzach 

 

Forget that it exists.

 

What is appropriate for the init.sqf...if anything?

Edited by Soapbox0331
added question

Share this post


Link to post
Share on other sites
7 hours ago, Harzach said:

initPlayerLocal.sqf and initServer.sqf.

 

And let me clarify - forget it when creating MP missions. For SP, where server and client are the same, it's fine.

 

See https://community.bistudio.com/wiki/Event_Scripts

 

Thanks for the clarification @Harzach, that is very helpful...I was struggling with the role of init.sqf for MP.

 

Share this post


Link to post
Share on other sites

@Harzach 

Along this same line, would like to add the opportunity to place defective ammo on dead AI. I have an ammo can with this:

[    
    this,                                                
    "Draw bad ammo",                                            
    "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",        
    "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",        
    "_this distance _target < 3",                            
    "_caller distance _target < 3",                            
    {player playMove "AinvPknlMstpSrasWrflDnon_Putdown_AmovPknlMstpSrasWrflDnon";},                                            
    {},                                                        
    {AmmoDrawn = true; publicVariable "AmmoDrawn"; hint "ammo drawn";},                    
    {},                                                        
    [],                                                        
    2,                                                        
    0,                                                        
    true,                                                    
    false                                                    
] remoteExec ["BIS_fnc_holdActionAdd", 0];


BadAmmo.sqf:

addMissionEventHandler ["EntityKilled", {    
    params ["_killed", "_killer", "_instigator"];
    
    if ((faction _killed) == "CIV_f" || faction _killer isEqualTo faction _killed) exitWith {false};
        [_killed,                                               
        "Plant bad ammo",                                           
        "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",       
        "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",       
        "_this distance _target < 3 && AmmoDrawn",                           
        "_caller distance _target < 3 && AmmoDrawn",                           
        {player playMove "AinvPknlMstpSrasWrflDnon_Putdown_AmovPknlMstpSrasWrflDnon";},                                                       
        {},                                                       
        {hint "ammo planted";},                   
        {},                                                       
        [],                                                       
        2,                                                       
        0,                                                       
        true,                                                   
        false                                                   
] remoteExec ["BIS_fnc_holdActionAdd", 0, _killed];
}];

 

1) If I have [] execVM "BadAmmo.sqf"; in initServer.sqf, does it run as soon as AmmoDrawn = true? Or am I running that script from the addAction on the ammo can?

 

2) Also to confirm, using the publicVariable "AmmoDrawn", new joins (JIP) will have this option once they join?

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

×