Raised This Month: $32 Target: $400
 8% 

[EXTENSION] Sidewinder


Post New Thread Reply   
 
Thread Tools Display Modes
OziOn
Senior Member
Join Date: Jan 2008
Old 03-05-2009 , 17:41   Re: [EXTENSION] Sidewinder
Reply With Quote #21

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 :/
__________________

OziOn is offline
voogru
Inspector Javert
Join Date: Oct 2004
Old 03-05-2009 , 20:27   Re: [EXTENSION] Sidewinder
Reply With Quote #22

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.
voogru is offline
pRED*
Join Date: Dec 2006
Old 03-05-2009 , 21:06   Re: [EXTENSION] Sidewinder
Reply With Quote #23

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>
pRED* is offline
voogru
Inspector Javert
Join Date: Oct 2004
Old 03-05-2009 , 21:40   Re: [EXTENSION] Sidewinder
Reply With Quote #24

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.

Last edited by voogru; 03-05-2009 at 21:43.
voogru is offline
pRED*
Join Date: Dec 2006
Old 03-09-2009 , 17:22   Re: [EXTENSION] Sidewinder
Reply With Quote #25

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)
pRED* is offline
msleeper
Veteran Member
Join Date: May 2008
Location: Atlanta, Jawjuh
Old 03-09-2009 , 20:40   Re: [EXTENSION] Sidewinder
Reply With Quote #26

Could you add an admin flag option to this? I would love to give a random crit chance to people with specific flags. Thanks.
__________________
msleeper is offline
OziOn
Senior Member
Join Date: Jan 2008
Old 03-10-2009 , 09:25   Re: [EXTENSION] Sidewinder
Reply With Quote #27

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 is offline
OziOn
Senior Member
Join Date: Jan 2008
Old 03-10-2009 , 17:43   Re: [EXTENSION] Sidewinder
Reply With Quote #28

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

OziOn is offline
pRED*
Join Date: Dec 2006
Old 03-10-2009 , 19:37   Re: [EXTENSION] Sidewinder
Reply With Quote #29

Windows? Got a mdmp?
pRED* is offline
OziOn
Senior Member
Join Date: Jan 2008
Old 03-10-2009 , 20:05   Re: [EXTENSION] Sidewinder
Reply With Quote #30

Sure do.
Attached Files
File Type: mdmp Steam__273447__2009_3_10T23_59_44C38673595.mdmp (57.3 KB, 144 views)
__________________

OziOn is offline
Reply


Thread Tools
Display Modes

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:45.


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