Moved Walls Don't Stay Put Across Restore

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
User avatar
Lark
Posts: 178
Joined: Wed Sep 19, 2012 4:23 pm
Location: Springfield, MO USA

Moved Walls Don't Stay Put Across Restore

Post 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:
User avatar
Prozail
Posts: 158
Joined: Mon Oct 27, 2014 3:36 pm

Re: Moved Walls Don't Stay Put Across Restore

Post 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:
User avatar
Blichew
Posts: 157
Joined: Thu Sep 27, 2012 12:39 am

Re: Moved Walls Don't Stay Put Across Restore

Post 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
User avatar
Phitt
Posts: 442
Joined: Tue Aug 14, 2012 9:43 am

Re: Moved Walls Don't Stay Put Across Restore

Post 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.
User avatar
Lark
Posts: 178
Joined: Wed Sep 19, 2012 4:23 pm
Location: Springfield, MO USA

Re: Moved Walls Don't Stay Put Across Restore

Post 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
NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

Re: Moved Walls Don't Stay Put Across Restore

Post 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?
User avatar
Lark
Posts: 178
Joined: Wed Sep 19, 2012 4:23 pm
Location: Springfield, MO USA

Re: Moved Walls Don't Stay Put Across Restore

Post 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
NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

Re: Moved Walls Don't Stay Put Across Restore

Post 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!
Batty
Posts: 509
Joined: Sun Apr 15, 2012 7:04 pm

Re: Moved Walls Don't Stay Put Across Restore

Post 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.
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Moved Walls Don't Stay Put Across Restore

Post 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.
Post Reply