1+ /* *
2+ * =============================================================================
3+ * Source Python
4+ * Copyright (C) 2012-2016 Source Python Development Team. All rights reserved.
5+ * =============================================================================
6+ *
7+ * This program is free software; you can redistribute it and/or modify it under
8+ * the terms of the GNU General Public License, version 3.0, as published by the
9+ * Free Software Foundation.
10+ *
11+ * This program is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14+ * details.
15+ *
16+ * You should have received a copy of the GNU General Public License along with
17+ * this program. If not, see <http://www.gnu.org/licenses/>.
18+ *
19+ * As a special exception, the Source Python Team gives you permission
20+ * to link the code of this program (as well as its derivative works) to
21+ * "Half-Life 2," the "Source Engine," and any Game MODs that run on software
22+ * by the Valve Corporation. You must obey the GNU General Public License in
23+ * all respects for all other code used. Additionally, the Source.Python
24+ * Development Team grants this exception to all derivative works.
25+ */
26+
27+ // ============================================================================
28+ // >> INCLUDES
29+ // ============================================================================
30+ // Source.Python
31+ #include " weapons_entity.h"
32+
33+
34+ // ============================================================================
35+ // >> PlayerMixin
36+ // ============================================================================
37+ boost::shared_ptr<WeaponMixin> WeaponMixin::__init__ (unsigned int uiEntityIndex)
38+ {
39+ CBaseEntityWrapper* pEntity = (CBaseEntityWrapper*) ExcBaseEntityFromIndex (uiEntityIndex);
40+
41+ // TODO
42+ // if (!pEntity->IsPlayer())
43+ // BOOST_RAISE_EXCEPTION(PyExc_ValueError, "Index '%d' is not a valid weapon.", uiEntityIndex);
44+
45+ return WeaponMixin::wrap (pEntity->GetBaseEntity ());
46+ }
47+
48+ boost::shared_ptr<WeaponMixin> WeaponMixin::wrap (CBaseEntity* pEntity)
49+ {
50+ return boost::shared_ptr<WeaponMixin>(
51+ (WeaponMixin *) pEntity,
52+ &NeverDeleteDeleter<WeaponMixin *>
53+ );
54+ }
55+
56+
57+ // CBaseCombatWeapon
58+ float WeaponMixin::GetNextAttack ()
59+ {
60+ static int offset = FindNetworkPropertyOffset (" LocalActiveWeaponData.m_flNextPrimaryAttack" );
61+ return GetNetworkPropertyByOffset<float >(offset);
62+ }
63+
64+ void WeaponMixin::SetNextAttack (float value)
65+ {
66+ static int offset = FindNetworkPropertyOffset (" LocalActiveWeaponData.m_flNextPrimaryAttack" );
67+ SetNetworkPropertyByOffset<float >(offset, value);
68+ }
69+
70+
71+ float WeaponMixin::GetNextSecondaryFireAttack ()
72+ {
73+ static int offset = FindNetworkPropertyOffset (" LocalActiveWeaponData.m_flNextSecondaryAttack" );
74+ return GetNetworkPropertyByOffset<float >(offset);
75+ }
76+
77+ void WeaponMixin::SetNextSecondaryFireAttack (float value)
78+ {
79+ static int offset = FindNetworkPropertyOffset (" LocalActiveWeaponData.m_flNextSecondaryAttack" );
80+ SetNetworkPropertyByOffset<float >(offset, value);
81+ }
82+
83+
84+ int WeaponMixin::GetAmmoProp ()
85+ {
86+ static int offset = FindNetworkPropertyOffset (" LocalWeaponData.m_iPrimaryAmmoType" );
87+ return GetNetworkPropertyByOffset<int >(offset);
88+ }
89+
90+ void WeaponMixin::SetAmmoProp (int value)
91+ {
92+ static int offset = FindNetworkPropertyOffset (" LocalWeaponData.m_iPrimaryAmmoType" );
93+ SetNetworkPropertyByOffset<int >(offset, value);
94+ }
95+
96+
97+ int WeaponMixin::GetSecondaryFireAmmoProp ()
98+ {
99+ static int offset = FindNetworkPropertyOffset (" LocalWeaponData.m_iSecondaryAmmoType" );
100+ return GetNetworkPropertyByOffset<int >(offset);
101+ }
102+
103+ void WeaponMixin::SetSecondaryFireAmmoProp (int value)
104+ {
105+ static int offset = FindNetworkPropertyOffset (" LocalWeaponData.m_iSecondaryAmmoType" );
106+ SetNetworkPropertyByOffset<int >(offset, value);
107+ }
108+
109+
110+ int WeaponMixin::GetOwnerHandle ()
111+ {
112+ static int offset = FindNetworkPropertyOffset (" m_hOwner" );
113+ return GetNetworkPropertyByOffset<int >(offset);
114+ }
115+
116+ void WeaponMixin::SetOwnerHandle (int value)
117+ {
118+ static int offset = FindNetworkPropertyOffset (" m_hOwner" );
119+ SetNetworkPropertyByOffset<int >(offset, value);
120+ }
121+
122+
123+ int WeaponMixin::GetClip ()
124+ {
125+ static int offset = FindDatamapPropertyOffset (" m_iClip1" );
126+ return GetNetworkPropertyByOffset<int >(offset);
127+ }
128+
129+ void WeaponMixin::SetClip (int value)
130+ {
131+ static int offset = FindDatamapPropertyOffset (" m_iClip1" );
132+ SetNetworkPropertyByOffset<int >(offset, value);
133+ }
134+
135+
136+ int WeaponMixin::GetSecondaryFireClip ()
137+ {
138+ static int offset = FindDatamapPropertyOffset (" m_iClip2" );
139+ return GetNetworkPropertyByOffset<int >(offset);
140+ }
141+
142+ void WeaponMixin::SetSecondaryFireClip (int value)
143+ {
144+ static int offset = FindDatamapPropertyOffset (" m_iClip2" );
145+ SetNetworkPropertyByOffset<int >(offset, value);
146+ }
147+
148+
149+ int WeaponMixin::GetFlipViewModel ()
150+ {
151+ static int offset = FindNetworkPropertyOffset (" LocalWeaponData.m_bFlipViewModel" );
152+ return GetNetworkPropertyByOffset<int >(offset);
153+ }
154+
155+ void WeaponMixin::SetFlipViewModel (int value)
156+ {
157+ static int offset = FindNetworkPropertyOffset (" LocalWeaponData.m_bFlipViewModel" );
158+ SetNetworkPropertyByOffset<int >(offset, value);
159+ }
160+
161+
162+ int WeaponMixin::GetWorldModelIndex ()
163+ {
164+ static int offset = FindNetworkPropertyOffset (" m_iWorldModelIndex" );
165+ return GetNetworkPropertyByOffset<int >(offset);
166+ }
167+
168+ void WeaponMixin::SetWorldModelIndex (int value)
169+ {
170+ static int offset = FindNetworkPropertyOffset (" m_iWorldModelIndex" );
171+ SetNetworkPropertyByOffset<int >(offset, value);
172+ }
173+
174+
175+ // CS:GO
176+ int WeaponMixin::GetPrimaryAmmoCount ()
177+ {
178+ static int offset = FindNetworkPropertyOffset (" m_iPrimaryReserveAmmoCount" );
179+ return GetNetworkPropertyByOffset<int >(offset);
180+ }
181+
182+ void WeaponMixin::SetPrimaryAmmoCount (int value)
183+ {
184+ static int offset = FindNetworkPropertyOffset (" m_iPrimaryReserveAmmoCount" );
185+ SetNetworkPropertyByOffset<int >(offset, value);
186+ }
187+
188+
189+ int WeaponMixin::GetSecondaryAmmoCount ()
190+ {
191+ static int offset = FindNetworkPropertyOffset (" m_iSecondaryReserveAmmoCount" );
192+ return GetNetworkPropertyByOffset<int >(offset);
193+ }
194+
195+ void WeaponMixin::SetSecondaryAmmoCount (int value)
196+ {
197+ static int offset = FindNetworkPropertyOffset (" m_iSecondaryReserveAmmoCount" );
198+ SetNetworkPropertyByOffset<int >(offset, value);
199+ }
0 commit comments