Data Realms Fan Forums
http://forums.datarealms.com/

Wave Defence with a twist
http://forums.datarealms.com/viewtopic.php?f=75&t=45727
Page 1 of 1

Author:  tomatopipps [ Wed Jun 04, 2014 4:55 pm ]
Post subject:  Wave Defence with a twist

Would it be possible to write a lua script that resets the terrain, including any added in build mode (and doors?), to an undamaged, debris-less state at the end of each wave? Of course, any physical objects (actors, items, etc.) that had fallen into original terrain boundaries would have to be moved upwards out of the way.
Maybe to make it more balanced, gold doesn't reset?

Author:  Sims_Doc [ Fri Jun 06, 2014 11:14 pm ]
Post subject:  Re: Wave Defence with a twist

Best way to do this would be option when creating a game rather than forcing it on a unwilling player because choice is always better.

Author:  Bad Boy [ Sat Jun 07, 2014 12:32 am ]
Post subject:  Re: Wave Defence with a twist

For what it's worth, it's probably a lot easier or more doable to just restart the scene and save the actor positions and gold, then readd the a actors, moving them so they're above terrain if necessary.
That said, mehman did make a map saving/loading mod that might be helpful for this if you really want to manually change the terrain.

Author:  clunatic [ Sat Jun 07, 2014 1:40 am ]
Post subject:  Re: Wave Defence with a twist

Saving actual bunker modules and loading them later is also possible since the latest patch. It just requires a lot of work, both ini and lua.

It's based around adding a child object to each and every bunker module using code like this with the presetname set to whichever bunker module its attached to:

Code:
   AddChildObject = SOPlacer
      PlacedObject = MOSRotating
         CopyOf = Add MOSR
         PresetName = Brain Vault
      Offset = Vector
         X = 0
         Y = 0


The MOSRotating runs a lua script on creation adding the presetname and position to a table that can be used to spawn the modules later using the new build 30 functions.

I've written some testing code to see if this was possible (it is, but I haven't fully investigated possible vector issues), but turning it into a complete mod would require quite a bit more work. Resetting the terrain and adding the actors is, like Bad Boy said, probably quite easy.

So, is it possible? Yes, it's just a lot of work.

Author:  Bad Boy [ Sat Jun 07, 2014 7:42 am ]
Post subject:  Re: Wave Defence with a twist

Please correct me if I'm wrong but clunatic, for your thing it's probably easier to add the bunker objects directly in lua or attach the script directly to the bunker module and have it put out a global reference, so you can actually interact with them via script.
If I'm not mistaken, if you just have preset name and position you can't actually access them or move them after they've been added. Or is there a metatable like MovableMan.Actors/Items/Whatever for terrainobjects/sceneobjects too?

Or maybe I'm misunderstanding what your aim is there? I guess it's none of this is too relevant to the actual topic either way haha.

Author:  clunatic [ Sat Jun 07, 2014 5:13 pm ]
Post subject:  Re: Wave Defence with a twist

Nah, as far as I know you can't add lua scripts scene objects or access them in any way. But the OP want to reset the map to a debris less, undamaged state, while still keeping the bunker he build. Unless I misunderstood his post. That can only be done by resetting the map to a blank state and then spawning in all the bunker modules that were placed. Spawning in all the bunker modules can only be done if you have their preset names and position, and since you can't actually get those in any way, I came up with my hacky solution.

My solution was thought up while I was trying to figure out a way to save and load bunkers. So that you could build a bunker normally and when done you could save it, so that you can use it later on a different map or gamemode. I thought it was relevant to this topic, since as far as I know, there is no other way to recreate custom build bunkers.

Author:  Bad Boy [ Sat Jun 07, 2014 9:40 pm ]
Post subject:  Re: Wave Defence with a twist

Well you can add terrain objects, which is basically the same as adding scene objects, with lua. But you're right, you can't really do much with them once you've added them to the scene, can't delete them or move them or anything.

You're right about saving bunker modules like that, that's probably the best way and it's a clever solution.
I think the op wanted to reset the map completely though, so the bunker modules were lost too, but maybe I'm wrong?

Author:  tomatopipps [ Sun Jun 08, 2014 5:59 pm ]
Post subject:  Re: Wave Defence with a twist

Thanks guys, glad to see it's possible.
To clarify, what I meant by "gold doesn't reset" is that maybe there would be a way to reset all of the terrain except for any gold that had been dug up. I'm guessing that would be much harder to implement, but I'm pretty new to CC modding.

Also, while I'm here, would there be any way to manually choose which of the vanilla activities a custom scene shows up in?
I've made a map that, due to its design, must be available only in activities with Build Mode.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/