Jump to content

? servers

? players online

[ZE] Molotov Lag

Recommended Posts


  • Content Count:  1534
  • Joined:  07/27/09
  • Status:  Offline

Bouncing it off a wall back into the zombies.

You underestimate the ingenuity of the people trying to teamkill.

 

My idea would save the direction the moment the nade was thrown, so no matter where it lands or how it bounces it can't be abused unless the player is already behind the zombie. (like fail knife scenarios)

 

Edit: I think you what you meant is if zombie random spawns in ahead of any human, however most maps teleport the zombie to spawn anyways?

Link to comment

  • Content Count:  954
  • Joined:  05/29/12
  • Status:  Offline

My idea would save the direction the moment the nade was thrown, so no matter where it lands or how it bounces it can't be abused unless the player is already behind the zombie. (like fail knife scenarios)

 

Edit: I think you what you meant is if zombie random spawns in ahead of any human, however most maps teleport the zombie to spawn anyways?

 

I'm just gonna give an example

Let's say we're on Mines of Moria, and there's a human in the back, about to get infected. He runs over towards one of the pillars on the left, throws a nade at it so it bounces back into the group of zombies, and launches them forwards.

I made this informative graph to help you understand.

 

[ATTACH=CONFIG]14930[/ATTACH]

Link to comment

  • Content Count:  1534
  • Joined:  07/27/09
  • Status:  Offline

I'm just gonna give an example

Let's say we're on Mines of Moria, and there's a human in the back, about to get infected. He runs over towards one of the pillars on the left, throws a nade at it so it bounces back into the group of zombies, and launches them forwards.

I made this informative graph to help you understand.

 

[ATTACH=CONFIG]14930[/ATTACH]

 

Well if he is infected before the grenade explodes it won't do anything anyways.

 

But heres a possible fix - As the grenade explodes check that its location is within 180 degrees ahead of where the player was originally facing... ?

 

11gmxyf.jpg

Edited by Wesker
Link to comment

  • Content Count:  1592
  • Joined:  03/16/12
  • Status:  Offline

I don't know if that's possible but can't we just simply reduce the movement speed for a certain amount of time for the zombies affected by the blast radius of a he grenade? At the moment the slowdown is applied with each molotov hit, but i don't know if the he spam would cause less lag. Of course this idea might be retarded, but just my thoughts.

Link to comment

  • Content Count:  1534
  • Joined:  07/27/09
  • Status:  Offline

I don't know if that's possible but can't we just simply reduce the movement speed for a certain amount of time for the zombies affected by the blast radius of a he grenade? At the moment the slowdown is applied with each molotov hit, but i don't know if the he spam would cause less lag. Of course this idea might be retarded, but just my thoughts.

 

This would still require either a timer or event to track the time of the slow.

 

 

Also apparently my solution would require calculus level math which I haven't quite figured out...

 

http://stackoverflow.com/questions/13221873/determining-if-one-2d-vector-is-to-the-right-or-left-of-another/13221874

 

http://gamedev.stackexchange.com/questions/18995/check-if-the-vector-is-behind-another-or-maybe-opposite-directions

Link to comment

  • Content Count:  1396
  • Joined:  09/14/12
  • Status:  Offline

Bump, started work on the plugin http://pastebin.com/59CM5Sva

 

If anyone wants to take a look and help out please let me know :)

 

ewwww old syntax

 

any reason your doing this

 

public OnEntityCreated(entity, const String:classname[]){
   //Hook the entity
   SDKHook(entity, SDKHook_SpawnPost, OnEntitySpawned);
}

public OnEntitySpawned(entity)
{
   //Is the plugin enabled? Otherwise dont continue
   if (!GetConVarBool(Enabled))
   {
       return;
   }
  
   decl String:class_name[32];
   GetEdictClassname(entity, class_name, 32);
   new owner = GetEntPropEnt(entity, Prop_Data, "m_hOwnerEntity"); //The client
  
   //Is the entity a projectile? This ignores weapon spawns
   if(StrContains(class_name, "projectile") != -1 && IsValidEntity(entity))
   {
       //Is the projectile an hegrenade?
       if(StrContains(class_name, "hegrenade") != -1)
       {
      
           //Get the clients angles and position
           decl Float:pEyePosition[3], Float:pEyeAngle[3];
           GetClientEyePosition(owner, pEyePosition);
           GetClientEyeAngles(owner, pEyeAngle);
          
           //To be completed, put these in a hash using client as key
          
           //Print to chat for debugging purposes
           PrintToChatAll( "[sM]%N: My horizontal position is %f %f", owner, pEyePosition[0], pEyePosition[1]);
           PrintToChatAll( "[sM]%N: My horizontal angles are %f %f", owner, pEyeAngle[0], pEyeAngle[1]);
       }
   }
}

 

 

over this

 

