Я сделал вот так но так вычитание происходит до нанесения урона
function Trig_Attack_in_Destroyer_Armor_Actions takes nothing returns nothing
//local unit u = GetTriggerUnit()
//Если состояние 100-91
if ( ( GetUnitAbilityLevel(GetTriggerUnit(), 'A01J') <= 101 ) ) and ( GetUnitAbilityLevel(GetTriggerUnit(), 'A01J') > 91 )
SetUnitAbilityLevel(GetTriggerUnit(), 'A01J', GetUnitAbilityLevel(GetTriggerUnit(), 'A01J') - GetRandomInt(1, 1) )
else
//Если состояние 90-71
if ( ( GetUnitAbilityLevel(GetTriggerUnit(), 'A01J') <= 91 ) ) and ( GetUnitAbilityLevel(GetTriggerUnit(), 'A01J') > 71 )
SetUnitAbilityLevel(GetTriggerUnit(), 'A01J', GetUnitAbilityLevel(GetTriggerUnit(), 'A01J') - GetRandomInt(2, 2) )
else
//Если состояние 70-41
if ( ( GetUnitAbilityLevel(GetTriggerUnit(), 'A01J') <= 71 ) ) and ( GetUnitAbilityLevel(GetTriggerUnit(), 'A01J') > 41 )
SetUnitAbilityLevel(GetTriggerUnit(), 'A01J', GetUnitAbilityLevel(GetTriggerUnit(), 'A01J') - GetRandomInt(3, 3) )
else
//Если состояние 40-1
if ( ( GetUnitAbilityLevel(GetTriggerUnit(), 'A01J') <= 41 ) ) and ( GetUnitAbilityLevel(GetTriggerUnit(), 'A01J') > 1 )
SetUnitAbilityLevel(GetTriggerUnit(), 'A01J', GetUnitAbilityLevel(GetTriggerUnit(), 'A01J') - GetRandomInt(4, 4) )
else
endif
endif
endif
endif
endfunction
//===========================================================================
function InitTrig_Attack_in_Destroyer_Armor takes nothing returns nothing
set gg_trg_Attack_in_Destroyer_Armor = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Attack_in_Destroyer_Armor, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddAction( gg_trg_Attack_in_Destroyer_Armor, function Trig_Attack_in_Destroyer_Armor_Actions )
endfunction
А тут нашёл наработку вычитание происходит точно после получения урона. Но почему вычет способности множится на 2 ?
function KDDS_Display takes nothing returns nothing
local unit u = GetTriggerUnit()
local real d = GetEventDamage()
local integer p = GetPlayerId(GetOwningPlayer(GetEventDamageSource()))
local unit u2 = GetEventDamageSource()
//Если состояние 100-91
if ( ( GetUnitAbilityLevel(u, 'A01J') <= 101 ) ) and ( GetUnitAbilityLevel(u, 'A01J') > 91 )
SetUnitAbilityLevel(u, 'A01J', GetUnitAbilityLevel(u, 'A01J') - GetRandomInt(1, 1) )
else
//Если состояние 90-71
if ( ( GetUnitAbilityLevel(u, 'A01J') <= 91 ) ) and ( GetUnitAbilityLevel(u, 'A01J') > 71 )
SetUnitAbilityLevel(u, 'A01J', GetUnitAbilityLevel(u, 'A01J') - GetRandomInt(2, 2) )
else
//Если состояние 70-41
if ( ( GetUnitAbilityLevel(u, 'A01J') <= 71 ) ) and ( GetUnitAbilityLevel(u, 'A01J') > 41 )
SetUnitAbilityLevel(u, 'A01J', GetUnitAbilityLevel(u, 'A01J') - GetRandomInt(3, 3) )
else
//Если состояние 40-1
if ( ( GetUnitAbilityLevel(u, 'A01J') <= 41 ) ) and ( GetUnitAbilityLevel(u, 'A01J') > 1 )
SetUnitAbilityLevel(u, 'A01J', GetUnitAbilityLevel(u, 'A01J') - GetRandomInt(4, 4) )
else
endif
endif
endif
endif
set u = null
set u2 = null
set d = 0
set p = 0
endfunction
function KDDS_RegisterUnit takes unit u returns nothing
call TriggerRegisterUnitEvent( gg_trg_Display_Damage_System, u, EVENT_UNIT_DAMAGED )
endfunction
function KDDS_SetUp takes nothing returns nothing
local group g = CreateGroup()
local unit u
local unit u2
set g = GetUnitsInRectAll(GetPlayableMapRect())
loop
set u = FirstOfGroup(g)
set u2 = FirstOfGroup(g)
exitwhen u == null
call KDDS_RegisterUnit(u)
call KDDS_RegisterUnit(u2)
call GroupRemoveUnit(g, u)
call GroupRemoveUnit(g, u2)
endloop
set g = null
endfunction
//===========================================================================
function InitTrig_Display_Damage_System takes nothing returns nothing
set gg_trg_Display_Damage_System = CreateTrigger( )
call TriggerAddAction( gg_trg_Display_Damage_System, function KDDS_Display )
call KDDS_SetUp()
endfunction
Accepted answer
loop
set u = FirstOfGroup(g)
set u2 = FirstOfGroup(g)
set u = FirstOfGroup(g)
set u2 = FirstOfGroup(g)
exitwhen u == null
call KDDS_RegisterUnit(u)
call KDDS_RegisterUnit(u2)
call GroupRemoveUnit(g, u)
call GroupRemoveUnit(g, u2)
endloop
call KDDS_RegisterUnit(u)
call KDDS_RegisterUnit(u2)
call GroupRemoveUnit(g, u)
call GroupRemoveUnit(g, u2)
endloop
Идет дублирование, из-за чего вычет дважды
`
LOADING AD...
To leave a comment please sign in to the site.
set u = FirstOfGroup(g)
set u2 = FirstOfGroup(g)
call KDDS_RegisterUnit(u)
call KDDS_RegisterUnit(u2)
call GroupRemoveUnit(g, u)
call GroupRemoveUnit(g, u2)
endloop