Skip to content

Compiler options

Zezombye edited this page Oct 14, 2020 · 11 revisions

Compiler options begin with the #! operator, not indented.

#!include

Inserts the text of the specified file. The file path can be relative; if so, it is relative to the main file. For example:

#!include "heroes/zenyatta.opy"
#!include "../main.opy"

#!mainFile

Specifies an .opy file as the main file (implying the current file is a module). This directive MUST be placed at the very beginning of the file. For example:

#!mainFile "../main.opy"

#!obfuscate

Obfuscates the resulting code. This directive assumes all your code is in the overpy file, meaning you should not combine the generated code with code that is only in the workshop GUI.

Usage of this directive will result in a size increase, and a very low performance decrease, but should not in any case alter how the existing code functions. (if it does, please report that as a bug)

The following obfuscation methods are applied:

  • Rule filling: 2500 empty rules are inserted, making it impossible to view the gamemode within the workshop UI. It must be copy-pasted to be able to be edited (you can then apply various anti copy-paste integrity checks).
  • Name obfuscation: all rule titles and comments are removed, and all variable/subroutine names are replaced with a combination of capital i and lowercase L.
  • String obfuscation: characters in custom strings are replaced with special characters that display in Overwatch, but not text editors.
  • Constant obfuscation: some constants, such as heroes or maps, are replaced with other values that compute to the original value.
  • Inspector obfuscation: the inspector is disabled, and all disable/enable inspector actions are removed.
  • Copy protection: the gamemode will break upon copying it via text. It is highly recommended to enable constant obfuscation to greatly strengthen this protection.

To save elements, it is possible to specify methods to disable, by prefixing them with no. For example, #!obfuscate noRuleFilling noConstantObfuscation will disable rule filling and constant obfuscation, which is useful if the obfuscation adds too much elements.

#!suppressWarnings

Suppresses the specified warnings globally across the program. Warnings must be separated by a space. Example:

#!suppressWarnings w_type_check w_unsuitable_event

Replacements

Several compiler options are available to automatically replace some constants, in order to save elements:

#!replaceTeam1ByControlScoringTeam
#!replace0ByCapturePercentage
#!replace0ByPayloadProgressPercentage
#!replace0ByIsMatchComplete
#!replace1ByMatchRound

These replacements should only be used if the requirements for the replacement are met. They are detailed in the intellisense description of each compiler option.