• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] This has me absolutly stumped. . .

Status
Not open for further replies.
Level 9
Joined
Jun 7, 2008
Messages
440
This is my trigger. It seems that it works fine. But the problem is, the dummy units do not cast the ability i want them to. I tried manually giving the ability to the dummy, but that did not work - frustrating. I am out of ideas, literally :(
JASS:
function Trig_Stun_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A01C'
endfunction

function Trig_Stun_Actions takes nothing returns nothing
    local unit cast = GetTriggerUnit()
    local location t = GetSpellTargetLoc()
    local group g = CreateGroup()
    local unit u
    local unit dumb
    call GroupEnumUnitsInRangeOfLoc(g, t, 512.00, null)
    loop
        exitwhen u==null
        if IsUnitEnemy(u, GetOwningPlayer(cast)) then
        set dumb = CreateUnit(GetOwningPlayer(cast), 'h01X', GetUnitX(cast), GetUnitY(cast), 0.00)
        call UnitAddAbility(dumb, 'A00F')
        call IssueTargetOrder(dumb, "firebolt", u)        
        call UnitApplyTimedLife(dumb, 'BTLF', 3)
        call GroupRemoveUnit(g,u)
        endif
        call GroupRemoveUnit(g,u)
    endloop
    call RemoveLocation(t)
    call DestroyGroup(g)
    set g = null
    set dumb = null
    set cast = null
    set t = null
endfunction

//===========================================================================
function InitTrig_Stun takes nothing returns nothing
    set gg_trg_Stun = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Stun, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Stun, Condition( function Trig_Stun_Conditions ) )
    call TriggerAddAction( gg_trg_Stun, function Trig_Stun_Actions )
endfunction
 
Level 9
Joined
Nov 28, 2008
Messages
704
-Is that the dummys ID
-Is "firebolt" the command string for sure?
-Does that ability exist?
-Does the dummy unit have mana?
JASS:
call GroupRemoveUnit(g,u)
endif
        call GroupRemoveUnit(g,u)

What? Fix that.

-You use locations. Why? You have to delete them.. and create them. Use GetSpellTargetX() and Y.

JASS:
call GroupEnumUnitsInRangeOfLoc(g, t, 512.00, null)
    loop
        exitwhen u==null

You need to set u = FirstOfGroup(). Thats your problem.
 
Level 9
Joined
Jun 7, 2008
Messages
440
-Is that the dummys ID
-Is "firebolt" the command string for sure?
It was modified off the base firebolt spell. . . so, ya.
-Does that ability exist?
It does indeed
-Does the dummy unit have mana?
Dumm unit has mana (1000000/+1000.00 regen)
JASS:
call GroupRemoveUnit(g,u)
endif
        call GroupRemoveUnit(g,u)

What? Fix that.
I don't follow. Doesn't the unit need to be removed from the group regardless if it is an enemy or not?

-You use locations. Why? You have to delete them.. and create them. Use GetSpellTargetX() and Y.

Still learning Jass. I tried something I figured would work from my knowledge. I don't know how to do that - yet that is. One tutorial at a time.

JASS:
call GroupEnumUnitsInRangeOfLoc(g, t, 512.00, null)
    loop
        exitwhen u==null

You need to set u = FirstOfGroup(). Thats your problem.
Thanks, I will give it a shot.

EDIT: The spell works, thanks alot. I still have a couple questions i would like to be answered if you wouldnt mind. +rep
 
for the group, read the comments:

JASS:
exitwhen u==null
        if IsUnitEnemy(u, GetOwningPlayer(cast)) then
        set dumb = CreateUnit(GetOwningPlayer(cast), 'h01X', GetUnitX(cast), GetUnitY(cast), 0.00)
        call UnitAddAbility(dumb, 'A00F')
        call IssueTargetOrder(dumb, "firebolt", u)
        call UnitApplyTimedLife(dumb, 'BTLF', 3)
        call GroupRemoveUnit(g,u)//Remove this one
endif
        call GroupRemoveUnit(g,u)//because this one will already work regardless if the unit is an enemy or not because its outside the if

and your trigger will pick every unit and add them to group, even dead units so you may want to add a filter so that it will only pick live enemies to reduce the number of dummies created......
 
Last edited:
Level 9
Joined
Nov 28, 2008
Messages
704
I don't follow. Doesn't the unit need to be removed from the group regardless if it is an enemy or not?

You are removing it twice.

JASS:
call GroupRemoveUnit(g,u)
endif
call GroupRemoveUnit(g,u)

You see, before the if is done, it will remove it. It will then try removing it again AFTER the if. Doing it twice is useless, and could bug (although that chance is low). It's just a good idea to not do it twice. The above posts mentions it correctly, remove the one inside the if. You want it to ALWAYS remove the unit so the thing loops correctly in this sort of loop, else you are going to have infinite loops.

Also, on that note, *please* indent your code. Anything inside of an if should be tabbed one more tab than the if. Its just good readability.

If you do have more questions, do ask. I dont mind helping.
 
Status
Not open for further replies.
Top