creating 2 dummies? or casting 2 of the same spell?

waaaks!

Zinctified
Reaction score
256
In the first thread I posted, I posted about stopping the locust swarm by killing the dummy unit, now I solved the problem, but it still has problems, the dummy kinda uses the spell twice, or maybe 2 dummies are created, because when I deactivated the immolation based spell, it kills the created dummy unit, but looks like there's another dummy unit remaining and still following my hero, but was not killed by the trigger.

I really don't have any idea why does the trigger created two units, it also has weird issues like if I removed the line that sets the global boolean back to false at the same instance the struct and timer was destroyed, it was like creating only 1 dummy. I need this global boolean to check if the spell was deactivated.

JASS:
scope LocustSwarm initializer init

globals
    private constant integer spell = 'A01R'
    private constant integer dspell = 'A01U'
    private boolean array done
endglobals

private struct data
    unit c
    unit u
endstruct

private function con takes nothing returns boolean
    return GetUnitAbilityLevel(GetLearningUnit(),spell) == 1
endfunction

private function callback takes nothing returns boolean
    local timer t = GetExpiredTimer()
    local data d = GetTimerData(t)
    call SetUnitX(d.u,GetUnitX(d.c))
    call SetUnitY(d.u,GetUnitY(d.c))
    call BJDebugMsg("running")
    if done[GetUnitId(d.c)] then
        call KillUnit(d.u)
        set d.u = null
        call ReleaseTimer(t)
        call d.destroy()
        call BJDebugMsg("destroyed")
    endif
    set t = null
    return true
endfunction

private function act2 takes nothing returns boolean
    local unit c = GetTriggerUnit()
    local timer t = NewTimer()
    local integer l = GetUnitAbilityLevel(c,spell)
    local data d = data.create()
    set d.c = c
    if GetIssuedOrderId() == OrderId("immolation") then
        set done[GetUnitId(c)] = false
        set d.u = CreateUnit(GetOwningPlayer(c),'e006',GetUnitX(c),GetUnitY(c),0.0)
        call UnitAddAbility(d.u,dspell)
        call SetUnitAbilityLevel(d.u,dspell,l)
        call IssueImmediateOrder(d.u,"locustswarm")
        call TimerStart(t,0.035,true,function callback)
        call SetTimerData(t,d)
        call BJDebugMsg("start")
    elseif GetIssuedOrderId() == OrderId("unimmolation") then
        set done[GetUnitId(c)] = true
        call BJDebugMsg("done")
    endif
    set c = null
    set t = null
    return true
endfunction

private function act takes nothing returns nothing
    local trigger t = CreateTrigger()
    local unit c = GetLearningUnit()
    call TriggerRegisterUnitEvent( t, c, EVENT_UNIT_ISSUED_ORDER )
    call TriggerAddAction(t,function act2)
    set c = null
    set t = null
endfunction

private function init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call XE_PreloadAbility(dspell)
    call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_HERO_SKILL)
    call TriggerAddCondition(t,Condition(function con))
    call TriggerAddAction(t,function act)
endfunction

endscope

EDIT:
updated the code, now working correctly, but with the debug message I added, it really is acting weird, it posted two "start", I'll show you how does it look like:
start
start
running
running
running
running
running
running
running
running
done
done
running
destroyed
running
destroyed
even though the 2 dummy units are successfully killed, the spell is not yet fixed, for I want only an exact number of locusts when the spell is activated, I don't want to double them, also I want to learn how to fix this for future use, thanks!
 

themean

Active Member
Reaction score
7
i want to help

I cant see were your function "GetUnitId()"
I cant understand why your function "callback" return boolean
and why you set d.u=createunit(...) before create him
maybe you must use
call createunit(...)
set d.u=GetLastCreatedUnit
test this and tell me what is happend???
Good luck:thup::thup:
and maybe after kill unit in "callback" remove him whit call removeunit(d.u)
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
and why you set d.u=createunit(...) before create him
maybe you must use
call createunit(...)
set d.u=GetLastCreatedUnit

there is nothing wrong with that because CreateUnit() function returns a unit

anyway, you're leaking the whole struct

every time you issue an order to your unit, you will create a struct because the act2 will run and if the order is not equal to "immolation" it will leak because struct never gets destroyed

JASS:
if GetIssuedOrderId() == OrderId("immolation") then


try replacing it with:

JASS:
if GetIssuedOrderId() == OrderId("immolation") and done[GetUnitId(c)] = true then


remember that you can always give your dummy a visible model so you can see how much dummies get created
 

themean

Active Member
Reaction score
7
lol

man maybe you must ignore init function because you dont need
use only act function with condition con
tell me what happened
struct is no problem for you
struct no cause leak just fulled (or filled) but every time when you need you destroy them
JASS:
if GetIssuedOrderId() == OrderId("immolation") and done[GetUnitId(c)] = true then

is no ofer for you because done is no have starting value
i think problem is in jass structure with 2 events like yours maybe cause bug who fire second event 2 times
use call destroytimer(getexpiratetimer) not only set to null to avoid lag
i hope you can do:thup::thup:
 

waaaks!

Zinctified
Reaction score
256
still not working
JASS:
scope LocustSwarm initializer init

globals
    private constant integer spell = 'A01R'
    private constant integer dspell = 'A01U'
    private boolean array done
endglobals

private struct data
    unit c
    unit u
endstruct

private function con takes nothing returns boolean
    return GetUnitAbilityLevel(GetLearningUnit(),spell) == 1
endfunction

