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: prospero, Ade

livid
Whelp
Posts: 17
Joined: Sat Jun 03, 2017 11:00 am

Re: Level Editing: Scripting

Postby livid » Thu Jun 08, 2017 3:52 pm

Thank you very much, Prospero :D. I knew the label of those weapons had something to do with them being not pickable. I'll have a go at it later.

I have another question. I hope you can understand it, it's a bit confusing.
I want to make a cutscene in which the player grabs a weapon and does a couple of anims with it while it plays. The problem is, if you are already holding a weapon and you have enough room in your inventory, the cutscene would be pointless as the character would put the new weapon in the inventory, messing up the cutscene.
Is there a way to "force" the character to hold the weapon he just picked up? (I think something similar happens when you get the Ianna Sword but I haven't played the main game in years so my memory is a bit iffy) I tried making the weapon OBJ_STANDARD at first, and then giving it OBJ_WEAPON when the scene ends, but the new weapon disappears if you change weapons and everything would be confusing to other players.
My new idea would be forcing the player to drop his weapon to the floor to make him grab the new one while in the cutscene, thus avoiding problems, but that's just too much for me. (I basically copy bits from other maps and adapt it all to my needs, as I said in my first post, I don't know anything about programming, excuse me :oops: )

A simple question to finish:
How would it look if I wanted to destroy the item that's being faded? I think it had something to do with adding -1 somewhere...
AuxFuncs.FadeObject("ObjectName", 1.0, 0.0, 1.0)
Last edited by livid on Fri Jun 09, 2017 12:04 am, edited 1 time in total.

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

Re: Level Editing: Scripting

Postby Tomash » Thu Jun 08, 2017 10:50 pm

#This function "force" the character to withdraw current weapon
Actions.FreeBothHands(EntityName,CallBack=None,Params=(),ForceNow = 1)

#For example:
Actions.FreeBothHands('Player1', SceneStep2)

#So char will withdraw his weapon and then the function SceneStep2 will be called.

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

Re: Level Editing: Scripting

Postby prospero » Fri Jun 09, 2017 2:10 am

There is a function to make the Player drop any object he is holding.

As you say it's a bit complicated.

My programming is a bit rusty. I'll have a look later......

Try...

Actions.TryDropRight("Player1")


Obliviously you would need to use scheduled functions to fix the timing of all the moves.

livid
Whelp
Posts: 17
Joined: Sat Jun 03, 2017 11:00 am

Re: Level Editing: Scripting

Postby livid » Fri Jun 09, 2017 10:40 am

@Tomash: That wasn't exactly what I was looking for, but it's something I will definitely need it at some point. Thanks :D

@Prospero: Yes, that is what I want. Thank you :) . Now I need to make the character grab the new weapon through functions. I guess that's harder...
If it gets too hard, maybe I could circumvent that by changing the cutscene a bit so that the weapon appears magically in my hand. But I don't know if that would be easier or harder.

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

Re: Level Editing: Scripting

Postby prospero » Fri Jun 09, 2017 11:49 am

Take a mo to study Actions.py. There are all the 'handler' functions.

If you use Actions.TakeObject("Player1", "WhateverSword")...

.....the sword will just appear in your hand. The functions in Actions check the state of the Player at the moment
the the object is 'used'. He may already be holding something. He may be fighting. The 'take' routine sorts out
what needs to be done (sheathe weapons, turn to face the object, launch the appropriate animation according
to the relative hight of the object, etc). It you think about it, it's really quite involved.

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

electric eels on electric damage hit don't cause damage

Postby cieply » Tue Jun 13, 2017 7:11 am

There is a damage type, namely electric that is "neglected" - it has no special fx and I decided to change that a bit. Because there is already aura for light damage which happens to be blueish white and aura for fire, and so on I thought adding another aura would be boring... and somewhat laborious. There is however effect that would fit perfectly to what we expect from electricity - electric bolt - so I used already done in GenFX.ElectricDischarge(...) and created electric eels around the victim's body.
Now there is a problem with that - it works to the extent - when these electric eels are still created victim doesn't take any damage, at all.

--code-- @ Lib/Damage.py
def InflictElectricDamage (special, special_resistance, effective_damage, VictimName, AttackerName, WeaponName, DamageType, DamageZone, DamageNode, x, y, z, Shielded): 
    # halo effect on victim, must be switched off on death
    special_damage= special[1]*(1.0-special_resistance)
    if special_damage>0:
        victim= Bladex.GetEntity(VictimName)
    if victim and victim.Person and victim.Data:
        victim.Data.LastDamageType= special[0]
    #-- electric eels --
    ListOfNodes=("Head", "L_Shoulder", "L_Elbow", "L_Hand", "R_Shoulder", "R_Elbow", "R_Hand", "Center", "L_Knee", "L_Foot", "R_Knee", "R_Foot")
    if (Bladex.GetEntity("ElectricBoltDmg-" + VictimName) <> None):
    Bladex.GetEntity("ElectricBoltDmg-" + VictimName).SubsribeToList("Pin") # delete existing bolt so it won't become permanent zombie

    GenFX.ElectricDischarge(VictimName, "ElectricBoltDmg-" + VictimName, 55, 55, 250, 600, ListOfNodes, 5, 0.66)
    #-- eof eels --
    return special_damage
