Skip to content

Commit

Permalink
syringegun poison: Change heuristics to avoid spawn hook
Browse files Browse the repository at this point in the history
This avoids attaching to virtual spawn functions and introducing
a performance impact.
  • Loading branch information
nosoop committed Sep 24, 2023
1 parent 4c2385c commit 654d8be
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions scripting/syringegun_poison_on_hit.sp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ public void OnMapStart() {
}

public void OnEntityCreated(int entity, const char[] name) {
SDKHook(entity, SDKHook_SpawnPost, OnEntitySpawnPost);
if (IsMedicWeapon(entity)) {
OnMedicWeaponCreated(entity);
}
}

public void OnGameFrame() {
Expand Down Expand Up @@ -199,10 +201,6 @@ public Action TF2_OnCalculateMaxSpeed(int client, float &speed) {
}

bool IsMedicWeapon(int entity) {
if (!TF2Util_IsEntityWeapon(entity)) {
return false;
}

int defindex = TF2_GetItemDefinitionIndexSafe(entity);
return TF2Econ_GetItemSlot(defindex, TFClass_Medic) == 0;
return TF2Util_IsEntityWeapon(entity)
&& TF2Util_GetWeaponID(entity) == TF_WEAPON_SYRINGEGUN_MEDIC;
}

0 comments on commit 654d8be

Please sign in to comment.