• 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.

[Solved] Help me a little

Status
Not open for further replies.
Level 7
Joined
Dec 20, 2007
Messages
151
hi i made a missle spell in jass

all worked fine utill when my dummy misslle meats another dummy missle they need to make a boom and remove ... well they meet and go foward

if you know a condition or something that

when dummy missle let's say : 'h00K' meats another 'h00K' they make a explosion and the dummy is removed

JASS:
function kunaiCond takes nothing returns boolean
return GetSpellAbilityId() == 'A00G' 
endfunction

function KunaiBoom takes nothing returns nothing
    local hashtable table = udg_table
    local integer h = udg_i
    local unit picked = GetEnumUnit ()
    local unit caster = LoadUnitHandle(table,h,1)
    local unit dummy = LoadUnitHandle(table,h,2)
    local real dx = GetUnitX(dummy)
    local real dy = GetUnitY(dummy)
    local real damage =I2R(GetUnitAbilityLevel(caster,'A00G')) * 200
    local real px = GetUnitX(picked)
    local real py = GetUnitY(picked)
    local real x = px - dx
    local real y = py - dy
    
    
    
    if SquareRoot(x * x + y * y)  <= 125 and IsUnitEnemy(picked, GetOwningPlayer(caster)) == true or GetUnitTypeId(picked) == 'h00K'  then
    call UnitDamageTarget(caster,picked,damage,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,null)
    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl",dx,dy))
    call RemoveUnit(dummy)
    call SaveReal(table,h,4,0)
      
    
    endif
    
    


endfunction


function KunaiTrue takes nothing returns boolean
return true
endfunction


function kunaiLoop takes nothing returns nothing
    local hashtable table = udg_table
    local timer t = GetExpiredTimer()
    local integer h = GetHandleId(t)
    local unit caster = LoadUnitHandle(table,h,1)
    local unit dummy = LoadUnitHandle(table,h,2)
    local real speed = LoadReal(table,h,3)
    local real distance = LoadReal(table,h,4)
    local real dx = GetUnitX(dummy)
    local real dy = GetUnitY(dummy)
    local real angle = GetUnitFacing(dummy) + 0
    local real x = dx + speed * Cos(angle * bj_DEGTORAD)
    local real y = dy + speed * Sin(angle * bj_DEGTORAD)
    local group g 
  
    
    
    if distance <=0 then
    call RemoveUnit(dummy)
    
    call FlushChildHashtable(table,h)
    set table = null
    set t = null
    set caster = null
    set dummy = null
    call DestroyTimer(GetExpiredTimer())
    
    else
    call SetUnitPosition(dummy,x,y)
    call SaveReal(table,h,4,distance-0.03)
    set udg_i = h
    set g = CreateGroup ()
    call GroupEnumUnitsInRange(g,dx,dy,100,function KunaiTrue)
    call ForGroup(g,function KunaiBoom)
    call DestroyGroup(g)
    
    endif


endfunction

function kunaiAct takes nothing returns nothing
    local hashtable table = udg_table
    local timer t = CreateTimer()
    local integer h = GetHandleId(t)
    local unit caster = GetTriggerUnit()
    
    local real cx = GetUnitX(caster)
    local real cy = GetUnitY(caster)
    local real tx = GetSpellTargetX()
    local real ty = GetSpellTargetY()
    local real angle = bj_RADTODEG * Atan2(ty - cy, tx - cx)
    
    local real x = cx + 50 * Cos(angle * bj_DEGTORAD)
    local real y = cy + 50 * Sin(angle * bj_DEGTORAD)
    
    local unit dummy = CreateUnit(GetOwningPlayer(caster),'h00K',x,y,angle)
    local real distance = 2
    local real speed = 35
    
    call SaveUnitHandle(table,h,1,caster)
    call SaveUnitHandle(table,h,2,dummy)
    call SaveReal(table,h,3,speed)
    call SaveReal(table,h,4,distance)
    
    call TimerStart(t,0.03,true,function kunaiLoop)
    
    set table = null
    set t = null
    set caster = null
    set dummy = null

endfunction

//===========================================================================
function InitTrig_kunai takes nothing returns nothing
    local trigger kunai = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( kunai, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( kunai, Condition( function kunaiCond ) )
    call TriggerAddAction(kunai, function kunaiAct )
    set kunai = null
endfunction

SOLVED
 
Last edited:
Level 7
Joined
Dec 20, 2007
Messages
151
GroupEnumUnitsInRange doesn't pick units with locust ability.

You can try picking units of player, that will pick units with locust. For example if all missiles are created for Plauyer(15) (neutral passive), pick all unit of that player.

well the missiles are created for player 1 2 3 4 5 6 7 8...
i mean for all players :D


also you mean this code:

call GroupEnumUnitsOfPlayer(g,Player (15),function KunaiBoom)

JASS:
  set udg_i = h
    set g = CreateGroup ()
    call GroupEnumUnitsOfPlayer(g,Player (15),function KunaiTrue)
    call ForGroup(g,function KunaiBoom)
    call DestroyGroup(g)

now the dummy don't move :D
 
Your script requires many improvements and I still dont know how you manager this to owrk in case there is a lot of trash code. You should be using two global variables in such case. Conditions & actions should be merged; use group filter to perform actions immidiately; your GroupEnum didn't have Filter() function and much much more.
JASS:
function KunaiBoom takes nothing returns boolean
    local unit u = GetFilterUnit()
    local real dx = GetUnitX(udg_globalDummy)
    local real dy = GetUnitY(udg_globalDummy)
    local real x = GetUnitX(u) - dx
    local real y = GetUnitY(u) - dy
    if (x*x + y*y)  <= 15625 and IsUnitEnemy(u, GetOwningPlayer(udg_globalCaster)) or GetUnitTypeId(u) == 'h00K'  then
        call UnitDamageTarget(udg_globalCaster, u, GetUnitAbilityLevel(udg_globalCaster, 'A00G') * 200., false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
        call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl",dx,dy))
        call RemoveUnit(udg_globalDummy)
    endif
    set u = null
    return false
endfunction

function kunaiLoop takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer h = GetHandleId(t)
    local real distance = LoadReal(udg_table, h, 4)
    local real dx
    local real dy
    set udg_globalCaster = LoadUnitHandle(udg_table, h, 1)
    set udg_globalDummy = LoadUnitHandle(udg_table, h, 2)
    if distance <=0 or GetUnitTypeId(udg_globalDummy) == 0 then
        call RemoveUnit(udg_globalDummy)
        call FlushChildHashtable(udg_table, h)
        call PauseTimer(t)
        call DestroyTimer(t)
    else
        set dx = GetUnitX(udg_globalDummy)
        set dy = GetUnitY(udg_globalDummy)
        call GroupEnumUnitsInRange(bj_lastCreatedGroup, dx, dy, 100, Filter(function KunaiBoom))
        set dx = dx + 35 * Cos(GetUnitFacing(udg_globalDummy) * bj_DEGTORAD)
        set dy = dy + 35 * Sin(GetUnitFacing(udg_globalDummy) * bj_DEGTORAD)
        call SetUnitPosition(udg_globalDummy, dx, dy)
        call SaveReal(udg_table, h, 4, distance-0.03125)
    endif
    set t = null
endfunction

function kunaiCond takes nothing returns boolean
    local timer t
    local integer h
    local unit u
    local real cx
    local real cy
    local real angle
    if GetSpellAbilityId() == 'A00G' then
        set t = CreateTimer()
        set h = GetHandleId(t)
        set u = GetTriggerUnit()
        set cx = GetUnitX(u)
        set cy = GetUnitY(u)
        set angle = bj_RADTODEG * Atan2(GetSpellTargetY() - cy, GetSpellTargetX() - cx)
        set cx = cx + 50 * Cos(angle * bj_DEGTORAD)
        set cy = cy + 50 * Sin(angle * bj_DEGTORAD)
        call SaveUnitHandle(udg_table, h, 1, u)
        call SaveUnitHandle(udg_table, h, 2, CreateUnit(GetTriggerPlayer(),'h00K',cx,cy,angle))
        call SaveReal(udg_table, h, 3, 2)
        call TimerStart(t, 0.03125, true, function kunaiLoop)
        set t = null
        set u = null
    endif
    return false
endfunction

//***************************************************************************
function InitTrig_kunai takes nothing returns nothing
    local trigger kunai = CreateTrigger()
    set udg_table = InitHashtable()
    call TriggerRegisterAnyUnitEventBJ(kunai, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(kunai, Filter(function kunaiCond))
    set kunai = null
endfunction
I wasn't testing this code in game actually, just freshhanded all the improvements.
 
Status
Not open for further replies.
Top