Showing posts with label cargo. Show all posts
Showing posts with label cargo. Show all posts

Wednesday, March 23, 2011

Cargo

More cargo work today since I found another corner I coded myself into. Turns out that since you can remove all the Cargo Modules off a ship, that leaves you with a zero sized cargo hold so once I forced the cargo moves to not be able to overload a ship then you couldn't put a Cargo Module back onto the ship in order to install it.

I thought of several ways to get around this, but what I ended up doing for now is that if you have a 0/0 cargo hold on a ship, you're allowed to move one Cargo Module over to temporarily overload the ship until you install that module, which will give you a 0/500 cargo hold at that point and let you resume normal cargo operations.

I'm heading out of town tomorrow until Sunday, so there probably won't be much going on in the game until next week.

Tuesday, March 22, 2011

Coded into a Corner

Not much going on today. I had dinner after work with some colleagues in from Atlanta.

I had intended to wrap up some of the work on the Scoop Gas Giant action tonight, but to do that I needed to do some work on moving cargo around. When I dug into that code I realized I had coded myself into a bit of a corner last month where my Move Cargo code worked great but didn't necessarily know if it was moving cargo from a ship to a colony or vs. versa.

So I had to redo some functions I had that returned the amount of current cargo and the max cargo, which will allow me to make sure when you scoop up that He3 from a gas giant you don't overload your cargo hold. This side trek does let me cross off one item from my todo list, which was to make sure that the Move Cargo functionality respects maximum cargo hold size, which it wasn't doing before.

Sunday, March 20, 2011

Cargo and He3

So today I decided to work on ships being able to scoop gas giants. It turns out I haven't had a ship orbit a gas giant in a while, so first I had to fix a lot of bugs that have crept in. Then I got the Scoop Gas Giant action 95% complete and had to switch over to Cargo for a while.

I hadn't put in the code to calculate how much space a ship's cargo hold had remaining, but that's in the game now. The next step is to use this information to enforce limits on items being put into the cargo hold, whether you're transferring items or basically creating a new item in the case of the Scoop Gas Giant action which is the source of He3 in the game. He3 will be used by ships for moving and jumping to new systems, and will power Fusion Reactors at colonies. It will likely also be used in the construction of some items in the game. He3 will basically be the lifeblood of the game, and will make Gas Giants and some comets very valuable resources.

I'll have the new action and cargo hold limits wrapped up by tomorrow night.

Sunday, February 13, 2011

Cargo Moves

I've got the basic Ship Cargo screen finished. A ship can now land at a colony that is owned by the same player and move cargo between the ship and the colony. While I was working on this, I decided to make a fairly major design change to simplify my life in coding and in the way the game is played.

I had planned for ships to take a certain amount of time to unload/load cargo. So it might take 10 minutes to unload a module, in which time the ship would be placed in Cargo Handling status for 10 minutes and wouldn't be able to initiate any other actions other than moving another item, which would extend the time out by 10 minutes. The item being moved to the colony would then not be available to the colony for until those initial 10 minutes was up.

I had planned on doing this by having an "available" column in the item table in the database, so when a ship moved a Command Module over to a colony the "available" column for that item would be set to a Unix timestamp 600 seconds in the future, and the colony would not be able to have access to that item until after that amount of time had passed. This is fine for modules and the like, which aren't stackable, but for things like ore, it would mean a ship moving a stack of 100 ore over to a colony that already had ore on hand would create a new stack of ore in the colony that wouldn't be available for 10 minutes and then the colony owner would have to consolidate those stacks. At an active colony this could lead to dozens of stacks of the same type of ore, and it would be more complicated to figure out which stack of ore to use first for production and such.

So, I've made the decision to just have the ships alone pay the time penalty for moving cargo. Anything moved from a ship to a colony will be instantly consolidated into the colony inventory and be available at the point the item was moved, while the ship will still have to wait for the action to complete before it can do anything else. This won't really matter when moving things from a colony to a ship since the ship will have to wait out the cargo action regardless.

It's not really the way I'd like to do it, but it makes things a lot simpler and will lead to getting the game playable sooner.

So here's a list of things a ship can currently do in the game.

