• 🏆 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] How can I make this work ?

Status
Not open for further replies.
Level 18
Joined
Sep 14, 2012
Messages
3,413
Hi everyone,
I have a problem.
Let's explain firstly the spells ( yes I got two spells which aren't working but it's the same problem XD ) :
Mass Hysteria : the hero launches a bouncing wave of shadows damaging all units touched. If the damaged unit got a buff called 'Banebow' they will not be able to cast/attack during some seconds.

Creeping Shadows : the hero launches a shadow in a line damaging all units in the path of the shadow. The damaged unit will be root. If the damaged unit got a buff called 'Banebow' they will be stun instead of root.

Ok now there is the current code :
- Mass Hysteria Start :

JASS:
function Trig_Mass_Hysteria_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A02S' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Mass_Hysteria_Actions takes nothing returns nothing
    local unit a = GetSpellAbilityUnit()
    local unit t = GetSpellTargetUnit()
    local location l = GetUnitLoc(a)
    set udg_Dummy_Hysteria = CreateUnitAtLoc( Player(0), 'h000', l, bj_UNIT_FACING )
    call UnitAddAbility( udg_Dummy_Hysteria, 'A02T' )
    call SetUnitAbilityLevel( udg_Dummy_Hysteria, 'A02T', GetUnitAbilityLevel( a, 'A02S' ) )
    call IssueTargetOrder( udg_Dummy_Hysteria, "chainlightning", t )  
    call UnitApplyTimedLife( udg_Dummy_Hysteria, 'BTLF', 8 )
    call TriggerSleepAction( 8 ) 
    call RemoveLocation(l)
    set l = null
    set a = null
    set t = null
    set udg_Dummy_Hysteria = null
endfunction

//===========================================================================
function InitTrig_Mass_Hysteria takes nothing returns nothing
    set gg_trg_Mass_Hysteria = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Mass_Hysteria, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Mass_Hysteria, Condition( function Trig_Mass_Hysteria_Conditions ) )
    call TriggerAddAction( gg_trg_Mass_Hysteria, function Trig_Mass_Hysteria_Actions )
endfunction

- Mass Hysteria Disable :

