AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Damage Grenade (https://forums.alliedmods.net/showthread.php?t=236343)

raducuursu 03-03-2014 09:32

Damage Grenade
 
Hi
I have a problem with the zombie plague, grenade explode


I sometimes appears
Damge to Name :: -23 dmg
Damge to Name :: -12 dmg
Damge to Name :: -3 dmg
Damge to Name :: -7 dmg

but must as a minimum be 0

but I look and positive numbers

look at the source
Quote:

// Set damage
static id, name[32], distance, Float:damage
id = entity_get_edict(ent, EV_ENT_owner)
get_user_name(victim, name, charsmax(name))
distance = floatround(entity_range(ent, victim))
damage = get_pcvar_float(cvar_explosedamage)-(get_pcvar_float(cvar_explosedamage)/NADE_EXPLOSION_RADIUS)*float(distance)
fm_set_user_health(victim, pev(victim, pev_health) - floatround(damage))
zp_colored_print(id, "%s Damage to^x03 %s^x01 ::^x04 %i damage", CHAT_PREFIX, name, floatround(damage))
and

Quote:

// Explosion radius for custom grenades
const Float:NADE_EXPLOSION_RADIUS = 240.0
Thanks

Kiske 03-03-2014 11:51

Re: Damage Grenade
 
Show the code what check if victim is in nade radius.

georgik57 03-03-2014 13:54

Re: Damage Grenade
 
Code:
// Set damage static id, damage id = entity_get_edict(ent, EV_ENT_owner) // damage lower than 1 has no point, so we round it down damage = floatround(get_pcvar_float(cvar_explosedamage) - (get_pcvar_float(cvar_explosedamage) / NADE_EXPLOSION_RADIUS) * entity_range(ent, victim), floatround_floor) // the target is out of the explosion range if (!damage)     return; // max CS name lenght is 31, not 32 static name[31] get_user_name(victim, name, 30) fm_set_user_health(victim, pev(victim, pev_health) - damage) zp_colored_print(id, "%s Damage to^x03 %s^x01 ::^x04 %d damage", CHAT_PREFIX, name, damage)

Kiske 03-04-2014 03:30

Re: Damage Grenade
 
PHP Code:

if(!is_valid_ent(ent)) {
    return;
}

new 
iAttacker;
iAttacker entity_get_edict(entEV_ENT_owner);

if(!
is_user_connected(iAttacker)) {
    return;
}

new 
Float:vecOrigin[3];
new 
Float:fCVAR_Value;
new 
Float:fDistance;
new 
Float:fDamage;
new 
Float:fEq;
new 
iVictim;

entity_get_vector(entEV_VEC_originvecOrigin);

fCVAR_Value get_pcvar_float(cvar_explosedamage);
fEq fCVAR_Value NADE_EXPLOSION_RADIUS;

iVictim = -1;

while((
iVictim engfunc(EngFunc_FindEntityInSphereiVictimvecOriginNADE_EXPLOSION_RADIUS)) != 0) {
    if(!
is_user_alive(iVictim))
        continue;
    
    
fDistance entity_range(entiVictim);
    
    
fDamage fCVAR_Value - (fEq fDistance);
    
    
ExecuteHam(Ham_TakeDamageiVictimiAttackeriAttackerfDamageDMG_BLAST);




All times are GMT -4. The time now is 05:58.

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