Page 1 of 1

AcceptEntityInput

Posted: Wed Jun 04, 2014 1:31 pm
by Hedgehog
Does Source.Python has some function similar to AcceptEntityInput from SourceMod or I need to call CBaseEntity::AcceptInput directly?

Posted: Wed Jun 04, 2014 3:38 pm
by satoon101
What exactly are you looking to do? We have direct access to the inputs themselves.

Posted: Wed Jun 04, 2014 4:54 pm
by Hedgehog
I'm trying to deal damage over point_hurt

Code: Select all

hurt = BaseEntity(ServerTools.create_entity('point_hurt'))

hurt.name = 'killer' + str(hurt.index)

hurt.edict.set_key_value_string('DamageTarget', player.edict.get_key_value_string('targetname'))
hurt.edict.set_key_value_string('damage', '150')
hurt.edict.set_key_value_string('damagetype', '0')

ServerTools.spawn_entity(hurt.index)

hurt.Hurt()
hurt.Kill()

it falls on hurt.Hurt() with this error:

Code: Select all

[SP] Caught an Exception:
Traceback (most recent call last):
  File '..\addons\source-python\packages\source-python\events\listener.py', line
 84, in fire_game_event
    callback(game_event)
  File '..\addons\source-python\plugins\ns_test\ns_test.py', line 142, in player
_say
    hurt.Hurt()
  File '..\addons\source-python\packages\source-python\entities\entity.py', line
 117, in __getattr__

AttributeError: Attribute 'Hurt' not found


I knew about damage function, but I want to know how can I call AcceptInput.

Also, is it normal that damage function gives damage to player in 2.857 times less, then I set?

Posted: Wed Jun 04, 2014 5:17 pm
by L'In20Cible
The damages are adjusted depending the type you use

Posted: Wed Jun 04, 2014 5:33 pm
by Hedgehog
L'In20Cible wrote:The damages are adjusted depending the type you use

I've tried several types from addons/source-python/data/source-python/entities/constants/orangebox.ini and with all of them damage get decreased in 2.857 times.

Posted: Thu Jun 05, 2014 12:55 am
by satoon101
Whenever I use DamageTypes.FALL, it seems to do the correct damage.

I am planning on creating a "hurt" method for BaseEntity. I have done a little bit of work on it, but have not tested it at all.

I am also currently working on an update to the BaseEntity attributes. It won't (shouldn't) affect usage. There may be an issue with the current implementation that does not register Hurt, but I do know that my current version of the update shows Hurt to properly be a method.

*Edit: also worth noting, if you use <BaseEntity>.Kill() , it takes a tick to kill off the entity. Using ServerTools.remove_entity(<index>) does the same. To remove the entity immediately, use ServerTools.remove_entity_immediate(<index>) .

Posted: Thu Jun 05, 2014 8:38 am
by Hedgehog
satoon101 wrote:Whenever I use DamageTypes.FALL, it seems to do the correct damage.


Am I doing something wrong?

Syntax: Select all

from entities.constants import DamageTypes
from events import Event
from players.entity import PlayerEntity
from players.helpers import index_from_userid

@Event
def player_say(event):
userid = event.get_int('userid')
text = event.get_string('text')
player = PlayerEntity(index_from_userid(userid))

if text == 'run':
player.damage(player.index, 100, DamageTypes.FALL, hitgroup=0, iObjectsPenetrated=2)

When someone type "run" in chat he gets only 35 HP damage (100 / 2.857).

CS:S, Windows, May 14 build.

Posted: Thu Jun 05, 2014 9:31 pm
by L'In20Cible
Well its normal you tell the game the bullet has passed 2 objects before hurting the player so less damage is.expected

Posted: Thu Jun 05, 2014 9:40 pm
by satoon101
The OrangeBox engine doesn't have an iObjectsPenetrated, only CS:GO does.

Posted: Thu Jun 05, 2014 10:01 pm
by Hedgehog
L'In20Cible wrote:Well its normal you tell the game the bullet has passed 2 objects before hurting the player so less damage is.expected

Nothing changes if I remove it...

satoon101 wrote:The OrangeBox engine doesn't have an iObjectsPenetrated, only CS:GO does.

After several attempts to fix it I took your code from this forum, but :(

Posted: Thu Jun 05, 2014 11:35 pm
by L'In20Cible
I see, i cannot test myself im on my phone lost in the.mountains