Advertisement
Guest User

Untitled

a guest
May 15th, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. // sets random skill depending on unit's class
  2. //#define DEBUG_MODE_FULL
  3. #include "script_component.hpp"
  4. params ["_unit"];
  5. private["_t","_sc","_sa","_i","_st","_sv","_fc","_fnc_getskillvalue"];
  6.  
  7. _fnc_getskillvalue = {
  8. private["_sv","_min","_var"];
  9. _min = _this select 0; //min skill
  10. _var = _this select 1; //max variance
  11. (_min + random _var)
  12. };
  13.  
  14. _t = typeOf _unit;
  15. _sc = [configfile>>"cfgvehicles">>_t>>"asr_ai_level", "number", 6] call CBA_fnc_getConfigEntry;
  16. TRACE_2("config",_unit,_sc);
  17.  
  18. // also check for override setting
  19. _i = 0;
  20. {
  21. if (_t in _x) exitWith {
  22. _sc = _i;
  23. TRACE_2("override",_unit,_i);
  24. };
  25. INC(_i);
  26. }
  27. forEach GVAR(levels_units);
  28.  
  29. _sa = GVAR(sets) select _sc; // get skill array for this unit
  30. if (count _sa == 0) exitWith {}; // do not run if empty
  31. if (isNull _unit) exitWith {};
  32.  
  33. _fc = 1;
  34. if (count GVAR(factions) > 0) then {
  35. { if (faction _unit == _x select 0) exitWith {_fc = _x select 1} } forEach GVAR(factions); TRACE_2("Faction coefficient",_unit,_fc);
  36. };
  37.  
  38. _i = 0;
  39. while {_i < count _sa} do {
  40. _st = _sa select _i; // skill type
  41. INC(_i);
  42. switch (_st) do {
  43. case "courage": {
  44. {
  45. _sv = ((_sa select _i) call _fnc_getskillvalue) * _fc;
  46. [_unit,[_x,_sv]] call FUNC(setSkill);
  47. }
  48. forEach ["courage"];
  49. };
  50. case "reloadSpeed": {
  51. {
  52. _sv = ((_sa select _i) call _fnc_getskillvalue) * _fc;
  53. [_unit,[_x,_sv]] call FUNC(setSkill);
  54. }
  55. forEach ["reloadSpeed"];
  56. };
  57. case "commanding": {
  58. {
  59. _sv = ((_sa select _i) call _fnc_getskillvalue) * _fc;
  60. [_unit,[_x,_sv]] call FUNC(setSkill);
  61. }
  62. forEach ["commanding"];
  63. };
  64. case "aimingAccuracy": {
  65. {
  66. _sv = ((_sa select _i) call _fnc_getskillvalue) * _fc;
  67. [_unit,[_x,_sv]] call FUNC(setSkill);
  68. }
  69. forEach ["aimingAccuracy"];
  70. };
  71. case "aimingShake": {
  72. {
  73. _sv = ((_sa select _i) call _fnc_getskillvalue) * _fc;
  74. [_unit,[_x,_sv]] call FUNC(setSkill);
  75. }
  76. forEach ["aimingShake"];
  77. };
  78. case "aimingSpeed": {
  79. {
  80. _sv = ((_sa select _i) call _fnc_getskillvalue) * _fc;
  81. [_unit,[_x,_sv]] call FUNC(setSkill);
  82. }
  83. forEach ["aimingSpeed"];
  84. };
  85. case "spotDistance": {
  86. {
  87. _sv = ((_sa select _i) call _fnc_getskillvalue) * _fc;
  88. [_unit,[_x,_sv]] call FUNC(setSkill);
  89. }
  90. forEach ["spotDistance"];
  91. };
  92. case "spotTime": {
  93. {
  94. _sv = ((_sa select _i) call _fnc_getskillvalue) * _fc;
  95. [_unit,[_x,_sv]] call FUNC(setSkill);
  96. }
  97. forEach ["spotTime"];
  98. };
  99. };
  100. INC(_i);
  101. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement