The Quest To Spew

More
18 years 7 months ago #13779 by cambragol
Replied by cambragol on topic The Quest To Spew
Keep up the quest mdvalley! I am on the same page as you. Having to actually dock and and undock pods adds to the whole simulation alot, and would make trading in the Middle States just a little more realistic than any other space sim. Adding to turn over time (by requiring docking and docking of pods) would mean we can rebalance the economy in a way that reduces repetitive, mindless autopilot shuttle runs in favor of fewer, more involved runs.

Please Log in or Create an account to join the conversation.

More
18 years 7 months ago #13781 by mdvalley
Replied by mdvalley on topic The Quest To Spew
I perused the big traffic/spewer thread and found Joco’s code. I’ll try to work it into the Epic tPodUtil code and see how it works out. At least the pods coming out have been working flawlessly, except that all 4 appear at once, while the AI using the spewer stagger them. Might be worth writing in; I’ll see how I feel.

Please Log in or Create an account to join the conversation.

More
18 years 7 months ago #13785 by mdvalley
Replied by mdvalley on topic The Quest To Spew
Success! We have pod dockage! Whatever is in that code block, it works. Sold pods dock at all four inputs on the spewer, even with the AI using the spewer at the same time. The pods like to do laps around the spewer before docking for some reason, but it doesn’t interfere with trade.

What the player needs to do different:
To buy: Wait about 15 seconds for the pods to emerge.
To sell: Nothing.
Code:
list get_subsims_like(hsim source, int type) // Shamelessly ripped from Joco's forum post { // we need to find all the subsims in the source sim that have a type_flags // equal to 'type' hsubsim ssim; list results; int i; int subsim_count = Sim.SubsimCount( source ); for(i = 0; i < subsim_count; ++i) { ssim = Sim.NthSubsim( source, i ); if( Object.IntProperty( ssim, "type_flags" ) == type ) { List.AddTail( results, ssim ); } } return results; } task send_pod_home(hisim pod, hhabitat station) // Joco's idea, md's merging into Epic. { list spewer_port_list; hdockport pod_sim_port; hdockport spewer_port; bool portfound = false; iSim.SetFaction(pod,iSim.Faction(station)); // Make it a non-player pod so it can't be picked up by a wingman. iShip.InstallAIPilot( iShip.Cast(pod), 0.25, 4.0, 0.1,"","","",""); iAI.GiveApproachOrderNoDropOff(pod, station); // An unordered pod can be hacked. spewer_port_list = get_subsims_like( Sim.Cast(station), 64); // Every spew port on the station pod_sim_port = iDockport.Cast(Sim.FindSubsimByName( pod, "system_pod_port" )); while(!portfound) { atomic // One task for each pod, no need to risk multiple pods trying for the same port { while( !List.IsEmpty( spewer_port_list ) && !portfound ) { spewer_port = iDockport.Cast( List.Head( spewer_port_list ) ); List.RemoveHead( spewer_port_list ); if( iDockport.Status( spewer_port ) == DS_Free) { portfound = true; iAI.GiveDockOrderWithDockport(pod_sim_port,spewer_port); } } // end while } // end atomic if(!portfound) { Task.Sleep(Task.Current(),1); } } // end big while } // end send_pod_home

Send_pod_home assumes that you have already checked that the station has a spewer before starting (and detaching!) it. The major difference between my and Joco’s code is that if there is no spot at the moment, Joco’s ends with a false return. Mine keeps trying.

So far my list of altered files is:

Tetradebuy.pkg, tetradebuy.pog,
Tetradesell.pkg, tetradesell.pog,
Tpodutil.pkg, tpodutil.pog, tpodutil.h.

TPodUtil got a new function (DockType), so it needs an updated header file. This file set should do for the next Epic update. The buy and sell programs now check for a spewer. If one exists, they call the code, most local, to handle the spew. If the spewer does not work for some reason, then the code reverts to the old method:
Code:
Sim.PlaceNear(pod, waypoint, 1km); // it's maaagic!

If I can dig out GrampaTrout’s e-mail, I will send those seven files.

Please Log in or Create an account to join the conversation.

More
18 years 7 months ago #13786 by cambragol
Replied by cambragol on topic The Quest To Spew
Nice! Post some screenshots of it in action. I really want to see this working, because I too never liked the magical docking and undocking of pods. So much more satisfying to see your wingman dock and actually unload pods into a station. Well I am hoping it will be satisfying.

Please Log in or Create an account to join the conversation.

More
18 years 7 months ago #13787 by mdvalley
Replied by mdvalley on topic The Quest To Spew
Well it seems the sell code has some more bugs... pods still like to dock to the station’s universal ports. Debugging is proving troublesome, as the behavior changes in developer mode! In dev mode, four pods go for the four ports, and the rest hang out near the station forever. While the AI docks to the spewer in dev mode, it doesn’t actually seem to use it.

IS there a way of printing a handle with dev mode off? I really need to know what exactly those pods are being commanded to dock to.

Please Log in or Create an account to join the conversation.

More
18 years 7 months ago #13788 by mdvalley
Replied by mdvalley on topic The Quest To Spew
One messy bit of code later, I found a way to tell what the pods are being ordered to. They all go for the same port.

It looks like if iAI.GiveDockOrderWithDockport has that particular port busy, it docks with any other port it can find. Not to mention it does not reserve the dockport, so all the pods go for the same one initially. That causes pods on the universal ports. The only solution I can think of is to REQUIRE that the unloading ship be docked before it can sell pods.

That’ll need a change to the sell code (so you can only offer pods that are on an attached ship), prodigious use of the dock lock (to keep a ship from running off and breaking the code), and a function to babysit the pods and force ports upon the tasks.

Additionally, if you haul a pod in a ship that can’t use the freighter dock (i.e., the tug), you will find yourself unable to sell it. Only way to save the player from him/herself there is to require a docked hauler to BUY the pods, too. (And another function to make sure this doesn’t apply to the items at the shipyard that don’t go to pods.) And if you’re in the middle of loading and get shot at, you are in serious crap.

This will be a lot of work. The good news is that it’ll be damn cool when it’s done.

A screenshot? I’m pretty happy with the way pods get coughed out; I’ll set up something with imageshack.

Please Log in or Create an account to join the conversation.