Raised This Month: $32 Target: $400
 8% 

[TF2] Deal damage in radius around player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AnubisTF2
Senior Member
Join Date: Oct 2015
Old 01-02-2019 , 21:07   [TF2] Deal damage in radius around player
Reply With Quote #1

I'm trying to write a plugin where when the player attacks, it will deal damage in a radius around the player, but I haven't had any luck. Here's what I've got:

Code:
public Action:TF2_CalcIsAttackCritical(client, weapon, String:weaponname[], &bool:isCrit)
{
	g_fRadius = 600.0;
	g_fDamage = 100.0;
	
	decl Float:origin[3];
	GetClientAbsOrigin(client, origin);
	
    if(1.00 > GetRandomFloat(0.0, 1.0) && GetClientTeam(client) == BossTeam)
    {
        isCrit = true;
		
		DamageArea(origin, g_fRadius, g_fDamage, client, client, GetClientTeam(client), DMG_GENERIC, -1, NULL_VECTOR);
    }
    return Plugin_Continue;
}

stock DamageArea(Float:origin[3], Float:distance = 500.0, Float:damage = 500.0, &attacker, &inflictor, int team = 0, damagetype, int weapon = -1, Float:damageforce[3] = NULL_VECTOR)
{
    if (distance <= 0.0 || damage <= 0.0)
        return;

    float vecOrigin[3];
    for (int i = 1; i <= MaxClients; i++)
    {
        if (!IsClientInGame(i) || !IsPlayerAlive(i) || (team > 0 && team != GetClientTeam(i)) || (attacker > 0 && i == attacker))
            continue;

        GetClientAbsOrigin(i, vecOrigin);

        if (GetVectorDistance(origin, vecOrigin) > distance)
            continue;

        SDKHooks_TakeDamage(i, inflictor, attacker, damage, damagetype, weapon, damageforce, origin);
    }

    int entity = -1;
    while ((entity = FindEntityByClassname(entity, "*")) != -1)
    {
        if (!HasEntProp(entity, Prop_Send, "m_vecOrigin") || attacker > 0 && attacker == entity)
            continue;

        GetEntPropVector(entity, Prop_Send, "m_vecOrigin", vecOrigin);

        if (GetVectorDistance(origin, vecOrigin) > distance)
            continue;

        SDKHooks_TakeDamage(entity, inflictor, attacker, damage, damagetype, weapon, damageforce, origin);
    }
}
Would really appreciate all the help I can get, thanks!
__________________
naw
AnubisTF2 is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 01-02-2019 , 23:43   Re: [TF2] Deal damage in radius around player
Reply With Quote #2

team != GetClientTeam(i)

Unless what you want is to deal damage to teammates I think the above is what is wrong?
__________________
8guawong is offline
AnubisTF2
Senior Member
Join Date: Oct 2015
Old 01-02-2019 , 23:50   Re: [TF2] Deal damage in radius around player
Reply With Quote #3

Quote:
Originally Posted by 8guawong View Post
team != GetClientTeam(i)

Unless what you want is to deal damage to teammates I think the above is what is wrong?
hm still doesn't work
compiles fine, but nothing happens in game.
the crit part works however, just not the radius damage part
__________________
naw
AnubisTF2 is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 01-03-2019 , 05:40   Re: [TF2] Deal damage in radius around player
Reply With Quote #4

Quote:
Originally Posted by AnubisTF2 View Post
hm still doesn't work
compiles fine, but nothing happens in game.
the crit part works however, just not the radius damage part
in that case you should do some debugging and see what part of the code is not working as expected
__________________
8guawong is offline
AnubisTF2
Senior Member
Join Date: Oct 2015
Old 01-03-2019 , 08:16   Re: [TF2] Deal damage in radius around player
Reply With Quote #5

Quote:
Originally Posted by 8guawong View Post
in that case you should do some debugging and see what part of the code is not working as expected
ive tried quite a bit of debugging, but no luck.
im pretty bad with SP, so thats why I came here to ask for some help
__________________
naw
AnubisTF2 is offline
Starbish
AlliedModders Donor
Join Date: Oct 2011
Location: South Korea
Old 01-03-2019 , 10:11   Re: [TF2] Deal damage in radius around player
Reply With Quote #6

PHP Code:
team && team != GetClientTeam(i
I think this is what you've mistaken.

Is this code intended to deal damage around your teammate?

You can find which statement makes something filtered.

I think That's what he mentioned 'debugging'.
__________________
Starbish is offline
AnubisTF2
Senior Member
Join Date: Oct 2015
Old 01-03-2019 , 21:48   Re: [TF2] Deal damage in radius around player
Reply With Quote #7

so another problem has risen
the point of the plugin, deal damage in a certain area on attack, works
however, every time you attack, it does 1 damage, sometimes 2 damage, and the radius is a lot larger than the value set. it's unusual, since the damage is set to 125, and the range is set to 400
https://pastebin.com/raw/kX5ERjpP
any ideas on why this occurs?
__________________
naw
AnubisTF2 is offline
Whai
Senior Member
Join Date: Jul 2018
Old 01-20-2019 , 17:27   Re: [TF2] Deal damage in radius around player
Reply With Quote #8

Quote:
Originally Posted by AnubisTF2 View Post
so another problem has risen
the point of the plugin, deal damage in a certain area on attack, works
however, every time you attack, it does 1 damage, sometimes 2 damage, and the radius is a lot larger than the value set. it's unusual, since the damage is set to 125, and the range is set to 400
https://pastebin.com/raw/kX5ERjpP
any ideas on why this occurs?
From sdkhooks.inc :
Code:
native void SDKHooks_TakeDamage(int entity, int inflictor, int attacker,
		float damage, int damageType=DMG_GENERIC, int weapon=-1,
		const float damageForce[3]=NULL_VECTOR, const float damagePosition[3]=NULL_VECTOR);
You skipped damageForce, You should try this :

Code:
SDKHooks_TakeDamage(entity, inflictor, attacker, damage, damagetype, weapon, _, origin);
__________________
Whai is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:47.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode