• 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] Whats wrong with this trigger???

Status
Not open for further replies.
Level 6
Joined
Nov 15, 2010
Messages
112
hey, i tried to make Hellfire with JASS trigger but whats up with this trigger??? Is this right or not???


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

function Hellfire_Actions takes nothing returns nothing
    set udg_caster = GetTriggerUnit()
    set udg_castrloc = GetUnitLoc(udg_caster)
    set udg_castrface = GetUnitFacing(udg_caster)
    set udg_targetloc = GetSpellTargetLoc()
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 10
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        call CreateNUnitsAtLoc( 1, 'hfoo', GetOwningPlayer(udg_caster), PolarProjectionBJ(udg_castrloc, 256, udg_castrface), bj_UNIT_FACING )
        set udg_dummy = GetLastCreatedUnit ()
        set udg_dummyloc = GetUnitLoc(udg_dummy)
        call UnitAddAbilityBJ( 'A000' , udg_dummy )
        call UnitApplyTimedLifeBJ( 1.50, 'BTLF', udg_dummy )
        call IssueImmediateOrderBJ( udg_dummy, "thunderclap" )
        call AddSpecialEffectLocBJ( udg_dummyloc, "Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl" )
        call DestroyEffectBJ( GetLastCreatedEffectBJ() )
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction                     

//===========================================================================
function InitTrig_Hellfire takes nothing returns nothing
    set gg_trg_Hellfire = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Hellfire, function Hellfire_Actions )
endfunction
 
Level 7
Joined
Oct 11, 2008
Messages
304
This is gui converted...

You have no event here.

JASS:
function InitTrig_Hellfire takes nothing returns nothing
    set gg_trg_Hellfire = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Hellfire, function Hellfire_Actions )
endfunction

You could change all the BJs (red names) to natives (purple names).
Also, you never use your condition and it can be improved.
 
Level 6
Joined
Nov 15, 2010
Messages
112
This is gui converted...

You have no event here.

JASS:
function InitTrig_Hellfire takes nothing returns nothing
    set gg_trg_Hellfire = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Hellfire, function Hellfire_Actions )
endfunction

You could change all the BJs (red names) to natives (purple names).
Also, you never use your condition and it can be improved.

how to add event???

and how i wanna use my condition??

aaaand how i wanna change BJ to natives????
 
like this...
JASS:
function Hellfire_Conditions takes nothing returns boolean
   return GetSpellAbilityId() == 'A000'
endfunction

function InitTrig_Hellfire takes nothing returns nothing
    set gg_trg_Hellfire = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Hellfire, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Hellfire, Condition(function Hellfire_Conditions))
    call TriggerAddAction( gg_trg_Hellfire, function Hellfire_Actions )
endfunction
 
Level 7
Joined
Oct 11, 2008
Messages
304
Most of BJs are stupid... Look this:

JASS:
call UnitAddAbilityBJ('A000' , udg_dummy) // this is the bj that call the native below
call UnitAddAbility(udg_dummy, 'A000') // this is the native

If you're using JNGP, hold Ctrl and click on some BJ and see how it's used.

Most of them are like my example above.

Edit: Something freehanded.


JASS:
function Hellfire_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local real f = GetUnitFacing(u)
    local player p = GetTriggerPlayer()
    // ------------------------------
    local real xx = x + 256 * Cos(f * bj_DEGTORAD)
    local real yy = y + 256 * Sin(f * bj_DEGTORAD)
    local integer i = 0
    local unit d
    
    loop
        exitwhen i > 9
        set d = CreateUnit(p, 'hfoo', xx, yy, 0.)
        call UnitAddAbility(d, 'A000')
        call UnitApplyTimedLife(d, 'BTLF', 1.50)
        call IssueImmediateOrder(d, "thunderclap")
        call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl", x, y)
        set i = i + 1
    endloop
    
    set u = null
    set d = null
    set p = null
endfunction
 
Level 6
Joined
Nov 15, 2010
Messages
112
Most of BJs are stupid... Look this:

JASS:
call UnitAddAbilityBJ('A000' , udg_dummy) // this is the bj that call the native below
call UnitAddAbility(udg_dummy, 'A000') // this is the native

If you're using JNGP, hold Ctrl and click on some BJ and see how it's used.

Most of them are like my example above.

Edit: Something freehanded.


JASS:
function Hellfire_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local real f = GetUnitFacing(u)
    local player p = GetTriggerPlayer()
    // ------------------------------
    local real xx = x + 256 * Cos(f * bj_DEGTORAD)
    local real yy = y + 256 * Sin(f * bj_DEGTORAD)
    local integer i = 0
    local unit d
    
    loop
        exitwhen i > 9
        set d = CreateUnit(p, 'hfoo', xx, yy, 0.)
        call UnitAddAbility(d, 'A000')
        call UnitApplyTimedLife(d, 'BTLF', 1.50)
        call IssueImmediateOrder(d, "thunderclap")
        call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl", x, y)
        set i = i + 1
    endloop
    
    set u = null
    set d = null
    set p = null
endfunction

yours are very good n i like it... no need to use:

JASS:
//===============================================
function InitTrig_Hellfire takes nothing returns nothing
    set gg_trg_Hellfire = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Hellfire, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Hellfire, Condition( function Hellfire_Conditions ) )
    call TriggerAddAction( gg_trg_Hellfire, function Hellfire_Actions )
endfunction

Edit:Wait, when i tried your trigger, it says "script errors:line 45:expected ''

and it highlighted

