For those who want to try pickup items (as seen in new Combo mode),
you can download http://files.maniaplanet.com/tools/Samp ... pItems.zip.
Unzip the content of this zip archive into your ManiaPlanet userdir (typically <userdocs>/ManiaPlanet/ , so that, in that case you have the <userdocs>/ManiaPlanet/Items/SMCommon/Pickups folder).
After extraction, restart Maniaplanet.
New items should appear in map editor, object mode (F4).
WARNING: The ManiaScript item API changed drastically. The following code doesn't work anymore with the current version of the game.
To use items in a game mode you have to create a TitlePack with a custom mode script.
First you must load the items you want to use at the beginning of your script.
Code: Select all
ItemList_Begin();
declare ArmorId = ItemList_Add("SMCommon\\Pickups\\Armor.Item.gbx");
declare RocketId = ItemList_Add("SMCommon\\Pickups\\Rocket.Item.gbx");
declare LaserId = ItemList_Add("SMCommon\\Pickups\\Laser.Item.gbx");
declare NucleusId = ItemList_Add("SMCommon\\Pickups\\Nucleus.Item.gbx");
declare ArrowId = ItemList_Add("SMCommon\\Pickups\\Arrow.Item.gbx");
ItemList_End();
You can now create an item:
Code: Select all
declare ItemArmor = CreateItem(ArmorId);
If the map creator puts items on the map, and you want to spawn them in your mode (as in Combo):
Code: Select all
foreach (ItemAnchor in ItemAnchors) {
switch (ItemAnchor.ItemName) {
case "SMCommon\\Pickups\\Armor.Item.gbx": {
AttachItemToAnchor(ItemArmor, ItemAnchor);
}
}
}
- The item you want to spawn in the map
- The anchor used to spawn the item
With this you have one item in your map at the position designed by the map maker.
Now you have to manage what happen when a player pick up an item:
Code: Select all
foreach (Event in PendingEvents) {
if (Event.Type == CSmModeEvent::EType::OnPlayerTouchesItem) {
if (Event.Player != Null && Event.Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawned) {
AttachItemToPlayer(Event.Item, Event.Player);
// Do something depending on the item
// ...
PassOn(Event);
}
}
}
- The item to pick up
- The player who'll receive the item
A short list of item related functions:
Code: Select all
// ----------------------------------------------------- //
/** Create an item
*
* @param ModelId The model if of the item to create
*
* @return The created item
*/
CSmItem CreateItem(Ident ModelId)
// ----------------------------------------------------- //
/** Destroy an item
*
* @param Item The item to destroy
*/
Void DestroyItem(CSmItem Item)
// ----------------------------------------------------- //
/// Destroy all the created items
DestroyAllItems()
Code: Select all
// ----------------------------------------------------- //
/** Attach an item to an anchor
*
* @param Item The item to attach
* @param ItemAnchor The anchor where to attach the item
*/
Void AttachItemToAnchor(CSmItem Item, CSmItemAnchor ItemAnchor)
// ----------------------------------------------------- //
/** Attach an item to a player
*
* @param Item The item to attach
* @param Player The player where to attach the item
*/
Void AttachItemToPlayer(CSmItem Item, CSmPlayer Player)
Code: Select all
// ----------------------------------------------------- //
/** Detach an item, it will be dropped at the position of the player/anchor carrying the item
*
* @param Item The item to drop
*/
Void DetachItem(CSmItem Item)
// ----------------------------------------------------- //
/** Detach an item and drop it at a given position
*
* @param Item The item to drop
* @param Position The position of the item
* @param Yaw The orientation of the item
*/
Void DetachItemAndSetPosition(CSmItem Item, Vec3 Position, Real Yaw)
Code: Select all
// ----------------------------------------------------- //
/** Unspawn an item
*
* @param Item The item to unspawn
*/
Void UnspawnItem(CSmItem Item)
Code: Select all
// ----------------------------------------------------- //
/** Find the player carrying a specific item
*
* @param Item The item to search
*
* @return The player carrying the given item, Null if the item is not carried by a player
*/
CSmPlayer GetPlayerCarryingItem(CSmItem Item)
// ----------------------------------------------------- //
/** Find the anchor carrying a specific item
*
* @param Item The item to search
*
* @return The anchor carrying the given item, Null if the item is not carried by an anchor
*/
CSmBlock GetBlockCarryingItem(CSmItem Item)