Overview

Exchange lets you turn any NPC into an item exchange shop: players hand in items (and/or Zen, WCoin, Ruud, Goblin Point) to receive other items or currencies. There are 3 shop types:

  • Type 1 - recipe list: each recipe is one row (items to hand in, reward, Exchange button). The items handed in are taken from the inventory.
  • Type 2 - drag and drop: uses the game's "Regular Combination" window. The player drags items into an 8 x 4 cell grid and presses the button. It uses the same recipe file as Type 1; only the interface differs.
  • Type 3 - combine / enhance: uses the "Elemental items refinement/combination" window: main item + sub item + materials, with a success rate, transferring Excellent options to the main item or raising its + level.

Every exchange is recorded in the exchange_log table (game database, created automatically by the GameServer) to compute limits on the number of times per day / in total, per character or per account. Rewards are given directly into the inventory: before taking anything, the server checks that there is enough room for all rewards; if not, it shows a dialog asking the player to free up space and takes nothing.

Requirements

  • Not tied to any key in Plugin.ini [Plugin]: the GameServer code does not check Feature() for Exchange. Turn it on / off with Enable in Data\Plugin\Exchange\ExchangeList.xml.
  • Client: a new Main.dll and the interface files in Data\Interface\GFx\: Exchange.ozg (Type 1), ExchangeMix.ozg (Type 2), ExchangeCombine.ozg (Type 3). No NPC model changes are needed.
  • To attach a shop to an NPC: in Data\Monster\MonsterSpawn.xml, set NpcFunction="<shop Name>" on the NPC's <Spawn> line. The order when clicking an NPC: NPC script, then the fixed functions (npc_talk_warehouse...), then Exchange, then the regular shop (ShopList.xml). If a name is both an Exchange shop and a shop in Data\Shops\ShopList.xml, Exchange is used and a warning is written to the log.
<Spawn Index="240" Distance="0" StartX="135" StartY="128" Dir="3" NpcFunction="exchange_jewel"/>

Folder structure

Path (inside Data\Plugin\Exchange\)Content
ExchangeList.xmlList of shops
Scripts\Exchange_Jewel.xml, Exchange_WCoin.xml, Exchange_Exc.xmlRecipes for Type 1 / Type 2 shops
Scripts\Exchange_Combine.xmlCombine list for Type 3 shops
ItemBags\Item bag files used by the <GiveBag> tag (same bag format as in Data\ItemBags)

In the XML files, do not write comments inside a tag.

ExchangeList.xml

Tag / attributeValueDefaultMeaning
<ExchangeList> Enable0 / 110 = turn off all shops.
<Exchange> Nameletters / digits / _, at most 32 characters, no ' characterempty (invalid)Shop name = the NPC's NpcFunction. Each shop has its own name; an empty name, one longer than 32 characters, or a duplicate causes the shop to be skipped and an error to be written to the log.
TitletextemptyWindow title.
Type1 / 2 / 31Shop type (see the Overview). Other values are skipped and an error is logged.
Filefile name in Scripts\emptyRecipe file (Type 1 / 2) or combine file (Type 3). A shop with no valid recipe is skipped.
Enable0 / 110 = turn off this shop only.
StartDate / EndDateYYYY-MM-DD HH:MM (server time)unlimited0000-00-00 00:00 = unlimited. Outside this time range, clicking the NPC shows the dialog "This function is not open yet." / "This function has ended." and the window does not open; within the range, the window shows "Active time: start - end".
<ExchangeList Enable="1">
	<Exchange Name="exchange_jewel" Title="Jewel Exchange" Type="1" File="Exchange_Jewel.xml" StartDate="0000-00-00 00:00" EndDate="0000-00-00 00:00" Enable="1" />
	<Exchange Name="exchange_exc" Title="Excellent Item Exchange" Type="2" File="Exchange_Exc.xml" StartDate="0000-00-00 00:00" EndDate="0000-00-00 00:00" Enable="1" />
	<Exchange Name="exchange_combine" Title="Item Enhancement" Type="3" File="Exchange_Combine.xml" StartDate="0000-00-00 00:00" EndDate="0000-00-00 00:00" Enable="1" />
