- 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
SOLVED
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: