[HL2:DM] es_blood to sp blood

A place for requesting new Source.Python plugins to be made for your server.

Please request only one plugin per thread.
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

[HL2:DM] es_blood to sp blood

Postby Painkiller » Thu Dec 29, 2016 4:46 am

Hi all,

I can not say exactly what it does.

I know but the one explosion near a person an effect triggers smoke overlay.

It would nevertheless be very nice if the complete script could be rewritten.

Syntax: Select all

}


block fragcloud
{

es_setinfo fragcloudtype 0
es_rand fragcloudtype 2 2
es_give event_var(userid) env_ar2explosion

if (server_var(fragcloudtype) == 1) do
{
es_fire event_var(userid) env_ar2explosion addoutput "Material smoke/smokeball-11-4.vmt"
}

if (server_var(fragcloudtype) == 2) do
{
es_fire event_var(userid) env_ar2explosion addoutput "Material smoke/smokeball-11-4.vmt"
}

es_delayed 0.01 es_fire event_var(userid) env_ar2explosion explode
es_delayed 8 es_fire event_var(userid) env_ar2explosion Kill
es_delayed 10 es_xcreateentitylist clouds env_ar2explosion
es_delayed 10 es_foreachkey cloud in clouds "es_fire event_var(userid) server_var(cloud) Kill"
es_delayed 10 es_xkeygroupdelete clouds
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: [HL2:DM] es_blood to sp blood

Postby Ayuto » Thu Dec 29, 2016 10:53 am

est_blood isn't used anywhere in that script. Also, the script isn't complete. It's just a fragment that doesn't do anything if it doesn't get called.
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: [HL2:DM] es_blood to sp blood

Postby L'In20Cible » Thu Dec 29, 2016 11:48 am

I assume "es_blood" is the name of the script.
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] es_blood to sp blood

Postby Painkiller » Thu Dec 29, 2016 1:31 pm

delete
Last edited by Painkiller on Fri Dec 30, 2016 4:58 am, edited 1 time in total.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: [HL2:DM] es_blood to sp blood

Postby Ayuto » Thu Dec 29, 2016 2:17 pm

After talking with Painkiller via Steam it seems like something like this was requested.

Syntax: Select all

import memory
from entities.entity import Entity
from events import Event
from players.entity import Player

PLAYER_HURT_TRIGGERS = [
'weapon_frag',
'weapon_smg1',
'weapon_rpg',
'weapon_slam',
]

@Event('player_hurt')
def player_hurt(event):
attacker_id = event['attacker']
if attacker_id == 0:
return

attacker = Player.from_userid(attacker_id)
weapon = attacker.active_weapon.classname
if weapon in PLAYER_HURT_TRIGGERS:
fragcloud(Player.from_userid(event['userid']))

def fragcloud(victim):
entity = memory.make_object(Entity, victim.give_named_item('env_ar2explosion'))
entity.set_key_value_string('material', 'smoke/smokeball-11-4.vmt')
entity.call_input('Explode')
entity.delay(8, entity.remove)
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] es_blood to sp blood

Postby Painkiller » Thu Dec 29, 2016 3:23 pm

Ok i have test it but no work.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: [HL2:DM] es_blood to sp blood

Postby satoon101 » Thu Dec 29, 2016 5:12 pm

What exactly doesn't work? We need details to help fix it.
Image
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] es_blood to sp blood

Postby Painkiller » Thu Dec 29, 2016 5:47 pm

It does not work
Loads normally but no error message
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: [HL2:DM] es_blood to sp blood

Postby L'In20Cible » Thu Dec 29, 2016 9:52 pm

According to the SDK, the following line:

Syntax: Select all

entity.call_input('explode')
Should be:

Syntax: Select all

entity.call_input('Explode')
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] es_blood to sp blood

Postby Painkiller » Fri Dec 30, 2016 1:36 am

L'In20Cible wrote:According to the SDK, the following line:

Syntax: Select all

entity.call_input('explode')
Should be:

Syntax: Select all

entity.call_input('Explode')


No chance not work. loads again good.
I have test with standart overlay, its from the game.

Syntax: Select all

from entities.entity import Entity
from events import Event
from players.entity import Player

PLAYER_HURT_TRIGGERS = [
'rpg_missile',
'tank',
'grenade_frag',
'smg1_grenade',
]

PLAYER_DEATH_TRIGGERS = [
'physics',
'rpg_missile',
'grenade_frag',
'smg1_grenade',
]

@Event('player_hurt')
def player_hurt(event):
if event['weapon'] in PLAYER_HURT_TRIGGERS:
fragcloud(Player.from_userid(event['userid']))

