AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Ham_Touch func_door_rotating (https://forums.alliedmods.net/showthread.php?t=209802)

jimaway 03-02-2013 05:22

Ham_Touch func_door_rotating
 
my goal is to stop players being able to block func_door_rotating opening/closing, but Ham_Touch only triggers when the door is fully open/closed, how would i detect players blocking the door opening/closing?

bibu 03-02-2013 07:00

Re: Ham_Touch func_door_rotating
 
Ham_Use?

jimaway 03-02-2013 09:59

Re: Ham_Touch func_door_rotating
 
how would i detect if player is blocking door opening with that?

ConnorMcLeod 03-02-2013 11:57

Re: Ham_Touch func_door_rotating
 
Ham_Blocked is sent but it's already too late i think, the code you would need to access belongs to the engine, so you need module such as orpheu or rage and a lot or research.

bibu 03-02-2013 12:00

Re: Ham_Touch func_door_rotating
 
Quote:

Originally Posted by jimaway (Post 1905050)
how would i detect if player is blocking door opening with that?

Sorry, I misunderstood your question in the first post.

jimaway 03-03-2013 13:28

Re: Ham_Touch func_door_rotating
 
Quote:

Originally Posted by ConnorMcLeod (Post 1905108)
Ham_Blocked is sent but it's already too late i think, the code you would need to access belongs to the engine, so you need module such as orpheu or rage and a lot or research.

just tested this, its actually not too late, the door wont close immediately when i return HAM_SUPERCEDE in the Ham_Block hook, but instead it gets stuck in "opening" state when the player is in the way. i tried calling Ham_Touch with the door in Ham_Block before superceding but it didn't seem to work, then i tried to call Ham_CS_Roundrespawn there to move the player out of the way, but that didn't work neighter.
i also tried setting players z origin little bit higher (so the player is in air and the door will just push him out of the way) with no luck.

any ideas?

ConnorMcLeod 03-03-2013 14:44

Re: Ham_Touch func_door_rotating
 
Set pev_dmg on all doors, once at plugin_init, and players gonna die.

Backstabnoob 03-04-2013 06:27

Re: Ham_Touch func_door_rotating
 
When exactly do door damage the player with pev_dmg? When the door are stuck because of player blocking them?

ConnorMcLeod 03-04-2013 07:39

Re: Ham_Touch func_door_rotating
 
Yes.

Code:

void CBaseDoor::Blocked( CBaseEntity *pOther )
{
        edict_t        *pentTarget = NULL;
        CBaseDoor        *pDoor                = NULL;


        // Hurt the blocker a little.
        if ( pev->dmg )
                pOther->TakeDamage( pev, pev, pev->dmg, DMG_CRUSH );

        // if a door has a negative wait, it would never come back if blocked,
        // so let it just squash the object to death real fast

        if (m_flWait >= 0)
        {
                if (m_toggle_state == TS_GOING_DOWN)
                {
                        DoorGoUp();
                }
                else
                {
                        DoorGoDown();
                }
        }

        // Block all door pieces with the same targetname here.
        if ( !FStringNull ( pev->targetname ) )
        {
                for (;;)
                {
                        pentTarget = FIND_ENTITY_BY_TARGETNAME(pentTarget, STRING(pev->targetname));

                        if ( VARS( pentTarget ) != pev )
                        {
                                if (FNullEnt(pentTarget))
                                        break;

                                if ( FClassnameIs ( pentTarget, "func_door" ) || FClassnameIs ( pentTarget, "func_door_rotating" ) )
                                {
                               
                                        pDoor = GetClassPtr( (CBaseDoor *) VARS(pentTarget) );

                                        if ( pDoor->m_flWait >= 0)
                                        {
                                                if (pDoor->pev->velocity == pev->velocity && pDoor->pev->avelocity == pev->velocity)
                                                {
                                                        // this is the most hacked, evil, bastardized thing I've ever seen. kjb
                                                        if ( FClassnameIs ( pentTarget, "func_door" ) )
                                                        {// set origin to realign normal doors
                                                                pDoor->pev->origin = pev->origin;
                                                                pDoor->pev->velocity = g_vecZero;// stop!
                                                        }
                                                        else
                                                        {// set angles to realign rotating doors
                                                                pDoor->pev->angles = pev->angles;
                                                                pDoor->pev->avelocity = g_vecZero;
                                                        }
                                                }

                                                if ( pDoor->m_toggle_state == TS_GOING_DOWN)
                                                        pDoor->DoorGoUp();
                                                else
                                                        pDoor->DoorGoDown();
                                        }
                                }
                        }
                }
        }
}


jimaway 03-04-2013 12:12

Re: Ham_Touch func_door_rotating
 
Quote:

Originally Posted by ConnorMcLeod (Post 1905864)
Set pev_dmg on all doors, once at plugin_init, and players gonna die.

but the player will still block the door opening/closing

PHP Code:

    if ( pev->dmg )
        
pOther->TakeDamagepevpevpev->dmgDMG_CRUSH );

    
// if a door has a negative wait, it would never come back if blocked,
    // so let it just squash the object to death real fast

    
if (m_flWait >= 0)
    {
        if (
m_toggle_state == TS_GOING_DOWN)
        {
            
DoorGoUp();
        }
        else
        {
            
DoorGoDown();
        }
    } 

and im still wondering why respawning player, changing players z origin and calling Ham_Touch in Ham_Blocked didnt work

edit: works with a 0.1 sec task


All times are GMT -4. The time now is 21:43.

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