Skip to content

Commit

Permalink
Add outputs for animatronic location point
Browse files Browse the repository at this point in the history
  • Loading branch information
VickyFrenzy committed Jan 12, 2025
1 parent 1302be2 commit 9a9365a
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
4 changes: 3 additions & 1 deletion gamemodes/fnafgm/entities/entities/fnafgm_animatronic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
19 changes: 17 additions & 2 deletions gamemodes/fnafgm/entities/entities/fnafgm_animatronic_point.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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))
Expand Down
4 changes: 3 additions & 1 deletion gamemodes/fnafgm/entities/entities/fnafgm_camera.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions gamemodes/fnafgm/fnafgm.fgd
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 4 additions & 1 deletion gamemodes/fnafgm/gamemode/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 9a9365a

Please sign in to comment.