Immolator-ish weapon help

Grab your favourite IDE and tinker with the innards of game engines

Immolator-ish weapon help

Postby Magicmuffin on Wed Jun 27, 2012 5:20 pm

Sorry if this isn't in a larger coding thread, but I have looked everywhere for some problems happening trying to convert the hl2 beta Immolator code (comes with your mod when you create it), from hl2sp to hl2mp, ill post the code and the errors.

Code: Select all
//=========2012-2012, My Corporation===========================================//
//
// Purpose: A weapon that either shoots a beam or a controlled stream of fire (like a boss)
//=========  and some chunks from Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
//=============================================================================//

#include "cbase.h"
#include "npcevent.h"
#include "in_buttons.h"
#ifdef CLIENT_DLL
   #include "c_hl2mp_player.h"
#endif
#ifdef SERVER_DLL
#include "baseentity.h"
#include "soundent.h"   
#include "hl2mp_player.h"
#include "te_particlesystem.h"
#include "basecombatcharacter.h"
#include "util.h"

#endif

#include "weapon_hl2mpbasehlmpcombatweapon.h"

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

#define MAX_BURN_RADIUS      175
#define RADIUS_GROW_RATE   50.0   // units/sec

#define FLAMETHROWER_TARGET_INVALID Vector( FLT_MAX, FLT_MAX, FLT_MAX )

class CWeaponFlamethrower: public CBaseHL2MPCombatWeapon
{
   DECLARE_CLASS( CWeaponFlamethrower, CBaseHL2MPCombatWeapon );
public:
   
   DECLARE_NETWORKCLASS();
   DECLARE_PREDICTABLE();
   DECLARE_ACTTABLE();

CWeaponFlamethrower( void );
void FlameDamage( const CTakeDamageInfo &info, const Vector &vecSrcIn, float flRadius, int iClassIgnore );
   virtual bool WeaponLOSCondition( const Vector &ownerPos, const Vector &targetPos, bool bSetConditions );   
   virtual int   WeaponRangeAttack1Condition( float flDot, float flDist );

void Precache( void );
   void PrimaryAttack( void );
   void ItemPostFrame( void );
   void Update();
   void UpdateThink();

   void StartFlaming();
   void StopFlaming();
   bool IsFlaming() { return m_flBurnRadius != 0.0; }

   DECLARE_DATADESC();

   int   m_beamIndex;

   float m_flBurnRadius;
   float m_flTimeLastUpdatedRadius;

   Vector  m_vecFlameTarget;


};

DECLARE_NETWORKCLASS(CWeaponFlamethrower, DT_WeaponFlamethrower)
BEGIN_NETWORK_TABLE( CWeaponFlamethrower, DT_WeaponFlamethrower )
END_NETWORK_TABLE()
                                                //This part is really giving me some useless problems >:(
LINK_ENTITY_TO_CLASS( info_target_flamethrower, CPointEntity );
LINK_ENTITY_TO_CLASS( weapon_Flamethrower, CWeaponFlamethrower );
PRECACHE_WEAPON_REGISTER( weapon_Flamethrower );

acttable_t CWeaponFlamethrower::m_acttable[] =
{
   { ACT_MP_STAND_IDLE,            ACT_HL2MP_IDLE_PHYSGUN,               false },
   { ACT_MP_CROUCH_IDLE,            ACT_HL2MP_IDLE_CROUCH_PHYSGUN,         false },

   { ACT_MP_RUN,                  ACT_HL2MP_RUN_PHYSGUN,               false },
   { ACT_MP_CROUCHWALK,            ACT_HL2MP_WALK_CROUCH_PHYSGUN,         false },

   { ACT_MP_ATTACK_STAND_PRIMARYFIRE,   ACT_HL2MP_GESTURE_RANGE_ATTACK_PHYSGUN,   false },
   { ACT_MP_ATTACK_CROUCH_PRIMARYFIRE,   ACT_HL2MP_GESTURE_RANGE_ATTACK_PHYSGUN,   false },

   { ACT_MP_RELOAD_STAND,            ACT_HL2MP_GESTURE_RELOAD_PHYSGUN,      false },
   { ACT_MP_RELOAD_CROUCH,            ACT_HL2MP_GESTURE_RELOAD_PHYSGUN,      false },

   { ACT_MP_JUMP,                  ACT_HL2MP_JUMP_PHYSGUN,               false },
};

IMPLEMENT_ACTTABLE( CWeaponFlamethrower );

//-----------------------------------------------------------------------------
// Constructor (Dat constructor)
//-----------------------------------------------------------------------------
CWeaponFlamethrower::CWeaponFlamethrower( void )
{
   m_fMaxRange1 = 4096;
   StopFlaming();
}

void CWeaponFlamethrower::StartFlaming()
{
   // Start the radius really tiny because we use radius == 0.0 to
   // determine whether the immolator is operating or not.
   m_flBurnRadius = 0.1;
   m_flTimeLastUpdatedRadius = gpGlobals->curtime;
   SetThink( UpdateThink );
   SetNextThink( gpGlobals->curtime );

}

