diff options
Diffstat (limited to 'src/server.cpp')
| -rw-r--r-- | src/server.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/server.cpp b/src/server.cpp index c2864c8..e9fd921 100644 --- a/src/server.cpp +++ b/src/server.cpp | |||
| @@ -51,6 +51,7 @@ static int g_srv_followtarget = -1; | |||
| 51 | static int g_srv_spawnflags = -1; | 51 | static int g_srv_spawnflags = -1; |
| 52 | static int g_srv_hacked = -1; | 52 | static int g_srv_hacked = -1; |
| 53 | static int g_srv_npcstate = -1; | 53 | static int g_srv_npcstate = -1; |
| 54 | static int g_srv_takedamage = -1; | ||
| 54 | static bool g_srv_ready = false; | 55 | static bool g_srv_ready = false; |
| 55 | static bool g_srv_checked = false; | 56 | static bool g_srv_checked = false; |
| 56 | 57 | ||
| @@ -141,15 +142,17 @@ bool resolve_server_netvars() { | |||
| 141 | g_srv_spawnflags = datamap_offset("m_spawnflags", FIELD_INTEGER, 0x4); | 142 | g_srv_spawnflags = datamap_offset("m_spawnflags", FIELD_INTEGER, 0x4); |
| 142 | g_srv_hacked = datamap_offset("m_bHackedByAlyx", FIELD_BOOLEAN); | 143 | g_srv_hacked = datamap_offset("m_bHackedByAlyx", FIELD_BOOLEAN); |
| 143 | g_srv_npcstate = datamap_offset("m_NPCState", FIELD_INTEGER); | 144 | g_srv_npcstate = datamap_offset("m_NPCState", FIELD_INTEGER); |
| 145 | g_srv_takedamage = datamap_offset("m_takedamage", FIELD_INTEGER); | ||
| 144 | g_srv_ready = g_srv_health > 0; | 146 | g_srv_ready = g_srv_health > 0; |
| 145 | if (g_srv_ready) { | 147 | if (g_srv_ready) { |
| 146 | logf("server datamap (%s): health=%d maxhealth=%d lifeste=%d " | 148 | logf("server datamap (%s): health=%d maxhealth=%d lifeste=%d " |
| 147 | "modelindex=%d absvel=%d vel=%d activeweapon=%d relationship=%d " | 149 | "modelindex=%d absvel=%d vel=%d activeweapon=%d relationship=%d " |
| 148 | "followtarget=%d spawnflags=%d hacked=%d npcstate=%d", | 150 | "followtarget=%d spawnflags=%d hacked=%d npcstate=%d " |
| 151 | "takedamage=%d", | ||
| 149 | g_server.path.c_str(), g_srv_health, g_srv_maxhealth, g_srv_lifestate, | 152 | g_server.path.c_str(), g_srv_health, g_srv_maxhealth, g_srv_lifestate, |
| 150 | g_srv_modelindex, g_srv_absvelocity, g_srv_velocity, | 153 | g_srv_modelindex, g_srv_absvelocity, g_srv_velocity, |
| 151 | g_srv_activeweapon, g_srv_relationship, g_srv_followtarget, | 154 | g_srv_activeweapon, g_srv_relationship, g_srv_followtarget, |
| 152 | g_srv_spawnflags, g_srv_hacked, g_srv_npcstate); | 155 | g_srv_spawnflags, g_srv_hacked, g_srv_npcstate, g_srv_takedamage); |
| 153 | fail_logged = false; | 156 | fail_logged = false; |
| 154 | } else if (!fail_logged) { | 157 | } else if (!fail_logged) { |
| 155 | fail_logged = true; | 158 | fail_logged = true; |
| @@ -268,6 +271,18 @@ int server_npc_state(int idx) { | |||
| 268 | return *(int *)((uintptr_t)base + g_srv_npcstate); | 271 | return *(int *)((uintptr_t)base + g_srv_npcstate); |
| 269 | } | 272 | } |
| 270 | 273 | ||
| 274 | // TAKEDAMAGE: 0 = DAMAGE_NO, 1 = DAMAGE_EVENTS_ONLY, 2 = DAMAGE_YES, | ||
| 275 | // 3 = DAMAGE_AIM. 0/1 cannot be damaged at all. | ||
| 276 | int server_npc_takedamage(int idx) { | ||
| 277 | if (!g_srv_ready || g_srv_takedamage < 0) | ||
| 278 | return -1; | ||
| 279 | void *base = nullptr; | ||
| 280 | server_entity_health(idx, nullptr, nullptr, &base); | ||
| 281 | if (!base) | ||
| 282 | return -1; | ||
| 283 | return *(int *)((uintptr_t)base + g_srv_takedamage); | ||
| 284 | } | ||
| 285 | |||
| 271 | bool server_npc_has_follow_target(int idx) { | 286 | bool server_npc_has_follow_target(int idx) { |
| 272 | if (!g_srv_ready || g_srv_followtarget < 0) | 287 | if (!g_srv_ready || g_srv_followtarget < 0) |
| 273 | return false; | 288 | return false; |
