Integrated zrtools and removed hacks extension dependency (don't forget zrtools.inc), and I'll make a repos for the source code and binary. No linux binary yet. Gunna be a pain in the ass.

This commit is contained in:
Greyscale 2009-05-11 04:47:09 +02:00
parent e9c611b476
commit 7c643c5d66
4 changed files with 252 additions and 75 deletions

195
src/include/zrtools.inc Normal file
View File

@ -0,0 +1,195 @@
#if defined _zrtools_included
#endinput
#endif
#define _zrtools_included
/**
* Specifies what to do after a hook completes.
*/
enum ZRTools_Action
{
ZRTools_Continue = 0, /**< Continue with the original action */
ZRTools_Changed = 1, /**< Inputs or outputs have been overridden with new values */
ZRTools_Handled = 2, /**< Handle the action at the end (don't call it) */
};
/**
* Callback function for TraceAttack.
*
* @param client The client index.
* @param inflictor The entity index of the inflictor.
* @param attacker The client index of the attacker.
* @param damage The amount of damage inflicted.
* @param hitbox The hitbox index.
* @param hitgroup The hitgroup index.
* @return Return ZRTools_Handled to stop bullet from hitting client.
* ZRTools_Continue to allow bullet to hit client.
*/
functag public ZRTools_Action:ZRTools_TraceAttack(client, inflictor, attacker, Float:damage, hitbox, hitgroup);
/**
* Hooks TraceAttack on a client.
*
* @param client The client index.
* @param callback The callback function for hook.
* @return The unique HookID.
*/
native ZRTools_HookTraceAttack(client, ZRTools_TraceAttack:callback);
/**
* Unhooks TraceAttack on a client.
*
* @param hookid The HookID of the hook.
* @error Invalid HookID.
*/
native ZRTools_UnhookTraceAttack(hookid);
// instant damage
#define DMG_GENERIC 0 // generic damage was done
#define DMG_CRUSH (1 << 0) // crushed by falling or moving object.
// NOTE: It's assumed crush damage is occurring as a result of physics collision, so no extra physics force is generated by crush damage.
// DON'T use DMG_CRUSH when damaging entities unless it's the result of a physics collision. You probably want DMG_CLUB instead.
#define DMG_BULLET (1 << 1) // shot
#define DMG_SLASH (1 << 2) // cut, clawed, stabbed
#define DMG_BURN (1 << 3) // heat burned
#define DMG_VEHICLE (1 << 4) // hit by a vehicle
#define DMG_FALL (1 << 5) // fell too far
#define DMG_BLAST (1 << 6) // explosive blast damage
#define DMG_CLUB (1 << 7) // crowbar, punch, headbutt
#define DMG_SHOCK (1 << 8) // electric shock
#define DMG_SONIC (1 << 9) // sound pulse shockwave
#define DMG_ENERGYBEAM (1 << 10) // laser or other high energy beam
#define DMG_PREVENT_PHYSICS_FORCE (1 << 11) // Prevent a physics force
#define DMG_NEVERGIB (1 << 12) // with this bit OR'd in, no damage type will be able to gib victims upon death
#define DMG_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death.
#define DMG_DROWN (1 << 14) // Drowning
// time-based damage
#define DMG_TIMEBASED (DMG_PARALYZE | DMG_NERVEGAS | DMG_POISON | DMG_RADIATION | DMG_DROWNRECOVER | DMG_ACID | DMG_SLOWBURN) // mask for time-based damage
#define DMG_PARALYZE (1 << 15) // slows affected creature down
#define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad
#define DMG_POISON (1 << 17) // blood poisoning - heals over time like drowning damage
#define DMG_RADIATION (1 << 18) // radiation exposure
#define DMG_DROWNRECOVER (1 << 19) // drowning recovery
#define DMG_ACID (1 << 20) // toxic chemicals or acid burns
#define DMG_SLOWBURN (1 << 21) // in an oven
#define DMG_REMOVENORAGDOLL (1<<22) // with this bit OR'd in, no ragdoll will be created, and the target will be quietly removed.
// use this to kill an entity that you've already got a server-side ragdoll for
#define DMG_PHYSGUN (1<<23) // Hit by manipulator. Usually doesn't do any damage.
#define DMG_PLASMA (1<<24) // Shot by Cremator
#define DMG_AIRBOAT (1<<25) // Hit by the airboat's gun
#define DMG_DISSOLVE (1<<26) // Dissolving!
#define DMG_BLAST_SURFACE (1<<27) // A blast on the surface of water that cannot harm things underwater
#define DMG_DIRECT (1<<28)
#define DMG_BUCKSHOT (1<<29) // not quite a bullet. Little, rounder, different.
// CS:S Specific damage flags. (should probably use these)
#define DMG_CSS_FALL (DMG_FALL) // Client was damaged by falling.
#define DMG_CSS_BLAST (DMG_BLAST) // Client was damaged by explosion.
#define DMG_CSS_BULLET (DMG_NEVERGIB) // Client was shot or knifed.
#define DMG_CSS_HEADSHOT (1 << 30) // Client was shot in the head.
/**
* Callback function for OnTakeDamage.
*
* @param client The client index.
* @param inflictor The entity index of the inflictor.
* @param attacker The client index of the attacker.
* @param damage The amount of damage inflicted.
* @param damagetype The type of damage inflicted.
* @param ammotype The ammo type of the attacker's weapon.
* @return Return ZRTools_Handled to stop the damage to client.
* ZRTools_Continue to allow damage to client.
*/
functag public ZRTools_Action:ZRTools_OnTakeDamage(client, inflictor, attacker, Float:damage, damagetype, ammotype);
/**
* Hooks OnTakeDamage on a client.
*
* @param client The client index.
* @param callback The callback function for hook.
* @return The unique HookID.
*/
native ZRTools_HookOnTakeDamage(client, ZRTools_OnTakeDamage:callback);
/**
* Unhooks OnTakeDamage on a client.
*
* @param hookid The HookID of the hook.
* @error Invalid HookID.
*/
native ZRTools_UnhookOnTakeDamage(hookid);
/**
* Callback function for Weapon_CanUse.
* Called when a client attempts to pick up a weapon.
*
* @param client The client index.
* @param weapon The weapon index.
* @return Return ZRTools_Handled to stop weapon pickup.
* ZRTools_Continue to allow weapon pickup.
*/
functag public ZRTools_Action:ZRTools_Weapon_CanUse(client, weapon);
/**
* Hooks Weapon_CanUse on a client.
*
* @param client The client index.
* @param callback The callback function for hook.
* @return The unique HookID.
*/
native ZRTools_HookWeapon_CanUse(client, ZRTools_Weapon_CanUse:callback);
/**
* Unhooks Weapon_CanUse on a client.
*
* @param hookid The HookID of the hook.
* @error Invalid HookID.
*/
native ZRTools_UnhookWeapon_CanUse(hookid);
/**
* Callback function for Weapon_Drop.
* Called when a client drops their weapon.
*
* @param client The client index.
* @param weapon The weapon index.
*/
functag public ZRTools_Action:ZRTools_Weapon_Drop(client, weapon);
/**
* Hooks Weapon_Drop on a client.
*
* @param client The client index.
* @param callback The callback function for hook.
* @return The unique HookID.
*/
native ZRTools_HookWeapon_Drop(client, ZRTools_Weapon_Drop:callback);
/**
* Unhooks Weapon_Drop on a client.
*
* @param hookid The HookID of the hook.
* @error Invalid HookID.
*/
native ZRTools_UnhookWeapon_Drop(hookid);
/**
* Do not edit below this line!
*/
public Extension:__ext_zrtools =
{
name = "ZR Tools",
file = "zrtools.ext",
autoload = 1,
#if defined REQUIRE_EXTENSIONS
required = 1,
#else
required = 0,
#endif
};

View File

@ -5,7 +5,7 @@
*
* File: zombiereloaded.sp
* Type: Base
* Description: Plugins base file.
* Description: Plugin's base file.
*
* ============================================================================
*/
@ -14,7 +14,7 @@
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <hacks>
#include <zrtools>
#undef REQUIRE_PLUGIN
#include <market>

View File

@ -10,14 +10,6 @@
* ============================================================================
*/
/**
* @section Damage type flags.
*/
#define DMG_FALL (1 << 5) /** Client was damaged by falling. */
#define DMG_BLAST (1 << 6) /** Client was damaged by explosion. */
#define DMG_BULLET (1 << 12) /** Client was shot or knifed. */
#define DMG_HEADSHOT (1 << 30) /** Client was shot in the head. */
/**
* @endsection
*/
@ -74,8 +66,8 @@ DamageInit()
DamageClientInit(client)
{
// Hook damage callbacks.
g_iDamageHookID[client][Hook_TraceAttack] = Hacks_Hook(client, HACKS_HTYPE_TRACEATTACK, DamageTraceAttack);
g_iDamageHookID[client][Hook_OnTakeDamage] = Hacks_Hook(client, HACKS_HTYPE_ONTAKEDAMAGE, DamageOnTakeDamage);
g_iDamageHookID[client][Hook_TraceAttack] = ZRTools_HookTraceAttack(client, DamageTraceAttack);
g_iDamageHookID[client][Hook_OnTakeDamage] = ZRTools_HookOnTakeDamage(client, DamageOnTakeDamage);
}
/**
@ -86,8 +78,8 @@ DamageClientInit(client)
DamageOnClientDisconnect(client)
{
// Unhook damage callbacks.
Hacks_Unhook(g_iDamageHookID[client][Hook_TraceAttack]);
Hacks_Unhook(g_iDamageHookID[client][Hook_OnTakeDamage]);
ZRTools_UnhookTraceAttack(g_iDamageHookID[client][Hook_TraceAttack]);
ZRTools_UnhookOnTakeDamage(g_iDamageHookID[client][Hook_OnTakeDamage]);
}
/**
@ -95,29 +87,26 @@ DamageOnClientDisconnect(client)
* Called right before the bullet enters a client.
*
* @param client The client index.
* @param inflictor Entity index of damage-causing entity.
* @param attacker The client doing the damage.
* @param damage The amount of damage that will be inflicted.
* @param inflictor The entity index of the inflictor.
* @param attacker The client index of the attacker.
* @param damage The amount of damage inflicted.
* @param hitbox The hitbox index.
* @param hitgroup The hitgroup index.
* @return Hacks_Continue allows shot to be made.
* 0 stops the bullet from impacting.
* @return Return ZRTools_Handled to stop bullet from hitting client.
* ZRTools_Continue to allow bullet to hit client.
*/
public DamageTraceAttack(client, inflictor, attacker, damage, hitbox, hitgroup)
public ZRTools_Action:DamageTraceAttack(client, inflictor, attacker, Float:damage, hitbox, hitgroup)
{
// Disabled
// new bool:enabled = GetConVarBool(g_hCvarsList[CVAR_ENABLE]);
// If attacker isn't valid, then stop.
if (!ZRIsClientValid(attacker))
{
return Hacks_Continue;
return ZRTools_Continue;
}
// If client is attacking himself, then stop.
if(attacker == client)
{
return Hacks_Continue;
return ZRTools_Continue;
}
// Get zombie flag for each client.
@ -131,11 +120,11 @@ public DamageTraceAttack(client, inflictor, attacker, damage, hitbox, hitgroup)
new bool:damageblockff = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_BLOCK_FF]);
if (!damageblockff)
{
return Hacks_Continue;
return ZRTools_Continue;
}
// Stop bullet from hurting client.
return 0;
return ZRTools_Handled;
}
// Here we know that attacker and client are different teams.
@ -145,7 +134,7 @@ public DamageTraceAttack(client, inflictor, attacker, damage, hitbox, hitgroup)
if (!damagehitgroups)
{
// Allow damage.
return Hacks_Continue;
return ZRTools_Continue;
}
// If damage is disabled for this hitgroup, then stop.
@ -153,11 +142,11 @@ public DamageTraceAttack(client, inflictor, attacker, damage, hitbox, hitgroup)
if (!candamage)
{
// Stop bullet from hurting client.
return 0;
return ZRTools_Handled;
}
// Allow damage.
return Hacks_Continue;
return ZRTools_Continue;
}
/**
@ -165,24 +154,16 @@ public DamageTraceAttack(client, inflictor, attacker, damage, hitbox, hitgroup)
* Called right before damage is done.
*
* @param client The client index.
* @param inflictor Entity index of damage-causing entity.
* @param attacker The client doing the damage.
* @param damage The amount of damage that will be inflicted.
* @param damagetype The type of damage done (see damage flag defines)
* @param ammotype Type of ammo attacker shot at client.
* @return Hacks_Continue allows shot to be made.
* 0 stops the bullet from doing damage.
* @param inflictor The entity index of the inflictor.
* @param attacker The client index of the attacker.
* @param damage The amount of damage inflicted.
* @param damagetype The type of damage inflicted.
* @param ammotype The ammo type of the attacker's weapon.
* @return Return ZRTools_Handled to stop the damage to client.
* ZRTools_Continue to allow damage to client.
*/
public DamageOnTakeDamage(client, inflictor, attacker, damage, damagetype, ammotype)
public ZRTools_Action:DamageOnTakeDamage(client, inflictor, attacker, Float:damage, damagetype, ammotype)
{
// Disabled.
/**
new bool:enabled = GetConVarBool(g_hCvarsList[CVAR_ENABLE]);
if (!enabled)
{
return Hacks_Continue;
}*/
// Get classname of the inflictor.
decl String:classname[64];
GetEdictClassname(inflictor, classname, sizeof(classname));
@ -190,16 +171,16 @@ public DamageOnTakeDamage(client, inflictor, attacker, damage, damagetype, ammot
// If entity is a trigger, then allow damage. (Map is damaging client)
if (StrContains(classname, "trigger") > -1)
{
return Hacks_Continue;
return ZRTools_Continue;
}
// Client was shot or knifed.
if (damagetype & DMG_BULLET)
if (damagetype & DMG_CSS_BULLET)
{
// If attacker isn't valid, then allow damage.
if (!ZRIsClientValid(attacker))
{
return Hacks_Continue;
return ZRTools_Continue;
}
// Get zombie flag for each client.
@ -209,7 +190,7 @@ public DamageOnTakeDamage(client, inflictor, attacker, damage, damagetype, ammot
// If client and attacker are on the same team, then let CS:S handle the rest.
if (clientzombie == attackerzombie)
{
return Hacks_Continue;
return ZRTools_Continue;
}
// We know that clientzombie is the opposite of attacker zombie.
@ -217,63 +198,63 @@ public DamageOnTakeDamage(client, inflictor, attacker, damage, damagetype, ammot
// If the client is a zombie, then allow damage.
if (clientzombie)
{
return Hacks_Continue;
return ZRTools_Continue;
}
// Client is about to be infected, re-add HP so they aren't killed by knife.
new health = GetClientHealth(client);
SetEntityHealth(client, health + damage);
SetEntityHealth(client, health + RoundToNearest(damage));
// Allow damage.
return Hacks_Continue;
return ZRTools_Continue;
}
// Client was damaged by explosion.
else if (damagetype & DMG_BLAST)
else if (damagetype & DMG_CSS_BLAST)
{
// If blast damage is blocked, then stop.
new bool:damageblockblast = GetConVarBool(g_hCvarsList[CVAR_DAMAGE_BLOCK_BLAST]);
if (!damageblockblast)
{
return Hacks_Continue;
return ZRTools_Continue;
}
// If attacker isn't valid, then allow damage.
if (!ZRIsClientValid(attacker))
{
return Hacks_Continue;
return ZRTools_Continue;
}
// If client is a zombie, then allow damage.
if (InfectIsClientInfected(client))
{
return Hacks_Continue;
return ZRTools_Continue;
}
// Stop damage.
return 0;
return ZRTools_Handled;
}
// Client was damaged by falling.
else if (damagetype & DMG_FALL)
else if (damagetype & DMG_CSS_FALL)
{
// If client isn't a zombie, then allow damage.
if (!InfectIsClientInfected(client))
{
return Hacks_Continue;
return ZRTools_Continue;
}
// If class has "nofalldamage" disabled, then allow damage.
new bool:blockfalldamage = ClassGetNoFallDamage(client);
if (!blockfalldamage)
{
return Hacks_Continue;
return ZRTools_Continue;
}
// Stop damage.
return 0;
return ZRTools_Handled;
}
// Allow damage.
return Hacks_Continue;
return ZRTools_Continue;
}
/**

View File

@ -209,7 +209,7 @@ RestrictWeaponUnrestrictAll()
RestrictClientInit(client)
{
// Hook "canuse" on client.
gCanUseHookID[client] = Hacks_Hook(client, HACKS_HTYPE_WEAPON_CANUSE, RestrictCanUse, false);
gCanUseHookID[client] = ZRTools_HookWeapon_CanUse(client, RestrictCanUse);
}
/**
@ -220,7 +220,7 @@ RestrictClientInit(client)
RestrictOnClientDisconnect(client)
{
// Unhook "canuse" on client.
Hacks_Unhook(gCanUseHookID[client]);
ZRTools_UnhookWeapon_CanUse(gCanUseHookID[client]);
}
/**
@ -231,8 +231,8 @@ RestrictOnClientDisconnect(client)
RestrictOnClientSpawn(client)
{
// Re-hook "canuse" on client.
Hacks_Unhook(gCanUseHookID[client]);
gCanUseHookID[client] = Hacks_Hook(client, HACKS_HTYPE_WEAPON_CANUSE, RestrictCanUse, false);
ZRTools_UnhookWeapon_CanUse(gCanUseHookID[client]);
gCanUseHookID[client] = ZRTools_HookWeapon_CanUse(client, RestrictCanUse);
}
/**
@ -868,9 +868,10 @@ RestrictGetGroupWeapons(const String:groupname[], String:weaponlist[], maxlen, c
* Hook callback, called when a player is trying to pick up a weapon.
* @param client The client index.
* @param weapon The weapon index.
* @return 0 to block weapon pickup, Hacks_Continue to allow.
* @return Return ZRTools_Handled to stop weapon pickup.
* ZRTools_Continue to allow weapon pickup.
*/
public RestrictCanUse(client, weapon, dummy1, dummy2, dummy3, dummy4)
public ZRTools_Action:RestrictCanUse(client, weapon)
{
new String:weaponname[WEAPONS_MAX_LENGTH];
GetEdictClassname(weapon, weaponname, sizeof(weaponname));
@ -881,21 +882,21 @@ public RestrictCanUse(client, weapon, dummy1, dummy2, dummy3, dummy4)
// If weapon is a knife, then allow pickup.
if (StrEqual(weaponname, "knife"))
{
return Hacks_Continue;
return ZRTools_Continue;
}
// If the weapon is restricted, then prevent pickup.
if (RestrictIsWeaponRestricted(weaponname))
{
return 0;
return ZRTools_Handled;
}
// If the player is a zombie, then prevent pickup.
if (InfectIsClientInfected(client))
{
return 0;
return ZRTools_Handled;
}
// Allow pickup.
return Hacks_Continue;
return ZRTools_Continue;
}