Author Topic: In-Game Scenario Editor  (Read 8987 times)

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
In-Game Scenario Editor
« on: November 05, 2020, 09:53:56 PM »
The barrier to mission development is pretty high, but here's something I'm hoping will lower it just a bit.  I've created an in-game scenario editor, available in both Colony Game and 6-player Last One Standing flavors.  You start with an empty tutorial.map, but using chat commands you can change the current terrain file, spawn units, structures, and mining beacons, change disaster settings, or even disable the editor and start a standard LOS game.  There is, of course, a command to generate C++ code that can be copied into a level's source code to recreate the current unit setup.  But this isn't just a tool for the technically-inclined among us.  You can also generate a command list that the editor can read in again later to recreate the unit setup in-game, that even works in multiplayer!

I've attached the colony game and multiplayer versions of the map, as well as a sample script file.  Load the Editor in multiplayer and have the host enter these commands to give it a try!
Code: [Select]
/changemap mp3_02.map/load sample1v1.txt
/startLOS

And here's a full command list, along with a list of (required) and [optional] arguments:
Code: [Select]
Command list (all commands and arguments are case-sensitive):
      /save                                                -- Generate code for the current setup on the local player's machine.  Does nothing for remote clients.
      /load (PreviousOutputFileName.txt)                -- Loads a script file previously generated by the /save command.  Only the host may use this command.
                                                           This works by generating fake chat command packets from the host which contain spawning instructions.
                                                           Since the game can only process so many command packets per cycle, this may take awhile to fully load complex setups.
      /cpp                                                -- Generates C++ code using TethysAPI for the current setup on the local player's machine.  Does nothing for remote clients.
      /cpp_legacy                                       -- Generates C++ code using Outpost2DLL for the current setup on the local player's machine.  Does nothing for remote clients.
      /python                                            -- Generate a Python script for the current setup on the local player's machine.  Does nothing for remote clients.
      /dc (disType) (chance)                            -- Sets the chance for the designated disaster (quake, storm, vortex, or meteor).  Disasters won't start spawning until /startLOS has been used.
      /eden                                                -- Sets the source player to Eden
      /plymouth                                            -- Sets the source player to Plymouth
      /setplayer (0-6)                                    -- Changes the local player ID to the specified number.  Allows you to take control of other players.  Seems to work in multiplayer, but you can't take control of other humans.
      /common (x) (y) [yield] [variant]                    -- Spawn a common ore mine at the passed-in coordinates.  Yield and variant should both be between 0 (high/3bar) and 2 (low/1bar).
      /rare (x) (y) [yield] [variant]                    -- Spawn a rare ore mine at the passed-in coordinates.  Yield and variant should both be between 0 (high/3bar) and 2 (low/1bar).
      /fumarole (x) (y)                                    -- Spawn a fumarole at the passed-in coordinates.
      /magmavent (x) (y)                                -- Spawn a magma vent at the passed-in coordinates.
      /wreck (x) (y) [techID] [isDiscovered]            -- Spawns wreckage at the passed-in coordinates.  Defaults to "Tiger Speed Upgrade" and undiscovered.
      /clear                                            -- Erases all units on the map.  Requires confirmation.  Attempting to delete mining beacons may crash OP2.
      /changemap (mapname.map)                            -- Loads the terrain of the specified map.  Cannot be used if any units currently exist on the map.  Only the host may use this command.
      /spawn (Unit) (owner) (x) (y) [cargo] [amount]    -- Spawns the designated unit, optionally carrying the designated cargo, at the specified coordinates for the source player.
                                                            You will not be allowed to give units "illegal" cargo (no ConVecs carrying Tigers, no Tigers armed with Command Centers, etc.).
                                                            Amount is optional and only applies to Cargo Trucks.  Default is 1000 for resources, "Tiger Speed Upgrade" for wreckage, and EDWARD Satellite for starship components.
                                                            Location is not checked before spawning, so you may get odd results if you do something the game doesn't expect!
                                                            Valid options for Unit (and Cargo for ConVecs, as appropriate):
                                                             - CargoTruck
                                                             - ConVec
                                                             - Spider
                                                             - Scorpion
                                                             - Lynx
                                                             - Panther
                                                             - Tiger
                                                             - RoboSurveyor
                                                             - RoboMiner
                                                             - GeoCon
                                                             - Scout
                                                             - RoboDozer
                                                             - EvacuationTransport
                                                             - RepairVehicle
                                                             - Earthworker
                                                             - CommonOreMine
                                                             - RareOreMine
                                                             - GuardPost
                                                             - LightTower
                                                             - CommonStorage
                                                             - RareStorage
                                                             - Forum
                                                             - CommandCenter
                                                             - MHDGenerator
                                                             - Residence
                                                             - RobotCommand
                                                             - TradeCenter
                                                             - BasicLab
                                                             - MedicalCenter
                                                             - Nursery
                                                             - SolarPowerArray
                                                             - RecreationFacility
                                                             - University
                                                             - Agridome
                                                             - DIRT
                                                             - Garage
                                                             - MagmaWell
                                                             - MeteorDefense
                                                             - GeothermalPlant
                                                             - ArachnidFactory
                                                             - ConsumerFactory
                                                             - StructureFactory
                                                             - VehicleFactory
                                                             - StandardLab
                                                             - AdvancedLab
                                                             - Observatory
                                                             - ReinforcedResidence
                                                             - AdvancedResidence
                                                             - CommonOreSmelter
                                                             - Spaceport
                                                             - RareOreSmelter
                                                             - GORF
                                                             - Tokamak
                                                        Valid options for weapons:
                                                             - AcidCloud
                                                             - EMP
                                                             - Laser
                                                             - Microwave
                                                             - RailGun
                                                             - RPG
                                                             - Starflare
                                                             - Supernova
                                                             - ESG
                                                             - Stickyfoam
                                                             - ThorsHammer
                                                        Valid options for Cargo Truck cargo:
                                                             - Food
                                                             - CommonOre
                                                             - RareOre
                                                             - CommonMetal
                                                             - RareMetal
                                                             - CommonRubble
                                                             - RareRubble
                                                             - Spaceport (starship components and satellites - only use values 88 - 104, inclusive, when passing in an amount!)
                                                             - Garbage (wreckage - amount corresponds to tech ID - invalid tech IDs will crash!)
    /setres (resource type) (amount)                    -- Gives the source player the specified quantity of the specified resources.
                                                            Valid options for resource type:
                                                             - common
                                                             - rare
                                                             - food
                                                             - kids
                                                             - workers
                                                             - scientists
    /setTechLevel (tech level)                            -- Gives all technologies whose tech level is less than the passed-in value.  Tech level 13 will give you all technologies.
                                                           Note that you can only give yourself techs this way, not take them away.
    /startLOS [keep resources]                            -- Gives all players default starting resources and creates default Last One Standing victory/defeat conditions.  Only the host may use this command.
                                                           Passing in 1 for the keep resources parameter will override the default LOS resources setting.
                                                           Using this command disables all other commands aside from /save, /cpp, and /python.
                                                           Important note!  The standard LOS victory check is hardcoded to ignore AI players, so attempting a human vs CPU match will instantly end the mission after using this command.

