--
--
[ Picked text/plain from multipart/alternative ]
Moltov Code, Release to Public:

::attached::

If you have any questions about it, just reply here, or email me at
[EMAIL PROTECTED]

Also, this is only the code, you guys can make the scripts :P..lol



On 2/10/06, Michael Kramer <[EMAIL PROTECTED]> wrote:
>
> Lol, No I did not.I didn't think it was that big of an accomplishment.
> Though, when I finish my mod (Half-Life 2 Revolution www.siosphere.com) I
> will release sourcecode to all the Weapons.
>
> On 2/10/06, Gus <[EMAIL PROTECTED]> wrote:
> >
> > Hello, Michael Kramer,
> >
> > And that's it, you didn't share it to the community?
> >
> > ======= At 2006-02-10, 05:30:02 you wrote: =======
> >
> > >--
> > >[ Picked text/plain from multipart/alternative ]
> > >I had already added the Molotov Cocktail into my mod. And got it
> > working and
> > >everything. But thanx anyway :D
> > >
> > >On 2/9/06, Gus <[EMAIL PROTECTED]> wrote:
> > >>
> > >> Hey all,
> > >>
> > >> there's a thread I and some guy who whom are trying to get Molotov
> > code
> > >> working.........somehow he's progressed at his end but not that he
> > posted a
> > >> tutorial on how he did it we need other peeps to try it out and see
> > whether
> > >> it really works.........here's the thread link..
> > >>
> > >> http://www.swallowbush.com/forum/viewtopic.php?p=2573#2573
> > >>
> > >>
> > >>
> > >> = = = = = = = = = = = = = = = = = = = =
> > >>
> > >>
> > >> Best regards.
> > >> Gus
> > >> [EMAIL PROTECTED]
> > >> 2006-02-08
> > >>
> > >>
> > >>
> > >> _______________________________________________
> > >> To unsubscribe, edit your list preferences, or view the list
> > archives,
> > >> please visit:
> > >> http://list.valvesoftware.com/mailman/listinfo/hlcoders
> > >>
> > >>
> > >--
> > >
> > >_______________________________________________
> > >To unsubscribe, edit your list preferences, or view the list archives,
> > please visit:
> > > http://list.valvesoftware.com/mailman/listinfo/hlcoders
> > >
> >
> > = = = = = = = = = = = = = = = = = = = =
> >
> >
> > Best regards.
> > Gus
> > [EMAIL PROTECTED]
> > 2006-02-10
> >
> >
> >
> > _______________________________________________
> > To unsubscribe, edit your list preferences, or view the list archives,
> > please visit:
> > http://list.valvesoftware.com/mailman/listinfo/hlcoders
> >
> >
>
--
X-Attachment-Id: f_ejrp6m57

//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. 
============//
//
// Purpose: This is the molotov weapon
//
// $Workfile:     $
// $Date:         $
// $NoKeywords: $
//=============================================================================//

#include "cbase.h"
#include        "NPCEvent.h"
#include "weapon_hl2mpbasehlmpcombatweapon.h"
#include "baseplayer_shared.h"
#include        "gamerules.h"           // For g_pGameRules
#include        "in_buttons.h"
#include "vstdlib/random.h"
#include "movevars_shared.h"

#ifdef CLIENT_DLL
        #include "c_hl2mp_player.h"
        #include "c_basecombatcharacter.h"
        #include "c_baseplayer.h"
#else
        #include "hl2mp_player.h"
        #include "explode.h"
        #include "basecombatcharacter.h"
        #include        "weapon_molotov.h"
        #include        "grenade_molotov.h"
#endif

#ifdef CLIENT_DLL
#define CWeaponMolotov C_WeaponMolotov
#endif

class CGrenade_Molotov;

class CWeaponMolotov : public CBaseHL2MPCombatWeapon
{
public:
        DECLARE_CLASS( CWeaponMolotov, CBaseHL2MPCombatWeapon );

        DECLARE_NETWORKCLASS();
        DECLARE_PREDICTABLE();

private:
        int  m_nNumAmmoTypes;
        CNetworkVar(bool,m_bNeedDraw);
        CNetworkVar(int,m_iThrowBits);                          // Save the 
current throw bits state
        CNetworkVar(float,m_fNextThrowCheck);                   // When to 
check throw ability next
        CNetworkVar(Vector,     m_vecTossVelocity);

public:

