• 🏆 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 - Multihit

Status
Not open for further replies.
Level 2
Joined
Mar 29, 2006
Messages
24
I've got a spell where myb unit blinks to the target and hit it 10 times with 50 dmg and blinks back. But I can't let him appear behind the target and not in the target, this is my trigger now, I know it leaks, I di'n't remove the leaks yet

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

function actions takes nothing returns nothing
local unit trig = GetTriggerUnit()
local location trigplace = GetUnitLoc(trig)
local unit targ = GetSpellTargetUnit()
local real count = 0
local location x = GetUnitLoc(targ)
local real face = GetUnitFacing(targ)-180
call SetUnitTimeScalePercent( trig, 300 )
loop
exitwhen count == 10
set count = count+1
call UnitDamageTarget(trig, targ, 10, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, null)
call SetUnitPositionLoc(trig, x)
call SetUnitAnimation( trig, "attack" )
call TriggerSleepAction(0.10)
endloop
call SetUnitPositionLoc(trig, trigplace)
endfunction

//===========================================================================
function InitTrig_Test takes nothing returns nothing
    set gg_trg_Test = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Test, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Test, Condition( function Trig_Test_Conditions ) )
    call TriggerAddAction( gg_trg_Test, function actions )
endfunction
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Something like this should work

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

function BlinkActions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local unit target = GetSpellTargetUnit()
    local real ux = GetUnitX(u)
    local real uy = GetUnitY(u)
    local real uangle = GetUnitFacing(u)
    local real x = GetUnitX(target)
    local real y = GetUnitX(target)
    local real angle = GetUnitFacing(target)
    local real newx = x - 20 * Cos(angle * bj_DEGTORAD)
    local real newy = y - 20 * Sin(angle * bj_DEGTORAD)
    local integer count = 1
    call SetUnitPosition(u, x, y)
    call SetUnitFacing(u, angle)
    loop
        exitwhen count == 10 or GetWidgetLife(target) == 0
        call SetUnitAnimation(u, "attack" )
        call UnitDamageTarget(u, target, 10, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
        call TriggerSleepAction(0.10)
        set count = count + 1
    endloop
    call SetUnitPosition(u, ux, uy)
    call SetUnitFacing(u, uangle)
    set u = null
    set target = null
endfunction

//===========================================================================
function InitTrig_blink takes nothing returns nothing
    set gg_trg_blink = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_blink, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_blink, Condition( function BlinkConditions ) )
    call TriggerAddAction( gg_trg_blink, function BlinkActions )
endfunction
 
Level 2
Joined
Mar 29, 2006
Messages
24
The code doesn't work :\
It causes my unit to shoot far from the unit instead of going behind it
thanks anyway with the code :)
 
Status
Not open for further replies.
Top