summaryrefslogtreecommitdiff
path: root/game/server/tf/trigger_catapult.h
blob: 3fbf66fb594e391a944684508f4efcf9c9b93d82 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

// copied from portal2 code; original code came with client-predicted counterpart,
// but implementing predictable triggers in tf2 wasn't trivial so this is just the
// server component. it works but causes prediction errors.
#ifndef TRIGGER_CATAPULT_H
#define TRIGGER_CATAPULT_H
#ifdef _WIN32
#pragma once
#endif

#include "triggers.h"


class CTriggerCatapult : public CBaseTrigger
{
	DECLARE_CLASS( CTriggerCatapult, CBaseTrigger );
	DECLARE_DATADESC();
	//DECLARE_SERVERCLASS();

public:

	CTriggerCatapult( void );

	virtual void	Spawn( void );
	virtual void	StartTouch( CBaseEntity *pOther );
	virtual void	EndTouch( CBaseEntity *pOther );
	virtual int		DrawDebugTextOverlays(void);
	virtual void	DrawDebugGeometryOverlays( void );

	void			LaunchThink( void );

	void			PlayerPassesTriggerFiltersThink( void );
	static const char *s_szPlayerPassesTriggerFiltersThinkContext;

private:
	void			InputSetPlayerSpeed( inputdata_t &in );
	void			InputSetPhysicsSpeed( inputdata_t &in );
	void			InputSetLaunchTarget( inputdata_t &in );
	void			InputSetExactVelocityChoiceType( inputdata_t &in );

	void			LaunchByTarget( CBaseEntity *pVictim, CBaseEntity *pTarget  );
	Vector			CalculateLaunchVector( CBaseEntity *pVictim, CBaseEntity *pTarget  );
	Vector			CalculateLaunchVectorPreserve( Vector vecInitialVelocity, CBaseEntity *pVictim, CBaseEntity *pTarget, bool bForcePlayer = false );

	void			LaunchByDirection( CBaseEntity *pVictim  );
	void			OnLaunchedVictim( CBaseEntity *pVictim );

	float m_flRefireDelay[MAX_PLAYERS + 1];
	float m_flPlayerVelocity;
	float m_flPhysicsVelocity;
	QAngle m_vecLaunchAngles;
	string_t m_strLaunchTarget;
	int m_ExactVelocityChoice;
	bool m_bUseExactVelocity;
	bool m_bUseThresholdCheck;
	float m_flLowerThreshold;
	float m_flUpperThreshold;
	float m_flEntryAngleTolerance;
	EHANDLE m_hLaunchTarget;
	bool m_bOnlyVelocityCheck;
	bool m_bApplyAngularImpulse;
	bool m_bPlayersPassTriggerFilters;
	float m_flAirControlSupressionTime;
	bool m_bDirectionSuppressAirControl;

	//CNetworkArray( float, m_flRefireDelay, MAX_PLAYERS + 1 ); // 0 for physics object the rest for each player userid
	//CNetworkVar( float, m_flPlayerVelocity );
	//CNetworkVar( float, m_flPhysicsVelocity );
	//CNetworkQAngle( m_vecLaunchAngles );
	////CNetworkVar( string_t, m_strLaunchTarget );
	//string_t m_strLaunchTarget;

	//CNetworkVar( int, m_ExactVelocityChoice );
	//CNetworkVar( bool, m_bUseExactVelocity );

	//CNetworkVar( bool, m_bUseThresholdCheck );
	//CNetworkVar( float, m_flLowerThreshold );
	//CNetworkVar( float, m_flUpperThreshold );
	//CNetworkVar( float, m_flEntryAngleTolerance );

	//CNetworkHandle( CBaseEntity, m_hLaunchTarget );

	//CNetworkVar( bool, m_bOnlyVelocityCheck );
	//CNetworkVar( bool, m_bApplyAngularImpulse );
	//CNetworkVar( bool, m_bPlayersPassTriggerFilters );

	//CNetworkVar( float, m_flAirControlSupressionTime ); // After catapult, stop air control for this long (or default of quarter second if this value is negative)
	//CNetworkVar( bool, m_bDirectionSuppressAirControl );	// Do we want to use air control suppression for directional catapults.

	COutputEvent	m_OnCatapulted;

	CUtlVector< EHANDLE > m_hAbortedLaunchees;
};

#endif // TRIGGER_CATAPULT_H