diff --git a/gamemodes/fnafgm/entities/entities/fnafgm_animatronic.lua b/gamemodes/fnafgm/entities/entities/fnafgm_animatronic.lua index 5879a63..9f775db 100644 --- a/gamemodes/fnafgm/entities/entities/fnafgm_animatronic.lua +++ b/gamemodes/fnafgm/entities/entities/fnafgm_animatronic.lua @@ -116,7 +116,9 @@ local sMCD = "maxcooldown" function ENT:KeyValue(k, v) if debugmode then print(k, v) end - if k == "AType" then + if string.Left(k, 2) == "On" then + self:StoreOutput(k, v) + elseif k == "AType" then self:SetAType(tonumber(v)) elseif k == "APos" then self:SetAPos(tonumber(v)) diff --git a/gamemodes/fnafgm/entities/entities/fnafgm_animatronic_point.lua b/gamemodes/fnafgm/entities/entities/fnafgm_animatronic_point.lua index 5ee31c6..d0ae7fb 100644 --- a/gamemodes/fnafgm/entities/entities/fnafgm_animatronic_point.lua +++ b/gamemodes/fnafgm/entities/entities/fnafgm_animatronic_point.lua @@ -81,6 +81,18 @@ function ENT:Initialize() local nApos = self:GetAPos() self:SetupAllTheData(sMap, nSelf, nApos) + + if CLIENT then return end + hook.Add("fnafgmAnimatronicMoved", tostring(self:MapCreationID()), function(nAType, nNewAPos, nOldAPos) + if not IsValid(self) then return end + if nSelf ~= nAType then return end + if nApos ~= nNewAPos then + if nApos ~= nOldAPos then return end + self:TriggerOutput("OnAnimatronicLeft") + return + end + self:TriggerOutput("OnAnimatronicEntered") + end) end function ENT:SetupDataTables() @@ -94,13 +106,16 @@ end function ENT:AcceptInput(name, activator, caller, data) if name == "MoveHere" then GAMEMODE:SetAnimatronicPos(nil, self:GetAType(), self:GetAPos()) + return true end - return true + return false end function ENT:KeyValue(k, v) if debugmode then print(k, v) end - if k == "AType" then + if string.Left(k, 2) == "On" then + self:StoreOutput(k, v) + elseif k == "AType" then self:SetAType(tonumber(v)) elseif k == "APos" then self:SetAPos(tonumber(v)) diff --git a/gamemodes/fnafgm/entities/entities/fnafgm_camera.lua b/gamemodes/fnafgm/entities/entities/fnafgm_camera.lua index 1c57e18..06bb5d1 100644 --- a/gamemodes/fnafgm/entities/entities/fnafgm_camera.lua +++ b/gamemodes/fnafgm/entities/entities/fnafgm_camera.lua @@ -65,7 +65,9 @@ end function ENT:KeyValue(k, v) if debugmode then print(k, v) end - if k == "locname" then + if string.Left(k, 2) == "On" then + self:StoreOutput(k, v) + elseif k == "locname" then self:SetLocName(v) end end diff --git a/gamemodes/fnafgm/fnafgm.fgd b/gamemodes/fnafgm/fnafgm.fgd index c594616..3fb535d 100644 --- a/gamemodes/fnafgm/fnafgm.fgd +++ b/gamemodes/fnafgm/fnafgm.fgd @@ -115,6 +115,8 @@ flexes(string) : "Flexes" : : "Flexes to apply at this location. Format like this: flex:weight|flex:weight|flex:weight" animation(string) : "Animation" : : "Name of the animation to play at this location." input MoveHere(void) : "Instantly move the animatronic to this location. Only works if the night is started and the animatronic is not on cooldown." + output OnAnimatronicEntered(void) : "Fired when the animatronic joined this location." + output OnAnimatronicLeft(void) : "Fired when the animatronic has left this location." ] @PointClass base(PlayerClass, Angles) studio("models/editor/playerstart.mdl") = fnafgm_teamanimatronics_start : "Spawn point for the animatronic team" diff --git a/gamemodes/fnafgm/gamemode/init.lua b/gamemodes/fnafgm/gamemode/init.lua index 8916442..f72f489 100644 --- a/gamemodes/fnafgm/gamemode/init.lua +++ b/gamemodes/fnafgm/gamemode/init.lua @@ -2470,6 +2470,7 @@ function GM:SetAnimatronicPos(ply, a, apos) if not GAMEMODE.Vars.startday then return end if IsValid(ply) and GAMEMODE.Vars.Animatronics[a][3] == -1 then return end if IsValid(ply) and (GAMEMODE.Vars.Animatronics[a][2] == GAMEMODE.APos[game.GetMap()].Office) then return end + local nOldAPos = ent:GetAPos() ent:SetAPos(apos or 7) if apos ~= GAMEMODE.APos[game.GetMap()].Office and apos ~= GAMEMODE.APos[game.GetMap()].Kitchen and apos ~= GAMEMODE.APos[game.GetMap()].SS then local camera = ents.FindByName("fnafgm_Cam" .. apos)[1] @@ -2540,8 +2541,10 @@ function GM:SetAnimatronicPos(ply, a, apos) if IsValid(ply) then GAMEMODE:Log(sLog .. " by " .. ply:GetName()) else - GAMEMODE:Log(sLog .. " by console/script", nil, true) + GAMEMODE:Log(sLog .. " by console/script/map", nil, true) end + + hook.Run("fnafgmAnimatronicMoved", a, apos, nOldAPos) end end