Physexplosion Entity

Please post any questions about developing your plugin here. Please use the search function before posting!
canibozz
Member
Posts: 32
Joined: Wed Apr 11, 2018 7:55 am

Physexplosion Entity

Postby canibozz » Tue Apr 17, 2018 10:38 am

Hello guys,

sorry another Entity Create Topic.

Iam spawning a model with prop_physics_multiplayer.
On that spawned model (entity), i want to create an env_physexplosion entity which pushes in a certain radius every physic around.

My code so far:

Syntax: Select all

def pushEntities(entities, magnitude, radius):
for entity in entities:
physExplosionEnt = Entity.create('env_physexplosion')
physExplosionEnt.origin = entity.origin
physExplosionEnt.damage = 0
physExplosionEnt.radius = radius
physExplosionEnt.magnitude = magnitude
physExplosionEnt.start = 1
physExplosionEnt.explode = 1
physExplosionEnt.spawn()


# Which are called like this:
spawnedModels = spawnModels(models, [Vector(deathOrigin[0] - 10, deathOrigin[1] - 10, deathOrigin[2])])
pushEntities(spawnedModels, 50000, 50000)


So the models are spawned correctly, the entity.origin is valid. Everything is ok.
It just hasn't the effect i want. Iam not sure if i forget a property to set.

Can someone help?
PS reversing the spawn then setting start & explode doesnt help aswell:

Syntax: Select all

physExplosionEnt.spawn()
physExplosionEnt.start = 1
physExplosionEnt.explode = 1



Here is a link to the doc:
https://developer.valvesoftware.com/wik ... sexplosion


Thank you very much!
Cheers,
CANi
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: Physexplosion Entity

Postby satoon101 » Tue Apr 17, 2018 11:59 am

It looks like we haven't added any CEnvExplosion values to our entity data:
https://github.com/Source-Python-Dev-Te ... n/entities

So setting the damage, radius, and magnitude attributes will not do anything. For now, you'll have to set those differently:

Syntax: Select all

physExplosionEnt.set_key_value_float('DamageForce', 0)
physExplosionEnt.set_key_value_int('iRadiusOverride', radius)
physExplosionEnt.set_key_value_int('iMagnitude', magnitude)


I don't see a "start" propery or keyvalue for the entity. For explode, that's an input, so you have to call it not set it. Again, for now, until we add these to our entity data, it will look like:

Syntax: Select all

physExplosionEnt.call_input('Explode')


If you want, take a look at this thread and feel free to add these to the entity data with a pull request:
viewtopic.php?f=8&t=972
Image
canibozz
Member
Posts: 32
Joined: Wed Apr 11, 2018 7:55 am

Re: Physexplosion Entity

Postby canibozz » Tue Apr 17, 2018 12:40 pm

satoon101 wrote:So setting the damage, radius, and magnitude attributes will not do anything. For now, you'll have to set those differently:

Syntax: Select all

physExplosionEnt.set_key_value_float('DamageForce', 0)
physExplosionEnt.set_key_value_int('iRadiusOverride', radius)
physExplosionEnt.set_key_value_int('iMagnitude', magnitude)

Syntax: Select all

physExplosionEnt.call_input('Explode')



Thank you for your answer.
Sadly, it's still not doing anything.

Here my current code:

Syntax: Select all

def pushEntities(entities, magnitude, radius, duration):
for entity in entities:
physExplosionEnt = Entity.create('env_physexplosion')
physExplosionEnt.spawn_flags = 1
physExplosionEnt.set_key_value_int('iRadiusOverride', radius)
physExplosionEnt.set_key_value_int('iMagnitude', magnitude)
physExplosionEnt.spawn()
physExplosionEnt.origin = entity.origin
#physExplosionEnt.teleport(entity.origin, None, None) #Needed?
physExplosionEnt.call_input('Explode')


Do you see whats missing?

I found a archive file to the linked link in the docs of valve:
https://archive.is/YuIaZ


Does this help figuring out what to do?
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: Physexplosion Entity

Postby satoon101 » Tue Apr 17, 2018 1:15 pm

Oh, sorry, I was looking at CEnvExplosion and not CPhysExplosion. The keyvalues are different:

Syntax: Select all

physExplosionEnt.set_key_value_int('radius', radius)
physExplosionEnt.set_key_value_int('magnitude', magnitude)


There's also a targetentityname keyvalue. So, you might need set the targetname of the entity you wish to push and the targetentityname of the env_physexplosion to some unique identifier.

Syntax: Select all

entity.targetname = physExplosionEnt.targetentityname = f'phys_{entity.index}'


Also, if this is for CS:GO and you only want this to fire once and then be removed, you can use the input ExplodeAndRemove. If it's a different game, you'll have to remove the entity after using the Explode input instead.
Image
canibozz
Member
Posts: 32
Joined: Wed Apr 11, 2018 7:55 am

Re: Physexplosion Entity

Postby canibozz » Tue Apr 17, 2018 2:01 pm

Now its working!
The only thing which isnt, is the targetentityname.

Are you sure it's phys_{entity.index}?

Iam spawning 'prop_physics_multiplayer'.
I tried to get the entities names by iterating through and printing the global_name, but that's empty.
How do you get the name of it?
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: Physexplosion Entity

Postby satoon101 » Tue Apr 17, 2018 2:43 pm

The f'phys_{entity.index}' is just setting it uniquely. For instance, if the entity's index is 12, the targetname for the entity and the targetentityname for the env_physexplosion entity are set to phys_12. By default, I believe the targetname of any entity is set to an empty string. So, because you set it to phys_12, and the targetentityname of the env_physexplosion to phys_12, the env_physexplosion knows which entity to act upon.

I'm not sure what you mean by it isn't working, though.

Edit: note that the f prior to the string is very important:
https://www.python.org/dev/peps/pep-0498/
Image
canibozz
Member
Posts: 32
Joined: Wed Apr 11, 2018 7:55 am

Re: Physexplosion Entity

Postby canibozz » Tue Apr 17, 2018 3:02 pm

Delete the last 2 posts & close the thread. Works,was my mistake.
Appreciated!
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: Physexplosion Entity

Postby satoon101 » Tue Apr 17, 2018 3:14 pm

:smile: no need to delete. Glad you got it working!
Image

Return to “Plugin Development Support”

Who is online

Users browsing this forum: Google [Bot] and 36 guests