public OnEntityCreated(entity, const String:classname[])
{
   //Is the plugin enabled? Otherwise dont continue
   if (!GetConVarBool(Enabled))
   {
       return;
   }
  
   decl String:class_name[32];
   GetEdictClassname(entity, class_name, 32);
   new owner = GetEntPropEnt(entity, Prop_Data, "m_hOwnerEntity"); //The client
  
   //Is the entity a projectile? This ignores weapon spawns
   if(StrContains(class_name, "projectile") != -1 && IsValidEntity(entity))
   {
       //Is the projectile an hegrenade?
       if(StrContains(class_name, "hegrenade") != -1)
       {
      
           //Get the clients angles and position
           decl Float:pEyePosition[3], Float:pEyeAngle[3];
           GetClientEyePosition(owner, pEyePosition);
           GetClientEyeAngles(owner, pEyeAngle);
          
           //To be completed, put these in a hash using client as key
          
           //Print to chat for debugging purposes
           PrintToChatAll( "[sM]%N: My horizontal position is %f %f", owner, pEyePosition[0], pEyePosition[1]);
           PrintToChatAll( "[sM]%N: My horizontal angles are %f %f", owner, pEyeAngle[0], pEyeAngle[1]);
       }
   }
}

 

 

doesn't really matter but yeahhh.

 