</ExchangeList>

Recipe file (Type 1 and Type 2)

Root tag <ExchangeScript Name="...">: Name is the line of text at the top of the Type 2 window (Type 1 does not use it). Inside are the <Recipe> tags.

<Recipe>

AttributeValueDefaultMeaning
Idnumber >= 1, one Id per recipe0Recipe ID within the file; the exchange_log table counts by this Id.
NametextemptyText of the row (and the recipe name in the Type 2 window). A recipe that uses item groups (with no picture) must have a name that clearly states its content.
LimitDay>= 00Number of times per day. 0 = no limit.
LimitTotal>= 00Total number of times. 0 = no limit.
LimitByCharacter / AccountCharacterWhether the limit is counted per character or per account.
StartDate / EndDateYYYY-MM-DD HH:MMunlimitedOutside this time range the row is locked.
LevelMin>= 00Required total level (normal + master + majestic).
ResetMin>= 00Required number of resets.

<Need> - items that must be handed in

There can be several <Need> tags; each exchange requires all of them. Type 1 takes from the inventory; Type 2 takes from the cells in the window (only items that are a Need of some recipe can be dropped in; recipes without a Need are skipped in Type 2). Items with an expiry time are never taken.

AttributeValueDefaultMeaning
Cat, Indexnumber-1A specific item (for example Cat="14" Index="13" = Jewel of Bless). Index="-1" = every item of group Cat. Cat="-1" = every item.
CatMaxnumber-1Together with Cat forms the group range Cat..CatMax (for example Cat="0" CatMax="11" = all weapons and armor).
Level-1 or 0 - 15-1-1 = any level (then LevelMin / LevelMax are used), otherwise exactly this level.
LevelMin / LevelMax0 - 150 / 15Level range, used when Level="-1".
Countnumber >= 11Quantity (stackable items are counted one by one: 1 stack of 10 = 10).
ExcMinnumber >= 00Minimum number of Excellent option lines. 0 = any.
Luck / Skill-1 / 0 / 1-1-1 = any, 1 = must have, 0 = must not have.
Ancient-1 / 0 / 1-1-1 = any, 1 = must be an Ancient item, 0 = must not be.

<NeedCost> and <GiveCost>

<NeedCost> = currency deducted, <GiveCost> = currency added, for ONE exchange. Attributes: Zen, WCoin, Ruud, GoblinPoint (number >= 0, default 0).

<Give> - items received (into the inventory)

AttributeValueDefaultMeaning
Cat, Indexnumber-The item created.
Level0 - 150+ level.
Countnumber >= 11Quantity (stackable items: total quantity).
Skill / Luck0 / 10Has skill / luck.
Option0 - 70Additional option level.
Exc0 - 255 (bits: 1 + 2 + 4 + 8 + 16 + 32; 63 = all 6 lines)0Excellent lines (same as in item bags).
Ancient0 - 2550Ancient type.
Durationseconds >= 00Usage time of the item. 0 = unlimited.
Lock0 / 101 = the item is trade-locked (trade window, personal store, sending to the web); it can still be used as a material, dropped, sold, or stored in the warehouse.

<GiveBag>

FileName: a bag file in Data\Plugin\Exchange\ItemBags\ (the Data\ItemBags bag format; the <DropAllow> tag chooses which character class receives which part). The window shows the items the character can receive.

<ExchangeScript>
	<Recipe Id="3" Name="Jewel of Chaos + 1,000,000 Zen → Jewel of Life" LimitDay="5" LimitTotal="0" LimitBy="Character" StartDate="0000-00-00 00:00" EndDate="0000-00-00 00:00" LevelMin="0" ResetMin="0">
		<Need Cat="12" Index="15" Level="-1" Count="1" ExcMin="0" Luck="-1" Skill="-1" Ancient="-1" />
		<NeedCost Zen="1000000" WCoin="0" Ruud="0" GoblinPoint="0" />
		<Give Cat="14" Index="16" Level="0" Count="1" Skill="0" Luck="0" Option="0" Exc="0" Ancient="0" Duration="0" />
	</Recipe>
	<Recipe Id="2" Name="20 Jewel of Soul → 500 Ruud" LimitDay="0" LimitTotal="0" LimitBy="Character" StartDate="0000-00-00 00:00" EndDate="0000-00-00 00:00" LevelMin="0" ResetMin="0">
		<Need Cat="14" Index="14" Level="-1" Count="20" ExcMin="0" Luck="-1" Skill="-1" Ancient="-1" />
		<GiveCost Zen="0" WCoin="0" Ruud="500" GoblinPoint="0" />
	</Recipe>
