Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //! zinc
- library PirateHunter requires TimerUtils,Status,GroupUtils,Projectile,AIDS{
- private{
- constant integer ABIL_ID = 'A0K6';
- unit Current_Target[8191];
- }
- struct data{
- unit hunter;
- }
- struct attack{
- unit attacker;
- }
- function GetUnitZ(unit whichUnit)->real{
- location l=Location(GetUnitX(whichUnit),GetUnitY(whichUnit));
- real p=GetLocationZ(l)+GetUnitFlyHeight(whichUnit);
- RemoveLocation(l);
- l=null;
- return p;
- }
- function OnUnitImpact(projectile p,unit u){
- if (u==p.targetUnit){
- UnitDamageTargetEx(p.sourceUnit,u,p.damageDealt,false,true,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_FORCE,WEAPON_TYPE_WHOKNOWS);
- p.terminate();
- p.removeUnit(u);
- }
- }
- function OnExpireFunc(projectile p){
- if (!p.isUnitAdded(p.targetUnit)&&IsUnitInRangeXY(p.targetUnit,p.posX,p.posY,p.unitHitRadius)){OnUnitImpact(p,p.targetUnit);}
- }
- function createProjectile(unit whichUnit,unit target,real damage){
- projectile p=0;
- real a=Atan2(GetUnitY(target)-GetUnitY(whichUnit),GetUnitX(target)-GetUnitX(whichUnit));
- p=projectile.create(GetUnitX(whichUnit),GetUnitY(whichUnit),GetUnitFlyHeight(whichUnit)+50.00+GetUnitZ(whichUnit),a);
- p.sourceUnit=whichUnit;
- p.owningPlayer=GetOwningPlayer(whichUnit);
- p.effectPath="Abilities\\Weapons\\BoatMissile\\BoatMissile.mdl";
- p.damageDealt=damage;
- p.scaleSize=1.0;
- p.zOffset=50.0;
- p.allowDeathSfx=true;
- p.allowTargetHoming=true;
- p.onUnit = OnUnitImpact;
- p.onExpire = OnExpireFunc;
- p.projectNormal(GetUnitX(target),GetUnitY(target),50.00+GetUnitZ(whichUnit),1100.0);
- }
- function onTimer(){
- timer t=GetExpiredTimer();
- data this=GetTimerData(t);
- player p=GetOwningPlayer(this.hunter);
- real d=BlzGetUnitBaseDamage(this.hunter,1)+BlzGetUnitDiceNumber(this.hunter,1)+Status[this.hunter].getDamageBonus();
- real s=BlzGetUnitAttackCooldown(this.hunter,1);
- 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";
- if (GetUnitState(this.hunter,UNIT_STATE_LIFE)>0.405){
- if (GetLocalPlayer()==p){BlzSetAbilityExtendedTooltip(ABIL_ID,tt,1);}
- }
- p=null;
- }
- function engageAttack(){
- timer t=GetExpiredTimer();
- attack that=GetTimerData(t);
- integer i=GetUnitId(that.attacker);
- unit n;
- group g=NewGroup();
- real d=BlzGetUnitBaseDamage(that.attacker,1)+BlzGetUnitDiceNumber(that.attacker,1)+Status[that.attacker].getDamageBonus();
- real s=BlzGetUnitAttackCooldown(that.attacker,1);
- if (GetUnitState(that.attacker,UNIT_STATE_LIFE)>0.405){
- if (Current_Target[i]!=null&&IsUnitInRange(Current_Target[i],that.attacker,600.00)){
- createProjectile(that.attacker,Current_Target[i],d);}
- else{
- Current_Target[i]=null;
- GroupUnitsInArea(g,GetUnitX(that.attacker),GetUnitY(that.attacker),600.0);
- n=FirstOfGroup(g);
- while (n!=null){
- if (!IsUnitInGroup(n,TitanGroup)){
- GroupRemoveUnit(g,n);
- }
- n=FirstOfGroup(g);
- }
- Current_Target[i]=GroupPickRandomUnit(g);
- createProjectile(that.attacker,Current_Target[i],d);
- }
- }
- TimerStart(t,s,false,function engageAttack);
- SetTimerData(t,that);
- ReleaseGroup(g);
- n=null;
- t=null;
- g=null;
- }
- function registerHunter(unit whichUnit){
- data this=data.create();
- attack that=attack.create();
- timer t=NewTimer();
- this.hunter=whichUnit;
- that.attacker=whichUnit;
- TimerStart(t,0.04,true,function onTimer);
- SetTimerData(t,this);
- t=NewTimer();
- TimerStart(t,BlzGetUnitAttackCooldown(whichUnit,1),false,function engageAttack);
- SetTimerData(t,that);
- t=null;
- }
- function onInit(){registerHunter(gg_unit_H046_0203);}
- }
- //! endzinc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement