forums | blogs | polls | tutorials | downloads | rules | help

Error message

Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in remember_me_form_alter() (line 78 of /var/www/siegetheday.org/sites/all/modules/contrib/remember_me/remember_me.module).

Have Random Object Placement Figured out

I figured out how to implement random object placement. It's all in my head right now. The user will be able to have settings for what I'm calling patterns, which can also be saved to a text file. The only problem with the approach I'm taking is that it will take time to get the object placement data. The issue I was facing was no info on the height of nodes, so I thought it will be best to place objects on each type of node and use the points from those objects as seeds for random placement. Each node will have an overall chance to spawn in one of the random seeds. The number of times it can loop over the map can be set by the user. I may add an individual node increase and decrease to the algorithm. Some nodes need less objects on them than others such as paths. I've written a bit more down and figured out more stuff, but thought I'd write a quick blog.

I will write it in python. I'm mostly a functional programmer, so it will have that sort of style. I will have to learn the gui for python. I thought about wrapping it in electron, but that's way too inefficient.

blogs: 

Comments

That’s awesome! Do keep the updates coming if possible. Maybe a flag for any “wall” nodes? Spawn chance could be 0, or for efficiency make it impossible to spawn there? Idk, I’m no coding mastermind, but it’s a really cool idea.

The hard part is getting the spawn spots. I will have to manually place them to get their positions. So I will leave out walls completely.

You can parse the SNO files and get their height / walkable flags. That will help you deduce where to put them.

Oh, that's true. I'll have to look at their data. I wonder if it'd be easy to match the height with the position the editor creates. Walkable flags would be really helpful.

Edit: It might be easy to calculate the center of the x and y coordinates using the vertices that make up the square or rectangle of a node and use those vertices as the max distance from the center. Not sure of a good solution for the height though.

Edit again: Think I might have to use barycentric coordinate system for that, but I don't have the math skills for it atm.
https://en.wikipedia.org/wiki/Barycentric_coordinate_system

Object placement is relative to the node itself - not the global position of the node. If you place a node that is 4 meters up and the place an object in the middle of that nodes - the location of the new object is 0,0,0 in local space. If you want to randomize the placements you can just deal in the local space of the individual node. Unless I'm not understanding what you're wanting to accomplish.

Flat nodes are fine. It's nodes (or sno files) that vary on their z axis that would be difficult to place the randomized object correctly on that axis. Need that calculated so they don't float or sink into the node. That's why I was thinking of doing manual placements. It's not ideal at all, since it'd be nice to get this to work with ds1 as well.

In Dungeon Siege the Y is up. When you start flagging faces in the SiegeMax and export the node, it will define a bunch of bounding boxes for each group that you define. So what you can do is read the size of that bounding box and then use that to limit where you place the object. You can even go as far to make sure it doesn't intersect the non-walkable and water faces as well, if you wanted.

This is a river node that has been visualized for the floor flags and bounding boxes. Notice that the floor is encompassed by bounding boxes? You could use those to know your bounds.

Attachment: 

Interesting. I'm going to have take a look at a sno file soon.

Hmm, the sno files are in hexadecimal.

They are in binary.

Oh. I think tank viewer must have built in hex. Is it possible to get that data from the binary?

You can represent binary in whatever format you'd like. You talked about python so I'd start here: https://www.tutorialsteacher.com/python/python-read-write-file

Once you have the file reading then you will need to read out each chunk. When you get it loading I can give you what I've figured out from the format spec.

Gotta get better at c#/.net for work, so I will probably write it in c#. I was reading that python wasn't so good at reading binary. However, it sounds really interesting for me to look into. I was thinking about prototyping in python and then using c# earlier.

Edit: Cool, looks like c# has a binary reader. I didn't know about this. On Ubuntu and have no sno files on my laptop, so I'll have to try it later.

https://www.tutorialsteacher.com/csharp/csharp-stream-io

I'll have to remember that y is up in DS/DS2. Used to looking at the plane from a top view.

Randomly generated remake of Diablo 1 & 2 when?

Eksevis wrote:

Randomly generated remake of Diablo 1 & 2 when?


DS/DS2 would be a bad platform, since it's not supported anymore with no source code Sad .