Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The LevelController command
#1
Question 
I'm working on some code battle levels
with some randomized elements.

I'm having a hard time with the LevelController command.

Q:

1. Does it work?
2. Is it used for executing CBot code independent of any bot?
3. Is it available for custom levels/code battles?
4. Are there any restrictions as to how it is used?
5. What is the path it requires for scripts?
#2
1. Yes, but it's currently quite limited and forces you to handle EndMissionTake and AudioChange logic manually in code. Also, it has been unmaintained for a long while, so I'm actually not 100% sure it still works. Keep in mind this is heaivly work in progress and definetly will break compatibility between releases when we come back to implementing it.
2. It uses an invisible object - you can select it with "controller" cheat code if it exists in the level. After CBot refactoring it is planned to be independent of any object.
3. Yes
4. Existence of the level controller script currently disables EndMissionTake and AudioChange commands. You have to handle them manually in the code, as this script was meant to be a future replacement of these commands (but it's not going to fully replace them probably)
5. Like any other script path in CreateObject command - defaults to ai/ but can be overriden by using the %lvl%, %chap% or %cat% commands.

As for writing custom implementation of the disabled commands, there is a slight problem as they do not support teams because the LevelController has not been maintained in a long time since it's so limited that nobody used it so far. The functions needed are:
Code:
void endmission(int result, float endDelay); // works only when LevelController exists and apparently is not highlighted in editor (like produce). result is one of: ResultNotEnded, ResultLost, ResultLostQuick, ResultWin. I'm pretty sure that if there is SpaceShip on the map it won't end immediately, but it'll unlock the takeoff button. endDelay works like EndMissionDelay in level file.
void playmusic(string filename, bool repeat);
void stopmusic();

You might also find those useful for LevelController (all of them operate on bitmasks):
Code:
int getbuild();
void setbuild(int new);
int getresearchenable();
void setresearchenable(int new);
int getresearchdone(); // no access to team-based research data unfortunately :(
void setresearchdone(int new); // no access to team-based research data unfortunately :(
And the corresponding constants:
Code:
   // NOTE: The Build___ constants are for use only with getbuild() and setbuild() for MissionController, not for normal players
   CBotProgram::DefineNum("BuildBotFactory",       BUILD_FACTORY);
   CBotProgram::DefineNum("BuildDerrick",          BUILD_DERRICK);
   CBotProgram::DefineNum("BuildConverter",        BUILD_CONVERT);
   CBotProgram::DefineNum("BuildRadarStation",     BUILD_RADAR);
   CBotProgram::DefineNum("BuildPowerPlant",       BUILD_ENERGY);
   CBotProgram::DefineNum("BuildNuclearPlant",     BUILD_NUCLEAR);
   CBotProgram::DefineNum("BuildPowerStation",     BUILD_STATION);
   CBotProgram::DefineNum("BuildRepairCenter",     BUILD_REPAIR);
   CBotProgram::DefineNum("BuildDefenseTower",     BUILD_TOWER);
   CBotProgram::DefineNum("BuildResearchCenter",   BUILD_RESEARCH);
   CBotProgram::DefineNum("BuildAutoLab",          BUILD_LABO);
   CBotProgram::DefineNum("BuildPowerCaptor",      BUILD_PARA);
   CBotProgram::DefineNum("BuildExchangePost",     BUILD_INFO);
   CBotProgram::DefineNum("BuildDestroyer",        BUILD_DESTROYER);
   CBotProgram::DefineNum("FlatGround",            BUILD_GFLAT);
   CBotProgram::DefineNum("UseFlags",              BUILD_FLAG);

   CBotProgram::DefineNum("ResearchTracked",       RESEARCH_TANK);
   CBotProgram::DefineNum("ResearchWinged",        RESEARCH_FLY);
   CBotProgram::DefineNum("ResearchShooter",       RESEARCH_CANON);
   CBotProgram::DefineNum("ResearchDefenseTower",  RESEARCH_TOWER);
   CBotProgram::DefineNum("ResearchNuclearPlant",  RESEARCH_ATOMIC);
   CBotProgram::DefineNum("ResearchThumper",       RESEARCH_THUMP);
   CBotProgram::DefineNum("ResearchShielder",      RESEARCH_SHIELD);
   CBotProgram::DefineNum("ResearchPhazerShooter", RESEARCH_PHAZER);
   CBotProgram::DefineNum("ResearchLegged",        RESEARCH_iPAW);
   CBotProgram::DefineNum("ResearchOrgaShooter",   RESEARCH_iGUN);
   CBotProgram::DefineNum("ResearchRecycler",      RESEARCH_RECYCLER);
   CBotProgram::DefineNum("ResearchSubber",        RESEARCH_SUBM);
   CBotProgram::DefineNum("ResearchSniffer",       RESEARCH_SNIFFER);
#3
Thanks.
#4
The LevelController (still called MissionController in parserparam.cpp)
object is currently disabled in source.

I temporarily revived it and confirmed that it works, but it is slightly broken.

That thing is really crazy to drive,
and parking it in shallow water results in constant splashing. Big Grin
#5
I noticed that it got lost somewhere, I have actually commited a fix on the dev branch about the same time you posted this:
https://github.com/colobot/colobot/commi...80f857f080


Forum Jump:


Users browsing this thread: 4 Guest(s)