function Trig_Kontrollpunkte_IsTowerOrHero takes nothing returns boolean local unit U = GetFilterUnit() local boolean Ret = false if not IsUnitAliveBJ(U) then set U = null return false endif // multiple or: if GetUnitTypeId(U) == 'h000' then set Ret = true endif if GetUnitTypeId(U) == 'h001' then set Ret = true endif if IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) then set Ret = true endif set U = null return Ret endfunction function Trig_Kontrollpunkte_IsAlliedTowerOrHero takes nothing returns boolean if IsUnitAlly(GetFilterUnit(), GetOwningPlayer(GetEnumUnit())) then if Trig_Kontrollpunkte_IsTowerOrHero() then return true endif endif return false endfunction function Trig_Kontrollpunkte_IsEnemyTowerOrHero takes nothing returns boolean if IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetEnumUnit())) then if Trig_Kontrollpunkte_IsTowerOrHero() then return true endif endif return false endfunction function Trig_Kontrollpunkte_IsFab takes nothing returns boolean local unit U = GetFilterUnit() local boolean Ret = false if not IsUnitAliveBJ(U) then set U = null return false endif // multiple or: if (GetUnitTypeId(U) == 'h002') then set Ret = true endif if (GetUnitTypeId(U) == 'h003') then set Ret = true endif if (GetUnitTypeId(U) == 'h004') then set Ret = true endif set U = null return Ret endfunction function Trig_Kontrollpunkte_IsTeamFab1 takes nothing returns boolean if udg_Team_Of_Player[GetConvertedPlayerId(GetOwningPlayer(GetFilterUnit()))] == 1 then if Trig_Kontrollpunkte_IsFab() then return true endif endif return false endfunction function Trig_Kontrollpunkte_IsTeamFab2 takes nothing returns boolean if udg_Team_Of_Player[GetConvertedPlayerId(GetOwningPlayer(GetFilterUnit()))] == 2 then if Trig_Kontrollpunkte_IsFab() then return true endif endif return false endfunction function Trig_Kontrollpunkte_SetHealDown takes nothing returns nothing call SetUnitAbilityLevelSwapped( 'A00G', GetEnumUnit(), 2 ) endfunction function Trig_Kontrollpunkte_SetHealUp takes nothing returns nothing call SetUnitAbilityLevelSwapped( 'A00G', GetEnumUnit(), 1 ) endfunction function Trig_Kontrollpunkte_UnitSelected takes nothing returns boolean return IsUnitSelected(GetEnumUnit(), GetFilterPlayer()) endfunction function Trig_Kontrollpunkte_SelectUnit takes nothing returns nothing call SelectUnitAddForPlayer( GetEnumUnit(), GetEnumPlayer() ) endfunction function Trig_Kontrollpunkte_TeamKPCheck takes nothing returns nothing local group Team1KPs = GetUnitsOfPlayerAndTypeId(Player(10), 'h00P') local group Team2KPs = GetUnitsOfPlayerAndTypeId(Player(11), 'h00P') local group G local integer HandleThisTeam = 0 if CountUnitsInGroup(Team1KPs) == 0 then set HandleThisTeam = 1 set G = GetUnitsInRectMatching(udg_Playable_Map, Condition(function Trig_Kontrollpunkte_IsTeamFab1)) endif if CountUnitsInGroup(Team2KPs) == 0 then set HandleThisTeam = 2 set G = GetUnitsInRectMatching(udg_Playable_Map, Condition(function Trig_Kontrollpunkte_IsTeamFab2)) endif if HandleThisTeam !=0 then call ForGroupBJ( G, function Trig_Kontrollpunkte_SetHealDown ) call DestroyGroup( G ) call DisplayTimedTextToForce( udg_Players_Team[HandleThisTeam], 5,"|cfffed312Dein Team besitzt keinen Kontrollpunkt und repariert Panzer nun langsamer.|r" ) call DisplayTimedTextToForce( udg_Players_Team[3 - HandleThisTeam], 5, "|cfffed312Der Feind besitzt keinen Kontrollpunkt und repariert Panzer nun langsamer.|r" ) else if GetUnitAbilityLevelSwapped('A00G', udg_HQ[1]) == 2 then set HandleThisTeam = 1 set G = GetUnitsInRectMatching(udg_Playable_Map, Condition(function Trig_Kontrollpunkte_IsTeamFab1)) endif if GetUnitAbilityLevelSwapped('A00G', udg_HQ[2]) == 2 then set HandleThisTeam = 2 set G = GetUnitsInRectMatching(udg_Playable_Map, Condition(function Trig_Kontrollpunkte_IsTeamFab2)) endif if HandleThisTeam !=0 then call ForGroupBJ( G, function Trig_Kontrollpunkte_SetHealUp ) call DestroyGroup( G ) call DisplayTimedTextToForce( udg_Players_Team[HandleThisTeam], 5,"|cfffed312Dein Team besitzt einen Kontrollpunkt und repariert Panzer nun normal.|r" ) call DisplayTimedTextToForce( udg_Players_Team[3 - HandleThisTeam], 5,"|cfffed312Der Feind besitzt einen Kontrollpunkt und repariert Panzer nun normal.|r" ) endif endif call DestroyGroup( Team1KPs ) call DestroyGroup( Team2KPs ) set HandleThisTeam = 0 set G = null set Team1KPs = null set Team2KPs = null endfunction function Trig_Kontrollpunkte_CheckThisPoint takes nothing returns nothing local force F local unit U = GetEnumUnit() local location P = GetUnitLoc(U) local integer OwningTeam = udg_Team_Of_Player[GetConvertedPlayerId(GetOwningPlayer(U))] local group NearbyAllies local group NearbyEnemies = GetUnitsInRangeOfLocMatching(500.00, P, Condition(function Trig_Kontrollpunkte_IsEnemyTowerOrHero)) if CountUnitsInGroup(NearbyEnemies) == 0 then // Es sind keine Feinde in der Nähe, der Kontrollpunkt erholt sich vom letzten Angriff if ( GetUnitUserData(U) != 0 ) then call SetUnitUserData( U, ( GetUnitUserData(U) - 1 ) ) endif else set NearbyAllies = GetUnitsInRangeOfLocMatching(500.00, P, Condition(function Trig_Kontrollpunkte_IsAlliedTowerOrHero)) if CountUnitsInGroup(NearbyAllies) == 0 then // Es sind keine Freunde, jedoch Feinde am Kontrollpunkt. Er wird erobert. if GetUnitUserData(U) == 0 then call DisplayTimedTextToForce( udg_Players_Team[OwningTeam], 5,"|cffff0000Eine feindliche Einheit beginnt, einen Kontrollpunkt zu erobern.|r" ) call DisplayTimedTextToForce( udg_Players_Team[3 - OwningTeam], 5,"|cff00ff00Eine verbündete Einheit beginnt, einen Kontrollpunkt zu erobern.|r" ) call PingMinimapLocForForceEx( udg_Players, GetUnitLoc(U), 0.80, bj_MINIMAPPINGSTYLE_SIMPLE, 64.00, 64.00, 64.00 ) endif if GetUnitUserData(U) < 9 then call SetUnitUserData( U, ( GetUnitUserData(U) + 1 ) ) else set F = GetPlayersMatching(Condition(function Trig_Kontrollpunkte_UnitSelected)) call SetUnitOwner( U, ConvertedPlayer(13 - OwningTeam), true ) call SetUnitUserData( U, 0 ) call ForForce( F, function Trig_Kontrollpunkte_SelectUnit ) call DestroyForce( F ) set F = null call DisplayTimedTextToForce( udg_Players_Team[OwningTeam], 5,"|cffff0000Eine feindliche Einheit hat einen Kontrollpunkt erobert.|r" ) call DisplayTimedTextToForce( udg_Players_Team[3 - OwningTeam], 5,"|cff00ff00Eine verbündete Einheit hat einen Kontrollpunkt erobert.|r" ) call PingMinimapLocForForceEx( udg_Players, P, 0.80, bj_MINIMAPPINGSTYLE_SIMPLE, 64.00, 64.00, 64.00 ) call AddSpecialEffectLocBJ( P, "Abilities\\Spells\\Other\\Charm\\CharmTarget.mdl" ) call DestroyEffectBJ( GetLastCreatedEffectBJ() ) call Trig_Kontrollpunkte_TeamKPCheck() endif endif call DestroyGroup( NearbyAllies ) set NearbyAllies = null endif call RemoveLocation ( P ) call DestroyGroup( NearbyEnemies ) set NearbyEnemies = null set OwningTeam = 0 set P = null set U = null endfunction function Trig_Kontrollpunkte_Actions takes nothing returns nothing local group KPs = GetUnitsOfTypeIdAll('h00P') call ForGroupBJ( KPs, function Trig_Kontrollpunkte_CheckThisPoint ) call DestroyGroup( KPs ) endfunction //=========================================================================== function InitTrig_Kontrollpunkte takes nothing returns nothing set gg_trg_Kontrollpunkte = CreateTrigger( ) call DisableTrigger( gg_trg_Kontrollpunkte ) call TriggerRegisterTimerEventPeriodic( gg_trg_Kontrollpunkte, 1.00 ) call TriggerAddAction( gg_trg_Kontrollpunkte, function Trig_Kontrollpunkte_Actions ) endfunction
Mã: function Trig_Kontrollpunkte_IsTowerOrHero takes nothing returns boolean local unit U = GetFilterUnit() local boolean Ret = false if not IsUnitAliveBJ(U) then set U = null return false endif // multiple or: if GetUnitTypeId(U) == 'h000' then set Ret = true endif if GetUnitTypeId(U) == 'h001' then set Ret = true endif if IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) then set Ret = true endif set U = null return Ret endfunction function Trig_Kontrollpunkte_IsAlliedTowerOrHero takes nothing returns boolean if IsUnitAlly(GetFilterUnit(), GetOwningPlayer(GetEnumUnit())) then if Trig_Kontrollpunkte_IsTowerOrHero() then return true endif endif return false endfunction function Trig_Kontrollpunkte_IsEnemyTowerOrHero takes nothing returns boolean if IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetEnumUnit())) then if Trig_Kontrollpunkte_IsTowerOrHero() then return true endif endif return false endfunction function Trig_Kontrollpunkte_IsFab takes nothing returns boolean local unit U = GetFilterUnit() local boolean Ret = false if not IsUnitAliveBJ(U) then set U = null return false endif // multiple or: if (GetUnitTypeId(U) == 'h002') then set Ret = true endif if (GetUnitTypeId(U) == 'h003') then set Ret = true endif if (GetUnitTypeId(U) == 'h004') then set Ret = true endif set U = null return Ret endfunction function Trig_Kontrollpunkte_IsTeamFab1 takes nothing returns boolean if udg_Team_Of_Player[GetConvertedPlayerId(GetOwningPlayer(GetFilterUnit ()))] == 1 then if Trig_Kontrollpunkte_IsFab() then return true endif endif return false endfunction function Trig_Kontrollpunkte_IsTeamFab2 takes nothing returns boolean if udg_Team_Of_Player[GetConvertedPlayerId(GetOwningPlayer(GetFilterUnit ()))] == 2 then if Trig_Kontrollpunkte_IsFab() then return true endif endif return false endfunction function Trig_Kontrollpunkte_SetHealDown takes nothing returns nothing call SetUnitAbilityLevelSwapped( 'A00G', GetEnumUnit(), 2 ) endfunction function Trig_Kontrollpunkte_SetHealUp takes nothing returns nothing call SetUnitAbilityLevelSwapped( 'A00G', GetEnumUnit(), 1 ) endfunction function Trig_Kontrollpunkte_UnitSelected takes nothing returns boolean return IsUnitSelected(GetEnumUnit(), GetFilterPlayer()) endfunction function Trig_Kontrollpunkte_SelectUnit takes nothing returns nothing call SelectUnitAddForPlayer( GetEnumUnit(), GetEnumPlayer() ) endfunction function Trig_Kontrollpunkte_TeamKPCheck takes nothing returns nothing local group Team1KPs = GetUnitsOfPlayerAndTypeId(Player(10), 'h00P') local group Team2KPs = GetUnitsOfPlayerAndTypeId(Player(11), 'h00P') local group G local integer HandleThisTeam = 0 if CountUnitsInGroup(Team1KPs) == 0 then set HandleThisTeam = 1 set G = GetUnitsInRectMatching(udg_Playable_Map, Condition(function Trig_Kontrollpunkte_IsTeamFab1)) endif if CountUnitsInGroup(Team2KPs) == 0 then set HandleThisTeam = 2 set G = GetUnitsInRectMatching(udg_Playable_Map, Condition(function Trig_Kontrollpunkte_IsTeamFab2)) endif if HandleThisTeam !=0 then call ForGroupBJ( G, function Trig_Kontrollpunkte_SetHealDown ) call DestroyGroup( G ) call DisplayTimedTextToForce( udg_Players_Team[HandleThisTeam], 5,"|cfffed312Dein Team besitzt keinen Kontrollpunkt und repariert Panzer nun langsamer.|r" ) call DisplayTimedTextToForce( udg_Players_Team[3 - HandleThisTeam], 5, "|cfffed312Der Feind besitzt keinen Kontrollpunkt und repariert Panzer nun langsamer.|r" ) else if GetUnitAbilityLevelSwapped('A00G', udg_HQ[1]) == 2 then set HandleThisTeam = 1 set G = GetUnitsInRectMatching(udg_Playable_Map, Condition(function Trig_Kontrollpunkte_IsTeamFab1)) endif if GetUnitAbilityLevelSwapped('A00G', udg_HQ[2]) == 2 then set HandleThisTeam = 2 set G = GetUnitsInRectMatching(udg_Playable_Map, Condition(function Trig_Kontrollpunkte_IsTeamFab2)) endif if HandleThisTeam !=0 then call ForGroupBJ( G, function Trig_Kontrollpunkte_SetHealUp ) call DestroyGroup( G ) call DisplayTimedTextToForce( udg_Players_Team[HandleThisTeam], 5,"|cfffed312Dein Team besitzt einen Kontrollpunkt und repariert Panzer nun normal.|r" ) call DisplayTimedTextToForce( udg_Players_Team[3 - HandleThisTeam], 5,"|cfffed312Der Feind besitzt einen Kontrollpunkt und repariert Panzer nun normal.|r" ) endif endif call DestroyGroup( Team1KPs ) call DestroyGroup( Team2KPs ) set HandleThisTeam = 0 set G = null set Team1KPs = null set Team2KPs = null endfunction function Trig_Kontrollpunkte_CheckThisPoint takes nothing returns nothing local force F local unit U = GetEnumUnit() local location P = GetUnitLoc(U) local integer OwningTeam = udg_Team_Of_Player[GetConvertedPlayerId(GetOwningPlayer(U))] local group NearbyAllies local group NearbyEnemies = GetUnitsInRangeOfLocMatching(500.00, P, Condition(function Trig_Kontrollpunkte_IsEnemyTowerOrHero)) if CountUnitsInGroup(NearbyEnemies) == 0 then // Es sind keine Feinde in der Nähe, der Kontrollpunkt erholt sich vom letzten Angriff if ( GetUnitUserData(U) != 0 ) then call SetUnitUserData( U, ( GetUnitUserData(U) - 1 ) ) endif else set NearbyAllies = GetUnitsInRangeOfLocMatching(500.00, P, Condition(function Trig_Kontrollpunkte_IsAlliedTowerOrHero)) if CountUnitsInGroup(NearbyAllies) == 0 then // Es sind keine Freunde, jedoch Feinde am Kontrollpunkt. Er wird erobert. if GetUnitUserData(U) == 0 then call DisplayTimedTextToForce( udg_Players_Team[OwningTeam], 5,"|cffff0000Eine feindliche Einheit beginnt, einen Kontrollpunkt zu erobern.|r" ) call DisplayTimedTextToForce( udg_Players_Team[3 - OwningTeam], 5,"|cff00ff00Eine verbündete Einheit beginnt, einen Kontrollpunkt zu erobern.|r" ) call PingMinimapLocForForceEx( udg_Players, GetUnitLoc(U), 0.80, bj_MINIMAPPINGSTYLE_SIMPLE, 64.00, 64.00, 64.00 ) endif if GetUnitUserData(U) < 9 then call SetUnitUserData( U, ( GetUnitUserData(U) + 1 ) ) else set F = GetPlayersMatching(Condition(function Trig_Kontrollpunkte_UnitSelected)) call SetUnitOwner( U, ConvertedPlayer(13 - OwningTeam), true ) call SetUnitUserData( U, 0 ) call ForForce( F, function Trig_Kontrollpunkte_SelectUnit ) call DestroyForce( F ) set F = null call DisplayTimedTextToForce( udg_Players_Team[OwningTeam], 5,"|cffff0000Eine feindliche Einheit hat einen Kontrollpunkt erobert.|r" ) call DisplayTimedTextToForce( udg_Players_Team[3 - OwningTeam], 5,"|cff00ff00Eine verbündete Einheit hat einen Kontrollpunkt erobert.|r" ) call PingMinimapLocForForceEx( udg_Players, P, 0.80, bj_MINIMAPPINGSTYLE_SIMPLE, 64.00, 64.00, 64.00 ) call AddSpecialEffectLocBJ( P, "Abilities\\Spells\\Other\\Charm\\CharmTarget. mdl" ) call DestroyEffectBJ( GetLastCreatedEffectBJ() ) call Trig_Kontrollpunkte_TeamKPCheck() endif endif call DestroyGroup( NearbyAllies ) set NearbyAllies = null endif call RemoveLocation ( P ) call DestroyGroup( NearbyEnemies ) set NearbyEnemies = null set OwningTeam = 0 set P = null set U = null endfunction function Trig_Kontrollpunkte_Actions takes nothing returns nothing local group KPs = GetUnitsOfTypeIdAll('h00P') call ForGroupBJ( KPs, function Trig_Kontrollpunkte_CheckThisPoint ) call DestroyGroup( KPs ) endfunction //================================================== ========================= function InitTrig_Kontrollpunkte takes nothing returns nothing set gg_trg_Kontrollpunkte = CreateTrigger( ) call DisableTrigger( gg_trg_Kontrollpunkte ) call TriggerRegisterTimerEventPeriodic( gg_trg_Kontrollpunkte, 1.00 ) call TriggerAddAction( gg_trg_Kontrollpunkte, function Trig_Kontrollpunkte_Actions ) endfunction
chuyện ngược đời...convert sang JASS nói còn nghe được..tự dưng đòi chuyển sang GUI..mệt lắm..code thì dài..mà chắc gì cái đoạn code ấy đã hay..