Skip to content

Commit 833f027

Browse files
committed
Implement natives for bleed-related operations
1 parent 0c6f1d0 commit 833f027

File tree

3 files changed

+321
-1
lines changed

3 files changed

+321
-1
lines changed

gamedata/tf2.utils.nosoop.txt

+54
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@
148148
"linux" "520"
149149
"windows" "520"
150150
}
151+
"CTFPlayerShared::m_BleedList"
152+
{
153+
// in MakeBleed
154+
"linux" "524"
155+
"windows" "524"
156+
}
151157

152158
"TFCondInfo_t::m_flDuration"
153159
{
@@ -165,6 +171,47 @@
165171
"linux" "20"
166172
"windows" "20"
167173
}
174+
175+
"BleedStruct_t::m_hAttacker"
176+
{
177+
"linux" "0"
178+
"windows" "0"
179+
}
180+
"BleedStruct_t::m_hWeapon"
181+
{
182+
"linux" "4"
183+
"windows" "4"
184+
}
185+
"BleedStruct_t::m_flNextTickTime"
186+
{
187+
"linux" "8"
188+
"windows" "8"
189+
}
190+
"BleedStruct_t::m_flExpireTime"
191+
{
192+
"linux" "12"
193+
"windows" "12"
194+
}
195+
"BleedStruct_t::m_nDamage"
196+
{
197+
"linux" "16"
198+
"windows" "16"
199+
}
200+
"BleedStruct_t::m_bPermanent"
201+
{
202+
"linux" "20"
203+
"windows" "20"
204+
}
205+
"BleedStruct_t::m_nCustomDamageType"
206+
{
207+
"linux" "24"
208+
"windows" "24"
209+
}
210+
"sizeof(BleedStruct_t)"
211+
{
212+
"linux" "28"
213+
"windows" "28"
214+
}
168215

169216
"CEconWearable::m_bAlwaysValid"
170217
{
@@ -238,6 +285,13 @@
238285
"linux" "@_ZN15CTFPlayerShared18GetMaxBuffedHealthEbb"
239286
"windows" "\x55\x8B\xEC\x83\xEC\x08\x56\x8B\xF1\x57\x8B\x8E\x2A\x01\x00\x00"
240287
}
288+
"CTFPlayerShared::MakeBleed()"
289+
{
290+
// copied from sm-tf2.games
291+
"library" "server"
292+
"linux" "@_ZN15CTFPlayerShared9MakeBleedEP9CTFPlayerP13CTFWeaponBasefibi"
293+
"windows" "\x55\x8B\xEC\x83\xEC\x2C\x57\x8B\xF9\x89\x7D\xF0"
294+
}
241295
"CTFPlayerShared::RemoveAllCond()"
242296
{
243297
// first non-virtual call after semi-unique xref to "Player.Spawn"

scripting/include/tf2utils.inc

+78
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,84 @@ native void TF2Util_SetPlayerBurnDuration(int client, float duration);
146146
native void TF2Util_IgnitePlayer(int client, int attacker, float duration,
147147
int weapon = INVALID_ENT_REFERENCE);
148148

149+
/**
150+
* @param client Client index.
151+
* @return Number of entries within the bleed list.
152+
* @error Invalid client index, or bleed list index is out of bounds.
153+
*/
154+
native int TF2Util_GetPlayerActiveBleedCount(int client);
155+
156+
/**
157+
* @param client Client index.
158+
* @param index Index into the player's bleed list.
159+
* @return Attacker client associated with the bleed effect.
160+
* @error Invalid client index, or bleed list index is out of bounds.
161+
*/
162+
native int TF2Util_GetPlayerBleedAttacker(int client, int index);
163+
164+
/**
165+
* @param client Client index.
166+
* @param index Index into the player's bleed list.
167+
* @return Weapon associated with the bleed effect, or INVALID_ENT_REFERENCE if invalid.
168+
* @error Invalid client index, or bleed list index is out of bounds.
169+
*/
170+
native int TF2Util_GetPlayerBleedWeapon(int client, int index);
171+
172+
/**
173+
* @param client Client index.
174+
* @param index Index into the player's bleed list.
175+
* @return Time remaining until this bleed effect deals damage to the given client.
176+
* @error Invalid client index, or bleed list index is out of bounds.
177+
*/
178+
native float TF2Util_GetPlayerBleedNextDamageTick(int client, int index);
179+
180+
/**
181+
* @param client Client index.
182+
* @param index Index into the player's bleed list.
183+
* @return Time remaining for the bleed effect.
184+
* @error Invalid client index, or bleed list index is out of bounds.
185+
*/
186+
native float TF2Util_GetPlayerBleedDuration(int client, int index);
187+
188+
/**
189+
* @param client Client index.
190+
* @param index Index into the player's bleed list.
191+
* @return Amount of damage inflicted per bleed 'tick'.
192+
* @error Invalid client index, or bleed list index is out of bounds.
193+
*/
194+
native int TF2Util_GetPlayerBleedDamage(int client, int index);
195+
196+
/**
197+
* @param client Client index.
198+
* @param index Index into the player's bleed list.
199+
* @return Custom damage type associated with the given bleed effect.
200+
* @error Invalid client index, or bleed list index is out of bounds.
201+
*/
202+
native int TF2Util_GetPlayerBleedCustomDamageType(int client, int index);
203+
204+
/**
205+
* Induces the bleed effect on a client. This is effectively the same as `TF2_MakeBleed`, with
206+
* support for additional parameters that the game provides.
207+
*
208+
* If the player already has a matching attacker / weapon combination, that entry will be
209+
* updated instead.
210+
*
211+
* @param client Client index.
212+
* @param attacker Attacking client's index.
213+
* @param duration Duration of the effect. If this is TFCondDuration_Infinite,
214+
* bleeding continues until the player removes it via medkit or
215+
* resupply.
216+
* @param weapon Weapon associated with the bleed effect, or INVALID_ENT_REFERENCE to
217+
* not provide a weapon (behaving the same as `TF2_MakeBleed`).
218+
* @param damage Amount of damage inflicted per bleed 'tick'.
219+
* @param damagecustom Custom damage type (see TF_CUSTOM_* constants).
220+
* @return Index into the player's bleed list where the effect was added, or -1
221+
* if the plugin could not determine the index.
222+
*/
223+
native int TF2Util_MakePlayerBleed(int client, int attacker, float duration,
224+
int weapon = INVALID_ENT_REFERENCE, int damage = 4,
225+
int damagecustom = TF_CUSTOM_BLEEDING);
226+
149227
/**
150228
* Returns true if the given player is immune to pushback.
151229
*

0 commit comments

Comments
 (0)