Starcraft modeling for Factorio - heinermann/factorio-starcraft GitHub Wiki
In order to operate in Factorio, some liberties were taken to allow dynamic interactions between StarCraft and Factorio mechanics while retaining the same StarCraft-to-StarCraft behaviours.
Damage Types
StarCraft has a damage type vs unit size type relationship that apply damage reduction to certain damage types against certain size types. The damage resistance table for StarCraft is as follows. A minimum of 0.5 damage is always given.
| Unit Size | Independent | Explosive | Concussive | Normal | Ignore Armour |
|---|---|---|---|---|---|
| Independent | 100% | 100% | 100% | 100% | 100% |
| Small | 100% | 50% | 0% | 0% | 0% |
| Medium | 100% | 25% | 50% | 0% | 0% |
| Large | 100% | 0% | 75% | 0% | 0% |
Factorio damage types are different but can be mapped to Starcraft damage types with resistances applied to have similar behaviour to StarCraft (granted we may need special logic for min damage and shields).
The mapping and reasons for mapping are as follows:
| StarCraft Type | Factorio Types | StarCraft Perspective | Factorio Perspective |
|---|---|---|---|
| Independent, Ignore Armour | N/A | There isn't really an equivalent in Factorio to these special types. | We can create new damage types as needed. Since they are new they will not be resisted. Example: "psionic" for psionic storm. |
| Explosive | Explosion, Acid | Corrosive Acid from Devourers deals explosive damage. | Spitters and Worms deal acid damage which are comparable to Hydralisks and Sunken Colonies (which deal explosive damage), so the damage type/unit size relationship is consistent with spitters vs StarCraft units. Grenades and rockets deal explosive which are comparable to StarCraft's rockets, spider mines, and siege tanks. |
| Concussive | Impact, Fire | Ghosts and other units deal concussive damage and the only other available physical attribute that made sense was Impact damage. Firebats and wall traps are the only units in StarCraft that use Fire. | Treating Fire as concussive means the Factorio flamethrower will classify as the same damage type as the Firebat. The larger Factorio units typically have higher impact resistance than physical resistance, for example locomotives and tanks have 60% and 80% resistance respectively which is close to StarCraft's Large type relationship. Unfortunately biters/behemoths don't have these. Some structures have impact + fire resistance as well which doesn't quite match up with StarCraft but it's closer than not having the relationship. |
| Normal | Physical, Laser, Electric | Most normal attacks include lasers, beams, and melee damage which can easily fall under laser, electric, and physical respectively. | |
| N/A | Poison | Irradiate against organic units only. Irradiate being a poison attack means Factorio structures, robots, and vehicles won't get damaged. | Structures/robots/vehicles are immune to poison in Factorio. This means StarCraft's structures, vehicles, and robots having poison immunity (irradiate immunity) fits into the Factorio universe. |
While we aren't barred from creating new types, creating relationships with Factorio as described above will allow the StarCraft universe to fit in better. New damage types can be reserved for i.e. Psionic Storm and Feedback.
The StarCraft Unit Size Type vs Factorio damage resistance table is as follows:
| Unit Size | Explosion | Acid | Impact | Fire | Physical | Laser | Electric |
|---|---|---|---|---|---|---|---|
| Independent | 99% | 99% | 99% | 99% | 99% | 99% | 99% |
| Small | 50% | 50% | 0% | 0% | 0% | 0% | 0% |
| Medium | 25% | 25% | 50% | 50% | 0% | 0% | 0% |
| Large | 0% | 0% | 75% | 75% | 0% | 0% | 0% |
Granted independent size units will not take the correct damage as in Starcraft, but its behaviour was limited to Use Map Settings maps anyway and there's argument for this inconsistency be overlooked.
Unit Prototype Flags and Properties
| Starcraft Property | Factorio Equivalent | Notes |
|---|---|---|
| Mine-safe (hovering) | has_belt_immunity or no water-tile/object-layer collision |
Units that are mine safe should be given belt immunity as well. |
| Flyer/Flying | collision_mask = nil |
Factorio doesn't actually have a concept of air vs ground units so some guesses need to be made. |
| Hero | N/A | |
| Regenerate | healing_per_tick = 0.0062 |
Zerg health regen happens at 1/64 per frame, StarCraft runs at 42ms/f while Factorio runs at 60f/s (16.666...ms/f). 42ms/f / 16.666...ms/f = 2.52 Factorio frames/StarCraft frame, so Zerg health regen should happen at (1/64)/2.52 = ~0.0062 per tick. |
| Spellcaster | Undecided. | |
| Permanently Cloaked | Custom. | |
| Invincible | destructible = false |
|
| Organic | breaths-air flag |
Needs thought. |
| Mechanical | Does not have the not-repairable flag |
Needs thought, since non-Terran mech units are also not repairable. |
| Robotic | Does not have the not-repairable and breaths-air flags |
Needs thought. |
| Detector | type = "radar" |
Radars should automatically detect nearby cloaked units as there is otherwise no such mechanism in Factorio. |
| Subunit | Internal mechanism | |
| Resource Container | type = "resource" |
|
| Resource Depot | StarCraft-specific mechanic | |
| Worker | ||
| Requires Psi | (Needs to be in-range of Pylons), maybe a power mechanic? Otherwise something else. | |
| Requires Creep | Only placeable on creep tiles | |
| Two Units in One Egg | ||
| Single Entity | Not sure | |
| Burrowable | ||
| Cloakable | ||
| Battle Reactions | ||
| Full Auto Attack | ||
| Building | TODO | |
| Addon | TODO | |
| Flying Building | ||
| Use Medium Overlays | Not sure if applicable | |
| Use Large Overlays | Not sure if applicable | |
| Ignore Supply Check | Internal | |
| Produces Units | ||
| Animated Overlay | ||
| Carryable | Has an item and can go into the inventory. |
|
| Unselectable | selectable_in_game = false |
Time and Scale
The Factorio character is roughly the same proportions and graphically very similar to the Terran Civilian. In Factorio the character takes about 1 full tile of space. The Civilian in StarCraft takes about half a tile. Using this as a reference, StarCraft units will use 2x the tiles. I.e. the mineral field is 2x1, in Factorio it should be 4x2, a pylon should be 4x4 tiles (larger than the electric mining drill), etc.
StarCraft runs at 42ms/frame (1000/42 fps) while Factorio runs at 60ups (1000/60 ms/frame), one StarCraft update ends up being 2.52 Factorio updates.
| What | StarCraft Measure | Factorio Measure | Notes |
|---|---|---|---|
| Tile | 1 tile | 2 tiles | |
| Pixel | 1 pixel | 1/16 tile | Unit of measure used most often in Starcraft. |
| Updates | 1 update | 2.52 updates | Often rounding 2 StarCraft updates to 5 Factorio updates because we cannot work well with fractional numbers. |
| Shield Regen | 7/256 per tick | 25/2304 per tick | 1 shield every 92.16 updates. |
| Zerg Regen | 4/256 per tick | 25/4032 per tick | 1 hp every 161.28 updates. |
| Energy Regen | 8/256 per tick | 25/2016 per tick | 1 energy every 80.64 updates. |
| Shield Battery recharge | 1280/256 per tick | 125/63 per tick | 2 shields every 1.008 updates. |
| Shield Battery recharge energy drain | -640/256 per tick | -125/126 per tick | 1 energy every 1.008 updates. |
| Burning Terran Building | -20/256 per tick | -125/4032 per tick | 1 hp every 32.256 updates. |
| Medic Heal hp | 200/256 per tick | 625/2016 per tick | 1 hp every 3.2256 updates. |
| Medic Heal energy drain | -100/256 per tick | -625/4032 per tick | 1 energy every 6.4512 updates. |
| Ghost cloak energy drain | -18/256 per tick | -25/896 per tick | 1 energy every 35.84 updates. |
| Wraith cloak energy drain | -21/256 per tick | -25/768 per tick | 1 energy every 30.72 updates. |
Unit States and Animations
Factorio entities don't support masking overlays or playing specific frames. LuaRendering does support sprites with specific animation offset but these are drawn above the specified layer, so they can't really be used for main graphics that other entities can walk behind or in front of.
Structures
Some entity types (mainly structures) do support animation variations and switching between them. Many entities will simply have multiple versions which will be swapped out.
Structures which can train, research, and upgrade will be AssemblingMachines. This allows them to have separate built-in idle/working anims, use Factorio's built-in system to handle the timing of training units (or researching/upgrading), as well as support vanilla speed beacons (or any modded entity that applies speed). Since there are several bugs with AssemblingMachine capabilities, I must opt for the below instead. This issue in particular ruins the immersive experience and this one means Zerg Structures cannot be supported by this model.
Other structures will be SimpleEntityWithForces. Some anims can be handled with animation variations. It's not clear whether switching animation variations will start playing the animation from the beginning or not though.
Entity clones can be categorized as follows:
- Zerg: Morph constructing, main structure (idle/attacking), morphing
- Protoss: Warp-in, finished warping, main structure (idle/working/attacking)
- Terran: Constructing, main structure (idle/working/attacking), liftoff
Factorio supports dying explosions and building rubble out of the box. Considered ElectricEnergyInterface for structures with energy or shields but it does not support variations. It's not clear if Turret is capable of meeting all the needs of turrets, cannons, sunkens, and spores.
The use of the Turret prototype for cannons, sunkens, spores, and turrets needs investigating, but as of right now their behaviours can be entirely scripted (and might need to be).
Liftable structures will need to be replaced with a separate moveable entity.
Not sure about Bunker behaviour, pylon power, or creep. As a visual enhancement, disabled Protoss structures can lose their glow overlay.
Units
Originally considered Factorio's Unit, but this doesn't support the movement behaviour fidelity or weapon switching needed to behave like a StarCraft unit. Nor can units support equipment grids for managing shields and energy. The second consideration was using Character, which does support movement fidelity and equipment grids, but only has 8 facing directions. Therefore units will all be Cars, since it is the only entity prototype which allows precise movement control with more than 8 facing directions as well as supports equipment grids.
Bullets/Projectiles
Factorio Projectiles have a lot of configuration options so I think most/all StarCraft weapons can be implemented using the built-in mechanics. Out of the box they support various movement options, shadows, smoke, actions/triggers, various splash damage types, appear-on-target or projectile, direction deviations, acceleration, turns, and running a script when it starts from a source or hits a target.
Abilities and Orders
| Ability | Implementation |
|---|---|
| Stim Pack | Invisible sticker applied to self which has a movement speed modifier. |
| Lockdown | Sticker with Lua that does entity.active = false seems most appropriate. |
| EMP Shockwave | Target action triggering a script which sets all shields, energy, and electricity for all properties, inventories, and equipment grids to 0. |
| Spider Mine | Spider mines will need to be uniquely scripted entities. |
| Scanner Sweep | Invisible entity with overlay and time to live timer which reveals any cloaked units (custom logic) in the area. |
| Siege Mode | Replace the entity as it would in StarCraft. |
| Defensive Matrix | Sticker with external tracking script? Script could track which entities have defensive matrix points remaining and somehow absorb damage? Largely unclear. |
| Irradiate | Sticker with damage per tick for poison damage. May need additional scripting for AOE damage. |
| Yamato Gun | Is a regular projectile. |
| Cloaking | Replace the entity with one that has a different graphic. |
| Burrow | Replace entity with unique burrowed version. |
| Infestation | Teleport to hidden surface with countdown, then replace the Command Center entity. |
| Spawn Broodling | Projectile, immediately kill target and create two broodlings. |
| Dark Swarm | Not sure. Can possibly query projectiles and modify their target. |
| Plague | AOE that applies stickers that deal damage. |
| Consume | Either a melee range projectile that appears on target and ends with a script or fully scripted. |
| Ensnare | AOE that applies speed debuff stickers. |
| Parasite | Not sure what to do with it. |
| Psionic Storm | Unknown? Surface sticker? |
| Hallucination | Special copies of entities which take more damage and deal none, dying in puff of smoke? |
| Recall | Teleport entities based on animation. |
| Stasis | Same as lockdown but with invincibility (entity.destructible = false). |
| Restoration | Remove all negative stickers and parasite/blind on target entity. |
| Disruption Web | Set shooting_target to {} for turrets every update. For failure cases, disable the turret entirely (might be the better option generally because of other mods). Not sure about movable entities, maybe unequip weapons somehow, or remove projectiles created in its vicinity? |
| Mind Control | Change owning force of target unit/vehicle/robot. Disallow on characters, trains, and probably also the normal robots which require roboports. |
| Feedback | Get energy amounts from inventories or equipment, and deal that in damage (i.e. damage based on battery capacity, may need balancing with energy-to-hp ratio). |
| Optical Flare | Unknown. |
| Maelstrom | Same as lockdown but AOE. |
| Healing | Unknown, maybe direct health modification? |
| Repair | Possibly use whatever Factorio's repair mechanics do? |