Guest
Public paste!

Untitled

By: a guest | Mar 18th, 2010 | Syntax: None | Size: 4.09 KB | Hits: 57 | Expires: Never
Copy text to clipboard
  1. //! zinc
  2.  
  3. library NaturesQuarry requires TimerUtils, Core, DamageSystem {      
  4.     struct Boulder {
  5.         static thistype tempBoulder;
  6.         static boolexpr FILTER;
  7.         unit u;
  8.         unit dummy;
  9.         real damage         = 0;
  10.         real distance       = 0;
  11.         real size         = 0;
  12.         group hitunits;
  13.         effect effect;
  14.        
  15.         static method Knock() {
  16.             unit t = GetEnumUnit();
  17.             real x = GetUnitX(thistype.tempBoulder.dummy);
  18.             real y = GetUnitY(thistype.tempBoulder.dummy);
  19.             SetUnitX(t, x);
  20.             SetUnitY(t, y);
  21.             t = null;
  22.         }
  23.        
  24.         static method Update() {
  25.             timer t = GetExpiredTimer();
  26.             thistype d = GetTimerData(t);
  27.             real x = PolarProjectionX( GetUnitX(d.dummy), 14, GetUnitFacing(d.dummy)*bj_DEGTORAD );
  28.             real y = PolarProjectionY( GetUnitY(d.dummy), 14, GetUnitFacing(d.dummy)*bj_DEGTORAD );
  29.            
  30.             if (IsTerrainWalkable(x,y)){
  31.                 SetUnitX(d.dummy, x);
  32.                 SetUnitY(d.dummy, y);
  33.             } else {
  34.                 d.distance = d.distance-20;
  35.             }
  36.            
  37.             DestroyEffect( AddSpecialEffect("Abilities\\Weapons\\AncientProtectorMissile\\AncientProtectorMissile.mdl", x, y) );            
  38.            
  39.             if ( d.size < 2 ) { d.size = d.size+0.125; SetUnitScale(d.dummy,d.size,d.size,d.size); }
  40.            
  41.             thistype.tempBoulder = d;
  42.             GroupEnumUnitsInRange( tempGroup, x, y, 125, thistype.FILTER );
  43.             ForGroup( d.hitunits, function thistype.Knock );
  44.            
  45.             d.distance = d.distance - 14;            
  46.             if (d.distance < 0) {
  47.                 d.destroy();
  48.                 ReleaseTimer(t);
  49.             }
  50.         }
  51.        
  52.         static method create (unit u, real x, real y) -> thistype {
  53.             timer t = NewTimer();
  54.             thistype d = thistype.allocate();
  55.             d.u = u;
  56.             d.dummy = CreateUnit( Player(15), 'h000', GetUnitX(u), GetUnitY(u), AngleBetweenPointsXY(GetUnitX(u), GetUnitY(u), x, y)*bj_RADTODEG );
  57.             d.damage = 40+GetUnitStat(u, SPELL_POWER)*0.75+GetHeroLevel(u)*5+GetHeroStr(u,true);
  58.             d.hitunits = CreateGroup();
  59.             d.distance = 800;
  60.             d.size      = 0;
  61.            
  62.             d.effect = AddSpecialEffectTarget("Abilities\\Weapons\\AncientProtectorMissile\\AncientProtectorMissile.mdl", d.dummy, "origin");
  63.             SetUnitScale(d.dummy,0,0,0);            
  64.            
  65.             SetTimerData(t,d);
  66.             TimerStart(t,0.035,true,function thistype.Update);
  67.             return d;
  68.         }
  69.        
  70.         static method FilterFunc() -> boolean {
  71.             unit t = GetFilterUnit();
  72.             if ( GetWidgetLife(t) > 0.405 && IsUnitEnemy(t, GetOwningPlayer( thistype.tempBoulder.u )) && !IsUnitInGroup(t, thistype.tempBoulder.hitunits) && !IsUnitType(t, UNIT_TYPE_MECHANICAL))
  73.             {                    
  74.                 UnitDamage(thistype.tempBoulder.u, t, MAGIC, thistype.tempBoulder.damage);                              
  75.                 GroupAddUnit(thistype.tempBoulder.hitunits, t);        
  76.             }
  77.             t = null;
  78.             return FALSE;
  79.         }
  80.        
  81.         static method onInit() {
  82.             thistype.FILTER = Condition( function thistype.FilterFunc );
  83.         }
  84.         method onDestroy() {
  85.             DestroyEffect(this.effect);
  86.             KillUnit( this.dummy );
  87.             DestroyGroup( this.hitunits );
  88.         }
  89.     }
  90.    
  91.     function Conditions() -> boolean {
  92.         return GetSpellAbilityId() == 'A04C';
  93.     }
  94.    
  95.     function Actions() {
  96.         real x = GetSpellTargetX();
  97.         real y = GetSpellTargetY();
  98.         Boulder.create( GetTriggerUnit(), x, y );
  99.     }
  100.    
  101.     function onInit(){
  102.         trigger t = CreateTrigger();
  103.         TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT);
  104.         TriggerAddCondition(t, Condition(function Conditions));
  105.         TriggerAddAction(t, function Actions);
  106.     }
  107. }
  108.  
  109. //! endzinc