GetDefaultByType
Jump to navigation
Jump to search
Note: This feature is for ZScript only. |
static readonly<Actor> GetDefaultByType(class<Actor> type)
Usage
Use this to find the default property of a class, rather than those of any particular actor instance.
Note that this is sensitive to whether the caller has a backpack, so it is not necessary to specifically check for a backpack and backpackmaxamount - checking maxamount will cover both situations.
Parameters
- class<Actor> type
- The name of an Actor-based class whose default values should be obtained.
Return values
This function is fairly unique in that it returns a readonly pointer to an Actor instance (as opposed to, for example, casting the return value of Spawn()).
Examples
class Example
{
static void getImpRadius()
{
class<Actor> cls = "DoomImp";
int impRadius = GetDefaultByType(cls).Radius;
console.printf("Imp default radius is: %d", impRadius);
}
}
Custom property defaults can also be retrieved by using the name of the variable that the property refers to. This class retrieves the custom DropCategory property of the class that represents a treasure dropped by a monster:
class MonsterDrop : Inventory
{
String myCategory;
property DropCategory: myCategory;
Default
{
MonsterDrop.DropCategory "Jewellery";
}
}
class Example
{
static void getMonsterDropCategory(String dropClass)
{
class<Actor> cls = dropClass;
String dropCategory = MonsterDrop(GetDefaultByType(cls)).myCategory;
console.printf("Drop category for %s is: %d", dropClass, dropCategory);
}
}