diff --git a/README.md b/README.md index 8de321b..fe4e214 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,21 @@ Credits to zen for the idea :) ConVars go into `cfg/sourcemod/plugin.tossbuildings.cfg`. ## Custom Attribute -This plugin also works as [custom attributes](https://github.com/nosoop/SM-TFCustAttr) plugin. -Add the "`toss buildings`" attribute to the building tool (base item def index `28`) with the following values (add up to combine) +This plugin also works as custom attribute. It is recommendedto use [Hidden dev attributes](https://forums.alliedmods.net/showthread.php?t=326853), but [custom attributes](https://github.com/nosoop/SM-TFCustAttr) is also supported. + +I'm not too familiar with hidden dev attributes, but the entry should probably look something like this (Don't forget to give it a unique id aka number somewhere above 4000): +```c +//Allows to throw buildings as engi +"4269" +{ + "name" "toss buildings" + "attribute_class" "toss buildings" + "description_format" "value_is_additive" + "stored_as_integer" "1" +} +``` + +Add the "`toss buildings`" attribute with the following values (add up to combine): * 1 : Dispenser * 2 : Teleporter * 4 : Sentries diff --git a/tbobj.games.txt b/tbobj.games.txt index cfffe37..73f30c9 100644 --- a/tbobj.games.txt +++ b/tbobj.games.txt @@ -2,7 +2,7 @@ "tf" { "Signatures" { // one of two methods with: "robo_sapper", starts with member lookup, first non-virtual call returns ~vtable fun 30 - "StartBuilding" { + "CTFWeaponBuilder::StartBuilding()" { "library" "server" "linux" "@_ZN16CTFWeaponBuilder13StartBuildingEv" "windows" "\x55\x8B\xEC\x51\x8B\xD1\x53\x89" @@ -10,11 +10,5 @@ //MASK ff ff ff ff ff ff ff ff 00 00 } } - //"Offsets" { - // "IsPlacementPosValid" { - // "linux" "335" - // "windows" "334" - // } - //} } } \ No newline at end of file diff --git a/tossbuildings.sp b/tossbuildings.sp index 705a29f..7b5e503 100644 --- a/tossbuildings.sp +++ b/tossbuildings.sp @@ -9,19 +9,23 @@ #undef REQUIRE_PLUGIN #tryinclude -#if !defined _inc_tf2hudmsg -#warning Compiling without TF2hudmsg -#endif + #if !defined _inc_tf2hudmsg + #warning Compiling without TF2hudmsg + #endif #tryinclude -#if !defined __tf_custom_attributes_included -#warning Compiling without TF Custom Attributes -#endif + #if !defined __tf_custom_attributes_included + #warning Compiling without TF Custom Attributes + #endif +#tryinclude + #if !defined _tf2attributes_included + #warning Compiling without TF2Attributes + #endif #define REQUIRE_PLUGIN #pragma newdecls required #pragma semicolon 1 -#define PLUGIN_VERSION "22w46a" +#define PLUGIN_VERSION "22w47a" public Plugin myinfo = { name = "[TF2] Toss Buildings", @@ -58,7 +62,6 @@ enum struct AirbornData { bool g_bPlayerThrow[MAXPLAYERS+1]; Handle sdk_fnStartBuilding; -//Handle sdk_fnIsPlacementPosValid; ArrayList g_aAirbornObjects; float g_flClientLastBeep[MAXPLAYERS+1]; float g_flClientLastNotif[MAXPLAYERS+1]; //for hud notifs, as those make noise @@ -78,6 +81,7 @@ bool g_bAllowStacking; GlobalForward g_fwdToss, g_fwdTossPost, g_fwdLanded; bool g_bDepHudMsg; //for fancy messages +bool g_bDepAttribHooks; //for hidden dev attributes, works better than custom attributes bool g_bDepCustomAttribs; //for custom attributes / custom weapons integration public void OnPluginStart() { @@ -86,15 +90,9 @@ public void OnPluginStart() { SetFailState("Could not load gamedata: File is missing"); StartPrepSDKCall(SDKCall_Entity); //weapon - PrepSDKCall_SetFromConf(data, SDKConf_Signature, "StartBuilding"); + PrepSDKCall_SetFromConf(data, SDKConf_Signature, "CTFWeaponBuilder::StartBuilding()"); if ((sdk_fnStartBuilding = EndPrepSDKCall())==null) - SetFailState("Could not load gamedata: StartBuilding Signature missing or outdated"); - -// StartPrepSDKCall(SDKCall_Entity); //building -// PrepSDKCall_SetFromConf(data, SDKConf_Virtual, "IsPlacementPosValid"); -// PrepSDKCall_SetReturnInfo(SDKType_PlainOldData, SDKPass_Plain); -// if ((sdk_fnIsPlacementPosValid = EndPrepSDKCall())==null) -// SetFailState("Could not load gamedata: IsPlacementPosValid Offset missing or outdated"); + SetFailState("Could not load gamedata: CTFWeaponBuilder::StartBuilding() Signature missing or outdated"); delete data; @@ -198,14 +196,17 @@ public void OnClientDisconnect(int client) { public void OnAllPluginsLoaded() { g_bDepHudMsg = LibraryExists("tf2hudmsg"); g_bDepCustomAttribs = LibraryExists("tf2custattr"); + g_bDepAttribHooks = LibraryExists("tf2attributes"); } public void OnLibraryAdded(const char[] name) { if (StrEqual(name, "tf2hudmsg")) g_bDepHudMsg = true; else if (StrEqual(name, "tf2custattr")) g_bDepCustomAttribs = true; + else if (StrEqual(name, "tf2attributes")) g_bDepAttribHooks = true; } public void OnLibraryRemoved(const char[] name) { if (StrEqual(name, "tf2hudmsg")) g_bDepHudMsg = false; else if (StrEqual(name, "tf2custattr")) g_bDepCustomAttribs = false; + else if (StrEqual(name, "tf2attributes")) g_bDepAttribHooks = false; } public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon, int &subtype, int &cmdnum, int &tickcount, int &seed, int mouse[2]) { @@ -317,10 +318,11 @@ public void ThrowBuilding(any buildref) { AddVectors(velocity, fwd, velocity); angles[0] = angles[2] = 0.0; //upright angle = 0.0 yaw 0.0 - //double up the CheckThrowPos trace, since we're note a net event and a tick later + //double up the CheckThrowPos trace, since we're a tick later TR_TraceRayFilter(eyes, origin, MASK_PLAYERSOLID, RayType_EndPoint, TEF_HitSelfFilterPassClients, owner); if (TR_DidHit()) { - Beep(owner); + // the building is already going up, we need to either handle the refund or break the building + BreakBuilding(building); return; } @@ -550,9 +552,15 @@ bool IsThrowBlocked(int client) { if (!(BUILDING_DISPENSER <= type <= BUILDING_SENTRYGUN)) return false; //supported buildings, not always correct on weapon_builder +#if defined _tf2attributes_included + if (g_bDepAttribHooks) { + int cwAllowed = TF2Attrib_HookValueInt(0, "toss buildings", client); + if ((cwAllowed & (1<