- Joined
- Jun 18, 2007
- Messages
- 214
JASS:
constant function Swing_Slash_Rawcode takes nothing returns integer
return 'A000'
endfunction
constant function Swing_Slash_DOT_Code takes nothing returns integer
return 'A001'
endfunction
constant function Swing_Slash_DOT_Buff_Code takes nothing returns integer
return 'B000'
endfunction
constant function Dummy_Unit_Code takes nothing returns integer
return 'h003'
endfunction
constant function Nova_SFX takes nothing returns string
return "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl"
endfunction
constant function Hit_SFX takes nothing returns string
return "Objects\\Spawnmodels\\Critters\\Albatross\\CritterBloodAlbatross.mdl"
endfunction
constant function Slash_Distance takes nothing returns real
return 250.0
endfunction
constant function Damage_Radius takes nothing returns real
return 90.0
endfunction
constant function Slash_Damage takes integer i returns real
return 50.0*i
endfunction
constant function Slash_Number takes nothing returns integer
return 10
endfunction
constant function Nova_Spawn_Speed takes nothing returns real
return 0.1
endfunction
//==========================================================================================================================================================================================================
//Condition trigger.
function Trig_Swing_Slash_Conditions takes nothing returns boolean
return GetSpellAbilityId() == Swing_Slash_Rawcode()
endfunction
//Filter for picking enemies in group.
function Swing_Slash_Filter takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(), bj_groupEnumOwningPlayer) and IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false and IsUnitType(GetFilterUnit(), UNIT_TYPE_MAGIC_IMMUNE) == false and (GetWidgetLife(GetFilterUnit())>0.405)
endfunction
//==========================================================================================================================================================================================================
//===========EXECUTE NOVA===============================================================================
function Slash_Nova takes nothing returns nothing
local timer novatimer = GetExpiredTimer()
local unit damager = LoadUnitHandle(udg_Hash, GetHandleId(novatimer), 1)
local unit ug = null
local unit dummy = null
local integer count = LoadInteger(udg_Hash, GetHandleId(novatimer), 6)
local integer angle = 180/Slash_Number()
local integer level = LoadInteger(udg_Hash, GetHandleId(novatimer), 7)
local real x = LoadReal(udg_Hash, GetHandleId(novatimer), 3)
local real y = LoadReal(udg_Hash, GetHandleId(novatimer), 4)
local real start = LoadReal(udg_Hash, GetHandleId(novatimer), 5)
local group g = null
local group hit = LoadGroupHandle(udg_Hash, GetHandleId(novatimer), 8)
local boolexpr b = null
local real newX
local real newY
if count < Slash_Number() then
set newX = x + Slash_Distance() * Cos((start + angle * count) * bj_DEGTORAD)
set newY = y + Slash_Distance() * Sin((start + angle * count) * bj_DEGTORAD)
call DestroyEffect(AddSpecialEffect(Nova_SFX(), newX, newY))
call SaveInteger (udg_Hash, GetHandleId(novatimer), 6, count + 1)
set g = CreateGroup()
set b = Condition(function Swing_Slash_Filter)
set bj_groupEnumOwningPlayer = GetOwningPlayer(damager)
call GroupEnumUnitsInRange(g, newX, newY, Damage_Radius(), b)
call DestroyBoolExpr(b)
loop
set ug = FirstOfGroup(g)
exitwhen ug == null
call GroupRemoveUnit(g, ug)
call DestroyEffect(AddSpecialEffect(Hit_SFX(), GetUnitX(ug), GetUnitY(ug)))
if IsUnitInGroup(ug, hit) == true then
else
call UnitDamageTarget(damager, ug, Slash_Damage(level), true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
set dummy = CreateUnit (GetOwningPlayer(damager), Dummy_Unit_Code(), GetUnitX(ug), GetUnitY(ug), 0.0)
call UnitAddAbility (dummy, Swing_Slash_DOT_Code())
call SetUnitAbilityLevel (dummy, Swing_Slash_DOT_Code(), level)
call IssueTargetOrder (dummy, "shadowstrike", ug)
call UnitApplyTimedLife (dummy, 'BTLF', 2.0)
endif
call GroupAddUnit (hit, ug)
endloop
call SaveGroupHandle (udg_Hash, GetHandleId(novatimer), 8, hit)
call DestroyGroup(g)
call DestroyGroup(hit)
set g = null
set hit = null
set b = null
set novatimer = null
set damager = null
set ug = null
else
call FlushChildHashtable(udg_Hash, GetHandleId(novatimer))
call PauseTimer(novatimer)
call DestroyTimer(novatimer)
set novatimer = null
set b = null
set g = null
set damager = null
set ug = null
endif
endfunction
//===============SETTINGS FOR 180 % NOVA==============================================================================
function Trig_Swing_Slash_Actions takes nothing returns nothing
local timer novatimer = CreateTimer()
local unit cast = GetTriggerUnit()
local integer level = GetUnitAbilityLevel(cast, Swing_Slash_Rawcode())
local real start = GetUnitFacing(cast) - 90.0
local real cX = GetUnitX(cast)
local real cY = GetUnitY(cast)
local group hit = CreateGroup()
call SaveUnitHandle (udg_Hash, GetHandleId(novatimer), 1, cast)
call SaveReal (udg_Hash, GetHandleId(novatimer), 3, cX)
call SaveReal (udg_Hash, GetHandleId(novatimer), 4, cY)
call SaveReal (udg_Hash, GetHandleId(novatimer), 5, start)
call SaveInteger (udg_Hash, GetHandleId(novatimer), 6, 1)
call SaveInteger (udg_Hash, GetHandleId(novatimer), 7, level)
call SaveGroupHandle (udg_Hash, GetHandleId(novatimer), 8, hit)
call TimerStart(novatimer, Nova_Spawn_Speed(), true, function Slash_Nova)
call DestroyGroup(hit)
set hit = null
set novatimer = null
set cast = null
endfunction
//=============INIT TRIGG===================================================================
function InitTrig_Swing_Slash takes nothing returns nothing
local trigger trig = CreateTrigger()
local integer guza
set guza = 0
loop
call TriggerRegisterPlayerUnitEvent(trig, Player(guza), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set guza = guza + 1
exitwhen guza == 16
endloop
call TriggerAddCondition(trig, Condition(function Trig_Swing_Slash_Conditions))
call TriggerAddAction(trig, function Trig_Swing_Slash_Actions)
call Preload(Nova_SFX())
call Preload(Hit_SFX())
call PreloadStart()
set udg_Hash = InitHashtable()
set trig = null
endfunction
Hello again. I'm sorry for bothering everyone with more questions. But I've been working on this spell the whole day. And I always have some problems.
Now the problem that I couldn't fix for the last 2 hours, is damage units.
This spell should create novas in front of caster in 180 %, that's working, actually everything is working, except damage. I want the novas to damage each caught unit once. If one nova dealt damage to the unit, next one shouldn't. I've tried everything, saving hit unit in a hash. Saving a group of hit units in hash, but I failed every time, they always get hit 2 or 3 times. Tried with damage radius, if I set it to 50 it's to small, if I set it to 6 they again get hit twice. So I really need someone's help again. Thank in advance.
EDIT: Damage action is in Slash_Nova function