Here comes the Tax Man

Post » Sun Jun 24, 2012 11:16 am

Basically, what i have set up so far is a town that the player is lord of, with numerous businesses that can be upgraded three levels. To reflect the upgrades, i have set up the various merchant's inventories to get better, their gold amounts to increase, furniture swaps and item additions.

What i want to do now is:

1. Make it so that on a weekly basis (eg, tamriels equivelent of Friday), the game automatically looks at each business' upgrade level, converts that into a gold amount, add it all together, then dump it in a set container

2. In game, have an activateable ledger than brings up an unstealable book that has written in it, an in character summary of that weeks taxes


I kind of have an idea about no.1, but im not sure whether i should be using ints in a script or globals or both?? And then i know i'll be needing to use RegisterForUpdate at some point, but I cannot quite figure out how i'll make it automatically repeat. Then when i start thinking about no.2 my brain starts to hurt

Anybody out there able to nudge me in the right direction?

- Hypno
User avatar
kitten maciver
 
Posts: 3472
Joined: Fri Jun 30, 2006 2:36 pm

Post » Sun Jun 24, 2012 5:18 pm

I will be watching this closely as I want to do something similar to # 1 as well. Thanks for posting. Would you be so kind as to post your results as they come? I think mine will just be based on player level not necessarily upgrades though.
User avatar
Peetay
 
Posts: 3303
Joined: Sun Jul 22, 2007 10:33 am

Post » Sun Jun 24, 2012 7:11 pm

Would you be so kind as to post your results as they come?

Of coarse im going to mate, thats the whole point of these topics, so others at a later date can also use the info for their own purposes

- Hypno

EDIT: I made a start with no.1 by adding to my existing upgradecount script

(The int properties at the top get raised by 1 each time the player purchases the upgrade. This is handled in my dialogue tree.)

Spoiler
Scriptname HWETownUpgradeCountScript extends Quest  Conditionalint Property GenStore = 0  Auto Conditionalint Property Market = 0  Auto Conditionalint Property Inn = 0  Auto Conditionalint Property Blacksmith = 0  Auto Conditionalint Property Alchemist = 0  Auto Conditionalint Property Weaponsmith = 0  Auto Conditionalint Property TaxGenStore = 200  Autoint Property TaxMarket = 0  Autoint Property TaxInn = 300  Autoint Property TaxBlacksmith = 200  Autoint Property TaxAlchemist = 0  Autoint Property TaxWeaponsmith = 0  Autoint Property TaxStables = 50  Autoint Property TaxTotal = 0  AutoglobalVariable Property HWETaxGenStore  AutoglobalVariable Property HWETaxMarket  AutoglobalVariable Property HWETaxInn  AutoglobalVariable Property HWETaxBlacksmith  AutoglobalVariable Property HWETaxAlchemist  AutoglobalVariable Property HWETaxWeaponsmith  AutoglobalVariable Property HWETaxStables  AutoglobalVariable Property HWETaxTotal  Autofunction calcGenStore()  if (Genstore > 0)	TaxGenStore = 200 + (GenStore * 100)  endIfendFunctionfunction calcMarket()  if (Market > 0)	TaxMarket = Market * 100  endIfendFunctionfunction calcInn()  if (Inn > 0)	TaxInn = 300 + (Inn * 150)  endIfendFunctionfunction calcBlacksmith()  if (Blacksmith > 0)	TaxBlacksmith = 200 + (Blacksmith * 100)  endIfendFunctionfunction calcAlchemist()  if (Alchemist > 0)	TaxAlchemist = 200 + (Alchemist * 100)  endIfendFunctionfunction calcWeaponsmith()  if (Weaponsmith > 0)	TaxWeaponsmith = 200 + (Weaponsmith * 100)  endIfendFunctionfunction calcTotal()	calcGenStore()	calcMarket()	calcInn()	calcBlacksmith()	calcAlchemist()	calcWeaponsmith()	TaxTotal = (TaxGenStore + TaxMarket + TaxInn + TaxBlacksmith + TaxAlchemist + TaxWeaponsmith + TaxStables)endFunctionfunction setTotal()	HWETaxGenStore.setValueInt(TaxGenStore)	HWETaxMarket.setValueInt(TaxMarket)	HWETaxInn.setValueInt(TaxInn)	HWETaxBlacksmith.setValueInt(TaxBlacksmith)	HWETaxAlchemist.setValueInt(TaxAlchemist)	HWETaxWeaponsmith.setValueInt(TaxWeaponsmith)	HWETaxTotal.setValueInt(TaxTotal)endFunction

now i have two useful functions:

calcTotal() - calculates all the different totals
setTotal() - sets the totals to the various global variables
User avatar
Jesus Lopez
 
Posts: 3508
Joined: Thu Aug 16, 2007 10:16 pm

Post » Sun Jun 24, 2012 10:16 am

How does the spouse store handle this? I think the spouse accumulates 100/day and will transfer if you ask.
I think there is also a spouse store mod that you dump your gear off and he or she sells it and you get the take.
The spouse can also level up and get better prices.

Might be an interesting script set to look at.
User avatar
Haley Merkley
 
Posts: 3356
Joined: Sat Jan 13, 2007 12:53 pm

Post » Sun Jun 24, 2012 7:56 am

Hmmm, good point. I'm not at home at the moment, so I cannot check for the time being. Cheers for the tip.

