player/entity constants: GODMODE

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

player/entity constants: GODMODE

Postby BackRaw » Thu Jun 04, 2015 1:54 pm

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?
My Github repositories:

Source.Python: https://github.com/backraw
User avatar
satoon101
Project Leader
Posts: 2703
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Thu Jun 04, 2015 2:41 pm

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.
Image
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Thu Jun 04, 2015 3:27 pm

Why? it seems a bit odd using Entity constants for Players lol :D

is LifeState.DEAD the correct value here?
User avatar
satoon101
Project Leader
Posts: 2703
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Thu Jun 04, 2015 3:30 pm

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.
Image
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Thu Jun 04, 2015 3:32 pm

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 :)
My Github repositories:

Source.Python: https://github.com/backraw
User avatar
satoon101
Project Leader
Posts: 2703
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Thu Jun 04, 2015 4:05 pm

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)
Image
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Thu Jun 04, 2015 5:21 pm

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.
My Github repositories:

Source.Python: https://github.com/backraw
User avatar
Mahi
Senior Member
Posts: 236
Joined: Wed Aug 29, 2012 8:39 pm
Location: Finland

Postby Mahi » Fri Jul 03, 2015 11:49 am

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?
User avatar
satoon101
Project Leader
Posts: 2703
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Fri Jul 03, 2015 1:33 pm

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.
Image
stonedegg
Senior Member
Posts: 141
Joined: Sun Aug 12, 2012 11:45 am

Postby stonedegg » Fri Jul 03, 2015 4:50 pm

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
User avatar
L'In20Cible
Project Leader
Posts: 1536
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Fri Jul 03, 2015 6:08 pm

We could name it Entity.damageable or something

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 122 guests