austin_medic 109 Posted August 29, 2015 Alright so I've solved some of the major issues with my unit interaction system, but now I'm deeply confused as to what is wrong with my logic in the scripts that only the player that tied up a surrendered unit can move him. Another instance of the same problem I assume is that when the player escorting the unit is killed the unit doesn't get unassigned from him, despite my code that is supposed to handle that. init.sqf moveCaptive.sqf -- activated via addaction on surrendered unit, should be accessible to all player units on west faction - note the variables are added to all AI units on mission start. scopeName "main"; _handled = false; _unit = cursorTarget; if(_unit getVariable "AUSMD_interact_moving") exitWith {diag_log "MOVE CAPTIVE :: Unit is already being moved.";}; _unit attachTo[player,[0,1,0]]; _unit setVariable ["AUSMD_interact_moving",true,true]; diag_log "MOVE CAPTIVE :: Unit is attached."; _stopMoveAct = _unit addAction ["Stop Moving Captive",{cursorTarget setVariable ["AUSMD_interact_moving",false,true];player setVariable ["AUSMD_interact_transporting",false,true];},nil,1,False,True,"",' player distance cursorTarget < 5 && alive cursorTarget && cursorTarget getVariable "AUSMD_interact_moving" ']; while{_unit getVariable "AUSMD_interact_moving"} do { scopeName "loop"; sleep 2; if(vehicle player != player) then { if(count crew (vehicle player) isEqualTo (getNumber (configFile >> "cfgVehicles" >> (typeOf(vehicle player)) >> 'transportSoldier'))) then { diag_log "MOVE CAPTIVE :: Unit detached because vehicle was full"; breakTo "main"; } else { _veh = vehicle player; diag_log "MOVE CAPTIVE :: Unit detached and put into vehicle"; player setVariable ["AUSMD_interact_transporting",false,true]; sleep 0.1; detach _unit; sleep 0.1; _unit enableAI "ANIM"; sleep 0.1; _unit moveinCargo _veh; waitUntil{vehicle player == player || !alive _unit || !alive _veh || !alive player}; if(!alive _unit || !alive _veh) then { diag_log "MOVE CAPTIVE :: Unit detached because veh exploded or unit is dead"; _unit setVariable ["AUSMD_interact_moving",false,true]; breakTo "main"; }; if(vehicle player == player || !alive player) then { diag_log "MOVE CAPTIVE :: Unit ejected because player ejected"; _unit action["Eject",vehicle _unit]; _unit setVariable ["AUSMD_interact_moving",false,true]; sleep 0.5; [[_unit,"AmovPercMstpSnonWnonDnon_Ease"],"AUSMD_fnc_animation",true,true] spawn BIS_fnc_MP; sleep 0.01; _unit disableAI "ANIM"; }; }; }; }; _unit removeAction _stopMoveAct; diag_log "MOVE CAPTIVE :: Unit detached, script done"; detach _unit; _handled = true; _handled; I've been working on this issue for about 3 hours now and testing with a friend in mp and still doesn't work despite trying different variations I'm also aware there could be some optimizations probably, but I'd prefer just to get something that functions first then go back for optimizations later. NOTE: This needs to be MP compatible Share this post Link to post Share on other sites
fn_Quiksilver 1636 Posted August 29, 2015 IIRC, addAction condition does not understand 'cursorTarget'. change 'cursorTarget' to _target (reserved variable), or create a function which gets called, and use 'cursorTarget' in there. _stopMoveAct = _unit addAction ["Stop Moving Captive",{cursorTarget setVariable ["AUSMD_interact_moving",false,true];player setVariable ["AUSMD_interact_transporting",false,true];},nil,1,False,True,"",' player distance _target < 5 && alive _target && _target getVariable "AUSMD_interact_moving" ']; or: _stopMoveAct = _unit addAction ["Stop Moving Captive",{cursorTarget setVariable ["AUSMD_interact_moving",false,true];player setVariable ["AUSMD_interact_transporting",false,true];},nil,1,False,True,"",'[] call TAG_fnc_myActionCondition; ']; There might be other stuff, that's just what jumped out at me. This is an example of something I cooked up for a rescue mission: player addAction ['Escort',QS_fnc_escort,[],90,TRUE,FALSE,'','[] call QS_fnc_condEscort']; where QS_fnc_condEscort is: private ['_c','_t']; _c = FALSE; _t = cursorTarget; if ((player distance _t) < 5) then { if (_t isKindOf 'Man') then { if (_t getVariable ['QS_rescueTarget',FALSE]) then { if (alive _t) then { if (!(_t getVariable 'QS_underEscort')) then { if (!(QS_mission_targetRescued)) then { _c = TRUE; }; }; }; }; }; }; _c; Share this post Link to post Share on other sites
austin_medic 109 Posted August 30, 2015 Thanks for that, but after changing cursorTarget to _target, the actions do not work at all as they are intended to. Also wiki states nothing about '_target' (at least on the addAction page), so how did you obtain that information exactly? (just curious) interrogate enemy and move actions are broken completely (don't even show up), and the civilian question action is the only thing to appear on captured hostiles. Anyhow doesnt matter now I've solved my issue. Share this post Link to post Share on other sites
dreadedentity 278 Posted August 30, 2015 Also wiki states nothing about '_target' (at least on the addAction page), so how did you obtain that information exactly? (just curious) Share this post Link to post Share on other sites
austin_medic 109 Posted August 30, 2015 Ok I did not catch that bit as I was in a bit of a rush and thats my bad Share this post Link to post Share on other sites