AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] tripmine satchel trigger (https://forums.alliedmods.net/showthread.php?t=117249)

ujjl 01-30-2010 10:52

[Help] tripmine satchel trigger
 
How to blow up a satchels, or tripmines, if i know theire entity id?

I have to remove them, but i dont want to use
Code:

engfunc(EngFunc_RemoveEntity, ent);
And i need to set the activator (who blowed up them) to a specific player id.

Arkshine 01-30-2010 11:21

Re: [Help] tripmine satchel trigger
 
Normal way :

For satchel, you can use Ham_Use, or force_use().
For tripmine, you can try to set to 0 m_hOwner offset.

With Orpheu :

For satchel, call : CGrenade::Detonate()
For tripmine, call : CGrenade::Explode() or CGrenade::Detonate().

ujjl 01-30-2010 13:55

Re: [Help] tripmine satchel trigger
 
Quote:

For tripmine, you can try to set to 0 m_hOwner offset.
EDIT:
I have to use Ham_TakeDamage

THX, solved.

ConnorMcLeod 01-30-2010 14:06

Re: [Help] tripmine satchel trigger
 
Code:

        float                m_flPowerUp;
        Vector                m_vecDir;
        Vector                m_vecEnd;
        float                m_flBeamLength;

        EHANDLE                m_hOwner;
        CBeam                *m_pBeam;
        Vector                m_posOwner;
        Vector                m_angleOwner;
        edict_t                *m_pRealOwner;// tracelines don't hit PEV->OWNER, which means a player couldn't detonate his own trip mine, so we store the owner here.
};

EHANDLE is not Cbase

Arkshine 01-30-2010 14:09

Re: [Help] tripmine satchel trigger
 
For Tripmine looks the code :
PHP Code:

void CTripmineGrenade :: BeamBreakThinkvoid  )
{
    
BOOL bBlowup 0;

    
TraceResult tr;

    
// HACKHACK Set simple box using this really nice global!
    
gpGlobals->trace_flags FTRACE_SIMPLEBOX;
    
UTIL_TraceLinepev->originm_vecEnddont_ignore_monstersENTpev ), &tr );

    
// ALERT( at_console, "%f : %f\n", tr.flFraction, m_flBeamLength );

    // respawn detect. 
    
if ( !m_pBeam )
    {
        
MakeBeam( );
        if ( 
tr.pHit )
            
m_hOwner CBaseEntity::Instancetr.pHit );    // reset owner too
    
}

    if (
fabsm_flBeamLength tr.flFraction ) > 0.001)
    {
        
bBlowup 1;
    }
    else
    {
        if (
m_hOwner == NULL)
            
bBlowup 1;
        else if (
m_posOwner != m_hOwner->pev->origin)
            
bBlowup 1;
        else if (
m_angleOwner != m_hOwner->pev->angles)
            
bBlowup 1;
    }

    if (
bBlowup)
    {
        
// a bit of a hack, but all CGrenade code passes pev->owner along to make sure the proper player gets credit for the kill
        // so we have to restore pev->owner from pRealOwner, because an entity's tracelines don't strike it's pev->owner which meant
        // that a player couldn't trigger his own tripmine. Now that the mine is exploding, it's safe the restore the owner so the 
        // CGrenade code knows who the explosive really belongs to.
        
pev->owner m_pRealOwner;
        
pev->health 0;
        
KilledVARSpev->owner ), GIB_NORMAL );
        return;
    }

    
pev->nextthink gpGlobals->time 0.1;


PHP Code:

        if (m_hOwner == NULL)
            
bBlowup 1;
        else if (
m_posOwner != m_hOwner->pev->origin)
            
bBlowup 1;
        else if (
m_angleOwner != m_hOwner->pev->angles)
            
bBlowup 1

it will explode if m_hOwner is null, or if m_posOwner/m_angleOwner is different.
For m_hOwner, get_pdata_ent() should work.

ujjl 01-30-2010 14:24

Re: [Help] tripmine satchel trigger
 
Yes it will blow up, but the made frags will count for the original deployer, not for the specified player. (Correct me if im wrong)

Arkshine 01-30-2010 15:01

Re: [Help] tripmine satchel trigger
 
Which is logic.. I don't get your point.

ujjl 01-30-2010 15:06

Re: [Help] tripmine satchel trigger
 
Im destroying respawn mines when a player respawn near to them, so the frags made the explosion because of destroying them shoud be counted for the respawner (who is in respawn protection for avoiding suicide)
So force_use and takedamage works well.


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

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