EDIT: I think I've got no.1 pretty much done out in my head. After reading the ck wiki I realised that I was confusing registerforupdate with registerforsingleupdate, so there was nothing to figure out because it repeats itself normally.

Hmmm, good point. I'm not at home at the moment, so I cannot check for the time being. Cheers for the tip.

EDIT: I think I've got no.1 pretty much done (in my head at least). After reading the ck wiki I realised that I was confusing registerforupdate with registerforsingleupdate, so there was nothing to figure out because it repeats itself normally.

So I'll attach the following to the trigger dialogue:

registerforupdate(168)

That should start up the weekly update. Now back to my UpgradeCountScript, I'll add the following code to the end of what I wrote last night:

function payday()    Alias_Container.additem(gold001, TaxTotal, false)    debug.notification("g town income has been added to the bedroom safe")endfunctionevent onUpdate()    calcTotal()    setTotal()    payDay()endevent

Will this work?

- Hypno
User avatar
Sierra Ritsuka
 
Posts: 3506
Joined: Mon Dec 11, 2006 7:56 am

Post » Sun Jun 24, 2012 1:05 pm

Sorry for the double post but I'm sitting here bored so I rewrote the script to update every 24 game-hours and (hopefully) only pay the player on Monday

Spoiler
Scriptname HWETownUpgradeCountScript extends Quest  Conditionalimport Mathimport Utilityint Property GenStore = 0  Auto Conditionalint Property Market = 0  Auto Conditionalint Property Inn = 0  Auto Conditionalint Property Blacksmith = 0  Auto Conditionalint Property Alchemist = 0  Auto Conditionalint Property Weaponsmith = 0  Auto Conditionalint Property TaxGenStore = 200  Autoint Property TaxMarket = 0  Autoint Property TaxInn = 300  Autoint Property TaxBlacksmith = 200  Autoint Property TaxAlchemist = 0  Autoint Property TaxWeaponsmith = 0  Autoint Property TaxStables = 50  Autoint Property TaxTotal = 0  AutoglobalVariable Property HWETaxGenStore  AutoglobalVariable Property HWETaxMarket  AutoglobalVariable Property HWETaxInn  AutoglobalVariable Property HWETaxBlacksmith  AutoglobalVariable Property HWETaxAlchemist  AutoglobalVariable Property HWETaxWeaponsmith  AutoglobalVariable Property HWETaxStables  AutoglobalVariable Property HWETaxTotal  AutoreferenceAlias Property Alias_Container  AutoreferenceAlias Property Alias_ContainerBackup  AutoobjectReference Property BedroomMarker  AutomiscObject Property Gold001  Autofunction calcGenStore()  if (Genstore > 0)        TaxGenStore = 200 + (GenStore * 100)  endIfendFunctionfunction calcMarket()  if (Market > 0)        TaxMarket = Market * 100  endIfendFunctionfunction calcInn()  if (Inn > 0)        TaxInn = 300 + (Inn * 150)  endIfendFunctionfunction calcBlacksmith()  if (Blacksmith > 0)        TaxBlacksmith = 200 + (Blacksmith * 100)  endIfendFunctionfunction calcAlchemist()  if (Alchemist > 0)        TaxAlchemist = 200 + (Alchemist * 100)  endIfendFunctionfunction calcWeaponsmith()  if (Weaponsmith > 0)        TaxWeaponsmith = 200 + (Weaponsmith * 100)  endIfendFunctionfunction calcTotal()        calcGenStore()        calcMarket()        calcInn()        calcBlacksmith()        calcAlchemist()        calcWeaponsmith()        TaxTotal = (TaxGenStore + TaxMarket + TaxInn + TaxBlacksmith + TaxAlchemist + TaxWeaponsmith + TaxStables)endFunctionfunction setTotal()        HWETaxGenStore.setValueInt(TaxGenStore)        HWETaxMarket.setValueInt(TaxMarket)        HWETaxInn.setValueInt(TaxInn)        HWETaxBlacksmith.setValueInt(TaxBlacksmith)        HWETaxAlchemist.setValueInt(TaxAlchemist)        HWETaxWeaponsmith.setValueInt(TaxWeaponsmith)        HWETaxTotal.setValueInt(TaxTotal)endFunctionfunction payday()  if (bedroomMarker.isdisabled())    Alias_ContainerBackup.getref().additem(gold001, TaxTotal, false)    debug.notification("g tax income has been added to the town hall chest")      Else    Alias_Container.getref().additem(gold001, TaxTotal, false)    debug.notification("g tax income has been added to the bedroom safe")  endIfendFunctionInt Function GetPassedGameDays() Global        Float GameTime        Float GameDaysPassed        GameTime = GetCurrentGameTime()        GameDaysPassed = Floor(GameTime)        return GameDaysPassed as IntEndFunctionInt Function GetDayOfWeek()        Int GameDaysPassed        GameDaysPassed = GetPassedGameDays()        return GameDaysPassed % 7EndFunctionevent onUpdate()  If ( GetDayOfWeek() == 1 )      calcTotal()      setTotal()       payDay()  endIf      registerForSingleUpdate(24)endevent

- Hypno
User avatar
Stat Wrecker
 
Posts: 3511
Joined: Mon Sep 24, 2007 6:14 am


Return to V - Skyrim