ChangeDef

Category: Objects / Status
Since engine version: 4.6.5.0 CP

Description

Assigns a new definition to an object.

Syntax

bool ChangeDef (id idNewDef, object pObj);

Parameters

idNewDef:
id of the new definition
pObj:
Object to change. Can be 0 in local calls.

Remarks

ChangeDef does not affect object local variables. The values of named local variables are transferred to local variables of the same name in the target definition.
Warning: if an object applies ChangeDef to itself, the executed object script will no longer match the object definition after the call. Because of this, following a ChangeDef call you should neither call any local function (use this()->function(...) instead) nor access any local variables (even if a variable of the same name exists in the new definition).

Example

ChangeDef(MONS, GetCursor(0));
Changes the selected clonk of the first player into a monster.
See also: GetID
Sven2, November 2001