Raised This Month: $ Target: $400
 0% 

Solved Get 'Owner' of other third entity


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
sursista
Senior Member
Join Date: Jul 2010
Location: Spain
Old 06-28-2021 , 05:52   Re: Get 'Owner' of other third entity
Reply With Quote #4

Quote:
Originally Posted by Celena Luna View Post
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(entpev_ownerid)
    
//...
}

public 
ShootEntityTouch(entid_touched)
{
    
//Do the usual check stuff like valid, alive,...
    
static iOwneriOwner pev(entpev_owner)
    static 
iVictimiVitcim FM_NULLENT;
    static 
FloatfOrigin[3]; pev(entpev_originfOrigin);

    
//In loop-for or loop-while to check AoE damage
    
while((iVictim engfunc(EngFunc_FindEntityInSphereiVictimfOriginEXP_RADIUS)) > 0)
    {
        if(
is_user_alive(iVictim) && zp_get_user_zombie(iVictim))
        {
            
ExecuteHamB(Ham_TakeDamageiVictimentiOwnerDAMAGEDMG_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 1<= 32i++) 
    {
        if ( 
is_user_alive(i)) 
        {       
            new 
id pev(entpev_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(iPlayerPos);

            
distance get_distance(PlayerPosNonFloatEndOrigin);

            if (
distance <= damageradius)
            { 
            
message_begin(MSG_ONEgmsg_screenshake, {0,0,0}, i);
            
write_short(1<<14);
            
write_short(1<<14);
            
write_short(1<<14);
            
message_end();

            new 
attacker pev(entpev_owner);
    
            
baz_damage(iattackermaxdamage floatround(floatmul(float(maxdamage), floatdiv(float(distance), float(damageradius)))), "bazooka");
            }
        }
    } 
And call function final:

PHP Code:
baz_damage(idattackerdamageweaponDescription[])
{
    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(idpev_takedamage) == DAMAGE_NO 
        return;
    if ( 
damage <= 
        return;

    new 
userHealth get_user_health(id);

    if (
userHealth damage <= 
    {
    
dmgcount[attacker] += userHealth damage;
    
set_msg_block(gmsg_deathBLOCK_SET);
    
//ExecuteHamB(Ham_Killed, id, attacker, 2);
    
ExecuteHamB(Ham_TakeDamageid 2attackerfloat(damage), DMG_GENERIC); 
    
set_msg_block(gmsg_deathBLOCK_NOT);


    
message_begin(MSG_BROADCASTgmsg_death);
    
write_byte(attacker);
    
write_byte(id);
    
write_byte(0);
    
write_string(weaponDescription);
    
message_end();

    
set_pev(attackerpev_fragsfloat(get_user_frags(attacker) + 1));

sursista is offline
Send a message via MSN to sursista Send a message via Skype™ to sursista
 



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 02:39.


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