Post tutorial RSS Enabling and disabling technologies with CBOT (updated)

Did you know that you can make your level much more complex by enabling or disabling some buildings or bots on the fly with just few more CBOT commands?

Posted by on - Basic Mapping/Technical

Did you know that you can make your level much more complex by enabling or disabling some buildings or bots on the fly with just few more CBOT commands? Note: there are two updates at the bottom of this article.

Commands setbuild, setresearchenable(), setresearchdone(), getbuild(), getresearchenable() and getresearchdone() are very useful for level makers, because they allow you to change any technologies available or researched on the fly. Bear in mind that they are cheats and should not be used in "legal" programs.

Some basic examples of use (if statements are here to prevent messing up of research mask):

  • Make shielder researchable (but not researched):
    if(canresearch(64) == false){setresearchenable(getresearchenable()+64);} 
  • Research shielder:
    if(researched(64) == false){setresearchdone(getresearchdone()+64);}
  • Unresearch (but not disable) orga shooters:
    if(researched(512) == true){setresearchdone(getresearchdone()-512);}
  • Enable a building - defense tower:
    if(buildingenabled(DefenseTower) == false){setbuild(getbuild()+256);}

Here's a little bigger example. Suppose you make a level where you want to give player access to winged robots only after he killed all the spiders. Here's how this can be done (this is a saveloading proof example by the way):

while(true)
{
	wait(1);
	if(canresearch(ResearchWinged) == false and radar(AlienSpider) == null) // Remember that ResearchWinged is int and equals 2
	{
		setresearchenable(getresearchenable()+ResearchWinged); // And it does not matter if you write 2 or ResearchWinged here
		message("You killed all spiders and now can research wingers!", DisplayInfo);
	}
}

Here are codes for all researches and buildings.

Researches:

  • 1 caterpillars
  • 2 wings
  • 4 cannon
  • 8 defense tower
  • 16 nuclear
  • 32 thumper
  • 64 shield
  • 128 phazer gun
  • 256 legs of insects
  • 512 cannon of insects
  • 1024 recycler
  • 2048 submarine
  • 4096 sniffer
  • 8192 builder
  • 16384 target bot

Buildings:

  • 1 BotFactory
  • 2 Derrick
  • 4 Converter
  • 8 RadarStation
  • 16 PowerPlant
  • 32 NuclearPlant
  • 64 PowerStation
  • 128 RepairCenter
  • 256 DefenseTower
  • 512 ResearchCenter
  • 1024 AutoLab
  • 2048 PowerCaptor
  • 4096 ExchangePost
  • 8192 Destroyer
  • 16384 checking flat ground
  • 32768 putting / removing flags

UPDATE:

It seems that you cannot include one of these commands directly inside another like this:

setbuild(getbuild()+64);

Because compiler does not allow it. You will have to store value from getbuild() (for example) in some int variable first and then use it like this:

b = getbuild();
setbuild(b+64);

UPDATE 2:

Enabled researches (but not done researches) will be reset after you will load a savegame in your level. Therefore you have to make sure that your piece of code that checks conditions and changes enabled researches is run always and not just once.

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.