void CWeaponFlamethrower::StopFlaming()
{
   m_flBurnRadius = 0.0;
   SetThink( NULL );
   m_vecFlameTarget= FLAMETHROWER_TARGET_INVALID;
   m_flNextPrimaryAttack = gpGlobals->curtime + 5.0;
}            //Had to take out SOUND_DANGER FROM THE CODE OF THE IMMOLATOR
//-----------------------------------------------------------------------------
// Purpose: To precache stuff
//-----------------------------------------------------------------------------
void CWeaponFlamethrower::Precache( void )
{
   m_beamIndex = PrecacheModel( "sprites/bluelaser1.vmt" );

   BaseClass::Precache();
}

//-----------------------------------------------------------------------------
// Purpose: I dunno look at the code
//-----------------------------------------------------------------------------
void CWeaponFlamethrower::PrimaryAttack( void )
{
   WeaponSound( SINGLE );

   if( !IsFlaming() )
   {
      StartFlaming();
   }
}
//-----------------------------------------------------------------------------
// This weapon is said to have Line of Sight when it CAN'T see the target, but
// can see a place near the target than can. This is one sexy comment.
//-----------------------------------------------------------------------------
bool CWeaponFlamethrower::WeaponLOSCondition( const Vector &ownerPos, const Vector &targetPos, bool bSetConditions )
{
   if( IsFlaming() )
   {
      // Don't update while Immolating. This is a committed attack. FO SHO.
      return false;
   }

   // Assume we won't find a target.
   m_vecFlameTarget = targetPos;
   return true;
}