JASS:
function Trig_Banebow_Q_Conditions takes nothing returns boolean
    if ( not ( GetEventDamageSource() == udg_Dummy_Hysteria ) ) then
        return false
    endif
    if ( not( GetUnitAbilityLevel( GetTriggerUnit(), 'B006') > 0 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Banebow_Q_Actions takes nothing returns nothing
    local unit t = GetTriggerUnit()
    local unit p = GetEventDamageSource()
    local location l = GetUnitLoc(t)
    local location v = GetUnitLoc(p)
    local unit u = null
    set u = CreateUnitAtLoc( Player(0), 'h000', v, bj_UNIT_FACING )
    call UnitAddAbility( u, 'A035' )
    call SetUnitAbilityLevel( u, 'A035', GetUnitAbilityLevel( udg_Shadow_Archer, 'A032' ) )
    call IssuePointOrderLoc( u, "silence", l )
    call UnitApplyTimedLife( u, 'BTLF', 1 )
    call RemoveLocation(l)
    set t = null
    set l = null
    set u = null 
endfunction

//===========================================================================
function InitTrig_Banebow_Q takes nothing returns nothing
    set gg_trg_Banebow_Q = CreateTrigger(  )
    call TriggerAddCondition( gg_trg_Banebow_Q, Condition( function Trig_Banebow_Q_Conditions ) )
    call TriggerAddAction( gg_trg_Banebow_Q, function Trig_Banebow_Q_Actions )
endfunction


- Creeping Shadow Start :

JASS:
function Trig_Creeping_Shadows_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A02X' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Creeping_Shadows_Actions takes nothing returns nothing
    local unit u = GetSpellAbilityUnit()
    local location l = GetUnitLoc(u)
    local location t = GetSpellTargetLoc()
    set udg_Dummy_Creeping = CreateUnitAtLoc( Player(0), 'h000', l, bj_UNIT_FACING )
    call UnitAddAbility( udg_Dummy_Creeping, 'A02Y' )
    call SetUnitAbilityLevel( udg_Dummy_Creeping, 'A02Y', GetUnitAbilityLevel( udg_Dummy_Creeping, 'A02X' ) )
    call IssuePointOrderLoc( udg_Dummy_Creeping, "shockwave", t )
    call UnitApplyTimedLife( udg_Dummy_Creeping, 'BTLF', 7 )
    call TriggerSleepAction( 7 )
    call RemoveLocation(l)
    call RemoveLocation(t)
    set u = null
    set l = null
    set t = null
    set udg_Dummy_Creeping = null
endfunction

//===========================================================================
function InitTrig_Creeping_Shadows takes nothing returns nothing
    set gg_trg_Creeping_Shadows = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Creeping_Shadows, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Creeping_Shadows, Condition( function Trig_Creeping_Shadows_Conditions ) )
    call TriggerAddAction( gg_trg_Creeping_Shadows, function Trig_Creeping_Shadows_Actions )
endfunction

- Creeping Shadow Disable :

JASS:
function Trig_Banebow_W_Conditions takes nothing returns boolean
    if ( not ( GetEventDamageSource() == udg_Dummy_Creeping ) ) then
        return false
    endif
    if ( not( GetUnitAbilityLevel( GetTriggerUnit(), 'B006') > 0 )  ) then
        return false
    endif
    return true
endfunction

function Trig_Banebow_W_Actions takes nothing returns nothing
    local unit t = GetTriggerUnit()
    local location l = GetUnitLoc(t)
    local unit u = CreateUnitAtLoc( Player(0), 'h000', l, bj_UNIT_FACING )
    if (  GetUnitAbilityLevel( GetTriggerUnit(), 'B006' ) < 0 ) then
        call UnitAddAbility( u, 'A036' )
        call IssueTargetOrder( u, "entanglingroots", t )
    else
        call UnitAddAbility( u, 'A037' )
        call SetUnitAbilityLevel( u, 'A037', GetUnitAbilityLevel( udg_Shadow_Archer, 'A032' ) )
        call IssueTargetOrder( u, "thunderbolt", t )    
    endif
    call UnitApplyTimedLife( u, 'BTLF', 1 )
    call RemoveLocation(l)
    set t = null
    set l = null
    set u = null 
endfunction

//===========================================================================
function InitTrig_Banebow_W takes nothing returns nothing
    set gg_trg_Banebow_W = CreateTrigger(  )
    call TriggerAddCondition( gg_trg_Banebow_W, Condition( function Trig_Banebow_W_Conditions ) )
    call TriggerAddAction( gg_trg_Banebow_W, function Trig_Banebow_W_Actions )
endfunction

Oh it isn't written in the trigger but the event unit takes damage has been added with a trigger adding every unit event takes damage.

The problem is that the wave / schockwave work as i wanted but the disables don't work at all :/
 
Level 18
Joined
Sep 14, 2012
Messages
3,413
Infact the problem seems to be there : local unit t = GetTriggerUnit()
I have the feeling that it isn't taking the good unit : the damaged unit :/

EDIT : So what should i use ? Should i use

JASS:
local unit u = GetTriggerUnit()
local real x = GetUnitX(u)
local real y = GetUnitY(u)

?
 

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,887
Exactly,
do this too on mass hysteria start:

JASS:
   if ( not ( GetSpellAbilityId() == 'A02S' ) ) then
        return false
   endif
return true
=>
JASS:
   if ( GetSpellAbilityId() == 'A02S' ) then
        return true
   endif
endfunction
 
Level 18
Joined
Sep 14, 2012
Messages
3,413
How BJDebugMsg works ?

I'll change every things you've said and i'll try after :D !

actually wrda u do this.

JASS:
function Trig_Mass_Hysteria_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A02S'
endfunction

there isnt an event in there malhorne. how does the trigger run ?

Infact I use
  • Events
    • Unit - A unit enters (Playable Map area)
  • Conditions
    • ((Triggering unit) is in UnitRegistered) Not equal to True
  • Actions
    • Unit Group - Add (Triggering Unit ) to UnitRegistered
    • Trigger - Add to Banebow Q <gen> the event ( Unit - ( Triggering Unit ) Takes damage )
    • Trigger - Add to Banebow W <gen> the event ( Unit - ( Triggering Unit ) Takes damage
And

  • Events
    • Map initialization
  • Conditions
  • Actions
    • Wait 1.00 seconds
    • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
      • Loop - Actions
        • If ( All Conditions are True ) then do ( Then Actions ) else do ( Else Actions )
          • If - Conditions
            • ((Picked unit ) is in IsUnitRegistered) Not equal to True
          • Then - Actions
            • Unit Group - Add (Picked Unit) to IsUnitRegistered
            • Trigger - Add to Banebow Q <gen> the event ( Unit - (Picked unit) Takes damage )
            • Trigger - Add to Banebow W <gen> the event ( Unit - (Picked unit) Takes damage )
 
Last edited:
Level 18
Joined
Sep 14, 2012
Messages
3,413
Ok thanks I see now :)
Just the myth of the : printf("Hello");
X)

