question about call UnitDamageTarget

cleeezzz

The Undead Ranger.
Reaction score
268
i see triggers use Debug messages but i dont really know how to use them.

you call the debug function but how do you make it show the debug text?
 

Kenny

Back for now.
Reaction score
202
You call:

JASS:
call BJDebugMsg("your string")


so you can use it in the onDestroy method like:

JASS:
call BJDebugMsg("Spell ended")


and stuff like that. I just makes sure that a certain part of the spell actually functions and runs when it should.

*EDIT*

I have a new suspicion after reading your message, and it also has to do with the SafeX and SafeY functions. I copied them from a map made by someone a long time ago and i think he may have had it wrong. Ill get back to you in one sec. Well i just found the map, and i cant find anything wrong with them except for the parenthesis. It isnt wrong but maybe remove them...
 

cleeezzz

The Undead Ranger.
Reaction score
268
ugh, i havent touched WE in forever, and when i did it crashes with a runtime error. something about microsoft visual C++

edit: just found out by searching, its cuz of newgen and 1.22


anyway,

can anyone see the definite problem in the code =/


edit: oh and without newgen, how the heck are we supposed to save vJass?.... downgrading is lame.
edit: nvm thanks kc (Still need help with the original question above.
edit: tested SafeX and SafeY without parenthesis, same result.

HUH? i used debug messages and guess what. the numbers were changing ?? how is that possible

JASS:
scope SA initializer InitTrig

globals
    // Configurables:
    private constant integer Abil_id = 'A011'  // Your spells raw code
    private constant integer Unit_id = 'h00J'  // Your dummy unit
    private constant real Period = 0.04        // Interval on the periodic timer
    private constant real Start_dist = 10.00   // Don't worry about this really, distance dummy unit starts away from the hero, i guess you would want this low
    private constant real Radius = 25.00       // Radius obviously
    private constant real Scale = 1            // Scale size of the arrow
    private constant real Fly_height = 60.00   // Fly height of the arrow
    private constant attacktype A_type = ATTACK_TYPE_CHAOS
    private constant damagetype D_type = DAMAGE_TYPE_UNIVERSAL
    private unit Caster
endglobals

//=======================================================================
private function Damage takes integer lvl returns real
    return 133.33+(66.66*lvl)
endfunction

private function Max_dist takes integer lvl returns real
    return 333.33+(666.66*lvl) 
endfunction

function CustomFilter takes nothing returns boolean
    return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(Caster)) and GetWidgetLife(GetFilterUnit())>0.405
endfunction



//=======================================================================
private struct SAD
    timer t
    unit cast
    unit dummy
    real castx
    real casty
    real targx
    real targy
    real Move_dist
    real dist = Start_dist
    real angle
    integer level
    group Group1 = CreateGroup()
    group Group2 = CreateGroup()
   
    static method create takes nothing returns SAD
        local SAD data = SAD.allocate()
        local location targ = GetSpellTargetLoc()
        set data.cast = GetTriggerUnit()
        set data.castx = GetUnitX(data.cast)
        set data.casty = GetUnitY(data.cast)
        set data.targx = GetLocationX(targ)
        set data.targy = GetLocationY(targ)
        set data.angle = AngleXY(data.castx,data.casty,data.targx,data.targy)
        set data.Move_dist = 44.00
        set data.level = GetUnitAbilityLevel(data.cast,Abil_id)
        set Caster = data.cast
       
        set data.dummy = CreateUnit(GetOwningPlayer(data.cast),Unit_id, PolarProjectionX (data.castx, Start_dist, data.angle), PolarProjectionY (data.casty, Start_dist, data.angle) , data.angle)
        call SetUnitPathing(data.dummy,false)
        call SetUnitScale(data.dummy,Scale,Scale,Scale)
        call SetUnitFlyHeight(data.dummy,Fly_height,0.00)
       
        call RemoveLocation(targ)
        set targ = null
        return data
    endmethod
   
    private method onDestroy takes nothing returns nothing
        call KillUnit(.dummy)
        call GroupClear(.Group1)
        call DestroyGroup(.Group1)
        call ReleaseTimer(.t)
    endmethod
endstruct

//=======================================================================
private function Move takes nothing returns nothing
    local SAD data = GetCSData(GetExpiredTimer())
    local unit u
    local real x = GetUnitX(data.dummy)
    local real y = GetUnitY(data.dummy)
   
    set data.dist = data.dist + data.Move_dist
    if data.dist >= Max_dist(data.level) then
        call data.destroy()
        return
    endif
    call BJDebugMsg(R2S(x))
    call BJDebugMsg(R2S(y))   
    set x = PolarProjectionX(x, data.Move_dist, data.angle)
    set y = PolarProjectionY(y, data.Move_dist, data.angle)
    call BJDebugMsg(R2S(x))
    call BJDebugMsg(R2S(y))

    call SetUnitX(data.dummy, x)
    call SetUnitY(data.dummy, y)
    call GroupClear(data.Group2)
    call GroupEnumUnitsInRange(data.Group2,SafeX(x),SafeY(y),Radius,Condition(function CustomFilter))
        loop
            set u = FirstOfGroup(data.Group2)
            exitwhen u == null
            if not(IsUnitInGroup(u,data.Group1)) then
                call GroupAddUnit(data.Group1,u)
                call UnitDamageTarget(data.cast,u,Damage(data.level),false,false,A_type,D_type,null)
                call GroupRemoveUnit(data.Group2,u)
            endif
                call GroupRemoveUnit(data.Group2,u)
        endloop
endfunction
   
//=======================================================================
private function Actions takes nothing returns nothing
    local SAD data = SAD.create()
   
    set data.t = NewTimer()
    call TimerStart(data.t,Period,true,function Move)
    call SetCSData(data.t,data)
endfunction

//=======================================================================
private function Conditions takes nothing returns boolean
    return GetSpellAbilityId()== Abil_id
endfunction


//=======================================================================
private function InitTrig takes nothing returns nothing
    local trigger trig = CreateTrigger()   
    call TriggerRegisterAnyUnitEventBJ(trig,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(trig,Condition(function Conditions))
    call TriggerAddAction(trig,function Actions)
endfunction

endscope

as you can see it tells me the x and y, then the polar projection of x and y, but the weird thing is it keeps changing??? how can it change, the x and y are constant since the dummy NEVER moves. it cant be safex and safey anymore, cuz if it was, all it would do is keep the unit in hte same place and that would mean x and y would be constant. but i get a huge list of different numbers.
 

cleeezzz

The Undead Ranger.
Reaction score
268
maybe ill just create a new thread, the question is not relevant to the title + its old.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top