Hello,
first off; heres the code:
This code works as intended; the only issue is; I have so the sound ACTIVATES once you ATTACK a targeted unit.
I have a different sound I want to start playing WHEN you activate it, not ATTACK with it.
But I have no clue on how to do that; tried and tried and tested and tested but no matter what happens, both sounds starts once I attack a unit.
Advice please!
first off; heres the code:
JASS:
function Trig_Rasengan_Conditions takes nothing returns boolean
return GetUnitAbilityLevel(GetAttacker(),0x42303036)>0 and IsUnitType(GetTriggerUnit(),UNIT_TYPE_STRUCTURE)==false and IsUnitEnemy(GetTriggerUnit(),GetOwningPlayer(GetAttacker()))
endfunction
function Trig_Rasengan_Actions2 takes nothing returns nothing
local timer t=GetExpiredTimer()
local integer id=GetHandleId(t)
local unit u=LoadUnitHandle(h,id,0)
local unit c=LoadUnitHandle(h,id,1)
local real x=LoadReal(h,id,2)
local real y=LoadReal(h,id,3)
local real x1=GetUnitX(c)
local real y1=GetUnitY(c)
local real a=Atan2(y1-y,x1-x)
if SR(x,y,x1,y1)<1000 and GetWidgetLife(c)>0 then
call SetUnitX(c,x1+25*Cos(a))
call SetUnitY(c,y1+25*Sin(a))
call DestroyEffect(AddSpecialEffectTarget("Objects\\Spawnmodels\\NightElf\\NEDeathSmall\\NEDeathSmall.mdl",c,"origin"))
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl",x1,y1))
call UnitApplyTimedLife(CreateUnit(GetOwningPlayer(u),0x65303037,x1,y1,GetUnitFacing(u)),0x42303031,0.5)
else
call PauseTimer(t)
call DestroyTimer(t)
call FlushChildHashtable(h,id)
endif
set u=null
set c=null
set t=null
endfunction
function Trig_Rasengan_Actions takes nothing returns nothing
local unit u=GetAttacker()
local unit c=GetTriggerUnit()
local real x=GetUnitX(u)
local real y=GetUnitY(u)
local timer t=CreateTimer()
local integer id=GetHandleId(t)
local integer lvl=(GetUnitAbilityLevel(u,0x41303233)+1)
call AddUnitAnimationProperties(u,"Spell two",true)
call UnitDamageTarget(u,c,GetHeroAgi(u,true)*lvl+100,false,false,null,null,null)
call UnitRemoveAbility(u,0x42303036)
set n=CreateUnit(GetOwningPlayer(u),0x68303139,x,y,0)
call UnitAddAbility(n,0x41303942)
call SetUnitAbilityLevel(n,0x41303942,1)
call UnitApplyTimedLife(n,0x42544C46,1)
call IssueTargetOrder(n,"thunderbolt",c)
call SaveUnitHandle(h,id,0,u)
call SaveUnitHandle(h,id,1,c)
call SaveReal(h,id,2,x)
call SaveReal(h,id,3,y)
set bj_lastPlayedSound=CreateSound("Sound\\Music\\mp3Music\\minatorasengan.mp3",false,false,true,12700,12700,"")
call StartSound(bj_lastPlayedSound)
call KillSoundWhenDone(bj_lastPlayedSound)
call TimerStart(t,0.025,true,function Trig_Rasengan_Actions2)
set u=null
set t=null
set c=null
endfunction
function InitTrig_Rasengan takes nothing returns nothing
set gg_trg_Rasengan=CreateTrigger()
call TriggerAddCondition(gg_trg_Rasengan,Condition(function Trig_Rasengan_Conditions))
call TriggerRegisterAnyUnitEventBJ(gg_trg_Rasengan,EVENT_PLAYER_UNIT_ATTACKED)
call TriggerAddAction(gg_trg_Rasengan,function Trig_Rasengan_Actions)
endfunction
This code works as intended; the only issue is; I have so the sound ACTIVATES once you ATTACK a targeted unit.
I have a different sound I want to start playing WHEN you activate it, not ATTACK with it.
But I have no clue on how to do that; tried and tried and tested and tested but no matter what happens, both sounds starts once I attack a unit.
Advice please!