fnc_heavyWeaponHandlePlayerWeaponChanged.sqf 955 B

12345678910111213141516171819202122232425262728293031323334353637
  1. params ["_unit", "_weapon"];
  2. diag_log "Handling Weapon Swap";
  3. if(_weapon == "" && !isForcedWalk _unit) exitWith { diag_log "No Weapon"; };
  4. diag_log format["%1 :: %2",_weapon, _unit];
  5. private _fn_unForceWalk = {
  6. params["_target"];
  7. diag_log "Unforce Walk";
  8. _target setVariable ["RD501_FORCE_WALK", false];
  9. _target forceWalk false;
  10. };
  11. private _forceWalk = _unit getVariable ["RD501_FORCE_WALK", false];
  12. diag_log format["Checking _forceWalk :: %1", _forceWalk];
  13. if(_weapon == "" && _forceWalk) exitWith {
  14. _unit call _fn_unForceWalk;
  15. };
  16. private _fn_forceWalk = {
  17. params["_target"];
  18. diag_log "Force Walk";
  19. _target setVariable ["RD501_FORCE_WALK", true];
  20. _target forceWalk true;
  21. };
  22. diag_log format["Weapon in force walk list :: %1", (_weapon in RD501_FORCE_WALK_WEAPONS)];
  23. if(_weapon in RD501_FORCE_WALK_WEAPONS) exitWith
  24. {
  25. if(!isForcedWalk _unit) then{
  26. _unit call _fn_forceWalk;
  27. };
  28. };
  29. if(_forceWalk) exitWith
  30. {
  31. _unit call _fn_unForceWalk;
  32. };