        void                            Precache( void );
        void                            Spawn( void );

        void                            DrawAmmo( void );

        virtual int                     WeaponRangeAttack1Condition( float 
flDot, float flDist );
        virtual bool            WeaponLOSCondition(const Vector &ownerPos, 
const Vector &targetPos, bool bSetConditions);

        void                            SetPickupTouch( void );
        void                            MolotovTouch( CBaseEntity *pOther );    
// default weapon touch
        #ifndef CLIENT_DLL
        int                                     CapabilitiesGet( void ) { 
return bits_CAP_WEAPON_RANGE_ATTACK1; }
#endif

        bool                            ObjectInWay( void );

        void                            ThrowMolotov( const Vector &vecSrc, 
const Vector &vecVelocity);
        void                            ItemPostFrame( void );
        void                            PrimaryAttack( void );
        void                            SecondaryAttack( void );
#ifndef CLIENT_DLL
        DECLARE_ACTTABLE();
#endif
        CWeaponMolotov(void);
};

IMPLEMENT_NETWORKCLASS_ALIASED( WeaponMolotov, DT_WeaponMolotov)

BEGIN_NETWORK_TABLE( CWeaponMolotov, DT_WeaponMolotov )
#ifdef CLIENT_DLL
RecvPropBool( RECVINFO( m_bNeedDraw ) ),
RecvPropInt( RECVINFO( m_iThrowBits ) ),
RecvPropFloat( RECVINFO( m_fNextThrowCheck ) ),
RecvPropVector( RECVINFO( m_vecTossVelocity ) ),
#else
SendPropBool( SENDINFO( m_bNeedDraw ) ),
SendPropInt( SENDINFO( m_iThrowBits ) ),
SendPropFloat( SENDINFO( m_fNextThrowCheck ) ),
SendPropVector( SENDINFO( m_vecTossVelocity ) ),
#endif
END_NETWORK_TABLE()

BEGIN_PREDICTION_DATA( CWeaponMolotov )
END_PREDICTION_DATA()

LINK_ENTITY_TO_CLASS( weapon_molotov, CWeaponMolotov );
PRECACHE_WEAPON_REGISTER(weapon_molotov);

#ifndef CLIENT_DLL

acttable_t      CWeaponMolotov::m_acttable[] =
{
        { ACT_HL2MP_IDLE,                                       
ACT_HL2MP_IDLE_GRENADE,                                 false },
        { ACT_HL2MP_RUN,                                        
ACT_HL2MP_RUN_GRENADE,                                  false },
        { ACT_HL2MP_IDLE_CROUCH,                        
ACT_HL2MP_IDLE_CROUCH_GRENADE,                  false },
        { ACT_HL2MP_WALK_CROUCH,                        
ACT_HL2MP_WALK_CROUCH_GRENADE,                  false },
        { ACT_HL2MP_GESTURE_RANGE_ATTACK,       
ACT_HL2MP_GESTURE_RANGE_ATTACK_GRENADE, false },
        { ACT_HL2MP_GESTURE_RELOAD,                     
ACT_HL2MP_GESTURE_RELOAD_GRENADE,               false },
        { ACT_HL2MP_JUMP,                                       
ACT_HL2MP_JUMP_GRENADE,                                 false },
};

IMPLEMENT_ACTTABLE(CWeaponMolotov);

#endif


void CWeaponMolotov::Precache( void )
{
        PrecacheModel("models/props_junk/w_garb_beerbottle.mdl");       
//<<TEMP>> need real model
        BaseClass::Precache();
}

void CWeaponMolotov::Spawn( void )
{
        // Call base class first
        BaseClass::Spawn();

        m_bNeedDraw             = true;

        SetModel( GetWorldModel() );
        #ifndef CLIENT_DLL
        UTIL_SetSize(this, Vector( -6, -6, -2), Vector(6, 6, 2));
#endif
}

//------------------------------------------------------------------------------
// Purpose : Override to use molotovs pickup touch function
// Input   :
// Output  :
//------------------------------------------------------------------------------
void CWeaponMolotov::SetPickupTouch( void )
{
        SetTouch(MolotovTouch);
}

