Raised This Month: $51 Target: $400
 12% 

Solved [L4D2] How to get or calculate the damage when bullet didnt hit


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Paimon
Member
Join Date: Jul 2021
Location: Zootopia
Old 02-03-2024 , 05:11   [L4D2] How to get or calculate the damage when bullet didnt hit
Reply With Quote #1

As the title says, I want to know how to get the bullet's damage if the bullet didn't hit.
If the game(left4dead2) didnt give the damage, how to calculate the damage by myself? (such as shot by smg)
__________________

Last edited by Paimon; 02-03-2024 at 23:25.
Paimon is offline
King_OXO
Senior Member
Join Date: Dec 2020
Location: Brazil
Old 02-03-2024 , 12:28   Re: [L4D2] How to get or calculate the damage when bullet didnt hit
Reply With Quote #2

Quote:
Originally Posted by Paimon View Post
As the title says, I want to know how to get the bullet's damage if the bullet didn't hit.
If the game(left4dead2) didnt give the damage, how to calculate the damage by myself? (such as shot by smg)
use the info editor de silvers to find out what the normal damage of weapons is, this is found in this file
Attached Files
File Type: cfg l4d_info_editor_weapons.example.cfg (8.0 KB, 18 views)
__________________
My Noob Plugins

Discord:WhiteFire#1301
Steam:WhiteFire
Youtube
King_OXO is offline
Paimon
Member
Join Date: Jul 2021
Location: Zootopia
Old 02-03-2024 , 21:32   Re: [L4D2] How to get or calculate the damage when bullet didnt hit
Reply With Quote #3

All right, I found it at here:
The way that distance effects bullet's damage
__________________
Paimon is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 02-04-2024 , 06:44   Re: [L4D2] How to get or calculate the damage when bullet didnt hit
Reply With Quote #4

Quote:
Originally Posted by Paimon View Post
All right, I found it at here:
The way that distance effects bullet's damage
Thanks. Now just need translate... I took picture

weapon attributes can look inside weapon ...scripts\*.ctx files or txt
(example, but don't edit server files, or players get kick https://forums.alliedmods.net/showthread.php?t=166468)
Attached Files
File Type: zip Screenshot 2024-02-04 at 13-33-00.png.zip (1.39 MB, 20 views)
__________________
Do not Private Message @me
Bacardi is offline
Paimon
Member
Join Date: Jul 2021
Location: Zootopia
Old 02-04-2024 , 07:12   Re: [L4D2] How to get or calculate the damage when bullet didnt hit
Reply With Quote #5

Quote:
Originally Posted by Bacardi View Post
Thanks. Now just need translate... I took picture

weapon attributes can look inside weapon ...scripts\*.ctx files or txt
(example, but don't edit server files, or players get kick https://forums.alliedmods.net/showthread.php?t=166468)
I have finished the function, here it is:
PHP Code:
#include <left4dhooks>

float GetWeaponDamage(const char[] clsnamefloat distance)
{
    
int damage;
    
float rangerangeModifiergainRangefinal_damage;
    
damage L4D2_GetIntWeaponAttribute(clsnameL4D2IWA_Damage);
    
range L4D2_GetFloatWeaponAttribute(clsnameL4D2FWA_Range);
    
rangeModifier L4D2_GetFloatWeaponAttribute(clsnameL4D2FWA_RangeModifier);
    
gainRange L4D2_GetFloatWeaponAttribute(clsnameL4D2FWA_GainRange);

    if (
distance <= gainRange)
        
final_damage CalculateDamage(damagerangeModifierdistance);
    else if(
distance <= rangefinal_damage CalculateGainDamage(damagerangerangeModifiergainRangedistance);
    else 
final_damage 0.0;

    return 
final_damage;
}

float CalculateDamage(int damagefloat rangeModifierfloat distance)
{
    
// 0~gainRange
    // f(x) = dmg * pow(rm, distance / 500)
    
return damage Pow(rangeModifierdistance 500);
}

float CalculateGainDamage(int damagefloat rangefloat rangeModifierfloat gainRangefloat distance)
{
    
// gainRange~range
    // f1(x) = f(x) * ((r - distance) / (r - gr))
    
return CalculateDamage(damagerangeModifierdistance) * ((range distance) / (range gainRange));

Usage:
PHP Code:
#include <left4dhooks>
// Some codes...
{
    
// blah-blah-blah...
    
float distance 600.0;
    
float damage GetWeaponDamage("weapon_smg_silenced"distance);

__________________

Last edited by Paimon; 02-04-2024 at 07:22.
Paimon is offline
Reply



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 03:30.


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