Couch changes
This commit is contained in:
@@ -4,6 +4,32 @@
|
||||
|
||||
#define _Couch_included
|
||||
|
||||
// Chat prefix shared by the whole couch plugin set. The trailing colour code tints the token that
|
||||
// follows it (a name or value); messages switch back with \x01. PREFIX_PLAIN is for console
|
||||
// replies, which don't render colour codes.
|
||||
#define PREFIX "\x07CD853F[Couch] \x04"
|
||||
#define PREFIX_PLAIN "[Couch]"
|
||||
|
||||
// Non-negative integer with a comma every three digits: 1532 -> "1,532".
|
||||
stock void FormatThousands(int value, char[] buffer, int maxlen)
|
||||
{
|
||||
char sDigits[16];
|
||||
int len = IntToString(value, sDigits, sizeof(sDigits));
|
||||
|
||||
int out = 0;
|
||||
for (int i = 0; i < len && out < maxlen - 1; i++)
|
||||
{
|
||||
// A comma goes before every digit that starts a new group of three from the right.
|
||||
if (i > 0 && (len - i) % 3 == 0)
|
||||
buffer[out++] = ',';
|
||||
|
||||
if (out < maxlen - 1)
|
||||
buffer[out++] = sDigits[i];
|
||||
}
|
||||
|
||||
buffer[out] = '\0';
|
||||
}
|
||||
|
||||
// How a player moved the couch, passed to Couch_OnCouchInteraction.
|
||||
enum CouchMethod
|
||||
{
|
||||
@@ -58,6 +84,25 @@ forward void Couch_OnCouchInteraction(int couch, int client, CouchMethod method,
|
||||
*/
|
||||
forward void Couch_OnClientBlocked(int couch, int client);
|
||||
|
||||
/**
|
||||
* Called whenever the couch's HP changes: zombie hits, regen ticks, admin sets, resets to full
|
||||
* on spawn and round start, and when the HP feature is switched on or off.
|
||||
*
|
||||
* @param couch Entity index of the couch, or -1 if the feature was switched off while there was none.
|
||||
* @param hp Current HP.
|
||||
* @param maxhp Maximum HP, sm_couch_hp_max.
|
||||
*/
|
||||
forward void Couch_OnCouchHpChanged(int couch, int hp, int maxhp);
|
||||
|
||||
/**
|
||||
* Called when the couch's HP reaches 0, before the humans are killed and the couch is removed.
|
||||
* Couch_OnCouchRemoved follows.
|
||||
*
|
||||
* @param couch Entity index of the couch; still valid during this call.
|
||||
* @param attacker Client index of the zombie whose hit broke it, or 0 when an admin set the HP to 0.
|
||||
*/
|
||||
forward void Couch_OnCouchBroken(int couch, int attacker);
|
||||
|
||||
/**
|
||||
* @return Entity index of the couch, or -1 if there is none.
|
||||
*/
|
||||
@@ -114,6 +159,16 @@ native bool Couch_IsEffectEnabled();
|
||||
*/
|
||||
native void Couch_SetEffectEnabled(bool enabled);
|
||||
|
||||
/**
|
||||
* Whether the sm_beacon-style rings on the couch are on. Mirrors sm_couch_beacon.
|
||||
*/
|
||||
native bool Couch_IsBeaconEnabled();
|
||||
|
||||
/**
|
||||
* Switches the beacon rings on or off. Writes sm_couch_beacon.
|
||||
*/
|
||||
native void Couch_SetBeaconEnabled(bool enabled);
|
||||
|
||||
/**
|
||||
* Whether only pistols and knives may move the couch. Mirrors sm_couch_pistol_only.
|
||||
*/
|
||||
@@ -151,6 +206,43 @@ native void Couch_SetClientBlocked(int client, bool blocked);
|
||||
*/
|
||||
native bool Couch_IsClientBlocked(int client);
|
||||
|
||||
/**
|
||||
* Whether couch HP is on: zombie hits wear the couch down and at 0 HP it breaks, killing every
|
||||
* human. Mirrors sm_couch_hp.
|
||||
*/
|
||||
native bool Couch_IsHpEnabled();
|
||||
|
||||
/**
|
||||
* Switches couch HP on or off. Turning it on sets the HP to full. Writes sm_couch_hp.
|
||||
*/
|
||||
native void Couch_SetHpEnabled(bool enabled);
|
||||
|
||||
/**
|
||||
* @return Current couch HP, or 0 if there is no couch.
|
||||
*/
|
||||
native int Couch_GetHp();
|
||||
|
||||
/**
|
||||
* Sets the couch's HP, clamped to 0..Couch_GetMaxHp(). Setting 0 breaks the couch as a zombie
|
||||
* hit would, provided the HP feature is on and a couch exists.
|
||||
*
|
||||
* @param hp New HP.
|
||||
*/
|
||||
native void Couch_SetHp(int hp);
|
||||
|
||||
/**
|
||||
* @return Maximum couch HP. Mirrors sm_couch_hp_max.
|
||||
*/
|
||||
native int Couch_GetMaxHp();
|
||||
|
||||
/**
|
||||
* Sets the maximum couch HP. A couch at full HP stays full; otherwise the HP is clamped to the
|
||||
* new maximum. Writes sm_couch_hp_max.
|
||||
*
|
||||
* @param maxhp New maximum, at least 1.
|
||||
*/
|
||||
native void Couch_SetMaxHp(int maxhp);
|
||||
|
||||
|
||||
public SharedPlugin __pl_Couch =
|
||||
{
|
||||
@@ -175,12 +267,20 @@ public SharedPlugin __pl_Couch =
|
||||
MarkNativeAsOptional("Couch_Remove");
|
||||
MarkNativeAsOptional("Couch_IsEffectEnabled");
|
||||
MarkNativeAsOptional("Couch_SetEffectEnabled");
|
||||
MarkNativeAsOptional("Couch_IsBeaconEnabled");
|
||||
MarkNativeAsOptional("Couch_SetBeaconEnabled");
|
||||
MarkNativeAsOptional("Couch_IsPistolOnly");
|
||||
MarkNativeAsOptional("Couch_SetPistolOnly");
|
||||
MarkNativeAsOptional("Couch_IsUseAllowed");
|
||||
MarkNativeAsOptional("Couch_SetUseAllowed");
|
||||
MarkNativeAsOptional("Couch_SetClientBlocked");
|
||||
MarkNativeAsOptional("Couch_IsClientBlocked");
|
||||
MarkNativeAsOptional("Couch_IsHpEnabled");
|
||||
MarkNativeAsOptional("Couch_SetHpEnabled");
|
||||
MarkNativeAsOptional("Couch_GetHp");
|
||||
MarkNativeAsOptional("Couch_SetHp");
|
||||
MarkNativeAsOptional("Couch_GetMaxHp");
|
||||
MarkNativeAsOptional("Couch_SetMaxHp");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user