@Event('player_death')
def player_death(event):
if event['weapon'] in PLAYER_DEATH_TRIGGERS:
fragcloud(Player.from_userid(event['userid']))

def fragcloud(victim):
entity = memory.make_object(Entity, victim.give_named_item('env_ar2explosion'))
entity.set_key_value_string('material', 'particle/particle_smokegrenade1.vmt')
entity.spawn()
entity.call_input('Explode')
entity.delay(8, entity.remove)
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: [HL2:DM] es_blood to sp blood

Postby Ayuto » Fri Dec 30, 2016 1:38 pm

L'In20Cible was right about the upper and lower case. I also fixed the missing memory import.

I guess the reason why you didn't see any exceptions is that I made a small mistake when I updated the logging format two weeks ago. Due to this mistake exceptions were only shown like this:

Code: Select all

2016-12-30 14:20:33 - sp   -   EXCEPTION   {message}
Please update your Source.Python installation and the plugin I have updated above. Then restart your server and test again.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: [HL2:DM] es_blood to sp blood

Postby satoon101 » Fri Dec 30, 2016 2:10 pm

I think having the same functionality in player_death as in player_hurt is a bit redundant. If someone dies from one of those weapons, they were obviously hurt by that weapon to cause their death.

Also, I'm not sure that those are the proper trigger names. It has been a long time since I tested, so I don't fully remember, but I believe that the projectile weapons in our data are the weapons in player_hurt/death:
https://github.com/Source-Python-Dev-Te ... mp.ini#L6-#L11

physics is probably correct for the weapon when using the physcannon.

The best way to test this is for you to use each weapon and kill an enemy while the following plugin is loaded, and post the output here:

Syntax: Select all

from events import Event

@Event('player_hurt', 'player_death')
def _print_weapon(game_event):
print(
'{event}: {weapon}'.format(
event=game_event.name,
weapon=game_event['weapon']
)
)
Image
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: [HL2:DM] es_blood to sp blood

Postby Ayuto » Fri Dec 30, 2016 2:55 pm

Well, that also what the old script did, but Painkiller just told me that he doesn't need it in player_death. However, there was also an issue with the player_hurt event, because the "weapon" data doesn't exist in HL2:DM, which caused another error. I have updated the plugin again to work around that issue.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: [HL2:DM] es_blood to sp blood

Postby satoon101 » Fri Dec 30, 2016 2:59 pm

I was wondering about that, but couldn't remember. Well, it would probably be better to use a hook for OnTakeDamage then, because by the time a frag explodes, the player could have changed weapons.
Image
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: [HL2:DM] es_blood to sp blood

Postby Ayuto » Fri Dec 30, 2016 3:27 pm

Feel free to do that. :grin: I hate writing things you can't test.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: [HL2:DM] es_blood to sp blood

Postby satoon101 » Fri Dec 30, 2016 3:42 pm

When I get home next week, I can work on this further. For now, using this post as a guide, the following might work:

Syntax: Select all

from entities import TakeDamageInfo
from entities.entity import Entity
from entities.hooks import EntityCondition, EntityPreHook
from memory import make_object
from players.entity import Player
from weapons.manager import weapon_manager


DAMAGE_TRIGGERS = [
'weapon_frag',
'weapon_smg1',
'weapon_rpg',
'weapon_slam',
]

@EntityPreHook(EntityCondition.is_player, 'on_take_damage')
def _pre_take_damage(stack_data):
victim = make_object(Entity, stack_data[0])
if not victim.is_player():
return

info = make_object(TakeDamageInfo, stack_data[1])

# World damage?
if info.attacker == 0:
return

# Was a projectile used?
if info.attacker != info.inflictor:
weapon = Entity(info.inflictor).classname

# Not sure if this line is necessary, but just in case
weapon = weapon_manager[weapon].name

# Not a projectile
else:
weapon = Player(info.attacker).active_weapon.classname

if weapon in DAMAGE_TRIGGERS:
fragcloud(Player(victim.index))


def fragcloud(victim):
entity = make_object(Entity, victim.give_named_item('env_ar2explosion'))
entity.set_key_value_string('material', 'smoke/smokeball-11-4.vmt')
entity.call_input('Explode')
entity.delay(8, entity.remove)
Image
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: [HL2:DM] es_blood to sp blood

Postby Ayuto » Fri Dec 30, 2016 4:18 pm

I just remembered that we have added a neat property to simplify this part:

Syntax: Select all

# Was a projectile used?
if info.attacker != info.inflictor:
weapon = Entity(info.inflictor).classname