//-----------------------------------------------------------------------------
// Purpose: Weapon firing conditions
//-----------------------------------------------------------------------------
// No comment? well i might as well add one.
void CWeaponFlamethrower::UpdateThink( void )
{
   CBaseCombatCharacter *pOwner = GetOwner();

   if( pOwner && !pOwner->IsAlive() )
   {
      StopFlaming();
      return;
   }

   Update();
   SetNextThink( gpGlobals->curtime + 0.05 );
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void CWeaponFlamethrower::Update()
{
   float flDuration = gpGlobals->curtime - m_flTimeLastUpdatedRadius;
   if( flDuration != 0.0 )
   {
      m_flBurnRadius += RADIUS_GROW_RATE * flDuration;
   }

   // Clamp
   m_flBurnRadius = min( m_flBurnRadius, MAX_BURN_RADIUS );

   CBasePlayer *pOwner = ToBasePlayer( GetOwner() );

   Vector vecSrc;
   Vector vecAiming;

   if( pOwner )
   {
      vecSrc    = pOwner->Weapon_ShootPosition( );
      vecAiming = pOwner->GetAutoaimVector(AUTOAIM_2DEGREES);
   }
   else
   {
      CBaseCombatCharacter *pOwner = GetOwner();

      vecSrc = pOwner->Weapon_ShootPosition( );
      vecAiming = m_vecFlameTarget - vecSrc;
      VectorNormalize( vecAiming );
   }

   trace_t   tr;
   UTIL_TraceLine( vecSrc, vecSrc + vecAiming * MAX_TRACE_LENGTH, MASK_SHOT, pOwner, COLLISION_GROUP_NONE, &tr );

   int brightness;
   brightness = 255 * (m_flBurnRadius/MAX_BURN_RADIUS);
   UTIL_Beam(  vecSrc,
            tr.endpos,
            m_beamIndex,
            0,      //halo index
            0,      //frame start
            2.0f,   //framerate
            0.1f,   //life
            20,      // width
            1,      // endwidth
            0,      // fadelength,
            1,      // noise

            0,      // red
            255,   // green
            0,      // blue,

            brightness, // bright
            100  // speed
            );


   if( tr.DidHitWorld() )
   {
      int beams;

      for( beams = 0 ; beams < 5 ; beams++ )
      {
         Vector vecDest;

         // Random unit vector
         vecDest.x = random->RandomFloat( -1, 1 );
         vecDest.y = random->RandomFloat( -1, 1 );
         vecDest.z = random->RandomFloat( 0, 1 );

         // Push out to radius dist.
         vecDest = tr.endpos + vecDest * m_flBurnRadius;

         UTIL_Beam(  tr.endpos,
                  vecDest,
                  m_beamIndex,
                  0,      //halo index
                  0,      //frame start
                  2.0f,   //framerate
                  0.15f,   //life
                  20,      // width
                  1.75,   // endwidth
                  0.75,   // fadelength,
                  15,      // noise

                  255,      // red
                  0,   // green
                  0,      // blue,

                  128, // bright
                  100  // speed
                  );
      }

      // Immolator starts to hurt a few seconds after the effect is seen
      if( m_flBurnRadius > 64.0 )
      {
         FlameDamage( CTakeDamageInfo( this, this, 1, DMG_BURN ), tr.endpos, m_flBurnRadius, CLASS_NONE );
      }
   }
   else
   {
      // The attack beam struck some kind of entity directly.
   }

   m_flTimeLastUpdatedRadius = gpGlobals->curtime;

   if( m_flBurnRadius >= MAX_BURN_RADIUS )
   {
      StopFlaming();
   }
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponFlamethrower::ItemPostFrame( void )
{
   BaseClass::ItemPostFrame();
}



void CWeaponFlamethrower::FlameDamage( const CTakeDamageInfo &info, const Vector &vecSrcIn, float flRadius, int iClassIgnore )
{
   CBaseEntity *pEntity = NULL;
   trace_t      tr;
   Vector      vecSpot;

   Vector vecSrc = vecSrcIn;

   // iterate on all entities in the vicinity.
   for ( CEntitySphereQuery sphere( vecSrc, flRadius ); pEntity = sphere.GetCurrentEntity(); sphere.NextEntity() )
   {
      CBaseCombatCharacter *pBCC;

      pBCC = pEntity->MyCombatCharacterPointer();

      if ( pBCC && !pBCC->IsOnFire() )
      {
         // UNDONE: this should check a damage mask, not an ignore
         if ( iClassIgnore != CLASS_NONE && pEntity->Classify() == iClassIgnore )
         {
            continue;
         }

         if( pEntity == GetOwner() )
         {
            continue;
         }

         pBCC->Ignite( random->RandomFloat( 15, 20 ) );
      }
   }
}

and the errors
Code: Select all
  weapon_flamethrower.cpp
..\shared\hl2mp\weapon_flamethrower.cpp(70): warning C4002: too many actual parameters for macro 'DECLARE_NETWORKCLASS'
..\shared\hl2mp\weapon_flamethrower.cpp(70): error C2575: 'YouForgotToImplementOrDeclareClientClass' : only member functions and bases can be virtual
..\shared\hl2mp\weapon_flamethrower.cpp(70): error C2575: 'GetClientClass' : only member functions and bases can be virtual
..\shared\hl2mp\weapon_flamethrower.cpp(70): error C2255: 'friend' : not allowed outside of a class definition
..\shared\hl2mp\weapon_flamethrower.cpp(74): error C2061: syntax error : identifier 'CPointEntity'
..\shared\hl2mp\weapon_flamethrower.cpp(74): error C2065: 'CPointEntity' : undeclared identifier
..\shared\hl2mp\weapon_flamethrower.cpp(74): error C2070: ''unknown-type'': illegal sizeof operand
..\shared\hl2mp\weapon_flamethrower.cpp(112): error C3867: 'CWeaponFlamethrower::UpdateThink': function call missing argument list; use '&CWeaponFlamethrower::UpdateThink' to create a pointer to member
..\shared\hl2mp\weapon_flamethrower.cpp(207): error C2039: 'Weapon_ShootPosition' : is not a member of 'C_BaseCombatCharacter'
          c:\users\enzo\src\game\client\c_basecombatcharacter.h(21) : see declaration of 'C_BaseCombatCharacter'
..\shared\hl2mp\weapon_flamethrower.cpp(217): error C3861: 'UTIL_Beam': identifier not found
..\shared\hl2mp\weapon_flamethrower.cpp(254): error C3861: 'UTIL_Beam': identifier not found
..\shared\hl2mp\weapon_flamethrower.cpp(278): error C2514: 'CTakeDamageInfo' : class has no constructors
          c:\users\enzo\src\game\client\c_baseentity.h(55) : see declaration of 'CTakeDamageInfo'
..\shared\hl2mp\weapon_flamethrower.cpp(278): error C2065: 'CLASS_NONE' : undeclared identifier
..\shared\hl2mp\weapon_flamethrower.cpp(321): error C2065: 'CLASS_NONE' : undeclared identifier
..\shared\hl2mp\weapon_flamethrower.cpp(321): error C2039: 'Classify' : is not a member of 'C_BaseEntity'
          c:\users\enzo\src\game\client\c_baseentity.h(173) : see declaration of 'C_BaseEntity'
..\shared\hl2mp\weapon_flamethrower.cpp(331): error C2039: 'Ignite' : is not a member of 'C_BaseCombatCharacter'
          c:\users\enzo\src\game\client\c_basecombatcharacter.h(21) : see declaration of 'C_BaseCombatCharacter'
User avatar
Magicmuffin
Member
Member
 
Joined: Tue Jun 12, 2012 2:41 am
Location: FL, USA

Re: Immolator-ish weapon help

Postby zombie@computer on Wed Jun 27, 2012 6:37 pm

And your question?
When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Re: Immolator-ish weapon help

Postby Magicmuffin on Wed Jun 27, 2012 8:06 pm

My question would be: How should I go along converting HL2 weapons to HL2MP?
User avatar
Magicmuffin
Member
Member
 
Joined: Tue Jun 12, 2012 2:41 am
Location: FL, USA

Re: Immolator-ish weapon help

Postby zombie@computer on Thu Jun 28, 2012 11:47 am

You can start by replacing every reference to 'hl2mp' by 'hl2', that'll probably fix 80% of your problems (this usually means 1000's more errors will be listed though). Then see what errors remain. Need more help, post the remaining problems.
When you are up to your neck in shit, keep your head up high
zombie@computer
Forum Goer Elite™
Forum Goer Elite™
 
Joined: Fri Dec 31, 2004 5:58 pm
Location: Lent, Netherlands

Return to Programming

Who is online

Users browsing this forum: No registered users