return NULL;
}
random_items_is_spawning = true;
- entity new_item = spawn();
- new_item.classname = strzone(new_classname);
- new_item.spawnfunc_checked = true;
- Item_Initialize(new_item, new_classname);
+ entity new_item = Item_Create(strzone(new_classname), item.origin);
random_items_is_spawning = false;
- if (wasfreed(new_item))
- {
- return NULL;
- }
- setorigin(new_item, item.origin);
return new_item;
}
.bool m_isloot; ///< Holds whether item is loot.
+entity Item_Create(string class_name, vector position)
+{
+ entity item = spawn();
+ item.classname = class_name;
+ item.spawnfunc_checked = true;
+ Item_Initialize(item, class_name);
+ if (wasfreed(item))
+ {
+ return NULL;
+ }
+ setorigin(item, position);
+ return item;
+}
+
void Item_Initialize(entity item, string class_name)
{
switch (class_name)
#pragma once
+/// \brief Creates a new item.
+/// \param[in] class_name Class name of the item.
+/// \param[in] position Position of the item.
+/// \return Item on success, NULL otherwise.
+entity Item_Create(string class_name, vector position);
+
/// \brief Initializes the item according to classname.
/// \param[in,out] item Item to initialize.
/// \param[in] class_name Class name to use.
/// \return No return.
+/// \nore This function is useful if you want to set some item properties before
+/// initialization.
void Item_Initialize(entity item, string class_name);
/// \brief Creates a loot item.