AcceptEntityInput

Please post any questions about developing your plugin here. Please use the search function before posting!
Hedgehog
Member
Posts: 62
Joined: Sun Nov 03, 2013 8:54 pm

AcceptEntityInput

Postby Hedgehog » Wed Jun 04, 2014 1:31 pm

Does Source.Python has some function similar to AcceptEntityInput from SourceMod or I need to call CBaseEntity::AcceptInput directly?
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Wed Jun 04, 2014 3:38 pm

What exactly are you looking to do? We have direct access to the inputs themselves.
Hedgehog
Member
Posts: 62
Joined: Sun Nov 03, 2013 8:54 pm

Postby Hedgehog » Wed Jun 04, 2014 4:54 pm

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

Postby L'In20Cible » Wed Jun 04, 2014 5:17 pm

The damages are adjusted depending the type you use
Hedgehog
Member
Posts: 62
Joined: Sun Nov 03, 2013 8:54 pm

Postby Hedgehog » Wed Jun 04, 2014 5:33 pm

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

Postby satoon101 » Thu Jun 05, 2014 12:55 am

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>) .
Hedgehog
Member
Posts: 62
Joined: Sun Nov 03, 2013 8:54 pm

Postby Hedgehog » Thu Jun 05, 2014 8:38 am

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

Postby L'In20Cible » Thu Jun 05, 2014 9:31 pm

Well its normal you tell the game the bullet has passed 2 objects before hurting the player so less damage is.expected
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Thu Jun 05, 2014 9:40 pm

The OrangeBox engine doesn't have an iObjectsPenetrated, only CS:GO does.
Hedgehog
Member
Posts: 62
Joined: Sun Nov 03, 2013 8:54 pm

Postby Hedgehog » Thu Jun 05, 2014 10:01 pm

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

Postby L'In20Cible » Thu Jun 05, 2014 11:35 pm

I see, i cannot test myself im on my phone lost in the.mountains

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 135 guests