//-----------------------------------------------------------------------------
// Purpose: Override so give correct ammo
// Input  : pOther - the entity that touched me
// Output :
//-----------------------------------------------------------------------------
void CWeaponMolotov::MolotovTouch( CBaseEntity *pOther )
{
        // ---------------------------------------------------
        //  First give weapon to touching entity if allowed
        // ---------------------------------------------------
        BaseClass::DefaultTouch(pOther);

        // ----------------------------------------------------
        //  Give molotov ammo if touching client
        // ----------------------------------------------------
        if (pOther->GetFlags() & FL_CLIENT)
        {
                // ------------------------------------------------
                //  If already owned weapon of this type remove me
                // ------------------------------------------------
                CBaseCombatCharacter* pBCC = ToBaseCombatCharacter( pOther );
                CWeaponMolotov* oldWeapon = 
(CWeaponMolotov*)pBCC->Weapon_OwnsThisType( GetClassname() );
                if (oldWeapon != this)
                {
                                                #ifdef CLIENT_DLL
#else
                        //UTIL_Remove( this );
#endif
                }
                else
                {
                        #ifdef CLIENT_DLL
#else
                        pBCC->GiveAmmo( 1, m_iSecondaryAmmoType );
                        SetThink (NULL);
#endif
                }
        }
}

//-----------------------------------------------------------------------------
// Purpose:
// Input  :
// Output :
//-----------------------------------------------------------------------------
bool CWeaponMolotov::ObjectInWay( void )
{
        CBaseCombatCharacter *pOwner  = GetOwner();
        if (!pOwner)
        {
                return false;
        }

Vector vecSrc, vecAiming;

        // Take the eye position and direction
        vecSrc = pOwner->EyePosition();

        QAngle angles = pOwner->GetLocalAngles();

        AngleVectors( angles, &vecAiming );

        trace_t tr;

        Vector  vecEnd = vecSrc + (vecAiming * 32);
        UTIL_TraceLine( vecSrc, vecEnd, MASK_SOLID, pOwner, 
COLLISION_GROUP_NONE, &tr );

        if (tr.fraction < 1.0)
        {
                // Don't block on a living creature
                if (tr.m_pEnt)
                {
                        CBaseEntity *pEntity = tr.m_pEnt;
                        CBaseCombatCharacter *pBCC              = 
ToBaseCombatCharacter( pEntity );
                        if (pBCC)
                        {
                                return false;
                        }
                }
                return true;
        }
        else
        {
                return false;
        }
}

//-----------------------------------------------------------------------------
// Purpose: Override to allow throw w/o LOS
// Input  :
// Output :
//-----------------------------------------------------------------------------
bool CWeaponMolotov::WeaponLOSCondition(const Vector &ownerPos, const Vector 
&targetPos,bool bSetConditions)
{
        // <<TODO>> should test if can throw from present location here...
        return true;
}

//-----------------------------------------------------------------------------
// Purpose: Override to check throw
// Input  :
// Output :
//-----------------------------------------------------------------------------
int CWeaponMolotov::WeaponRangeAttack1Condition( float flDot, float flDist )
{
        // If things haven't changed too much since last time
        // just return that previously calculated value
        if (gpGlobals->curtime < m_fNextThrowCheck )
        {
                return m_iThrowBits;
        }

        if ( flDist < m_fMinRange1) {

                m_iThrowBits = 36;

        }
        else if (flDist > m_fMaxRange1) {

                m_iThrowBits = 37;

        }
        else if (flDot < 0.5) {
                m_iThrowBits = 38;

        }
        else {

        }
        // don't check again for a while.
        m_fNextThrowCheck = gpGlobals->curtime + 0.33; // 1/3 second.

        return m_iThrowBits;
}

//-----------------------------------------------------------------------------
// Purpose:
//
//
//-----------------------------------------------------------------------------
void CWeaponMolotov::ThrowMolotov( const Vector &vecSrc, const Vector 
&vecVelocity)
{
        #ifdef CLIENT_DLL
#else
        CGrenade_Molotov *pMolotov = (CGrenade_Molotov*)Create( 
"grenade_molotov", vecSrc, vec3_angle, GetOwner() );

        if (!pMolotov)
        {
                Msg("Couldn't make molotov!\n");
                return;
        }
        pMolotov->SetAbsVelocity( vecVelocity );

        // Tumble through the air
        QAngle angVel( random->RandomFloat ( -100, -500 ), random->RandomFloat 
( -100, -500 ), random->RandomFloat ( -100, -500 ) );
        pMolotov->SetLocalAngularVelocity( angVel );

        pMolotov->SetThrower( GetOwner() );
        pMolotov->SetOwnerEntity( ((CBaseEntity*)GetOwner()) );
        #endif

}

