From b2752756525cb86f9776fe37ea7dc469a03ed2fb Mon Sep 17 00:00:00 2001 From: Marco Cawthorne Date: Sun, 17 Jul 2022 09:04:16 -0700 Subject: [PATCH] GS-EntBase: Initial documentation for info_hint. --- src/gs-entbase/server.src | 2 + src/gs-entbase/server/info_hint.qc | 252 +++++++++++++++++++++++++++++ src/gs-entbase/server/info_node.qc | 4 +- src/gs-entbase/server/stubs.qc | 1 - 4 files changed, 257 insertions(+), 2 deletions(-) create mode 100644 src/gs-entbase/server/info_hint.qc diff --git a/src/gs-entbase/server.src b/src/gs-entbase/server.src index 2f21f85c..c336ade5 100644 --- a/src/gs-entbase/server.src +++ b/src/gs-entbase/server.src @@ -10,6 +10,8 @@ shared/NSVehicle.h server/info_null.qc server/info_notnull.qc server/info_intermission.qc +server/info_node.qc +server/info_hint.qc server/button_target.qc server/cycler.qc server/cycler_sprite.qc diff --git a/src/gs-entbase/server/info_hint.qc b/src/gs-entbase/server/info_hint.qc new file mode 100644 index 00000000..ba2084a5 --- /dev/null +++ b/src/gs-entbase/server/info_hint.qc @@ -0,0 +1,252 @@ +/* + * Copyright (c) 2016-2022 Vera Visions LLC. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +/*QUAKED info_hint (0 0 0) (-8 -8 -8) (8 8 8) x x x x x x x x x x x x x x x x HINTSF_ALLOWJUMPUP +Helper entity for the AI routines. Defines where to go for +sensible defense/offensive or other hints. + +-------- KEYS -------- +"targetname" : Name +"hinttype" : Hint type, this controls this hints' purpose. See notes +"hintactivity" : Associated animation activity. Once an NPC goes to this node they'll play it +"nodeFOV" : Field of view of the node. You'll probably want to set a sensible angle too. +"StartHintDisabled" : Whether or not to 'hide' the hint on start, requiring activation to work. +"Group" : Hint group definition. Some NPCs are set up to only look for their specific group. +"IgnoreFacing" : Whether or not we need to ignore the angle (?), see notes. +"MinimumState" : The minimum AI state required to use this hint, see notes. +"MaximumState" : The maximum AI state allowed to use this hint, see notes. + +-------- SPAWNFLAGS -------- +HINTSF_ALLOWJUMPUP : Allow the AI to 'jump' up this node. + +-------- NOTES -------- +The 'hinttype' field can be one of these integer values: + + HINT_NONE = 0 + HINT_WORLD_WINDOW = 2 + HINT_WORLD_WORK_POSITION = 12 + HINT_WORLD_VISUALLY_INTERESTING = 13 + HINT_WORLD_VISUALLY_INTERESTING_DONT_AIM = 14 + HINT_WORLD_INHIBIT_COMBINE_MINES = 15 + HINT_WORLD_VISUALLY_INTERESTING_STEALTH = 16 + HINT_TACTICAL_COVER_MED = 100 + HINT_TACTICAL_COVER_LOW = 101 + HINT_TACTICAL_WASTESCANNER = 102 + HINT_TACTICAL_PINCH = 103 + HINT_TACTICAL_GUARD_POINT = 104 + HINT_TACTICAL_ENEMY_DISADVANTAGED = 105 + HINT_HEALTH_KIT = 106 + HINT_ANTLION_BURROW_POINT = 400 + HINT_ANTLION_THUMPER_FLEE_POINT = 401 + HINT_HEADCRAB_BURROW_POINT = 450 + HINT_CROW_FLYTO_POINT = 700 + HINT_CROW_PERCH_POINT = 701 + HINT_FOLLOW_WAIT_POINT = 900 + HINT_JUMP_OVERRIDE = 901 + HINT_PLAYER_SQUAD_TRANSITON_POINT = 902 + HINT_NPC_EXIT_POINT = 903 + HINT_STRIDER_NODE = 904 + HINT_PLAYER_ALLY_MOVE_AWAY_DEST = 950 + HINT_PLAYER_ALLY_FEAR_DEST = 951 + HINT_WORLD_MACHINERY = 1000 + HINT_WORLD_BLINKING_LIGHT = 1001 + HINT_WORLD_HUMAN_BLOOD = 1002 + HINT_WORLD_ALIEN_BLOOD = 1003 + +The 'IgnoreFacing' field can be one of 3 values: + + IGNORE_NO = 0 + IGNORE_YES = 1 + IGNORE_DEFAULT = 2 + +The 'MinimumState' and 'MaximumState' field can be one of 3 values: + + AISTATE_IDLE = 0 + AISTATE_ALERT = 1 + AISTATE_COMBAT = 2 + +-------- TRIVIA -------- +This entity was introduced in Half-Life 2 (2004). + +Some functionality of this entity was meant to be part of `info_node` in the original Half-Life (1998). +However, that was never completed. +*/ + +/* hint types taken from https://developer.valvesoftware.com/wiki/Hint_nodes#Hint */ +typedef enum +{ + HINT_NONE = 0, + HINT_WORLD_WINDOW = 2, + HINT_WORLD_WORK_POSITION = 12, + HINT_WORLD_VISUALLY_INTERESTING = 13, + HINT_WORLD_VISUALLY_INTERESTING_DONT_AIM = 14, + HINT_WORLD_INHIBIT_COMBINE_MINES = 15, + HINT_WORLD_VISUALLY_INTERESTING_STEALTH = 16, + HINT_TACTICAL_COVER_MED = 100, + HINT_TACTICAL_COVER_LOW = 101, + HINT_TACTICAL_WASTESCANNER = 102, + HINT_TACTICAL_PINCH = 103, + HINT_TACTICAL_GUARD_POINT = 104, + HINT_TACTICAL_ENEMY_DISADVANTAGED = 105, + HINT_HEALTH_KIT = 106, + HINT_ANTLION_BURROW_POINT = 400, + HINT_ANTLION_THUMPER_FLEE_POINT = 401, + HINT_HEADCRAB_BURROW_POINT = 450, + HINT_CROW_FLYTO_POINT = 700, + HINT_CROW_PERCH_POINT = 701, + HINT_FOLLOW_WAIT_POINT = 900, + HINT_JUMP_OVERRIDE = 901, + HINT_PLAYER_SQUAD_TRANSITON_POINT = 902, + HINT_NPC_EXIT_POINT = 903, + HINT_STRIDER_NODE = 904, + HINT_PLAYER_ALLY_MOVE_AWAY_DEST = 950, + HINT_PLAYER_ALLY_FEAR_DEST = 951, + HINT_WORLD_MACHINERY = 1000, + HINT_WORLD_BLINKING_LIGHT = 1001, + HINT_WORLD_HUMAN_BLOOD = 1002, + HINT_WORLD_ALIEN_BLOOD = 1003, +} hinttype_e; + +typedef enum +{ + IGNORE_NO, + IGNORE_YES, + IGNORE_DEFAULT +} ignorefacing_e; + +/* TODO: Make this match NSMonster more */ +typedef enum +{ + AISTATE_IDLE, + AISTATE_ALERT, + AISTATE_COMBAT +} aistate_e; + +#define HINTSF_ALLOWJUMPUP 65536 + +class +info_hint:NSPointTrigger +{ + hinttype_e m_hintType; + string m_strHintActivity; + float m_flNodeFOV; + bool m_bStartDisabled; + string m_strHintGroup; + ignorefacing_e m_ignoreFacing; + aistate_e m_minState; + aistate_e m_maxState; + + void(void) info_hint; + + /* overrides */ + virtual void(float) Save; + virtual void(string,string) Restore; + virtual void(string, string) SpawnKey; +}; + + +void +info_hint::Save(float handle) +{ + SaveFloat(handle, "m_hintType", m_hintType); + SaveString(handle, "m_strHintActivity", m_strHintActivity); + SaveFloat(handle, "m_flNodeFOV", m_flNodeFOV); + SaveBool(handle, "m_bStartDisabled", m_bStartDisabled); + SaveString(handle, "m_strHintGroup", m_strHintGroup); + SaveFloat(handle, "m_ignoreFacing", m_ignoreFacing); + SaveFloat(handle, "m_minState", m_minState); + SaveFloat(handle, "m_maxState", m_maxState); + super::Save(handle); +} + +void +info_hint::Restore(string strKey, string strValue) +{ + switch (strKey) { + case "m_hintType": + m_hintType = ReadFloat(strValue); + break; + case "m_strHintActivity": + m_strHintActivity = ReadString(strValue); + break; + case "m_flNodeFOV": + m_flNodeFOV = ReadFloat(strValue); + break; + case "m_bStartDisabled": + m_bStartDisabled = ReadFloat(strValue); + break; + case "m_strHintGroup": + m_strHintGroup = ReadString(strValue); + break; + case "m_ignoreFacing": + m_ignoreFacing = ReadFloat(strValue); + break; + case "m_minState": + m_minState = ReadFloat(strValue); + break; + case "m_maxState": + m_maxState = ReadFloat(strValue); + break; + default: + super::Restore(strKey, strValue); + } +} + +void +info_hint::SpawnKey(string strKey, string strValue) +{ + switch (strKey) { + case "hinttype": + m_hintType = stof(strValue); + break; + case "hintactivity": + m_strHintActivity = strValue; + break; + case "nodeFOV": + m_flNodeFOV = stof(strValue); + break; + case "StartHintDisabled": + m_bStartDisabled = stof(strValue) == 1 ? true : false; + break; + case "Group": + m_strHintGroup = strValue; + break; + case "IgnoreFacing": + m_ignoreFacing = stof(strValue); + break; + case "MinimumState": + m_minState = stof(strValue); + break; + case "MaximumState": + m_maxState = stof(strValue); + break; + default: + super::SpawnKey(strKey, strValue); + } +} + +void +info_hint::info_hint(void) +{ + m_hintType = HINT_NONE; + m_strHintActivity = __NULL__; + m_flNodeFOV = 360; + m_bStartDisabled = false; + m_strHintGroup = __NULL__; + m_ignoreFacing = IGNORE_DEFAULT; + m_minState = AISTATE_IDLE; + m_maxState = AISTATE_COMBAT; +}; \ No newline at end of file diff --git a/src/gs-entbase/server/info_node.qc b/src/gs-entbase/server/info_node.qc index 37d07634..ab3e9561 100644 --- a/src/gs-entbase/server/info_node.qc +++ b/src/gs-entbase/server/info_node.qc @@ -22,4 +22,6 @@ It's a node, helping monsters navigate on the ground. -------- TRIVIA -------- This entity was introduced in Half-Life (1998). -*/ \ No newline at end of file +*/ + +CLASSEXPORT(info_node, info_notnull) \ No newline at end of file diff --git a/src/gs-entbase/server/stubs.qc b/src/gs-entbase/server/stubs.qc index eca7abf3..4ee3937f 100644 --- a/src/gs-entbase/server/stubs.qc +++ b/src/gs-entbase/server/stubs.qc @@ -74,7 +74,6 @@ of the entity, keep that in mind. This entity was introduced in Quake (1996). */ -CLASSEXPORT(info_node, info_notnull) CLASSEXPORT(info_target, info_notnull) CLASSEXPORT(env_sound, info_notnull) CLASSEXPORT(env_sun, info_notnull)