Why wont it work?

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
Why dont this work. There is no KnockBack
JASS:
function Trig_Bolt_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'AHtb'
endfunction

function Trig_Bolt_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit t = GetSpellTargetUnit()
    local real x = GetUnitX(t)
    local real y = GetUnitY(t)
    local real f = GetUnitFacing(u)
    local integer i = 0 
    loop
    set i = i + 1
    call SetUnitPosition(t, x + 5 * Cos(f * .0175), y + 5 * Sin(f * .0175))
    call TriggerSleepAction(.03)
    exitwhen i == 100
endloop
endfunction
//===========================================================================
function InitTrig_Bolt takes nothing returns nothing
    set gg_trg_Bolt = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Bolt, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Bolt, Condition( function Trig_Bolt_Conditions ) )
    call TriggerAddAction( gg_trg_Bolt, function Trig_Bolt_Actions )
endfunction
 
The unit coordinates are currently constant.

Move the "set x = GetUnitX(t)" and "set y = GetUnitY(t)" calls to the loop.
 
JASS:
    call SetUnitPosition(t, x + 5 * Cos(f * .0175), y + 5 * Sin(f * .0175))


Those values will not change no matter how many times you loop, since the variables "x" and "y" are stored as the X and Y values of the target when the effect started.
 
Now i get errors saying "local declaration after first statement"
 
Let me guess... You did this, right?
JASS:
function Trig_Bolt_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'AHtb'
endfunction

function Trig_Bolt_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit t = GetSpellTargetUnit()
    local real f = GetUnitFacing(u)
    local integer i = 0 
    loop
    set i = i + 1
    local real x = GetUnitX(t)
    local real y = GetUnitY(t)
    call SetUnitPosition(t, x + 5 * Cos(f * .0175), y + 5 * Sin(f * .0175))
    call TriggerSleepAction(.03)
    exitwhen i == 100
endloop
endfunction
//===========================================================================
function InitTrig_Bolt takes nothing returns nothing
    set gg_trg_Bolt = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Bolt, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Bolt, Condition( function Trig_Bolt_Conditions ) )
    call TriggerAddAction( gg_trg_Bolt, function Trig_Bolt_Actions )
endfunction

I'm assuming that is what you did. To fix it, do this instead.
JASS:
function Trig_Bolt_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'AHtb'
endfunction

function Trig_Bolt_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit t = GetSpellTargetUnit()
    local real x
    local real y
    local real f = GetUnitFacing(u)
    local integer i = 0 
    loop
    set i = i + 1
    set x = GetUnitX(t)
    set y = GetUnitY(t)
    call SetUnitPosition(t, x + 5 * Cos(f * .0175), y + 5 * Sin(f * .0175))
    call TriggerSleepAction(.03)
    exitwhen i == 100
endloop
endfunction
//===========================================================================
function InitTrig_Bolt takes nothing returns nothing
    set gg_trg_Bolt = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Bolt, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Bolt, Condition( function Trig_Bolt_Conditions ) )
    call TriggerAddAction( gg_trg_Bolt, function Trig_Bolt_Actions )
endfunction

As Andrewgosu said, move the GetUnitX/Y into the loop, not the whole declaration.
 
Ok this is what i have. why do i get errors with the special effect
JASS:
function Trig_Bolt_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'AHtb'
endfunction

function Trig_Bolt_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit t = GetSpellTargetUnit()
    local real x
    local real y
    local real f = GetUnitFacing(u)
    local integer i = 0 
    loop
    set x = GetUnitX(t)
    set y = GetUnitY(t)
    set i = i + 1
    call SetUnitPosition(t, x + 7 * Cos(f * .0175), y + 7 * Sin(f * .0175))
    call UnitDamageTargetBJ(u, t, 5.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL ) 
    call AddSpecialEffectLocBJ(GetUnitLoc(t),"Abilities\Spells\Human\FlakCannons\FlakTarget.mdl")
    call TriggerSleepAction(.01)
    exitwhen i == 200
endloop
endfunction
//===========================================================================
function InitTrig_Bolt takes nothing returns nothing
    set gg_trg_Bolt = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Bolt, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Bolt, Condition( function Trig_Bolt_Conditions ) )
    call TriggerAddAction( gg_trg_Bolt, function Trig_Bolt_Actions )
endfunction
 
call SetUnitPosition(t, x + 7 * Cos(f * .0175), y + 7 * Sin(f * .0175))

the bolded is a constant

it just keeps counting the same thing over and over, making it "slow" (in reality, it's maybe few .00000001 secs slower, but still :p it looks cleaner)

do this:

JASS:
function Trig_Bolt_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit t = GetSpellTargetUnit()
    local real x
    local real y
    local real f = GetUnitFacing(u)
    local integer i = 0 

    local real a = 7 * Cos(f * .0175)
    local real b = 7 * Sin(f * .0175)
    loop
    set x = GetUnitX(t)
    set y = GetUnitY(t)
    set i = i + 1
    call SetUnitPosition(t, x + a, y + b)
    call UnitDamageTargetBJ(u, t, 5.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL ) 
    call AddSpecialEffectLocBJ(GetUnitLoc(t),"Abilities\\Spells\\Human\\FlakCannons\\FlakTarget.mdl")
    call TriggerSleepAction(.01)
    exitwhen i == 200
endloop
endfunction
 
Thx i got the path from the editor and there it only has 1 slash
 
At some point you'll figure out that the trigger isn't waiting .01 seconds. This is because TriggerSleepAction(...) is delayed by about .1 seconds. The solution is to learn vJass asap and then use a timer.

Also you may note that after casting the spell a couple of times the game begins to lag. This is because you leak 200 effects for every cast of the spell.
 
Yea i like to finish spell first and sure it works then get to the leaks. Yea that triggersleep action dont work to well the knock doesnt look smooth so i switched to a periodic event hehehe
 
the knock doesnt look smooth so i switched to a periodic event

you use a periodic timer in Jass, not event like in GUI...

but that's the advanced part since you need a struct and a timer attachment system

hard to learn, very easy to use.
 
But i made the event in GUI and converted it but still dont know if it works
 
General chit-chat
Help Users

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top