Difference between revisions of "CreateObject"

From Dragon Age Toolset Wiki
Jump to: navigation, search
(Remarks)
(Examples)
Line 52: Line 52:
 
== Examples ==
 
== Examples ==
 
<!-- This section contains examples transcluded from the snippet library. -->
 
<!-- This section contains examples transcluded from the snippet library. -->
To Create a creature:<br />
+
To create a creature:<br />
 
CreateObject(OBJECT_TYPE_CREATURE, R"<name>.utc", <location>);<br /><br />
 
CreateObject(OBJECT_TYPE_CREATURE, R"<name>.utc", <location>);<br /><br />
 
<name> = Resource Name<br />
 
<name> = Resource Name<br />

Revision as of 08:59, 13 November 2009

Create an object in the specified location. Will attempt to use a corresponding pool if one exists.

object CreateObject(
int nObjectType,
resource rTemplate,
location lLoc,
string sOverrideScript = "",
int bSpawnActive = TRUE,
int bNoPermDeath = FALSE
);
Parameters:
nObjectType
The object type (placeable, creature, etc)
rTemplate
The template to use
lLoc
Location of the object
sOverrideScript
Script assigned to the object. If empty, the engine will use the template script
bSpawnActive
Whether or not this object is enabled at spawn time
bNoPermDeath
Set to TRUE to avoid destroying the object permanently (only valid for pool creatures)
Returns:

The new object, OBJECT_INVALID on failure

Source:

script.ldf


Remarks

Note that dynamic creation of objects in the engine is subject to a host of limitations, reason being attempts to cut down 'unaccounted' memory usage.

Try avoiding CreateObject whenever possible.


These objects can be created with CreateObject:
- Creature
- Placeable

These objects can not be created with CreateObject:
- Merchant

Examples

To create a creature:
CreateObject(OBJECT_TYPE_CREATURE, R"<name>.utc", <location>);

<name> = Resource Name
<location> = Location. See GetLocation for an example.

See also

CreatePool, DestroyObject, OBJECT_TYPE*