# Not sure if this line is necessary, but just in case
weapon = weapon_manager[weapon].name

# Not a projectile
else:
weapon = Player(info.attacker).active_weapon.classname
It could simply be:

Syntax: Select all

weapon_index = info.weapon

https://github.com/Source-Python-Dev-Te ... #L105-L124
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] es_blood to sp blood

Postby Painkiller » Fri Dec 30, 2016 10:13 pm

satoon101 wrote:When I get home next week, I can work on this further. For now, using this post as a guide, the following might work:

Syntax: Select all

from entities import TakeDamageInfo
from entities.entity import Entity
from entities.hooks import EntityCondition, EntityPreHook
from memory import make_object
from players.entity import Player
from weapons.manager import weapon_manager


DAMAGE_TRIGGERS = [
'weapon_frag',
'weapon_smg1',
'weapon_rpg',
'weapon_slam',
]

@EntityPreHook(EntityCondition.is_player, 'on_take_damage')
def _pre_take_damage(stack_data):
victim = make_object(Entity, stack_data[0])
if not victim.is_player():
return

info = make_object(TakeDamageInfo, stack_data[1])

# World damage?
if info.attacker == 0:
return

# Was a projectile used?
if info.attacker != info.inflictor:
weapon = Entity(info.inflictor).classname

# Not sure if this line is necessary, but just in case
weapon = weapon_manager[weapon].name

# Not a projectile
else:
weapon = Player(info.attacker).active_weapon.classname

if weapon in DAMAGE_TRIGGERS:
fragcloud(Player(victim.index))


def fragcloud(victim):
entity = make_object(Entity, victim.give_named_item('env_ar2explosion'))
entity.set_key_value_string('material', 'smoke/smokeball-11-4.vmt')
entity.call_input('Explode')
entity.delay(8, entity.remove)


Ok Satoon,
it works grenade, rpg, smg1_grenade but not for slam and barrels.
No Errors.
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] es_blood to sp blood

Postby Painkiller » Wed Jan 04, 2017 12:36 pm

Its Done thanks on all.
User avatar
Painkiller
Senior Member
Posts: 725
Joined: Sun Mar 01, 2015 8:09 am
Location: Germany
Contact:

Re: [HL2:DM] es_blood to sp blood

Postby Painkiller » Mon Jan 23, 2017 5:16 pm

Hello with the newest SP update broke this plugin.

Syntax: Select all

[SP] Caught an Exception:
Traceback (most recent call last):
File "../addons/source-python/plugins/explosive/explosive.py", line 43, in _pre_take_damage
weapon = Player(info.attacker).active_weapon.classname
File "../addons/source-python/packages/source-python/entities/_base.py", line 116, in __getattr__
raise AttributeError('Attribute "{0}" not found'.format(attr))

AttributeError: Attribute "active_weapon" not found


Syntax: Select all

[SP] Caught an Exception:
Traceback (most recent call last):
File "../addons/source-python/plugins/explosive/explosive.py", line 39, in _pre_take_damage
weapon = weapon_manager[weapon].name

AttributeError: 'NoneType' object has no attribute 'name'


Current code:

Syntax: Select all

from stringtables.downloads import Downloadables

dl = Downloadables()
dl.add('materials/smoke/smokeball-11-4.vmt')


from entities import TakeDamageInfo
from entities.entity import Entity
from entities.hooks import EntityCondition, EntityPreHook
from memory import make_object
from players.entity import Player
from weapons.manager import weapon_manager


DAMAGE_TRIGGERS = [
'weapon_frag',
'smg1_grenade',
'weapon_rpg',
'weapon_slam',
]

@EntityPreHook(EntityCondition.is_player, 'on_take_damage')
def _pre_take_damage(stack_data):
victim = make_object(Entity, stack_data[0])
if not victim.is_player():
return

info = make_object(TakeDamageInfo, stack_data[1])

# World damage?
if info.attacker == 0:
return

# Was a projectile used?
if info.attacker != info.inflictor:
weapon = Entity(info.inflictor).classname

# Not sure if this line is necessary, but just in case
weapon = weapon_manager[weapon].name

# Not a projectile
else:
weapon = Player(info.attacker).active_weapon.classname

if weapon in DAMAGE_TRIGGERS:
fragcloud(Player(victim.index))


def fragcloud(victim):
entity = make_object(Entity, victim.give_named_item('env_ar2explosion'))
entity.set_key_value_string('material', 'smoke/smokeball-11-4.vmt')
entity.call_input('Explode')
entity.delay(8, entity.remove)

Return to “Plugin Requests”

Who is online

Users browsing this forum: No registered users and 3 guests