- Joined
- Jul 14, 2011
- Messages
- 3,213
Hi!
I'm helping someone with an ability that makes some spirits cicle around a unit (already achieved); each spirit regens the unit depending on the level of the ability being cast (already achieved) BUT they block incoming damage, and every (30 + (level of ability x 15)) one of them flies away towards the damage dealer (the one that reached the damage gap) and explode on it's position dealing the same amount of blocked damage (30+lvl*15).
I don't know how to access the spirits that are spinning around the unit to send them to the damage dealer
I don't know how to block/null damage either.
Here's what I have
Some values are messed up because I'm just testing, but I just got tired
I'm helping someone with an ability that makes some spirits cicle around a unit (already achieved); each spirit regens the unit depending on the level of the ability being cast (already achieved) BUT they block incoming damage, and every (30 + (level of ability x 15)) one of them flies away towards the damage dealer (the one that reached the damage gap) and explode on it's position dealing the same amount of blocked damage (30+lvl*15).
I don't know how to access the spirits that are spinning around the unit to send them to the damage dealer
I don't know how to block/null damage either.
Here's what I have
JASS:
globals
integer Spart_SpiritCount = 5 // Number of Spirits to create
group Spart_SpiritProtectGroup = CreateGroup() // Unit Group
group Spart_SpiritAttackGroup = CreateGroup() // Unit Group
group Spart_ProtectedGroup = CreateGroup() // Unit Group
integer Spart_SpiritId = 'xxxx' // Id of your dummy
real Spart_SpiritOffset = 15*Spart_SpiritCount // Distance between spirits and target
real Spart_SpiritSpeed = 0.09 // Higher number means faster movement
real Spart_SpiritDuration = 15 // Duration of the Spirits if target doesn't take any damage
unit array Spart_SpiritTarget // Target of each spirit
real array Spart_SpiritAngle // Angle of each spirit in relation to its target
real array Spart_SpiritTimer // Expiration timer of each spirit
real Spart_DBS = 360 / Spart_SpiritCount // Distance between spirits
real array Spart_DmgAcum // Accumulated Damage
integer Spart_HealId = 'A000' // Id of Regen ability
integer Spart_SpiritAbilId = 'AHhb' // Id of the Ability to summon the spirits
unit array Spart_Spirits
endglobals
function SpartSpiritSetActions takes nothing returns nothing
local unit Target = GetSpellTargetUnit()
local integer looper = 0
local unit dummy
local real angle
local real x
local real y
local integer cv
loop
exitwhen looper == Spart_SpiritCount
set angle = (R2I(looper) * Spart_DBS) * bj_DEGTORAD
set x = GetUnitX(Target) + Spart_SpiritOffset * Cos(angle)
set y = GetUnitY(Target) + Spart_SpiritOffset * Sin(angle)
set dummy = CreateUnit(GetOwningPlayer(Target), Spart_SpiritId, x, y, 0)
set cv = GetUnitUserData(dummy)
set Spart_SpiritAngle[cv] = angle
set Spart_SpiritTarget[cv] = Target
set Spart_SpiritTimer[cv] = Spart_SpiritDuration
call GroupAddUnit(Spart_SpiritProtectGroup, dummy)
call SetUnitAbilityLevel(dummy, Spart_HealId, GetUnitAbilityLevel(GetTriggerUnit(), Spart_SpiritAbilId))
set looper = looper+1
endloop
set Spart_SpiritAmount[GetUnitUserData(Target)] = Spart_SpiritAmount[GetUnitUserData(Target)] + 5
call GroupAddUnit(Spart_ProtectedGroup, Target)
call EnableTrigger(gg_trg_SpartSpirit_Protect_Loop)
set Target = null
set dummy = null
endfunction
//===========================================================================
function InitTrig_SpartSpirit_Set takes nothing returns nothing
set gg_trg_SpartSpirit_Set = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_SpartSpirit_Set, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddAction( gg_trg_SpartSpirit_Set, function SpartSpiritSetActions )
endfunction
JASS:
function SpartSpirit_Protect_Loop_GroupActions takes nothing returns nothing
local unit dummy = GetEnumUnit()
local integer cv = GetUnitUserData(dummy)
local unit target = Spart_SpiritTarget[cv]
local real x
local real y
local real angle = Spart_SpiritAngle[cv] + Spart_SpiritSpeed
set Spart_SpiritAngle[cv] = angle
set x = GetUnitX(target) + Spart_SpiritOffset * Cos(angle)
set y = GetUnitY(target) + Spart_SpiritOffset * Sin(angle)
call SetUnitX(dummy, x)
call SetUnitY(dummy, y)
set Spart_SpiritTimer[cv] = Spart_SpiritTimer[cv]-0.03
if Spart_SpiritTimer[cv] <= 0 then
call GroupRemoveUnit(Spart_SpiritProtectGroup, dummy)
call KillUnit(dummy)
set Spart_SpiritTarget[cv] = null
endif
set dummy = null
set target = null
endfunction
function Trig_SpartSpirit_Protect_Loop_Actions takes nothing returns nothing
set bj_groupCountUnits = 0
call ForGroup(Spart_SpiritProtectGroup, function CountUnitsInGroupEnum)
if bj_groupCountUnits > 0 then
call ForGroup(Spart_SpiritProtectGroup, function SpartSpirit_Protect_Loop_GroupActions)
else
call DisableTrigger( GetTriggeringTrigger() )
endif
endfunction
//===========================================================================
function InitTrig_SpartSpirit_Protect_Loop takes nothing returns nothing
set gg_trg_SpartSpirit_Protect_Loop = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_SpartSpirit_Protect_Loop, 0.03 )
call TriggerAddAction( gg_trg_SpartSpirit_Protect_Loop, function Trig_SpartSpirit_Protect_Loop_Actions )
endfunction
JASS:
function Trig_Untitled_Trigger_001_Conditions takes nothing returns boolean
return IsUnitInGroup(udg_GDD_DamagedUnit, Spart_ProtectedGroup) == true
endfunction
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
local integer cv = GetUnitUserData(udg_GDD_DamagedUnit)
set Spart_DmgAcum[cv] = Spart_DmgAcum[cv] + udg_GDD_Damage
call BJDebugMsg(R2S(Spart_DmgAcum[cv]))
if Spart_DmgAcum[cv] >= 300
set Spart_DmgAcum[cv] = 0
endif
endfunction
//===========================================================================
function InitTrig_SpartSpirit_Damage_Block takes nothing returns nothing
set gg_trg_SpartSpirit_Damage_Block = CreateTrigger( )
call TriggerRegisterVariableEvent( gg_trg_SpartSpirit_Damage_Block, "udg_GDD_Event", NOT_EQUAL, 0 )
//call TriggerAddCondition( gg_trg_SpartSpirit_Damage_Block, Condition( function Trig_Untitled_Trigger_001_Conditions ) )
call TriggerAddAction( gg_trg_SpartSpirit_Damage_Block, function Trig_Untitled_Trigger_001_Actions )
endfunction
Some values are messed up because I'm just testing, but I just got tired
Attachments
Last edited: