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

krehmall
Dragon
Posts: 176
Joined: Wed Apr 11, 2007 11:01 pm
Location: Israel
Contact:

Re: Level Editing: Scripting

Post by krehmall »

hi everyone, if prospero remembers me i was trying 2times to make single player mod)) when i failed when stucked in something hard to make, this time i got even better in scripting understanding well how functions work not realy understand in clases and this my third try to make something good hope ill suceess this time :mrgreen: so first i cant find some effects like when hero touches the fire life damages but how to make so he will be knocked back on touch and have burn effect on body anlso i not found how to do bleeding efects when he fall on spikes

Code: Select all

		p = ent.Position
		Blood.BleedingImpact(ent , p[0], p[1], p[2],9999,0,0 )
		Blood.BleedingImpact(ent , p[0], p[1], p[2],9999,0,9999 )
		Blood.BleedingImpact(ent , p[0], p[1], p[2],3333,0,0 )
		Blood.BleedingImpact(ent , p[0], p[1], p[2],9999,0,3333 )
		Blood.BleedingImpact(ent , p[0], p[1], p[2],0,0,3333 )
		Blood.BleedingImpact(ent , p[0], p[1], p[2],0,0,9999 )
		Blood.BleedingImpact(ent , p[0], p[1], p[2],0,0,0 )
this example doesnt work any other ways?
and one more:i trying to make knight zombie body dead in siting position but he doest let use traitor knight anim so i made knight in zombie mesh but he bleeding like alive whe i cut him.my goal is to make rotten dead body without deasapearing efeect and without alive bleeding, is there way to make animation to work for another mob or its needed to make new enemy class?

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

Re: Level Editing: Scripting

Post by prospero »

Every map has a MusicEvents.py. Each tune is defined....

Bladex.AddMusicEventADPCM("Music1", "..\\..\\Sounds\\ATMOSFERA5.wav", 0.1, 1.0, 1.0, 1, 0, -1 )


The values at the end set certain actions. Not sure which one is the volume, but I think maybe the third. Try it and see what happens.

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

Re: Level Editing: Scripting

Post by prospero »

The fire damage thing uses a neat little function in darfuncs.py


darfuncs.FireOnGS("fuego1")

This makes a circular Ghost Sector around the named object, "fuego1" in this case and assigns a pre-set function to the sector so that when the Player
enters the area (about 2000 radius) he starts to burn and loose points. Leaving the sector stops the burning.

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

Re: Level Editing: Scripting

Post by prospero »

The Knight sitting animations aren't loaded in the animation set. You need to preload them. Check DefAnims.py in the Labyrinth (Tell Halaf) map.

Also check 'cadaveres.py' in the same map.

krehmall
Dragon
Posts: 176
Joined: Wed Apr 11, 2007 11:01 pm
Location: Israel
Contact:

Re: Level Editing: Scripting

Post by krehmall »

i did FireOnGs func the problem is its not realistick on your maps you made something bether with knockback and fire aura on body,i checked it in telhalaf and did what i wrote he do eror in console because its not made for zombies but only for knight, so somehow you did old animation for new characters so i think its posible to make knights animation legal for zombie)))

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

Re: Level Editing: Scripting

Post by prospero »

If they are just static characters then you can do them with a Traitor Knight and switch the mesh to the zombie knight.

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

Re: Level Editing: Scripting

Post by cieply »

prospero wrote:Every map has a MusicEvents.py...
I checked the file, and other .py and .sf but it's not that
when you pass bars the same music continues to play, only volume changes, so it's not the music event, the volume is increased when entering the sector I guess but I couldn't to figure out where is it in code

that's why I put link to savegame so one could see and hear what I mean
l'aria fresca,
vino puro, ...

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

adding some code to map/savegame

Post by cieply »

#
I tried to add something
-- test5.py

Code: Select all

import Bladex
import Console
import Actions

def log_char_position():
	print "char.Position=%.1f,%.1f,%.1f\n" %(char.Position[0], char.Position[1], char.Position[2])
	print "char.Orientation=%.6f,%.6f,%.6f,%.6f\n" %(char.Orientation[0], char.Orientation[1], char.Orientation[2], char.Orientation[3])

Bladex.AddInputAction("log_char_position", 0)
Bladex.AddBoundFunc("log_char_position", log_char_position)
Bladex.AssocKey("log_char_position", "Keyboard", "Z", 1)

-- EOF test5.py

to particular savegame at the very end, like shown:

Code: Select all

if Reference.PYTHON_DEBUG >= 1:
  try:
    execfile("Positions.py")
  except IOError:
    print "Can't find Positions.py"

#test5: // and it doesn't work, I don't see any text printed into console
try:
    execfile("test5.py")
    print "try execfile(\"test5.py\")"
except:
    print "tets5/err"
    pass
#-- EOF test5

__load_bar.Clear()
del __load_bar
Bladex.SetTime(459.750000)
#   Good Bye! (Enjoy The Silence)
and didn't work


#
I tried also add it to map for example in cfg.py: execfile("test5.py")
and also without success
don't know what I'm doing wrong

the problem is that it works fine if I run it from a console:
execfile ("test5.py")

but it's not an option as you can guess... I don't want to play in window with console.
l'aria fresca,
vino puro, ...

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

Re: Level Editing: Scripting

Post by prospero »

This is the code I use:

Code: Select all

def WritePos():
	char=Bladex.GetEntity("Player1")
	x=int(char.Position[0])
	y=int(char.Position[1])
	z=int(char.Position[2])
	file = open("../../BODLoader/Mods/WhateverFolder/pos.txt","a")
        file.write("("+str(x)+","+str(y)+","+str(z)+")"+"\n")
        file.close()
        
        