Edit: Also here is 1 fix of you forgetting to hook into the player_hurt event(I'm guessing thats what you are doing) + updated to 1.7 syntax if u want it cause I'm bored http://pastebin.com/hbcEnTGM @Agent Wesker

 

I think I might be bored

  • Like 1
Edited by R3TROATTACK
boredom
Link to comment

  • Content Count:  1534
  • Joined:  07/27/09
  • Status:  Offline

I copied that from another plugin, if it works without the SDKHook then that's good I guess.

 

As for the syntax, this would be the first time I'm working with sourcemod, literally learned all this today.

 

Edit: I will post any updates to the plugin in first post.

Edited by Wesker
Link to comment

  • Content Count:  1534
  • Joined:  07/27/09
  • Status:  Offline

Alright I believe it's finished.

 

@R3TROATTACK can you please review my code for any major problems or changes

 

 

#include 
#include 
#include 

//Create ConVar handles
ConVar g_ConVar_Enabled;
ConVar g_ConVar_Debug;
ConVar g_ConVar_vKnockback;
ConVar g_ConVar_hKnockback;
//Separate ConVar variables to prevent looping in hooks
bool g_Enabled = true;
bool g_Debug = false;
float g_vKnockback = 1.0;
float g_hKnockback = 1.0;
//Create our hash map handles
StringMap hMapDirection;
StringMap hMapOrigin;

public Plugin myinfo =  {
name = "Nade_Kick",
author = "AgentWesker",
description = "Zombie knockback plugin.",
version = "0.0.1",
url = "http://steam-gamers.net"
};

public void OnPluginStart()
{
//Enabled ConVar
g_ConVar_Enabled = CreateConVar("sm_nadekick_enabled", "1", "Enable/Disable the plugin. Enable = 1", _, true, 0.0, true, 1.0);
g_Enabled = GetConVarBool(g_ConVar_Enabled);
HookConVarChange(g_ConVar_Enabled, OnEnabledChanged);

//Debug ConVar
g_ConVar_Debug = CreateConVar("sm_nadekick_debug", "0", "Print debug to chat. Enable = 1", _, true, 0.0, true, 1.0);
g_Debug = GetConVarBool(g_ConVar_Debug);
HookConVarChange(g_ConVar_Debug, OnDebugChanged);

//Knockback ConVars
g_ConVar_vKnockback = CreateConVar("sm_nadekick_vknockback", "1.0", "Vertical knockback multiplier. Default = 1", _, true, 0.1, true, 30.0);
g_ConVar_hKnockback = CreateConVar("sm_nadekick_hknockback", "1.0", "Horizontal knockback multiplier. Default = 1", _, true, 0.1, true, 30.0);
g_vKnockback = GetConVarFloat(g_ConVar_vKnockback);
g_hKnockback = GetConVarFloat(g_ConVar_hKnockback);
HookConVarChange(g_ConVar_vKnockback, OnVerKnockbackChanged);
HookConVarChange(g_ConVar_hKnockback, OnHorKnockbackChanged);

//Hook event to handle nade damage
HookEvent("player_hurt", Event_HandleNadeDamage);

//Create our hash maps
hMapDirection = new StringMap();
hMapOrigin = new StringMap();

//Execute the config and create if not yet made
AutoExecConfig(true, "nade_kick");
}

public void OnPluginEnd()
{
//Close the handle if the plugin unloads
delete hMapDirection;
delete hMapOrigin;
}

public OnEnabledChanged(Handle:cvar, const String:oldVal[], const String:newVal[])
{
if(StringToInt(newVal) == 1) {
	g_Enabled = true;
} else {
	g_Enabled = false;
}
}

public OnDebugChanged(Handle:cvar, const String:oldVal[], const String:newVal[])
{
if(StringToInt(newVal) == 1) {
	g_Debug = true;
} else {
	g_Debug = false;
}
}

public OnVerKnockbackChanged(Handle:cvar, const String:oldVal[], const String:newVal[])
{
g_vKnockback = StringToFloat(newVal);
}

public OnHorKnockbackChanged(Handle:cvar, const String:oldVal[], const String:newVal[])
{
g_hKnockback = StringToFloat(newVal);
}

public void OnEntityCreated(int entity, const char[] classname)
{
//Hook the entity, we must wait until post spawn
SDKHook(entity, SDKHook_SpawnPost, OnEntitySpawned);
}

public void OnEntitySpawned(int entity)
{
//Is the plugin enabled? Otherwise don't continue
if (!g_Enabled) {
	return;
}
  
char class_name[32];
GetEdictClassname(entity, class_name, 32);
int owner = GetEntPropEnt(entity, Prop_Data, "m_hOwnerEntity"); //The client
  
//Is the entity a projectile? This ignores weapon spawns
if (StrContains(class_name, "projectile", false) != -1 && IsValidEntity(entity))
{
	//Is the projectile an hegrenade?
	if (StrContains(class_name, "hegrenade") != -1)
	{
		//Get players origin and grenade origin then draw new vector
		float pEyeOrigin[3], gOrigin[3], pgVector[3];
		GetClientEyePosition(owner, pEyeOrigin); //Player origin		   
		GetEntPropVector(entity, Prop_Send, "m_vecOrigin", gOrigin); //Grenade origin
		
		//Find the directional vector
		MakeVectorFromPoints(pEyeOrigin, gOrigin, pgVector); //Draw player grenade vector
		NormalizeVector(pgVector, pgVector); //Clamp vector to 1 unit
		
		//Save pgVector to hash
		char ownerStr[12];
		IntToString(owner, ownerStr, 12);
		hMapDirection.SetArray(ownerStr, pgVector, 3, true);
		hMapOrigin.SetArray(ownerStr, pEyeOrigin, 3, true);
		
		//For debugging purposes only
		if (g_Debug) {
			float pgAngles[3];
			GetVectorAngles(pgVector, pgAngles);
			
			//Print to chat for debugging purposes
			PrintToChatAll("[sM]%N: My horizontal position is %f %f", owner, pEyeOrigin[0], pEyeOrigin[1]);
			PrintToChatAll("[sM]%N: My horizontal angles are %f %f", owner, pgAngles[0], pgAngles[1]);
		}
	}
}
}

public void Event_HandleNadeDamage(Event event, const char[] name, bool dontBroadcast)
{
//Stop if disabled
if (!g_Enabled) {
	return;
}

//Get client of attacker and victim
int victim = GetClientOfUserId(event.GetInt("userid"));
int attacker = GetClientOfUserId(event.GetInt("attacker"));

//Stop if attacker is dead
if(!IsPlayerAlive(attacker)) {
	return;
}

//Get damage value for knockback
float damage = float(event.GetInt("dmg_health"));

char weapon[32];
event.GetString("weapon", weapon, 32);

// If the player is a zombie and it is hurt with a grenade
if (GetClientTeam(victim) == 2 && StrEqual("weapon_hegrenade", weapon, false)) {

	//Initialize vector handles
	float victimOrigin[3], pEyeOrigin[3], pgVector[3], pvVector[3];
	
	//Use client index as key and grab pgVector from hash
	char attackerStr[12];
	IntToString(attacker, attackerStr, 12);
	
	//Check that hash values return successfully otherwise call the cops
	if (!hMapDirection.GetArray(attackerStr, pgVector, 3, _))
		ThrowError("Attacker has no direction vector!");
	if (!hMapOrigin.GetArray(attackerStr, pEyeOrigin, 3, _))
		ThrowError("Attacker has no origin vector!");
	
	//Get the origin vector for victim (nade is gone by this point)
	GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victimOrigin);
	
	//Make new vector from player to victim
	MakeVectorFromPoints(pEyeOrigin, victimOrigin, pvVector);
	NormalizeVector(pvVector, pvVector);
	
	//Get the dot product from these two vectors and check angle is over 90 degrees
	float dot = GetVectorDotProduct(pgVector, pvVector); //Get initial dot product
	dot = (dot / FloatMul(GetVectorLength(pvVector, true), GetVectorLength(pgVector, true))); //Divide by vector magnitude
	float vectorAngle = RadToDeg(ArcCosine(dot)); //Get angle in radians, then convert to degrees

	if (g_Debug) {
		PrintToChatAll("[sM]Nade Kick: %N victim angle is %f", attacker, vectorAngle);
	}
	
	//Check if victim is behind attacker
	if (vectorAngle 			//Scale original values to maintain direction
		ScaleVector(pgVector, g_hKnockback); //Scale by multiplier
		ScaleVector(pgVector, damage); //Scale by damage
	} else {
		//Only go vertical
		pgVector[0] = 0.0;
		pgVector[1] = 0.0;
	}
	
	pgVector[2] = FloatMul(g_vKnockback, damage); //Set vertical velocity
   
	// Apply the directional push
	TeleportEntity(victim, NULL_VECTOR, NULL_VECTOR, pgVector);
}
}


 

 

If everything looks good will compile and give to @Crazy Swede for testing.

Edited by Wesker
Link to comment

Reply to Thread

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...