Quick map

File / folderPurposeProgram that reads itReload
Data\ItemBags\ID - Loại - Tên.xmlThe contents of one bag: which items, at what rates. One file per bag; the current package has about 620 files, divided by the type written in the file name: Item, Monster, Event, Mix, World, Zone.GameServer.reload item or the Reload items / Lua button on the GameServer window
Data\ItemBags\### Item Bags System Description ###.txtGuide to the bag file format (read it before creating a new bag).Read only-
Data\Scripts\Item\ItemBagScript.luaThe list of "when each bag is opened": each ItemBag_Xxx(ID, ...) line attaches a bag ID to a flow. A bag with no line here is never used.GameServerSame as above

Some other configurations call bags by ID (the list of files in the Data folder of the current package that have attributes referencing a bag ID):

  • Data\Monster\MonsterSpawnEvent.xml (ItemBag="ID")
  • Data\Shops\MossMerchantSection.xml (ItemBag)
  • Data\Quest\QuestEvolutionItemReward.xml (ItemBagID)
  • Data\Plugin\HideAndSeek.xml (ItemBagID)
  • Data\Event\Event.ini (reward bags of some events)
  • Data\Event\BlessingBox.xml, PlayTime.xml (ItemBagID)
  • Data\Event\Dungeon\EventDungeonLevel.xml (ItemBag, BossItemBag, RandomItemBag)
  • Data\Event\ArkaWar\ArkaWar.xml, Kanturu\Kanturu.xml, Raklion\Raklion_Monsters.xml, TormentedSquare\TormentedSquare_Battle.xml (ItemBag)
  • Data\Event\Scramble\Scramble.xml (Reward), Doppelganger\DoppelgangerLevel.xml (Bag), LastManStanding\LastManStanding.xml (LooserEventBagID)
  • Data\Event\ImperialFortress\ImperialGuardian.xml (AdditionalRewardBagID), ImperialGuardian_Reward_Info.xml (ItemBagID)

How it works

The item bag system has two parts:

  • Bag contents: each bag is an XML file in Data\ItemBags, named in the form ID - Loại - Tên.xml (for example 0300 - Monster - Gorgon (18).xml). GameServer relies only on the ID number at the start of the file name; the "Type" and "Name" are only for human readers. For the content format, see the guide file Data\ItemBags\### Item Bags System Description ###.txt.
  • When a bag is opened: the file Data\Scripts\Item\ItemBagScript.lua. Each ItemBag_Xxx(ID, ...) line attaches a bag ID to a flow (dropping a box on the ground, opening a box in the inventory, monster kills, by map, item combination, called by ID...). A bag file with no line in ItemBagScript.lua is never used.

Other configurations also call bags by ID (for example the attribute ItemBag="3044" in MonsterSpawnEvent.xml, EventDungeonLevel.xml, Event.ini...; the full list is in the table above).

This system does not depend on Plugin.ini. ItemBagScript.lua runs in a separate Lua machine that has only the ItemBag_Xxx functions (no LuaAPI functions), and it runs once each time it is loaded, not each time a bag is opened.

Reload

GameServer reads ItemBagScript.lua at startup and when you click Reload items / Lua on the control window (this button reloads both the item data and the drop data; the matching command is .reload item). Errors:

  • Syntax error in the file: GameServer writes the log [ ITEM BAG ] Scripts/Item/ItemBagScript.lua: ... and no bag is loaded.
  • Run-time error (for example the ID is not a number >= 0, or there are extra parameters): execution stops at the faulty line; the lines before the faulty line are still loaded, the lines after it are not. The log states the function and the ID.
  • Two files with the same ID: the first file is used and an error is reported on the GameServer window.

Syntax of one line

ItemBag_Drop(1, 14, 11, 1, { ZenRate = 1000, ZenMin = 500000, ZenMax = 500000, ReqLevel = 1 })
--           ^ID  ^keys 1,2,3 (see the flow table)     ^options table { } (can be omitted)

