Add extra couch features

This commit is contained in:
2026-09-29 17:36:33 +01:00
parent 598dc20ae3
commit 63c218a0e9
4 changed files with 516 additions and 45 deletions
+34 -1
View File
@@ -4,6 +4,16 @@
#define _Couch_included
// How a player moved the couch, passed to Couch_OnCouchInteraction.
enum CouchMethod
{
CouchMethod_Bullet, // Gunfire; weapon is the gun, e.g. "ak47".
CouchMethod_Knife, // weapon is "knife".
CouchMethod_Grenade, // weapon is "hegrenade".
CouchMethod_Use, // +use; weapon is empty.
CouchMethod_Other // Any other damage credited to a player; weapon is the inflictor's classname.
};
// The core defines COUCH_CORE; it creates the forwards and natives itself.
#if !defined COUCH_CORE
@@ -30,7 +40,18 @@ forward void Couch_OnCouchRemoved();
forward void Couch_OnCouchDamaged(int couch, int attacker, float damage);
/**
* Called when a hit from a blocked client is refused. Fires per pellet, so rate-limit anything you send.
* Called for every hit or +use the couch accepts from a player, saying how it was moved. Hits
* fire alongside Couch_OnCouchDamaged, so shotguns report once per pellet.
*
* @param couch Entity index of the couch.
* @param client Client index of the player.
* @param method How the couch was moved.
* @param weapon Weapon without its "weapon_" prefix, see CouchMethod.
*/
forward void Couch_OnCouchInteraction(int couch, int client, CouchMethod method, const char[] weapon);
/**
* Called when a hit or +use from a blocked client is refused. Fires per pellet, so rate-limit anything you send.
*
* @param couch Entity index of the couch.
* @param client Client index of the blocked player.
@@ -103,6 +124,16 @@ native bool Couch_IsPistolOnly();
*/
native void Couch_SetPistolOnly(bool enabled);
/**
* Whether players may +use the couch to pick it up. Mirrors sm_allow_couch_use.
*/
native bool Couch_IsUseAllowed();
/**
* Allows or forbids picking the couch up with +use; when forbidden it can only be shot. Writes sm_allow_couch_use.
*/
native void Couch_SetUseAllowed(bool allowed);
/**
* Blocks or unblocks a client from the couch: their hits are refused and their body can't push
* it. The flag is per slot and cleared on disconnect and map start; the caller owns persistence.
@@ -146,6 +177,8 @@ public SharedPlugin __pl_Couch =
MarkNativeAsOptional("Couch_SetEffectEnabled");
MarkNativeAsOptional("Couch_IsPistolOnly");
MarkNativeAsOptional("Couch_SetPistolOnly");
MarkNativeAsOptional("Couch_IsUseAllowed");
MarkNativeAsOptional("Couch_SetUseAllowed");
MarkNativeAsOptional("Couch_SetClientBlocked");
MarkNativeAsOptional("Couch_IsClientBlocked");
}