AngleBetweenPoints, how to use the native ?

chobibo

Level 1 Crypt Lord
Reaction score
48
JASS:
function H2I takes handle h returns integer
    return h
    return 0
endfunction

function CheckLeak takes nothing returns nothing
    local trigger t=CreateTrigger()
    
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_CAST)
    call DestroyTrigger(t)
    
    call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, I2S(H2I(t)))
    
    set t=null
endfunction


function InitTrig_Leak_Test takes nothing returns nothing
    call TimerStart(CreateTimer(), 1, true, function CheckLeak)
endfunction


The null boolexpr problem is associated with groups, not triggers.
 

Viikuna

No Marlo no game.
Reaction score
265
Yea, that cool. RegisterAyUnitEvent makes things pretty fast, so its a great function to have. Not all BJs are bad.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Now the trigger is created and destroyed every time it fires right ????
And btw, sorry but i don't understand at all what those handles are there or why you put in a timer and whatnot
 

chobibo

Level 1 Crypt Lord
Reaction score
48
Yes, the trigger is destroyed everytime. A handle is a parent type of the trigger. A timer accurately executes a code handle (function) and is affected by game pauses, which means when the game is paused, it is also paused.

The function H2I returns an integer value which we may call a handle Id, if the handle Id continues on incrementing then we have ourselves a handle leak, likewise, if the memory usage of war3.exe increases then we may have a memory leak.

A null boolexpr used for a trigger does not leak, but when used for groups, it leaks memory.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
so should i replace this with something ??

And why is that textmessage there ?

EDIT: So is this how it's supposed to look ?

JASS:
function Spell_Check takes nothing returns boolean
    return (GetSpellAbilityId() == '0000')
endfunction

function True takes nothing returns boolean
    return true
endfunction

function H2I takes handle h returns integer
    return h
    return 0
endfunction

function Effects takes nothing returns nothing
    local string o = "move"
    local integer i = 0
    local string e = "Abilities\\Spells\\Human\\Flare\\FlareCaster.mdl"
    local string e2 = "Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosTarget.mdl"
    local unit u = GetTriggerUnit()
    local real xu = GetUnitX(u)
    local real yu = GetUnitY(u)
    local real x
    local real y
    local player p = GetOwningPlayer(u)
    local integer unitid = 'h000'
    local integer aid = 'Aloc'
    local integer bid = 'BTLF'
    local unit du
    call DestroyEffect(AddSpecialEffect(e,xu,yu))
    loop
        exitwhen i>16
        set x = xu+200*Cos((i*22.5)*bj_DEGTORAD)
        set y = yu+200*Sin((i*22.5)*bj_DEGTORAD)
        call DestroyEffect(AddSpecialEffect(e,x,y))
        call DestroyEffect(AddSpecialEffect(e2,x,y))
        call UnitDamagePoint(u,0,10,x,y,50,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
        set du = CreateUnit(p,unitid,xu,yu,bj_RADTODEG*Atan2(y-yu,x-xu))
        call UnitApplyTimedLife(du,bid,2.)
        call UnitAddAbility(du,aid)
        call IssuePointOrder(u,o,x,y)
        set x = 0
        set y = 0
        set i = i+1
        set du = null
    endloop
    set u = null
    set p = null
    set unitid = 0
    set aid = 0
    set bid = 0
    set i = 0
    set xu = 0
    set yu = 0
endfunction

function Spell takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_CAST)
    call TriggerAddCondition(t,Condition(function Spell_Check))
    call TriggerAddAction(t,function Effects)
    call TriggerAddAction(t,function True)
    call DestroyTrigger(t)
    call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, I2S(H2I(t)))
    set t=null
endfunction

function InitTrig_Leak_Test takes nothing returns nothing
    call TimerStart(CreateTimer(), 1, true, function Spell)
endfunction
 

chobibo

Level 1 Crypt Lord
Reaction score
48
Oh, Flare's right, you misunderstood my code, what I was saying is that TriggerRegisterAnyUnitEventBJ is leak free, so you don't have to worry about using it. anyways change that:

JASS:
function Spell_Check takes nothing returns boolean
    return (GetSpellAbilityId() == '0000')
endfunction

function Effects takes nothing returns nothing
    local string o = "move"
    local integer i = 0
    local string e = "Abilities\\Spells\\Human\\Flare\\FlareCaster.mdl"
    local string e2 = "Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosTarget.mdl"
    local unit u = GetTriggerUnit()
    local real xu = GetUnitX(u)
    local real yu = GetUnitY(u)
    local real x
    local real y
    local player p = GetOwningPlayer(u)
    local integer unitid = 'h000'
    local integer aid = 'Aloc'
    local integer bid = 'BTLF'
    local unit du
    call DestroyEffect(AddSpecialEffect(e,xu,yu))
    loop
        exitwhen i>16
        set x = xu+200*Cos((i*22.5)*bj_DEGTORAD)
        set y = yu+200*Sin((i*22.5)*bj_DEGTORAD)
        call DestroyEffect(AddSpecialEffect(e,x,y))
        call DestroyEffect(AddSpecialEffect(e2,x,y))
        call UnitDamagePoint(u,0,10,x,y,50,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
        set du = CreateUnit(p,unitid,xu,yu,bj_RADTODEG*Atan2(y-yu,x-xu))
        call UnitApplyTimedLife(du,bid,2.)
        call UnitAddAbility(du,aid)
        call IssuePointOrder(u,o,x,y)
        set x = 0
        set y = 0
        set i = i+1
        set du = null
    endloop
    set u = null
    set p = null
    set unitid = 0
    set aid = 0
    set bid = 0
    set i = 0
    set xu = 0
    set yu = 0
endfunction

function InitTrig_<The trigger name goes here> takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t,Condition(function Spell_Check))
    call TriggerAddAction(t,function Effects)
endfunction


Sorry for the misunderstanding lol.
 

chobibo

Level 1 Crypt Lord
Reaction score
48
Sure, but you still have to edit the code since I didn't review the code and I just copied it from your previous post, I just removed the unecessary parts. I'll try looking into your spell later, I'm still doing something atm.

EDIT:

how do i know how long it takes for a unit with the movement speed 100 to move 200 distance

velocity=distance/time

where:
velocity = 100 units per second
distance = 200 units
time = unknown

deriving the formula from the previous formula we get:

time=distance/velocity

time=200 d / 100 d/s
time=2s
 
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