Skip to content

Machine flags & attackby: How to operate the general code

PJB3005 edited this page Mar 28, 2016 · 4 revisions

Assuming you know what bitflags are, all types under obj/machinery have a shared var for flags determining common behaviour: machine_flags. The flags, which you can find in setup.dm, are as follows:

  • 1 - EMAGGABLE - If this is enabled, the machine will call the emag proc when smacked with an emag.
  • 2 - SCREWTOGGLE - If this is enabled, the machine will call the togglePanelOpen proc when smacked with a screwdriver. NB - this changes the panel_open var, which is also common to all machines. DO NOT create a new var to see if your machine is open. panel_open. Use it.
  • 4 - CROWDESTROY - If this is enabled, the machine will follow common deconstruction when it's hit by a crowbar while the panel is open. Common deconstruction is for anything using constructable_frame and machine components.
  • 8 - WRENCHMOVE - If this is enabled, the machine can be anchored or unanchored whenever it is hit with a wrench. Pretty useful for machines you want to move about.
  • 16 - FIXED2WORK - If this is enabled, the machine loses power when not wrenched down.
  • 32 - EJECTNOTDEL - If this is enabled, the machine's contents (not parts, but stuff that's actually IN the machine) will be ejected when it is deconstructed. Smartfridges want this, for example. Other things don't.
  • 64 - WELD_FIXED - With the addition of state as a var for all machines, this flag now allows for some special behaviour mainly used on engine machines: welding down. If you enable this flag, the machine can use weldToFloor as a proc. Machines need to be wrenched to be welded, and unwelded to be unwrenched.

You can set these flags by editing the machine_flags var for a machine.

All these flags operate on one basic assumption: that the machine inherits all its attackbys from obj/machinery, and does so in such a way that if the parent attackby returns a non-null value, the child attackby returns it as well. In other words, you're going to want some sort of if(..()) check in your code to use these flags properly.