• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[General] Help with income formula

Status
Not open for further replies.
Level 3
Joined
Aug 12, 2010
Messages
29
I'm in a bit of a stump on how to get the math down for my income formula(It is taxed based on how much income you have).

So every 25g in your income will be taxed by 10%, increasing by 10% every threshold.

0-25 = 0% tax.
26-50 = 10%
51-75 = 20%
and so forth, capping out at 80%, and for everything 1g above 80% is taxed.

I just can't seem how to get it into a trigger form. Any help would be much appreciated.
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
I'd suggest calculating with a limit function,
although easier to understand would be just with an if/then/else statement for the limit.
Something like:
  • Set Income = Player X income
  • Set TaxPercent = (Income - 25.00) / 25.00 / 10.00
  • If (TaxPercent > 0.8)
    • Set Tax Percent = 0.8
  • Set IncomePercent = 1 - TaxPercent
  • Set IncomeAfterTax = Income * IncomePercent
  • Set Tax = Income * TaxPercent
  • --------
  • And then you use IncomeAfterTax and Tax for whatever you like
Ideally, there would be a few more configurables for ease of access.

JASS:
//This is just so i can explain what is happening
Set Income = Player X income //Variable for the player income, take it from whatever system you have
Set TaxPercent =  (Income - 25.00) / 25.00 / 10.00 // Income - 25 because 0-25 is 0 tax / 25 / 10 to turn it into percentage.
If (TaxPercent > 0.8) //check if tax is over limit
 Set Tax Percent = 0.8 //if it is, it sets it to the limit
Set IncomePercent = 1 - TaxPercent // calculate percent of the income
Set IncomeAfterTax = Income * IncomePercent //get amount of total income
Set Tax = Income * TaxPercent //and finally get amount of tax

regards
-Ned
 
Last edited:
Status
Not open for further replies.
Top