Osiris/Shared/DB DialogMoneyTransfer

From Divinity Engine Wiki
Revision as of 15:56, 8 August 2017 by Tinkerer (talk | contribs) (Osiris Helper Mod APIs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Full Definition(s)
  • DB_DialogMoneyTransfer((INTEGER)_MoneyVarIndex,(STRING)_DialogName,(INTEGER)_Amount)
  • DB_DialogMoneyTransfer((INTEGER)_MoneyVarIndex,(STRING)_DialogName,(INTEGER)_Amount,(INTEGER)_CheckSpeakerIndex)
  • DB_DialogMoneyTransfer((INTEGER)_MoneyVarIndex,(STRING)_DialogName,(INTEGER)_Amount,(INTEGER)_CheckSpeakerIndex,(INTEGER)_TargetDBIndex)
Description

This functionality can be used in dialogs both to check whether a participant has a certain amount of gold, and to transfer this gold from one participant to another:

  • _MoneyVarIndex: can be 1-5. Determines which of the GEN_CheckMagicPocketGold/_2/../_5 dialog variables gets set, and hence whether you can use the GEN_CheckPocketGold/_2/../_5 scrip var to check whether a dialog participant (see _CheckSpeakerIndex) has at least the specified amount of money.
  • _DialogName: the name of the dialog that this DB should influence.
  • _Amount: the amount of money that should be checked and/or transferred.
  • _CheckSpeakerIndex: This sets the speaker dialog variable used by GEN_CheckPocketGold/.. and hence must refer to a speaker index in the dialog. It determines which speaker will be checked for having a sufficient amount of gold. If unspecified, it defaults to 2 (the player in most dialogs that have two speakers).
  • _TargetDBIndex: This only affects money transfers. Money transfers can be performed by setting the GEN_TransferNPCPayment/_2/../_5 character flag on either a player or an NPC in the dialog (independent of what _CheckSpeakerIndex is). It will then transfer up to _Amount gold (depending on how much gold this character had) from that flagged character to another character. This other character is determined by _TargetDBIndex as follows, with this value defaulting to 1 if unspecified:
Notes
  • The reason for the discrepancy between how _CheckSpeakerIndex and _TargetDBIndex are interpreted, is due to the fact that Osiris only supports requesting NPC and player speakers separately. Additionally, this also allows using a single DB_DialogMoneyTransfer() definition to transfer money back and forth between a player and an NPC (if you only need to check in one direction whether the source has in fact enough money).
  • If you wish to make sure a participant has enough gold before transferring, always perform the verification (check GEN_CheckMagicPocketGold/..) and the transfer (setting GEN_TransferNPCPayment/..) on the same node. Otherwise, the participant could lose gold in between the check and the transfer.
  • Examples
See Also
  • /