Is there something wrong with this code?

chadpiety123

New Member
Reaction score
0
Is there something wrong? It's just supposed to buff every unit in an area including both enemies and allies. I don't get it it won't work.

EDIT: I changed it to this one and added the event, but it still won't work. I used Curse as the base ability of the buff, and blizzard as the base ability of the AoE.

EDIT2: I removed the leaks I knew how to remove and added the creategroup() function. Unfortunately, still not working. It doesn't buff the area at all.

EDIT3: Still not working after optimizing GroupActions and replacing GetTriggerUnit and GetTriggerPlayer

JASS:
scope ExertionDummy
    globals
        private constant integer DUMMYSPELL = 'A000'
        private constant integer MAINSPELL = 'A001'
        private constant integer DUMMYUNIT = 'h003'
        private constant integer TIMEDLIFE = 'BTLF'
        private constant real LIFEDURATION = 1.5
        private constant real AOE = 500
        private constant string DSCOMMAND = "blizzard"
        private constant string MSCOMMAND = "curse"
        
        unit CASTER
    endglobals
    
    function ExertionGroupConditions takes nothing returns boolean
        return IsUnitAliveBJ(GetFilterUnit()) == true
    endfunction
    
    function GroupActions takes nothing returns nothing
        local unit u = GetEnumUnit()
        local real x = GetUnitX(u)
        local real y = GetUnitY(u)
        local unit d = CreateUnit(GetOwningPlayer(CASTER), DUMMYUNIT, x, y, 0)
        
        call UnitApplyTimedLife(d, TIMEDLIFE, LIFEDURATION)
        call UnitAddAbility(d, MAINSPELL)
        call SetUnitAbilityLevel(d, MAINSPELL, GetUnitAbilityLevel(CASTER, DUMMYSPELL))
        call IssueTargetOrder(d, MSCOMMAND, u)
        
        set u = null
        set d = null
    endfunction

    function DummyActions takes nothing returns nothing
        local integer i = 0
        local group g = CreateGroup()
        local unit array uarray
        local real locationX = GetLocationX(GetSpellTargetLoc())
        local real locationY = GetLocationY(GetSpellTargetLoc())
        set CASTER = GetTriggerUnit()
        
        call GroupEnumUnitsInRange(g, locationX, locationY, AOE, Condition(function ExertionGroupConditions))
        call ForGroup(g, function GroupActions)
        call DestroyGroup(g)
        set CASTER = null
    endfunction
    
    function DummyConditions takes nothing returns boolean
        return GetSpellAbilityId() == DUMMYSPELL
    endfunction

    //===========================================================================
 
    function ExertionDummyTrigger takes nothing returns nothing
        local trigger ExertionDummy = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(ExertionDummy, EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(ExertionDummy, Condition(function DummyConditions))
        call TriggerAddAction(ExertionDummy, function DummyActions)
    endfunction
endscope
 

cleeezzz

The Undead Ranger.
Reaction score
268
no event

i think your going for the

call TriggerRegisterAnyUnitEventBJ( ExertionDummy, EVENT_PLAYER_UNIT_SPELL_EFFECT )
 

cleeezzz

The Undead Ranger.
Reaction score
268
you didnt initialize group g

set g = CreateGroup()

or if you have GroupUtils,

set g = NewGroup()


dont forget to Destroy/Release it

and just a leak check:
in GroupActions, you didn't null u, UnitLoc leaks location
in DummyActions, you leak a group.

and what is uarray for? you dont use it
 

chadpiety123

New Member
Reaction score
0
Ah I see. I'll try to do it again now.

uarray was for the code before I edited it. I forgot to remove it. I'll just ask again if I need some more help.
 

cleeezzz

The Undead Ranger.
Reaction score
268
k

1. in GroupActions, when you create the unit, there is no Triggering Player
2. in GroupActions, when you set the ability level, there is no triggering unit.

you could store the unit into a global, since everything is instant, it will still be MUI

then you would do

call CreateUnitAtLoc(GetOwningPlayer(GLOBAL_UNIT), DUMMYUNIT, xy, 0)

and

call SetUnitAbilityLevel(GetLastCreatedUnit(), MAINSPELL, GetUnitAbilityLevel(GLOBAL_UNIT, DUMMYSPELL))
 

cleeezzz

The Undead Ranger.
Reaction score
268
since you used ForGroup, the function it calls (in your case, GroupActions), it will no longer have access to functions that relate to your event, such as GetTriggerUnit, if you use GetTriggerUnit in GroupActions, it will return null because there is none.

here is how i would do it.

JASS:
scope ExertionDummy
    globals
        private unit CASTER
        private constant integer DUMMYSPELL = 'A000'
        private constant integer MAINSPELL = 'A001'
        private constant integer DUMMYUNIT = 'h003'
        private constant integer TIMEDLIFE = 'BTLF'
        private constant real LIFEDURATION = 1.5
        private constant real AOE = 500
        private constant string DSCOMMAND = "blizzard"
        private constant string MSCOMMAND = "curse"
    endglobals
    
    function ExertionGroupConditions takes nothing returns boolean
        return IsUnitAliveBJ(GetFilterUnit()) == true
    endfunction
    
    function GroupActions takes nothing returns nothing
        local unit u = GetEnumUnit()
        local location xy = GetUnitLoc(u)
        
        call CreateUnitAtLoc(GetOwningPlayer(CASTER), DUMMYUNIT, xy, 0)
        call UnitApplyTimedLife(GetLastCreatedUnit(), TIMEDLIFE, LIFEDURATION)
        call UnitAddAbility(GetLastCreatedUnit(), MAINSPELL)
        call SetUnitAbilityLevel(GetLastCreatedUnit(), MAINSPELL, GetUnitAbilityLevel(CASTER, DUMMYSPELL))
        call IssueTargetOrder(GetLastCreatedUnit(), MSCOMMAND, u)
        set u = null
        call RemoveLocation(xy)
    endfunction

    function DummyActions takes nothing returns nothing
        local integer i = 0
        local group g = CreateGroup()
        local unit array uarray
        local real locationX = GetLocationX(GetSpellTargetLoc())
        local real locationY = GetLocationY(GetSpellTargetLoc())
        set CASTER = GetTriggerUnit()
        call GroupEnumUnitsInRange(g, locationX, locationY, AOE, Condition(function ExertionGroupConditions))
        call ForGroup(g, function GroupActions)
        call DestroyGroup(g)
    endfunction
    
    function DummyConditions takes nothing returns boolean
        return GetSpellAbilityId() == DUMMYSPELL
    endfunction

    //===========================================================================
 
    function ExertionDummyTrigger takes nothing returns nothing
        local trigger ExertionDummy = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(ExertionDummy, EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(ExertionDummy, Condition(function DummyConditions))
        call TriggerAddAction(ExertionDummy, function DummyActions)
    endfunction
endscope


oh and if you want to optimize your GroupActions, i would do this


JASS:
    function GroupActions takes nothing returns nothing
        local unit u = GetEnumUnit()
        local real x = GetUnitX(u)
        local real y = GetUnitY(u)
        local unit d = CreateUnit(GetOwningPlayer(CASTER), DUMMYUNIT, x, y, 0)
        call UnitApplyTimedLife(d, TIMEDLIFE, LIFEDURATION)
        call UnitAddAbility(d, MAINSPELL)
        call SetUnitAbilityLevel(d, MAINSPELL, GetUnitAbilityLevel(CASTER, DUMMYSPELL))
        call IssueTargetOrder(d, MSCOMMAND, u)
        set u = null
        set d = null
    endfunction


x,y are reals so they do not leak, plus they are faster than locations

(im not entirely sure, but if you use CreateUnit, the GetLastCreatedUnit() probably doesn't work, which is why i set it to a variable, "d")
 

chadpiety123

New Member
Reaction score
0
I did all of what you said, and it still doesn't work. I'm lost. Maybe it's with the base ability I'm using, or maybe not?
 

cleeezzz

The Undead Ranger.
Reaction score
268
maybe.

remove locust from the dummy, give it a model, see if it creates, if it does, then click it and try to manual cast

that will probably tell you if something is wrong. also make sure the order strings are right.
 

cleeezzz

The Undead Ranger.
Reaction score
268
hm... i dont see why not.

you sure the dummy is 'h003' ?

oh wth, i know why lol, take a close look (hint, first line)

JASS:
scope ExertionDummy initializer ExertionDummyTrigger
    globals
        private constant integer DUMMYSPELL = 'A000'
        private constant integer MAINSPELL = 'A001'
        private constant integer DUMMYUNIT = 'h003'
        private constant integer TIMEDLIFE = 'BTLF'
        private constant real LIFEDURATION = 1.5
        private constant real AOE = 500
        private constant string DSCOMMAND = "blizzard"
        private constant string MSCOMMAND = "curse"
        
        unit CASTER
    endglobals
    
    function ExertionGroupConditions takes nothing returns boolean
        return IsUnitAliveBJ(GetFilterUnit()) == true
    endfunction
    
    function GroupActions takes nothing returns nothing
        local unit u = GetEnumUnit()
        local real x = GetUnitX(u)
        local real y = GetUnitY(u)
        local unit d = CreateUnit(GetOwningPlayer(CASTER), DUMMYUNIT, x, y, 0)
        
        call UnitApplyTimedLife(d, TIMEDLIFE, LIFEDURATION)
        call UnitAddAbility(d, MAINSPELL)
        call SetUnitAbilityLevel(d, MAINSPELL, GetUnitAbilityLevel(CASTER, DUMMYSPELL))
        call IssueTargetOrder(d, MSCOMMAND, u)
        
        set u = null
        set d = null
    endfunction

    function DummyActions takes nothing returns nothing
        local integer i = 0
        local group g = CreateGroup()
        local unit array uarray
        local real locationX = GetLocationX(GetSpellTargetLoc())
        local real locationY = GetLocationY(GetSpellTargetLoc())
        set CASTER = GetTriggerUnit()
        
        call GroupEnumUnitsInRange(g, locationX, locationY, AOE, Condition(function ExertionGroupConditions))
        call ForGroup(g, function GroupActions)
        call DestroyGroup(g)
        set CASTER = null
    endfunction
    
    function DummyConditions takes nothing returns boolean
        return GetSpellAbilityId() == DUMMYSPELL
    endfunction

    //===========================================================================
 
    function ExertionDummyTrigger takes nothing returns nothing
        local trigger ExertionDummy = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(ExertionDummy, EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(ExertionDummy, Condition(function DummyConditions))
        call TriggerAddAction(ExertionDummy, function DummyActions)
    endfunction
endscope


i dont think your trigger was ever initialized.
 

chadpiety123

New Member
Reaction score
0
I'm quite sure, do you mind if I upload the map here? Maybe you could check it personally. I'll be very thankful.
 

Attachments

  • Exertion Code.w3x
    31 KB · Views: 181

cleeezzz

The Undead Ranger.
Reaction score
268
read my post again, i updated.

also, how come you didn't update your wc3 yet? lol

your code wont work in v1.24 because your using TimerUtils which uses H2I, if and when you do update your wc3, remember to update TimerUtils which you can find in wc3c.net
 

chadpiety123

New Member
Reaction score
0
Umm, can you tell me what you meant when you said that the trigger wasn't initialized? Sorry for being such a no-brainer. This is my first Jass code.

And did you change anything in your post? I can't seem to tell.

Thanks again >.<

and with regards to updating... unfortunately, I can't -- in the country where I'm staying, updating your WC means not playing with anybody.
 

cleeezzz

The Undead Ranger.
Reaction score
268
i already gave you a hint, the first line of the code changed O_O

basically, the scope needs to know which function to run when map starts, if it doesn't run ExertionDummyTrigger then the trigger doesn't exist yes? (thats where you create the trigger)
 
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

      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