Skip to content

Commit 414eb91

Browse files
committed
Fixed a few issues with BaseEntity attributes.
Fixed an error for godmode in data.
1 parent 7cd8679 commit 414eb91

File tree

4 files changed

+33
-37
lines changed

4 files changed

+33
-37
lines changed

addons/source-python/data/source-python/properties/player/csgo.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ type = 'int'
7777
[godmode]
7878
prop = 'm_lifeState'
7979
type = 'int'
80-
True = 512
81-
False = 0
80+
True = 0
81+
False = 512
8282

8383
[place]
8484
prop = 'm_szLastPlaceName'

addons/source-python/data/source-python/properties/player/cstrike.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ type = 'int'
7373
[god]
7474
prop = 'm_lifeState'
7575
type = 'int'
76-
True = 512
77-
False = 0
76+
True = 0
77+
False = 512
7878

7979
[place]
8080
prop = 'm_szLastPlaceName'

addons/source-python/packages/source-python/entities/attributes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def get_game_attributes(self, args):
5050
# Loop through all given entities
5151
for arg in args:
5252

53-
# Add teh entities to the dictionary
53+
# Add the entities to the dictionary
5454
values.update(self[arg])
5555

5656
# Return all attributes for the given entities

addons/source-python/packages/source-python/entities/entity.py

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# >> IMPORTS
55
# =============================================================================
66
# Source.Python Imports
7-
#from Source import Binutils
87
from conversions_c import edict_from_index
8+
from memory_c import CPointer
99
from public import public
1010
# Entities
1111
#from entities.functions import EntityFunctions
@@ -94,55 +94,55 @@ def __getattr__(self, attr):
9494
def _get_property(self, item):
9595
'''Gets the value of the given property'''
9696

97-
# Get the property's type
98-
prop_type = self.properties[item].type
97+
# Get the property so that we don't have to make multiple calls
98+
prop = self.properties[item]
9999

100100
# Get the property's value
101-
value = getattr(self.edict, 'get_prop_{0}'.format(
102-
prop_type))(self.properties[item].prop)
101+
value = getattr(
102+
self.edict, 'get_prop_{0}'.format(prop.type))(prop.prop)
103103

104104
# Is the property a True/False property?
105-
if 'True' in self.properties[item]:
105+
if 'True' in prop:
106106

107107
# Return if the current value equals the "True" value
108-
return value == self.properties[item]['True']
108+
return value == prop['True']
109109

110110
# Return the value of the property
111111
return value
112112

113113
def _get_keyvalue(self, item):
114114
'''Gets the value of the given keyvalue'''
115115

116-
# Get the keyvalue's type
117-
kv_type = self.keyvalues[item].type
118-
119116
# Return the value of the given keyvalue
120-
return getattr(self.edict, 'get_keyvalue_{0}'.format(kv_type))(item)
117+
return getattr(
118+
self.edict, 'get_keyvalue_{0}'.format(self.keyvalues[item]))(item)
121119

122120
def _get_offset(self, item):
123121
'''Gets the value of the given offset'''
124122

125-
# Get the offset's type
126-
offset_type = self.offsets[item].type
123+
# Get the offset so that we don't have to make multiple calls
124+
offset = self.offsets[item]
127125

128126
# Get the CPointer instance for the entity
129127
pointer = CPointer(self.pointer)
130128

131129
# Return the value of the offset
132-
return getattr(pointer, 'get_{0}'.format(
133-
offset_type))(self.offsets[item].offset)
130+
return getattr(pointer, 'get_{0}'.format(offset.type))(offset.offset)
134131

135132
def _get_function(self, item):
136133
'''Calls a dynamic function'''
137134

135+
# Get the function so that we don't have to make multiple calls
136+
function = self.functions[item]
137+
138138
# Does the entity's pointer need to be added to the arguments?
139-
if self.functions[item].pointer_index != -1:
139+
if function.pointer_index != -1:
140140

141141
# Set the entity's pointer as the current one
142-
self.functions[item].current_pointer = self.pointer
142+
function.current_pointer = self.pointer
143143

144144
# Return the pre call function method
145-
return self.functions[item]._pre_call_function
145+
return function._pre_call_function
146146

147147
def __setattr__(self, attr, value):
148148
'''Finds if the attribute is value and sets its value'''
@@ -194,40 +194,36 @@ def __setattr__(self, attr, value):
194194
def _set_property(self, item, value):
195195
'''Sets the value of the given propery'''
196196

197-
# Get the property's type
198-
prop_type = self.properties[item].type
197+
# Get the property so that we don't have to make multiple calls
198+
prop = self.properties[item]
199199

200200
# Is the property a True/False property?
201-
if 'True' in self.properties[item]:
201+
if 'True' in prop:
202202

203203
# Get the exact value to set the property to
204-
value = self.properties[item][str(value)]
204+
value = prop[str(value)]
205205

206206
# Set the property's value
207-
getattr(prop, 'set_prop_{0}'.format(
208-
prop_type))(self.properties[item].prop, value)
207+
getattr(self.edict, 'set_prop_{0}'.format(prop.type))(prop.prop, value)
209208

210209
def _set_keyvalue(self, item, value):
211210
'''Sets the value of the given keyvalue'''
212211

213-
# Get the keyvalue's type
214-
kv_type = self.keyvalues[item]
215-
216212
# Set the keyvalue's value
217-
getattr(self.edict, 'set_keyvalue_{0}'.format(kv_type))(item, value)
213+
getattr(self.edict, 'set_keyvalue_{0}'.format(
214+
self.keyvalues[item]))(item, value)
218215

219216
def _set_offset(self, item, value):
220217
'''Sets the value of the given offset'''
221218

222-
# Get the offset's type
223-
offset_type = self.offsets[item].type
219+
# Get the offset so that we don't have to make multiple calls
220+
offset = self.offsets[item]
224221

225222
# Get the CPointer instance for the entity
226223
pointer = CPointer(self.pointer)
227224

228225
# Set the offset's value
229-
getattr(pointer, 'set_{0}'.format(
230-
offset_type))(self.offsets[item].offset, value)
226+
getattr(pointer, 'set_{0}'.format(offset.type))(offset.offset, value)
231227

232228
def get_color(self):
233229
'''Returns a 4 part tuple (RGBA) for the entity's color'''

0 commit comments

Comments
 (0)