Skip to content

NodeGraph

Nak edited this page May 13, 2022 · 5 revisions

Note: Mimics Sources NodeGraph system and load .ain files. Any changes to the NodeGraph won't carry on to the C++ based one. Unless you replace the .ain file.

Functions Returns Description
alt textNodeGraph.GetMap() NodeGraph, [AIN_ERROR_*] Returns the nodegraph for the current map and caches it
alt textNodeGraph.LoadAin( fileName = nil ) NodeGraph, [AIN_ERROR_*] Loads the file and returns a nodegraph object. If no files given it will return the current map's nodegraph.
  • AIN_ERROR_VERSIONNUM
  • AIN_ERROR_ZONEPATCH ( This just indecates there was zone-errors in the AIN file, and they got patched )
There are 3 valid node types:
* NODE_TYPE_GROUND
* NODE_TYPE_AIR
* NODE_TYPE_CLIMB
Hull and CAP / Move Enums

Hull Enums: ( NN recreates these on the client )

* HULL_HUMAN 			= 0	--	30w, 73t		// Combine, Stalker, Zombie...
* HULL_SMALL_CENTERED 	= 1	--	40w, 40t		// Scanner
* HULL_WIDE_HUMAN		= 2	--	?				// Vortigaunt
* HULL_TINY				= 3	--	24w, 24t		// Headcrab
* HULL_WIDE_SHORT		= 4	--	?				// Bullsquid
* HULL_MEDIUM			= 5	--	36w, 65t		// Cremator
* HULL_TINY_CENTERED	= 6	--	16w, 8t			// Manhack 
* HULL_LARGE			= 7	--	80w, 100t		// Antlion Guard
* HULL_LARGE_CENTERED 	= 8	--	?				// Mortar Synth / Strider
* HULL_MEDIUM_TALL		= 9	--	36w, 100t		// Hunte

Move Enums ( NN recreates these 4 on the client )

CAP_MOVE_GROUND	= 0x01 -- walk/run
CAP_MOVE_JUMP	= 0x02 -- jump/leap
CAP_MOVE_FLY	= 0x04 -- can fly, move all around
CAP_MOVE_CLIMB	= 0x08 -- climb ladders

Note: You can combine these with bit.bor( CAP_MOVE_GROUND, CAP_MOVEJUMP, CAP_MOVE_CLIMB )

PathFind Functions

PathFinding accepts a table of options on how the path should be gennerated.

options.MaxDistance = 100000
options.BitCapability = CAP_MOVE_GROUND or CAP_MOVE_FLY, depending on NODE_TYPE
options.JumpMultiplier = 1.4
options.ClimbMultiplier = 1.2

You can make your own generator to tell how the pathfind should be made:
generator( ain_node current, ain_node neighbor, CAP_MOVE, BitCapability, Number NormalCost )

