Wallet trick with custom trigger members
From AgeofWiki
The wallet trick is a set of triggers which makes a person only able to carry so much of a resource, such as coin (money). This is useful in RPGs mostly, because in campaigns and such you need the money to train units. This wallet trick uses custom conditions and effects, so please read Adding Custom Triggers before using this trick.
The Custom Conditions and Effects required
Copy the following conditions and effects into your typetest.xml document, as instructed by the aforementioned guide.
<Condition name="Player Resource Compare to QV">
<Param name="PlayerID" dispName="$$22301$$Player" VarType="player">1</Param>
<Param name="Resource" dispName="$$22324$$Resource" VarType="resource">food</Param>
<Param name="Op" dispName="$$22297$$Operator" VarType="operator">==</Param>
<Param name="QVID" dispName="$$32955$$Var Name 1" varType="string">QV1</Param>
<Expression>trPlayerResourceCount(%PlayerID%, "%Resource%") %Op% trQuestVarGet("%QVID%")</Expression>
</Condition>
<Effect name="Set Resource to QV">
<Param name="PlayerID" dispName="$$22301$$Player" varType="player">1</Param>
<Param name="ResName" dispName="$$22455$$Resource" varType="resource">food</Param>
<Param name="QVName" dispName="$$32954$$Var Name" VarType="string">QV1</Param>
<Command>trPlayerGrantResources(%PlayerID%, "%ResName%", (trQuestVarGet("%QVName%")-trPlayerResourceCount(%PlayerID%, "%ResName%")));</Command>
</Effect>
The first will be used for checking if the coin has exceeded the wallet size, and the second will make it so the resources do not exceed the wallet size.
Putting it together
This is how the one trigger will be put together in the trigger menu.
Trigger 0
Loop: yes
Run immediately: no
Active: yes
Condition: Player Resource Compare to QV
Player: 1
Resource: Coin
Op: >=
Var Name 1: WalletSize
Effect: Set Resource to QV
Player: 1
Resource: Coin
Var Name: WalletSize
Now you can simply use other triggers to change the WalletSize quest var and you will have a wallet of varying size. Not only does this method only require one trigger, it also executes faster because it doesn't take away the coin one by one.
