Mega Gravity Gun, compiling problems

z3rb

Newbie
Joined
Oct 8, 2006
Messages
48
Reaction score
0
Okay, so I've been playing about with the SourceSDK today, and I decided a simple mod would be to create a console command that would give you the mega gravity gun.

So here's what I've come up with. This is in weapon_physcannon.cpp.
Code:
//========= Copyright ? 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: Physics cannon
//
//=============================================================================//

#include "cbase.h"
#include "player.h"
#include "gamerules.h"
#include "soundenvelope.h"
#include "engine/IEngineSound.h"
#include "physics.h"
#include "in_buttons.h"
#include "soundent.h"
#include "IEffects.h"
#include "ndebugoverlay.h"
#include "shake.h"
#include "hl2_player.h"
#include "beam_shared.h"
#include "sprite.h"
#include "util.h"
#include "weapon_physcannon.h"
#include "physics_saverestore.h"
#include "ai_basenpc.h"
#include "player_pickup.h"
#include "physics_prop_ragdoll.h"
#include "globalstate.h"
#include "props.h"
#include "movevars_shared.h"
#include "basehlcombatweapon.h"
#include "te_effect_dispatch.h"
#include "vphysics/friction.h"
#include "saverestore_utlvector.h"
#include "prop_combine_ball.h"
#include "physobj.h"
#include "hl2_gamerules.h"
#include "citadel_effects_shared.h"
#include "eventqueue.h"
#include "model_types.h"
#include "ai_interactions.h"
#include "rumble_shared.h"
#include "convar.h"
#include "triggers.h"
#include "basecombatweapon_shared.h"

//-----------------------------------------------------------------------------
// SuperPhysGun. Derived from CTriggerWeaponDissolve in hl2_triggers.cpp
//-----------------------------------------------------------------------------
class SuperPhysClass : public CTriggerMultiple
{
	DECLARE_CLASS( SuperPhysClass, CTriggerMultiple );
	DECLARE_DATADESC();
	DECLARE_SERVERCLASS();

public:
	void	Destroy( void );
	void	DoIt( void );

private:

	COutputEvent	m_OnChargingPhyscannon;

	CUtlVector< CHandle<CBaseCombatWeapon> >	m_pWeapons;
};

BEGIN_DATADESC( SuperPhysClass )

	DEFINE_UTLVECTOR( m_pWeapons,		FIELD_EHANDLE ),

	DEFINE_OUTPUT( m_OnChargingPhyscannon, "OnChargingPhyscannon" ),

	DEFINE_THINKFUNC( DoIt ),

END_DATADESC()

//-----------------------------------------------------------------------------
// Destructor
//-----------------------------------------------------------------------------
void SuperPhysClass::Destroy( void )
{
	m_pWeapons.Purge();
}
[COLOR="Red"]//Don't ask about this bit, it just solved a compiling problem earlier.[/COLOR]
SuperPhysClass link;
Code:
//-----------------------------------Added--------------------------------------
// Gives client super physgun
//------------------------------------------------------------------------------
void SuperPhysClass::DoIt (void)
	{
	if ( !sv_cheats->GetBool() )
		return;

	//So sv_cheats has been triggered, it's safe to give them the superphysgun.
	int	numWeapons = m_pWeapons.Count();

	// Dissolve all the items within the volume
	for ( int i = 0; i < numWeapons; i++ )
	{
		CBaseCombatWeapon *pWeapon = m_pWeapons[i];
		
		// The physcannon upgrades when this happens
		if ( FClassnameIs( pWeapon, "weapon_physcannon" ) )
		{
			// This must be the last weapon for us to care
			if ( numWeapons > 1 )
				continue;

			PhysCannonBeginUpgrade( pWeapon );
			//m_OnChargingPhyscannon.FireOutput( this, this );


			// We're done
			return;
		}
	}
	}
void CC_Superphysgun_f (void)
{
	link.DoIt();
	return;
}
static ConCommand super_phys("super_phys", CC_Superphysgun_f, "Gives player super gravity gun (must have sv_cheats).", FCVAR_CHEAT );

It's pretty much just a modified version of trigger_weapon_dissolve.

However, it just won't compile.

Here's my errors from Visual Studio (2005):
Code:
1>------ Build started: Project: server_hl2, Configuration: Release HL2 Win32 ------
1>Compiling...
1>weapon_physcannon.cpp
1>Linking...
1>choreoobjects.lib(choreoevent.obj) : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
1>   Creating library Release HL2/server.lib and object Release HL2/server.exp
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
1>weapon_physcannon.obj : error LNK2001: unresolved external symbol "public: virtual class ServerClass * __thiscall SuperPhysClass::GetServerClass(void)" (?GetServerClass@SuperPhysClass@@UAEPAVServerClass@@XZ)
1>weapon_physcannon.obj : error LNK2001: unresolved external symbol "public: virtual char const * __thiscall SuperPhysClass::GetClassName(void)" (?GetClassName@SuperPhysClass@@UAEPBDXZ)
1>weapon_physcannon.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall SuperPhysClass::YouForgotToImplementOrDeclareServerClass(void)" (?YouForgotToImplementOrDeclareServerClass@SuperPhysClass@@UAEHXZ)
1>Release HL2/server.dll : fatal error LNK1120: 3 unresolved externals
1>Creating browse information file...
1>Microsoft Browse Information Maintenance Utility Version 8.00.50727
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>Build log was saved at "file://f:\Gravity\src\dlls\Release HL2\BuildLog.htm"
1>server_hl2 - 4 error(s), 3 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I'm not sure if this is a source thing or something I've done completely wrong, since I'm not entirely familiar with C++.

I'm not asking for a difinitive "THIS IS HOW YOU FIX IT" guide, rather a push in the right direction, thanks.
 
I'm asking anyway.

//Don't ask about this bit, it just solved a compiling problem earlier.
SuperPhysClass link;


Where error did that fix?

Valve's SDK is quite friendly when it comes to certain minor mistakes.

Notice this error message in the errorlog ;)

1>weapon_physcannon.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall SuperPhysClass::YouForgotToImplementOrDeclareServerClass(void)"
 
Code:
void CC_Superphysgun_f (void)
{
	link.DoIt();  <-That "link." part
	return;
}

No where in the source sdk code can I find anything like that, what is it's purpose?

Also, your weapons list is empty, you have to cycle through the players weapons somehow and add them to the list.
 
Back
Top