|
Senior Member
Join Date: Jul 2010
Location: Spain
|

06-28-2021
, 05:52
Re: Get 'Owner' of other third entity
|
#4
|
Quote:
Originally Posted by Celena Luna
I think as long as the entity deal damage via ExecuteHamB TakeDamge with correct attacker and victim input, it should work.
The attacker from those entity should be get from pev_owner
PHP Code:
public ShootEntity(id)
{
new ent;
//Do usual create entity stuff ()
//...
set_pev(ent, pev_owner, id)
//...
}
public ShootEntityTouch(ent, id_touched)
{
//Do the usual check stuff like valid, alive,...
static iOwner; iOwner = pev(ent, pev_owner)
static iVictim; iVitcim = FM_NULLENT;
static Float: fOrigin[3]; pev(ent, pev_origin, fOrigin);
//In loop-for or loop-while to check AoE damage
while((iVictim = engfunc(EngFunc_FindEntityInSphere, iVictim, fOrigin, EXP_RADIUS)) > 0)
{
if(is_user_alive(iVictim) && zp_get_user_zombie(iVictim))
{
ExecuteHamB(Ham_TakeDamage, iVictim, ent, iOwner, DAMAGE, DMG_GENERIC); //ent or iOwner is fine.
}
}
//finish up
}
Some plugin used ent as attacker so that would lead to not passing though "player takedamage" forward
ExecuteHam also won't pass though takedamage forward, must be ExecuteHamB
|
It seems to be working, I changed how the bazooka plugin kills its victims and now if it registers it when dying, but not when taking damage in TakeDamage:
PHP Code:
new maxdamage = get_cvar_num("zp_bazooka_damage");
new damageradius = get_cvar_num("zp_bazooka_radius");
new PlayerPos[3], distance
for (new i = 1; i <= 32; i++)
{
if ( is_user_alive(i))
{
new id = pev(ent, pev_owner)
if(is_user_alive(id))
{
if((zp_core_is_zombie(id)) || ((zp_class_nemesis_get(id))))
if((zp_core_is_zombie(i)) || (zp_class_nemesis_get(i)))
continue;
if((!zp_core_is_zombie(id)) && (!zp_class_nemesis_get(id)))
if((!zp_core_is_zombie(i)) && (!zp_class_nemesis_get(i)))
continue;
}
get_user_origin(i, PlayerPos);
distance = get_distance(PlayerPos, NonFloatEndOrigin);
if (distance <= damageradius)
{
message_begin(MSG_ONE, gmsg_screenshake, {0,0,0}, i);
write_short(1<<14);
write_short(1<<14);
write_short(1<<14);
message_end();
new attacker = pev(ent, pev_owner);
baz_damage(i, attacker, maxdamage - floatround(floatmul(float(maxdamage), floatdiv(float(distance), float(damageradius)))), "bazooka");
}
}
}
And call function final:
PHP Code:
baz_damage(id, attacker, damage, weaponDescription[])
{
if ( zp_core_is_zombie(attacker) || !is_user_alive(attacker) || zp_class_nemesis_get(attacker) )
{
ChatColor(attacker, "!g[ESSA] !tThe /gbug bazooka !tis !gFixed!")
return;
}
if ( pev(id, pev_takedamage) == DAMAGE_NO )
return;
if ( damage <= 0 )
return;
new userHealth = get_user_health(id);
if (userHealth - damage <= 0 )
{
dmgcount[attacker] += userHealth - damage;
set_msg_block(gmsg_death, BLOCK_SET);
//ExecuteHamB(Ham_Killed, id, attacker, 2);
ExecuteHamB(Ham_TakeDamage, id , 2, attacker, float(damage), DMG_GENERIC);
set_msg_block(gmsg_death, BLOCK_NOT);
message_begin(MSG_BROADCAST, gmsg_death);
write_byte(attacker);
write_byte(id);
write_byte(0);
write_string(weaponDescription);
message_end();
set_pev(attacker, pev_frags, float(get_user_frags(attacker) + 1));
}
|
|