Since George seems to be in a talkative mode today
I know that the universe is created completely when the game is launched, per the topology section of the XML. However, are the actual systems resolved (which stations are present and their locations) before the player first visits them? Furthermore, all of the sys functions refer only to the player's current system, is there a way to peek into other systems?
I ask, because the Wikipedia entry so recently created cites Elite as one of the inspiration for Transcendence. However, I've never once screamed in blind rage as I smacked into the docking bay of a station I was landing at. I was thinking about how Transcendence could be more like Elite, and aside from implementing a random chance of blowing up each time you dock, I figured that implementing a bit of an economy feel would help.
Most of it is easy enough, I can give stations a list of resources and finished goods and wire transports to run around delivering everything, but the "economy" would grind to a halt real fast if the economy was limited to one system.
Basically, as a test, I am trying to construct a 5 system loop that has a vaguely functional economy, but doing it without being able to see into the other systems makes it next to impossible.
State of the Universe
In system most of it is easy. Economy is handled by timers. A (sysAddObjRecurringTimerEvent) call to set an <OnProduction> event for the station handles each station's regular production. For example:
In the <OnCreate> event for the station:
(sysAddObjRecurringTimerEvent 3600 gSource "OnProduction")
(objSetData gSource "RawMaterials" '('(&rawMaterial1, QuantityNeeded1), '(&RawMaterial2, QuantityNeeded2),...))
(objSetData gSource "FinishedGoods" '('(&finishedGood1, QuantityProduced1), '(&finishedGood2, QuantityProduced2),...))
Then later in the <Events> tag
<OnProduction>
(if (rawMaterialsCheck (objGetData gSource "RawMaterials"))
(block nil
(addFinishedGoods (objGetData gSource "FinishedGoods"))
(removeRawMaterials (objGetData gSource "RawMaterials"))
)
)
</OnProduction>
Where rawMaterialsCheck, addFinishedGoods, and removeRawMaterials are global and defined in the <Globals> section of the XML.
In addition, you need a bunch of freighters ferrying around goods. Mostly (shpOrderDock) from one station to the next and using <OnObjDocked> events to handle transactions.
In the <OnCreate> event for the station:
(sysAddObjRecurringTimerEvent 3600 gSource "OnProduction")
(objSetData gSource "RawMaterials" '('(&rawMaterial1, QuantityNeeded1), '(&RawMaterial2, QuantityNeeded2),...))
(objSetData gSource "FinishedGoods" '('(&finishedGood1, QuantityProduced1), '(&finishedGood2, QuantityProduced2),...))
Then later in the <Events> tag
<OnProduction>
(if (rawMaterialsCheck (objGetData gSource "RawMaterials"))
(block nil
(addFinishedGoods (objGetData gSource "FinishedGoods"))
(removeRawMaterials (objGetData gSource "RawMaterials"))
)
)
</OnProduction>
Where rawMaterialsCheck, addFinishedGoods, and removeRawMaterials are global and defined in the <Globals> section of the XML.
In addition, you need a bunch of freighters ferrying around goods. Mostly (shpOrderDock) from one station to the next and using <OnObjDocked> events to handle transactions.
If the functions exist, I can use them. It's the functions that don't exist that I have a problem with.
Stations that replenish their wares has been done, someone had a working mod for that a over a year ago. Wiring a system up to have transports zipping back and forth is fun, but if the player is just interested in jumping in, wasting some pirates, and jumping to the next system, it seems like a lot of wasted effort.
The trick is dealing with systems that are frozen in time while the player is in another system.
Stations that replenish their wares has been done, someone had a working mod for that a over a year ago. Wiring a system up to have transports zipping back and forth is fun, but if the player is just interested in jumping in, wasting some pirates, and jumping to the next system, it seems like a lot of wasted effort.
The trick is dealing with systems that are frozen in time while the player is in another system.
-
- Developer
- Posts: 2997
- Joined: Thu Jul 24, 2003 9:53 pm
- Contact:
Unfortunately, as you suspect, the actual system is not created until the player first visits it. And, unfortunately, systems are saved out to disk and flushed from memory when you leave.Burzmali wrote:However, are the actual systems resolved (which stations are present and their locations) before the player first visits them? Furthermore, all of the sys functions refer only to the player's current system, is there a way to peek into other systems?
Nevertheless, I think there might be a work-around. You can store information attached to the station type (not the station instance). For example, imagine that in system A you call:
(staSetGlobalData &stMyCoolStation; "System-A-needs" '(metals))
Since this is stored with the station type, you can access this same variable from any other system. Thus, from system B you can call:
(staGetGlobalData &stMyCoolStation; "System-A-needs")
and you will get the list of things that system A needs.
You can use the function:
(sysGetName) to figure out the name of the current system and even use that in the variable name.
In the next version (because you've inspired me) I'm going to add the following:
(sysGetNodeID) which returns the node ID of the current system (this is better than (sysGetName) because it is valid even for systems that have not been created yet.
(sysSetData nodeID variable value)
(sysGetData nodeID variable)
which will let you get/set data and associate it with a system (even a system that has not been created yet).
(sysGetStargateTopology nodeID) which returns a list of stargate names and nodeID. This should let you navigate the entire system topology (though not the contents of each system).
With all of that, you should be able to do anything you want across systems. I should also add a new event on stations that gets called when a system is loaded. That would allow you to do any fix ups that you need to handle the intervening time while the system was "paged out"
I was planning to stuff the inter-system information into gPlayerShip, for now, as I have to be able to reference station types that may not be present in the player's current system. That way, at least I can be sure that it won't go out of scope. Being able to link information to the NodeIDs will make that a whole lot easier, as long as they are always considered live for the purposes of triggering events.
I was planning on handling out of system (OOS) events by determining the time to complete a trade run and setting a timer to handle to transactions. I suppose I could force all the systems to be generated by jumping the player ship through each of them, but I don't really think that is a good idea.
I was planning on handling out of system (OOS) events by determining the time to complete a trade run and setting a timer to handle to transactions. I suppose I could force all the systems to be generated by jumping the player ship through each of them, but I don't really think that is a good idea.
- Betelgeuse
- Fleet Officer
- Posts: 1920
- Joined: Sun Mar 05, 2006 6:31 am
that
(sysSetData nodeID variable value)
sounds like an easy way of keeping track of where you have been 8)
sounds like a great idea
(sysSetData nodeID variable value)
sounds like an easy way of keeping track of where you have been 8)
sounds like a great idea
Crying is not a proper retort!