PathFind Functions Returns Description
alt textNodeGraph:CanMaybeReach( Vector start_pos, Vector end_pos, NODE_TYPE = NODE_TYPE_GROUND, HULL = HULL_HUMAN, Number MaxDistance = nil ) Boolean A cheap lookup function. Checks to see if we can reach the position using nearby nodes.
alt textNodeGraph:PathFind( Vector start_pos, Vector end_pos, NODE_TYPE = NODE_TYPE_GROUND, Table options = nil, HULL = HULL_HUMAN, Function generator = nil ) LPathFollower or boolean A* pathfinding using the NodeGraph. Will return false if unable to create a path.
alt textNodeGraph:PathFindASync( Vector start_pos, Vector end_pos, callback, NODE_TYPE = NODE_TYPE_GROUND, Table options = nil, HULL = HULL_HUMAN, generator = nil ) A* pathfinding using the NodeGraph. Returns the result in the callback. Calculates 20 paths pr tick.
NodeGraph Functions
NodeGraph Functions Returns Description
alt textNodeGraph:GetVersion() Number Returns the AIN version. Should be 37.
alt textNodeGraph:GetMapVersion() Number Returns the AIN map-version.
alt textNodeGraph:GetNode(Number id ) ain_node Returns the given ain_node at said ID.
alt textNodeGraph:GetAllNodes() Table Returns all nodes on the NodeGraph with the ID as keys.
alt textNodeGraph:FindNode( Vector position, NODE_TYPE = NODE_TYPE_GROUND, Zone = nil, HULL = HULL_HUMAN ) ain_node Returns the nearestnode with the given parameters.
alt textNodeGraph:FindHintNode( Vector position, NODE_TYPE = NODE_TYPE_GROUND, HintType, HintGroup, Zone = nil, HULL = HULL_HUMAN )ain_node Returns the nearest node with said HintType and parameters.
alt textNodeGraph:FindNodeWithHull( Vector position, NODE_TYPE = NODE_TYPE_GROUND, Zone = nil, HULL = HULL_HUMAN ) ain_node Returns thenearest node with a connection matching the hull.
alt textNodeGraph:GenerateZones() Overrides and generates all the zones in the nodegraph. This can fix zone-errors.
alt textNodeGraph:SaveAin( String fileName ) Saves the nodegraph to a file.
alt textNodeGraph:SaveToBuf() ByteBuffer Returns the nodegraph as a bytebuffer.

Nodes

Notes are points placed on the NodeGraph that NPC's can pathfind to.

Node Functions

Note: HintData are stored as a table on the node with the key "hint": ain_node.hint

Node Functions Returns Description
alt textain_node:IsNodeType( NODE_TYPE ) Boolean Returns true if the node_type match.
alt textain_node:GetAllGridNodes() Table A function returning all nodes connected to this one. A bit costly.
alt textain_node:GetConnections() Table Returns all the connections from this node.
alt textain_node:GetConnectionsByHull( Hull ) Table Returns all the connections from this node, with said hull that aren't invalid.
alt textain_node:GetID() Number Returns the node ID
alt textain_node:GetInfo() Number Returns the node info.
alt textain_node:GetMoveType() Number Returns the move-type to this node.
alt textain_node:GetPos( Hull ) Vector Returns the node position
alt textain_node:GetType() NODE_TYPE Returns the node type
alt textain_node:GetYaw() Number Returns the node YAW
alt textain_node:GetZone() Number Returns the node zone. It should match any notes connected to this one.
alt textain_node:IsValid() Boolean Returns true if the node is valid.
alt textain_node:RemoveFromClosedList() Removes the node from the closed list.
Link Functions ( Not implimented functions yet. They're stored on `NodeGraph._links` )
Links Returns Description
alt text[ain_link]:GetDestID() [Nuber] Returns the node IF of the distination node.
alt text[ain_link]:GetID() Number Returns the link ID
alt text[ain_link]:GetMove(, HULL ) Number Returns the move bitflags
alt text[ain_link]:GetSrcID() Number Returns the node ID of the source node.
alt text[ain_link]:HasMoveFlag(, HULL, flag ) Boolean Checks to see if it has any of said move flag
A* Functions
A* Node Functions Returns Description
alt textain_node:IsClosed() Boolean Returns true if the node is within the closed list.
alt textain_node:IsOpen() Boolean Returns true if the node is on the open list
alt textain_node:IsOpenListEmpty() Boolean Retursn true if the open list is empty
alt textain_node:SetMoveType( CAP_MOVE ) Sets the move-type to this node.
alt textain_node:SetTotalCost( Number cost ) Sets the total cost
alt textain_node:UpdateOnOpenList() Updates the open list
alt textain_node:AddToClosedList() Adds the node to the closed list.
alt textain_node:AddToOpenList() Adds the node to the open list
alt textain_node:GetCostSoFar() Number Returns the cost so far
alt textain_node:GetTotalCost() Number Returns the total cost
alt textain_node:SetCostSoFar( Number cost ) Sets the cost for pathfinding.
alt textain_node:PopOpenList() Pops the open list and returns the kiwest total cost node.

Nik Naks Wiki


Features:

Clone this wiki locally