• 🏆 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] I have no Idea why this trigger isn't working :\

Status
Not open for further replies.
Level 4
Joined
Mar 15, 2008
Messages
71
[SOLVED]I have no Idea why this trigger isn't working :\

please check this trigger and tell me what's the problem if you can find it.
I put it in my map after making it in the jasscraft and the Powerful_Ignition trigger is disabled anytime I try to save the map :\
JASS:
//===========================================================================
// Trigger: Attack Register
//===========================================================================
function Trig_Attack_Register_Conditions takes nothing returns boolean
    if  (( GetUnitAbilityLevel(GetAttacker(),'A003') > 0 ) and ( GetUnitAbilityLevel(GetAttacker(),'A003') < 3 ) and(IsUnitType(GetAttacker(),UNIT_TYPE_MECHANICAL)==false) and (IsUnitType(GetAttacker(),UNIT_TYPE_STRUCTURE)==false)and IsUnitInRange(GetTriggerUnit(),GetAttacker(),(50+100*I2R(GetUnitAbilityLevel(GetAttacker(),'A003'))))) then
        return true
    endif
    return false
endfunction

function Trig_Attack_Register_Actions takes nothing returns nothing
    set udg_aunit = GetTriggerUnit()
endfunction

function InitTrig_Attack_Register takes nothing returns nothing
    set gg_trg_Attack_Register = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Attack_Register,EVENT_PLAYER_UNIT_ATTACKED)
    call TriggerAddCondition(gg_trg_Attack_Register,Condition(function Trig_Attack_Register_Conditions))
    call TriggerAddAction(gg_trg_Attack_Register,function Trig_Attack_Register_Actions)
endfunction
//===========================================================================
// Trigger: Powerful Ignition
//===========================================================================
function Powerful_Ignition_Effect takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit u = GetHandleUnit(t,"u")
    local unit v = GetHandleUnit(t,"v")
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local real a = GetUnitX(v)
    local real b = GetUnitY(v)
    local real r = Atan2(b-y,a-x)
    local real lvl = I2R(GetUnitAbilityLevel(u,'A003'))
    call SetUnitPosition(v,a+Sin(r)*(5+10*lvl),b+Cos(r)*(5+10*lvl))
    set u = null
    set v = null
endfunction
function Trig_Powerful_Ignition_Actions takes nothing returns nothing
    local timer t = CreateTimer()
    local effect se = AddSpecialEffectTarget("Abilities\\Spells\\Human\\FlakCannons\\FlakTarget.mdl" ,GetTriggerUnit(),"origin")
    call TimerStart(t,0.05,true,function Powerful_Ignition_Effect)
    call SetHandleHandle(t,"u",GetEventDamageSource())
    call SetHandleHandle(t,"v",GetTriggerUnit())
    call TriggerSleepAction(0.55)
    call PauseTimer(t)
    call DestroyTimer(t)
    call DestroyEffect(se)
    set se = null
    set t = null
endfunction

//===========================================================================
function InitTrig_Powerful_Ignition takes nothing returns nothing
    set gg_trg_Powerful_Ignition = CreateTrigger()
    call TriggerRegisterUnitEvent(gg_trg_Powerful_Ignition,udg_aunit,EVENT_UNIT_DAMAGED )
    call TriggerAddAction( gg_trg_Powerful_Ignition, function Trig_Powerful_Ignition_Actions )
endfunction
//===========================================================================
function InitCustomTriggers takes nothing returns nothing
    call InitTrig_Melee_Initialization()
    call InitTrig_Powerful_Ignition()
    call InitTrig_Attack_Register()
endfunction

//===========================================================================
ofc the udg_aunit is defined in the globals like this:
JASS:
globals
    //User-Defined
    unit                    udg_aunit                   = null
    // Generated
    trigger                 gg_trg_Melee_Initialization = null
    trigger                 gg_trg_Powerful_Ignition    = null
    trigger                 gg_trg_Attack_Register      = null
endglobals

EDIT: My problem was solved by Element of Water
thx again :)
 
Last edited:
Level 4
Joined
Mar 15, 2008
Messages
71
It gives a bunch of errors that don't make sense...the WE marks every line from the 22nd till the end as an error with one of these errors : "Expected a name,Expected expression,expected a variable name,expected a code statement..."
Could you try to add these two triggers into your WE and try to run them...It's only the Powerful Ignition that becomes disabled :\
 
Level 4
Joined
Mar 15, 2008
Messages
71
I'm telling you,It enlists almost every line of the jass code as an error ,and I think I can't copy the error messages :\,how about we do it like this?
If you would like to check my triggers yourself here's the link :) :
the whole map
the jass file
btw: Thanks for trying ^^.
And don't worry there are only these 2 triggers in the map :\
 
Level 4
Joined
Mar 15, 2008
Messages
71
sorry,I'm a newb when it comes to jass :).
Could you instruct me or send me an example what are(is) handlevars(I get what's it used for but donno exactly ) and where and how do I implement it ? thx man ,your really helpful and u sure have a lot of patients for noobs like me x)
EDIT: K now I found the "Local Handle Vars By: Kattana" and implemented it in the Custom Script Code,now the trigger is enabled but it won't work in game :\
 
Last edited:
Level 4
Joined
Mar 15, 2008
Messages
71
thx :) I figured it out somehow :\ I had to change the triggers tho,there is only one trigger that registers when an unit is attacked,I had to remove the unit takes damage event since it wasn't working for some reason and I had no more patience to keep fixing it :))
 
Status
Not open for further replies.
Top