--Script.Load( "C:\\91 Spiele\\Siedler 5 Mapping\\tower fight.lua" ) ----------------------------------------------------------------------------- -- MapName: XXX -- Author: XXX ----------------------------------------------------------------------------- -- interessante Funktionen die es zu teste gilt: -- MPGame_ATFicationCallback_ReceivedChatMessage() g_MC_StR = 1 function GameCallback_OnGameStart() -- Include global tool script functions Script.Load(Folders.MapTools.."Ai\\Support.lua") Script.Load( "Data\\Script\\MapTools\\MultiPlayer\\MultiplayerTools.lua" ) Script.Load( "Data\\Script\\MapTools\\Tools.lua" ) Script.Load( "Data\\Script\\MapTools\\WeatherSets.lua" ) IncludeGlobals("Comfort") -- Init global MP stuff MultiplayerTools.InitCameraPositionsForPlayers() MultiplayerTools.SetUpGameLogicOnMPGameConfig() if XNetwork.Manager_DoesExist() == 0 then -- Standardschleife für Multiplayersetup 8 Player for i=1,8 do MultiplayerTools.DeleteFastGameStuff(i) end local PlayerID = GUI.GetPlayerID() Logic.PlayerSetIsHumanFlag( PlayerID, 1 ) Logic.PlayerSetGameStateToPlaying( PlayerID ) end MultiplayerTools.SetUpDiplomacyOnMPGameConfig() LoadComforts() SpecialMapInitialization() Initialisierung() end function SpecialMapInitialization() local _mapname = "(8)Tower Fight" local _mapper = "Anarki" local _version = "TF 1.0" local _specialtext = "Mod by Anarki" MapVersion_Write_Comfort(_mapname, _mapper, _version, _specialtext) RessourcesInitialized = false LocalMusic.UseSet = HIGHLANDMUSIC SetupHighlandWeatherGfxSet() AddPeriodicSummer(10) Score.Player[0] = {} --um error bei ID0 zu vermeiden Score.Player[0]["buildings"] = 0 Score.Player[0]["all"] = 0 table.foreach(Technologies, function(key,value) if not string.find(key, "T_Upgrade") and not string.find(key, "T_Sights") and not string.find(key, "T_UpgradeRifle1") then for i = 1,8 do ResearchTechnology( value, i ) end end end) --ForbidTechnology(Technologies.MU_LeaderSword4, 1); for i = 1,8 do Logic.SetPlayerPaysLeaderFlag( i, 0 ); ForbidTechnology(Technologies.T_Sights, i); ForbidTechnology(Technologies.T_UpgradeRifle1, i); ForbidTechnology(Technologies.MU_Serf, i); end ReplaceEntitySetPlayerZero = function(_pId, _entity) Comfort_TrackEntityIni(_pId,_entity) for i = Track_Entity_Table[_pId][_entity].count, 1, -1 do local _pos = GetPosition ( Track_Entity_Table[_pId][_entity][i] ) local _rot = Logic.GetEntityOrientation ( Track_Entity_Table[_pId][_entity][i] ) DestroyEntity ( Track_Entity_Table[_pId][_entity][i] ) Logic.CreateEntity( _entity, _pos.X, _pos.Y, _rot, 0 ) end end ReplaceEntitySetPlayerZero(1,Entities.XD_WallStraight) Comfort_TrackEntityIni(1,Entities.XD_ScriptEntity) ReplaceEntitySetPlayerZero(1,Entities.PB_Residence1) ReplaceEntitySetPlayerZero(1,Entities.PB_Residence2) ReplaceEntitySetPlayerZero(1,Entities.PB_Residence3) Comfort_TrackEntityIni(1,Entities.CB_DarkCastle) Comfort_TrackEntityIni(5,Entities.CB_DarkCastle) -- Fahnen setzen -- Towers erfassen und Owner null setzen TowerOwner = {} for i = Track_Entity_Table[1][Entities.XD_ScriptEntity].count, 1, -1 do TowerOwner[i] = {} TowerOwner[i].Owner = 0 TowerOwner[i].Id = Track_Entity_Table[1][Entities.XD_ScriptEntity][i] end -- Militärgebäude unverwundbar machen for _pId = 1,8 do Comfort_TrackEntityIni(_pId,Entities.PB_Barracks2) Comfort_TrackEntityIni(_pId,Entities.PB_Archery2) for i = Track_Entity_Table[_pId][Entities.PB_Barracks2].count, 1, -1 do MakeInvulnerable( Track_Entity_Table[_pId][Entities.PB_Barracks2][i] ) end for i = Track_Entity_Table[_pId][Entities.PB_Archery2].count, 1, -1 do MakeInvulnerable( Track_Entity_Table[_pId][Entities.PB_Archery2][i] ) end end TowerInFight = {} TowerInFight.InFight = {} TowerInFight.Timer = {} TowerInFight.Hostile = {} TowerFightJobTimer5Sec = 5 TowerFightJobFirstTime = false --TowerFightJob() StartSimpleJob("TowerFightJob") --for i = 1,10 do -- Logic.CreateEntity( Entities.PU_LeaderRifle2, 3800, 30500, 0, 2 ) --end --SetHostile(1,2) herotable = { {"PU_Hero1", "Dario"}, {"PU_Hero1a", "Dario"}, {"PU_Hero1b", "Dario"}, {"PU_Hero1c", "Dario"}, {"PU_Hero2", "Pilgrim"}, {"PU_Hero3", "Salim"}, {"PU_Hero4", "Erec"}, {"PU_Hero5", "Ari"}, {"PU_Hero6", "Helias"}, {"CU_BlackKnight", "Kerberos"}, {"CU_Mary_de_Mortfichet", "MarydeMortfichet"}, {"CU_Barbarian_Hero", "Varg"}, {"CU_Evil_Queen", "Kala"}, {"PU_Hero11", "Yuki"} } for _pId = 1,8 do for i = 1,14 do Comfort_TrackEntityIni(_pId,Entities[herotable[i][1]]) end --Comfort_TrackEntityIni(1,Entities.PU_Hero6) --Comfort_TrackEntityIni(1,Entities.PU_Hero4) --Comfort_TrackEntityIni(1,Entities.CU_Barbarian_Hero) end DamageHeadQuartersTable={false,false} StartSimpleHiResJob("DamageHeadQuarters") StartSimpleJob("HeroCheckDeadJob") Trigger.RequestTrigger( Events.LOGIC_EVENT_ENTITY_HURT_ENTITY, "", "ActionOnEntityHurt", 1) Trigger.RequestTrigger( Events.LOGIC_EVENT_ENTITY_CREATED, "", "ActionOnEntityCreated", 1) Trigger.RequestTrigger( Events.LOGIC_EVENT_ENTITY_DESTROYED, "", "ActionOnEntityDestroyed", 1) Trigger.RequestTrigger( Events.LOGIC_EVENT_RESEARCH_DONE, "", "ActionOnResearchDone", 1) end function Circle_Effect_Tower(_pos, _range, _pIdEffect, _type, _nr, _getpos) local _effect = {} local _sin30 = 0.5 * _range local _cos30 = 0.866 * _range local _sin60 = 0.866 * _range local _cos60 = 0.5 * _range if _nr == 1 then _effect.X = _pos.X + _range; _effect.Y = _pos.Y; _effect.rot = 0 + 90 elseif _nr == 2 then _effect.X = _pos.X + _sin30; _effect.Y = _pos.Y + _cos30; _effect.rot = 30 + 90 elseif _nr == 3 then _effect.X = _pos.X + _sin60; _effect.Y = _pos.Y + _cos60; _effect.rot = 60 + 90 elseif _nr == 4 then _effect.X = _pos.X; _effect.Y = _pos.Y + _range; _effect.rot = 90 + 90 elseif _nr == 5 then _effect.X = _pos.X - _sin60; _effect.Y = _pos.Y + _cos60; _effect.rot = 120 + 90 elseif _nr == 6 then _effect.X = _pos.X - _sin30; _effect.Y = _pos.Y + _cos30; _effect.rot = 150 + 90 elseif _nr == 7 then _effect.X = _pos.X - _range; _effect.Y = _pos.Y; _effect.rot = 180 + 90 elseif _nr == 8 then _effect.X = _pos.X - _sin30; _effect.Y = _pos.Y - _cos30; _effect.rot = 210 + 90 elseif _nr == 9 then _effect.X = _pos.X - _sin60; _effect.Y = _pos.Y - _cos60; _effect.rot = 240 + 90 elseif _nr == 10 then _effect.X = _pos.X; _effect.Y = _pos.Y - _range ; _effect.rot = 270 + 90 elseif _nr == 11 then _effect.X = _pos.X + _sin60; _effect.Y = _pos.Y - _cos60; _effect.rot = 300 + 90 elseif _nr == 12 then _effect.X = _pos.X + _sin30; _effect.Y = _pos.Y - _cos30; _effect.rot = 330 + 90 end if not(_type == nil) then Logic.CreateEffect( _type, _effect.X, _effect.Y, _pIdEffect ); end if not(_getpos == nil) then return _effect end end function TowerFightJob() TowerFightJobTimer5Sec = TowerFightJobTimer5Sec - 1 local team1towers = 0 local team2towers = 0 if TowerFightJobTimer5Sec == 0 then TowerFightJobFirstTime = true local entities = {} TowerFightJobTimer5Sec = 1 for i = Track_Entity_Table[1][Entities.XD_ScriptEntity].count, 1, -1 do local _pos = GetPosition ( TowerOwner[i].Id ) local _foundOwner = false local _foundHostile = false local _HostilePlayer = nil if TowerOwner[i].Owner >= 5 and TowerOwner[i].Owner <= 8 then team2towers = team2towers + 1 elseif TowerOwner[i].Owner >= 1 and TowerOwner[i].Owner <= 4 then team1towers = team1towers + 1 end local unitsOwner = 0 local unitsHostile = 0 for _pId = 1, 4 do --GetPlayerEntitiesInArea local entities = {Logic.GetPlayerEntitiesInArea( _pId, 0, _pos.X, _pos.Y, 1950, 20 )}; if entities[1] > 0 then if TowerOwner[i].Owner >= 1 and TowerOwner[i].Owner <= 4 then unitsOwner = unitsOwner + entities[1] else unitsHostile = unitsHostile + entities[1] _HostilePlayer = _pId end end end for _pId = 5, 8 do --GetPlayerEntitiesInArea local entities = {Logic.GetPlayerEntitiesInArea( _pId, 0, _pos.X, _pos.Y, 1950, 20 )}; if entities[1] > 0 then if TowerOwner[i].Owner >= 5 and TowerOwner[i].Owner <= 8 then unitsOwner = unitsOwner + entities[1] else unitsHostile = unitsHostile + entities[1] _HostilePlayer = _pId end end end if (unitsOwner-2) > unitsHostile and not(TowerInFight.Timer[Track_Entity_Table[1][Entities.XD_ScriptEntity][i]] == nil) then TowerInFight.Timer[Track_Entity_Table[1][Entities.XD_ScriptEntity][i]] = TowerInFight.Timer[Track_Entity_Table[1][Entities.XD_ScriptEntity][i]] + 1 local _flagpos = Circle_Effect_Tower(_pos, 2000, nil, nil, TowerInFight.Timer[Track_Entity_Table[1][Entities.XD_ScriptEntity][i]]-1, true) DestroyEntity(Logic.GetEntityAtPosition(_flagpos.X, _flagpos.Y)) if TowerOwner[i].Owner > 0 then Logic.CreateEntity( Entities.XD_StandartePlayerColor, _flagpos.X, _flagpos.Y, _flagpos.rot, TowerOwner[i].Owner ) end elseif (unitsOwner-2) < unitsHostile and unitsHostile > 0 then if TowerInFight.Timer[Track_Entity_Table[1][Entities.XD_ScriptEntity][i]] == nil then TowerInFight.Timer[Track_Entity_Table[1][Entities.XD_ScriptEntity][i]] = 13 TowerInFight.Hostile[Track_Entity_Table[1][Entities.XD_ScriptEntity][i]] = _HostilePlayer end TowerInFight.Timer[Track_Entity_Table[1][Entities.XD_ScriptEntity][i]] = TowerInFight.Timer[Track_Entity_Table[1][Entities.XD_ScriptEntity][i]] - 1 local _flagpos = Circle_Effect_Tower(_pos, 2000, nil, nil, TowerInFight.Timer[Track_Entity_Table[1][Entities.XD_ScriptEntity][i]], true) GUI.ScriptSignal(_pos.X, _pos.Y, _HostilePlayer) DestroyEntity(Logic.GetEntityAtPosition(_flagpos.X, _flagpos.Y)) Logic.CreateEntity( Entities.XD_StandartePlayerColor, _flagpos.X, _flagpos.Y, _flagpos.rot, _HostilePlayer ) end if TowerInFight.Timer[Track_Entity_Table[1][Entities.XD_ScriptEntity][i]] == 0 then local _tower = {} if TowerOwner[i].Owner > 0 then _tower = {Logic.GetEntitiesInArea( Entities.PB_Tower2, _pos.X, _pos.Y, 200, 1)} DestroyEntity(_tower[2]) end --Logic.CreateEntity( Entities.PB_Hero10, _pos.X, _pos.Y, 0, TowerInFight.Hostile[Track_Entity_Table[1][Entities.XD_ScriptEntity][i]]) MakeInvulnerable(Logic.CreateEntity( Entities.PB_Tower2, _pos.X, _pos.Y, 0, TowerInFight.Hostile[Track_Entity_Table[1][Entities.XD_ScriptEntity][i]] )) for _nr = 1,12 do Circle_Effect_Tower(_pos, 150, TowerInFight.Hostile[Track_Entity_Table[1][Entities.XD_ScriptEntity][i]], GGL_Effects.FXDieHero, _nr,nil) end if (TowerInFight.Hostile[Track_Entity_Table[1][Entities.XD_ScriptEntity][i]] <=4) then if gv_guipId <=4 then Sound.PlayGUISound( Sounds.fanfare, 127 ) else Sound.PlayGUISound( Sounds.OnKlick_Select_kerberos, 127 ) end else if gv_guipId >4 then Sound.PlayGUISound( Sounds.fanfare, 127 ) else Sound.PlayGUISound( Sounds.OnKlick_Select_kerberos, 127 ) end end Sound.PlayGUISound( Sounds.fanfare, 127 ) Logic.CreateEffect( GGL_Effects.FXDieHero, _pos.X, _pos.Y, TowerInFight.Hostile[Track_Entity_Table[1][Entities.XD_ScriptEntity][i]] ); TowerOwner[i].Owner = TowerInFight.Hostile[Track_Entity_Table[1][Entities.XD_ScriptEntity][i]] _HostilePlayer = TowerInFight.Hostile[Track_Entity_Table[1][Entities.XD_ScriptEntity][i]] TowerInFight.Hostile[Track_Entity_Table[1][Entities.XD_ScriptEntity][i]] = nil TowerInFight.Timer[Track_Entity_Table[1][Entities.XD_ScriptEntity][i]] = nil elseif TowerInFight.Timer[Track_Entity_Table[1][Entities.XD_ScriptEntity][i]] == 13 then TowerInFight.Hostile[Track_Entity_Table[1][Entities.XD_ScriptEntity][i]] = nil TowerInFight.Timer[Track_Entity_Table[1][Entities.XD_ScriptEntity][i]] = nil end end end if TowerFightJobFirstTime then local iron = 0 local sulfur = 0 local wood = 0 for _pId = 1,4 do iron = 99999 - Logic.GetPlayersGlobalResource( _pId, ResourceType.IronRaw ) sulfur = 99999 - Logic.GetPlayersGlobalResource( _pId, ResourceType.SulfurRaw ) wood = 99999 - Logic.GetPlayersGlobalResource( _pId, ResourceType.WoodRaw ) Tools.GiveResouces(_pId, 40 + 2 * team1towers , 0, wood, 0, iron, sulfur) end for _pId = 5,8 do iron = 99999 - Logic.GetPlayersGlobalResource( _pId, ResourceType.IronRaw ) sulfur = 99999 - Logic.GetPlayersGlobalResource( _pId, ResourceType.SulfurRaw ) wood = 99999 - Logic.GetPlayersGlobalResource( _pId, ResourceType.WoodRaw ) Tools.GiveResouces(_pId, 40 + 2 * team2towers, 0, wood, 0, iron, sulfur) end if team1towers > 0 or team2towers > 0 then local _text = "@color:255,128,128 @cr Towers: @cr @color:0,255,0 @cr Team1: "..team1towers.." @cr @color:128,128,255 Team2: "..team2towers MapVersion_InitMapInfoButton( _text ) end else --GlobalMissionScripting.ChangeHealthOfEntity(Track_Entity_Table[1][Entities.CB_DarkCastle][1],100) end end ---- Hier die Grundeinstellungen machen function Initialisierung() Camera.ZoomSetFactorMax(2) -- Einige Mapinfos wie sie oben links erscheinen Setup_GUIHacks() end -- Aktionen bei Friedenszeitende und zur Mapinitialisierung function LoadComforts() -- Laden der benötigten Comforts Countdown_and_Peacetime() Comfort_TrackEntitysIni() Tribute_Comforts() Globale_Hilfsvariablen() end -- FOLGENDEN CODE NICHT VERAENDERN => COMFORTS function Countdown_and_Peacetime() StartCountdown = function (_Limit, _Callback, _Show) assert(type(_Limit) == "number") Counter.Index = (Counter.Index or 0) + 1 if _Show and CountdownIsVisisble() then assert(false, "StartCountdown: A countdown is already visible") end Counter["counter" .. Counter.Index] = {Limit = _Limit, TickCount = 0, Callback = _Callback, Show = _Show, Finished = false} if _Show then MapLocal_StartCountDown(_Limit) end if Counter.JobId == nil then Counter.JobId = StartSimpleJob("CountdownTick") end return Counter.Index end StopCountdown = function(_Id) if Counter.Index == nil then return end if _Id == nil then for i = 1, Counter.Index do if Counter.IsValid("counter" .. i) then if Counter["counter" .. i].Show then MapLocal_StopCountDown() end Counter["counter" .. i] = nil end end else if Counter.IsValid("counter" .. _Id) then if Counter["counter" .. _Id].Show then MapLocal_StopCountDown() end Counter["counter" .. _Id] = nil end end end CountdownTick = function() local empty = true for i = 1, Counter.Index do if Counter.IsValid("counter" .. i) then if Counter.Tick("counter" .. i) then Counter["counter" .. i].Finished = true end if Counter["counter" .. i].Finished and not IsBriefingActive() then if Counter["counter" .. i].Show then MapLocal_StopCountDown() end -- callback function if type(Counter["counter" .. i].Callback) == "function" then Counter["counter" .. i].Callback() end Counter["counter" .. i] = nil end empty = false end end if empty then Counter.JobId = nil Counter.Index = nil return true end end CountdownIsVisisble = function() for i = 1, Counter.Index do if Counter.IsValid("counter" .. i) and Counter["counter" .. i].Show then return true end end return false end end function Comfort_TrackEntitysIni() Track_Entity_Table = {} for i = 1,8 do Track_Entity_Table[i] = {} end Comfort_TrackEntityIni = function(_pId,_eType) local temp = {Logic.GetPlayerEntities(_pId, _eType,1)} local count = 0 Track_Entity_Table[_pId][_eType] = {} Track_Entity_Table[_pId][_eType].tracked = true Track_Entity_Table[_pId][_eType].count = 0 if temp[1] > 0 then local latestEntity = temp[2] for u = 1, Logic.GetNumberOfEntitiesOfTypeOfPlayer(_pId, _eType) do if latestEntity ~= 0 then table.insert(Track_Entity_Table[_pId][_eType], latestEntity) count = count + 1 end latestEntity = Logic.GetNextEntityOfPlayerOfType(latestEntity); end Track_Entity_Table[_pId][_eType].count = count end end Comfort_TrackEntity_Created = function(_eId) local _pId = GetPlayer(_eId) local _eType = Logic.GetEntityType(_eId) if Comfort_TrackEntity_IsTracked(_pId,_eType) then if Track_Entity_Table[_pId][_eType].tracked then table.insert(Track_Entity_Table[_pId][_eType], _eId) Track_Entity_Table[_pId][_eType].count = Track_Entity_Table[_pId][_eType].count + 1 end end end Comfort_TrackEntity_Destroyed = function(_eId) local _pId = GetPlayer(_eId) local _eType = Logic.GetEntityType(_eId) if Comfort_TrackEntity_IsTracked(_pId,_eType) then for i = 1, Track_Entity_Table[_pId][_eType].count do if _eId == Track_Entity_Table[_pId][_eType][i] then table.remove(Track_Entity_Table[_pId][_eType], i) break end end end end Comfort_TrackEntity_IsTracked = function(_pId, _eType, _TypeOrId) if _TypeOrId == false then _eType = Logic.GetEntityType(_eTypeOrId) end if type(Track_Entity_Table[_pId]) == "table" then if type(Track_Entity_Table[_pId][_eType]) == "table" then else return false end else return false end return Track_Entity_Table[_pId][_eType].tracked end Comfort_TrackEntity_RemoveTracking = function(_pId, _eType) Track_Entity_Table[_pId][_eType] = {} Track_Entity_Table[_pId][_eType].tracked = false Track_Entity_Table[_pId][_eType].count = -1 end end function Tribute_Comforts() AddTribute = function( _tribute ) assert( type( _tribute ) == "table", "Tribut muß ein Table sein" ); assert( type( _tribute.text ) == "string", "Tribut.text muß ein String sein" ); assert( type( _tribute.cost ) == "table", "Tribut.cost muß ein Table sein" ); assert( type( _tribute.pId ) == "number", "Tribut.pId muß eine Nummer sein" ); assert( not _tribute.Tribute , "Tribut.Tribute darf nicht vorbelegt sein"); uniqueTributeCounter = uniqueTributeCounter or 1; _tribute.Tribute = uniqueTributeCounter; uniqueTributeCounter = uniqueTributeCounter + 1; local tResCost = {}; for k, v in pairs( _tribute.cost ) do assert( ResourceType[k] ); assert( type( v ) == "number" ); table.insert( tResCost, ResourceType[k] ); table.insert( tResCost, v ); end Logic.AddTribute( _tribute.pId, _tribute.Tribute, 0, 0, _tribute.text, unpack( tResCost ) ); SetupTributePaid( _tribute ); return _tribute.Tribute; end CreateATribute = function(_pId, _text, _cost, _callback) local tribute = {}; tribute.pId = _pId; tribute.text = _text; tribute.cost = _cost; tribute.Callback = _callback; return tribute end GameCallback_FulfillTribute = function() return 1 end end function Mission_InitLocalResources() if not(RessourcesInitialized) then RessourcesInitialized = true for i=1,8,1 do Tools.GiveResouces(i, 10000 , 99999, 99999, 99999, 99999, 99999) end end end function MapVersion_InitMapInfoButton( _text) if type(_text) == "string" then XGUIEng.SetText( "TopMainMenuTextButton", "@color:0,0,0,0: ....... @color:255,255,255 Menü @cr @cr ".._text) else XGUIEng.SetText( "TopMainMenuTextButton", "@color:0,0,0,0: ....... @color:255,255,255 Menü @cr @cr Hier die Mapversion und sonstige Infos einfügen") end end function MapVersion_Write_Comfort(_mapname, _mapper, _version, _specialtext) local _text = "@color:255,128,128 @cr Mapname @cr ".._mapname.." by ".._mapper.." @cr @cr Version: ".._version.." @cr @cr ".._specialtext mpc_MapVersionText = _text MapVersion_InitMapInfoButton( _text ) end function Globale_Hilfsvariablen() gv_guipId = GUI.GetPlayerID() gvCol = { weiss = "@color:255,255,255", schwarz = "@color:0,0,0", rot = "@color:255,0,0", gelb = "@color:255,232,0", gruen = "@color:0,255,0", dunkelgruen = "@color:0,100,0", blau = "@color:0,0,255", lila = "@color:200,0,200", grau = "@color:150,150,150", tuerkis = "@color:0,180,180", orange = "@color:255,130,0", beige = "@color:190,190,150", hellgrau = "@color:170,170,170", dunkelgrau = "@color:120,120,120", TTgelb = "@color:255,200,0", TTrot = "@color:200,60,0", TUTgruen = "@color:90,190,20", space = "@color:0,0,0,0", } end function Setup_GUIHacks() -- Trade window verbieten --StartSimpleHiResJob() GUIAction_UpgradeSelectedBuilding = function() end GUIAction_ToggleMenu_Orig = GUIAction_ToggleMenu GUIAction_ToggleMenu = function(_window,_state) if (_window == "TradeWindow" or _window == 51) and _state == 1 then GUIAction_ToggleMenu_Orig(_window,0) end GUIAction_ToggleMenu_Orig(_window,_state) end GameCallback_GUI_SelectionChanged_OrigProtected = GameCallback_GUI_SelectionChanged; GameCallback_GUI_SelectionChanged = function() XGUIEng.ShowWidget( gvGUI_WidgetID.DestroyBuilding, 0 ); XGUIEng.ShowWidget( gvGUI_WidgetID.DestroyBuilding, 0 ); XGUIEng.ShowWidget( gvGUI_WidgetID.DestroyBuilding, 0 ); GameCallback_GUI_SelectionChanged_OrigProtected() end firstRessourceUpdate = {} GUIUpdate_ResourceAmount_Orig = GUIUpdate_ResourceAmount GUIUpdate_ResourceAmount = function(_type,_number) if _type == ResourceType.Gold then GUIUpdate_ResourceAmount_Orig(_type,_number) else --GUIUpdate_ResourceAmount_Orig(_type,_number) if firstRessourceUpdate[_type] == nil then firstRessourceUpdate[_type] = 0 end if firstRessourceUpdate[_type] < 10 then firstRessourceUpdate[_type] = firstRessourceUpdate[_type] + 1 GUIUpdate_ResourceAmount_Orig(_type,_number) elseif firstRessourceUpdate[_type] == 10 then firstRessourceUpdate[_type] = firstRessourceUpdate[_type] + 1 Mission_InitLocalResources() end end end GUIAction_BuyMilitaryUnit_Orig = GUIAction_BuyMilitaryUnit GUIAction_BuyMilitaryUnit = function(_a) if not(_a == UpgradeCategories.LeaderRifle) then local _check = false if (_a == UpgradeCategories.LeaderSword) then if Logic.IsTechnologyResearched(GUI.GetPlayerID(), Technologies.T_UpgradeSword3) == 1 then _check = true end elseif (_a == UpgradeCategories.LeaderBow) then if Logic.IsTechnologyResearched(GUI.GetPlayerID(), Technologies.T_UpgradeBow3) == 1 then _check = true end elseif (_a == UpgradeCategories.LeaderPoleArm) then if Logic.IsTechnologyResearched(GUI.GetPlayerID(), Technologies.T_UpgradeSpear3) == 1 then _check = true end end if _check then GUIAction_BuyMilitaryUnit_Orig(_a) else Message("Erforsche erst die hoechste Stufe!") end else GUIAction_BuyMilitaryUnit_Orig(_a) end end for i = 1,8 do end GUI.SellBuilding_OrigProtected = GUI.SellBuilding; GUI.SellBuilding = function() end end function ActionOnEntityHurt() local attacker = Event.GetEntityID1() --Angreifer local hurt = Event.GetEntityID2() --Angriffsziel if Track_Entity_Table[1][Entities.CB_DarkCastle][1] == hurt then MakeInvulnerable(hurt) DamageHeadQuartersTable[1] = true end if Track_Entity_Table[5][Entities.CB_DarkCastle][1] == hurt then MakeInvulnerable(hurt) DamageHeadQuartersTable[2] = true end end function DamageHeadQuarters() if DamageHeadQuartersTable[1] then MakeVulnerable(Track_Entity_Table[1][Entities.CB_DarkCastle][1]) SetHealth(Track_Entity_Table[1][Entities.CB_DarkCastle][1],GetHealth(Track_Entity_Table[1][Entities.CB_DarkCastle][1])-0.08) DamageHeadQuartersTable[1] = false if IsDead(Track_Entity_Table[1][Entities.CB_DarkCastle][1]) then for _pId = 1,4 do for i = Track_Entity_Table[_pId][Entities.PB_Barracks2].count, 1, -1 do MakeVulnerable( Track_Entity_Table[_pId][Entities.PB_Barracks2][i] ) DestroyEntity(Track_Entity_Table[_pId][Entities.PB_Barracks2][i]) end for i = Track_Entity_Table[_pId][Entities.PB_Archery2].count, 1, -1 do MakeVulnerable( Track_Entity_Table[_pId][Entities.PB_Archery2][i] ) DestroyEntity(Track_Entity_Table[_pId][Entities.PB_Archery2][i]) end end end end if DamageHeadQuartersTable[2] then MakeVulnerable(Track_Entity_Table[5][Entities.CB_DarkCastle][1]) SetHealth(Track_Entity_Table[5][Entities.CB_DarkCastle][1],GetHealth(Track_Entity_Table[5][Entities.CB_DarkCastle][1])-0.08) DamageHeadQuartersTable[2] = false if IsDead(Track_Entity_Table[5][Entities.CB_DarkCastle][1]) then for _pId = 5,8 do for i = Track_Entity_Table[_pId][Entities.PB_Barracks2].count, 1, -1 do MakeVulnerable( Track_Entity_Table[_pId][Entities.PB_Barracks2][i] ) DestroyEntity(Track_Entity_Table[_pId][Entities.PB_Barracks2][i]) end for i = Track_Entity_Table[_pId][Entities.PB_Archery2].count, 1, -1 do MakeVulnerable( Track_Entity_Table[_pId][Entities.PB_Archery2][i] ) DestroyEntity(Track_Entity_Table[_pId][Entities.PB_Archery2][i]) end end end end end function GetHealth( _entity ) local entityID = GetEntityId( _entity ); if not Tools.IsEntityAlive( entityID ) then return 0; end local MaxHealth = Logic.GetEntityMaxHealth( entityID ); local Health = Logic.GetEntityHealth( entityID ); return ( Health / MaxHealth ) * 100 end function HeroCheckDeadJob() for _pId = 1,8 do for i = 1,14 do if not(Track_Entity_Table[_pId][Entities[herotable[i][1]]][1] == nil) then if IsDead(Track_Entity_Table[_pId][Entities[herotable[i][1]]][1]) then local _posold = GetPosition(Track_Entity_Table[_pId][Entities[herotable[i][1]]][1]) local _pos = {} if _pId >= 1 and _pId <=4 then _pos.X = 3600 _pos.Y = 30600 elseif _pId >=5 and _pId<=8 then _pos.X = 56000 _pos.Y = 30600 end if not(_posold.X == _pos.X) and not(_posold.Y == _pos.Y)then SetPosition(Track_Entity_Table[_pId][Entities[herotable[i][1]]][1], _pos) SetHealth(Track_Entity_Table[_pId][Entities[herotable[i][1]]][1],0) --SetHealth(Track_Entity_Table[_pId][Entities[herotable[i][1]]][1],0) end end end end end end function ActionOnEntityCreated() local _eId = Event.GetEntityID() local _eType = Logic.GetEntityType( _eId ) local _eTypeName = Logic.GetEntityTypeName(_eType) Comfort_TrackEntity_Created(_eId) if _eType == Entities.PU_LeaderPoleArm4 then _pId = GetPlayer(_eId) Tools.GiveResouces(_pId, 200, 0, 0, 0, 0, 0) end --Message(Logic.GetEntityTypeName(_eType)) --Message(Logic.GetEntityTypeName(_eId)) end function ActionOnEntityDestroyed() local _eId = Event.GetEntityID() local _eType = Logic.GetEntityType( _eId ) Comfort_TrackEntity_Destroyed(_eId) end