In order to support steam engine or a large variety of power source, we will need a way to store power.
At the very generic level, we can have a token that indicates a "store stuff" action, and have a massless/dimensionless item called "power" (or "steam") for steam engine. Although for sanity purposes, let's just have [POWER] related tag.
You can define it in a reaction raw.
[REACTION:ADD_FUEL]
[NAME:Add fuel]
[BUILDING:STEAM_ENGINE:a]
[REAGENT:A:150:BAR:NONE:COAL:NONE]
[REAGENT:water:1:LIQUID_MISC:NONE:WATER:NONE][PRODUCT_DIMENSION:150] need a new ability to trigger dwarf to get a bucket of water.
[REAGENT:bucket:1:NONE:NONE:NONE:NONE]
[CONTAINS:water]
[NOT_IMPROVED]
[PRESERVE_REAGENT]
[PRODUCT:100:0:NONE:NONE:NONE:NONE][ADD_POWER:100000] - amount of power to add the building within which this reaction occurs. Doesn't do anything if the building in question don't have capacity for any power.
[SKILL:SMELT] furnace operator skill
[AUTOMATIC_POWER] the building will automatically queue up this task when the building's stored power is less than POWER_CAPACITY minus this reaction's ADD_POWER amount AND all reagents are available. Basically, this reaction is eligible to be automatically added if it can add power to the building without overfilling it.
Basically, this adds an reaction to a STEAM_ENGINE requiring one bar of coal and one bucket of water. Once reacted, it created a non-existent product (or you can have it create something that cause minor/major syndromes, so you can have somethings that, say, sacrifice the operator's life and/or skill level and/or attribute to fuel it, like a soul-powered generator). It also add 100000 units of power to the building within which the reaction occurs.
Alternatively, a reaction can be something like this.
[REACTION:ADD_FUEL]
[NAME:Add fuel]
[BUILDING:STEAM_ENGINE:a]
[FUEL][CONSUME] the consume tag indicate that in the case of magma, it will consume 1/7 unit of magma from the tile beneath
[WATER][CONSUME] The water tag indicate that it require either a bucket of water OR at minimum 4/7 tile of water beneath. Consume tag indicate that in this reaction a 1/7 unit of water will be consumed.
[PRODUCT:100:0:NONE:NONE:NONE:NONE][ADD_POWER:100000]
[SKILL:SMELT] furnace operator skill
[AUTOMATIC_POWER]
The consume tag can be omitted for the current "infinite power" engine that's placed on 1 water and 1 magma tile. The consume tag is just my thought on how to balance magma related furnaces/engines (instead of current "get 1 4/7 magma tile under smetler, use it forever).
Or you can have a sort of "dwarven based" power source.
[REACTION:WIND_UP]
[NAME:Crank]
[BUILDING:CRANK_ENGINE:c]
[PRODUCT:100:0:NONE:NONE:NONE:NONE][ADD_POWER:10000]
[SKILL:OPERATE_PUMP]
no automatic power needed, just set this on repeat since it doesn't consume anything (other than a dwarf's time)
A steam engine building/workshop would look something like this (I'm leaving out building size/shape definition to shorten it).
[BUILDING_ENGINE:STEAM_ENGINE] an engine building, indicating that it can produce power (perhaps existing BUILDING_WORKSHOP/BUILDING_FURNACE is sufficient)
[POWER_CAPACITY:200000] the maximum units of power the building can store.
[POWER_OUTPUT:100] the amount of power this building can produce per tick. Also the units of power this unit will "consume" from its internal store per tick. In this case, the STEAM_ENGINE filled to max capacity can generate 100 power for 2000 ticks (1 day).
[POWER_EDGE:SIDE:TOP] which edge of the building can be connected for send/receive power. Can be SIDE (for four sides on the same Z-level), TOP (z-level above building), BOTTOM (z-level below building), or ALL (all sides). Argument can be combined as the example here, which defines the steam engine as having a valid power connection on its sides and top. Omitting this tag defaults to all-side of engine capable of connecting to power connections.
Okay, so how about creature power. The way I see it, creature type/size/power should belong to building definition, with the reaction definition associated with said building define how much power the building generate.
[BUILDING_ENGINE:TREAD_MILL]
[POWER_CAPACITY:100000]
[POWER_OUTPUT:40]
[WORK_CREATURE] Indicate that this building can have a creature. Essentially the building can act as a sort of chain (chain that allows no movement) to let dwarf "chain" any creature in it. Building with this tag will provide an interface for player to select which animal to "chain" to the engine after the building is built. The work creature tag can be followed by one or more [WC_*] tag to indicate certain constraints on what kind of creatures. The idea is that almost any creature definition tokens can be checked. All building can have at most 1 creature "chained" to it. But multiple WORK_CREATURE tag can be defined, the workshop will accept creature that fits at least one of the WORK_CREATURE definition. Vermin will also work. Removing the creature from a building with this tag disables the building (no power output despite still having power stored). Some examples.
[WC_CDI_REQ:<interaction token>] creature must be capable of performing the interaction listed (for example, a dragon-fire based steam engine).
[WC_CAN_LEARN][WC_CAN_SPEAK] creature must be capable of learning/speaking (for example... I don't know, magic engine that provides power by being talked to?).
[WC_CREATURE_ALLOWED:creature:caste] require a specific creature and/or caste (so you can say only use the ANT by omitting the caste, or ANT of WORKER caste by defining the require caste as worker). Can have multiple. If defined, the building will ONLY allow creature that's defined in WC_CREATURE_ALLOWED and WC_CREATURE_CLASS_ALLOWED and nothing else.
[WC_CREATURE_FORBIDDEN:creature:caste] similar as above, but specifically forbid certain creature. Note that is WC_CREATURE_ALLOWED is defined, this tag have no meaning (because any creature not part of WC_CREATURE_ALLOWED is considered forbidden).
[WC_CREATURE_CLASS_ALLOWED:class] same as WC_CREATURE_ALLOWED, but based on CREATURE_CLASS tag (again, multiple definition is possible). If defined along with WC_CREATURE_ALLOWED. The building will allow creatures that fulfills either WC_CREATURE_CLASS_ALLOWED or WC_CREATURE_ALLOWED.
[WC_CREATURE_CLASS_FORBIDDEN:class] same as WC_CREATURE_FORBIDDEN. Again have no meaning if the "ALLOWED" counterpart is defined.
[WC_BODYSIZE_RANGE:min:max] creature must have a body size that's within the given range (omitting max indicates no upper limit. to "omit" min, set it to 0). An upper limit would make sense for, say, you make a power generator that runs off guinea pigs or rats (can't stuff a dragon in there).
[WC_REQ_BP_*] * can be one of several body tokens (LIMB, GRASP, STANCE, FLIER, THOUGHT). Creature must have a body part with the given tag to be available (so a CRANK_ENGINE would require a creature with GRASP tag. A treadmill requires STANCE. A Matrix battery requires THOUGHT). Multiple definition means that creature must have all those body tokens available to be eligible.
I think the above should be sufficient. Worst come to worst, you have to manually mod valid creature to have an additional CREATURE_CLASS called "Generator" or something.
So, for power generation reactions, you get something like this.
[REACTION:WALK_TREAD]
[NAME:Drive creature]
[BUILDING:TREAD_MILL:a]
[NEED_WORK_CREATURE] tag indicate that this reaction needs a creature chained to the building.
--- optional restriction tag --- additional [WC_*] that define some required properties for the creature chained to the building. Basically if a building don't have a creature passing these requirement chained to the building, this reaction will be unavailable. Omitting the optional tag means that this reaction only cares that a creature is chained.
[PRODUCT:100:0:NONE:NONE:NONE:NONE][ADD_POWER:50000]
[SKILL:ANIMAL_TRAINER] well, you still need someone to give that creature some incentives to move.
[AUTOMATIC_POWER]
Basically, this combination should give you several options for power sources.
1. Power output based on creature size
Define different building with different power output, each with a different minimum body sized requirement.
2. Dwarf powered engine
Define a reaction with no reagent but still ADD_POWER.
3. Dragonfire based steam engine
Have to modify dragon to change its CAN_DO_INTERACTION:MATERIAL_EMISSION to something more clear like
CAN_DO_INTERACTION:DRAGON_BREATH. Require building/reaction to require creature the "WC_CDI_REQ:DRAGON_BREATH". Any creature with "DRAGON_BREATH" interaction can be used.
4. Matrix-style battery:
Two possible way. An additional feature to dwarf fortress can allow a reaction to "target" the worker/creature chained to workshop. Or using the already defined system, have a PRODUCT that creatures a syndrome based boulder (or bar, or glob) that vaporizes at room temperature (say, boiling point of 1000 urist (water freezes at 10000 urists)). So you can have a generator that produce a lot of power from a dwarf, but renders him unconscious. Or if you want a sacrificial altar, kills the dwarf.
5. Steam engines
Well... duh.
Finally, on power consumption.
All workshop, furnace, engine buildings can have a [USE_POWER:power] tag, where power is the amount of power required to keep it "active". If an engine building have a [USE_POWER:power] tag, you can have an engine that requires a certain amount of power to start up. So you can have building that have this.
[BUILDING_ENGINE:TESSERACT]
[POWER_CAPACITY:10000000]
[POWER_OUTPUT:2000]
[NEED_POWER:1000]
[POWER_EDGE:ALL]
with one reaction
[REACTION:ALIGN_CRYSTAL]
[NAME:Realign power crystals]
[BUILDING:TESSERACT:a]
[PRODUCT:100:0:NONE:NONE:NONE:NONE][ADD_POWER:5000000]
[PRODUCT:5:0:BOULDER:NONE:INORGANIC:TESSERACT_SHARD]
[AUTOMATIC_POWER]
with material
[INORGANIC:TESSERACT_SHARD]
[USE_MATERIAL_TEMPLATE:STONE_TEMPLATE]
[STATE_NAME_ADJ:ALL_SOLID:tesseract shard]
[MELTING_POINT:1000]
[BOILING_POINT:1001]
[SOLID_DENSITY:100]
[USE_MATERIAL_TEMPLATE:POD_JUICE:CREATURE_EXTRACT_TEMPLATE]
[STATE_NAME:ALL_SOLID:tesseract shard]
[STATE_ADJ:ALL_SOLID:tesseract shard]
[STATE_NAME:LIQUID:tesseract fluid]
[STATE_ADJ:LIQUID:tesseract fluid]
[STATE_NAME:GAS:tesseract vapor]
[STATE_ADJ:GAS:tesseract vapor]
[PREFIX:NONE]
[SYNDROME]
[SYN_NAME:tesseract syndrome]
[SYN_AFFECTED_CLASS:GENERAL_POISON]
[SYN_CONTACT]
[CE_FEVER:SEV:50:PROB:100:RESISTABLE:START:50:PEAK:500:END:3000]
[CE_NAUSEA:SEV:35:PROB:100:RESISTABLE:START:50:PEAK:100:END:1000]
[CE_DROWSINESS:SEV:75:PROB:100:RESISTABLE:START:1000:PEAK:2000:END:10000]
[CE_DIZZINESS:SEV:75:PROB:100:RESISTABLE:START:1000:PEAK:2000:END:10000]
Basically, it's an engine that, once supply with an initial 1000 units of power, will provide a net output of 1000 units of power that just require a dwarf to "maintain" it once in a while. But has a 5% chance of causing a crystal shard to break off and vaporize, which cause cave-floater like syndrome over a long period of time.