Object categories (C4D)

Description

Constants for setting or retrieving categories of an object. These constants are used with GetCategory and SetCategory. The category of an object is a DWord bitmask composed of the following values. The first 5 categories do not allow any combination, exactly one of the bits 0-4 may and must be set at any time.
The C4D_All constant introduced in 4.6.5.0 CP stands for "all categories" and can be used for filter functions for example. Constants that are not listed but are in DefCore.txt categories can be set with the appropriate numeric value via SetCategory.

Constants

Name Category Description Introduced in Value
C4D_StaticBack Objects/Category Immovable background objects. 4.6.5.0 CP 1
C4D_Structure Objects/Category Buildings. 4.6.5.0 CP 2
C4D_Vehicle Objects/Category Vehicles. 4.6.5.0 CP 4
C4D_Living Objects/Category Living beings. 4.6.5.0 CP 8
C4D_Object Objects/Category Small objects/items. 4.6.5.0 CP 16
C4D_Goal Objects/Category Game goals. 4.6.5.0 CP 32
C4D_Environment Objects/Category Environmental control objects. 4.9.5.0 CE 64
C4D_Knowledge Objects/Category Construction plans. For the menu system selection of manufacturable objects. 4.6.5.0 CP 1024
C4D_Magic Objects/Category Spell. Interpretable as a numerical value by the engine already from 4.9.1.0 GWE. 4.9.5.0 CE 131072
C4D_Rule Objects/Category Game rules. 4.6.5.0 CP 524288
C4D_Background Objects/Category Is drawn behind the landscape. Useful, for example, for effect objects such as clouds or celestial bodies. This category does not work in the 8-bit graphics system. 4.9.1.0 GWE 1048576
C4D_Parallax Objects/Category The object moves parallax with respect to the landscape. This means that the apparent object position changes depending on the scroll position of the viewport. This can be used to have objects apparently moving in the far background or to create status overlays.
Parallax deviation from the normal location is specified in percent and stored in the first two indexed, local variables (see Local()) of the object (Local(0) for horizontal, Local(1) for vertical deviation). This means for normal location these two values should be 100. A value of 0 will lock the object to the viewport. For parallax background object use values between 0 and 100. To position objects directly at the player's viewport, for example to realize status displays, Local(0) and Local(1) can be set to 0. The object position is then always relative to the upper left corner of the viewport. From CR, object positions can also be negative values. Those objects will then be aligned with the right or bottom edge of the screen respectively.
4.9.1.0 GWE 2097152
C4D_MouseSelect Objects/Category Object can be clicked with the mouse, causing a MouseSelection(int iPlr) callback in the object. 4.9.5.0 CE 4194304
C4D_Foreground Objects/Category Object is always in the foreground, even before global particles. 4.9.5.0 CE 8388608
C4D_MouseIgnore Objects/Category Object cannot be selected with the mouse. 4.9.5.0 CE 16777216
C4D_IgnoreFoW Objects/Category Object is also completely visible within FoW, i.e. it is drawn even if it is actually covered by the fog of war. Useful for status indicators and control elements, for example. 4.9.6.0 CR 33554432

Examples

SetCategory(C4D_StaticBack, this());
Makes the object into a background object. This is used with castle parts so after completion other objects can be built in front.
GetPlrKnowledge(0, 0, 0, C4D_Structure);
Returns the first building type that the first player can build.
GetDefinition(0, C4D_Object);
Returns the id of the first loaded definition. Similar scripting is used in the research lab to list researchable object.
var obj;
while (obj=FindObject(0, 0, 0, 0, 0, 0, 0, 0, 0, obj))
if (GetCategory(obj) & C4D_Goal)
RemoveObject(obj);
				
Removing all game goals. Using bitwise AND you can check whether two objects correspond in at least one category.
if(GetCategory( 0, GetHomebaseMaterial()) & C4D_Knowledge) Message("Spieler 1 kann etwas kaufen, was er auch erforschen oder bauen könnte.");
Using bitwise AND you can check whether two objects correspond in at least one category.
for(var obj in FindObjects(Find_Category(C4D_Rule)))
RemoveObject(obj);
Removes all rules. :-)
SetCategory(GetCategory() | C4D_Background);
Move the calling object into the background.
SetCategory(GetCategory() | C4D_Parallax | C4D_Background);
Local()=50; Local(1)=100;
Moves the calling object into the background and adds horizontal parallaxity.

Changelog

Date Author Version Affecting Description
January 2002 Sven2 4.6.5.0 CP C4D_All, C4D_Goal Introduction C4D constant group.
February 2002 Günther 4.6.5.0 CP C4D_Living, C4D_Object, C4D_Knowledge Added constants.
April 2002 jwk 4.6.5.0 CP C4D_StaticBack, C4D_Structure, C4D_Vehicle, C4D_Rule Added constants.
June 2003 Sven2 4.9.1.0 GWE C4D_Background, C4D_Parallax Added constants.
15th September 2022 Funni 4.9.5.0 CE C4D_MouseSelect, C4D_Foreground, C4D_MouseIgnore, C4D_Magic, C4D_Environment Constants added and assigned to a version based on the release logs and e.g. Clonk Endeavour documentation. Possibly the constants were already implemented before. Note: The exact release version of CE is not clear, since the information, which comes from the Releaselogs, describes only the introduction of the constants as game constants, not as Script constants.
15th September 2022 Funni 4.9.6.0 CR C4D_IgnoreFoW Was at least added as a game constant in the NET2 engine, which was later renamed Clonk Rage.
Sven2, June 2003
Günther, February 2002
jwk, April 2002
DerTod, 15th September 2022
Funni, 15th September 2022