--/code--

As you can see it makes list of nodes and makes these bolts between them using GenFX.ElectricDischarge(...)
Seemingly not too much but this effect while on prevents victim from taking any damage. It goes like this: after hit this code generates these ElectricDischarge effects and victim gets damage. Then while they are on it prevents them from taking any more damage. For example normal whirlwind damages 4 times (1A + 3*WW) and when this effect is on it damages twice (1A + 1*WW(3'rd swing - one late enough to happen after electric bolts went off))

I tried to debug it but don't get Damage module very well. I managed to get to the following conclusions ( with PrintFormula=1 ):
(check attachment - it works in 'FugitiveI' )

after hit
>> InflictElectricDamage (special=['Electric', 50.0],...)
is called and returns special_damage=50.0
then somewhere in CalculateDamage()
>> Special damage type 'Electric' (resisted at 0.0) adds 50.0 to effective damage. # @ 1459 in original Damage.py
>> Special damage type 'Light' (resisted at 0.0) adds 130.0 to effective damage.
then second hit
>> InflictElectricDamage (special=['Electric', 50.0],...) returns special_damage=50.0
and that's it, it doesn't deal any damage and I have no idea what to actually look for in this file. Even pdb.set_trace() doesn't help - it's even worse than primitive printf.

Someone have any idea what could be a reason of such behaviour?
Attachments
_eels-dmg-test.zip
(739 Bytes) Downloaded 76 times
l'aria fresca,
vino puro, ...

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

Re: Level Editing: Scripting

Postby prospero » Tue Jun 13, 2017 4:48 pm

I'm not completely sure what you saying. The damage effects don't do the damage. They are just for show.

What means are you using to actually inflict the damage?

I'm not sure if the 'electric bolts' actually do Electric damage. Could be wrong. :?

You can add special damage to any weapon by tacking it onto it's definition in Reference.py

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

Re: Level Editing: Scripting

Postby prospero » Tue Jun 13, 2017 4:54 pm

btw. If you do use Entity ElectricBolt in a trap or whatever, you need the Damage attribute set to 1

ray.Damage = 0 # and you can touch them. change to 1 and get fried

and you can switch them on and off with

ray.Active = 1 #or 0

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

causing damage fixed

Postby cieply » Wed Jun 14, 2017 2:31 pm

I understand these are visual effects but this one was preventing Damage::CalculateDamage() from working properly - turned out to be a typo, maybe silly but true - `SubsribeToList' should be `SubscribeToList'. Thanks for pointing it out - that actually helped more than anything.

After this correction it started to work but `.SubsribeToList("Pin")' rendered to be ineffective, namely too slow ( at least with lightning hurling statue in FugitiveI ) and I had to use Bladex.DeleteEntity()

----
if (Bladex.GetEntity("ElectricBoltDmg-" + VictimName) <> None):
Bladex.DeleteEntity("ElectricBoltDmg-" + VictimName) # delete existing bolt so it won't become permanent zombie

----
l'aria fresca,
vino puro, ...

livid
Whelp
Posts: 17
Joined: Sat Jun 03, 2017 11:00 am

Re: Level Editing: Scripting

Postby livid » Fri Jun 23, 2017 7:31 pm

Hi again :), some questions here:

How to use skeleton generators? Do you have to use ghost sectors? Because I have read about them and I still don't understand how they work. Tried to link them to an OnEnter sector trigger but it had something wrong (nothing in the map besides me and the LED structure, don't know how you call this kind of error).

Which exact files do I need to add a custom behaviour to the enemies? I have tried the KnightSkel from MoriaMod and it worked, but not properly. First of all, the console spams an annoying message if the skellie is fighting me. Secondly, when he tries to attack using The Dream combo, he does so but slow mo. :roll:

And how to add a CombatMusic for a group of enemies? I want the music to keep playing until I kill them all.

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

Re: Level Editing: Scripting

Postby prospero » Sat Jun 24, 2017 2:28 am

Ghost Sectors are created using code and don't rely on sectors hard-coded into the map structure.

They require different handling to trigger sectors using the map sectors. You can create them in the LED using
the ghost sector tools and export them to an .sf extension file. The sectors are not saved in the map. The map is used
purely for reference. You can create them purely in code if you know where you want them. They are a bit tricky when
it comes to placement. Sometimes they don't work if you have part of the GS in a solid area.

One neat method I devised to create triggers is to use an object for reference. This ideal for doing skel spawn points.
Go to where you want a skel to appear and create a small object.

Then use this function....(set the right formatting)

Code: Select all

def SetGhostSectorObject(entityname, function, radius=2000.0, floor_displ=1000.0, roof_displ=2000.0): x = Bladex.GetEntity(entityname).Position[0] y = Bladex.GetEntity(entityname).Position[1] z = Bladex.GetEntity(entityname).Position[2] dx=radius/2.0 dz=radius*((math.sqrt(3.0))/2.0) trsector_name=entityname+"_TrSector" Bladex.AddTriggerSector(trsector_name, "SectoresTriggerObject", y+floor_displ, y-roof_displ, [(x+dx, z+dz), (x-dx, z+dz), (x-radius, z), (x-dx, z-dz), (x+dx, z-dz), (x+radius, z)]) Bladex.SetTriggerSectorFunc(trsector_name, "OnEnter", function) print "Skel Trigger Set"
After the dummy object creation, add...

SetGhostSectorObject(o.Name, DoMyFunction)

The function you want to call is like this...

Code: Select all

def DoMyFunction(sector,entity): per=Bladex.GetEntity(entity) if per.Name=="Player1": ### whatevercode here print"Enter Ghost Sector"
All you maybe need to adjust is the radius. That code is set to 2000.
I've used this a lot and it's reliable.
You can set GS to as many objects as you like using the same function and if you like you can
make the dummy object invisible with...

o.Alpha = 0.0
o.CastShadows=0

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

Re: Level Editing: Scripting

Postby prospero » Sat Jun 24, 2017 2:46 am

As for custom behaviour, you can stitch on animations and such, but I find by far the best way is to
create a whole new race using a new or cloned model. This way it's all self-contained and you have total control.

The procedure is quite straightforward but not exactly simple. If you check our 'Dwarf Wars' or other mods you can
get some idea how it's done. Basically, you need to recreate all the files - animation sets, etc in your mod. There is a
bit of work involved in implementing a new char, but once you have done it it's easy to do more. 8)

livid
Whelp
Posts: 17
Joined: Sat Jun 03, 2017 11:00 am

Re: Level Editing: Scripting

Postby livid » Sat Jun 24, 2017 1:40 pm

Thank you very much for the great explanation. :D It is clearer now.
The code you sent me still looks a bit weird in the forum but I'll work with it.
With that in mind, I should also be able to make breakable walls, right? I have been taking a closer look at DwarfQuest, in which you can find a couple of breakable walls. However, I can't spot any ghost sectors files or anything related to them. It seems he used another method which at first glance seems easier. It is in DQbreakablewalls.py if you have the map handy (a bit long to put it here with the weird code tags).

Regarding "custom behaviour" as I called it, I think there has been a misunderstanding. I must be because of how I explained it, a bit confusing maybe, and saying custom behaviour did not help at all (altered [combat] behaviour may have been better, "Types" seems to be the term), sorry about that :?. New races are out of my reach, for now, but I'll get at it someday. This is what I meant:

Code: Select all

ExTypes.GladiatorDefaultFuncs (baro1)
^ from DwarfQuest, a basic barbarian enemy

Code: Select all

o.Data=MoriaTypes.Knight_Skl(o)
^ from MoriaMod, altered skeleton that uses The Dream as one of his combos

For example, the player characters as enemies, like they appear in Gladiator where the DQ barbarian probably comes from, who need something else to fight properly. Or skeletons that stop using the suicide 3-hit combo always when they are at mid range (same goes for the ork's jump attack).
I hope it is better now.

Kn1MS
Whelp
Posts: 20
Joined: Sun Apr 08, 2018 6:26 pm

Re: Level Editing: Scripting

Postby Kn1MS » Thu May 03, 2018 1:02 am

Hey guys, I'm currently going through enemy spawning tutorial and I've got a problem... again :D
So, the game apparently can't read my npc's Kind thing:
Traceback (innermost last):
File "Cfg.py", line 41, in ?
execfile("enems.py")
File "enems.py", line 6, in ?
knightEnem1=Bladex.CreateEntity("KnightEnem1",Knight_Traitor, 9500, -1000, -6750,"Person")
NameError: Knight_Traitor
The same error goes for Ork type. It looks like I should import or execute something?

Here's the enems file code: https://puu.sh/AeTD2/6fecb0441d.png

The script is executed the last if it does matter :roll:

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

Re: Level Editing: Scripting

Postby Tomash » Thu May 03, 2018 5:42 am

Wrong:
knightEnem1=Bladex.CreateEntity("KnightEnem1",Knight_Traitor, 9500, -1000, -6750,"Person")

Right:
knightEnem1=Bladex.CreateEntity("KnightEnem1","Knight_Traitor", 9500, -1000, -6750,"Person")

Second param of Bladex.CreateEntity must be string


Return to “Severance BoD: Modding Community”

Who is online

Users browsing this forum: No registered users and 7 guests

cron