[This page is outdated! See instead the wiki page: https://wiki.project-tamriel.com/wiki/Banking_Framework]
Introduction
Tamriel Data contains scripts, activators, and dialogue for a banking framework.
Its features are:
- Storing/retrieving money to and from a bank account,
- Taking out loans from a bank,
- Accounts shared across all branches of a single bank,
- Multiple banks with multiple branches each.
While inherently more useful with a gold weight mod, banking serves as another world-building tool as well.
For modders, there are roughly two use cases: either you need to add a new branch of an existing bank or you need to add a new bank to the banking framework in Tamriel Data.
Adding a new bank branch
Bank dialogue and scripts are filtered according to two different values:
- The NPC has the banker class (T_Glb_Banker),
- the NPC is in a cell with a bank activator.
For example, to create a new bank branch with banking services for the Briricca Private bank, a banker class NPC needs to be in a cell with the T_ScBank_RingBriricca ("Ring of Banking (Briricca)") clothing item.
Example: Old Ebonheart, Briricca Bank
Adding a new bank
Banks consist of a collection of scripts and globals in Tamriel_Data. Dialogue and the script calls are implemented in dialogue replies,
Except for an addition to Greeting 7, everything that needs to be added to or edited is held in Tamriel_Data.esm.
Globals
The most important global is T_Glob_Bank_All_CurrentBank, which controls what bank is currently addressed by the banking scripts.
As it is defined in Tamriel_Data and more than one master file need to use it, it is critically important that no duplicate bank numbers or shorthands are used.
List of Values, Shorthands, and Banks |
0 |
|
None |
1 |
Bri |
Briricca private bank (Tamriel province mods) |
2 |
Pet |
Reserved Dummy - Petrocca private bank (Morrowind Rebirth) |
3 |
Hla |
Hlaalu council bank (Tamriel Rebuilt) |
Three more globals hold the amount for savings and loans and the date the loan is due. They need to be duplicated with the new bank’s shorthand. For the Briricca private bank, these are:
- T_Glob_Bank_Bri_AcctAmount (Long)
- T_Glob_Bank_Bri_LoanAmount (Short)
- T_Glob_Bank_Bri_LoanDate (Short)
- T_Glob_Bank_Bri_LoanFail (Short)
New Scripts
Three scripts are bank-specific and need to be duplicated with the new bank’s shorthand and edited to use the new bank’s globals:
begin T_ScBank_Bri_CurrentBank
;Briricca Bank - Local Script to Set Global
;-------------
;- Local script placed on a hidden object in
; all Briricca bank cells.
;- Changes global T_Glob_Bank_All_CurrentBank
; to 1 for deposit and withdraw scripts.
;-------------
;Last modified by Texafornian on 2018-02-19
;global T_Glob_Bank_All_CurrentBank
;Add more bank-specific globals as necessary
if ( MenuMode )
Return
endif
if ( T_Glob_Bank_All_CurrentBank != 1 )
set T_Glob_Bank_All_CurrentBank to 1
return
endif
end
begin T_ScBank_Bri_LoanCheck
;Briricca Bank - Loan Check Script
;-------------
;- Global script that runs while a Briricca
; Bank loan is outstanding.
;- Checks whether one month has passed. If
; so, loan failure script starts.
;-------------
;Last modified by Texafornian on 2018-02-21
short doMath
;global T_Glob_Bank_Bri_LoanDate
if ( MenuMode )
return
endif
;Check whether 7 days have passed since receiving the loan
set doMath to ( DaysPassed - T_Glob_Bank_Bri_LoanDate )
if ( doMath < 8 )
Return
endif
end
begin T_ScBank_Bri_LoanFail
;Briricca Bank - Loan Failure Script
;-------------
;- Runs once after 7 days pass on loan.
;- If player has deposit account, then
; funds are removed to pay off loan.
;- If no account or not enough funds then
; player receives bounty for remaining debt.
;-------------
;Last modified on 200804
float crimeHold
;global T_Glob_Bank_Bri_AcctAmount
;global T_Glob_Bank_Bri_LoanAmount
;global T_Glob_Bank_Bri_LoanFail
;If 7 days have passed then tack on additional 10 percent of outstanding loan
set T_Glob_Bank_Bri_LoanAmount to ( T_Glob_Bank_Bri_LoanAmount + ( T_Glob_Bank_Bri_LoanAmount * 0.1 ) )
;If player has deposit account then reduce the loan amount by those funds
if ( T_Glob_Bank_Bri_AcctAmount > 0 )
if ( T_Glob_Bank_Bri_LoanAmount < T_Glob_Bank_Bri_AcctAmount )
set T_Glob_Bank_Bri_AcctAmount to ( T_Glob_Bank_Bri_AcctAmount - T_Glob_Bank_Bri_LoanAmount )
set T_Glob_Bank_Bri_LoanAmount to 0
MessageBox "You are late on your payments and Briricca Bank has called the loan. Your debt has been paid out of your deposit account."
elseif ( T_Glob_Bank_Bri_LoanAmount == T_Glob_Bank_Bri_AcctAmount )
set T_Glob_Bank_Bri_AcctAmount to 0
set T_Glob_Bank_Bri_LoanAmount to 0
MessageBox "You are late on your payments and Briricca Bank has called the loan. Your debt has been paid out of your deposit account, which is now closed."
elseif ( T_Glob_Bank_Bri_LoanAmount > T_Glob_Bank_Bri_AcctAmount )
set T_Glob_Bank_Bri_LoanAmount to ( T_Glob_Bank_Bri_LoanAmount - T_Glob_Bank_Bri_AcctAmount )
set T_Glob_Bank_Bri_AcctAmount to 0
MessageBox "You are late on your loan repayments to Briricca Bank. Your deposit account has been closed and a bounty has been placed on your head for the remainder of the debt."
endif
elseif ( T_Glob_Bank_Bri_AcctAmount <= 0 )
MessageBox "You are late on your loan repayments to Briricca Bank. A bounty has been placed on your head for the remainder of the debt."
endif
;Increase player bounty by remaining outstanding loan amount
set crimeHold to ( GetPCCrimeLevel + T_Glob_Bank_Bri_LoanAmount )
if ( crimeHold > 0 )
if ( crimeHold > 5000 ) ;Make sure that player is not given a death warrant
set crimeHold to 4500
endif
SetPCCrimeLevel crimeHold
endif
set T_Glob_Bank_Bri_LoanAmount to 0
set T_Glob_Bank_Bri_LoanFail to 1
StopScript T_ScBank_Bri_LoanFail
Return
end
Edited Scripts
Five scripts are bank-agnostic, but need to be edited to handle the new bank’s shorthand and globals. In order to properly showcase the necessary edits, the Petrocca private bank will be added:
begin T_ScBank_All_Deposit
;All Banks - Balances Script
;-------------
;- This script runs from dialogue results.
;- T_Glob_Bank_All_CurrentBank is set via local
; script and is used to report relevant balances.
;- Add more elseif conditions for new banks as they are
; added by copying and editing existing conditions.
;-------------
;Last modified on 200804
short doMath
;vanilla global DaysPassed
;Tamriel_Data global T_Glob_Bank_All_CurrentBank
;Tamriel_Data global T_Glob_Bank_Bri_AcctAmount
;Tamriel_Data global T_Glob_Bank_Bri_LoanAmount
;Tamriel_Data global T_Glob_Bank_Bri_LoanDate
;Tamriel_Data global T_Glob_Bank_Pet_AcctAmount
;Tamriel_Data global T_Glob_Bank_Pet_LoanAmount
;Tamriel_Data global T_Glob_Bank_Pet_LoanDate
;--------------------------------
;ADD NEW BANKS TO THE BLOCK BELOW
;--------------------------------
if ( T_Glob_Bank_All_CurrentBank == 1 ) ;Briricca Bank
if ( T_Glob_Bank_Bri_AcctAmount > 0 )
MessageBox "[Your account balance is %G gold]" T_Glob_Bank_Bri_AcctAmount
endif
if ( T_Glob_Bank_Bri_LoanAmount > 0 )
set doMath to ( DaysPassed - T_Glob_Bank_Bri_LoanDate )
set doMath to ( 10 - doMath )
MessageBox "[Your outstanding loan balance is %G gold]" T_Glob_Bank_Bri_LoanAmount
MessageBox "[You have %G day(s) to pay off your outstanding loan balance]" doMath
endif
elseif ( T_Glob_Bank_All_CurrentBank == 2 ) ;Petrocca Bank
if ( T_Glob_Bank_Pet_AcctAmount > 0 )
MessageBox "[Your account balance is %G gold]" T_Glob_Bank_Pet_AcctAmount
endif
if ( T_Glob_Bank_Pet_LoanAmount > 0 )
set doMath to ( DaysPassed - T_Glob_Bank_Pet_LoanDate )
set doMath to ( 10 - doMath )
MessageBox "[Your outstanding loan balance is %G gold]" T_Glob_Bank_Pet_LoanAmount
MessageBox "[You have %G day(s) to pay off your outstanding loan balance]" doMath
endif
else
MessageBox "T_ScBank_All_Balances: Global T_Glob_Bank_All_CurrentBank check failed."
endif
;--------------------------------
;ADD NEW BANKS TO THE BLOCK ABOVE
;--------------------------------
StopScript T_ScBank_All_Balances
Return
endy/pre>
begin T_ScBank_All_Deposit
;All Banks - Deposit Script
;-------------
;- This script runs from dialogue results and gold
; condition checks.
;- Used to initially open account with 100 gold deposit.
;- T_Glob_Bank_All_TempAmount is set via same results
; as this StartScript.
;- T_Glob_Bank_All_CurrentBank is set via local script.>
;- Add more elseif conditions for banks 2, 3, etc. when
; they are added by copying and editing existing conditions.
;-------------
;Last modified by Texafornian on 2018-02-19
long goldHold
;global T_Glob_Bank_All_CurrentBank
;global T_Glob_Bank_All_TempAmount
;global T_Glob_Bank_Bri_AcctAmount
;global T_Glob_Bank_Pet_AcctAmount
;Add more bank-specific globals as necessary
set goldHold to ( Player->GetItemCount Gold_001 )
if ( goldHold < T_Glob_Bank_All_TempAmount )
MessageBox "[You do not have enough gold to deposit that amount.]"
set T_Glob_Bank_All_TempAmount to 0
StopScript T_ScBank_All_Deposit
Return
endif
if ( T_Glob_Bank_All_TempAmount == 10 )
Player->RemoveItem gold_001 10
elseif ( T_Glob_Bank_All_TempAmount == 50 )
Player->RemoveItem gold_001 50
elseif ( T_Glob_Bank_All_TempAmount == 100 )
Player->RemoveItem gold_001 100
elseif ( T_Glob_Bank_All_TempAmount == 500 )
Player->RemoveItem gold_001 500
elseif ( T_Glob_Bank_All_TempAmount == 1000 )
Player->RemoveItem gold_001 1000
endif
;------------------------------
;ADD NEW BANKS IN THIS BLOCK V
;------------------------------
if ( T_Glob_Bank_All_CurrentBank == 1 ) ;Briricca Bank
set T_Glob_Bank_Bri_AcctAmount to ( T_Glob_Bank_Bri_AcctAmount + T_Glob_Bank_All_TempAmount )
MessageBox "[You have deposited %G gold. Your account balance is now: %G gold.]" T_Glob_Bank_All_TempAmount T_Glob_Bank_Bri_AcctAmount
elseif ( T_Glob_Bank_All_CurrentBank == 2 ) ;Petrocca Bank
set T_Glob_Bank_Pet_AcctAmount to ( T_Glob_Bank_Pet_AcctAmount + T_Glob_Bank_All_TempAmount )
MessageBox "[You have deposited %G gold. Your account balance is now: %G gold.]" T_Glob_Bank_All_TempAmount T_Glob_Bank_Pet_AcctAmount
else
MessageBox "T_ScBank_All_Deposit: Global T_Glob_Bank_All_CurrentBank check failed."
endif
;------------------------------
set T_Glob_Bank_All_TempAmount to 0
StopScript T_ScBank_All_Deposit
Return
endy/pre>
begin T_ScBank_All_LoanObtain
;All Banks - Loan Script
;-------------
;- This script runs from dialogue results.
;- T_Glob_Bank_All_TempAmount is set via same
; results as this StartScript.
;- T_Glob_Bank_All_CurrentBank is set via local
; script and is used to start bank loan script.
;- Add more elseif conditions for banks 2, 3,
; etc when they are added by copying and
; editing existing conditions.
;-------------
;Last modified by Texafornian on 2018-02-19
;global T_Glob_Bank_All_CurrentBank
;global T_Glob_Bank_All_TempAmount
;global T_Glob_Bank_Bri_LoanAmount
;global T_Glob_Bank_Bri_LoanDate
;global T_Glob_Bank_Pet_LoanAmount
;global T_Glob_Bank_Pet_LoanDate
;Add more bank-specific globals as necessary
;------------------------------
;ADD NEW BANKS IN THIS BLOCK V
;------------------------------
if ( T_Glob_Bank_All_CurrentBank == 1 ) ;Briricca Bank
set T_Glob_Bank_Bri_LoanAmount to ( T_Glob_Bank_All_TempAmount + ( T_Glob_Bank_All_TempAmount * 0.2 ) )
set T_Glob_Bank_Bri_LoanDate to DaysPassed
MessageBox "[You have taken out a loan of %G gold. Full payment of %G gold is due within 10 days.]" T_Glob_Bank_All_TempAmount T_Glob_Bank_Bri_LoanAmount
StartScript T_ScBank_Bri_LoanCheck
elseif ( T_Glob_Bank_All_CurrentBank == 2 ) ;Petrocca Bank
set T_Glob_Bank_Pet_LoanAmount to ( T_Glob_Bank_All_TempAmount + ( T_Glob_Bank_All_TempAmount * 0.2 ) )
set T_Glob_Bank_Pet_LoanDate to DaysPassed
MessageBox "[You have taken out a loan of %G gold. Full payment of %G gold is due within 10 days.]" T_Glob_Bank_All_TempAmount T_Glob_Bank_Pet_LoanAmount
StartScript T_ScBank_Pet_LoanCheck
else
MessageBox "T_ScBank_All_LoanObtain: Global T_Glob_Bank_All_CurrentBank check failed."
endif
;------------------------------
set T_Glob_Bank_All_TempAmount to 0
StopScript T_ScBank_All_LoanObtain
Return
end
begin T_ScBank_All_LoanPayment
;All Banks - Loan Payment Script
;-------------
;- This script runs from dialogue results.
;- T_Glob_Bank_All_TempAmount is set via same
; results as this StartScript.
;- T_Glob_Bank_All_CurrentBank is set via local
; script and is used to start bank loan script.
;- Add more elseif conditions for banks 2, 3,
; etc when they are added by copying and
; editing existing conditions.
;-------------
;Last modified by Texafornian on 2018-02-19
short failState
long goldHold
short loanHold
;global T_Glob_Bank_All_CurrentBank
;global T_Glob_Bank_All_TempAmount
;global T_Glob_Bank_Bri_LoanAmount
;global T_Glob_Bank_Bri_LoanDate
;global T_Glob_Bank_Pet_LoanAmount
;global T_Glob_Bank_Pet_LoanDate
;Add more bank-specific globals as necessary
set goldHold to ( Player->GetItemCount gold_001 )
if ( goldHold < T_Glob_Bank_All_TempAmount )
MessageBox "[You do not have enough gold to make that payment.]"
set failState to 1
endif
;------------------------------
;ADD NEW BANKS IN THIS BLOCK V
;------------------------------
if ( T_Glob_Bank_All_CurrentBank == 1 ) ;Briricca Bank
set loanHold to T_Glob_Bank_Bri_LoanAmount
elseif ( T_Glob_Bank_All_CurrentBank == 2 ) ;Petrocca Bank
set loanHold to T_Glob_Bank_Pet_LoanAmount
else
MessageBox "T_ScBank_All_LoanPayment: Global T_Glob_Bank_All_CurrentBank check failed."
set failState to 1
endif
;------------------------------
if ( failState != 1 )
if ( T_Glob_Bank_All_TempAmount > loanHold )
MessageBox "[You cannot pay more than you owe.]"
set failState to 1
elseif ( T_Glob_Bank_All_TempAmount <= loanHold )
set loanHold to ( loanHold - T_Glob_Bank_All_TempAmount )
endif
endif
if ( failState )
set failState to 0
set T_Glob_Bank_All_TempAmount to 0
StopScript T_ScBank_All_LoanPayment
Return
endif
if ( T_Glob_Bank_All_TempAmount == 10 )
Player->RemoveItem gold_001 10
elseif ( T_Glob_Bank_All_TempAmount == 50 )
Player->RemoveItem gold_001 50
elseif ( T_Glob_Bank_All_TempAmount == 100 )
Player->RemoveItem gold_001 100
elseif ( T_Glob_Bank_All_TempAmount == 500 )
Player->RemoveItem gold_001 500
elseif ( T_Glob_Bank_All_TempAmount == 1000 )
Player->RemoveItem gold_001 1000
endif
;------------------------------
;ADD NEW BANKS IN THIS BLOCK V
;------------------------------
if ( T_Glob_Bank_All_CurrentBank == 1 ) ;Briricca Bank
set T_Glob_Bank_Bri_LoanAmount to loanHold
if ( T_Glob_Bank_Bri_LoanAmount > 0 )
MessageBox "[You have deposited %G gold. Your loan balance is now: %G gold.]" T_Glob_Bank_All_TempAmount T_Glob_Bank_Bri_LoanAmount
elseif ( T_Glob_Bank_Bri_LoanAmount == 0 )
MessageBox "[You have deposited %G gold and paid off your loan.]" T_Glob_Bank_All_TempAmount
if ( ScriptRunning T_ScBank_Bri_LoanCheck )
StopScript T_ScBank_Bri_LoanCheck
Return
endif
endif
elseif ( T_Glob_Bank_All_CurrentBank == 2 ) ;Petrocca Bank
set T_Glob_Bank_Pet_LoanAmount to loanHold
if ( T_Glob_Bank_Pet_LoanAmount > 0 )
MessageBox "[You have deposited %G gold. Your loan balance is now: %G gold.]" T_Glob_Bank_All_TempAmount T_Glob_Bank_Pet_LoanAmount
elseif ( T_Glob_Bank_Pet_LoanAmount == 0 )
MessageBox "[You have deposited %G gold and paid off your loan.]" T_Glob_Bank_All_TempAmount
if ( ScriptRunning T_ScBank_Pet_LoanCheck )
StopScript T_ScBank_Pet_LoanCheck
Return
endif
endif
endif
;------------------------------
set T_Glob_Bank_All_TempAmount to 0
StopScript T_ScBank_All_LoanPayment
Return
end
begin T_ScBank_All_Withdraw
;All Banks - Withdrawal Script
;-------------
;- This script runs from dialogue results and
; gold condition checks.
;- T_Glob_Bank_All_TempAmount is set via same
; results as this StartScript.
;- T_Glob_Bank_All_CurrentBank is set via local
; script.
;- Add more elseif conditions for banks 2, 3,
; etc when they are added by copying and
; editing existing conditions.
;-------------
;Last modified by Texafornian on 2018-02-19
long accountHold
;global T_Glob_Bank_All_CurrentBank
;global T_Glob_Bank_All_TempAmount
;global T_Glob_Bank_Bri_AcctAmount
;global T_Glob_Bank_Pet_AcctAmount
;Add more bank-specific globals as necessary
;------------------------------
;ADD NEW BANKS IN THIS BLOCK V
;------------------------------
if ( T_Glob_Bank_All_CurrentBank == 1 ) ;Briricca Bank
set accountHold to T_Glob_Bank_Bri_AcctAmount
elseif ( T_Glob_Bank_All_CurrentBank == 2 ) ;Petrocca Bank
set accountHold to T_Glob_Bank_Pet_AcctAmount
else
MessageBox "T_ScBank_All_Withdraw: Global T_Glob_Bank_All_CurrentBank check failed."
set T_Glob_Bank_All_TempAmount to 0
StopScript T_ScBank_All_Withdraw
Return
endif
;------------------------------
set accountHold to ( accountHold - T_Glob_Bank_All_TempAmount )
if ( accountHold < 0 )
set T_Glob_Bank_All_TempAmount to 0
MessageBox "[You do not have enough gold to withdraw that amount.]"
StopScript T_ScBank_All_Withdraw
Return
endif
if ( T_Glob_Bank_All_TempAmount == 10 )
Player->AddItem gold_001 10
elseif ( T_Glob_Bank_All_TempAmount == 50 )
Player->AddItem gold_001 50
elseif ( T_Glob_Bank_All_TempAmount == 100 )
Player->AddItem gold_001 100
elseif ( T_Glob_Bank_All_TempAmount == 500 )
Player->AddItem gold_001 500
elseif ( T_Glob_Bank_All_TempAmount == 1000 )
Player->AddItem gold_001 1000
endif
;------------------------------
;ADD NEW BANKS IN THIS BLOCK V
;------------------------------
if ( T_Glob_Bank_All_CurrentBank == 1 ) ;Briricca Bank
set T_Glob_Bank_Bri_AcctAmount to ( T_Glob_Bank_Bri_AcctAmount - T_Glob_Bank_All_TempAmount )
if ( T_Glob_Bank_Bri_AcctAmount > 0 )
MessageBox "[You have withdrawn %G gold. Your account balance is now: %G gold.]" T_Glob_Bank_All_TempAmount T_Glob_Bank_Bri_AcctAmount
elseif ( T_Glob_Bank_Bri_AcctAmount == 0 )
MessageBox "[You have withdrawn %G gold and closed your bank account.]" T_Glob_Bank_All_TempAmount
endif
elseif ( T_Glob_Bank_All_CurrentBank == 2 ) ;Petrocca Bank
set T_Glob_Bank_Bri_AcctAmount to ( T_Glob_Bank_Pet_AcctAmount - T_Glob_Bank_All_TempAmount )
if ( T_Glob_Bank_Pet_AcctAmount > 0 )
MessageBox "[You have withdrawn %G gold. Your account balance is now: %G gold.]" T_Glob_Bank_All_TempAmount T_Glob_Bank_Pet_AcctAmount
elseif ( T_Glob_Bank_Pet_AcctAmount == 0 )
MessageBox "[You have withdrawn %G gold and closed your bank account.]" T_Glob_Bank_All_TempAmount
endif
endif
;------------------------------
set T_Glob_Bank_All_TempAmount to 0
StopScript T_ScBank_All_Withdraw
Return
end
New script-holder Clothing
For our given example, T_ScBank_Bri_CurrentBank is held in a clothing item, T_ScBank_RingBriricca. As with other "clothing" items, simply placing it in an interior is sufficient to trigger the script that is assigned to it.
This simply needs to be duplicated with the new bank’s shorthand, name, and script. A T_ScBank_Pet_CurrentBank would be held in a clothing item, T_ScBank_RingPetrucca.
The Brircca banking ring exists only for the script.
Dialogue
Most dialogue entries are bank-agnostic, but several call on bank-specific globals.
All interactive bank dialogue is handled within Tamriel Data and limited to replies for the following topics:
- deposit funds
- take out a loan
- repay a loan
- withdraw funds
“Deposit funds” has a dual purpose: it acts both as a means to move money off the character and into the account, but it also covers the creation of an account in the first place.
Just as there is no separate topic to create an account, there is no topic to close one: as soon as an account balance reaches 0, it is automatically closed.
To add a new bank, all replies for these topics need to be checked and duplicated as necessary. Bank-agnostic replies usually have an indication in their result box:
This does not need to be duplicated.This, as shown by the Global filter, does.
Additionally, if you add a new bank, add a new reply to the following topic in your plugin:
Example implementation in Old Ebonheart.
With this done, a new bank has set up shop in Tamriel. Mercantilism ho!