SEVERANCE, BLADE OF DARKNESS

Prospero's pages

Updated July 21, 2005

HOME PAGEAUTHORS > PROSPERO > BOD PYTHON SCRIPTING (04)

 

Tut4. Adding Objects

The map looks a bit empty, so now you want to add some objects.

Before that, just a word about map coordinates.

In the LED, you have three Axes (not the chopping sort). The X axis runs West-East. West from the origin the values are all negative: postive East of the origin. The Y axis runs North-South. The values North are negative and positive to the South. The Z axis runs Up-Down. This is the one you set as Floor/Ceiling hight.

Now when you use the LED readings in script it is not quite straightforward . Firstly, all the LED units need to be multplied by 1000. (If the LED units are meters, they should be expressed as millimeters in script. The X axis reads true, but the Y and Z axes don't. Basically what you have to do with the Y and Z is to call a positive number negative and vice versa.

e.g. Put the LED mouse cursor over a spot where you would like to create an object and say the x[] y[] boxes in LED read 279.000 and 100.000. The sector is 0 floor - 10 ceiling and you want the object about one meter up off the floor. The correct coords for the scripts would be:

279000, -1000, -100000

They are always written X, Z, Y   (not X, Y, Z).

It is important to get a feel for this as you will be needing lots of coords.

Ok, now we have got that straight, let's make something. Create a file and call it
objs.py (You can name these files whatever you like, but don't call them the obvious 'Objects.py' or 'objects.py'. There is a BOD source file of that name.) At the top type:

import Bladex

The basic creation code is:


o=Bladex.CreateEntity("Thing1","Cazo",279000, -1000, -100000, "Weapon")


Before you can use this file it must be added to the execs in
cfg.py.

execfile("objs.py")

Thats all. Load the map and you should have a ladle at the spot you picked.

"Thing1" is the individual Name of the ladle. You can't have two Thing1s in the same map.

"Cazo" is the object Kind. Kind is an proper attribute of an object, as is Name, Scale, Orientation and Position.

There then follows the three coords to fix the Position of the object. x, z, y -> 
279000,-1000,-100000

The last argument is the entity class. In this case it is a
"Weapon".
If you are not sure of the entity class, there is a neat function in file
Lib/Reference.py that will return the correct entity class:

Reference.ObjType("Cazo")

Put this function call in place of
"Weapon". As you are now refering to another file, remember to

import Reference

Objects that can be moved are classed as
"Physic". Static objects have no class so Reference will return "". (an empty string in Python terminology).


If you know an object is Static, you can omit the last arg completely.

You can give each object whatever name you like. As with variables they can be any combination of letters and numbers and under_scores.

The '
Kind' arg is critical. Most of the Kinds are in Spanish. In practice you soon get familiar with them. (Unless you are Spanish, in which case you have no probs.) If you d/l the Objects catalogue the Kinds are all listed with nice piccies. The case is also critical. "antorcha" is not the same as "Antorcha". (This is a wall torch btw.)

Accurately placing objects is best done using the
EBrowser tool (by Masklin.) I will come to that later.

Now you can create anything you like and position it (approximately).
As you proceed you will notice that some things don't behave as expected. You can't use Potions or smash up boxes for example. Your Bows/Quivers won't work, etc. Some objects need extra data contained in a class structure that controls how they work.

To make a box breakable add

Breakings.SetBreakable("Box1",12,100)

after creation. If you use the variable
o to create the box you can put

Breakings.SetBreakable(o.Name,12,100)

Same thing really, but if you have a lot to do it's quicker to copy/paste this line rather than type all individual names. If you use another var, say
box1, put box1.Name. Don't worry about the last two args. All the ones I have seen in the game use the same values.

(*Don't forget
import Breakings at top of file)

Not all objects are Breakable. Check
Breakings.py. If the object is not mentioned there you can't break it. What actually happens when you break an object is that the original object is instantly removed an is replaced by a number of seperate objects that together look like the original. These are all named ObjNamePieza1 etc and are numbered sequentialy. Some objs have a lot of Piezas, some have just two. As soon as they are all created in the position of the original object they are exploded. Later they will fade away for the sake of performance. You can create piezas seperately if you want a bit of wreckage lying about.

With Potions, you make them useable with:

pocimac.CreatePotion("Potion1") # or (o.Name)

again remember to
import pocimac file.

for food

pocimac.CreateFood("Cheese1")

for Power Potions

pocimac.CreatePowerPotion("PowerPot1")

You can now eat and drink and smash things up.

Weapons next.....