Removed antistick nudge on infect, disabled zadmin menu items that are under construction, added knockback module, and weapon-specific knockback multipliers in weapons.txt

This commit is contained in:
Greyscale 2009-04-14 22:05:20 +02:00
parent 9031facaec
commit ddf0515a9e
11 changed files with 259 additions and 155 deletions

View File

@ -6,6 +6,7 @@
// {
// "restrict" "no" (default) // Restricts the weapon on each map start
// "menu" "yes" (default) // Allows admins to toggle restriction with the menu
// "knockback" "1.0" (default) // The knockback multiplier for the weapon
// }
//
// Notes:
@ -24,164 +25,191 @@
{
"Glock"
{
//"restrict" "no"
"restrict" "no"
"menu" "yes"
"knockback" "0.8"
}
"USP"
{
"restrict" "no"
//"menu" "yes"
"menu" "yes"
"knockback" "0.8"
}
"P228"
{
//"restrict" "no"
//"menu" "yes"
"restrict" "no"
"menu" "yes"
"knockback" "1.0"
}
"Deagle"
{
"restrict" "no"
"menu" "yes"
"knockback" "1.2"
}
"Elite"
{
"restrict" "no"
"menu" "yes"
"knockback" "1.0"
}
"Fiveseven"
{
"restrict" "no"
"menu" "yes"
"knockback" "1.0"
}
"M3"
{
"restrict" "no"
"menu" "yes"
"knockback" "0.8" // Remember that there are 8 pellets in 1 shot.
}
"XM1014"
{
"restrict" "no"
"menu" "yes"
"knockback" "0.8" // See above comment.
}
"Mac10"
{
"restrict" "no"
"menu" "yes"
"knockback" "1.0"
}
"TMP"
{
"restrict" "no"
"menu" "yes"
"knockback" "1.0"
}
"MP5Navy"
{
"restrict" "no"
"menu" "yes"
"knockback" "1.0"
}
"UMP45"
{
"restrict" "no"
"menu" "yes"
"knockback" "1.0"
}
"P90"
{
"restrict" "no"
"menu" "yes"
"knockback" "1.0"
}
"Galil"
{
"restrict" "no"
"menu" "yes"
"knockback" "1.0"
}
"Famas"
{
"restrict" "no"
"menu" "yes"
"knockback" "1.0"
}
"AK47"
{
"restrict" "no"
"menu" "yes"
"knockback" "1.2"
}
"M4A1"
{
"restrict" "no"
"menu" "yes"
"knockback" "1.1"
}
"SG552"
{
"restrict" "no"
"menu" "yes"
"knockback" "1.0"
}
"AUG"
{
"restrict" "no"
"menu" "yes"
"knockback" "1.1"
}
"Scout"
{
"restrict" "no"
"menu" "yes"
"knockback" "1.5"
}
"SG550"
{
"restrict" "yes"
"menu" "yes"
"knockback" "1.3"
}
"G3SG1"
{
"restrict" "yes"
"menu" "yes"
"knockback" "1.3"
}
"AWP"
{
"restrict" "yes"
"menu" "yes"
"knockback" "1.8"
}
"M249"
{
"restrict" "yes"
"menu" "yes"
"knockback" "1.2"
}
"hegrenade"
{
"restrict" "no"
"menu" "yes"
"knockback" "6.0"
}
"flashbang"
{
"restrict" "yes"
"menu" "no"
"knockback" "100.0"
}
"smokegrenade"
{
"restrict" "yes"
"menu" "no"
"knockback" "100.0"
}
"NVGs"

View File

@ -37,6 +37,9 @@
// Weapons
#include "zr/weapons/weapons"
// Knockback
#include "zr/knockback"
#include "zr/zadmin"
#include "zr/damagecontrol"
#include "zr/commands"
@ -153,6 +156,7 @@ public OnConfigsExecuted()
if (FileExists(path))
{
ServerCommand("exec %s", mapconfig);
if (LogFlagCheck(LOG_CORE_EVENTS))
{
LogMessage("Executed map config file: %s", mapconfig);

View File

@ -47,44 +47,6 @@ AntiStickReset()
tAntiStick = INVALID_HANDLE;
}
/**
* Pushes a player away from another to prevent sticking. (Used on infect)
*
* @param attacker The player to push away.
* @param client The client to push player away from.
*/
AntiStick(attacker, client)
{
// Validate player is valid client and in-game
if (!attacker || !IsClientInGame(attacker))
{
return;
}
// Retrieve cvar value for force of the push, if 0 is returned, stop function
new Float:force = GetConVarFloat(gCvars[CVAR_INFECT_ANTISTICK_FORCE]);
if (force == 0.0)
{
return;
}
new Float:vector[3];
new Float:attackerloc[3];
new Float:clientloc[3];
GetClientAbsOrigin(attacker, attackerloc);
GetClientAbsOrigin(client, clientloc);
MakeVectorFromPoints(attackerloc, clientloc, vector);
NormalizeVector(vector, vector);
ScaleVector(vector, force);
// Push player
TeleportEntity(attacker, NULL_VECTOR, NULL_VECTOR, vector);
}
/**
* Checks if a player is currently stuck within another player
*

View File

@ -96,7 +96,7 @@ LoadClassData()
arrayClasses[classCount][data_speed] = KvGetFloat(kvClasses, "speed"), GetConVarFloat(gCvars[CVAR_ZOMBIE_SPEED]);
arrayClasses[classCount][data_jump_distance] = KvGetFloat(kvClasses, "jump_distance"), GetConVarFloat(gCvars[CVAR_ZOMBIE_JUMP_DISTANCE]);
arrayClasses[classCount][data_jump_height] = KvGetFloat(kvClasses, "jump_height"), GetConVarFloat(gCvars[CVAR_ZOMBIE_JUMP_HEIGHT]);
arrayClasses[classCount][data_knockback] = KvGetFloat(kvClasses, "knockback"), GetConVarFloat(gCvars[CVAR_ZOMBIE_KNOCKBACK]);
arrayClasses[classCount][data_knockback] = KvGetFloat(kvClasses, "knockback");
arrayClasses[classCount][data_nvgs] = KvGetNum(kvClasses, "nvgs"), GetConVarInt(gCvars[CVAR_ZOMBIE_NVGS]);
arrayClasses[classCount][data_fov] = KvGetNum(kvClasses, "fov"), GetConVarInt(gCvars[CVAR_ZOMBIE_FOV]);
arrayClasses[classCount][data_regen] = bool:KvGetNum(kvClasses, "regen"), GetConVarBool(gCvars[CVAR_ZOMBIE_REGEN]);

View File

@ -264,7 +264,8 @@ public Action:Command_KnockbackMMenu(client, argc)
{
if (IsClientPlayer(client))
{
ZRKnockbackMMenu(client);
// Disabled, under construction.
// ZRKnockbackMMenu(client);
}
else
{

View File

@ -27,8 +27,6 @@ enum ZRSettings
Handle:CVAR_ZOMBIE_SPEED,
Handle:CVAR_ZOMBIE_JUMP_DISTANCE,
Handle:CVAR_ZOMBIE_JUMP_HEIGHT,
Handle:CVAR_ZOMBIE_KNOCKBACK,
Handle:CVAR_ZOMBIE_KNOCKBACK_GRENADE,
Handle:CVAR_ZOMBIE_NVGS,
Handle:CVAR_ZOMBIE_FOV,
Handle:CVAR_ZOMBIE_REGEN,
@ -118,8 +116,6 @@ CreateCvars()
gCvars[CVAR_ZOMBIE_SPEED] = CreateConVar("zr_zombie_speed", "350", "How fast zombies travel (300: Default speed, 600: Double speed)");
gCvars[CVAR_ZOMBIE_JUMP_DISTANCE] = CreateConVar("zr_zombie_jump_distance", "0.1", "How far the zombie jumps, (0: Regular jump distance)");
gCvars[CVAR_ZOMBIE_JUMP_HEIGHT] = CreateConVar("zr_zombie_jump_height", "10.0", "How high a zombie jumps (0: Regular jump height)");
gCvars[CVAR_ZOMBIE_KNOCKBACK] = CreateConVar("zr_zombie_knockback", "1", "How far zombies are pushed back when shot. If classes are enabled: This one is a multiplier for class knockback values (1: Default)");
gCvars[CVAR_ZOMBIE_KNOCKBACK_GRENADE] = CreateConVar("zr_zombie_knockback_grenade", "4.0", "Knockback multiplier when a grenade inflicts damage on a zombie. (4.0: Default)");
gCvars[CVAR_ZOMBIE_NVGS] = CreateConVar("zr_zombie_nvgs", "-1", "Zombies will be equipped with nightvision. Also used to override class nvgs if non-negative. (-1: No override, uses class setting, 0: No nvgs, 1: Nvgs on)");
gCvars[CVAR_ZOMBIE_FOV] = CreateConVar("zr_zombie_fov", "110", "The field of vision of zombies (90: Default vision)");
gCvars[CVAR_ZOMBIE_REGEN] = CreateConVar("zr_zombie_regen", "0", "Zombies will regenerate health");

View File

@ -252,11 +252,14 @@ public Action:PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
new index = GetClientOfUserId(GetEventInt(event, "userid"));
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
new dmg = GetEventInt(event, "dmg_health");
new dmg_health = GetEventInt(event, "dmg_health");
decl String:weapon[32];
GetEventString(event, "weapon", weapon, sizeof(weapon));
// Forward event to modules.
KnockbackPlayerHurt(index, attacker, weapon, dmg_health);
// Check if the attacker is a player.
if (attacker != 0)
{
@ -269,41 +272,6 @@ public Action:PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
Zombify(index, attacker);
}
}
// Check if a human attacks a zombie.
if (IsPlayerZombie(index) && IsPlayerHuman(attacker))
{
// Get zombie knockback value.
new Float:knockback = ClassGetKnockback(index);
new Float:clientloc[3];
new Float:attackerloc[3];
GetClientAbsOrigin(index, clientloc);
// Check if a grenade was thrown.
if (StrEqual(weapon, "hegrenade"))
{
// Get the location of the grenade.
FindExplodingGrenade(attackerloc);
// Give knockback on the victim.
KnockBack(index, clientloc, attackerloc, knockback, dmg, true);
}
else
{
GetPlayerEyePosition(attacker, attackerloc);
new Float:attackerang[3];
GetPlayerEyeAngles(attacker, attackerang);
// Calculate victim location.
TR_TraceRayFilter(attackerloc, attackerang, MASK_ALL, RayType_Infinite, TraceRayFilter);
TR_GetEndPosition(clientloc);
KnockBack(index, clientloc, attackerloc, knockback, dmg, false);
}
}
}
// Check if the player is a human.
@ -337,41 +305,6 @@ public Action:PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
UpdateHPDisplay(index);
}
public bool:TraceRayFilter(entity, contentsMask)
{
if (entity > 0 && entity < MAXPLAYERS)
{
return false;
}
return true;
}
FindExplodingGrenade(Float:heLoc[3])
{
decl String:classname[64];
new maxentities = GetMaxEntities();
for (new x = GetMaxClients(); x <= maxentities; x++)
{
if (IsValidEdict(x))
{
GetEdictClassname(x, classname, sizeof(classname));
if (StrEqual(classname, "hegrenade_projectile"))
{
new takedamage = GetEntProp(x, Prop_Data, "m_takedamage");
if (takedamage == 0)
{
GetEntPropVector(x, Prop_Send, "m_vecOrigin", heLoc);
return x;
}
}
}
}
return -1;
}
public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
new index = GetClientOfUserId(GetEventInt(event, "userid"));

167
src/zr/knockback.inc Normal file
View File

@ -0,0 +1,167 @@
/**
* ====================
* Zombie:Reloaded
* File: knockback.inc
* Author: Greyscale
* ====================
*/
/**
* @section Player hitgroup values.
*/
#define HITGROUP_GENERIC 0
#define HITGROUP_HEAD 1
#define HITGROUP_CHEST 2
#define HITGROUP_STOMACH 3
#define HITGROUP_LEFTARM 4
#define HITGROUP_RIGHTARM 5
#define HITGROUP_LEFTLEG 6
#define HITGROUP_RIGHTLEG 7
#define HITGROUP_GEAR 10
/**
* @endsection
*/
/** Player hurt event
* @param client The victim index. (zombie)
* @param attacker The attacker index. (human)
* @param weapon The weapon used.
* @param dmg_health Damage done.
*/
KnockbackPlayerHurt(client, attacker, const String:weapon[], dmg_health)
{
// Check if the attacker is a player.
if (attacker != 0)
{
// Check if a human attacks a zombie.
if (IsPlayerZombie(client) && IsPlayerHuman(attacker))
{
// Get zombie knockback value.
new Float:knockback = ClassGetKnockback(client);
new Float:clientloc[3];
new Float:attackerloc[3];
GetClientAbsOrigin(client, clientloc);
// Check if a grenade was thrown.
if (StrEqual(weapon, "hegrenade"))
{
// Get the location of the grenade.
if (KnockbackFindExplodingGrenade(attackerloc) == -1)
{
// If the grenade wasn't found, then stop.
return;
}
}
else
{
// Get attackers eye position.
GetPlayerEyePosition(attacker, attackerloc);
// Get attackers eye angles.
new Float:attackerang[3];
GetPlayerEyeAngles(attacker, attackerang);
// Calculate knockback end-vector.
TR_TraceRayFilter(attackerloc, attackerang, MASK_ALL, RayType_Infinite, KnockbackTRFilter);
TR_GetEndPosition(clientloc);
}
// Apply damage knockback multiplier
knockback *= float(dmg_health);
// Retrieve weapon knockback boost.
new Float:boostWeapon = WeaponGetWeaponKnockback(weapon);
// Apply weapon knockback multiplier.
knockback *= boostWeapon;
// Apply knockback.
KnockbackSetVelocity(client, attackerloc, clientloc, knockback);
}
}
}
/**
* Sets velocity on a player.
* @param client The client index.
* @param startpoint The starting coordinate to push from.
* @param endpoint The ending coordinate to push towards.
* @param magnitude Magnitude of the push.
*/
KnockbackSetVelocity(client, const Float:startpoint[3], const Float:endpoint[3], Float:magnitude)
{
// Create vector from the given starting and ending points.
new Float:vector[3];
MakeVectorFromPoints(startpoint, endpoint, vector);
// Normalize the vector (equal magnitude at varying distances).
NormalizeVector(vector, vector);
// Apply the magnitude by scaling the vector (multiplying each of its components).
ScaleVector(vector, magnitude);
// ADD the given vector to the clients current velocity.
SetPlayerVelocity(client, vector, false);
}
/**
* Trace Ray forward, used as a filter to continue tracing if told so. (See sdktools_trace.inc)
* @param entity The entity index.
* @param contentsMask The contents mask.
* @return True to allow hit, false to continue tracing.
*/
public bool:KnockbackTRFilter(entity, contentsMask)
{
// If entity is a player, continue tracing.
if (entity > 0 && entity < MAXPLAYERS)
{
return false;
}
// Allow hit.
return true;
}
/**
* Find the location of an exploding grenade (currently inflicting damage in player_hurt).
* @param heLoc The location of the exploding grenade.
* @return The entity index of the grenade.
*/
KnockbackFindExplodingGrenade(Float:heLoc[3])
{
decl String:classname[64];
// Find max entities and loop through all of them.
new maxentities = GetMaxEntities();
for (new x = MaxClients; x <= maxentities; x++)
{
// If entity is invalid, then stop.
if (!IsValidEdict(x))
{
continue;
}
// If entity isn't a grenade, then stop.
GetEdictClassname(x, classname, sizeof(classname));
if (!StrEqual(classname, "hegrenade_projectile", false))
{
continue;
}
// If m_takedamage is set to 0, we found our grenade.
new takedamage = GetEntProp(x, Prop_Data, "m_takedamage");
if (takedamage == 0)
{
// Return its location.
GetEntPropVector(x, Prop_Send, "m_vecOrigin", heLoc);
// Return its entity index.
return x;
}
}
// Didn't find the grenade.
return -1;
}

View File

@ -114,9 +114,11 @@ WeaponsOnClientDisconnect(client)
*/
WeaponsCreateWeaponArray(&Handle:arrayWeapons, maxlen = WEAPONS_MAX_LENGTH)
{
// Initialize array handle.
arrayWeapons = CreateArray(maxlen);
new count = 0;
// Reset keyvalue's traveral stack.
KvRewind(kvWeapons);
if (KvGotoFirstSubKey(kvWeapons))
{
@ -126,11 +128,15 @@ WeaponsCreateWeaponArray(&Handle:arrayWeapons, maxlen = WEAPONS_MAX_LENGTH)
{
KvGetSectionName(kvWeapons, weapon, maxlen);
// Push weapon name into the array
PushArrayString(arrayWeapons, weapon);
// Increment count.
count++;
} while (KvGotoNextKey(kvWeapons));
}
// Return the count
return count;
}
@ -193,6 +199,7 @@ WeaponGetDisplayName(const String:weapon[], String:display[])
*/
bool:WeaponsIsWeaponMenu(const String:weapon[])
{
// Reset keyvalue's traversal stack.
KvRewind(kvWeapons);
if (KvGotoFirstSubKey(kvWeapons))
{
@ -203,14 +210,44 @@ bool:WeaponsIsWeaponMenu(const String:weapon[])
{
KvGetSectionName(kvWeapons, validweapon, sizeof(validweapon));
// If this is the right weapon, then return setting for it.
if (StrEqual(validweapon, weapon, false))
{
KvGetString(kvWeapons, "menu", menu, sizeof(menu), "yes");
// Return weapon's setting.
return ConfigSettingToBool(menu);
}
} while (KvGotoNextKey(kvWeapons));
}
return false;
}
/**
* Returns knockback multiplier of the weapon
* @param weapon The weapon name.
* @return The float value of the knockback multiplier, 1.0 if not found.
*/
Float:WeaponGetWeaponKnockback(const String:weapon[])
{
// Reset keyvalue's traversal stack.
KvRewind(kvWeapons);
if (KvGotoFirstSubKey(kvWeapons))
{
decl String:validweapon[WEAPONS_MAX_LENGTH];
do
{
KvGetSectionName(kvWeapons, validweapon, sizeof(validweapon));
// If this is the right weapon, then return setting for it.
if (StrEqual(validweapon, weapon, false))
{
return KvGetFloat(kvWeapons, "knockback", 1.0);
}
} while (KvGotoNextKey(kvWeapons));
}
return 1.0;
}

View File

@ -42,12 +42,12 @@ bool:ZRAdminMenu(client)
Format(weapons, sizeof(weapons), "%t", "!zadmin main weapons");
Format(logflags, sizeof(logflags), "%t", "!zadmin main logflags");
AddMenuItem(menu_zadmin, "knockbackm", knockbackm);
AddMenuItem(menu_zadmin, "knockback", knockback);
AddMenuItem(menu_zadmin, "nvgs", nvgs);
AddMenuItem(menu_zadmin, "knockbackm", knockbackm, ITEMDRAW_DISABLED);
AddMenuItem(menu_zadmin, "knockback", knockback, ITEMDRAW_DISABLED);
AddMenuItem(menu_zadmin, "nvgs", nvgs, ITEMDRAW_DISABLED);
AddMenuItem(menu_zadmin, "infect", infect);
AddMenuItem(menu_zadmin, "zspawn", zspawn);
AddMenuItem(menu_zadmin, "ztele", ztele);
AddMenuItem(menu_zadmin, "ztele", ztele, ITEMDRAW_DISABLED);
AddMenuItem(menu_zadmin, "weapons", weapons);
AddMenuItem(menu_zadmin, "logflags", logflags);
@ -66,15 +66,15 @@ public ZRAdminMenuHandle(Handle:menu_admin, MenuAction:action, client, slot)
{
case 0:
{
ZRKnockbackMMenu(client);
//ZRKnockbackMMenu(client);
}
case 1:
{
ZRClassSelectMenu(client);
//ZRClassSelectMenu(client);
}
case 2:
{
ZRNVGSMenu(client);
//ZRNVGSMenu(client);
}
case 3:
{
@ -112,7 +112,10 @@ public ZRAdminMenuHandle(Handle:menu_admin, MenuAction:action, client, slot)
}
}
ZRKnockbackMMenu(client)
/**
* Needs to be recoded to support new modules.
*/
/*ZRKnockbackMMenu(client)
{
new Handle:menu_knockbackm = CreateMenu(ZRKnockbackMHandle);
new Float:curknockback = GetConVarFloat(gCvars[CVAR_ZOMBIE_KNOCKBACK]);
@ -352,7 +355,7 @@ public ZRNVGSHandle(Handle:menu_nvgs, MenuAction:action, client, slot)
{
CloseHandle(menu_nvgs);
}
}
}*/
ZRInfectMenu(client)
{

View File

@ -308,7 +308,6 @@ Zombify(client, attacker = -1, bool:motherinfect = false)
// Forward event to modules.
ClassOnClientInfected(client);
AbortTeleport(client);
AntiStick(attacker, client);
// Apply effects.
InfectionEffects(client);
@ -390,32 +389,6 @@ InfectionEffects(client)
}
}
KnockBack(client, const Float:clientloc[3], const Float:attackerloc[3], Float:power, dmg, bool:grenade)
{
if (!IsPlayerZombie(client))
{
return;
}
new Float:vector[3];
MakeVectorFromPoints(attackerloc, clientloc, vector);
NormalizeVector(vector, vector);
vector[0] *= power * (float(dmg) * 1.5);
vector[1] *= power * (float(dmg) * 1.5);
vector[2] *= power * (float(dmg) * 1.5);
if (grenade)
{
new Float:knockback_grenade = GetConVarFloat(gCvars[CVAR_ZOMBIE_KNOCKBACK_GRENADE]);
ScaleVector(vector, knockback_grenade);
}
SetPlayerVelocity(client, vector, false);
}
JumpBoost(client, Float:distance, Float:height)
{
new Float:vel[3];