Advertisement
Halvhjearne

removeclothes.sqf

Dec 22nd, 2013
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.21 KB | None | 0 0
  1. // Created by [GEEK SQUAD]Churchie
  2. // Contributors to getting it working are:| cyrq | Manatee Hunter | Deasil | OnlyblackSurvivor | Thank you!
  3. //epoch version and updates to check for ai, humanity and gender by HALV
  4. player removeAction s_clothes;
  5. s_clothes = -1;
  6. private["_body","_result","_models2use","_femodels","_defmodels","_model","_humanity","_side","_hero","_bandit","_survivor","_Fside","_Hside"];
  7. _body = _this select 3;
  8. _model = typeOf _body;
  9. _side = side (group _body);
  10. _humanity = _body getVariable ["humanity",0];
  11. ////////////////////settings area////////////////////
  12. //models that can be taken
  13. _models2use = ["RU_Policeman_DZ","Priest_DZ","Haris_Press_EP1_DZ","Pilot_EP1_DZ","Functionary1_EP1_DZ","Rocker3_DZ","Rocker1_DZ","Rocker2_DZ","Rocker4_DZ","SurvivorW3_DZ","BanditW2_DZ","SurvivorWcombat_DZ","SurvivorWdesert_DZ","SurvivorWurban_DZ","SurvivorWpink_DZ","Rocket_DZ","Soldier1_DZ","Sniper1_DZ","CZ_Soldier_Sniper_EP1_DZ","Camo1_DZ","FR_OHara_DZ","FR_Rodriguez_DZ","Graves_Light_DZ","CZ_Special_Forces_GL_DES_EP1_DZ","Soldier_Bodyguard_AA12_PMC_DZ","Soldier_Sniper_PMC_DZ","GUE_Soldier_Sniper_DZ","GUE_Soldier_Crew_DZ","GUE_Soldier_CO_DZ","GUE_Soldier_2_DZ","GUE_Commander_DZ","Ins_Soldier_GL_DZ","TK_INS_Soldier_EP1_DZ","TK_INS_Warlord_EP1_DZ","GUE_Soldier_MG_DZ"];
  14. //all female models
  15. _femodels = ["SurvivorW3_DZ","SurvivorWcombat_DZ","SurvivorWdesert_DZ","SurvivorWurban_DZ","SurvivorWpink_DZ","BanditW2_DZ"];
  16. //all default models
  17. _defmodels = ["Survivor2_DZ","Bandit1_DZ","SurvivorW2_DZ","BanditW1_DZ","Survivor3_DZ","Soldier_Crew_PMC"];
  18. //amount of humanity to define hero
  19. _hero = (_humanity >= 5000);
  20. //amount of negative humanity to define bandit
  21. _bandit = (_humanity <= -5000);
  22. //in between these amount will end up survivor
  23. _survivor = (_humanity <= 5000) or (_humanity >= -5000);
  24. //friendly ai side
  25. _Fside = resistance;
  26. //hostile/Bandit ai side
  27. _Hside = east;
  28. /////////////////////////////////////////////////////
  29. switch (true) do {
  30.     case (_bandit and (_model in _femodels)):
  31.     {Skin_switch_class = "BanditW1_DZ"; diag_log "bandit female detected";};
  32.     case (_bandit and !(_model in _femodels)):
  33.     {Skin_switch_class = ["Bandit1_DZ","Bandit2_DZ"] call bis_fnc_selectrandom; diag_log "bandit male detected";};
  34.     case (_hero and (_model in _femodels)):
  35.     {Skin_switch_class = "SurvivorW2_DZ"; diag_log "hero female detected";};
  36.     case (_hero and !(_model in _femodels)):
  37.     {Skin_switch_class = "Survivor3_DZ"; diag_log "hero male detected";};
  38.     case ((_humanity !=0) and (_survivor) and (_model in _femodels)):
  39.     {Skin_switch_class = "SurvivorW2_DZ"; diag_log "survivor female detected";};
  40.     case ((_humanity !=0) and (_survivor) and !(_model in _femodels)):
  41.     {Skin_switch_class = ["Survivor2_DZ","Soldier_Crew_PMC"] call bis_fnc_selectrandom; diag_log "survivor male detected";};
  42.     case ((_side == _Hside) and (_model in _femodels)):
  43.     {Skin_switch_class = "BanditW1_DZ"; diag_log "Bandit (east) ai female detected";};
  44.     case ((_side == _Hside) and !(_model in _femodels)):
  45.     {Skin_switch_class = ["Bandit1_DZ","Bandit2_DZ"] call bis_fnc_selectrandom; diag_log "Bandit (east) ai male detected";};
  46.     case ((_side == _Fside) and (_model in _femodels)):
  47.     {Skin_switch_class = "SurvivorW2_DZ"; diag_log "resistance ai soldier female detected";};
  48.     case ((_side == _Fside) and !(_model in _femodels)):
  49.     {Skin_switch_class = ["Survivor2_DZ","Soldier_Crew_PMC","Survivor3_DZ"] call bis_fnc_selectrandom; diag_log "resistance ai soldier male detected";};
  50.     default
  51.     { //should not happend
  52.         if(_model in _femodels)then{
  53.             Skin_switch_class = ["BanditW1_DZ","SurvivorW2_DZ"] call bis_fnc_selectrandom;
  54.         }else{
  55.             Skin_switch_class = ["Bandit1_DZ","Survivor2_DZ"] call bis_fnc_selectrandom;
  56.         };
  57.         _txt = format["Something went wrong while checking skin %1 %2 %3 %4 %5 %6",_body,typeOf _body,_side,_humanity,Skin_switch_class,_this];
  58. //      cutText [_txt, "PLAIN DOWN"];
  59.         diag_log _txt;
  60.     };
  61. };
  62. if(_model in _models2use) then {
  63.     _model2skin = "Skin_" + _model;
  64.     _result = [player,_model2skin] call BIS_fnc_invAdd;
  65.     if (_result) then {
  66.         player playActionNow "PutDown";
  67.         private["_name","_method","_methodStr"];
  68.         _isGutted = _body getVariable["meatHarvested",false];
  69.         _name = _body getVariable["bodyName","unknown"];
  70.         _method = _body getVariable["deathType","unknown"];
  71.         _methodStr = localize format ["str_death_%1",_method];
  72.         _position = getPosATL _body;
  73.         _dir = getDir _body;
  74.         _currentAnim = animationState _body;
  75.         private ["_weapons","_magazines","_primweapon","_secweapon"];
  76.         _weapons = weapons _body;
  77.         _primweapon = primaryWeapon _body;
  78.         _secweapon = secondaryWeapon _body;
  79.         if(!(_primweapon in _weapons) && _primweapon != "") then {
  80.             _weapons = _weapons + [_primweapon];
  81.         };
  82.         if(!(_secweapon in _weapons) && _secweapon != "") then {
  83.             _weapons = _weapons + [_secweapon];
  84.         };
  85.         _magazines = magazines _body;
  86.         private ["_newBackpackType","_backpackWpn","_backpackMag"];
  87.         dayz_myBackpack = unitBackpack _body;
  88.         _newBackpackType = (typeOf dayz_myBackpack);
  89.         if(_newBackpackType != "") then {
  90.             _backpackWpn = getWeaponCargo unitBackpack _body;
  91.             _backpackMag = getMagazineCargo unitBackpack _body;
  92.         };
  93.         _currentWpn = currentWeapon _body;
  94.         _muzzles = getArray(configFile >> "cfgWeapons" >> _currentWpn >> "muzzles");
  95.         if (count _muzzles > 1) then {
  96.             _currentWpn = currentMuzzle _body;
  97.         };
  98.         diag_log "Attempting to switch model";
  99.         diag_log str(_weapons);
  100.         diag_log str(_magazines);
  101.         diag_log (str(_backpackWpn));
  102.         diag_log (str(_backpackMag));
  103.         _body setPosATL dayz_spawnPos;
  104.         _oldUnit = _body;
  105.         _group = createGroup west;
  106.         _newUnit = _group createUnit [Skin_switch_class,position player,[],0,"NONE"];
  107.         _newUnit setPosATL _position;
  108.         _newUnit setDir _dir;
  109.         {
  110.             _newUnit removeMagazine _x;
  111.         } forEach magazines _newUnit;
  112.         removeAllWeapons _newUnit;
  113.         {
  114.             if (typeName _x == "ARRAY") then {
  115.                 _newUnit addMagazine [_x select 0,_x select 1]
  116.             } else {
  117.                 _newUnit addMagazine _x
  118.             };
  119.         } forEach _magazines;
  120.         {
  121.             _newUnit addWeapon _x;
  122.         } forEach _weapons;
  123.         if(str(_weapons) != str(weapons _newUnit)) then {
  124.             {
  125.                 _weapons = _weapons - [_x];
  126.             } forEach (weapons _newUnit); {
  127.                 _newUnit addWeapon _x;
  128.             } forEach _weapons;
  129.         };
  130.         if(_primweapon != (primaryWeapon _newUnit)) then {
  131.             _newUnit addWeapon _primweapon;
  132.         };
  133.         if(_secweapon != (secondaryWeapon _newUnit) && _secweapon != "") then {
  134.             _newUnit addWeapon _secweapon;
  135.         };
  136.         if (!isNil "_newBackpackType") then {
  137.             if (_newBackpackType != "") then {
  138.                 _newUnit addBackpack _newBackpackType;
  139.                 _oldBackpack = dayz_myBackpack;
  140.                 dayz_myBackpack = unitBackpack _newUnit;
  141.                 _backpackWpnTypes = [];
  142.                 _backpackWpnQtys = [];
  143.                 if (count _backpackWpn > 0) then {
  144.                     _backpackWpnTypes = _backpackWpn select 0;
  145.                     _backpackWpnQtys = _backpackWpn select 1;
  146.                 };
  147.                 _countr = 0;
  148.                 {
  149.                     dayz_myBackpack addWeaponCargoGlobal [_x,(_backpackWpnQtys select _countr)];
  150.                     _countr = _countr + 1;
  151.                 } forEach _backpackWpnTypes;
  152.                 _backpackmagTypes = [];
  153.                 _backpackmagQtys = [];
  154.                 if (count _backpackmag > 0) then {
  155.                     _backpackmagTypes = _backpackMag select 0;
  156.                     _backpackmagQtys = _backpackMag select 1;
  157.                 };
  158.                     _countr = 0;
  159.                 {
  160.                     dayz_myBackpack addmagazineCargoGlobal [_x,(_backpackmagQtys select _countr)];
  161.                     _countr = _countr + 1;
  162.                 } forEach _backpackmagTypes;
  163.             };
  164.         };
  165.         diag_log "Taking Clothes. Equipment:";
  166.         diag_log str(weapons _newUnit);
  167.         diag_log str(magazines _newUnit);
  168.         diag_log str(getWeaponCargo unitBackpack _newUnit);
  169.         diag_log str(getMagazineCargo unitBackpack _newUnit);
  170.         removeAllWeapons _oldUnit;
  171.         {
  172.             _oldUnit removeMagazine _x;
  173.         } forEach magazines _oldUnit;
  174.         deleteVehicle _oldUnit;
  175.         _newUnit setDamage 1;
  176.         _newUnit setVariable["bodyName",_name,true];
  177.         _newUnit setVariable["deathType",_method,true];
  178.         if (_isGutted) then {
  179.             _newUnit setVariable["meatHarvested",true,true];
  180.         };
  181.     } else {
  182.         cutText ["You need a free slot to take clothing", "PLAIN DOWN"];
  183.     };
  184. }else{
  185.     if (_model in _defmodels) then {
  186.         cutText ["You cant take default clothes", "PLAIN DOWN"];
  187.     } else {
  188.         _txt = format["You cant take these clothes (%1 not supported)",_model];
  189.         cutText [_txt, "PLAIN DOWN"];
  190.         diag_log _txt;
  191.     };
  192. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement