function MS_Damage takes nothing returns nothing
local timer t = GetExpiredTimer()
local real damage = LoadReal(udg_Table, GetHandleId(t), StringHash("Damage"))
local unit target = LoadUnitHandle(udg_Table, GetHandleId(t), StringHash("Target"))
local unit dummy = LoadUnitHandle(udg_Table, GetHandleId(t), StringHash("Dummy"))
local integer int = LoadInteger(udg_Table, GetHandleId(t), StringHash("AttackType"))
call UnitDamageTargetBJ( dummy, target, damage, ConvertAttackType(int), DAMAGE_TYPE_NORMAL )
call FlushChildHashtable(udg_Table, GetHandleId(t))
call DestroyTimer(t)
set t = null
set target = null
set dummy = null
endfunction
function MS_Values takes real tim, real dam, unit targ, unit dum, integer att returns nothing
local timer t = CreateTimer()
call SaveReal(udg_Table, GetHandleId(t), StringHash("Damage"), dam)
call SaveUnitHandle(udg_Table, GetHandleId(t), StringHash("Target"), targ)
call SaveUnitHandle(udg_Table, GetHandleId(t), StringHash("Dummy"), dum)
call SaveInteger(udg_Table, GetHandleId(t), StringHash("AttackType"), att)
call TimerStart(t, tim , false, function MS_Damage)
set t = null
endfunction
function DamageBlock takes nothing returns nothing
local timer t = GetExpiredTimer()
local real health = LoadReal(udg_Table, GetHandleId(t), StringHash("Health"))
local unit u = LoadUnitHandle(udg_Table, GetHandleId(t), StringHash("Unit"))
call UnitRemoveAbilityBJ( 'A02P', u )
call SetUnitLifeBJ( u, health )
call FlushChildHashtable(udg_Table, GetHandleId(t))
call DestroyTimer(t)
set t = null
set u = null
endfunction
function DB_Timer takes unit u, real l returns nothing
local timer t = CreateTimer()
call SaveUnitHandle(udg_Table, GetHandleId(t), StringHash("Unit"), u)
call SaveReal(udg_Table, GetHandleId(t), StringHash("Health"), l)
call TimerStart(t, 0.00, false, function DamageBlock)
set t = null
set u = null
endfunction
function ImmunityPart takes unit u, unit d, location ul, location tl, real dam, integer att returns nothing
local integer a
local real r
if ( GetUnitAbilityLevelSwapped('Amim', u ) > 0 ) then
call UnitRemoveAbilityBJ( 'Amim', u )
set a = 'Amim'
else
if ( GetUnitAbilityLevelSwapped('ACm2', u ) > 0 ) then
call UnitRemoveAbilityBJ( 'ACm2', u )
set a = 'ACm2'
else
if ( GetUnitAbilityLevelSwapped('ACm3', u ) > 0 ) then
call UnitRemoveAbilityBJ( 'ACm3', u )
set a = 'ACm3'
else
if ( GetUnitAbilityLevelSwapped('ACmi', u ) > 0 ) then
call UnitRemoveAbilityBJ( 'ACmi', u )
set a = 'ACmi'
else
set a = udg_null_ability
endif
endif
endif
endif
call IssueTargetOrderBJ( d, "acidbomb", u )
if ( a != udg_null_ability ) then
set r = ( DistanceBetweenPoints(ul, tl) / 900.00 )
call MS_Values(r,dam,u,d,att)
else
endif
call UnitAddAbilityBJ( a , u )
endfunction
function MS_Group_3 takes nothing returns nothing
local unit t = GetEnumUnit()
call GroupAddUnitSimple( t, udg_MultiGroup[3] )
set udg_MultishotCount = ( udg_MultishotCount + 1 )
set t = null
endfunction
function Owner_check takes nothing returns boolean
return ( IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), GetOwningPlayer(udg_GDD_DamageSource)) == true )
endfunction
function Multishot takes nothing returns nothing
local integer count
local real t_life
local unit dummy
local location para_pt
local real damage
local unit m_ut = udg_GDD_DamageSource
local location m_ut_pt = GetUnitLoc(m_ut)
local real x = GetLocationX(m_ut_pt)
local real y = GetLocationY(m_ut_pt)
local unit m_targ = udg_GDD_DamagedUnit
local location m_point = GetUnitLoc(m_targ)
local boolean bull = LoadBoolean(udg_Table, GetUnitTypeId(m_ut), StringHash("Upgradeable"))
local integer targ_am = LoadInteger(udg_Table, GetUnitTypeId(m_ut), StringHash("Targets"))
local real dist = LoadReal(udg_Table, GetUnitTypeId(m_ut), StringHash("Parabola"))
local real rang = LoadReal(udg_Table, GetUnitTypeId(m_ut), StringHash("Range"))
local integer a_type = LoadInteger(udg_Table, GetUnitTypeId(m_ut), StringHash("AttackType"))
if ( bull == true ) then
set rang = ( ( 200.00 * I2R(GetPlayerTechCountSimple('R00K', GetOwningPlayer(m_ut))) ) + rang )
endif
set para_pt = PolarProjectionBJ(m_ut_pt, dist, AngleBetweenPoints(m_ut_pt, m_point))
set t_life = GetUnitStateSwap(UNIT_STATE_LIFE, m_targ)
call CreateNUnitsAtLoc( 1, 'h00C', GetOwningPlayer(m_ut), m_ut_pt, bj_UNIT_FACING )
set dummy = GetLastCreatedUnit()
call UnitApplyTimedLifeBJ( 2.00, 'BTLF', dummy )
call UnitAddAbilityBJ( 'A00P', dummy )
call UnitAddAbilityBJ( 'A02P', m_targ )
call SetUnitLifePercentBJ( m_targ, 100 )
call UnitDamageTargetBJ( dummy , m_targ , 25000.00, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL )
set damage = ( ( 25000.00 / ( GetUnitStateSwap(UNIT_STATE_MAX_LIFE, m_targ) - GetUnitStateSwap(UNIT_STATE_LIFE, m_targ) ) ) * udg_GDD_Damage )
call SetUnitLifePercentBJ( m_targ, 100 )
call SaveReal( udg_Table, GetHandleId(dummy),StringHash("Damage"), damage )
call SaveInteger( udg_Table , GetHandleId(dummy), StringHash("AttackType"), a_type )
call DB_Timer(m_targ, t_life)
call ImmunityPart(m_targ, dummy, m_ut_pt, m_point, damage, a_type)
call RemoveLocation(m_point)
set m_targ = null
if ( IsPlayerAlly(GetOwningPlayer(m_ut), GetOwningPlayer(m_targ)) == true ) then
else
set udg_MultiGroup[0] = GetUnitsInRangeOfLocMatching(rang, m_ut_pt , Condition( function Owner_check))
call GroupRemoveUnitSimple( m_targ , udg_MultiGroup[0] )
if ( targ_am == 0 ) then
call GroupEnumUnitsInRange(udg_MultiGroup[0],x,y,rang,null)
loop
set m_targ = FirstOfGroup(udg_MultiGroup[0])
exitwhen m_targ == null
set m_point = GetUnitLoc(m_targ)
if ( DistanceBetweenPoints(para_pt, udg_MultiPt) <= ( ( 2.00 * ( dist * RSignBJ(dist) ) ) / ( 1 - CosBJ(( AngleBetweenPoints(para_pt, m_point) - AngleBetweenPoints(m_ut_pt, para_pt) )) ) ) ) then
call ImmunityPart( m_targ , dummy , m_ut_pt, m_point, damage, a_type)
endif
call GroupRemoveUnitSimple( m_targ , udg_MultiGroup[0])
call RemoveLocation(m_point)
endloop
else
set count = 1
if ( targ_am == 1 ) then
else
set m_targ = null
call RemoveLocation(m_point)
call GroupEnumUnitsInRange(udg_MultiGroup[0],x,y,rang,null)
loop
set m_targ = FirstOfGroup(udg_MultiGroup[0])
exitwhen m_targ == null
set m_point = GetUnitLoc(m_targ)
if ( DistanceBetweenPoints(para_pt, udg_MultiPt) <= ( ( 2.00 * ( dist * RSignBJ(dist) ) ) / ( 1 - CosBJ(( AngleBetweenPoints(para_pt, m_point) - AngleBetweenPoints(m_ut_pt, para_pt) )) ) ) ) then
if (( AngleBetweenPoints(udg_MultiUtPt, udg_MultiPt) - AngleBetweenPoints(udg_MultiUtPt, udg_MultiPoint) ) >= 0.00 ) then
call GroupAddUnitSimple( GetEnumUnit(), udg_MultiGroup[1] )
else
call GroupAddUnitSimple( GetEnumUnit(), udg_MultiGroup[2] )
endif
endif
call GroupRemoveUnitSimple( m_targ , udg_MultiGroup[0])
call RemoveLocation(m_point)
endloop
if ( CountUnitsInGroup(udg_MultiGroup[2]) >= CountUnitsInGroup(udg_MultiGroup[1]) ) then
call ForGroupBJ( GetRandomSubGroup(( ( udg_MultishotTargets - 1 ) / 2 ), udg_MultiGroup[1]), function MS_Group_3 )
call ForGroupBJ( GetRandomSubGroup(( udg_MultishotTargets - udg_MultishotCount ), udg_MultiGroup[2]), function MS_Group_3 )
else
call ForGroupBJ( GetRandomSubGroup(( ( udg_MultishotTargets - 1 ) / 2 ), udg_MultiGroup[2]), function MS_Group_3 )
call ForGroupBJ( GetRandomSubGroup(( udg_MultishotTargets - udg_MultishotCount ), udg_MultiGroup[1]), function MS_Group_3 )
endif
call GroupClear( udg_MultiGroup[1] )
call GroupClear( udg_MultiGroup[2] )
call GroupEnumUnitsInRange(udg_MultiGroup[3],x,y,rang,null)
loop
set m_targ = FirstOfGroup(udg_MultiGroup[3])
exitwhen m_targ == null
set m_point = GetUnitLoc(m_targ)
call ImmunityPart( m_targ , dummy , m_ut_pt, m_point, damage, a_type)
call RemoveLocation(m_point)
call GroupRemoveUnitSimple( m_targ , udg_MultiGroup[3])
endloop
endif
endif
call GroupClear( udg_MultiGroup[0] )
endif
call RemoveLocation(m_ut_pt)
call RemoveLocation(para_pt)
endfunction
function Trig_Multishot_Conditions takes nothing returns boolean
if ( not ( GetUnitAbilityLevelSwapped('A00L', udg_GDD_DamageSource) > 0 ) ) then
call Multishot()
return false
endif
return true
endfunction
//===========================================================================
function InitTrig_Multishot takes nothing returns nothing
set gg_trg_Multishot = CreateTrigger( )
call TriggerRegisterVariableEvent( gg_trg_Multishot, "udg_GDD_Event", EQUAL, 0 )
call TriggerAddCondition( gg_trg_Multishot, Condition( function Trig_Multishot_Conditions ) )
endfunction