wraithseeker
Tired.
- Reaction score
- 122
How?
A example would be nice.
A example would be nice.
scope deathpact initializer Init
globals
private constant integer SPELL = 039;A00P039;
private constant string EFFECT = "MDX\\NewDarkPillar.mdx"
private sound SLEEP
private constant string UDEATH = "Objects\\Spawnmodels\\Undead\\UDeathMedium\\UDeath.mdl"
endglobals
private struct data
//! runtextmacro PUI()
unit caster
unit target
unit dummy
timer t
integer ticks
static method create takes nothing returns data
local data d = data.allocate()
set d.caster = GetTriggerUnit()
set d.target = GetSpellTargetUnit()
set d.t = NewTimer()
set d.dummy = CreateUnit(GetOwningPlayer(d.caster),DUMMY,GetUnitX(d.target),GetUnitY(d.target),GetUnitFacing(d.target))
set d.ticks = 0
call UnitApplyTimedLife(d.dummy,039;BTLF039;,3)
call StunUnit(d.target,3)
call AddTimedEffectTarget(EFFECT,d.dummy,"origin",1)
return d
endmethod
endstruct
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL
endfunction
private function Loop takes nothing returns nothing
local data d = data(GetTimerData(GetExpiredTimer()))
local real TLife = GetWidgetLife(d.target) * 0.10
local real TMana = GetUnitState(d.target,UNIT_STATE_MANA) *0.10
local real x = GetUnitX(d.target)
local real y = GetUnitY(d.target)
call SetWidgetLife(d.caster,GetWidgetLife(d.caster)+ TLife)
call SetUnitState(d.caster,UNIT_STATE_MANA,GetUnitState(d.caster,UNIT_STATE_MANA) + TMana)
call SetWidgetLife(d.target,GetWidgetLife(d.target)-TLife)
call SetUnitState(d.target,UNIT_STATE_MANA,GetUnitState(d.target,UNIT_STATE_MANA) - TMana)
set d.ticks = d.ticks + 1
if d.ticks == 3 then
call ReleaseTimer(d.t)
call DestroyEffect(AddSpecialEffect(UDEATH,x,y))
call SetUnitExploded(d.target,true)
call KillUnit(d.target)
endif
endfunction
private function Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit t = GetSpellTargetUnit()
local data d
if GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_EFFECT then
call StartSound(SLEEP)
set d = data.create()
set data<u> = d
call SetTimerData(d.t,d)
call TimerStart(d.t,1,true,function Loop)
set u = null
set t = null
elseif GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_ENDCAST then
set d = data<u>
call ShowUnit(d.dummy,false)
call StopEffect(1)
call RemoveUnit(d.dummy)
call d.destroy()
set u = null
endif
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_ENDCAST)
call TriggerAddAction( t, function Actions )
call TriggerAddCondition(t,Condition(function Conditions))
//set SLEEP = CreateSoundFromLabel("SleepBirth1",false,true,true,10,10)
set SLEEP = CreateSound("Internal\\Abilities\\Spells\\Undead\\SleepBirth1",false,true,true,10,10,"")
call StartSound(SLEEP)
call Preload("Internal\\Abilities\\Spells\\Undead\\SleepBirth1")
call SetSoundVolume(SLEEP,2000)
endfunction
endscope</u></u>
function PlaySound takes string soundName returns nothing
local sound soundHandle = CreateSound(soundName, false, false, true, 12700, 12700, "")
call StartSound(soundHandle)
call KillSoundWhenDone(soundHandle)
endfunction
AttachSoundToUnit() and/or SetSoundPosition()
scope deathpact initializer Init
globals
private constant integer SPELL = 039;A00P039;
private constant string EFFECT = "MDX\\NewDarkPillar.mdx"
private sound SLEEP
private constant string UDEATH = "Objects\\Spawnmodels\\Undead\\UDeathMedium\\UDeath.mdl"
endglobals
private struct data
unit caster
unit target
unit dummy
timer t
integer ticks
implement AutoData
static method create takes nothing returns data
local data d = data.allocate()
set d.caster = GetTriggerUnit()
set d.target = GetSpellTargetUnit()
set d.t = NewTimer()
set d.dummy = CreateUnit(GetOwningPlayer(d.caster),DUMMY,GetUnitX(d.target),GetUnitY(d.target),GetUnitFacing(d.target))
set d.ticks = 0
call UnitApplyTimedLife(d.dummy,039;BTLF039;,3)
call StunUnit(d.target,3)
call AddTimedEffectTarget(EFFECT,d.dummy,"origin",1)
return d
endmethod
endstruct
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL
endfunction
private function Loop takes nothing returns nothing
local data d = data(GetTimerData(GetExpiredTimer()))
local real TLife = GetWidgetLife(d.target) * 0.10
local real TMana = GetUnitState(d.target,UNIT_STATE_MANA) *0.10
local real x = GetUnitX(d.target)
local real y = GetUnitY(d.target)
call AttachSoundToUnit(SLEEP,d.target)
call StartSound(SLEEP)
call SetWidgetLife(d.caster,GetWidgetLife(d.caster)+ TLife)
call SetUnitState(d.caster,UNIT_STATE_MANA,GetUnitState(d.caster,UNIT_STATE_MANA) + TMana)
call SetWidgetLife(d.target,GetWidgetLife(d.target)-TLife)
call SetUnitState(d.target,UNIT_STATE_MANA,GetUnitState(d.target,UNIT_STATE_MANA) - TMana)
set d.ticks = d.ticks + 1
if d.ticks == 3 then
call ReleaseTimer(d.t)
call DestroyEffect(AddSpecialEffect(UDEATH,x,y))
call SetUnitExploded(d.target,true)
call KillUnit(d.target)
endif
endfunction
private function Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit t = GetSpellTargetUnit()
local data d
local integer id = GetUnitId(u)
if GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_EFFECT then
call StartSound(SLEEP)
set d = data.create()
set data<u> = d
call SetTimerData(d.t,d)
call TimerStart(d.t,1,true,function Loop)
set u = null
set t = null
elseif GetTriggerEventId() == EVENT_PLAYER_UNIT_SPELL_ENDCAST then
set d = data<u>
call ShowUnit(d.dummy,false)
call StopEffect(1)
call RemoveUnit(d.dummy)
call d.destroy()
set u = null
endif
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_ENDCAST)
call TriggerAddAction( t, function Actions )
call TriggerAddCondition(t,Condition(function Conditions))
//set SLEEP = CreateSoundFromLabel("SleepBirth1",false,true,true,10,10)
set SLEEP = CreateSound("Internal\\Abilities\\Spells\\Undead\\SleepBirth1",false,true,true,10,10,"")
call StartSound(SLEEP)
call Preload("Internal\\Abilities\\Spells\\Undead\\SleepBirth1")
call SetSoundVolume(SLEEP,2000)
endfunction
endscope
</u></u>
function Force3dSound takes string SPath, unit onWho, real MaxDistance, real FadeDistance, integer MaxVolume returns nothing
local sound s = CreateSound(SPath,false,false,true,1,1,"DefaultEAXON") //path / boolean if looping / boolean if 3D / boolean if stop when out of range / integer fade in rate / integer fade out rate
local real dx = GetUnitX(onWho) - GetCameraTargetPositionX()
local real dy = GetUnitY(onWho) - GetCameraTargetPositionY()
local real dist = SquareRoot(dx*dx+dy*dy)
local integer volume = 0
if dist < FadeDistance then
set volume = MaxVolume
elseif dist < MaxDistance then
set volume = R2I(MaxVolume * (MaxDistance - dist) / (MaxDistance - FadeDistance))
endif
call SetSoundDuration(s,100) //in ms
call SetSoundChannel(s,0) //not needed
call SetSoundPitch(s,1.) //pitch in real, 1. = 100%
//The following commands do the exact same as PlaySoundOnUnitBJ
call AttachSoundToUnit(s, GetTriggerUnit())
call SetSoundVolume(s,volume) //volume
call StartSound(s)
endfunction
local sound snd = CreateSound("war3mapImported\\Rin NP.mp3", false, false, false, 10, 10,"DefaultEAXON") //create default sound
call SetSoundDuration(snd, 6740) //duration 6,740ms
call SetSoundChannel(snd, 0) //channel normal
call SetSoundVolume(snd, 127) //volume max
call SetSoundPitch(snd, 1.0) //pitch rate 1.0x