nosoop / sm-tfutils Goto Github PK
View Code? Open in Web Editor NEWSourceMod function call and memory access natives for TF2
License: GNU General Public License v3.0
SourceMod function call and memory access natives for TF2
License: GNU General Public License v3.0
Soucemod - 1.11 - build 6919
//// tf2utils.sp
//
// tf2utils.sp(500) : warning 209: function has explicit 'int' tag but does not return a value
// tf2utils.sp(559) : warning 209: function has explicit 'int' tag but does not return a value
// tf2utils.sp(580) : warning 209: function has explicit 'int' tag but does not return a value
// tf2utils.sp(610) : warning 209: function has explicit 'int' tag but does not return a value
// tf2utils.sp(776) : warning 242: function "Native_SetPlayerConditionDuration" should return an explicit value
// tf2utils.sp(808) : warning 242: function "Native_SetPlayerConditionProvider" should return an explicit value
// tf2utils.sp(836) : warning 242: function "Native_SetPlayerBurnDuration" should return an explicit value
// tf2utils.sp(836) : warning 242: function "Native_SetPlayerBurnDuration" should return an explicit value
// tf2utils.sp(849) : warning 242: function "Native_IgnitePlayer" should return an explicit value
// tf2utils.sp(971) : warning 242: function "Native_SetPlayerRespawnTimeOverride" should return an explicit value
// tf2utils.sp(971) : warning 242: function "Native_SetPlayerRespawnTimeOverride" should return an explicit value
// Code size: 31760 bytes
// Data size: 10000 bytes
// Stack/heap size: 16732 bytes
// Total requirements: 58492 bytes
//
// 11 Warnings.
//
// Compilation Time: 0.48 sec
Can you fix please?
Fresh install, attempted using both the newest and second newest release, plugin in plugins folder, gamedata in gamedata file etc.
SM errors on attempting to load plugin:
[SM] Exception reported: Could not determine location to read CTFPlayer::m_aObjects from.
[SM] Blaming: tf2utils.smx
[SM] Call stack trace:
[SM] [0] SetFailState
[SM] [1] Line 243, scripting/tf2utils.sp::OnPluginStart
SM version 1.10.0.6528
TF2Util_GetPlayerMaxHealth
doesn't handle overheal correctly, no matter what bIgnoreOverheal
is set to. Fairly confident this isn't intended behaviour, as projectile_heal_on_teammate_contact.sp
in the Custom Attribute Starter Pack explicitly uses base health to calculate a separate max overheal proportion.
This code:
int iMaxHP = TF2Util_GetPlayerMaxHealth(attacker, false, false);
PrintToServer("Max HP (bIgnoreOverheal = false):");
char bffr5[16];
IntToString(iMaxHP, bffr5, 16);
PrintToServer(bffr5);
iMaxHP = TF2Util_GetPlayerMaxHealth(attacker, false, true);
PrintToServer("Max HP (bIgnoreOverheal = true):");
char bffr6[16];
IntToString(iMaxHP, bffr6, 16);
PrintToServer(bffr6);
Produces this output in console:
(Note: This is on Demoman, so it is at least calculating max HP with overheal correctly.)
Posting for you the error I encounter upon trying to load tf2utils
L 04/18/2024 - 20:49:28: [nosoop_tf2utils.smx] TF_COND_LAST is not within expected bounds (found 83000000). Condition bounds checking will produce false positives and condition count native will report incorrect values.
L 04/18/2024 - 20:49:28: [SM] Exception reported: Could not determine offset of CTFPlayer::m_flRespawnTimeOverride (received bb831574)
L 04/18/2024 - 20:49:28: [SM] Blaming: nosoop_tf2utils.smx
L 04/18/2024 - 20:49:28: [SM] Call stack trace:
L 04/18/2024 - 20:49:28: [SM] [0] SetFailState
L 04/18/2024 - 20:49:28: [SM] [1] Line 433, scripting/tf2utils.sp::OnPluginStart
It's probably not this plugin's fault but either TF2 or the plugin using the function, but still will submit this issue
Crash report:
https://crash.limetech.org/qcm4q72xgbtc
From the limited analysis this crash happens inside ::GetViewModel()
function.
I'm using this function in place of SetEntProp(client, Prop_Send, "m_hActiveWeapon")
inside EquipBoss()
of FF2 plugin (this is where the crash happened, if it's relevant).
Cause is wrong CTFPlayer::m_aObjects
offset.
Diff:
@@ -41,7 +41,7 @@
"windows"
{
"signature" "CTFPlayer::AddObject()"
- "offset" "37"
+ "offset" "53"
}
}
"offsetof(CTFPlayer::m_flRespawnTimeOverride)"
DHooks with detour support has been merged into SourceMod, so now we can start supporting hooks.
L 04/18/2024 - 23:09:09: [SM] Exception reported: Failed to set up call to CTFPlayerShared::MakeBleed()
L 04/18/2024 - 23:09:09: [SM] Blaming: tf2utils.smx
L 04/18/2024 - 23:09:09: [SM] Call stack trace:
L 04/18/2024 - 23:09:09: [SM] [0] SetFailState
L 04/18/2024 - 23:09:09: [SM] [1] Line 236, scripting/tf2utils.sp::OnPluginStart
Just make every tf2 plugin author use tf2utils and submit their gamedata file with pull request.
Placeholder issue so nobody thinks it's not known.
nosoop โ Today at 4:48 PM
feel free to raise an issue for it in tf2utils if you want; was planning on adding [a function to force a team win]
... I love getting useless GitHub stats, say no more
Anyway, a function to force a team to win or stalemate would be nice
Some useful implementation details:
CTFGameRules
(tf_gamerules
) has a function called SetWinningTeam
and SetStatemate
When game_round_win is used, it calls one of these 2 functions.
Arguments for CTFGameRules::SetWinningTeam
:
0 is the team index (int)
1 is the win reason, used for pass time? It's also provided in the teamplay_round_win
event (int)
2 resets the map if set to true (bool)
3 switches the teams if set to true (bool)
4 adds 1 to the team score thing that shows at the end if set to true (bool)
5 makes the humiliation period last for 5 seconds if true and if we're in competitive mode (bool)
CTFGameRules::SetStalemate
only has args 1-3 of CTFGameRules::SetWinningTeam
CTFPlayerInventory::GetItemInLoadout gets the player's equipped item in the specified class's specified loadout slot.
CTFPlayer::GetLoadoutItem calls CTFPlayerInventory::GetItemInLoadout but also checks to see if the item is banned in the competitive whitelist, in which case, the base/stock item is returned.
I think natives to use those 2 functions would be useful.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.