</ExchangeScript>

Behavior specific to Type 2 (drag and drop)

When the button is pressed, the server checks the recipes from TOP to BOTTOM and performs each recipe AS MANY TIMES AS POSSIBLE according to the items in the cells (for example 90 stones in the cells and a recipe "30 stones → 1 item" gives 3 items). Leftover items stay in the cells; closing the window returns them. The top frame shows <ExchangeScript Name>, the middle frame shows the recipe names (gray; white with "Quantity: X" is the number of times it will be performed), and the bottom list is everything the player will receive.

Combine file (Type 3)

Root tag <ExchangeCombine Name="...">: Name is the guide page shown before a row is selected (scrollable when long). Text formatting commands: \n line break; [color=#ffaa00]text[/color] colored text; [center]text[/center] centered; [dot] the game's dot icon placed before a heading. Text with no color is shown in light gray (#ebebeb).

Each <Combine> tag is one row in the list on the left. The player selects a row, picks up an item from the inventory and clicks a cell to place it (right-click on a cell = take it back), then presses the Combine button. Closing the window (or leaving the game) returns all items to the inventory.

  • "Required items": at most 4 cells in a row: the main item (<Main>), the sub item (<Sub>, if any), then each <Material> in turn. At most 4 cells in total (with Sub, 2 materials; without Sub, 3).
  • "Optional items": 2 charm cells. Left = luck charm (<LuckCharm>), right = protection charm (<ProtectCharm>).
  • The "Result" cell shows the main item after success. Under each cell it shows "have / need"; the bottom of the window shows the fee and the success rate.

<Combine>

AttributeValueDefaultMeaning
Idnumber >= 1, unique in the file0Row ID. An Id <= 0 or a duplicate causes the row to be skipped and an error to be logged.
NametextemptyText of the row.
ActionExcTransfer / LevelUpExcTransferExcTransfer: randomly takes Lines Excellent lines of the sub item that the main item does NOT yet have and adds them to the main item (main A,B + sub A,C → main also gets C); refused when the sub item has no new lines or the main item already has all 6 lines. LevelUp: the + level of the main item increases by Levels (not above LevelMax). Other values are skipped and an error is logged.
Lines1 - 61(ExcTransfer) number of Excellent lines added.
Levels1 - 151(LevelUp) number of levels gained.
LevelMax0 - 1515(LevelUp) highest + level.
Rate0 - 100100Success rate (%).
FailMain0 / 101 = the main item is LOST on failure, 0 = it is kept.
FailSub0 / 111 = the sub item is lost on failure, 0 = it is kept. On success, the sub item is always consumed.

Materials, charms and the fee are always consumed whether the attempt succeeds or fails.

<Main>, <Sub>, <Material>, <LuckCharm>, <ProtectCharm>

The item-selection attributes are the same as <Need> above (Cat, Index, CatMax, Level, LevelMin, LevelMax, ExcMin, Luck, Skill, Ancient), plus:

Tag / attributeValueDefaultMeaning
<Sub> Same0 / 101 = the sub item must be of the SAME type as the main item. No <Sub> tag = the row has no sub item (only used for LevelUp).
Count (or Durability) of Material / charmnumber >= 11Quantity that cell requires (stackable items, for example 10 Jewel of Chaos); exactly that amount is consumed.
<LuckCharm> AddRate0 - 1000Additional success rate when the charm is in the cell (for example Talisman of Luck 14,53).
<ProtectCharm>--When the charm is in the cell and the attempt fails, the MAIN item is not lost (FailMain is ignored); the sub item is still lost if FailSub="1" (for example Talisman of Chaos Assembly 14,96).
Required0 / 101 = the charm cell must contain an item before Combine can be pressed. It is enough for one tag of the cell to set 1 for the cell to be mandatory.

Several <LuckCharm> (or <ProtectCharm>) tags = the cell accepts ANY of those items (each tag has its own Count / AddRate). Removing all tags of a charm cell = that cell is hidden.

<Cost> and <ExcLine>

  • <Cost Zen WCoin Ruud GoblinPoint/>: fee per attempt.
  • <ExcLine Line Rate Zen WCoin Ruud GoblinPoint/> (ExcTransfer only, optional, one tag per line count): Line 1 - 6 is the ordinal number of Excellent lines the main item will have after this attempt (if it currently has 2 lines and a 3rd line is added, Line="3"). Rate replaces the Rate of <Combine> (not declared = use the Rate of <Combine>). If any fee attribute (Zen/WCoin/Ruud/GoblinPoint) is present, that fee replaces <Cost>. Line counts without an <ExcLine> use the Rate and <Cost> of <Combine>. The AddRate of the luck charm is added on top.
<ExchangeCombine Name="[center][color=#ffaa00]You can combine by selecting the menu on the left.[/color][/center]">
	<Combine Id="1" Name="Enhance Excellent Item" Action="ExcTransfer" Lines="1" Rate="60" FailMain="1" FailSub="1">
		<Main Cat="0" CatMax="11" Index="-1" Level="-1" LevelMin="0" LevelMax="15" ExcMin="2" Luck="-1" Skill="-1" Ancient="-1" />
		<Sub Same="1" Cat="0" CatMax="11" Index="-1" Level="-1" LevelMin="0" LevelMax="15" ExcMin="2" Luck="-1" Skill="-1" Ancient="-1" />
		<LuckCharm Cat="14" Index="53" Level="-1" ExcMin="0" Luck="-1" Skill="-1" Ancient="-1" AddRate="10" Required="0" />
		<ProtectCharm Cat="14" Index="96" Level="-1" ExcMin="0" Luck="-1" Skill="-1" Ancient="-1" Required="0" />
		<Cost Zen="10000000" WCoin="0" Ruud="0" GoblinPoint="0" />
		<ExcLine Line="1" Rate="80" Zen="5000000" WCoin="0" Ruud="0" GoblinPoint="0" />
		<ExcLine Line="2" Rate="70" Zen="10000000" WCoin="0" Ruud="0" GoblinPoint="0" />
	</Combine>
</ExchangeCombine>

Messages (Lang)

The window text comes from Data\Lang, group Type="51" named "Exchange" (ID 1 - 50). Some commonly seen IDs:

  • ID 1 - 2 "Exchange", ID 3 "Fee: %s", ID 4 "Today %d / %d", ID 5 "Used %d / %d", ID 6 "Starts %s", ID 7 "Ended", ID 8 "Requires level %d", ID 9 "Requires reset %d", ID 10 "Limit reached", ID 11 "Not enough items".
  • ID 14 "[Exchange] %s - done.", ID 16 "You are too far from the NPC.", ID 20 "[Exchange] %d exchange(s) done."
  • Type 3: ID 24 - 32 (refusal reasons), ID 33 - 39 (window labels), ID 40 "[Combine] %s - success!", ID 41 "[Combine] %s - failed.", ID 46 - 50 (cell tooltips).
  • ID 42 "This function is not open yet.", ID 43 "This function has ended.", ID 44 "Active time: %s - %s".
  • The dialog for no inventory room uses Data\Lang group 10, ID 37 "Not enough room in the inventory. Please rearrange your inventory."
[TO VERIFY: Lang group 51 ID 13 "Gremory Case is full..." is still in the language file, but the current code gives rewards directly into the inventory, so this ID may no longer be used]

Reloading the configuration

Press the Reload plugin button on the GameServer panel: it reloads ExchangeList.xml and every file in Scripts\. Configuration errors (shop name, Type, Action, empty recipe...) are written to the GameServer log with the prefix [Exchange].