The first parameter is the bag file ID (a number >= 0). The following integers are the flow's "keys" (in the order given in the table below); the table parameter { } is optional and can be placed in any position. A key left empty takes the flow's default value. Extra keys or a wrong type cause an error.

Flows

FunctionKeys (after the ID)When the bag is opened
ItemBag_DropGroup, Number, Level (-1 = any level)An item (box) is dropped on the ground and then drops its items.
ItemBag_DropGroupGroup, Number, LevelAs above but all items of one random Group are dropped (the bag uses the flat-list format, without <DropSection>).
ItemBag_InventoryGroup, Number, LevelRight-click an item in the inventory (open a box); the items go into the inventory.
ItemBag_MonsterMonster, LevelMin, LevelMaxKilling a monster drops items. Monster = -1: called by ID only (for example from MonsterSpawnEvent.xml).
ItemBag_MonsterGroupMonster, LevelMin, LevelMaxAs above, dropping all items of one random Group.
ItemBag_MonsterAllMonsterEvery player within 20 cells of the monster receives it once.
ItemBag_MonsterRateMonster, Map, RateThe monster drops at a rate of n/10000; Map = -1 = every map.
ItemBag_WorldMap, Rate, MonsterLevelMinEvery monster in the map can drop it (rate n/10000).
ItemBag_World2Map, Rate1, Rate2Two rolls: Rate1 succeeds, then Rate2 (n/10000).
ItemBag_ZoneZone, RateBy the gate the player is standing in (ArkaWar).
ItemBag_EventMonsterEvent, Floor, RateEvent monsters (by event code / floor).
ItemBag_MixMixID, IndexRewards of the item combination machine (Chaos Machine).
ItemBag_Event(none)Only called by ID from another configuration (events, NPCs, rewards; the configuration states ItemBag="ID").

Options table { }

KeyDefaultMeaning
DropMin, DropMax1, 1The number of item rolls each time the bag is opened. Not used for group-format bags (with <DropSection>) in the Item / Inventory / Monster / MonsterRate / EventMonster flows: the number of items follows Count in <Drop>.
ZenRate0The probability of Zen instead of an item, n/10000.
ZenMin, ZenMax-The Zen range when ZenRate succeeds.
ReqLevel0Minimum level to open (Item / Inventory flows).
FireWork-1 = fire fireworks when opened.
CreateTypeper bag fileItemBag_Event only: how items are granted. 0 on the ground, 1 inventory, 2 Chaos Box, 3 event reward (on the ground), 4 Gremory Case. If empty: takes BagUseType from the bag file (0 ground, 1 inventory, 2 Gremory); if absent, 0.
SubId-ItemBag_Event with Gremory Case only: extra data written into the item.

Examples

-- Box dropped on the ground (Luck Box 14,11,0)
ItemBag_Drop(0, 14, 11, 0)

-- Box opened in the inventory, any level, with a chance of Zen
ItemBag_Inventory(66, 13, 210, 0, { ZenRate = 5000, ZenMin = 100000, ZenMax = 100000 })

-- Box that drops 3 to 5 times each time it is opened
ItemBag_Drop(20, 14, 157, 0, { DropMin = 3, DropMax = 5 })

-- Bag called by ID from another configuration
ItemBag_Event(3044)
To add a new bag: (1) create the file ID - Loại - Tên.xml in Data\ItemBags following the format in the guide file; (2) add one ItemBag_Xxx line with exactly that ID; (3) click Reload items / Lua. Choose an unused ID (IDs 0000 - 2999 are the existing group-format bags (with <DropSection>); IDs 3000 and above are flat-list format bags).
ItemBagScript.lua runs in a restricted environment like the other Lua machines (no debug table, os.execute, os.remove, os.rename, os.tmpname, os.exit, io.popen, package.loadlib; load / dofile... accept only source code as text) and has a 10 second time limit for loading the file (the file runs only once at startup / reload): an infinite loop is stopped and logged instead of hanging the server.
Editing long bag files by hand is error-prone. Back up the file before editing. A single syntax error in ItemBagScript.lua prevents every bag from loading, including the event reward bags.