private function callback takes nothing returns boolean
    local timer t = GetExpiredTimer()
    local data d = GetTimerData(t)
    call SetUnitX(d.u,GetUnitX(d.c))
    call SetUnitY(d.u,GetUnitY(d.c))
    call BJDebugMsg("running")
    if done[GetUnitId(d.c)] then
        call KillUnit(d.u)
        set d.u = null
        call ReleaseTimer(t)
        call d.destroy()
        call BJDebugMsg("destroyed")
    endif
    set t = null
    return true
endfunction

private function act2 takes nothing returns boolean
    local unit c = GetTriggerUnit()
    local timer t
    local integer l = GetUnitAbilityLevel(c,spell)
    local data d
    if GetIssuedOrderId() == OrderId("immolation") then
        set t = NewTimer()
        set d = data.create()
        set d.c = c
        set done[GetUnitId(c)] = false
        set d.u = CreateUnit(GetOwningPlayer(c),'e006',GetUnitX(c),GetUnitY(c),0.0)
        call UnitAddAbility(d.u,dspell)
        call SetUnitAbilityLevel(d.u,dspell,l)
        call IssueImmediateOrder(d.u,"locustswarm")
        call TimerStart(t,0.035,true,function callback)
        call SetTimerData(t,d)
        set t = null
        call BJDebugMsg("start")
    elseif GetIssuedOrderId() == OrderId("unimmolation") then
        set done[GetUnitId(c)] = true
        call BJDebugMsg("done")
    endif
    set c = null
    return true
endfunction

private function act takes nothing returns nothing
    local trigger t = CreateTrigger()
    local unit c = GetLearningUnit()
    call TriggerRegisterUnitEvent( t, c, EVENT_UNIT_ISSUED_ORDER )
    call TriggerAddAction(t,function act2)
    set c = null
    set t = null
endfunction

private function init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call XE_PreloadAbility(dspell)
    call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_HERO_SKILL)
    call TriggerAddCondition(t,Condition(function con))
    call TriggerAddAction(t,function act)
endfunction

endscope


if add this
JASS:
if GetIssuedOrderId() == OrderId("immolation") and done[GetUnitId(c)] == true then

it doesn't run on first cast, but works in the second cast, and it leaks more, starts only 1 timer, and destroys 2 timers, also when my hero drains mana, until the immolation deactivates itself, it does'nt kill the dummy unit
 

themean

Active Member
Reaction score
7
!!

man try without init function
JASS:
scope LocustSwarm initializer act

JASS:


private function con2 takes nothing returns boolean
    return GetUnitAbilityLevel(GetTriggerUnit(),spell) != 0
endfunction

 
private function act takes nothing returns nothing
    local trigger t = CreateTrigger()
    local unit c = GetLearningUnit()
    call TriggerRegisterUnitEvent( t, c, EVENT_UNIT_ISSUED_ORDER )
    call TriggerAddCondition(t,Condition(function con2))
    call TriggerAddAction(t,function act2)
//    set c = null
 //   set t = null
endfunction

try this maybe work
if work remake skill
pls try
 

Tom Jones

N/A
Reaction score
437
Function callback shouldn't return a boolean.
Neither should act2.
I'm amazed that it doesn't crash your editor, it would in the old days.

EVENT_PLAYER_HERO_SKILL gives you access to GetLearnedSkillLevel().

Always use GetTriggerUnit() when appliable, in this case GetLearningUnit() == GetTriggerUnit().

Did you add the spell twice to the hero in the object editor?
 

waaaks!

Zinctified
Reaction score
256
man try without init function
JASS:
scope LocustSwarm initializer act

JASS:
private function con2 takes nothing returns boolean
    return GetUnitAbilityLevel(GetTriggerUnit(),spell) != 0
endfunction

 
private function act takes nothing returns nothing
    local trigger t = CreateTrigger()
    local unit c = GetLearningUnit()
    call TriggerRegisterUnitEvent( t, c, EVENT_UNIT_ISSUED_ORDER )
    call TriggerAddCondition(t,Condition(function con2))
    call TriggerAddAction(t,function act2)
//    set c = null
 //   set t = null
endfunction

try this maybe work
if work remake skill
pls try
don't force me to remake the skill if it doesn't work, there's always a solution for everything, and why the hell should I remove the init function, for I need to register the learning unit as the unit used in my trigger
Function callback shouldn't return a boolean.
Neither should act2.
I'm amazed that it doesn't crash your editor, it would in the old days.

EVENT_PLAYER_HERO_SKILL gives you access to GetLearnedSkillLevel().

Always use GetTriggerUnit() when appliable, in this case GetLearningUnit() == GetTriggerUnit().

Did you add the spell twice to the hero in the object editor?
some member here used to tell me to return booleans when using timer call backs or triggers that are created in the actions or anywhere except init functions (dynamic triggers? is that what they've called it)

and the hero has full abilities in the object editor (5 hero abilities)

EDIT: got it working, I just lack a condition and just positioned some true or false
 

themean

Active Member
Reaction score
7
Im not force you :)

Im not force you just give you an idea
for consultation unit cant use spell before learning(have at lvl 1 or more)
and this event is unnecessary by my opinion
if you find solution pls post
im curious:rolleyes:
sorry if you need because
JASS:
 call XE_PreloadAbility(dspell)

you can create another trigger with this init function
just see whether is a bug in jass
 

saw792

Is known to say things. That is all.
Reaction score
280
Alright themean, stop posting when you clearly don't understand a single word of his code.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top