IndeedPete 1038 Posted October 18, 2013 Hey Folks, i have a small issue in my mission. Once the player gets killed he can choose another unit via teamswitch until the whole squad is dead. However, he looses access to the supports provided by BIS' support module. I've tried several ways to re-add the supports, noe of them worked. Any ideas? What i've tried already: 1. Adding supports to all playable units // Works only for actual player {[_x, IP_SuppReq, IP_SuppPro_Trans] call BIS_fnc_addSupportLink} forEach IP_PLAYERGROUP; 2. Script gets called from init and waits for the groupleader to die and then links the module to the new leader: sleep 1; _grp = group player; while {(count units _grp) > 0} do { _ldr = leader _grp; waitUntil{!alive _ldr}; IP_SuppReq synchronizeObjectsRemove [_ldr]; _ldr synchronizeObjectsRemove [iP_SuppReq]; waitUntil{(leader _grp) != _ldr}; _ldr = leader _grp; // [_ldr, IP_SuppReq, IP_SuppPro_Trans] call BIS_fnc_addSupportLink; IP_SuppReq synchronizeObjectsAdd [_ldr]; _ldr synchronizeObjectsAdd [iP_SuppReq]; }; Tried the above code with different ways, none of them works. Share this post Link to post Share on other sites
Larrow 2822 Posted October 19, 2013 When you die before you respawn i thought an AI member becomes the leader until you respawn so wouldn't waitUntil{(leader _grp) != _ldr}; in your second example have the effect of trying to add the supports to this AI? Its never going to detect the change in leadership when the player respawns as the script is waiting for this AI that got assigned as leader to die before rechecking. Could you not just use a respawn evenHandler on the player to do this ? player addEventHandler ["Respawn", { _player = _this select 0; [_player , IP_SuppReq, IP_SuppPro_Trans] call BIS_fnc_addSupportLink; }]; Share this post Link to post Share on other sites
pro 10 Posted October 19, 2013 Same problem here with my mission where my JTAC lose all support after spawn, biggest problem is that he is alone. Share this post Link to post Share on other sites
IndeedPete 1038 Posted October 19, 2013 Hey, tried eventhandlers before (just forgot to post it), no luck. The second script actually works, it detects the change in leadership but the function to add supports doesn't do anything. Either BIS_fnc_addSupportLink or the synch by myself (which is basically what BIS_fnc_addSupportLink does) won't work. I guess once you synched the module you can't synch it to antother unit as well. (I've tried to add it to multiple units - no luck.) Seems like a problem within the module? Maybe something to report to BIS? Share this post Link to post Share on other sites
Larrow 2822 Posted October 20, 2013 (edited) onPlayerRespawn.sqf _oldUnit = _this select 1; _oldProviders = _oldUnit getVariable ["BIS_SUPP_allProviderModules",[]]; _HQ = _oldUnit getVariable ["BIS_SUPP_HQ",nil]; if ((count _oldProviders) > 0) then { { _providerModule = _x; { if (typeOf _x == "SupportRequester" && _oldUnit in (synchronizedObjects _x)) then { [player, _x, _providerModule] call BIS_fnc_addSupportLink; }; }forEach synchronizedObjects _providerModule; }forEach _oldProviders; }; { _used = _oldUnit getVariable [format ["BIS_SUPP_used_%1",_x], 0]; player setVariable [format ["BIS_SUPP_used_%1", _x], _used, true] } forEach [ "Artillery", "CAS_Heli", "CAS_Bombing", "UAV", "Drop", "Transport" ]; player setVariable ["BIS_SUPP_transmitting", false]; player kbAddTopic ["BIS_SUPP_protocol", "A3\Modules_F\supports\kb\protocol.bikb", "A3\Modules_F\supports\kb\protocol.fsm", {call compile preprocessFileLineNumbers "A3\Modules_F\supports\kb\protocol.sqf"}]; if (!(isNil "_HQ")) then { player setVariable ["BIS_SUPP_HQ", _HQ]; }; This works for respawn type GROUP and SIDE. From what ive tested respawn types INSTANT and BASE already transfer your supports for you. The above code transfers needed variables from old unit to new including amount of supply calls already used. If you want to respawn the unit with a whole new set of support calls change _used = _oldUnit getVariable [format ["BIS_SUPP_used_%1",_x], 0]; player setVariable [format ["BIS_SUPP_used_%1", _x], _used, true] for player setVariable [format ["BIS_SUPP_used_%1", _x], 0, TRUE] TEST_MISSION Event "Respawn" does not seem to work for type GROUP or SIDE, totally gets ignored? Is this correct or is this a bug? as i cant remember ever using type GROUP and event respawn. Is it because the swap is just a camera transfer rather than a new unit being created? Something as simple as player addEvenHandle ["Respawn", { player sidechat "respawn event" }]; just never happens but works fine for respawn types BASE and INSTANT. Edited October 20, 2013 by Larrow 1 Share this post Link to post Share on other sites
IndeedPete 1038 Posted October 20, 2013 Thank you very much. But i've might expressed myself wrong: it is an SP-Mission where the Player basically just teamswitches to another unit when he's killed. Hence no real respawn. But i will mess around with your code there and see if i can get it working. :) Share this post Link to post Share on other sites
doc_no1UK 10 Posted October 20, 2013 Not using scripts here pete but sp mission i make just F5 sync all your team to support requester so when i die and play as next guy in my group it works fine. Share this post Link to post Share on other sites
IndeedPete 1038 Posted October 20, 2013 Thanks, thought of that. Problem is that certain supports become availabe later in the mission so i have to add them via scripting. Plus at one point i spawn a group that joins the player and thereby becomes playable, i can't synch that one in the editor... ;) Share this post Link to post Share on other sites
IndeedPete 1038 Posted October 20, 2013 (edited) @Larrow: I've adapted it a little bit and it seems to work fine. Muchas gracias, see you in the credits. ;) Edited October 20, 2013 by IndeedPete Share this post Link to post Share on other sites
Larrow 2822 Posted October 20, 2013 But i've might expressed myself wrong:No i just didnt read your post properly or look at your mission till after id experimented for a couple of hours with MP respawning :DI then tried a quick experiment with onTeamSwitch and couldnt get it to work in your mission before eventually falling asleep on the keyboard. I was going to come back and try implementing it into your mission today but i see you have got it done GJ Share this post Link to post Share on other sites
IndeedPete 1038 Posted October 21, 2013 Haha, well nevermind then. It seems to work so thank you again. Still, BIS should work on the support module regarding this issue sometime. :) Share this post Link to post Share on other sites
shark-attack 2 Posted January 9, 2014 Hey, sorry to jump onboard but ..... Is there any solution on how to pass down the chain of command the available support options in Multi player mode with group respawn enabled when the current group leader is killed. Share this post Link to post Share on other sites
Larrow 2822 Posted January 9, 2014 Hey, sorry to jump onboard but .....Is there any solution on how to pass down the chain of command the available support options in Multi player mode with group respawn enabled when the current group leader is killed. I think (been a few months since i looked at this) but what is in post #5 should do what you want. Rather than adding it back to the player, find the new group leader and add it to them. Something like... _oldUnit = _this select 1; _oldGroup = group _oldUnit; //We dont care if he was not the leader if (leader _oldGroup == _oldUnit) then { h = [_oldUnit, _oldGroup] spawn { _oldUnit = _this select 0; _oldGroup = _this select 1; _oldProviders = _oldUnit getVariable ["BIS_SUPP_allProviderModules",[]]; _HQ = _oldUnit getVariable ["BIS_SUPP_HQ",nil]; //Wait for a new leader to be assigned waitUntil { leader _oldGroup != _oldUnit }; _leader = leader _oldGroup; if ((count _oldProviders) > 0) then { { _providerModule = _x; { if (typeOf _x == "SupportRequester" && _oldUnit in (synchronizedObjects _x)) then { [_leader, _x, _providerModule] call BIS_fnc_addSupportLink; }; }forEach synchronizedObjects _providerModule; }forEach _oldProviders; }; { _used = _oldUnit getVariable [format ["BIS_SUPP_used_%1",_x], 0]; _leader setVariable [format ["BIS_SUPP_used_%1", _x], _used, true] } forEach [ "Artillery", "CAS_Heli", "CAS_Bombing", "UAV", "Drop", "Transport" ]; _leader setVariable ["BIS_SUPP_transmitting", false]; _leader kbAddTopic ["BIS_SUPP_protocol", "A3\Modules_F\supports\kb\protocol.bikb", "A3\Modules_F\supports\kb\protocol.fsm", {call compile preprocessFileLineNumbers "A3\Modules_F\supports\kb\protocol.sqf"}]; if (!(isNil "_HQ")) then { _leader setVariable ["BIS_SUPP_HQ", _HQ]; }; }; }; but will need testing to make sure the group returns ok from a dead unit and that the new group leader has been assigned ok. Share this post Link to post Share on other sites
shark-attack 2 Posted January 9, 2014 (edited) Thanks a million Larrow. The above code works to a certain extent. If i have the module synched to a unit who is not the team leader [eg JTAC] and he is killed then the support assets are handed to the current team leader which is great for the specific mission im working on. However the support options are only passed down one time, after the Team leader is killed then all options are lost. Would it be possible to keep handing the available assest down the chain until all units are killed ? Also for future missions would it be possible to enable the script for the team leader from the mission start ? Best wishes shark attack Edited January 9, 2014 by shark-attack Share this post Link to post Share on other sites
Larrow 2822 Posted January 10, 2014 The above code works to a certain extent. If i have the module synched to a unit who is not the team leader [eg JTAC] and he is killed then the support assets are handed to the current team leaderThat's weird as i wrote the above only to hand off supports from the leader if he dies. if (leader _oldGroup == _oldUnit) then { as your JTAC is not the leader it should of ignored him dying and done nothing. However the support options are only passed down one time, after the Team leader is killed then all options are lost. Would it be possible to keep handing the available assets down the chain until all units are killed ?This is what should happen in the above script :/. How are you implementing the script?? in the onPlayerRespawn.sqf ??Weird that its all working ass about face to what i expected. Im out this morning but when i get back this afternoon ill run some tests see whats happening. Share this post Link to post Share on other sites
shark-attack 2 Posted January 10, 2014 Cant get the script to execute at all this morning. I have saved the code as assets.sqf and i am calling it from a trigger which detects the death of the team leader !(alive leader sealteam) . Thanks for your help with this Larrow Share this post Link to post Share on other sites
barbolani 198 Posted June 2, 2015 Hi, despite this is an old post, I just want to thank you Larrow for this wonderful script which made a lot happier all the Antistasi players. Thanks! Share this post Link to post Share on other sites
mikeap 0 Posted August 8, 2015 I'm having a similar issue. I have a MP coop mission where the mission leader has virtual artillery and transportation available, but loses it when he dies or leaves server. Is there a way to do this through initialization using mission-added request modules? Player name: MissionLeader Support Requester name: LeaderRequester Arty Requester name: VirtualArty Transport Requester name: VirtualTransport Share this post Link to post Share on other sites
Larrow 2822 Posted August 9, 2015 Something like.. //initPlayerLocal.sqf _player = _this select 0; myTag_fnc_reSyncSupports = { if ( _this isEqualTo MissionLeader ) then { { [ _this, LeaderRequester, _x ] call BIS_fnc_addSupportLink; }forEach [ VirtualArty, VirtualTransport ]; }; }; _player addEventHandler [ "Respawn", { ( _this select 0 ) call myTag_fnc_reSyncSupports; }]; _player call myTag_fnc_reSyncSupports; Should be enough, may depend on where the variables you have provided are initialised. (e.g are they in the units/modules name field or are they init in init.sqf etc check the WIKI for initialisation order )Some of the code in post #5 maybe worth looking at if you need to keep track of number of supports already used. Share this post Link to post Share on other sites