//-----------------------------------------------------------------------------
// Purpose:
//
//
//-----------------------------------------------------------------------------
void CWeaponMolotov::PrimaryAttack( void )
{

        CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );

        if (!pPlayer)
        {
                return;
        }

        Vector vecSrc           = pPlayer->WorldSpaceCenter();
        #ifdef CLIENT_DLL
#else
        Vector vecFacing        = pPlayer->BodyDirection3D( );

        vecSrc                          = vecSrc + vecFacing * 18.0;
        // BUGBUG: is this some hack because it's not at the eye position????
        vecSrc.z                   += 24.0f;

        // Player may have turned to face a wall during the throw anim in which 
case
        // we don't want to throw the SLAM into the wall
        if (ObjectInWay())
        {
                vecSrc   = pPlayer->WorldSpaceCenter() + vecFacing * 5.0;
        }

        Vector vecAiming = pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
        vecAiming.z += 0.20; // Raise up so passes through reticle

        ThrowMolotov(vecSrc, vecAiming*800);
        pPlayer->RemoveAmmo( 1, m_iSecondaryAmmoType );


        // Don't fire again until fire animation has completed
        //m_flNextPrimaryAttack = gpGlobals->curtime + CurSequenceDuration();
        //<<TEMP>> - till real animation is avaible
        m_flNextPrimaryAttack = gpGlobals->curtime + 1.0;
        m_flNextSecondaryAttack = gpGlobals->curtime + 1.0;

        m_bNeedDraw = true;
        #endif
}

//-----------------------------------------------------------------------------
// Purpose:
//
//
//-----------------------------------------------------------------------------
void CWeaponMolotov::SecondaryAttack( void )
{
        //<<TEMP>>
        // Hmmm... what should I do here?
}

//-----------------------------------------------------------------------------
// Purpose:
//
//
//-----------------------------------------------------------------------------
void CWeaponMolotov::DrawAmmo( void )
{
        Msg("Drawing Molotov...\n");
        m_bNeedDraw = false;

        //<<TEMP>> - till real animation is avaible
        m_flNextPrimaryAttack   = gpGlobals->curtime + 2.0;
        m_flNextSecondaryAttack = gpGlobals->curtime + 2.0;

}

//-----------------------------------------------------------------------------
// Purpose: Override so shotgun can do mulitple reloads in a row
// Input  :
// Output :
//-----------------------------------------------------------------------------
void CWeaponMolotov::ItemPostFrame( void )
{
        CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
        if (!pOwner)
        {
                return;
        }


        if ((pOwner->m_nButtons & IN_ATTACK2) && (m_flNextSecondaryAttack <= 
gpGlobals->curtime))
        {
                SecondaryAttack();
        }
        else if ((pOwner->m_nButtons & IN_ATTACK) && (m_flNextPrimaryAttack <= 
gpGlobals->curtime))
        {
                        PrimaryAttack();
        }
        else if (m_bNeedDraw)
        {
                DrawAmmo();
        }
        else
        {
                WeaponIdle( );
        }
}


//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CWeaponMolotov::CWeaponMolotov( void )
{
#ifdef _DEBUG
        m_vecTossVelocity.Init();
#endif

        m_fMinRange1    = 200;
        m_fMaxRange1    = 1000;
}
--
X-Attachment-Id: f_ejrp73oq

//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. 
============//
//
// Purpose:             Molotov weapon
//
// $Workfile:     $
// $Date:         $
//
//-----------------------------------------------------------------------------
// $Log: $
//
// $NoKeywords: $
//=============================================================================//

#include "weapon_hl2mpbasehlmpcombatweapon.h"

#ifndef WEAPON_MOLOTOV_H
#define WEAPON_MOLOTOV_H

#endif  //WEAPON_MOLOTOV_H
--

_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to