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: 315
Joined: Wed Jun 26, 2013 3:43 pm

sector trigger

Postby cieply » Wed Jan 20, 2016 4:32 pm

That was it!
The key, placed there later on was activating the trigger. Adding `entityname' check did the job. I also moved that from DefFuncs.py do separate file ran from cfg.py afterwards to prevent it from happening.


Interesting thing - when I enter that area later (as supposed to), values passed to function are: "sectorindex=654,entityname='Player1' " but later part of code gives actual position as "sector.Index=2579".

It works anyway so it's fine, thanks.
l'aria fresca,
vino puro, ...

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

visualizing sector

Postby cieply » Tue Sep 06, 2016 1:34 am

Mine_M5__sector_visualization1.zip
Mine_M5__sector_visualization1.zip
(117.79 KiB) Downloaded 82 times
At the time I wanted to see where exactly is the Rune sector in Mines of Kelbegen (Mine_M5), and some more in other maps too.
I had learned that the only way to visualize given sector is to get source map, change atmosphere in it, compile altered map
and then use it in game to see the sector.

I dug all internet searching for source of that map (and some other too) but unsuccessfully so after some contemplation
I committed program that lists actual sectors in binary map and this let me to alter binary map and check what I intended.

This is effect of my work:
It's visualization of Rune sector ("tSceneBSector") done by changing sector's atmosphere into dense white fog.
Binary difference .diffb file included can be used to recreate map:
backup original maine.bw and then change bytes according to the mine.diffb using any binary/hex editor like hexplorer or wxHexEditor.

enter in console:
>>>

Code: Select all

Bladex.LoadLevel("Mine_M5") char.Position = (119131.897511, -16112.0711465, -159942.491902) # now you can admire cool look of cube sector
this is a result:




Last edited by cieply on Sat Sep 10, 2016 2:12 am, edited 1 time in total.
l'aria fresca,
vino puro, ...

User avatar
prospero
Ancient Dragon
Posts: 1716
Joined: Wed Nov 21, 2001 1:42 am
Location: United Kingdom

Re: Level Editing: Scripting

Postby prospero » Tue Sep 06, 2016 5:03 pm

I have the Mines .mp file somewhere. At least a version of it. The end is different.

I'll see if I can dig it out if you want. :D

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

re: mine.mp

Postby cieply » Sat Sep 10, 2016 2:00 am

Sure, if you have one, I will be grateful.

btw, if someone needs that program to list binary offsets of sectors in .bw map I will post it. At the moment it is not even alpha state.
l'aria fresca,
vino puro, ...

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

electric eels on object

Postby cieply » Sat Sep 10, 2016 9:22 pm

I tried to create electric eels on weapon (here: enchanted with electric damage in FugitiveI map) but all I achieved was to create them on characted/humanoid model only, not on weapon. I used GenFX.ElectricDischarge(...) but it uses List-of-nodes[] which exist only on animated humanoid models. Is there any way to repeat the effect on weapon? There has to be some way to get certain points of weapon as for example in IceWand (and other ice weapons) there are particles attached to specyfic points on weapon - it seems to be on anchors but they are not present as nodes in model ( icewand.BOD )
l'aria fresca,
vino puro, ...

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

how to handle simple mod to support savegames?

Postby cieply » Sun Sep 11, 2016 12:36 pm

it seems I didn't do extensive testing of my little mod (electric eels on weapon - check last question question) and saving game doesn't work

so now the question is what should I do?

quick review of what I've done:

put new pickup event:

Code: Select all

OnInitTake.AddOnInitTakeEvent("Bo_1404", pu_Bo_1404, 1)
and defind pickup function:

Code: Select all

def pu_Bo_1404(): print "picked up Bo_1404" (...) # body of function
and all of this was put in bo1.py executed in cfg.py

--
now as far as I understand game doesn't save neither the function nor the event in OnInitTake.InitTakeDictionary
in console I get:

Code: Select all

SystemError: Failed to import class pu_Bo_1404 from module __main__
shall I put them all in DefFuncs.py or can I somehow force game to save this stuff from bo1.py

I understand it's not so trivial with functions but why OnInitTake.InitTakeDictionary['Bo_1404'] doesn't exist at all, as well? I did it exactly the same like in $BOD/Maps/Desert_M13/LlaveMagica.py with OnInitTake.AddOnInitTakeEvent("BEETLE", PickUpLaLlave)
l'aria fresca,
vino puro, ...

User avatar
MBK_MBK
Dragon
Posts: 339
Joined: Sun Jun 19, 2011 9:06 am
Location: Spain
Contact:

Re: electric eels on object

Postby MBK_MBK » Sun Sep 11, 2016 7:28 pm

I tried to create electric eels on weapon (here: enchanted with electric damage in FugitiveI map) but all I achieved was to create them on characted/humanoid model only, not on weapon. I used GenFX.ElectricDischarge(...) but it uses List-of-nodes[] which exist only on animated humanoid models. Is there any way to repeat the effect on weapon? There has to be some way to get certain points of weapon as for example in IceWand (and other ice weapons) there are particles attached to specyfic points on weapon - it seems to be on anchors but they are not present as nodes in model ( icewand.BOD )
Hello,

Yes, it needs the nodes of the weapon on right hand. But I do not know how is it..
You can try this code:

#####
## Electric effect in weapon of right hand.
#
char=Bladex.GetEntity("Player1")#
wright=Bladex.GetEntity(char.InvRight)#
xwr,ywr,zwr=wright.Position#
#
raywr=Bladex.CreateEntity("Electricrays1", "Entity ElectricBolt", xwr,ywr-700,zwr)#
#
raywr.Position=xwr,ywr+350,zwr# here are the x y z coordenades. The ray can be horizontal or vertical, as you wish.
#
raywr.Target=xwr,ywr-700,zwr# here is the final point of the vector. The ray in this code is vertical, going to up.
#
raywr.MaxAmplitude=650# try 350 or 500 or 650.
#
raywr.MinSectorLength=10000#
raywr.Damage=0#
raywr.Active=1#
#
Bladex.AddScheduledFunc(Bladex.GetTime()+0.35, raywr.SuscribeToList, ("Pin",))#
#####

...and that is all :)
Do not forget to verify if the code is written well. I hope you can see well the code.
Greetings.
Loose your ghosts, because they keep suspiciously your freedom.

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

electric eels on weapon v.1

Postby cieply » Tue Sep 13, 2016 2:28 am

Checked your code and it works but had to delay it as it didn't want to cooperate without it. (check here)
I think 0.5s is the best.

Code: Select all

def electric_eels_on_weapon1(ent_name): ## Electric effect in weapon of right hand. #wright=Bladex.GetEntity(char.InvRight) weapon = Bladex.GetEntity(ent_name) xwr,ywr,zwr = weapon.Position raywr = Bladex.CreateEntity("Electricrays1", "Entity ElectricBolt", xwr, ywr-700, zwr) raywr.Position = xwr, ywr+350, zwr raywr.Target = xwr, ywr-700, zwr raywr.MaxAmplitude = 650 raywr.MinSectorLength = 10000 raywr.Damage = 0 raywr.Active = 1 # Bladex.AddScheduledFunc(Bladex.GetTime()+0.35, raywr.SubscribeToList, ("Pin",)) #def electric_eels_on_weapon(): def pu_Bo_1404(): ent_name = "Bo_1404" ent1 = Bladex.GetEntity(ent_name) Bladex.AddScheduledFunc(Bladex.GetTime()+0.5, electric_eels_on_weapon1, (ent_name,)) # has to be delayed cause doesn't start ####### (...) #def pu_Bo_1404():
btw what is SubscribeToList("Pin") ? I never figured it out although I see it in code a lot.
l'aria fresca,
vino puro, ...

User avatar
prospero
Ancient Dragon
Posts: 1716
Joined: Wed Nov 21, 2001 1:42 am
Location: United Kingdom

Re: Level Editing: Scripting

Postby prospero » Sat Sep 17, 2016 2:14 pm

btw what is SubscribeToList("Pin") ? I never figured it out although I see it in code a lot.
I never figured it out either. :roll: As far as I know it removes the item from the game memory.
There is another built-in function: RemoveFromWorld() which seems to suggest it does the same thing.(?)


As far as saved games go, there is a routine on first load of the map all the .py files are executed to create all
the objects/people. In loading a saved game only key files like DefFuncs.py and others are executed. Otherwise you get
duplicated objects. For this reason only create things in ******.py files and only put functions in DefFuncs.py.

Files with class definitions don't normally need to be executed from cfg.py but to use their data they need to be imported.

If you create things dynamically - that is while the game is in progress, you need the import statement in DefFuncs otherwise
the data class will not be recognised.


Keeping savegame integrity is very complicated. :?

User avatar
Tomash
Dragon
Posts: 246
Joined: Sat Oct 25, 2008 11:23 am
Location: Russia
Contact:

Re: Level Editing: Scripting

Postby Tomash » Sat Sep 17, 2016 3:25 pm

RemoveFromWorld() does not remove object from memory. It just hides object from camera and collisions. You can hide object using RemoveFromWorld() and then take it back using PutToWorld()

But after SubscribeToList('Pin') you can't get access to object anymore. Seems it's useful for economical use of hardware resources.

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

execfile("bo1.py")

Postby cieply » Sat Sep 17, 2016 10:58 pm

from what you say I conclude (correct me if I'm wrong) that execfile("bo1.py") should be put in DefFuncs.py to make it working with savegames; if put in cfg.py it will only work once map is started/restarted
l'aria fresca,
vino puro, ...

User avatar
prospero
Ancient Dragon
Posts: 1716
Joined: Wed Nov 21, 2001 1:42 am
Location: United Kingdom

Re: Level Editing: Scripting

Postby prospero » Sun Sep 18, 2016 12:56 am

It depends what is in the file. If it has a class definition then you don't really need to exec it in cfg.py.
Just import it into whatever file needs to use the data.

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

Re: execfile("bo1.py")

Postby cieply » Fri Sep 30, 2016 7:16 pm

you can see that there is only definition of function called at pickup event and AddOnInitTakeEvent(...)

Code: Select all

def electric_eels_on_weapon1(ent_name): # actual effect (...) def pu_Bo_1404(): # on pickup event (...) electric_eels_on_weapon1("Bo_1404") # call effect (...) OnInitTake.AddOnInitTakeEvent("Bo_1404", pu_Bo_1404, 1)
for sure OnInitTake.AddOnInitTakeEvent("Bo_1404", pu_Bo_1404, 1) will be preserved but functions are bit different story
l'aria fresca,
vino puro, ...

User avatar
MBK_MBK
Dragon
Posts: 339
Joined: Sun Jun 19, 2011 9:06 am
Location: Spain
Contact:

Re: Level Editing: Scripting

Postby MBK_MBK » Fri Sep 30, 2016 11:02 pm

Hello :)
It seems that is better to put "all code that do something on the entities of the map", in DefFuncs.py ... and then to add a call to the functions, where the entity was created.. So the game could save-load well.

Another thing that makes conflicts and crash the game, is the "TimerFunctions"... quite complex. These functions are in C code and are not the same that a "While" in python code? :s
I think that TimerFuncs is for an Entity, that was created before.
And "while", it good with variables...

The console do not give me messages if the game crash by some conflict in TimerFuncs...
For example when I would to make an scene with other allies, moves with camera, etc; it seems that first I must to finish the TimerFunc , with this code for example:

def timerfunctionOFF (self):#
me=Bladex.GetEntity (self.Name)#
me.RemoveFromList ("Timer15")#
me.TimerFuncs=""#
me.SuscribeToList ("Timer15")#
me.Wea=Reference.WEA_ENDED#

I am testing how it works, so I am not sure how is it. Seems my code of allies and dialogues of TalkSystem, have conflicts with Timers.. somebody know how is it? Thanks for help :)

Greetings.
----------------------

Well, looking in the code I think that I found it.
In other file of map, first to create entity, like some door for example; then using Bladex.CreateTimer("Timername",timearg)# ... well, I think that I should to finish the first TimerFuncs before to start another function with timer... :roll: sometimes if there are many entities with many TimerFuncs, the game crash...
Loose your ghosts, because they keep suspiciously your freedom.

User avatar
Tomash
Dragon
Posts: 246
Joined: Sat Oct 25, 2008 11:23 am
Location: Russia
Contact:

Re: Level Editing: Scripting

Postby Tomash » Sat Oct 01, 2016 12:05 am

def timerfunctionOFF (self):#
me=Bladex.GetEntity (self.Name)# Get access to entity
me.RemoveFromList ("Timer15")# remove timer linked to that entity
me.TimerFuncs=""# remove function link
me.SuscribeToList ("Timer15")# but then create such timer again
me.Wuea=Reference.WUEA_ENDED# set Reference.WUEA_ENDED value for Wuea param, so when LaunchAnimation function will be called the current animation will be interrupted

Seems 4th line of this function is unwanted


Return to “Severance BoD: Modding Community”

Who is online

Users browsing this forum: No registered users and 2 guests

cron