1. Land on a planet at a certain square or at a colony.
2. Lift off into orbit of a planet.
3. Leave orbit of a planet.
4. Perform an overall mineral scan of a planet.
5. Perform a scan of a certain square on a planet. (Reveals that square on the planet map.)
6. Move to a new space square on the System Map.
7. Jump to a new star system via an Interstitial Access Point (IAP).
8. Perform a system scan to put the System Map in the library and reveal the distance to the closest IAP. If performed in the same space square as an unknown IAP, this will add the IAP to the library.
9. Install/Uninstall ship modules.
10. Move Cargo to/from a colony with the same owner.

Upcoming Ship Actions
1. Harvest comets.
2. Scoop Gas Giants.
3. Buy/Sell at colony markets.
4. Scan other ships.
5. Attack other ships.

Thursday, February 10, 2011

Cargo

Today's project is to finally finish the cargo move functionality, which is going to involve a lot of code refactoring. This will let ships move items from their cargo holds into the cargo area of colonies that are also owned by the player. I had a half-assed version of this done a while back, but the data tables have changed a bit in the meantime and it never really worked right anyway.

This is fairly complicated functionality, since a player will want to move partial stacks of items, which is different from moving an entire item. So for example, if a player has 100 Precious Metals ore on their ship, they may only want to move 50 of them, which involves possibly creating a new stack of that item in the colony unless there is already a stack of Precious Metals there in which case it would just add 50 to it.

At least I already have the interface in place, I just need to get all of the functions behind the scenes working correctly now.

Thursday, May 27, 2010

Refactoring

While I was working on the cargo functionality yesterday, I realized I introduced a fairly fundamental database design error when I added the ability for ships to land at colonies. This led to a problem where ships could attempt to transfer cargo down to the colony while they were taking off from the colony. I could have hacked around it, but I decided to go ahead and rework the database and the code, which meant I had to refactor about 5 pages all together.

Tuesday, May 25, 2010

Some Clean Up and More Cargo Work

I got side-tracked a bit tonight, but I got some cleanup work done first:

1. Fixed the Hire New Personnel page, which I broke a while back. I got the fields lined up and when you hire a new employee they get placed at Zed, the only colony in the game. (So Far)

2. Figured out how to fix the date column on the reports screen so it will sort correctly. I'm using a really great sortable table library by Stuart Langridge that he's provided free of charge on the Internet. He did an awesome job and it has saved me a ton of coding and works great.

3. Some minor cleanup on the Main screen with the ship action descriptions.

4. I added an admin page to let me add new Item types to the database without having to enter it directly with SQL statements. Trying to keep up with the dependencies was getting a bit tedious.

In tonight's Major News, I got the functionality working to move cargo between a ship and colony. It's still instantaneous, and I also need to decide on the method to determine how long it will take to move cargo around. I've got several factors I'd like to include in the equation, like the size of the ship's cargo area, the cargo handling skill of the crew on the ship, and the cargo handling rating of the colony.

More Cargo

Last night I got the cargo screen for ships up and running. It will currently display a sortable list of cargo that is on the ship, and if the ship is landed at a colony owned by the same player, it will also display a list of all cargo assigned to that colony.

Now I need to add the functionality that will let the player transfer cargo between the ship and the colony, and also to split and merge groups of the same type. This will allow the player to take a 100 unit pile of ore and split it into two piles before transferring one pile to the colony, or vice versa.

Eventually ships will be able to dock to each other and transfer cargo, and expeditionary forces will have the same abilities. All of this is necessary before I can implement the mining, gas giant scooping, and comet harvesting actions in the game since those all create new piles of materials and there has to be some place to put them.

Sunday, May 23, 2010

Loading Up the Ship

My focus this week is on the ship's cargo hold. I'm still relatively inexperienced at database design, so I originally had a table that consisted only of the asset ID and the cargo ID. This was a waste of course, so that table had now been dropped and items will be installed on an asset (ship, colony, ground party), or assigned as cargo to assets.

In other news, Jake the wonder artist has sent over the Water planet tile sets and it looks insanely great, just like the others he's done so far. Next up he's working on the asteroid tile set and I'm anxiously awaiting the outcome. The great thing about Jake's artwork is that it gives me other ideas for the game, and has directly influenced the game design already.

Once I get the cargo areas set up, I'll add the ability for ships to transfer cargo between ships and colonies owned by the same player. This will set things up so that I can add the Scoop Gas Giant action for ships, and will take me one step closer to implementing mining deposits on planets and asteroids.