Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.41 KB | None | 0 0
  1. //! zinc
  2. library PirateHunter requires TimerUtils,Status,GroupUtils,Projectile,AIDS{
  3.  
  4. private{
  5. constant integer ABIL_ID = 'A0K6';
  6. unit Current_Target[8191];
  7. }
  8.  
  9. struct data{
  10. unit hunter;
  11. }
  12.  
  13. struct attack{
  14. unit attacker;
  15. }
  16.  
  17. function GetUnitZ(unit whichUnit)->real{
  18. location l=Location(GetUnitX(whichUnit),GetUnitY(whichUnit));
  19. real p=GetLocationZ(l)+GetUnitFlyHeight(whichUnit);
  20. RemoveLocation(l);
  21. l=null;
  22. return p;
  23. }
  24.  
  25. function OnUnitImpact(projectile p,unit u){
  26. if (u==p.targetUnit){
  27. UnitDamageTargetEx(p.sourceUnit,u,p.damageDealt,false,true,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_FORCE,WEAPON_TYPE_WHOKNOWS);
  28. p.terminate();
  29. p.removeUnit(u);
  30. }
  31. }
  32.  
  33. function OnExpireFunc(projectile p){
  34. if (!p.isUnitAdded(p.targetUnit)&&IsUnitInRangeXY(p.targetUnit,p.posX,p.posY,p.unitHitRadius)){OnUnitImpact(p,p.targetUnit);}
  35. }
  36.  
  37. function createProjectile(unit whichUnit,unit target,real damage){
  38. projectile p=0;
  39. real a=Atan2(GetUnitY(target)-GetUnitY(whichUnit),GetUnitX(target)-GetUnitX(whichUnit));
  40. p=projectile.create(GetUnitX(whichUnit),GetUnitY(whichUnit),GetUnitFlyHeight(whichUnit)+50.00+GetUnitZ(whichUnit),a);
  41. p.sourceUnit=whichUnit;
  42. p.owningPlayer=GetOwningPlayer(whichUnit);
  43. p.effectPath="Abilities\\Weapons\\BoatMissile\\BoatMissile.mdl";
  44. p.damageDealt=damage;
  45. p.scaleSize=1.0;
  46. p.zOffset=50.0;
  47. p.allowDeathSfx=true;
  48. p.allowTargetHoming=true;
  49. p.onUnit = OnUnitImpact;
  50. p.onExpire = OnExpireFunc;
  51. p.projectNormal(GetUnitX(target),GetUnitY(target),50.00+GetUnitZ(whichUnit),1100.0);
  52. }
  53.  
  54. function onTimer(){
  55. timer t=GetExpiredTimer();
  56. data this=GetTimerData(t);
  57. player p=GetOwningPlayer(this.hunter);
  58. real d=BlzGetUnitBaseDamage(this.hunter,1)+BlzGetUnitDiceNumber(this.hunter,1)+Status[this.hunter].getDamageBonus();
  59. real s=BlzGetUnitAttackCooldown(this.hunter,1);
  60. string tt="|c00eac117Cannon Damage: |r"+I2S(R2I(d))+"|n|c00eac117Reload Speed: |r"+R2S(s)+"|n|n|c00eac117Passive:|r Fire a cannon at a nearby enemy within a 600 radius.|n|n|c00eac117Active:|r Locks a cannon onto a selected target.|n|n|c00ff0000Cooldown:|r 5";
  61. if (GetUnitState(this.hunter,UNIT_STATE_LIFE)>0.405){
  62. if (GetLocalPlayer()==p){BlzSetAbilityExtendedTooltip(ABIL_ID,tt,1);}
  63. }
  64. p=null;
  65. }
  66.  
  67. function engageAttack(){
  68. timer t=GetExpiredTimer();
  69. attack that=GetTimerData(t);
  70. integer i=GetUnitId(that.attacker);
  71. unit n;
  72. group g=NewGroup();
  73. real d=BlzGetUnitBaseDamage(that.attacker,1)+BlzGetUnitDiceNumber(that.attacker,1)+Status[that.attacker].getDamageBonus();
  74. real s=BlzGetUnitAttackCooldown(that.attacker,1);
  75. if (GetUnitState(that.attacker,UNIT_STATE_LIFE)>0.405){
  76. if (Current_Target[i]!=null&&IsUnitInRange(Current_Target[i],that.attacker,600.00)){
  77. createProjectile(that.attacker,Current_Target[i],d);}
  78. else{
  79. Current_Target[i]=null;
  80. GroupUnitsInArea(g,GetUnitX(that.attacker),GetUnitY(that.attacker),600.0);
  81. n=FirstOfGroup(g);
  82. while (n!=null){
  83. if (!IsUnitInGroup(n,TitanGroup)){
  84. GroupRemoveUnit(g,n);
  85. }
  86. n=FirstOfGroup(g);
  87. }
  88. Current_Target[i]=GroupPickRandomUnit(g);
  89. createProjectile(that.attacker,Current_Target[i],d);
  90. }
  91. }
  92. TimerStart(t,s,false,function engageAttack);
  93. SetTimerData(t,that);
  94. ReleaseGroup(g);
  95. n=null;
  96. t=null;
  97. g=null;
  98. }
  99.  
  100. function registerHunter(unit whichUnit){
  101. data this=data.create();
  102. attack that=attack.create();
  103. timer t=NewTimer();
  104. this.hunter=whichUnit;
  105. that.attacker=whichUnit;
  106. TimerStart(t,0.04,true,function onTimer);
  107. SetTimerData(t,this);
  108. t=NewTimer();
  109. TimerStart(t,BlzGetUnitAttackCooldown(whichUnit,1),false,function engageAttack);
  110. SetTimerData(t,that);
  111. t=null;
  112. }
  113.  
  114. function onInit(){registerHunter(gg_unit_H046_0203);}
  115. }
  116. //! endzinc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement