• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Trigger doesn't function properly - how can I make it work?

Status
Not open for further replies.
Level 6
Joined
Mar 9, 2023
Messages
75
Hi! I'm pretty wack at Jass, but I tried to make a trigger in it. Problem is that despite it's being "approved" by the system, it doesn't actually do anything. The intent is to deal damage to the caster's HP based on its maximum life * 0.1 per ability level.

JASS:
//TESH.scrollpos=0
//TESH.alwaysfold=0
function BerserkRampage_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A07G'
endfunction

function BerserkRampage_Actions takes nothing returns nothing
local unit u = GetSpellAbilityUnit()
local real lvl = 0.1 * (GetUnitAbilityLevel(u,'A07G'))
call SetUnitState(u,UNIT_STATE_LIFE,GetUnitState(u,UNIT_STATE_LIFE) - lvl)
set u = null
endfunction

//===========================================================================
function InitTrig_BerserkRampage takes nothing returns nothing
    set gg_trg_BerserkRampage = CreateTrigger(  )
    call TriggerAddAction( gg_trg_BerserkRampage, function BerserkRampage_Actions )
endfunction

Edit: Solved with some help! Abandoned the idea of keeping it to be based off max health. Final code looked like:
JASS:
function BerserkRampage_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A07G'
endfunction

function BerserkRampage_Actions takes nothing returns nothing
local unit u = GetSpellAbilityUnit()
local real lvl = (GetUnitAbilityLevel(u,'A07G')) * 0.1
call SetUnitState(u,UNIT_STATE_LIFE,(GetUnitState(u,UNIT_STATE_MAX_LIFE) * (1 - lvl)))
set u = null
endfunction

//===========================================================================
function InitTrig_BerserkRampage takes nothing returns nothing
    set gg_trg_BerserkRampage = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( gg_trg_BerserkRampage,EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_BerserkRampage, Condition( function BerserkRampage_Conditions ) )
    call TriggerAddAction( gg_trg_BerserkRampage, function BerserkRampage_Actions )
endfunction
 
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Your Trigger doesn't have an Event or Condition.

You need to Add these just like you added the Action:
vJASS:
function InitTrig_BerserkRampage takes nothing returns nothing
    set gg_trg_BerserkRampage = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( gg_trg_BerserkRampage , EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_BerserkRampage, function BerserkRampage_Conditions )
    call TriggerAddAction( gg_trg_BerserkRampage, function BerserkRampage_Actions )
endfunction
My syntax might be a little off, I don't use Jass or ever bother adding Conditions. You may need to wrap the Condition's function with Condition() or Filter().
 
Status
Not open for further replies.
Top