Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Installer/Changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ WadTool:

TEN nodes:
* Added a node to unswap a previously swapped mesh.
* Added a node to check Lara's traversal mode.

Version 1.11
============
Expand Down
184 changes: 184 additions & 0 deletions TombLib/TombLib/Catalogs/TEN Node Catalogs/Lara Traversal.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
-- !Ignore
-- Helper function to test whether Lara is in a specific traversal mode based on the provided state. Used by TestLaraTraversalState.
LevelFuncs.Engine.Node.TestLaraTraversalMode = function(mode, state)
local ladderStates =
{
10, -- hang state
19, -- grabbing (pulling up)
55, -- climbing up
56, -- idle on ladder
57, -- ladder up
58, -- ladder left
59, -- ladder down
60, -- ladder right
61, -- climbing down
88, -- climb off ladder
107, -- shimmy outer left
108, -- shimmy outer right
109, -- shimmy inner left
110, -- shimmy inner right
138, -- ladder to crouch
}

local crawlingStates =
{
71, -- crouch idle
72, -- crouch roll
80, -- crawling idle
81, -- crawl forward
84, -- crawling turn left
85, -- crawling turn right
86, -- crawling backwards
105, -- crouch turn left
106, -- crouch turn right
160, -- crawl step up
161, -- crawl step down
167, -- 1 step crouch vault
168, -- 2 step crouch vault
169, -- 3 step crouch vault
171, -- crouch turn 180
172, -- crawl turn 180
}

local horizontalBarStates =
{
128, -- horizontal bar swing
129, -- horizontal bar leap
}

local monkeySwingStates =
{
75, -- monkey swing idle
76, -- monkey swing forward
77, -- monkey swing shimmy left
78, -- monkey swing shimmy right
79, -- monkey swing turn 180
82, -- monkey turn left
83, -- monkey turn right
}

local poleVaultStates =
{
99, -- pole idle
100, -- pole up
101, -- pole down
102, -- pole turn clockwise
103, -- pole turn counterclockwise
}

local ropeSwingStates =
{
90, -- rope turn clockwise
91, -- rope turn counterclockwise
111, -- rope idle
112, -- rope up
113, -- rope down
114, -- rope swing
115, -- rope unknown
}

local swimStates =
{
13, -- swimming idle
17, -- swim forward
18, -- swim inertia
35, -- dive
40, -- use switch
42, -- use key
43, -- use puzzle
44, -- underwater death
66, -- underwater roll
67, -- pickup flare
89, -- misc control (opening door, trapdoor, kick)
93, -- trapdoor floor open
104, -- using pulley
189, -- remove puzzle
198, -- ungrab pulley
}

local tightropeStates =
{
119, -- Tightrope idle
120, -- Tightrope turn 180
121, -- Tightrope walk
122, -- Tightrope unbalance left
123, -- Tightrope unbalance right
124, -- Tightrope enter
125, -- Tightrope dismount
}

local function IsStateInList(currentState, states)
for _, expectedState in ipairs(states) do
if (currentState == expectedState) then
return true
end
end

return false
end

local TRAVERSAL_MODE =
{
CLIMB = 0,
CRAWL = 1,
HORIZONTAL_BAR = 2,
MONKEY_SWING = 3,
POLE_VAULT = 4,
ROPE_SWING = 5,
SWIM = 6,
TIGHTROPE = 7,
}

local traversalModeTests =
{
[TRAVERSAL_MODE.CLIMB] = function(currentState)
return IsStateInList(currentState, ladderStates)
end,

[TRAVERSAL_MODE.CRAWL] = function(currentState)
return IsStateInList(currentState, crawlingStates)
end,

[TRAVERSAL_MODE.HORIZONTAL_BAR] = function(currentState)
return IsStateInList(currentState, horizontalBarStates)
end,

[TRAVERSAL_MODE.MONKEY_SWING] = function(currentState)
return IsStateInList(currentState, monkeySwingStates)
end,

[TRAVERSAL_MODE.POLE_VAULT] = function(currentState)
return IsStateInList(currentState, poleVaultStates)
end,

[TRAVERSAL_MODE.ROPE_SWING] = function(currentState)
return IsStateInList(currentState, ropeSwingStates)
end,

[TRAVERSAL_MODE.SWIM] = function(currentState)
return IsStateInList(currentState, swimStates)
end,

[TRAVERSAL_MODE.TIGHTROPE] = function(currentState)
return IsStateInList(currentState, tightropeStates)
end,
}

local traversalTest = traversalModeTests[mode]

if (traversalTest == nil) then
return false
end

return traversalTest(state)
end

-- !Name "If Lara traversal state is..."
-- !Section "Lara state"
-- !Conditional "True"
-- !Description "Checks Lara's current traversal state."
-- !Arguments "Enumeration, [ Climb | Crawl | Horizontal Bar | Monkey Swing | Pole Vault | Rope Swing | Swim | Tightrope ], 30, Traversal state to test."

LevelFuncs.Engine.Node.TestLaraTraversalState = function(mode)
return LevelFuncs.Engine.Node.TestLaraTraversalMode(mode, TEN.Objects.Lara:GetState())
end
2 changes: 1 addition & 1 deletion TombLib/TombLib/Catalogs/TEN Node Catalogs/Lara.lua
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,4 @@ end

LevelFuncs.Engine.Node.TestLaraTargeting = function()
return TEN.Objects.Lara:GetTarget() ~= nil
end
end
3 changes: 1 addition & 2 deletions TombLib/TombLib/Catalogs/TEN Node Catalogs/_System.lua
Original file line number Diff line number Diff line change
Expand Up @@ -207,5 +207,4 @@ LevelFuncs.Engine.Node.SetInteractionHighlightType = function(index)
[2] = TEN.Objects.InteractionType.USE,
}
return interactionIconType[index]
end

end