EDIT : I haven't done the changes. But when i will, i will tell you if it works ;)
EDIT : How can i get the coordinates for this GetSpellTargetLoc() ? Except by using GetLocationX and GetLocationY
 
Last edited:
Level 18
Joined
Sep 14, 2012
Messages
3,413
It doesn't work XD !

Anyway i modified the code and it doesn't work at all :/

Here the new code :
MASS HYSTERIA

JASS:
function Trig_Mass_Hysteria_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A02S'
endfunction

function Trig_Mass_Hysteria_Actions takes nothing returns nothing
    local unit a = GetSpellAbilityUnit()
    local unit t = GetSpellTargetUnit()
    local real x = GetUnitX(a)
    local real y = GetUnitY(a)
    set udg_Dummy_Hysteria = CreateUnit( Player(0), 'h000', x, y, bj_UNIT_FACING )
    call UnitAddAbility( udg_Dummy_Hysteria, 'A02T' )
    call SetUnitAbilityLevel( udg_Dummy_Hysteria, 'A02T', GetUnitAbilityLevel( a, 'A02S' ) )
    call IssueTargetOrder( udg_Dummy_Hysteria, "chainlightning", t )  
    call UnitApplyTimedLife( udg_Dummy_Hysteria, 'BTLF', 8 )
    call TriggerSleepAction( 8 ) 
    set a = null
    set t = null
    set udg_Dummy_Hysteria = null
endfunction

//===========================================================================
function InitTrig_Mass_Hysteria takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function Trig_Mass_Hysteria_Conditions ) )
    call TriggerAddAction( t, function Trig_Mass_Hysteria_Actions )
    set t = null
endfunction


MASS HYSTERIA DISABLE

JASS:
function Trig_Banebow_Q_Conditions takes nothing returns boolean
    return ( GetEventDamageSource() == udg_Dummy_Hysteria and GetUnitAbilityLevel( GetTriggerUnit(), 'B006' ) > 0 ) 
endfunction

function Trig_Banebow_Q_Actions takes nothing returns nothing
    local unit t = GetTriggerUnit()
    local unit p = GetEventDamageSource()
    local real x = GetUnitX(t)
    local real y = GetUnitY(t)
    local real X = GetUnitX(p)
    local real Y = GetUnitY(p)
    local unit u = null
    set u = CreateUnit( Player(0), 'h000', X, Y, bj_UNIT_FACING )
    call UnitAddAbility( u, 'A035' )
    call SetUnitAbilityLevel( u, 'A035', GetUnitAbilityLevel( udg_Shadow_Archer, 'A032' ) )
    call IssuePointOrder( u, "silence", x, y )
    call UnitApplyTimedLife( u, 'BTLF', 1 )
    set t = null
    set p = null
    set u = null 
endfunction

