Merchant

From Dragon Age Toolset Wiki
Revision as of 23:39, 28 June 2009 by BryanDerksen (Talk | contribs) (import from extranet)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

A merchant resource keeps track of an inventory of items that can be bought and sold, along with various properties to determine the details of those deals.

Triggering in dialog

The use of a merchant's store is triggered by a script, specifically by the "OpenStore(object oStore)" function. This function is usually called by a script triggered in a conversation with an NPC merchant.

To simplify matters you could write a generic "store opening" script as follows:

object oStore = GetObjectByTag("store_" + GetTag(oConversationOwner));
if(IsObjectValid(oStore))
      OpenStore(oStore);
else
      Log_Trace(LOG_CHANNEL_SYSTEMS, GetCurrentScriptName(), "INVALID STORE OBJECT");

You would then be able to reuse this script for all merchants in your game by tagging each merchant object with the same tag as the creature you're conversing with to open the store and adding the "store_" prefix to the merchant's tag. So for example if you have a character in your game whose tag is "fishmonger_alice", you could set the above script to run as an "action" script in her dialog tree and when that node is reached it'll open the store with the tag "store_fishmonger_alice", and if you used the same action script in a dialog attached to "blacksmith_steve" it would open the store with the tag "store_blacksmith_steve".

A script with this generic approach can be triggered by setting the plot flag "GEN_OPEN_STORE" in the "gen00pt_generic_actions" plot. This plot is a wrapper for commonly used generic conversation script code like this.

Variables

MERCHANT_COUNTER_1 to 3 int

Properties

General
Comments General information about this merchant
Name Name of this merchant as seen within the game.
NameRequiresReTranslation A flag used in game development during localization
Resource Name A unique string identifier the toolset and the game both use to refer to this resource.
Script Event script assigned to the resource
Tag A non-unique string identifier used mostly by scripts and other resources to refer to this resource.
Variable 2da Allows selecting a variable table. Only the values in the table can be set and retrieved by scripting.
Variables Displays the table selected in the "Variable 2da" field. Allows setting intial values for parameters.
Inventory
Gold The amount of money the merchant has that can be used to buy items from the player. A value of -1 represents infinite gold.
Inventory a list of the items the merchant has for sale.
Restricted Items A list of types of items that the merchant can be set to refuse to buy, or alternately can be set to buy exclusively. For example, you could set a pacifistic merchant to refuses to deal in weapons or armor, or set a hunter to only buy arrows and other such items that are useful to him.
Pricing
Buy Mark Down a percentage value dictating how much the price of items the merchants buy from the player is scaled down from their default price
Max Buy Price the maximum amount of gold the merchant will spend to buy a single item from the player. A value of -1 represents infinite gold.
Sell Mark Up percentage value of how much the price of items sold by the merchant to the player is scaled up from their default price.