Code:
function Start()
Daten = {
IdWoelfe = 1,
Tag = 1,
Nacht = 0,
Wolfopfer = 2,
Gesundheit = 25,
GesundheitLeader = 35,
Umgewandelt = 1,
Faehigkeit = 0,
EffektZeit = 400,
EffektAusfuehrungen = 3,
EffektRadius = 1000,
Nachtdauer = 900,
Tagdauer = 900,
}
rolay={ nSimpleJob=0,nSimpleHiResJob=0}
StartSimpleJob("RolayStarter")
EffektZaehler = 0
zahlxy = 0
gesamt = 1
Effekt = {}
Werwoelfe = {}
AlternativName = {}
TNParameter = {}
Angst = {}
SetHostile(Daten.IdWoelfe, Daten.Wolfopfer)
end
function CreateWerwolf( _X, _Y, _Type, _PlayerMensch, _AlternativName)
assert(type(_X) == "number")
assert(type(_Y) == "number")
assert(type(_PlayerMensch) == "number")
_AlternativName = _AlternativName
_Type = _Type
gesamt = gesamt + 1
if Nacht == 1 then
CreateEntity(Daten.IdWoelfe, Entities.CU_AggressiveWolf, {X = _X, Y = _Y}, "WW"..gesamt)
else
CreateEntity(_PlayerMensch, _Type, {X = _X, Y = _Y}, "WW"..gesamt)
end
local lo = {
name = "WW"..gesamt,
etype = _Type,
pid = _PlayerMensch,
}
table.insert(Werwoelfe,lo)
AlternativName[_AlternativName] = "WW"..gesamt
end
function Tag(_Start)
_Start = _Start or 0
if _Start == 0 then
TagUndNacht.Tag()
EndJob(IDw)
EndJob(IDmw)
EndJob(IDwl)
EndJob(IDwle)
EndJob(IDwlu)
EndJob(IDwlue)
StopCountdown( IDwlea )
StopCountdown( IDwleaa )
local lo = GetBetterRandom(1, 7)
if lo == 1 then
Message("Es ist Tag")
elseif lo == 2 then
Message("Der Tag bricht an")
elseif lo == 3 then
Message("Der ertse Hahnenschrei hallt uebers Land")
elseif lo == 4 then
Message("Es wird hell")
elseif lo == 5 then
Message("Das Licht vertreibt die Finsternis")
elseif lo == 6 then
Message("Die Sonne geht auf")
elseif lo == 7 then
Message("Die Stadt erwacht zu neuem Leben")
end
else
Start()
Daten.Tag = 1
TagUndNacht.Start()
end
TNParameter.LightA = 40
TNParameter.LightC = -50
TNParameter.LightD = 136
TNParameter.LightE = 144
TNParameter.LightF = 144
TNParameter.LightG = 128
TNParameter.LightH = 104
TNParameter.LightI = 72
TNParameter.FogA = 0.0
TNParameter.FogB = 1.0
TNParameter.FogC = 38
TNParameter.FogD = 48
TNParameter.FogE = 58
TNParameter.FogF = 4000
SetupNormalWeatherGfxSet()
end
TagUndNacht = {
Start = function()
table.insert(rolay,{
soll=1,
ist=0,
zaehler=1,
actionEnd = function()
StartSimpleJob("TagNacht")
IDmw = StartSimpleJob("MenschWerwolf")
IDw = StartSimpleJob("Werwolf")
Daten.Nacht = 1
end
})
end,
Nacht = function()
table.insert(rolay,{
soll=Daten.Nachtdauer,
ist=0,
zaehler=1,
actionEnd = function()
Daten.Nacht = 0
IDwm = StartSimpleJob("WerwolfMensch")
StartSimpleJob("NachtTag")
end
})
end,
Tag = function()
table.insert(rolay,{
soll=Daten.Tagdauer,
ist=0,
zaehler=1,
actionEnd = function()
Daten.Tag = 0
StartSimpleJob("TagNacht")
IDmw = StartSimpleJob("MenschWerwolf")
IDw = StartSimpleJob("Werwolf")
Daten.Nacht = 1
end
})
end,
}
---------------------------------------Tag--------------------------------
function TagNacht()
TNParameter.LightA = TNParameter.LightA - 2
TNParameter.LightC = TNParameter.LightC + 2.5
TNParameter.LightD = TNParameter.LightD - 1.55
TNParameter.LightE = TNParameter.LightE - 1.95
TNParameter.LightF = TNParameter.LightF - 1.95
TNParameter.LightG = TNParameter.LightG - 6.4
TNParameter.LightH = TNParameter.LightH - 5.2
TNParameter.LightI = TNParameter.LightI - 3.6
TNParameter.FogC = TNParameter.FogC + 0.8
TNParameter.FogD = TNParameter.FogD + 0.3
TNParameter.FogE = TNParameter.FogE - 0.2
TNParameter.FogF = TNParameter.FogF - 100
Display.SetRenderUseGfxSets(1)
Display.GfxSetSetFogParams(1, 0.0, 1.0, 1,
math.floor ( TNParameter.FogC + 0.5 ), math.floor ( TNParameter.FogD + 0.5 ),
math.floor ( TNParameter.FogE + 0.5 ), math.floor ( TNParameter.FogF + 0.5 ), 10500)
Display.GfxSetSetLightParams(1, 0.0, 1.0, math.floor ( TNParameter.LightA + 0.5 ), -15,
math.floor ( TNParameter.LightC + 0.5 ), math.floor ( TNParameter.LightD + 0.5 ), math.floor ( TNParameter.LightE + 0.5 ),
math.floor ( TNParameter.LightF + 0.5 ), math.floor ( TNParameter.LightG + 0.5 ), math.floor ( TNParameter.LightH + 0.5 ),
math.floor ( TNParameter.LightI + 0.5 ))
if TNParameter.LightA == 0 then
Nacht()
return true
end
end
function Werwolf()
for i = 1, table.getn(Werwoelfe) do
if Werwoelfe[i] == nil then
elseif IsDead(Werwoelfe[i].name) then
table.remove(Werwoelfe,i)
else
OpferSuchen(Werwoelfe[i].name, Daten.Gesundheit)
end
end
end
function MenschWerwolf()
for i = 1, math.ceil ( table.getn(Werwoelfe) * 0.08) do
if (Daten.Umgewandelt <= table.getn(Werwoelfe)) then
ReplaceEntity(Werwoelfe[Daten.Umgewandelt].name, Entities.CU_AggressiveWolf)
ChangePlayer(Werwoelfe[Daten.Umgewandelt].name, Daten.IdWoelfe)
local pos = GetPosition(Werwoelfe[Daten.Umgewandelt].name)
Logic.CreateEffect( GGL_Effects.FXKerberosFear, pos.X, pos.Y, 1 )
Daten.Umgewandelt = Daten.Umgewandelt + 1
end
if (Daten.Umgewandelt > table.getn(Werwoelfe)) then
WLEW()
IDwlue = StartSimpleJob("WerwolfleaderUeberwachen")
Daten.Umgewandelt = 1
return true
end
end
end
function Nacht()
TNParameter.LightA = 45
TNParameter.LightC = 0
TNParameter.LightD = 105
TNParameter.LightE = 105
TNParameter.LightF = 105
TNParameter.LightG = 0
TNParameter.LightH = 0
TNParameter.LightI = 0
TNParameter.FogA = 10.0
TNParameter.FogB = 10.0
TNParameter.FogC = 54
TNParameter.FogD = 54
TNParameter.FogE = 54
TNParameter.FogF = 2000
SetupNachtGfxSet()
local lo = GetBetterRandom(1, 7)
if lo == 1 then
Message("Die Nacht bricht herein")
elseif lo == 2 then
Message("Es ist Nacht")
elseif lo == 3 then
Message("Die Nacht verschlingt das Land")
elseif lo == 4 then
Message("Der Mond leuchtet hell")
elseif lo == 5 then
Message("Finsternis bedeckt das Land")
elseif lo == 6 then
Message("Es wird dunkel")
elseif lo == 7 then
Message("Die Kreaturen der Finsternis ziehen umher")
end
--Daten.Umgewandelt = 1
EndJob(IDwm)
TagUndNacht.Nacht()
end
function WLEW()
if Daten.Faehigkeit > Daten.EffektAusfuehrungen + 10 then
Daten.Faehigkeit = 0
end
IDwle = StartSimpleJob("WerwolfleaderEffekt")
end
function WerwolfleaderUeberwachen()
if not IsDead("WerwolfLeader") then
local pos = GetPosition("WerwolfLeader")
Logic.CreateEffect( GGL_Effects.FXKerberosFear, pos.X, pos.Y, 1 )
ReplaceEntity("WerwolfLeader", Entities.CU_AggressiveWolf)
IDwl = StartSimpleJob("Werwolfleader")
return true
end
end
function Werwolfleader()
if IsDead("WerwolfLeader") then
CreateEntity(1, Entities.CU_Barbarian_Hero, {X = WerwolfLeaderPos.X, Y = WerwolfLeaderPos.Y}, "WerwolfLeader")
SetHealth( "WerwolfLeader", 0)
EndJob(IDwle)
StopCountdown( IDwlea )
IDwlu = StartSimpleJob("WerwolfleaderUeberwachen")
return true
else
WerwolfLeaderPos = GetPosition("WerwolfLeader")
OpferSuchen( "WerwolfLeader", Daten.GesundheitLeader)
end
end
function WerwolfleaderEffekt()
if Daten.Faehigkeit == Daten.EffektAusfuehrungen then
Daten.Faehigkeit = Daten.Faehigkeit + 100
IDwleaa = StartCountdown( Daten.EffektZeit, WLEW)
return true
else
posa = GetPosition("WerwolfLeader")
ress = {Logic.GetPlayerEntitiesInArea(Daten.Wolfopfer, 0, posa.X, posa.Y, 2000, 1)}
for i = 2, ress[1]+1 do
if Logic.IsWorker(ress[i]) == 0 and Logic.IsBuilding(ress[i]) == 0 then
Daten.Faehigkeit = Daten.Faehigkeit + 1
SetHealth( ress[i], math.ceil(GetHealth(ress[i]) / 2))
posb = GetPosition(ress[i])
for i = 1, 10 do
Logic.CreateEffect( GGL_Effects.FXKalaPoison, posb.X, posb.Y, 1 )
end
Linie( posa.X, posa.Y, posb.X, posb.Y, GGL_Effects.FXMaryDemoralize)
IDwleaa = StartCountdown( 4, WLEW)
return true
end
end
end
end
function Linie( _Ax, _Ay, _Bx, _By, _effekt)
assert(type(_Ax) == "number")
assert(type(_Ay) == "number")
assert(type(_Bx) == "number")
assert(type(_By) == "number")
local startX = _Bx
local startY = _By
local _effekt = _effekt
local _Cx = (_Ax - _Bx)
local _Cy = (_Ay - _By)
if (_Cx < 0) and (_Cy < 0) then
local loX = -_Cx
local loY = -_Cy
if (loX > loY) then
Anzahl = math.floor ((loX / 100) + 0.5)
else
Anzahl = math.floor ((loY / 100) + 0.5)
end
elseif (_Cx < 0) then
local loX = -_Cx
local loY = _Cy
if (loX > loY) then
Anzahl = math.floor ((loX / 100) + 0.5)
else
Anzahl = math.floor ((loY / 100) + 0.5)
end
elseif (_Cy < 0) then
local loX = _Cx
local loY = -_Cy
if (loX > loY) then
Anzahl = math.floor ((loX / 100) + 0.5)
else
Anzahl = math.floor ((loY / 100) + 0.5)
end
else
local loX = _Cx
local loY = _Cy
if (loX > loY) then
Anzahl = math.floor ((loX / 100) + 0.5)
else
Anzahl = math.floor ((loY / 100) + 0.5)
end
end
local _Cx = _Cx / Anzahl
local _Cy = _Cy / Anzahl
if (_Cx > 0) and (_Cy > 0) then
while _Bx <= _Ax do
_Ax = _Ax - _Cx
_Ay = _Ay - _Cy
Logic.CreateEffect( _effekt, _Ax, _Ay, 1 )
end
local lo = {startX = startX, startY = startY, name = "ziel"..zahlxy}
table.insert (Angst, lo)
CreateEntity(0, Entities.XD_ScriptEntity ,{X = _Ax - (20 * _Cx), Y = _Ay - (20 * _Cy)}, "ziel"..zahlxy)
StartCountdown( 15, weglaufenBeenden)
zahlxy = zahlxy + 1
elseif (_Cx > 0) and (_Cy < 0) then
local _Cy = -_Cy
while _Bx <= _Ax do
_Ax = _Ax - _Cx
_Ay = _Ay + _Cy
Logic.CreateEffect( _effekt, _Ax, _Ay, 1 )
end
local lo = {startX = startX, startY = startY, name = "ziel"..zahlxy}
table.insert (Angst, lo)
CreateEntity(0, Entities.XD_ScriptEntity ,{X = _Ax - (20 * _Cx), Y = _Ay + (20 * _Cy)}, "ziel"..zahlxy)
StartCountdown( 15, weglaufenBeenden)
zahlxy = zahlxy + 1
elseif (_Cx < 0) and (_Cy > 0) then
local _Cx = -_Cx
while _Bx >= _Ax do
_Ax = _Ax + _Cx
_Ay = _Ay - _Cy
Logic.CreateEffect( _effekt, _Ax, _Ay, 1 )
end
local lo = {startX = startX, startY = startY, name = "ziel"..zahlxy}
table.insert (Angst, lo)
CreateEntity(0, Entities.XD_ScriptEntity ,{X = _Ax + (20 * _Cx), Y = _Ay - (20 * _Cy)}, "ziel"..zahlxy)
StartCountdown( 15, weglaufenBeenden)
zahlxy = zahlxy + 1
else
local _Cx = -_Cx
local _Cy = -_Cy
while _Bx >= _Ax do
_Ax = _Ax + _Cx
_Ay = _Ay + _Cy
Logic.CreateEffect( _effekt, _Ax, _Ay, 1 )
end
local lo = {startX = startX, startY = startY, name = "ziel"..zahlxy}
table.insert (Angst, lo)
CreateEntity(0, Entities.XD_ScriptEntity ,{X = _Ax + (20 * _Cx), Y = _Ay + (20 * _Cy)}, "ziel"..zahlxy)
StartCountdown( 15, weglaufenBeenden)
zahlxy = zahlxy + 1
end
EffektRADIUS = Daten.EffektRadius
for r = 1, table.getn(Angst) - 1 do
EffektB = GetPosition(Angst[table.getn(Angst)].name)
EffektCx = startX - EffektB.X
EffektCy = startY - EffektB.Y
if (EffektCx < 0) then
EffektCx = -EffektCx
end
if (EffektCy < 0) then
EffektCy = - EffektCy
end
if (EffektCx < EffektRADIUS + 100) and (EffektCy < EffektRADIUS + 100) then
if (EffektCx - (Angst[r].radius + 100) > EffektCy - (Angst[r].radius + 100)) and (EffektCx - (Angst[r].radius + 100) < EffektRADIUS) then
EffektRADIUS = EffektCx - (Angst[r].radius + 100)
elseif (EffektCy - (Angst[r].radius + 100) > EffektCx - (Angst[r].radius + 100)) and (EffektCy - (Angst[r].radius + 100) < EffektRADIUS) then
EffektRADIUS = EffektCx - (Angst[r].radius + 100)
end
end
end
if (EffektRADIUS < 0) then
EffektRADIUS = 0
end
Angst[table.getn(Angst)].radius = EffektRADIUS
if table.getn(Angst) == 1 then
IDangst = StartSimpleJob("AngstHasen")
end
end
function weglaufenBeenden()
if table.getn(Angst) == 1 then
EndJob(AngstHasen)
end
DestroyEntity(Angst[1].name)
table.remove(Angst, 1)
end
function AngstHasen()
for i = 1, table.getn(Angst) do
local hase = {Logic.GetPlayerEntitiesInArea(Daten.Wolfopfer, 0, Angst[i].startX, Angst[i].startY, Angst[i].radius, 16)}
for j = 2, hase[1]+1 do
if Logic.IsEntityInCategory(hase[j], EntityCategories.Military ) then
Move(hase[j], Angst[i].name, 100)
end
end
end
end
-------------------------------------------Nacht-----------------------------
function WerwolfMensch()
for i = 1, math.ceil ( table.getn(Werwoelfe) * 0.06) do
if (Daten.Umgewandelt <= table.getn(Werwoelfe)) then
ReplaceEntity(Werwoelfe[Daten.Umgewandelt].name, Werwoelfe[Daten.Umgewandelt].etype)
ChangePlayer(Werwoelfe[Daten.Umgewandelt].name, Werwoelfe[Daten.Umgewandelt].pid)
local pos = GetPosition(Werwoelfe[Daten.Umgewandelt].name)
Logic.CreateEffect( GGL_Effects.FXKerberosFear, pos.X, pos.Y, 1 )
Daten.Umgewandelt = Daten.Umgewandelt + 1
elseif (Daten.Umgewandelt >= table.getn(Werwoelfe)) then
ReplaceEntity("WerwolfLeader", Entities.CU_Barbarian_Hero)
StopCountdown( IDwlea )
Daten.Umgewandelt = 1
return true
end
end
end
function NachtTag()
TNParameter.LightA = TNParameter.LightA - 3
TNParameter.LightC = TNParameter.LightC - 2.5
TNParameter.LightD = TNParameter.LightD + 1.55
TNParameter.LightE = TNParameter.LightE + 1.95
TNParameter.LightF = TNParameter.LightF + 1.95
TNParameter.LightG = TNParameter.LightG + 6.4
TNParameter.LightH = TNParameter.LightH + 5.2
TNParameter.LightI = TNParameter.LightI + 3.6
TNParameter.FogC = TNParameter.FogC - 0.8
TNParameter.FogD = TNParameter.FogD - 0.3
TNParameter.FogE = TNParameter.FogE + 0.2
TNParameter.FogF = TNParameter.FogF + 100
Display.SetRenderUseGfxSets(1)
Display.GfxSetSetFogParams(1, 10.0, 10.0, 1,
math.floor ( TNParameter.FogC + 0.5 ), math.floor ( TNParameter.FogD + 0.5 ),
math.floor ( TNParameter.FogE + 0.5 ), math.floor ( TNParameter.FogF + 0.5 ), 10500)
Display.GfxSetSetLightParams(1, 0.0, 1.0, 30, math.floor ( TNParameter.LightA + 0.5 ),
math.floor ( TNParameter.LightC + 0.5 ), math.floor ( TNParameter.LightD + 0.5 ), math.floor ( TNParameter.LightE + 0.5 ),
math.floor ( TNParameter.LightF + 0.5 ), math.floor ( TNParameter.LightG + 0.5 ), math.floor ( TNParameter.LightH + 0.5 ),
math.floor ( TNParameter.LightI + 0.5 ))
if TNParameter.LightA == -15 then
Tag()
return true
end
end
function OpferSuchen( _Jaeger, _Gesundheit)
assert(type(_Jaeger) == "string")
assert(type(_Gesundheit) == "number")
local pos = GetPosition( _Jaeger )
local pof = {Logic.GetPlayerEntitiesInArea(Daten.Wolfopfer, 0, pos.X, pos.Y, 500, 16)}
for j = 2, pof[1]+1 do
if Logic.IsHero(pof[j]) == 0 and Logic.IsBuilding(pof[j]) == 0 and (GetHealth(pof[j]) <= _Gesundheit) then
gesamt = gesamt + 1
local lo = {
name = "WW"..gesamt,
etype = Logic.GetEntityType(GetEntityId(pof[j])),
pid = GetPlayer(pof[j]),
}
table.insert(Werwoelfe,lo)
local poso = GetPosition(pof[j])
Logic.CreateEffect( GGL_Effects.FXMaryDemoralize, poso.X, poso.Y, 1 )
CreateEntity(Daten.IdWoelfe, Entities.CU_AggressiveWolf , { X = poso.X, Y = poso.Y }, "WW"..gesamt)
DestroyEntity(pof[j])
end
end
end
function RolayStarter()
if not rolay then
rolay={ nSimpleJob=0,nSimpleHiResJob=0}
end
for i = 1, table.getn(rolay) do
if not rolay[i].aktiv then
rolay[i].aktiv = true
if rolay[i].simpleHiResJob then
rolay.nSimpleHiResJob=rolay.nSimpleHiResJob + 1
if rolay.nSimpleHiResJob == 1 then
StartSimpleHiResJob("RolayHiRes")
end
else
rolay.nSimpleJob=rolay.nSimpleJob+1
if rolay.nSimpleJob == 1 then
StartSimpleJob("Rolay")
end
end
end
end
end
function Rolay()
for i = table.getn(rolay),1,-1 do
if not rolay[i].simpleHiResJob then
if rolay[i].zaehler < 0 then
if rolay[i].sonderAction then
if rolay[i].ist <= rolay[i].sonderSoll and not rolay[i].sonderErledigt then
rolay[i].sonderErledigt=true
rolay[i].sonderAction(rolay[i].ist, rolay[i].variablen)
end
end
if rolay[i].ist <= rolay[i].soll then
rolay[i].erreicht=true
end
else
if rolay[i].sonderAction then
if rolay[i].ist >= rolay[i].sonderSoll and not rolay[i].sonderErledigt then
rolay[i].sonderErledigt=true
rolay[i].sonderAction(rolay[i].ist, rolay[i].variablen)
end
end
if rolay[i].ist >= rolay[i].soll then
rolay[i].erreicht=true
end
end
if rolay[i].erreicht then
if type(rolay[i].actionEnd) == "function" then
rolay[i].actionEnd()
end
rolay.nSimpleJob=rolay.nSimpleJob-1
if rolay.nSimpleJob == 0 then
table.remove(rolay,i)
return true
else
rolay[i].toRemove=true
end
end
if not rolay[i].toRemove then
rolay[i].ist = rolay[i].ist + rolay[i].zaehler
if type(rolay[i].action) == "function" then
rolay[i].action(rolay[i].ist, rolay[i].variablen)
end
end
end
end
for i = table.getn(rolay),1,-1 do
if rolay[i].toRemove then
table.remove(rolay,i)
end
end
end
function RolayHiRes()
for i = table.getn(rolay),1,-1 do
if rolay[i].simpleHiResJob then
if rolay[i].zaehler <0 then
if rolay[i].sonderAction then
if rolay[i].ist <= rolay[i].sonderSoll and not rolay[i].sonderErledigt then
rolay[i].sonderErledigt=true
rolay[i].sonderAction(rolay[i].ist, rolay[i].variablen)
end
end
if rolay[i].ist <= rolay[i].soll then
rolay[i].erreicht=true
end
else
if rolay[i].sonderAction then
if rolay[i].ist >= rolay[i].sonderSoll and not rolay[i].sonderErledigt then
rolay[i].sonderErledigt=true
rolay[i].sonderAction(rolay[i].ist, rolay[i].variablen)
end
end
if rolay[i].ist >= rolay[i].soll then
rolay[i].erreicht=true
end
end
if rolay[i].erreicht then
if type(rolay[i].actionEnd) == "function" then
rolay[i].actionEnd(rolay[i].ist, rolay[i].variablen)
end
rolay.nSimpleHiResJob=rolay.nSimpleHiResJob-1
if rolay.nSimpleHiResJob == 0 then
table.remove(rolay,i)
return true
else
rolay[i].toRemove=true
end
end
if not rolay[i].toRemove then
rolay[i].ist = rolay[i].ist + rolay[i]. zaehler
if type(rolay[i].action) == "function" then
rolay[i].action(rolay[i].ist, rolay[i].variablen)
end
end
end
end
for i = table.getn(rolay),1,-1 do
if rolay[i].toRemove then
table.remove(rolay,i)
end
end
end
function GetBetterRandom(_min, _max)
if not gvRandomseed then
local seed = ""
gvRandomseed = true
if XNetwork and XNetwork.Manager_DoesExist() == 1 then
local humanPlayer = XNetwork.GameInformation_GetMapMaximumNumberOfHumanPlayer()
for i = 1, humanPlayer do
if XNetwork.GameInformation_IsHumanPlayerAttachedToPlayerID( i ) == 1 then
seed = seed .. tostring(XNetwork.GameInformation_GetLogicPlayerUserName( i ))
end
end
else
seed = XGUIEng.GetSystemTime()
end
math.randomseed(seed)
end
return math.random(_min, _max)
end
function SetupNachtGfxSet()
Display.SetRenderUseGfxSets(1)
Display.GfxSetSetSkyBox(1, 0.0, 1.0, "YSkyBox07")
Display.GfxSetSetRainEffectStatus(1, 0.0, 1.0, 0)
Display.GfxSetSetSnowStatus(1, 0, 1.0, 0)
Display.GfxSetSetSnowEffectStatus(1, 0.0, 0.8, 0)
Display.GfxSetSetFogParams(1, 10.0, 10.0, 1, 54,54,54, 2000,10500)
Display.GfxSetSetLightParams(1, 0.0, 1.0, 0, -15, 30, 105,105,105, 0,0,0)
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 StartCountdown(_Limit, _Callback, _Show)
assert(type(_Limit) == "number")
assert( not _Callback or type(_Callback) == "function" )
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
function StopCountdown(_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
function CountdownTick()
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
function CountdownIsVisisble()
for i = 1, Counter.Index do
if Counter.IsValid("counter" .. i) and Counter["counter" .. i].Show then
return true
end
end
return false
end
Ich habe noch vor einige Sachen am Code zu ergänzen und würde mich auch freuen, wenn jemand der beim Testen Bugs oder ähnliches bemerkt die mir dann mitteilt
Lesezeichen