Page 23 of 25

Re: Level Editing: Scripting

Posted: Thu Jun 08, 2017 3:52 pm
by livid
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)

Re: Level Editing: Scripting

Posted: Thu Jun 08, 2017 10:50 pm
by Tomash
#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.

Re: Level Editing: Scripting

Posted: Fri Jun 09, 2017 2:10 am
by prospero
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......



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

Re: Level Editing: Scripting

Posted: Fri Jun 09, 2017 10:40 am
by livid
@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.

Re: Level Editing: Scripting

Posted: Fri Jun 09, 2017 11:49 am
by prospero
Take a mo to study 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.

electric eels on electric damage hit don't cause damage

Posted: Tue Jun 13, 2017 7:11 am
by cieply
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/
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

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
>> 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?

Re: Level Editing: Scripting

Posted: Tue Jun 13, 2017 4:48 pm
by prospero
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

Re: Level Editing: Scripting

Posted: Tue Jun 13, 2017 4:54 pm
by prospero
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

causing damage fixed

Posted: Wed Jun 14, 2017 2:31 pm
by cieply
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


Re: Level Editing: Scripting

Posted: Fri Jun 23, 2017 7:31 pm
by livid
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.

Re: Level Editing: Scripting

Posted: Sat Jun 24, 2017 2:28 am
by prospero
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]
	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):
	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

Re: Level Editing: Scripting

Posted: Sat Jun 24, 2017 2:46 am
by prospero
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)

Re: Level Editing: Scripting

Posted: Sat Jun 24, 2017 1:40 pm
by livid
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 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

^ 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.

Re: Level Editing: Scripting

Posted: Thu May 03, 2018 1:02 am
by Kn1MS
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 "", line 41, in ?
File "", 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:

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

Re: Level Editing: Scripting

Posted: Thu May 03, 2018 5:42 am
by Tomash
knightEnem1=Bladex.CreateEntity("KnightEnem1",Knight_Traitor, 9500, -1000, -6750,"Person")

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

Second param of Bladex.CreateEntity must be string