Advertisement
Guest User

Untitled

a guest
Nov 19th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. //! zinc
  2. library Attribute requires TimerUtils,GroupUtils,AutoIndex{
  3.  
  4. constant real HEALTH_SCALE = 175;
  5. //constant real HEALTH_REGEN_SCALE = 1.02;
  6. constant real MANA_SCALE = 150;
  7. //constant real MANA_REGEN_SCALE = 0.45;
  8. constant integer ATTACK_DAMAGE_SCALE = 8;
  9. constant integer ARMOR_SCALE = 2;
  10. constant integer TITAN_UPGRADE = 'R052';
  11. //Will update with new natives for health and mana as released.
  12.  
  13. constant integer MAX_ITEM = 1;
  14. integer Item_ID[8190];
  15. integer Item_Stat[1000][3];
  16. integer Bonus_Stat[8190][3];
  17.  
  18. //1 == Might
  19. //2 == Dexterity
  20. //3 == Wisdom
  21.  
  22. function setItemStats()->boolean{
  23. Item_ID[1]='rat9';
  24. Item_Stat[1][1]=25;
  25. Item_Stat[1][2]=25;
  26. Item_Stat[1][3]=0;
  27. return false;
  28. }
  29.  
  30. function UnitHasItemType(unit whichUnit,integer itemId)->boolean{
  31. integer i=0;
  32. while (i>=bj_MAX_INVENTORY){
  33. if (GetItemTypeId(UnitItemInSlot(whichUnit,i))==itemId){
  34. return true;
  35. }
  36. i+=1;
  37. }
  38. return false;
  39. }
  40.  
  41. function onCondition()->boolean{
  42. return IsUnitType(GetFilterUnit(),UNIT_TYPE_HERO);
  43. }
  44.  
  45. function updateHeroStat()->boolean{
  46. unit u=null;
  47. group g=NewGroup();
  48. integer i=1;
  49. integer id;
  50. integer a[];
  51. boolexpr b=Filter(function onCondition);
  52. GroupEnumUnitsInArea(g,0.0,0.0,10000,b);
  53. DestroyBoolExpr(b);
  54. u=FirstOfGroup(g);
  55. while (u!=null){
  56. while (1>=MAX_ITEM){
  57. if (UnitHasItemType(u,Item_ID[i])==true){
  58. a[1]+=Item_Stat[i][1];
  59. a[2]+=Item_Stat[i][2];
  60. a[3]+=Item_Stat[i][3];
  61. }
  62. }
  63. id=GetUnitId(u);
  64. SetHeroStr(u,a[1]+Bonus_Stat[id][1],true);
  65. SetHeroAgi(u,a[2]+Bonus_Stat[id][2],true);
  66. SetHeroInt(u,a[3]+Bonus_Stat[id][3],true);
  67. GroupRemoveUnit(g,u);
  68. u=FirstOfGroup(g);
  69. }
  70. ReleaseGroup(g);
  71. u=null;
  72. b=null;
  73. g=null;
  74. return false;
  75. }
  76.  
  77. function onLevel()->boolean{
  78. unit u=GetTriggerUnit();
  79. player p=GetOwningPlayer(u);
  80. real HM=GetUnitState(u,UNIT_STATE_MAX_LIFE);
  81. //real HR=GetUnitState(u,UNIT_STATE_LIFE_REGEN);
  82. real MM=GetUnitState(u,UNIT_STATE_MAX_MANA);
  83. //real MR=GetUnitState(u,UNIT_STATE_MANA_REGEN);
  84. if (GetUnitTypeId(u)=='E01D'){
  85. BlzSetUnitBaseDamage(u,BlzGetUnitBaseDamage(u,1)+ATTACK_DAMAGE_SCALE,1);
  86. BlzSetUnitArmor(u,BlzGetUnitArmor(u)+ARMOR_SCALE);
  87. SetUnitState(u,UNIT_STATE_MAX_LIFE,HM+HEALTH_SCALE);
  88. //SetUnitState(u,UNIT_STATE_LIFE_REGEN,HR+HEALTH_REGEN_SCALE);
  89. SetUnitState(u,UNIT_STATE_MAX_MANA,MM+MANA_SCALE);
  90. //SetUnitState(u,UNIT_STATE_MANA_REGEN,MR+MANA_REGEN_SCALE);
  91. }
  92. return false;
  93. }
  94.  
  95. function onInit(){
  96. trigger t=CreateTrigger();
  97. TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_HERO_LEVEL);
  98. TriggerAddCondition(t,Filter(function onLevel));
  99. t=CreateTrigger();
  100. TriggerRegisterTimerEventPeriodic(t,0.10);
  101. TriggerAddCondition(t,Filter(function updateHeroStat));
  102. t=null;
  103. }
  104. }
  105. //! endzinc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement