A16 [WIPproto] Grid Takeoff and Landing: Suborbital jump for ship with interiors

Started by Houkime, January 29, 2017, 05:10:00 PM

Previous topic - Next topic

Houkime

Description:

Allows spaceships to have detectable interiors (no structural beams needed) and allows them to do suborbital jumps. With planned animation (droppod style).
Currently in early stage with working (i.e jumping) prototype done.
Prototype can currently transport pretty much everything except zoning.
Without animation yet.

After developed it is supposed to be integrated with things like RimVerse and such and be a framework for other mods.
Feel free to use detailed concept below and code in your mods (or continue it yourself if I abandon this). Just keep in mind that everything is subject to change.
All tips are welcome.

Mechanics:

Modified ship ComputerCore.
When commanded to launch a suborbital jump does following (at least this is a plan):

1. Detects ship boundaries and returns ship area as List<IntVec3>. (yes)
2. Constructs full lists of floors, walls and other buildings, pawns and things (possibly zones) inside ship area. (yes)
3. Asks player to select destination (like transportPod). Uses the constructed catalog to project ship boundaries allowing to select suitable place for landing. (yes)
4. Despawns entire ship except for ComputerCore itself and packs it into inner storage. (yes)
5. Using massive Draw() override and disabled Print() projects an illusion of a ship (based on the stored info) instead of despawned actual ship. (not yet)
6. Performs takeoff animation. (not yet)
7. Forms DropPod-like object on the global map but with more content attached to it. (yes)
8. Travels. (yes)
9. On arrival spawns ShipComputerCore that makes an illusion again and on touch down spawns everything. (no illusions yet)

Progress:

Step 1. Simple Illusions. (done)
Managed to make ShipComputerCore mimick different flooring and buildings with Draw() or Graphic() overrides.

Also managed to make ShipComputerCore look like it launches itself in the sky on command despite it being a building (you need to conditionally override Draw, DrawPos, disable Print and call a dirtymesh cleanup for this.)

The reason I did this first is because flooring in game is very different from Things and you need special tricks to make it move smoothly. I wasn't sure it is possible from start but seems like it is mostly ok.
Ideally I will also mimick items and pawns and lights and shadows but it seems like it should be ok so I better prove other stuff first.

Step 2. Ship boundary detection (Done. Ship area is now connected together by any floors and walls)
Created basic selection overlay for ShipComputerCore to visualize ship area.
Decided to make first iteration of area to be Everything that is connected by walls or floors with the Core.
Wrote a recurrent algorithm for boundary detection and it works.
Right now floors-not floors is decided by having/not having a blueprint def in Terraindata. I did it because i wanted for mod to be as compatible as it can.

Step 3. Basic ship contents detection. (done)

Ship now correctly detects all flooring, walls, buildings, items, dirt and pawns inside without double detections. No roof detection yet.
I also overwrote gamend spacelaunch conditions so that ship can now search for needed parts on entire ship grid. Ideally it will require them to be powered.

Step 6. Basic worldmap/localmap landing area selection interface. (done)

Made a raw but working adaptation of user interface from compLaunchable.

Step 7. Basic Travelling Spaceship worldobject. (done)

Prepared mostly-empty but working "spaceship" that is created on launch, is visible on map, travels to destination, sends a message on arrival and is ready to be filled with shipgrid info and actions.

Section: This Map-> This Map transportation tests (via Travelling Spaceship worldobject)
                Step 8. Floor transport. (done)
                 
                          If launch was ordered from pause state... then some unknown...  bad thing ( it brought me a lot of headache) tried to nullify flooring storage of a ship on unpause. Protected my ship storage by adding special setter which DOES NOT allow nullification... and now it seems to work... Yes, Rimworld is a dangerous place indeed.
...Maybe i can use the setter to catch this flooring thief ( like "oh... the value you want to set is null... Can you tell me your name, please?"), but I don't know how to do it yet.

                Step 9. Item transport. (done)
                Step 10. Building transport. (done)
There is a bug in game where simultaneous deletion of walls with doors inserted like X|-|-|X results in a bunch of errors. Was forced to invent a workaround for this. Now works without errors.
                Step 11. Pawn transport.(Done. At least no bugs noticed yet.)
Used 40kInjector (see Acknowledgements).
Detoured Pawnsfinder.get_AllMapsCaravansAndTravelingTransportPods
Detoured PawnsUtility.IsTravelingInTransportPodWorldObject(Pawn pawn)
Now pawns in spaceships should be counted as pawns in droppods.
                Step 12. Roof detection and transport.(done but no hanging outside roof detection yet. For number of reasons including potential problem avoidance and aerodynamical realism it is probable that it will remain this way.)

Step 13. Full destination selection interface with multicell checks based on ship area. (done)

Section: This Map-> Other Map transportation tests.
                Step 14. Automatic landing area selection.(Seems to be working. It is random so hard to tell.)
                Step 15. Attacking other bases. (Done. Well, at least it seems to work.)
There was a funny bug with generated map for some reason starting with null sections[] but putting MapDrawer.RegenerateEverythingNow() was enough to counter this.
There is only one deployment method at the moment and it is "at the edge".
I was experimenting mostly with small "spaceships" though and it looks like bigger ones should have much more trouble with finding place to land.
Don't know what to do with that for now. Maybe less limitations on where it is possible to land (right now for every cell of the ship it is similar to droppod except for it cannot punch through roofs) or an ability to crashland.
                Step 16. Settling with spaceship. (done with cat sleeping on knees)



[Note] Keep in mind that animation is not really necessary for mod to add to gameplay.
If all animation efforts will fail I will just use default screenfader to white to hide the moment of launch. (I will put it there anyway till animation is done)
So when Step 16 is done I will call it a working prototype.

Section: Static ship illusion.
             Step 1. Floors.
             Step 2. Buildings.
             Step 3. Items.
             Step 4. Pawns.
Step 5. Takeoff and landing animations.
Step 6. Shadows and lighting.

Screenshots:

On this screenshot cyan "ship" outline is shown.
ShipComputerCore pretends that it is just wooden plancks and certainly not a modified core.



Landing site selection interface (on world map standard droppod interface is used.)





Abanqueiro was tired of short jumps that evil Houkime forced him to do over and over (and also from other colonists trying to catch his jumping cabin) and this time jumped much farther.

A few seconds before jump:


And after his multi game-hour flight:



Acknowledgements:

Detours (2 methods) in this mod are made using 40KInjector which is cpt. Ohu's convenient repack of CCL-team detouring methods. Injector was taken from his colossal mod Warhammer 40K Corruption. You can find it here:
https://ludeon.com/forums/index.php?topic=28422.msg286833#msg286833


Downloads:

A bit bugfixed GridTOL prototype is attached.

[attachment deleted by admin due to age]

Thirite

After hearing the RimVerse guy hadn't even created a prototype before posting his thread I was pretty doubtful if he was going to make anything. I hope to see a proof of concept soon! I want to see crazy FTL style mechanics happen.

Houkime

I was sad about RimVerse, too. :(
My project is much smaller, much more specific and should be easier.

And BTW I just completed second stage ^_^.

Next two steps will probably be the most complex ones.
#6 should be easy and quick enough once grand illusion is done.


Rilamus

This looks amazing. I personally think this would be very useful towards  endgame colonies that are starting to lag.

Hydromancerx

Could this be made to be used for boats? So one could build say a boat on a coastal tile and then travel to other coastal tiles. Maybe even settle on an ocean tile.

Thirite


Houkime

Hooray!

Completed all 16 steps.
Will test and debug it for a bit (haven't performed some electricity tests yet) and then upload here.


Goldenpotatoes


ChaosChronicler


Houkime

Ok, here's the very first raw toy to play with. Please do not try it on your beloved colonies because I don't really know how stable and balanced it is (WARNING: it is most probably NOT stable at all. You better not expect anything to work.) and also it does not yet really integrate with a standard gamend with credits.
So it is more of a proof of concept and a possibility to see something right now.
Attached folder to the first post.

Rules:
Ship is everything connected by floors (like if thing stands on floor) and walls to your ship core.+ you can attach structural beams, ship reactors, engines and solar arrays externally. (floor also can connect to an adjacent wall)
For ship to perform suborbital jumps it needs to have Reactor and Engine somewhere in the ship.
No crew required unless it is raid (which is lost if you are not there obviously) because AI core is quite a person with a mind of its own.
Though unmanned stuff is not really tested yet outside of hops on the map.

Tips and tricks:

During raid you can rejump with your ship to be able to manually select better landing spot... and to be very cheaty...

When raid starts you can zoom in into raided base or click on your colonists in the colonists bar to dive into action. (it is vanilla stuff that it does not automatically jump camera to raid but instead pauses time. Maybe i will change this.)

Known issues and just untested things:

Bed ownership is reset in flight.
Hydroponics and plant pots are untested.
Saving during flight is not recommended because I did no data exposing yet (was in a big hurry). Flights are short though.
Prisoners and enemies (if so happens..) are yet untested (and most likely broken).
Large ships are not really tested. I haven't got any troubles yet but it seems like landing problems are very likely to arise especially in forests.
Haven't decided what ship is supposed to do if landing fails yet.

Quote from: ChaosChronicler on February 04, 2017, 11:34:12 PM
Wait, Does this mean I can create Dropships?

*Klendathu Drop Intensifies*
https://www.youtube.com/watch?v=CIGHCoVzqtk


Sort of. Can get in. Can fight. Can get out with loot. Don't know about efficient designs though yet.


Seeker89


Goldenpotatoes



Pretty fun, dropping a whole ship next to an outpost and letting the turrets take the blunt of the attack to chew up defenders is good stuff.

Beds don't keep prisoner/hospital markings, probably same reason why ownership gets reset.

Prisoners/enemies seem to work fine, at least surviving the jumps with no issues in the log.

Plants throw an error in the log about spawning a destroyed item, but seem to work otherwise.

Stockpiles are ignored when launching, which really isn't an issue as more of a slight inconvenience.

Potential issue when launching transport pods and ships close together. I launched a transport pod and a ship to the same destination one after the other, and..



Breaking things is pretty fun.

Houkime

Update time.
Fixed resetting bed designations and ownership.
Seems to be fine now. Transported prison bedroom highlight now becomes blue for some reason. Seems to work nevertheless.
Pawns even remain in their beds unless timezone shift is too big.
And as a fun bonus get Disturbed Sleep.)
(Animals are a bit more alarmed about flight though and can get up for a bit)