From 1dc1f5cefeea270bfad5de78bd457ca9be04dd47 Mon Sep 17 00:00:00 2001 From: Greyscale Date: Mon, 30 Mar 2009 21:40:56 +0200 Subject: [PATCH] Improved knockback, renamed ZTele function, changed ZStuck to reset velocity, modified velocity changing function, removed unneeded offset (basevelocity) --- src/zr/cvars.inc | 2 ++ src/zr/event.inc | 25 +++++++++++++++++++------ src/zr/offsets.inc | 45 ++++++++++++++++++++++++++++++++++++--------- src/zr/sayhooks.inc | 9 +++++++-- src/zr/teleport.inc | 2 +- src/zr/zombie.inc | 12 +++++++----- 6 files changed, 72 insertions(+), 23 deletions(-) diff --git a/src/zr/cvars.inc b/src/zr/cvars.inc index 2a2a363..96fe4d7 100644 --- a/src/zr/cvars.inc +++ b/src/zr/cvars.inc @@ -26,6 +26,7 @@ enum ZRSettings 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, @@ -111,6 +112,7 @@ CreateCvars() 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"); diff --git a/src/zr/event.inc b/src/zr/event.inc index bcc9cad..a307a02 100644 --- a/src/zr/event.inc +++ b/src/zr/event.inc @@ -304,18 +304,21 @@ public Action:PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast) if (!StrEqual(weapon, "hegrenade")) { - GetClientAbsOrigin(attacker, attackerloc); + GetPlayerEyePosition(attacker, attackerloc); - new bool:shotgun = (StrEqual(weapon, "m3") || StrEqual(weapon, "xm1014")); + new Float:attackerang[3]; + GetPlayerEyeAngles(attacker, attackerang); - KnockBack(index, clientloc, attackerloc, knockback, dmg, shotgun); + TR_TraceRayFilter(attackerloc, attackerang, MASK_ALL, RayType_Infinite, TraceRayFilter); + TR_GetEndPosition(clientloc); + + KnockBack(index, clientloc, attackerloc, knockback, dmg, false); } else { - new Float:heLoc[3]; - FindExplodingGrenade(heLoc); + FindExplodingGrenade(attackerloc); - KnockBack(index, clientloc, heLoc, knockback, dmg, true); + KnockBack(index, clientloc, attackerloc, knockback, dmg, true); } } } @@ -360,6 +363,16 @@ public Action:PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast) UpdateAlphaDamaged(index); } +public bool:TraceRayFilter(entity, contentsMask) +{ + if (entity > 0 && entity < MAXPLAYERS) + { + return false; + } + + return true; +} + FindExplodingGrenade(Float:heLoc[3]) { decl String:classname[64]; diff --git a/src/zr/offsets.inc b/src/zr/offsets.inc index 73aa1dd..42e7675 100644 --- a/src/zr/offsets.inc +++ b/src/zr/offsets.inc @@ -6,7 +6,6 @@ * ==================== */ -new offsBaseVelocity; new offsGetVelocity0; new offsGetVelocity1; new offsGetVelocity2; @@ -23,15 +22,11 @@ new offsRender; new Handle:g_hGameConf = INVALID_HANDLE; new Handle:g_hRemoveAllItems = INVALID_HANDLE; new Handle:g_hTerminateRound = INVALID_HANDLE; +new Handle:g_hEyePosition = INVALID_HANDLE; +new Handle:g_hEyeAngles = INVALID_HANDLE; FindOffsets() { - offsBaseVelocity = FindSendPropInfo("CBasePlayer", "m_vecBaseVelocity"); - if (offsBaseVelocity == -1) - { - SetFailState("Couldn't find \"m_vecBaseVelocity\"!"); - } - offsGetVelocity0 = FindSendPropInfo("CBasePlayer", "m_vecVelocity[0]"); if (offsGetVelocity0 == -1) { @@ -111,6 +106,16 @@ SetupGameData() PrepSDKCall_SetFromConf(g_hGameConf, SDKConf_Virtual, "RemoveAllItems"); g_hRemoveAllItems = EndPrepSDKCall(); + StartPrepSDKCall(SDKCall_Player); + PrepSDKCall_SetFromConf(g_hGameConf, SDKConf_Virtual, "EyePosition"); + PrepSDKCall_SetReturnInfo(SDKType_QAngle, SDKPass_ByValue); + g_hEyePosition = EndPrepSDKCall(); + + StartPrepSDKCall(SDKCall_Player); + PrepSDKCall_SetFromConf(g_hGameConf, SDKConf_Virtual, "EyeAngles"); + PrepSDKCall_SetReturnInfo(SDKType_QAngle, SDKPass_ByValue); + g_hEyeAngles = EndPrepSDKCall(); + StartPrepSDKCall(SDKCall_GameRules); PrepSDKCall_SetFromConf(g_hGameConf, SDKConf_Signature, "TerminateRound"); PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Plain); @@ -118,9 +123,21 @@ SetupGameData() g_hTerminateRound = EndPrepSDKCall(); } -SetPlayerVelocity(client, const Float:vec[3]) +SetPlayerVelocity(client, const Float:vec[3], bool:reset) { - SetEntDataVector(client, offsBaseVelocity, vec, true); + if (reset) + { + TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vec); + } + else + { + new Float:fVelocity[3]; + GetPlayerVelocity(client, fVelocity); + + AddVectors(vec, fVelocity, fVelocity); + + TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, fVelocity); + } } GetPlayerVelocity(client, Float:vel[3]) @@ -190,6 +207,16 @@ RemoveAllPlayersWeapons(client) SDKCall(g_hRemoveAllItems, client); } +GetPlayerEyePosition(client, Float:vec[3]) +{ + SDKCall(g_hEyePosition, client, vec); +} + +GetPlayerEyeAngles(client, Float:ang[3]) +{ + SDKCall(g_hEyeAngles, client, ang); +} + TerminateRound(Float:delay, reason) { if (g_hTerminateRound == INVALID_HANDLE) return; diff --git a/src/zr/sayhooks.inc b/src/zr/sayhooks.inc index 0774a06..3f867f8 100644 --- a/src/zr/sayhooks.inc +++ b/src/zr/sayhooks.inc @@ -30,6 +30,11 @@ public Action:SayCommand(client, argc) MainMenu(client); } + if (StrEqual(args, "!zadmin", false)) + { + ZRAdminMenu(client); + } + else if (StrEqual(args, "!zclass", false)) { ZClass(client); @@ -50,7 +55,7 @@ public Action:SayCommand(client, argc) StrEqual(args, "!tele", false) || StrEqual(args, "!teleport", false)) { - ZTeleClientCheck(client); + ZTele(client); } else if (StrEqual(args, "!teleabort", false)) @@ -268,7 +273,7 @@ ZStuck(client) nudge[0] = x; nudge[1] = y; - SetPlayerVelocity(client, nudge); + SetPlayerVelocity(client, nudge, true); } public Action:CollisionOn(Handle:timer, any:index) diff --git a/src/zr/teleport.inc b/src/zr/teleport.inc index e62ee2c..8561ccf 100644 --- a/src/zr/teleport.inc +++ b/src/zr/teleport.inc @@ -333,7 +333,7 @@ public Action:Command_TeleportAbort(client, argc) return Plugin_Handled; } -bool:ZTeleClientCheck(client) +bool:ZTele(client) { // Check if the teleporter is disabled. new bool:tele = GetConVarBool(gCvars[CVAR_ZTELE]); diff --git a/src/zr/zombie.inc b/src/zr/zombie.inc index cf09259..c1c5808 100644 --- a/src/zr/zombie.inc +++ b/src/zr/zombie.inc @@ -428,7 +428,7 @@ ApplyZombieAlpha(client) SetPlayerAlpha(client, alpha); } -KnockBack(client, const Float:clientloc[3], const Float:attackerloc[3], Float:power, dmg, bool:boost) +KnockBack(client, const Float:clientloc[3], const Float:attackerloc[3], Float:power, dmg, bool:grenade) { if (!IsPlayerZombie(client)) { @@ -438,18 +438,20 @@ KnockBack(client, const Float:clientloc[3], const Float:attackerloc[3], Float:po 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 (boost) + if (grenade) { - ScaleVector(vector, 4.0); + new Float:knockback_grenade = GetConVarFloat(gCvars[CVAR_ZOMBIE_KNOCKBACK_GRENADE]); + ScaleVector(vector, knockback_grenade); } - SetPlayerVelocity(client, vector); + SetPlayerVelocity(client, vector, false); } JumpBoost(client, Float:distance, Float:height) @@ -462,7 +464,7 @@ JumpBoost(client, Float:distance, Float:height) vel[1] *= distance; vel[2] = height; - SetPlayerVelocity(client, vel); + SetPlayerVelocity(client, vel, false); } PlayerLeft(client)