• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] This isn't working, anybody knows why?

Status
Not open for further replies.
Level 2
Joined
Mar 29, 2006
Messages
24
I'm trying to make a spell which is based on immolation and when it's activated, it shoots a starfall-bolt every second to a random enemy in 400 aoe around you. The problem is, it doesn't do anything, any JASS-er wants to help me? :D
JASS:
function Filter1 takes nothing returns boolean
    return ( IsUnitDeadBJ(GetFilterUnit()) == false )
endfunction

function Filter2 takes nothing returns boolean
    return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == true )
endfunction

function Filter3 takes nothing returns boolean
    return GetBooleanAnd( Filter1(), Filter2() )
endfunction

function ImmolateActions takes nothing returns nothing
    local unit C = GetTriggerUnit()
    local group G = CreateGroup()
    local location CL
    local unit T
    local effect E
    loop
        exitwhen UnitHasBuffBJ(C, 'BEia') == false
        set CL = GetUnitLoc(C)
        set G = GetUnitsInRangeOfLocMatching(400.00, CL), Condition(function Filter3))
        set T = GroupPickRandomUnit(G)
        call UnitDamageTargetBJ( C, T, 10.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
        set E = AddSpecialEffectLoc("Abilities\\Spells\\NightElf\\Starfall\\StarfallTarget.mdl", GetUnitLoc(T))
        set T = null
        set G = null
        set CL = null
        set E = null
        call TriggerSleepAction(1.00)
    endloop
    set C = null
    set G = null
    set T = null
    set CL = null
    set E = null
endfunction

//=================================================================
function InitTrig_Untitled_Trigger_002 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_002 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_002, EVENT_PLAYER_UNIT_SPELL_FINISH )
    call TriggerAddAction( gg_trg_Untitled_Trigger_002, function ImmolateActions)
endfunction
 
Last edited by a moderator:
Level 23
Joined
Nov 29, 2006
Messages
2,482
I believe it's the event. Immolation is triggered by issued order, not finishing spell casting. To determine if it is the activation order it's "immolation", and for deactivation it's "unimmolation".

Also Im not sure GetTriggerUnit() is parsed through the filters, but I might be wrong here
Try to change the event first
 
Level 14
Joined
Nov 20, 2005
Messages
1,156
Please indent properly (it is so much easier to read) and use JASS tags.

TriggerSleepAction fails miserably for this - simply too inaccurate. You need to use timers, which means attaching stuff. I'd suggest GC + H2I to attach a struct to a timer.

As Eccho says, detect the activation order, but detect the buff disappearing for the deactivation, not the order.
 
Level 2
Joined
Mar 29, 2006
Messages
24
I've made it withouth conditions (just issued order) and wiht conditions (order = equal to immolation) and it still doesn't work, I'm not a star in Jass so I can't see any problem in it atm ;-)
JASS:
function Filter1 takes nothing returns boolean
    return ( IsUnitDeadBJ(GetFilterUnit()) == false )
endfunction

function Filter2 takes nothing returns boolean
    return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == true)
endfunction

function Filter3 takes nothing returns boolean
    return GetBooleanAnd( Filter1(), Filter2() )
endfunction

function ImmolateActions takes nothing returns nothing
    local unit C = GetTriggerUnit()
    local group G = CreateGroup()
    local location CL
    local unit T
    local effect E
    loop
        exitwhen UnitHasBuffBJ(C, 'BEia') == false
        set CL = GetUnitLoc(C)
        set G = GetUnitsInRangeOfLocMatching(400.00, GetUnitLoc(GetTriggerUnit()), Condition(function Filter3))
        set T = GroupPickRandomUnit(G)
        call UnitDamageTargetBJ( C, T, 10.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
        set E = AddSpecialEffectLoc("Abilities\\Spells\\NightElf\\Starfall\\StarfallTarget.mdl", GetUnitLoc(T))
        set T = null
        set G = null
        set CL = null
        set E = null
        call TriggerSleepAction(1.00)
    endloop
    set C = null
    set G = null
    set T = null
    set CL = null
    set E = null
endfunction

//=================================================================
function InitTrig_Untitled_Trigger_002 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_002 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_002, EVENT_PLAYER_UNIT_ISSUED_ORDER )
    call TriggerAddAction( gg_trg_Untitled_Trigger_002, function ImmolateActions)
endfunction
 
Last edited by a moderator:
Level 23
Joined
Nov 29, 2006
Messages
2,482
well, why not call a BJDebug message somewhere?

I have 2 suggestions of what could be wrong.
1st: the thing that captain griffen said, and well he said that you must use a Handle Attachment system for that. There are some to chose from. Otherwise try "polled wait".

The second one could be the Filter conditions. Try use all in one filter.

As for the loop, you dont need to nullify the variables in there
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
well simply put some places where you write call BJDebugMsg("Your Message") and add different strings at every place...

As for the filter. Instead of having a filter which is calling to match 2 other filters, have them both in the first one:

JASS:
function YourFilter takes nothing returns boolean
   return IsUnitDeadBJ(GetFilterUnit()) == false and IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit()))
endfunction

Note that BJ:s should be avoied generally except when using a temporary debug message
 
Level 2
Joined
Mar 29, 2006
Messages
24
I made a few Debug messages, one at the start after setting locals, one in the middle of the loop and one at the end. I saw that the second one never went on, only when I did the skill off. I fixed this by letting the wait occur at the first part. the second problem is that it won't deal any dmg nor shoot bolts.

Edit: It works, thank you!:D I made a mistake with doing the issued order boolean in the conditions everey second which bugged it :p
 
Status
Not open for further replies.
Top