AI Command List (work in progress):
        /ai mining (playerNo) (x1) (y1) (x2) (y2)        - Searches for existing common/rare ore mines and smelters within the specified area and sets up ore-hauling behavior.
                                                          Will fail if more than 1 mine of the same type exists within the specified area.
                                                          AI cannot currently build up its own mines and smelters; they must be pre-placed.
        /ai defenders (playerNo) (x1) (y1) (x2) (y2)    - Searches for combat units within the specified area and sets them up to automatically defend that area.
                                                          Due to internal limitations, only the first 32 units found will be added to the group.
        /ai reinforce (playerNo)                        - Searches for Vehicle Factories owned by the specified player and sets them up to rebuild destroyed units from
                                                          any existing ore-hauling or defense unit groups.  This command should be called after all such groups
                                                          have already been defined.
8/18/2021 update: /cpp now generates calls new-style TethysAPI calls.  Use /cpp_legacy for old-style Outpost2DLL calls.  /python command now works but it's largely untested.  Also added the /wreck and /setTechLevel commands.  Fixed a few bugs.
« Last Edit: August 18, 2021, 08:42:51 AM by Sirbomber »
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials

Offline leeor_net

  • Administrator
  • Hero Member
  • *****
  • Posts: 2352
  • OPHD Lead Developer
    • LairWorks Entertainment
Re: In-Game Scenario Editor
« Reply #1 on: November 06, 2020, 08:34:58 AM »
This is pretty sweet! I'll have to check it out.

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Re: In-Game Scenario Editor
« Reply #2 on: November 06, 2020, 10:14:39 AM »
I posted incomplete documentation; these commands allow you to set up extremely basic AI opponents:
Code: [Select]
AI commands - these will all fail if used on an active human player.
    /ai mining (playerNo) (x1) (y1) (x2) (y2)        - Searches for existing common/rare ore mines and smelters within the specified area and sets up ore-hauling behavior.
                                                      Will fail if more than 1 mine of the same type exists within the specified area.
                                                      AI cannot currently build up its own mines and smelters; they must be pre-placed.
    /ai defenders (playerNo) (x1) (y1) (x2) (y2)    - Searches for combat units within the specified area and sets them up to automatically defend that area.
                                                      Due to internal limitations, only the first 32 units found will be added to the group.
    /ai reinforce (playerNo)                        - Searches for Vehicle Factories owned by the specified and sets them up to rebuild destroyed units from
                                                      any existing ore-hauling or defense unit groups.  This command should be called after all such groups
                                                      have already been defined.
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Re: In-Game Scenario Editor
« Reply #3 on: November 06, 2020, 01:43:24 PM »
Hey, neat

Offline tigerstorms

  • Newbie
  • *
  • Posts: 9
Re: In-Game Scenario Editor
« Reply #4 on: November 06, 2020, 01:53:36 PM »
this is awesome, thank you for your hard work.

Offline RokkanJC

  • Newbie
  • *
  • Posts: 7
  • Adun'toridas
Re: In-Game Scenario Editor
« Reply #5 on: May 29, 2021, 08:48:44 PM »
I find this project very cool, I have a lot of ideas to make Outpost 2 maps, so it makes it too easy for me something like this.

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3238
Re: In-Game Scenario Editor
« Reply #6 on: August 18, 2021, 09:13:25 AM »
Quick update, the /cpp command now generates code that uses Arklon's new TethysAPI.  If you still want to use old-style Outpost2DLL calls, use /cpp_legacy.  And the /python command now works, though since the Python mission interpreter isn't actually available yet, this is currently of limited use.

You can also now use /setTechLevel to give yourself technologies.  The command expects an integer and will give you every research item you could have researched in the previous campaign mission (so a value of 4, the lowest value that actually has an effect when using multitek, gives you all technologies that first became available in mission 3).  A value of 13 will give you all normally researchable technologies.

The /wreck command can be used to place starship wreckage components.  Wreckages can be returned to a Spaceport to unlock a free technology.  The default technology is the secret Tiger Speed Upgrade technology.  If you choose to define something else, make sure it's a valid tech ID or the game will crash!
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials