Page 1 of 2

Moved Walls Don't Stay Put Across Restore

Posted: Thu Nov 06, 2014 5:40 pm
by Lark
Before I launch into the issue, I really wonder if anyone has found a hook so that a script could be run if the game was restored. If you get nothing else from this post, please know that not everything that was moved with setWorldPosition stays put across a restore.

Okay, I admit that I'm running amuck with setWorldPosition - it's just way too cool. So I created some scripts to create and adjust the positions of walls for special occasions. First, I lowered the walls to give a cool, stem-wall that the party can see over, shoot over, but can't cross. Secondly, I pushed some walls back to allow some other receptor pipes to show through, built into the walls. While these techniques have worked well and the new positions for buttons, lever, and lanterns have survived restores, sadly the wall movements don't. I guess the lesson learned is that a scripter shouldn't solve model challenges with scripts, but it was so easy!

Stem Wall - Before and After Restore:
SpoilerShow
Before Restore:
Image

After Restore:
Image
I've tried several techniques: manually placing walls, script placing walls, trying to be sure the script only runs once, trying to get it to run more than once, et cetera. I can destroy and rebuild the walls by trigger just before the party enters the area, but upon restore in the area, things go wonkers.

I've been replaying Skuggasveinn's "Broken Wall" tutorial (to make my own walls), but man is he fast on those Blender clicks! Now I'm watching Blender tutorials! Help! Will I never have a real life again!

Cheers, -Lark :geek:

Re: Moved Walls Don't Stay Put Across Restore

Posted: Thu Nov 06, 2014 5:44 pm
by Prozail
Lark wrote:I've been replaying Skuggasveinn's "Broken Wall" tutorial (to make my own walls), but man is he fast on those Blender clicks! Now I'm watching Blender tutorials! Help! Will I never have a real life again!
I know exactly how you feel... I can't stay focused on one thing with this game 'til its finished.. There is just too much good stuff to mess around with :geek:

Re: Moved Walls Don't Stay Put Across Restore

Posted: Thu Nov 06, 2014 5:48 pm
by Blichew
That is the most upsetting news Lark, we have to rebuild models... unless... is there a hook onSaveGame / onLoadGame ? I've just imagine a piece of code which dumps eachentity:getworldposition() to external file on disk and restores it just after loading :D

Re: Moved Walls Don't Stay Put Across Restore

Posted: Thu Nov 06, 2014 5:55 pm
by Phitt
While I'm sure a solution to the setWorldPosition problem can be useful in the future for something else it is really an unnecessarily complicated method to do something as simple as this.

The assets aren't available yet, so unless you'd 'hack' the dat file you'd have to wait to do this, but there is really nothing simpler than moving an object around a bit. I can assure you that it won't take longer than 10 minutes to figure out how to do this in Blender or any other 3d app. Actually you only need a tutorial to learn how to import and export the model, moving it around should be pretty self-explanatory. Once you know what you do doing simple things like this won't take longer than a few seconds, so it will come in quite handy in the future.

Re: Moved Walls Don't Stay Put Across Restore

Posted: Thu Nov 06, 2014 6:06 pm
by Lark
Phitt wrote:Actually you only need a tutorial to learn how to import and export the model, moving it around should be pretty self-explanatory. Once you know what you do doing simple things like this won't take longer than a few seconds, so it will come in quite handy in the future.
I agree!... This should be simple once I understand how to get around in Blender. I have the wall model imported and mucking with it already. Learning Blender and altering (or eventually making new) models will be like learning to fly - no longer shall I be bound to the earth! Ha! Move over Icarus!

I really just wanted to be sure the community knew that setWorldPosition isn't always the best choice!

Take care, -Lark

Re: Moved Walls Don't Stay Put Across Restore

Posted: Thu Nov 06, 2014 6:08 pm
by NutJob
Try this (if I'm following what your is problem, correctly):

Change the function that executes position placement to only save the coordinates [and extra paramenters/values needed] into a table (variable) and a second function that always runs your mappings when loading a level IF there's a table (with values). Maybe?

Re: Moved Walls Don't Stay Put Across Restore

Posted: Thu Nov 06, 2014 8:41 pm
by Lark
Thanks NutJob, but if I could get something to run when a level loaded (on a restore specifically), I could handle it easily! :P I've tried a few things, but no luck. I'm sure glad I don't have to make a model for every button or lever placement as this would be time consuming, tedious, and would clutter the world with unnecessary models, but doing so for a few walls shouldn't be too bad! I'm off to Blender now, then back to the puzzle that needs it! :shock: Oooh, look at that shiny over there!

How many ADHD people does it take to change a lightbulb? Uh, ...anyone want to go for a bike ride?

Take care, -Lark

Re: Moved Walls Don't Stay Put Across Restore

Posted: Thu Nov 06, 2014 9:51 pm
by NutJob
I guess I don't know how to retain the positions either, then. Currently I do some world positions, too, on a few entities on each level. How I have it setup is each level has a timer {timerInterval:0.1;currentLevelOnly:true;disableSelf:false} that calls a script to do an assortment of things [specific to that level] and one of those routines is to set positions on a table of entity references. It does it each time I enter a level.

So if something like that [described above] is used, AND you have a function that just "saves" the values required, then you could do it per-level on a timer....maybe? I may not understand the guts of your functions. =)

I like turtles!

Re: Moved Walls Don't Stay Put Across Restore

Posted: Thu Nov 06, 2014 10:00 pm
by Batty
As simple as moving something in Blender is, you don't even need that. Just move it in the GMT, easier than script.

Re: Moved Walls Don't Stay Put Across Restore

Posted: Thu Nov 06, 2014 11:06 pm
by petri
Important thing to know:

All objects in LoG2 are full objects with components, even "static" floors, walls, pillars etc. This means they are fully scriptable. However, because of this the amount of objects in the game is staggering. Therefore to reduce save game size and optimize loading & saving speed "decorative objects" whose properties do not change during game play are marked to have minimal save state. Minimal save state means that only objects' name and x,y,facing coordinates are saved. Most walls, floors and pillars are defined to use minimal save state (there are some other objects with minimal save state, mainly some static props that have large number of instances).

Minimal save state can be toggled on/off per object type by setting the value of "minimalStateState" to either true or false. You can clone an existing object and override the minimalSaveState property if you really need to have full save state on for walls but you have to remember that this will be costly for large dungeons, because every wall object will then save ALL properties of all its components.