Skip to content

Instantly share code, notes, and snippets.

TF2's player damage process

note: documentation is released as-is and reports of any inaccuracies will be ignored

Call tree:

  • CTFPlayer::ModifyDamageInfo
  • CTFPlayer::OnTakeDamage
    • If attacker is carrying RUNE_STRENGTH, scale damage by 2.0f.
    • CTFGameRules::ApplyOnDamageModifyRules
/**
* dhooks_gameconf_shim
* (c) 2023 nosoop
*
* DHooks stores the hook definitions in-extension. Because it's keyed globally, it has the
* side effect of conflicting if multiple game config files use the same name for different
* hook definitions, no matter which plugin is loading them.
*
* This issue is tracked here: https://github.com/alliedmodders/sourcemod/issues/1879
*
#!/usr/bin/python3
# BSD Zero Clause License
#
# Copyright (C) 2023 by nosoop
#
# Permission to use, copy, modify, and/or distribute this software for any purpose with or
# without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS

This patch is a fix for the bug observed in this video.

Requires Source Scramble and its manager plugin.

tf2.fix_ammo_gain_windows.patch.txt goes into addons/sourcemod/configs/sourcescramble and tf2.fix_ammo_gain_windows.txt goes into addons/sourcemod/gamedata.

/**
* Prevents birds from spawning near players in water.
*/
#pragma semicolon 1
#include <sourcemod>
#pragma newdecls required
#define DOVE_SQUARED_TOLERANCE 2500.0 // 50.0 HU^2
@nosoop
nosoop / config.ini
Last active September 2, 2022 07:38
[DEFAULT]
basedir = gamefiles/%(appid)s
info_file = %(basedir)s/%(gamedir)s/steam.inf
[Team Fortress 2]
gamedir = tf
appid = 232250
files = server_srv.so
engine_srv.so
server.dll
/**
* if you're bored you can simply close your eyes and rotate a cow in your mind.
* it's free and the cops can't stop you
*/
#pragma semicolon 1
#include <sourcemod>
#pragma newdecls required
#include <stocksoup/traceutils>

fresh benchmarks for attributes and attribute strings with some new optimizations on tf2attributes' side

(note that the optimizations only affect native attributes)


Running benchmark with 65536 iterations. (This benchmark was run multiple times, and the best time for each was taken.)

  • GetGameTime took 0.000384s
  • GetEntPropString took 0.010754s
#!/usr/bin/python3
"""
Finds the location of the given string and patches the first character to the null terminator,
preventing the message from being displayed in the server console.
This can be executed while the server is running.
"""
import mmap
@nosoop
nosoop / makesig.py
Last active September 6, 2021 02:38
makesig.idc-like script in Ghidra
#Generates a SourceMod-ready signature.
#@author nosoop
#@category _NEW_
#@keybinding
#@menupath
#@toolbar
import ghidra.program.model.lang.OperandType as OperandType
import ghidra.program.model.lang.Register as Register