globals
integer array CombatPoint
boolean array CombatFlag
endglobals
function CombatCon takes nothing returns boolean
return ((GetEventPlayerChatString() == "-st") or (GetUnitAbilityLevel(GetKillingUnit(),'A03J') > 0)) or (GetLearnedSkillBJ() == 'A03J')
endfunction
function CombatAct takes nothing returns nothing
local unit u
local player p
if GetLearnedSkillBJ() == 'A03J' then
set u = GetTriggerUnit()
set p = GetOwningPlayer(u)
set CombatFlag[GetConvertedPlayerId(p)] = true
endif
if GetEventPlayerChatString() == "-st" then
set p = GetTriggerPlayer()
if CombatFlag[GetConvertedPlayerId(p)] then
call DisplayTextToForce(GetForceOfPlayer(p),( "Combat Points: " + ( I2S(CombatPoint[GetConvertedPlayerId(p)]) + "." )))
endif
else
if (GetUnitAbilityLevel(GetKillingUnit(),'A03J') > 0) and (GetDyingUnit() == UNIT_TYPE_HERO) then
set u = GetKillingUnit()
set p = GetOwningPlayer(u)
if CombatFlag[GetConvertedPlayerId(p)] then
set CombatPoint[GetConvertedPlayerId(p)] = CombatPoint[GetConvertedPlayerId(p)] + 1
endif
endif
endif
set p = null
set u = null
endfunction
//===========================================================================
function InitTrig_Combat_Mastery takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_DEATH )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_HERO_SKILL )
set bj_forLoopAIndex = 0
set bj_forLoopAIndexEnd = 11
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
call TriggerRegisterPlayerChatEvent( t, Player(GetForLoopIndexA()), "-st", true )
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
call TriggerAddCondition(t,function CombatCon)
call TriggerAddAction( t, function CombatAct )
set t = null
endfunction