From 452ec389bdef2ed6d0e021b32ab9c8cc0d270802 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Sat, 9 Nov 2019 17:09:39 -0300 Subject: Function helpers --- npc/functions/politics.txt | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/npc/functions/politics.txt b/npc/functions/politics.txt index 19fdcda81..b3eeb209f 100644 --- a/npc/functions/politics.txt +++ b/npc/functions/politics.txt @@ -94,6 +94,51 @@ function script POL_LocToTP { return Exception("Invalid town requested / POL_LocToTP", RB_DEFAULT|RB_SPEECH, -1); } +// Adjusts prices for crafts +// POL_AdjustPrice( price, {TOWNCODE} ) +function script POL_AdjustPrice { + .@p=getarg(0); + .@l$=getarg(1, LOCATION$); + + // Town Admin is always tax exempt + if (getd(.@l$ + "_MAYOR$") == strcharinfo(0)) + .@p=0; + + // Town option for tax immunity + if (getd(.@l$ + "_TAXOFF")) { + .@vat=getd("$"+.@l$+"_TAX"); + .@tax=.@p*.@vat/10000; + .@p-=.@tax; + } + + // Return adjusted price + return .@p; +} + +// Change a town money at player expense +// POL_PlayerMoney( price, {TOWNCODE} ) +function script POL_PlayerMoney { + .@p=getarg(0); + .@l$=getarg(1, LOCATION$); + .@t=POL_LocToTP(.@l$); + + Zeny-=.@p; + + // Town option for tax immunity + if (getd(.@l$ + "_TAXOFF")) { + return 0; + } + + // Calculate tax and add to town vault + .@vat=getd("$"+.@l$+"_TAX"); + .@tax=.@p*.@vat/10000; + .@GP=getd("$"+getarg(0)+"_MONEY"); + setd(.@town$+"_MONEY", .@GP+.@tax); + + // Return the taxes paid + return .@tax; +} + - script Politics NPC_HIDDEN,{ OnSun0000: -- cgit v1.2.3-60-g2f50