Nodegraph(節點與曲線)
Nodegraph被設計者用來幫助NPC的AI規劃活動路徑,Nodegraph包括人工放置的Nodes(節點)與自動在Node間形成的Links (連結)。每個獨立的Node代表NPC實際上可以移動到的地方,Nodegraph的連結則會在編輯時自動產生,但可以用連結控制工具來調整。AI會驅使NPC順著連結從一個節點移動到另一個節點,不過不一定會精確地到達Node的位置,也不一定會走直線路徑。
- 一個節點可能會有「Hint(指示節點)」協助,像是「蹲下掩護」之類的,來幫助NPC在某些特定的位置做出反應。詳情參見Hint nodes
- Counter-Strike:Source 的 BOT 也有類似的東西,叫做 Navigation Meshes(網狀導航).
編輯
Nodegraph會在地圖載入時自動存入ain檔,除非本來就有相符的ain檔存在。(未完成)
構成要素
以下是建立Nodegraph的要素:
- 地面節點
info_node
info_node_hint
info_node_climb
- 空中節點
info_node_air
info_node_air_hint
- 連結控制
info_node_link
info_node_link_controller
建立
放置節點
map_edit
指示節點
曲線除錯
連結控制
The info_node_link is a VERY valuable entity. It "forces" a connection between two nodes.
For example, if you are building an elevator and an NPC needs to come along for the ride, it is sometimes difficult to get the info_nodes to work properly since the elevator is a brush-based entity and not a world brush. This can cause a myriad of problems and the NPC will not want to get on the elevator, even if you have a scripted_sequence on it. However, by using an info_node_link you can solve this problem.
Simply place an info_node on the ground and another right above the elevator platform. Now make an info_node_link close to those nodes. Check the properties of the info_nodes and get their NodeIDs. Now go back into the properties of the info_node_link and put the target NodeIDs in the starting and ending node sections. That's all there is to it. You will now have two connected nodes that can be enabled/disabled on command.
Usage by NPCs
When an NPC attempts to build a route, it accesses the nodegraph to follow these steps:
- 找尋距離NPC的位置最近的節點
- 找尋距離NPC想到的位置最近的節點
- 確認兩點間有連接起來,並且找尋最佳路徑
- 使用 moveprobes 來確認NPC可以抵達目標節點
- 使用 moveprobes 來確認NPC可以利用目標節點到達他想到的位置