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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include <KeyValues.h>
#include "dod_weapon_parse.h"
#include "dod_shareddefs.h"
// criteria that we parse out of the file.
// tells us which player animation states
// should use the alternate wpn p model
static struct
{
const char *m_pCriteriaName;
int m_iFlagValue;
} g_AltWpnCritera[] =
{
{ "ALTWPN_CRITERIA_FIRING", ALTWPN_CRITERIA_FIRING },
{ "ALTWPN_CRITERIA_RELOADING", ALTWPN_CRITERIA_RELOADING },
{ "ALTWPN_CRITERIA_DEPLOYED", ALTWPN_CRITERIA_DEPLOYED },
{ "ALTWPN_CRITERIA_DEPLOYED_RELOAD", ALTWPN_CRITERIA_DEPLOYED_RELOAD },
{ "ALTWPN_CRITERIA_PRONE_DEPLOYED_RELOAD", ALTWPN_CRITERIA_PRONE_DEPLOYED_RELOAD }
};
FileWeaponInfo_t* CreateWeaponInfo()
{
return new CDODWeaponInfo;
}
CDODWeaponInfo::CDODWeaponInfo()
{
m_szReloadModel[0] = '\0';
m_szDeployedModel[0] = '\0';
m_szDeployedReloadModel[0] = '\0';
m_szProneDeployedReloadModel[0] = '\0';
}
void CDODWeaponInfo::Parse( KeyValues *pKeyValuesData, const char *szWeaponName )
{
BaseClass::Parse( pKeyValuesData, szWeaponName );
m_iCrosshairMinDistance = pKeyValuesData->GetInt( "CrosshairMinDistance", 4 );
m_iCrosshairDeltaDistance = pKeyValuesData->GetInt( "CrosshairDeltaDistance", 3 );
m_iMuzzleFlashType = pKeyValuesData->GetFloat( "MuzzleFlashType", 0 );
m_flMuzzleFlashScale = pKeyValuesData->GetFloat( "MuzzleFlashScale", 0.5 );
m_iDamage = pKeyValuesData->GetInt( "Damage", 1 );
m_flAccuracy = pKeyValuesData->GetFloat( "Accuracy", 1.0 );
m_flSecondaryAccuracy = pKeyValuesData->GetFloat( "SecondaryAccuracy", 1.0 );
m_flAccuracyMovePenalty = pKeyValuesData->GetFloat( "AccuracyMovePenalty", 0.1 );
m_flRecoil = pKeyValuesData->GetFloat( "Recoil", 99.0 );
m_flPenetration = pKeyValuesData->GetFloat( "Penetration", 1.0 );
m_flFireDelay = pKeyValuesData->GetFloat( "FireDelay", 0.1 );
m_flSecondaryFireDelay = pKeyValuesData->GetFloat( "SecondaryFireDelay", 0.1 );
m_flTimeToIdleAfterFire = pKeyValuesData->GetFloat( "IdleTimeAfterFire", 1.0 );
m_flIdleInterval = pKeyValuesData->GetFloat( "IdleInterval", 1.0 );
m_bCanDrop = ( pKeyValuesData->GetInt( "CanDrop", 1 ) > 0 );
m_iBulletsPerShot = pKeyValuesData->GetInt( "BulletsPerShot", 1 );
m_iHudClipHeight = pKeyValuesData->GetInt( "HudClipHeight", 0 );
m_iHudClipBaseHeight = pKeyValuesData->GetInt( "HudClipBaseHeight", 0 );
m_iHudClipBulletHeight = pKeyValuesData->GetInt( "HudClipBulletHeight", 0 );
m_iAmmoPickupClips = pKeyValuesData->GetInt( "AmmoPickupClips", 2 );
m_iDefaultAmmoClips = pKeyValuesData->GetInt( "DefaultAmmoClips", 0 );
m_flViewModelFOV = pKeyValuesData->GetFloat( "ViewModelFOV", 90.0f );
// const char *pAnimEx = pKeyValuesData->GetString( "PlayerAnimationExtension", "error" );
// Q_strncpy( m_szAnimExtension, pAnimEx, sizeof( m_szAnimExtension ) );
// if this key exists, use this for reload animations instead of anim_prefix
// Q_strncpy( m_szReloadAnimPrefix, pKeyValuesData->GetString( "reload_anim_prefix", "" ), MAX_WEAPON_PREFIX );
m_flBotAudibleRange = pKeyValuesData->GetFloat( "BotAudibleRange", 2000.0f );
m_iTracerType = pKeyValuesData->GetInt( "Tracer", 0 );
//Weapon Type
const char *pTypeString = pKeyValuesData->GetString( "WeaponType", NULL );
m_WeaponType = WPN_TYPE_UNKNOWN;
if ( !pTypeString )
{
Assert( false );
}
else if ( Q_stricmp( pTypeString, "Melee" ) == 0 )
{
m_WeaponType = WPN_TYPE_MELEE;
}
else if ( Q_stricmp( pTypeString, "Camera" ) == 0 )
{
m_WeaponType = WPN_TYPE_CAMERA;
}
else if ( Q_stricmp( pTypeString, "Grenade" ) == 0 )
{
m_WeaponType = WPN_TYPE_GRENADE;
}
else if ( Q_stricmp( pTypeString, "Pistol" ) == 0 )
{
m_WeaponType = WPN_TYPE_PISTOL;
}
else if ( Q_stricmp( pTypeString, "Rifle" ) == 0 )
{
m_WeaponType = WPN_TYPE_RIFLE;
}
else if ( Q_stricmp( pTypeString, "Sniper" ) == 0 )
{
m_WeaponType = WPN_TYPE_SNIPER;
}
else if ( Q_stricmp( pTypeString, "SubMG" ) == 0 )
{
m_WeaponType = WPN_TYPE_SUBMG;
}
else if ( Q_stricmp( pTypeString, "MG" ) == 0 )
{
m_WeaponType = WPN_TYPE_MG;
}
else if ( Q_stricmp( pTypeString, "Bazooka" ) == 0 )
{
m_WeaponType = WPN_TYPE_BAZOOKA;
}
else if ( Q_stricmp( pTypeString, "Bandage" ) == 0 )
{
m_WeaponType = WPN_TYPE_BANDAGE;
}
else if ( Q_stricmp( pTypeString, "Sidearm" ) == 0 )
{
m_WeaponType = WPN_TYPE_SIDEARM;
}
else if ( Q_stricmp( pTypeString, "RifleGrenade" ) == 0 )
{
m_WeaponType = WPN_TYPE_RIFLEGRENADE;
}
else if ( Q_stricmp( pTypeString, "Bomb" ) == 0 )
{
m_WeaponType = WPN_TYPE_BOMB;
}
else
{
Assert( false );
}
Q_strncpy( m_szReloadModel, pKeyValuesData->GetString( "reloadmodel" ), sizeof( m_szReloadModel ) );
Q_strncpy( m_szDeployedModel, pKeyValuesData->GetString( "deployedmodel" ), sizeof( m_szDeployedModel ) );
Q_strncpy( m_szDeployedReloadModel, pKeyValuesData->GetString( "deployedreloadmodel" ), sizeof( m_szDeployedReloadModel ) );
Q_strncpy( m_szProneDeployedReloadModel, pKeyValuesData->GetString( "pronedeployedreloadmodel" ), sizeof( m_szProneDeployedReloadModel ) );
m_iAltWpnCriteria = ALTWPN_CRITERIA_NONE;
for ( int i=0; i < ARRAYSIZE( g_AltWpnCritera ); i++ )
{
int iVal = pKeyValuesData->GetInt( g_AltWpnCritera[i].m_pCriteriaName, 0 );
if ( iVal == 1 )
{
m_iAltWpnCriteria |= g_AltWpnCritera[i].m_iFlagValue;
}
}
const char *szNormalOffset = pKeyValuesData->GetString( "vm_normal_offset", "0 0 0" );
const char *szProneOffset = pKeyValuesData->GetString( "vm_prone_offset", "0 0 0" );
const char *szIronSightOffset = pKeyValuesData->GetString( "vm_ironsight_offset", "0 0 0" );
sscanf( szNormalOffset, "%f %f %f", &m_vecViewNormalOffset[0], &m_vecViewNormalOffset[1], &m_vecViewNormalOffset[2]);
sscanf( szProneOffset, "%f %f %f", &m_vecViewProneOffset[0], &m_vecViewProneOffset[1], &m_vecViewProneOffset[2]);
sscanf( szIronSightOffset, "%f %f %f", &m_vecIronSightOffset[0], &m_vecIronSightOffset[1], &m_vecIronSightOffset[2]);
m_iDefaultTeam = TEAM_ALLIES;
const char *pDefaultTeam = pKeyValuesData->GetString( "default_team", NULL );
if ( pDefaultTeam )
{
if ( FStrEq( pDefaultTeam, "Axis" ) )
{
m_iDefaultTeam = TEAM_AXIS;
}
else if ( FStrEq( pDefaultTeam, "Allies" ) )
{
m_iDefaultTeam = TEAM_ALLIES;
}
else
{
Assert( !"invalid param to \"default_team\" in weapon scripts\n" );
}
}
}
|