//===========================================================================
function InitTrig_Banebow_Q takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerAddCondition( t, Condition( function Trig_Banebow_Q_Conditions ) )
    call TriggerAddAction( t, function Trig_Banebow_Q_Actions )
    set t = null
endfunction

CREEPING SHADOWS

JASS:
function Trig_Creeping_Shadows_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A02X'
endfunction

function Trig_Creeping_Shadows_Actions takes nothing returns nothing
    local unit u = GetSpellAbilityUnit()
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local location t = GetSpellTargetLoc()
    local real X = GetLocationX(t)
    local real Y = GetLocationY(t)
    set udg_Dummy_Creeping = CreateUnit( Player(0), 'h000', x, y, bj_UNIT_FACING )
    call UnitAddAbility( udg_Dummy_Creeping, 'A02Y' )
    call SetUnitAbilityLevel( udg_Dummy_Creeping, 'A02Y', GetUnitAbilityLevel( udg_Dummy_Creeping, 'A02X' ) )
    call IssuePointOrder( udg_Dummy_Creeping, "shockwave", X, Y )
    call UnitApplyTimedLife( udg_Dummy_Creeping, 'BTLF', 7 )
    call TriggerSleepAction( 7 )
    call RemoveLocation(t)
    set u = null
    set t = null
    set udg_Dummy_Creeping = null
endfunction

//===========================================================================
function InitTrig_Creeping_Shadows takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function Trig_Creeping_Shadows_Conditions ) )
    call TriggerAddAction( t, function Trig_Creeping_Shadows_Actions )
    set t = null
endfunction


CREEPING SHADOW DISABLE

JASS:
function Trig_Banebow_W_Actions takes nothing returns nothing
    local unit t = GetTriggerUnit()
    local real x = GetUnitX(t)
    local real y = GetUnitY(t)
    local unit u = CreateUnit( Player(0), 'h000', x, y, bj_UNIT_FACING )
    if (  GetUnitAbilityLevel( GetTriggerUnit(), 'B006' ) < 0 ) then
        call UnitAddAbility( u, 'A036' )
        call IssueTargetOrder( u, "entanglingroots", t )
    else
        call UnitAddAbility( u, 'A037' )
        call SetUnitAbilityLevel( u, 'A037', GetUnitAbilityLevel( udg_Shadow_Archer, 'A032' ) )
        call IssueTargetOrder( u, "thunderbolt", t )    
    endif
    call UnitApplyTimedLife( u, 'BTLF', 1 )
    set t = null
    set u = null 
endfunction

//===========================================================================
function InitTrig_Banebow_W takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerAddAction( t, function Trig_Banebow_W_Actions )
    set t = null
endfunction
 
Level 18
Joined
Sep 14, 2012
Messages
3,413
And like this :
  • Events
    • Time - Elapsed game time is 1.00 second
  • Conditions
  • Actions
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
      • Loop - Actions
        • If ( All Conditions are True ) then do ( Then Actions ) else do ( Else Actions )
          • If - Conditions
            • ((Picked unit ) is in IsUnitRegistered) Not equal to True
          • Then - Actions
            • Unit Group - Add (Picked Unit) to IsUnitRegistered
            • Trigger - Add to Banebow Q <gen> the event ( Unit - (Picked unit) Takes damage )
            • Trigger - Add to Banebow W <gen> the event ( Unit - (Picked unit) Takes damage )
 
Level 18
Joined
Sep 14, 2012
Messages
3,413
I'll make again tomorrow.
This two spells are going on my nerves :/

EDIT : I won't be able to do this tomorrow so i'll do it as soon as possible ...

EDIT : Oh fudge this anyway i wanted to those spells differently so i think i'll get rid of it for now ...
 
Last edited:
Jasscraft don't know GetSpellTargetX does it work ?

JassCraft uses an older common.j/blizzard.j. Certain natives, like GetSpellTargetX()/GetSpellTargetY() and hashtable natives, are not included in it. You may want to code in TESH instead if you want to use those natives (or make JassCraft accept those natives).
 
Status
Not open for further replies.
Top