Awhile ago I posted a thread asking for help in creating a midair mod. I got very helpful responses and was able to create a semi-functional script thanks to the help of the replies.
After messing around with the script for a while, I began to see an important issue. If the player being shot at is any distance from the ground, even only 1cm, the player will still be instagibbed. What I need to do is create a minimum height for the rocket to do damage but I don't know how.
This script is very messy and poorly written because it is my first pawn script and I have no prior experience in any similar languages. Most of it is copied from scripts posted on this forum so thank you to the original authors. It also relies on the edited soldier ctx file which makes rockets do 250 damage, among other things.
Also, if there is any way to increase the force of rockets other then the secret console commands that would be great. Currently, the force seems to be maxed out via the console commands and I am just wondering if I could increase the force via other means.
Code:
#include <sourcemod>
#include <dukehacks>
#define PLUGIN_VERSION "6.1"
public Plugin:myinfo =
{
name = "midair",
author = "matt",
description = "air shots only",
version = PLUGIN_VERSION,
url = ""
}
new Handle:cvDmgMult = INVALID_HANDLE;
// Hook events
public OnPluginStart()
{
dhAddClientHook(HK_TraceAttack, TraceAttackHook);
HookEvent("player_hurt", Event_PlayerHurt);
}
// Air shot damage ONLY
public Action:TraceAttackHook(client, attacker, inflictor, Float:damage, &Float:multiplier)
{
new entvalue
new m_Offset
m_Offset=FindSendPropOffs("CTFPlayer","m_hGroundEntity")
//client = GetClientOfUserId(GetEventInt(event,"userid"))
entvalue=GetEntData(client,m_Offset,4)
if(entvalue > -1.000000009)
{
multiplier *= 0.001;
return Plugin_Changed;
}
else
{
multiplier *= 4.0;
return Plugin_Changed;
}
}
// Remove fall damage
public Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
new victim = GetClientOfUserId(GetEventInt(event,"userid"));
new attacker = GetClientOfUserId(GetEventInt(event,"attacker"));
if(victim > 0 && IsClientInGame(victim) & FL_ONGROUND)
{
new victimLost = GetEventInt(event,"damage");
new victimHealth = GetEventInt(event,"health") + victimLost;
new shealth = 200 - victimLost
if(IsClientInGame(victim) && IsPlayerAlive(victim) && (GetEntityFlags(victim) & FL_ONGROUND))
{
SetEntityHealth(victim, 200);
}
}
}