Home › Forums › Torn Stars › Fleet Operation code details
- This topic has 0 replies, 1 voice, and was last updated 18 years, 9 months ago by GrandpaTrout.
-
AuthorPosts
-
8. March 2006 at 23:52 #15911GrandpaTroutParticipant
Fleet Operations
I thought I would document a little bit about how the Torn Stars code implements operations. And then add in a little bit about how to make these operations move. This might give other modders some ideas of how they might make use of them. The Torn Stars code is in the public domain.
The concept of an operation is a mobile station. It has many of the properties of a station. It has an owning faction. A station has a type that tells the game “this station is a common metals mine. An operation has the same kind of “production type� that says this operation is a pirate embezzling operation.
And, most importantly, an operation gets saved into globals when the game is saved. And it restores from globals when the game restores.
Operations are implemented as waypoints that are never placed in game. (if not placed, a sim consumes very little resource and you can have thousands of them without penalty. A handy trick to know). The Object.Property functions are used to attach the operations properties to the waypoint when the Operations are created and restored.
Operations are stored in a master List. And each station has a list property attached to it that contains the Operations that are in orbit around the station. (so to move an operation, you remove it from one stations list, and place it in the destinations station. That all.)
Since operation are just waypoints, they are very efficient when the player is not around. When the player arrives at a station, the operation needs to be turned into ships.
When the player arrives near a station, a player watch task calls a Location Initialization function. One of the jobs of this function is to look at each operation located near the station, and create a list of Environment Items that each operation requires.
When you fly around the Middle States, you see environment items everywhere. Asteroids, wingmen for hire, pirate tolls. This code was written to allow fast customization of large star clusters. The power of it is leveraged here for Operations.
For example: When the player arrives at a station that has a Pirate Toll operation, the Player watch task calls the Location init. The location init reads an INI file for each operation, and it creates the environment objects that operation requires. In the case of a Pirate Toll, this is a tPcPirateToll pog object.
Here we get to another cool concept of the Epic code base. Pog objects. A pog object is designed to emulate a standard EOC sim. You give the command “tPogClass.Create(“ini:/sims/pc_pirate_toll�). And it creates a whole pirate toll for you. All the details of the pirate toll are controlled by the INI file, allowing massive customization. Basically Pog Objects are to fleets, what iShip.Create is to a single ship.
Fleet Operations end up being simple, because of all this code they leverage. An operation is a simple waypoint, but when the player shows up it can be a whole fleet of ships.
Moving Fleet Operations
To build moving fleet operations is very simple. Every 7 days (or 1 day or whenever) a function checks each Operation in the master list and makes a decision if it should move or stay.
Most operations will be content to sit still. But they could check the other operations also currently at the station. If a pirate operation notices a police operation has arrived, it could move. If a pirate toll has been preying on 1 lpoint and attracting attention for too long, it could move.
This “do I move� code is unique to each type of fleet operation. And it is the only new part needed to create moving operations.
An operation that chases around the player could work like this: every x many days it looks at where the player is currently located. It moves itself to this location. The next time the player arrives at that location, the fleet will be created. It would be as if the hostile fleet was just one step behind the player. (more complexity could be added to the chase decision making code, but you get the idea). Essentially, you get pursuit goon-squads for about 10 extra lines of code.
Goon squads could work using the current tPcGuards.Create pog object. This object guards lpoints and stations and attacks hostiles. But to enhance the experience, the goon squads could have a custom pog object added that gives the player unique messages such as “Aha! We have finally caught you! Revenge is at hand!� or “Your bounty will bring a handsome price!�
[center][url=”http://www.torn-stars.com”%5D
-
AuthorPosts
- You must be logged in to reply to this topic.