Skip to content

Commit

Permalink
Implement natives for bleed-related operations
Browse files Browse the repository at this point in the history
  • Loading branch information
nosoop committed Aug 12, 2022
1 parent 0c6f1d0 commit 833f027
Show file tree
Hide file tree
Showing 3 changed files with 321 additions and 1 deletion.
54 changes: 54 additions & 0 deletions gamedata/tf2.utils.nosoop.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@
"linux" "520"
"windows" "520"
}
"CTFPlayerShared::m_BleedList"
{
// in MakeBleed
"linux" "524"
"windows" "524"
}

"TFCondInfo_t::m_flDuration"
{
Expand All @@ -165,6 +171,47 @@
"linux" "20"
"windows" "20"
}

"BleedStruct_t::m_hAttacker"
{
"linux" "0"
"windows" "0"
}
"BleedStruct_t::m_hWeapon"
{
"linux" "4"
"windows" "4"
}
"BleedStruct_t::m_flNextTickTime"
{
"linux" "8"
"windows" "8"
}
"BleedStruct_t::m_flExpireTime"
{
"linux" "12"
"windows" "12"
}
"BleedStruct_t::m_nDamage"
{
"linux" "16"
"windows" "16"
}
"BleedStruct_t::m_bPermanent"
{
"linux" "20"
"windows" "20"
}
"BleedStruct_t::m_nCustomDamageType"
{
"linux" "24"
"windows" "24"
}
"sizeof(BleedStruct_t)"
{
"linux" "28"
"windows" "28"
}

"CEconWearable::m_bAlwaysValid"
{
Expand Down Expand Up @@ -238,6 +285,13 @@
"linux" "@_ZN15CTFPlayerShared18GetMaxBuffedHealthEbb"
"windows" "\x55\x8B\xEC\x83\xEC\x08\x56\x8B\xF1\x57\x8B\x8E\x2A\x01\x00\x00"
}
"CTFPlayerShared::MakeBleed()"
{
// copied from sm-tf2.games
"library" "server"
"linux" "@_ZN15CTFPlayerShared9MakeBleedEP9CTFPlayerP13CTFWeaponBasefibi"
"windows" "\x55\x8B\xEC\x83\xEC\x2C\x57\x8B\xF9\x89\x7D\xF0"
}
"CTFPlayerShared::RemoveAllCond()"
{
// first non-virtual call after semi-unique xref to "Player.Spawn"
Expand Down
78 changes: 78 additions & 0 deletions scripting/include/tf2utils.inc
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,84 @@ native void TF2Util_SetPlayerBurnDuration(int client, float duration);
native void TF2Util_IgnitePlayer(int client, int attacker, float duration,
int weapon = INVALID_ENT_REFERENCE);

/**
* @param client Client index.
* @return Number of entries within the bleed list.
* @error Invalid client index, or bleed list index is out of bounds.
*/
native int TF2Util_GetPlayerActiveBleedCount(int client);

/**
* @param client Client index.
* @param index Index into the player's bleed list.
* @return Attacker client associated with the bleed effect.
* @error Invalid client index, or bleed list index is out of bounds.
*/
native int TF2Util_GetPlayerBleedAttacker(int client, int index);

/**
* @param client Client index.
* @param index Index into the player's bleed list.
* @return Weapon associated with the bleed effect, or INVALID_ENT_REFERENCE if invalid.
* @error Invalid client index, or bleed list index is out of bounds.
*/
native int TF2Util_GetPlayerBleedWeapon(int client, int index);

/**
* @param client Client index.
* @param index Index into the player's bleed list.
* @return Time remaining until this bleed effect deals damage to the given client.
* @error Invalid client index, or bleed list index is out of bounds.
*/
native float TF2Util_GetPlayerBleedNextDamageTick(int client, int index);

/**
* @param client Client index.
* @param index Index into the player's bleed list.
* @return Time remaining for the bleed effect.
* @error Invalid client index, or bleed list index is out of bounds.
*/
native float TF2Util_GetPlayerBleedDuration(int client, int index);

/**
* @param client Client index.
* @param index Index into the player's bleed list.
* @return Amount of damage inflicted per bleed 'tick'.
* @error Invalid client index, or bleed list index is out of bounds.
*/
native int TF2Util_GetPlayerBleedDamage(int client, int index);

/**
* @param client Client index.
* @param index Index into the player's bleed list.
* @return Custom damage type associated with the given bleed effect.
* @error Invalid client index, or bleed list index is out of bounds.
*/
native int TF2Util_GetPlayerBleedCustomDamageType(int client, int index);

/**
* Induces the bleed effect on a client. This is effectively the same as `TF2_MakeBleed`, with
* support for additional parameters that the game provides.
*
* If the player already has a matching attacker / weapon combination, that entry will be
* updated instead.
*
* @param client Client index.
* @param attacker Attacking client's index.
* @param duration Duration of the effect. If this is TFCondDuration_Infinite,
* bleeding continues until the player removes it via medkit or
* resupply.
* @param weapon Weapon associated with the bleed effect, or INVALID_ENT_REFERENCE to
* not provide a weapon (behaving the same as `TF2_MakeBleed`).
* @param damage Amount of damage inflicted per bleed 'tick'.
* @param damagecustom Custom damage type (see TF_CUSTOM_* constants).
* @return Index into the player's bleed list where the effect was added, or -1
* if the plugin could not determine the index.
*/
native int TF2Util_MakePlayerBleed(int client, int attacker, float duration,
int weapon = INVALID_ENT_REFERENCE, int damage = 4,
int damagecustom = TF_CUSTOM_BLEEDING);

/**
* Returns true if the given player is immune to pushback.
*
Expand Down
Loading

0 comments on commit 833f027

Please sign in to comment.