AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Extensions (https://forums.alliedmods.net/forumdisplay.php?f=134)
-   -   [EXTENSION] Sidewinder (https://forums.alliedmods.net/showthread.php?t=86817)

OziOn 03-05-2009 17:41

Re: [EXTENSION] Sidewinder
 
The spies was never a problem on my server. The rockets just never saw them when cloaked/disguised.
The new version is working great, but now the rockets aren't homing anymore when deflected by the flamethrower :/

voogru 03-05-2009 20:27

Re: [EXTENSION] Sidewinder
 
PHP Code:

class CProjectileRocket : public CEntity
{
private:
    
bool                    *m_bCritical;
public:
    
DECLARE_CLASS(CProjectileRocketCEntity);

    
bool                    IsCritical                    void ) { return *m_bCritical; }
    
void                    SetCritical                    bool bCritical ) { *m_bCritical bCritical; }

    
virtual void            Spawn                        void );
    
virtual void            RocketThink                    void );

};

LINK_ENTITY_TO_CLASS(tf_projectile_rocketCProjectileRocket);

void m_bCriticalRocketProxy( const SendProp *pProp, const void *pStructBase, const void *pDataDVariant *pOutint iElementint objectID )
{
    
CProjectileRocket *pRocket dynamic_cast<CProjectileRocket*>(CEntity::Instance(objectID));
    if(
pRocket) {
        
pOut->m_Int pRocket->IsCritical();
    }
}

void CProjectileRocket :: Spawn void )
{
    
AddEffects(EF_NODRAW); //Hide entity until we're done with it (prevents occasionall wierdness with rockets not showing up as crits)

    
static int m_iCriticalOffset g_Util.GetOffset("DT_TFProjectile_Rocket","m_bCritical");

    
m_bCritical = (bool *)((char *)BaseEntity() + m_iCriticalOffset);

    static 
bool bProxyInstalled false;

    if(!
bProxyInstalled
    {
        
ServerData()->HookSendProxy("CTFProjectile_Rocket""m_bCritical"m_bCriticalRocketProxy);
        
bProxyInstalled true;
    }

    
SetThink( &CProjectileRocket::RocketThink );
    
SetNextThinkgpGlobals->curtime );
}


void CProjectileRocket :: RocketThink void )
{
    
RemoveEffects(EF_NODRAW);
}

class 
CSentryRocket : public CProjectileRocket
{
public:
    
DECLARE_CLASS(CSentryRocketCProjectileRocket);

    
virtual void            Spawn                        void );
    
virtual void            IgniteThink                    void );
    
virtual void            SeekThink                    void );
};

LINK_ENTITY_TO_CLASS(tf_projectile_sentryrocketCSentryRocket);

void CSentryRocket :: Spawn void )
{
    
BaseClass::Spawn();

    if(!
fa_sentrygun_homingrockets.GetBool()) 
    {
        
RemoveEffects(EF_NODRAW);

        
SetThink(NULL);
        
SetNextThink (TICK_NEVER_THINK);
        return;
    }

    
int iCritChance fa_sentrygun_homingrockets_critchance.GetInt();
    if(
iCritChance 0
    {
        if( 
g_Util.RandomInt(0,100) >= (100 iCritChance) ) {
            
SetCritical true );
        }
    }

    
SetThink( &CSentryRocket::IgniteThink );
    
SetNextThinkgpGlobals->curtime );
}

void CSentryRocket :: IgniteThink void )
{
    
RemoveEffects(EF_NODRAW);

    
Vector vecForward;

    
AngleVectorsGetLocalAngles(), &vecForward );
    
SetAbsVelocityvecForward fa_sentrygun_homingrockets_speed.GetFloat() );

    
SetThink( &CSentryRocket::SeekThink );
    
SetNextThinkgpGlobals->curtime );
}

void CSentryRocket :: SeekThinkvoid )
{
    
CEntity        *pBestVictim    NULL;
    
float        flBestVictim    MAX_TRACE_LENGTH;
    
float        flVictimDist;

    
CBaseEntity *pBaseEntity NULL;

    while(
pBaseEntity g_Util.FindEntityInSphere(pBaseEntityGetAbsOrigin(), 2048)) 
    {
        
CEntity *pEntity CEntity::Instance(pBaseEntity);

        if(!
pEntity)
            continue;

        if(!
pEntity->IsPlayer())
            continue;

        
CPlayer *pPlayer GetPlayerPointerpEntity->BaseEntity() );

        
AssertpPlayer );

        if(!
pPlayer)
            continue;

        if(!
pPlayer->IsAlive())
            continue;

        
//As much as I hate spies as engineer, they too have rights...
        
if(pPlayer->GetPlayerClass() == PLAYERCLASS_SPY
        {
            
//Cloaky
            
if(pPlayer->GetPlayerCond() & PLAYERCOND_SPYCLOAK) {
                continue;
            }

            
//Disguised
            
if(pPlayer->IsDisguised() && pPlayer->GetDisguisedTeam() == GetTeam())
                continue;
        }

        if(
pEntity->GetTeam() != GetTeam() && FVisible(pEntityMASK_OPAQUENULL) )
        {
            
flVictimDist = (GetAbsOrigin() - pEntity->GetAbsOrigin()).Length();

            
//Find closest
            
if ( flVictimDist flBestVictim )
            {
                
pBestVictim    pEntity;
                
flBestVictim flVictimDist;
            }
        }
    }

    
//No victims :(
    
if ( pBestVictim == NULL ) {
        
SetNextThinkgpGlobals->curtime );
        return;
    }

    
//truncated...


Just thought I'd throw it up there. :D

pRED* 03-05-2009 21:06

Re: [EXTENSION] Sidewinder
 
Get on irc damnit.

Why bother finding a new target every frame and the proxy stuff seems like a waste of effort.
<insert other assorted complaints with no real substance here>

voogru 03-05-2009 21:40

Re: [EXTENSION] Sidewinder
 
Only every frame if it doesn't find one, otherwise thinks 10 times a second. Proxy stuff was to resolve a damn wierd bug I had, I'm not sure if it still exists though.

The bug was basically, crit rockets would not always show up as crits, even though they were crits.

pRED* 03-09-2009 17:22

Re: [EXTENSION] Sidewinder
 
Updated to version 1.1:

http://users.alliedmods.net/~pred/co...idewinder/1.1/

Changes:
- Big backend rewrite - Now using my CEntity framework
- Targetting code updated thanks to suggestions from voogru
- 2 New convars sm_sidewinder_enabled (0/1) and sm_sentryrocket_critchance (0.0 - 1.0)

msleeper 03-09-2009 20:40

Re: [EXTENSION] Sidewinder
 
Could you add an admin flag option to this? I would love to give a random crit chance to people with specific flags. Thanks.

OziOn 03-10-2009 09:25

Re: [EXTENSION] Sidewinder
 
It seem to work now. Except for the criticals. No matter whan I set sm_sentryrocket_critchance or sm_sentryrocket_crit to, it never fires any critical rockets.

OziOn 03-10-2009 17:43

Re: [EXTENSION] Sidewinder
 
Hmm, the latest version also seem to crash my server at every 2nd or 3rd mapchange. Anyone else having this too? (Windows server)

pRED* 03-10-2009 19:37

Re: [EXTENSION] Sidewinder
 
Windows? Got a mdmp?

OziOn 03-10-2009 20:05

Re: [EXTENSION] Sidewinder
 
1 Attachment(s)
Sure do.


All times are GMT -4. The time now is 12:49.

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