[JASS=] call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl", x, y) [/code]

wtf!!! after i tried this trigger:

[JASS=]

function Hellfire_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real f = GetUnitFacing(u)
local player p = GetTriggerPlayer()
//-------------------------------
local real xx = x + 256 * Cos(f * bj_DEGTORAD)
local real yy = y + 256 * Sin(f * bj_DEGTORAD)
local integer i = 0
local unit d

loop
exitwhen i > 9
set d = CreateUnit( p, 'hfoo', xx , yy , 0 )
call UnitAddAbility(d, 'A000')
call UnitApplyTimedLife(d, 'BTLF', 1.50)
call IssueImmediateOrder(d, "thunderclap")
set i = i + 1
endloop

set u = null
set d = null
set p = null
endfunction

//--------------------------------------------------------
function InitTrig_Hellfire takes nothing returns nothing
set gg_trg_Hellfire = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( gg_trg_Hellfire, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddAction( gg_trg_Hellfire, function Hellfire_Actions )
endfunction

[/code]


my pc lag like shit and crash my whole pc
:(

and this trigger cant be used as long as the InitTrig_Hellfire not used...
 
Last edited by a moderator:
Level 17
Joined
Feb 11, 2011
Messages
1,860
JASS:
function cond_Hellfire takes nothing returns boolean
    if (GetSpellAbilityId() == 'your_id') then
        return true
    endif
    return false
endfunction

function InitTrig_Hellfire takes nothing returns nothing
    set gg_trg_Hellfire = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Hellfire, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition(gg_trg_Hellfire, Condition(function cond_Hellfire))
    call TriggerAddAction( gg_trg_Hellfire, function Hellfire_Actions )
endfunction
Note: Replace your_id with the ID of your Hellfire spell.
 
Level 7
Joined
Oct 11, 2008
Messages
304
JASS:
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Other\\Doom\\DoomDeath.mdl", x, y))

Sorry :p I forget one ) in the end of line lol

The actual problem is that there's no condition to detect what exactly ability is... If any ability is casted, then this trigger will run. In the trigger, dummies cast thunder clap, so the trigger run again, creating new dummies, ordering them to thunder clap again and make the trigger running again. Infinity loop :p.

Also, to make the spell cast thunder clap in line, you should change the value of variables 'xx' and 'yy' inside the loop based on the variable 'i'. Like:

JASS:
function Hellfire_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local real f = GetUnitFacing(u)
    local player p = GetTriggerPlayer()
    //-------------------------------
    local real xx = x + 50 * Cos(f * bj_DEGTORAD)
    local real yy = y + 50 * Sin(f * bj_DEGTORAD)
    local integer i = 1
    local unit d
  
    loop
        exitwhen i > 10
        set d = CreateUnit( p, 'hfoo', xx , yy , 0 )
        set xx = x + (50 * i) * Cos(f * bj_DEGTORAD) //this will be dynamic
        set yy = y + (50 * i) * Sin(f * bj_DEGTORAD) //the distance will be 50/100/150... util 500
        call UnitAddAbility(d, 'A000')
        call UnitApplyTimedLife(d, 'BTLF', 1.50)
        call IssueImmediateOrder(d, "thunderclap")
        set i = i + 1
    endloop

    set u = null
    set d = null
    set p = null
endfunction
 
Level 6
Joined
Nov 15, 2010
Messages
112
is this okay???

JASS:
function Hellfire_Condition takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction 

function Hellfire_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local real f = GetUnitFacing(u)
    local player p = GetTriggerPlayer()
    //-------------------------------
    local real xx = x + 50 * Cos(f * bj_DEGTORAD)
    local real yy = y + 50 * Sin(f * bj_DEGTORAD)
    local integer i = 1
    local unit d
  
    loop
        exitwhen i > 10
        set d = CreateUnit( p, 'hfoo', xx , yy , 0 )
        set xx = x + (50 * i) * Cos(f * bj_DEGTORAD) //this will be dynamic
        set yy = y + (50 * i) * Sin(f * bj_DEGTORAD) //the distance will be 50/100/150... util 500
        call UnitAddAbility(d, 'A000')
        call UnitApplyTimedLife(d, 'BTLF', 1.50)
        call IssueImmediateOrder(d, "thunderclap")
        set i = i + 1
    endloop

    set u = null
    set d = null
    set p = null
endfunction

//--------------------------------------------------------
function InitTrig_Hellfire takes nothing returns nothing
    set gg_trg_Hellfire = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Hellfire, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Hellfire, Condition( function Hellfire_Condition ) )
    call TriggerAddAction( gg_trg_Hellfire, function Hellfire_Actions )
endfunction
 
Last edited:
Level 6
Joined
Nov 15, 2010
Messages
112
b4 i post this into spells, i wanna make sure if this SpawnCreeps trigger is right:

[JASS=]function SpawnCreeps_Actions takes nothing returns nothing

call FogEnableOff( )
call FogMaskEnableOff( )
call CreateNUnitsAtLoc( 10, 'nmrl', Player(PLAYER_NEUTRAL_AGGRESSIVE), GetRectCenter(gg_rct_Region_000), bj_UNIT_FACING )


endfunction

//===========================================================================
function InitTrig_SpawnCreeps takes nothing returns nothing
set gg_trg_SpawnCreeps = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_SpawnCreeps, 5.00 )
call TriggerAddAction( gg_trg_SpawnCreeps, function SpawnCreeps_Actions )
endfunction

[/code]
 
Status
Not open for further replies.
Top