AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved [L4D2] How to get or calculate the damage when bullet didnt hit (https://forums.alliedmods.net/showthread.php?t=345936)

Paimon 02-03-2024 05:11

[L4D2] How to get or calculate the damage when bullet didnt hit
 
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)

King_OXO 02-03-2024 12:28

Re: [L4D2] How to get or calculate the damage when bullet didnt hit
 
1 Attachment(s)
Quote:

Originally Posted by Paimon (Post 2817336)
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

Paimon 02-03-2024 21:32

Re: [L4D2] How to get or calculate the damage when bullet didnt hit
 
All right, I found it at here:
The way that distance effects bullet's damage

Bacardi 02-04-2024 06:44

Re: [L4D2] How to get or calculate the damage when bullet didnt hit
 
1 Attachment(s)
Quote:

Originally Posted by Paimon (Post 2817391)
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)

Paimon 02-04-2024 07:12

Re: [L4D2] How to get or calculate the damage when bullet didnt hit
 
Quote:

Originally Posted by Bacardi (Post 2817412)
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);




All times are GMT -4. The time now is 13:07.

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