Bladex.AddInputAction("WritePos", 0)
Bladex.AddBoundFunc("WritePos", WritePos)
Bladex.AssocKey("WritePos", "Keyboard", "I", 1)
I put it in DefFuncs.py.

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

Re: Level Editing: Scripting

Post by Sryml »

Before that, I encountered such a problem:

I add custom Key Function in "DefFuncs.py", like shown:

Code: Select all

def NewKeyInput():
	print "test..........."

Bladex.AddInputAction("NKI", 0)
Bladex.AssocKey("NKI", "Keyboard", "5", 1)
Bladex.AddBoundFunc("NKI", NewKeyInput)
But it sometimes appears abnormal (key failure). so I added a scheduled function to delay the call it. Like shown:

Code: Select all

def NewKeyInput():
	print "test..........."

def NewKeyInputInit():
	Bladex.AddInputAction("NKI", 0)
	Bladex.AssocKey("NKI", "Keyboard", "5", 1)
	Bladex.AddBoundFunc("NKI", NewKeyInput)

Bladex.AddScheduledFunc(Bladex.GetTime()+0.5, NewKeyInputInit, ())
Yes! This is feasible. But I don't know why it would happen exception!

Until one day, I finally found the reason:
The game has more Input Actions.
1. "Default"(in the map)
2. "Menu"(Press Esc in the map)
3. "EmptySet"(Call the "Bladex.DeactivateInput()")
4. "TalkSystem" and "TSJournal"(in the Talk System)
5. Unknown More...................etc.

We can get the current input action:

Code: Select all

import BInput
InputManager=BInput.GetInputManager()
CurrentInput= InputManager.GetInputActionsSet()
print CurrentInput
This means that we need to add key functions in the corresponding input action. Like shown:

Code: Select all

def NewKeyInput():
   print "test..........."

InputManager=BInput.GetInputManager()
OldInput= InputManager.GetInputActionsSet() # save old input action
InputManager.SetInputActionsSet("Default") # set corresponding input

Bladex.AddInputAction("NKI", 0)
Bladex.AssocKey("NKI", "Keyboard", "5", 1)
Bladex.AddBoundFunc("NKI", NewKeyInput)

InputManager.SetInputActionsSet(OldInput) # return old input action
This is really a problem plagued me for a long time, I hope this way can help you. cieply! :mrgreen:
Fear can hold you prisoner. Hope can set you free.
My YouTube: https://www.youtube.com/channel/UCg0SHO ... P3FdZLWzpQ

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

assigning hot keys properly...

Post by cieply »

apart from actual code, which I did in more "printf" style than string str() style I managed to do as follows
  • function that works (here: prints character location)
  • assign to key
  • run a map and use it
now there is a problem - when I save and load game it stops working (and yes - save was done after alterations)
what is the problem I don't know.

same problem with hotkeys I have with simple mod I made
I bet that solution to will work with another

here is atual code:

Code: Select all

######################################################################################	
# Stopwatch mod
# execfile("../../BODLoader/Mods/stopwatch/stopwatch.py")
######################################################################################	
import Bladex
import Actions

stopwatch_start_time=0

def stopwatch1():
	global stopwatch_start_time
	stopwatch_start_time = Bladex.GetTime()
	Actions.ReportMsg("stopwatch started...")

def stopwatch0():
	stopwatch_stop_time = Bladex.GetTime()
	global stopwatch_start_time
	stopwatch = stopwatch_stop_time - stopwatch_start_time
	time_msg = "stopwatch: %.1f" %(stopwatch)
	Actions.ReportMsg(time_msg)


Bladex.AddInputAction("stopwatch1", 0)
Bladex.AddBoundFunc("stopwatch1", stopwatch1)
Bladex.AssocKey("stopwatch1", "Keyboard", "Comma", 1)

Bladex.AddInputAction("stopwatch0", 0)
Bladex.AddBoundFunc("stopwatch0", stopwatch0)
Bladex.AssocKey("stopwatch0", "Keyboard", "Period", 1)
l'aria fresca,
vino puro, ...

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

Re: Level Editing: Scripting

Post by prospero »

Could be because you have the code in a separate file. If this file is exe'd from cfg.py it won't be exe'd again in the save. Only certain key files are exe'd in the save game load routine - DefFuncs.py being the principle one.

Try executing the file with the code in from DefFuncs.

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

re: re: assigning hot keys properly...

Post by cieply »

Could be because you have the code in a separate file
if you meant this piece of code:

Code: Select all

# execfile("../../BODLoader/Mods/stopwatch/stopwatch.py")
then it's just a test line (commented anyway) added for my convenience, so I don't have to write it manually in console during tests

just tried to put it into DefFuncs.py and still doesn't work

it's proper mod, try it here: stopwatch-1.0.1.zip

i think the problem is described by Sryml with InputManager but I didn't manage to digest and test it yet
simply don't get what it does
l'aria fresca,
vino puro, ...

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

non selectable object

Post by cieply »

how to make object non-selectable?
for example I want to put somewhere axe (or any other weapon), that is "element of landscape" and cannot be selected and taken; like these weapons on racks - how to set them unable to select (and thereby be taken)
l'aria fresca,
vino puro, ...

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

Re: non selectable object

Post by prospero »

cieply wrote:how to make object non-selectable?
for example I want to put somewhere axe (or any other weapon), that is "element of landscape" and cannot be selected and taken; like these weapons on racks - how to set them unable to select (and thereby be taken)

Code: Select all

Reference.EntitiesSelectionData["ObjectName"]=(0,0,"")
in DefFuncs.py

Post Reply