Level Editing: Scripting

Talk about Severance Blade of Darkness modifications and maps here. No tips or tech support questions please, use the forum above. Note that the game is rated 18 so some content may be unsuitable for younger readers.

Moderators: Ade, prospero

User avatar
cieply
Dragon
Posts: 321
Joined: Wed Jun 26, 2013 3:43 pm

Grenade smoke

Postby cieply » Thu May 24, 2018 3:21 am

I tried to make exploding grenades (in PeasantRevolt) to make a smoke. After all they are made of black powder isn't it?-)

as long as I put it "directly" in the code, it works:
@ $BOD/Maps/PeasantRevolt/WeaponTypes.py::class LooseFireBomb(ItemTypes.PersistantItemType)::def Detonate(self, EntityName):
self.ImpactSound.Position=weapon.Position[0],weapon.Position[1],weapon.Position[2]
self.ImpactSound.PlaySound(0) ## -- place it here --
### generate smoke at position point rather than object/person
x=weapon.Position[0]; z=weapon.Position[1]; y=weapon.Position[2]; sx=50; sz=50; sy=50; pps=64; ptype="DarkSmoke"; t2l=80; t2d=0.70;
# x,z,y - position; sx,sz,sy - dunno; pps - particles/sec; ptype - particle type; t2l - time to live (life span of particle); t2d - time to death - life span of effect
wps = Bladex.CreateEntity("smoke_D3_"+str(int(Bladex.GetTime()*1000)), "Entity Particle System D3", x + sx, y + sy, z + sz)
wps.ParticleType = ptype
wps.PPS = pps
wps.YGravity = -400.0
wps.Friction = 0.1
wps.Velocity = 20.0, -400.0, 20.0
wps.RandomVelocity = 20.0
wps.Time2Live = t2l
wps.DeathTime = Bladex.GetTime()+t2d
but when I tried to be more elegant and enclosed it in class method then it refuses to work.
self.ImpactSound.Position=weapon.Position[0],weapon.Position[1],weapon.Position[2]
self.ImpactSound.PlaySound(0) ## -- place it here --
### generate smoke at position point rather than object/person
self.ps_smoke_D3(weapon.Position[0], weapon.Position[1], weapon.Position[2])

(...)
def ps_smoke_D3(x, y, z, sx=50, sy=50, sz=50, pps=64, ptype="DarkSmoke", t2l=80, t2d=0.70):
       wps = Bladex.CreateEntity("smoke_D3_"+str(int(Bladex.GetTime()*1000)), "Entity Particle System D3", x +sx, z, y + sy)
       (...)
I don't get it - other functions of this class work.
When attempted to debug it and enclosed with try: except: I caught this exception:
Traceback (innermost last):
File ".\WeaponTypes.py", line 1629, in Detonate
self.ps_smoke_D3(weapon.Position[0], weapon.Position[1], weapon.Position[2])
File ".\WeaponTypes.py", line 1711, in ps_smoke_D3
wps = Bladex.CreateEntity("smoke_D3_"+str(int(Bladex.GetTime()*1000)), "Entity Particle System D3", x +sx, z, y + sy)
TypeError: __add__ nor __radd__ defined for these operands
This "TypeError" is somewhat crazy as if I tried to concatenate different types of variables into a string, but I don't. And whether without function clause or even with, in separate file (`exec("my_ps.py"); ps_smoke_D3(1000, 2000, 3000);`) it runs, without problems.

Anyone understands what's going on with it?

PS. I attached .diff file so you can easier check it.
Attachments
WeaponTypes.py-greande-smoke-1.diff.gz
WeaponTypes.py-greande-smoke-1.diff.gz
(1.02 KiB) Downloaded 66 times
l'aria fresca,
vino puro, ...

User avatar
Sryml
Dragon
Posts: 114
Joined: Tue Aug 28, 2012 12:50 pm
Location: China
Contact:

Re: Level Editing: Scripting

Postby Sryml » Sat May 26, 2018 12:27 pm

Hi cieply! :)
It is a class member function, the first parameter must be self

wrong:

Code: Select all

def ps_smoke_D3(x, y, z, sx=50, sy=50, sz=50, pps=64, ptype="DarkSmoke", t2l=80, t2d=0.70):
correct:

Code: Select all

def ps_smoke_D3(self, x, y, z, sx=50, sy=50, sz=50, pps=64, ptype="DarkSmoke", t2l=80, t2d=0.70):
Anything is possible!

User avatar
cieply
Dragon
Posts: 321
Joined: Wed Jun 26, 2013 3:43 pm

self

Postby cieply » Sun May 27, 2018 3:06 am

Thanks, that's what I needed. Got me lose lot of time but at least I've learned something.
l'aria fresca,
vino puro, ...


Return to “Severance BoD: Modding Community”

Who is online

Users browsing this forum: No registered users and 1 guest

cron