Moving a rect and destroying destructs/trees

shiFt

Member
Reaction score
8
Im trying to destroy trees around a unit that is moving however having no success, ive posted what im using, What am I doing incorrectly?


JASS:
private rect r = Rect(0,200.,0,200.)

JASS:
 private function TreeConditions takes nothing returns boolean
        return GetDestructableLife(GetEnumDestructable()) > .405
    endfunction
    
    private function KillTrees takes nothing returns nothing
        call KillDestructable( GetEnumDestructable() )
    endfunction


JASS:
       call MoveRectTo(r,d.x,d.y)
        call EnumDestructablesInRect(r, function TreeConditions ,function KillTrees)
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
The fact that you're using [ljass]GetEnumDestructable[/ljass] instead of [ljass]GetFilterDestructable[/ljass] in the filter might be causing it.
 

shiFt

Member
Reaction score
8
lol its from my other posts, nearly there though :)
JASS:
scope BRUSH initializer Init

    globals 
        private constant integer SPELL_ID = 'A04Q'
        private constant integer DUMMY = 'h01J'
        private constant integer DUMMY_SPELL = 'A0AJ'
        private hashtable ht = InitHashtable()
    endglobals
    
    private struct Data
        unit cs
        real x
        real y
        player p
        real dur
        integer ticks
        integer timeScaleTicks
        timer t
        group g
        real dmg
        real a
        real dist
        real x1
        real y1
        real targetX
        real targetY
        real x3
        real y3
        real newx
        real newy
    endstruct
    
    globals
        private unit U
        private unit DUM
        private Data D
        private real X
        private real Y
        private integer array TimerData
        private conditionfunc cf
        private group gg = CreateGroup()
        private rect r = Rect(0,0,200,200)
    endglobals
    
    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == SPELL_ID
    endfunction

  private function Effect2 takes nothing returns boolean
        set U = GetFilterUnit()
       
        if GetWidgetLife(U) > .405 and IsUnitEnemy(U,D.p) and not IsUnitInGroup(U,D.g) and IsUnitType(U,UNIT_TYPE_STRUCTURE) == false then
    
            call UnitDamageTargetEx(D.cs,U, D.dmg, false, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS )
            
            set DUM = CreateUnit(D.p, DUMMY, GetWidgetX(U), GetWidgetY(U) ,0.00)
            call UnitAddAbility(DUM, DUMMY_SPELL)
            call UnitApplyTimedLife( DUM, 'BTLF', 1)
            call SetUnitAbilityLevel(DUM, DUMMY_SPELL,GetUnitAbilityLevel(D.cs, SPELL_ID))
            call IssueTargetOrder( DUM, "slow" ,U )
            
            call GroupAddUnit(D.g,U)
            
        endif
        return false
    endfunction
    
     private function TreeConditions takes nothing returns boolean
        return GetDestructableLife(GetFilterDestructable()) > .405
    endfunction
    
    private function KillTrees takes nothing returns nothing
        call KillDestructable( GetEnumDestructable() )
    endfunction
    
    private function Effects takes nothing returns nothing
        local Data d = LoadInteger(ht,GetHandleId(GetExpiredTimer()),0)
        set d.x = GetUnitX(d.cs)
        set d.y = GetUnitY(d.cs)
        set d.x3 = d.targetX - d.x
        set d.y3 = d.targetY - d.y
        set d.dist = SquareRoot(d.x3 * d.x3 + d.y3 * d.y3)
        set d.a = AngleBetweenCoords( d.x, d.y, d.targetX,d.targetY )
        
        set d.newx = d.x+ 37*Cos(d.a * bj_DEGTORAD)
        set d.newy = d.y+ 37*Sin(d.a * bj_DEGTORAD)
        call SetUnitPosition(d.cs, d.newx,d.newy)
        call MoveRectTo(r,d.x,d.y)
        call EnumDestructablesInRect(r, function TreeConditions ,function KillTrees)
        
        if d.ticks > 0 then
            set d.ticks = d.ticks - 1
            if d.timeScaleTicks > 0 then
                set d.timeScaleTicks = d.timeScaleTicks - 1
           else
                set d.timeScaleTicks = 10000
            endif
            set D = d
            call GroupEnumUnitsInRange(gg,d.x,d.y,175.,cf)
        if d.dist < 50 then
            call PauseTimer(d.t)
             set d.t =null
            call GroupClear(d.g)
            call d.destroy()
            call SetUnitPathing(d.cs,true)
          
            call PauseUnit( d.cs, false)
            
            endif
            
         if GetWidgetLife(d.cs) < .405 then
            call PauseTimer(d.t)
             set d.t =null
            call GroupClear(d.g)
            call d.destroy()
             call SetUnitPathing(d.cs,true)
            call PauseUnit( d.cs, false)
            
            endif
            
            return
        endif
        call PauseTimer(d.t)
         set d.t =null
        call GroupClear(d.g)
        call d.destroy()
        call SetUnitPathing(d.cs,true)
        call PauseUnit( d.cs, false)
         
        
         
    endfunction
    
    private function Actions takes nothing returns nothing
        local Data d = Data.create()
        set d.cs = GetTriggerUnit()
        set d.x = GetUnitX(d.cs)
        set d.y = GetUnitY(d.cs)
        set d.targetX = GetSpellTargetX()
        set d.targetY = GetSpellTargetY()
        set d.x1 = d.x - d.targetX
        set d.y1 = d.y - d.targetY
        set d.p = GetOwningPlayer(d.cs)
        set d.dist = SquareRoot(d.x1 * d.x1 + d.y1 * d.y1)
        set d.dur = d.dist/ 52.
        set d.ticks = R2I(d.dur / .03)
        set d.timeScaleTicks = R2I(1. / .03)
        set d.dmg = 60 + ( 10* GetUnitAbilityLevel(d.cs,SPELL_ID))
        
        call SetUnitPathing(d.cs,false)
        
        if d.t == null then
            set d.t = CreateTimer()
            call SaveInteger(ht,GetHandleId(d.t),0,d)
            call PauseUnit( d.cs, true)
            call SetUnitAnimationWithRarity( d.cs, "attack slam", RARITY_RARE )
            call SetUnitPathing(d.cs,false)
        endif
        
        if d.g == null then
            set d.g = CreateGroup()
        endif
        call TimerStart(d.t,.03,true,function Effects)
    endfunction

//---------------------------------------------------------------------------------------------------------
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger(  )
		local integer i = 0
		
		loop
			exitwhen i > 11
			call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
			set i = i + 1
		endloop

		call TriggerAddCondition( t, Condition( function Conditions ) )
		call TriggerAddAction( t, function Actions )
		 set cf = Condition(function Effect2)
		set t = null
	endfunction
    
endscope
 

Azlier

Old World Ghost
Reaction score
461
Use Rect(0, 200, 0, 200). You had it right the first time.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Well, it's still supposed to be [ljass]Rect(0., 0., 200., 200. )[/ljass]...

Also, you REALLY need to learn to debug yourself !
Put some random messages in there, to see that runs even (Like 1 message in the Actual method, one in the filter and one in the enum method :D)

Then, if those all show fine, put some useful content in the messages, like some data from the struct "d" etc...
 

Azlier

Old World Ghost
Reaction score
461
Yeah I misread the native. Ignore me previous statement.
 

shiFt

Member
Reaction score
8
those values still dont change a thing, :( also even if I use debug msgs I would not know how to fix the problem, hence the post :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top