Page 1 of 1

player/entity constants: GODMODE

Posted: Thu Jun 04, 2015 1:54 pm
by BackRaw
Hi,

as for a player entity to be in godmode, which one should I use?

Syntax: Select all

from entities.constants import EntityStates

from players.constants import LifeState
from players.entity import PlayerEntity
from players.helpers import index_from_userid

from events import Event


@Event
def player_say(game_event):
player = PlayerEntity(index_from_userid(game_event.get_int('userid')))

"""GodMode"""

# manually
player.life_state = 0

# LifeState constants
player.life_state = LifeState.DEAD # is this the equivalent to 0 ??

# EntityStates constants
player.life_state = EntityStates.GODMOD
or, more precisely: What's the different between EntityStates and LifeState?

Posted: Thu Jun 04, 2015 2:41 pm
by satoon101
To set life_state, you would want to use LifeState values. Though, ideally, you would really set the m_takedamage property using the entities.constants.TakeDamage enum.

Posted: Thu Jun 04, 2015 3:27 pm
by BackRaw
Why? it seems a bit odd using Entity constants for Players lol :D

is LifeState.DEAD the correct value here?

Posted: Thu Jun 04, 2015 3:30 pm
by satoon101
Players are entities. Using m_takedamage allows you to set it so that an entity/player does not take damage. This is a true godmode instead of being tricky with life states.

Posted: Thu Jun 04, 2015 3:32 pm
by BackRaw
satoon101 wrote:Players are entities. Using m_takedamage allows you to set it so that an entity/player does not take damage. This is a true godmode instead of being tricky with life states.


Yeah I kinda thought of it that way but I wasn't sure. Thanks, I'll look into it :)

Posted: Thu Jun 04, 2015 4:05 pm
by satoon101
As far as LifeState values, for any enum class, to get the 'real' value of each member, you can use:

Syntax: Select all

for name in dir(LifeState):
if not name.isupper():
continue
print(name, getattr(LifeState, name).real)

Posted: Thu Jun 04, 2015 5:21 pm
by BackRaw
satoon101 wrote:As far as LifeState values, for any enum class, to get the 'real' value of each member, you can use:

Syntax: Select all

for name in dir(LifeState):
if not name.isupper():
continue
print(name, getattr(LifeState, name).real)

Good to know, thanks.

Posted: Fri Jul 03, 2015 11:49 am
by Mahi
satoon101 wrote:Players are entities. Using m_takedamage allows you to set it so that an entity/player does not take damage. This is a true godmode instead of being tricky with life states.
What would be the most convenient way of using m_takedamage? Is there a property for it or should I use player.set_property_bool (or int?) for it?

Posted: Fri Jul 03, 2015 1:33 pm
by satoon101
If I remember right, it's uchar. If you try getting/setting it with the wrong method name, it will raise an error that will tell you the correct type to use. Also, you want to use entities.constants.TakeDamage types to set it. Currently, there is no Entity attribute added via the data. The issue is finding the right name. We already have a take_damage method and an on_take_damage virtual function.

Posted: Fri Jul 03, 2015 4:50 pm
by stonedegg
Yes it's uchar:

Syntax: Select all

from entities.constants import TakeDamage

player.set_property_uchar('m_takedamage', TakeDamage.YES) #no godmode
player.set_property_uchar('m_takedamage', TakeDamage.NO) #godmode

Posted: Fri Jul 03, 2015 6:08 pm
by L'In20Cible
We could name it Entity.damageable or something