Osiris/Shared/DB DialogMoneyTransfer

From Divinity Engine Wiki
Revision as of 09:39, 2 February 2018 by LarIlya (talk | contribs)
(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 (= transfer flag) 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:
    • If the character on which the transfer flag is set is a player, the money will go to the NPC matching DB_DialogNPCs(_, _, _TargetDBIndex) for the current dialog. I.e., if _TargetDBIndex is 1, it will transfer the money to the first NPC in the dialog in this case.
    • If the character on which the transfer flag is set is an NPC, the money will go to the player matching DB_DialogPlayers(_, _, _TargetDBIndex) for the current dialog. I.e., if _TargetDBIndex is 1, it will transfer the money to the first player in the dialog in this case.
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
    • DB_DialogMoneyTransfer(1,"FTJ_GhettoBoss",50);
      • When the GEN_CheckMagicPocketGold script var is checked in the FTJ_GhettoBoss dialog, this will check whether speaker 2 (default, because unspecified; corresponds to the player in this dialog) has at least 50 gold.
      • When the character flag GEN_TransferNPCPayment is set on the player in that dialog, up to 50 gold will be transferred from the player to the first NPC in that dialog (_TargetDBIndex defaults to 1). I.e., it will transfer up to 50 gold from the player to Griff. If it is set on Griff, the transfer will go in the other direction.
    • DB_DialogMoneyTransfer(2,"ARX_Neighborhood_Street_TraderBaker",1000,3,2);
      • Here we can check using the GEN_CheckMagicPocketGold_2 script var whether speaker 3 (the player, in this dialog) has at least 1000 gold.
      • By setting GEN_TransferNPCPayment_2 on the player in that dialog, we can transfer up to thousand gold to the second NPC in this dialog. Setting this flag on an NPC will not do anything, because that would result in an attempt to transfer this money to a second player in this dialog, which does not exist.
See Also
  • /