• New Horizons on Maelstrom
    Maelstrom New Horizons


    Visit our website www.piratehorizons.com to quickly find download links for the newest versions of our New Horizons mods Beyond New Horizons and Maelstrom New Horizons!

Improve town economy

Kenway1776

Landlubber
How do I improve town economy? Kinda sad see barbados island always on bad economic situation. And is trading mission really help to improve town economy? Or is just normal quest?
 
How do I improve town economy? Kinda sad see barbados island always on bad economic situation. And is trading mission really help to improve town economy? Or is just normal quest?

Or trading mission really make the town economy even worse then before?
 
I don't think player actions can affect the town economy, except by temporary price changes when you buy or sell goods. Random events will alter the town's economy. You can see if these have been happening by asking for gossip about colonies in the tavern. Bad events such as hurricanes, Indian attacks, slave revolts etc. will harm a town's economy; good events such as new settlers, expedition returning, etc. will help the town. But as far as I can tell from looking at storekeeper dialogs and quest code for control cargo missions, there's no mention of town economy there, which would mean that cargo missions don't affect the town's economy. Likewise, I can't find anything in dialogs or quest code associated with fetch quests which affects a town's economy, though the economy may affect the amount and price of goods which you are asked to fetch.

It's a town. It's a lot bigger than you. Unless you're in command of a fleet of really big merchants, you can't carry enough goods to do anything permanent to the local economy. (But you might harm the town's economy, not to mention its population size, if you attack it!)
 
How do I improve town economy?
I was talking to "redarmy275" on our Discord the other day, who was trying to give the player some more influence in the town economy.
Our first idea was that giving money to the local Loanshark could positively influence the economy.
Coding-wise, that shouldn't be too difficult to get working.
 
@Kenway1776: Quickest experiment of quick experiments:
Code:
           string sTownName = GetCurrentTownID();
           int TownGold = GetTownGold(sTownName);
           TraceAndLog(sTownName + ": Old Gold = " + TownGold);
           SetTownGold(sTownName, TownGold+100);
           TownGold = GetTownGold(sTownName);
           TraceAndLog(sTownName + ": New Gold = " + TownGold);
Make a backup of your PROGRAM\DIALOGS\Usurer_dialog.c file, then put attached file there instead.
Ideally use WinMerge to see what changes there are with your own copy.

Results can be seen in "compile.log" in the main game folder.
Every time you talk to the Loanshark, the town gets 100 more gold:
Douwesen: Old Gold = 12000000
Douwesen: New Gold = 12000100
Douwesen: Old Gold = 12000100
Douwesen: New Gold = 12000200
Douwesen: Old Gold = 12000200
Douwesen: New Gold = 12000300
Douwesen: Old Gold = 12000300
Douwesen: New Gold = 12000400
 

Attachments

  • Usurer_dialog.c
    24.2 KB · Views: 164
[SIZE=4]Kenway1776[/SIZE] and @Grey Roger: Merging with the latest mod update today, I ran into this unfinished experiment again.
So I made a couple of extra steps in the attached file. Might still need a bit more work, but hopefully still a li'l better than we had it. :doff
 

Attachments

  • Usurer_dialog.c
    24.4 KB · Views: 118
Why is the loanshark now responsible for the town's entire gold reserve? Possibly add a small percentage to the town's gold when you make a deposit with the loanshark, as he's investing some of your money into local companies in the hope of making some profit for himself. But I don't think your entire loan should be taken from the town, nor your entire deposit be given to the town.

But I can see one improvement that may need to be made to "Usurer_dialog.c". Isn't 'sti' the correct way to convert a string to an integer, rather than 'makeint'? ;)
 
Why is the loanshark now responsible for the town's entire gold reserve? Possibly add a small percentage to the town's gold when you make a deposit with the loanshark, as he's investing some of your money into local companies in the hope of making some profit for himself. But I don't think your entire loan should be taken from the town, nor your entire deposit be given to the town.
Why?
Because it's simple; and because that's what the person I talked with before suggested doing.

If you want to make it more fancy, go for it.
I just offer this as a proof of concept.

But I can see one improvement that may need to be made to "Usurer_dialog.c". Isn't 'sti' the correct way to convert a string to an integer, rather than 'makeint'? ;)
Honestly, I never did quite understand the difference between those two...
 
If you want to make it more fancy, go for it.
Easy. Remove all the adjustments to town gold apart from the one where you're depositing gold, and change that to give 10% of the deposit to the town as the loanshark uses some of your money to invest in local business in the hope of making a profit. (He's not a charity, so he has to make the money to pay your interest somehow!)
Original deposit line:
Code:
SetTownGold(NPC_Area, GetTownGold(NPC_Area)+makeint(Pchar.Quest.Loans.(NPC_Area).Sum));
Revised version:
Code:
SetTownGold(NPC_Area, GetTownGold(NPC_Area)+makeint(sti(Pchar.Quest.Deposits.(NPC_Area).Sum)/10));
Honestly, I never did quite understand the difference between those two...
I thought that 'makeint' is to convert a float to an integer, while 'sti' converts a string to an integer, and that's how I used them here - 'sti' to turn the attribute into an integer, 'makeint' to turn it back into an integer after it's been divided by 10. Having said that, there are plenty of code lines which use 'makeint' to convert an attribute to an integer and seem to get away with it - unless any of them are causing bugs which haven't been spotted yet...

And then I tested the new "Usurer_dialog.c" by putting a line into "console.c" to display the town's gold, used it once before talking to the loanshark, and used it again after depositing a load of money. The town's gold went up by the appropriate amount. Whether that will affect the town's actual economy status, and therefore the types of ships for sale in the shipyard, items for sale from stores and traders, etc., I've no idea. (But I'm fairly sure the original line wouldn't have worked. Dividing by 10 wasn't the only change I made. ;))
 

Attachments

  • Usurer_dialog.c
    24.1 KB · Views: 115
I thought that 'makeint' is to convert a float to an integer, while 'sti' converts a string to an integer, and that's how I used them here
Without anyone knowing better, I'd say that's a decent way to look at 'em. :onya

Whether that will affect the town's actual economy status, and therefore the types of ships for sale in the shipyard, items for sale from stores and traders, etc., I've no idea.
I kind-of hope so; that was the original wish, after all...

But probably not, actually.
I suspect that requires a call to the 'AdjustTownEconomy' function too; as shown by 'LaunchRandomTownEvent' in Towntable.c .
 
I kind-of hope so; that was the original wish, after all...

But probably not, actually.
I suspect that requires a call to the 'AdjustTownEconomy' function too; as shown by 'LaunchRandomTownEvent' in Towntable.c .
Version 2 attached. In this one, the fraction of your deposit which the loanshark invests in local business is now a variable defined at the top of the file:
Code:
   float NPC_INVEST_RATE = 0.1;   // If you deposit money, the loanshark invests this much of it into local business...
   int NPChar_Investment;       // ... and this is the amount invested
Then, at case "deposit_exit":
Code:
           NPChar_Investment = makeint(sti(Pchar.Quest.Deposits.(NPC_Area).Sum) * NPC_INVEST_RATE);
           SetTownGold(NPC_Area, GetTownGold(NPC_Area) + NPChar_Investment); // GR: Some of deposit invested into town gold
           switch (GetTownEconomy(GetTownFromID(NPC_Area)))
           {
               case TOWN_ECONOMY_STARVING:
                   if (NPChar_Investment > 10000) AdjustTownEconomy(GetTownFromID(NPC_Area), 1);
                   if (NPChar_Investment > 50000) AdjustTownEconomy(GetTownFromID(NPC_Area), 1);
               break;
               case TOWN_ECONOMY_STRUGGLING:
                   if (NPChar_Investment > 50000) AdjustTownEconomy(GetTownFromID(NPC_Area), 1);
                   if (NPChar_Investment > 500000) AdjustTownEconomy(GetTownFromID(NPC_Area), 1);
               break;
               case TOWN_ECONOMY_SURVIVING: if (NPChar_Investment > 500000) AdjustTownEconomy(GetTownFromID(NPC_Area), 1); break;
               case TOWN_ECONOMY_PROSPERING: if (NPChar_Investment > 1000000) AdjustTownEconomy(GetTownFromID(NPC_Area), 1); break;
               // No entry for TOWN_ECONOMY_WEALTHY as that's the maximum economy level!
           }
Depending on the town's current economy and how much you deposit, the economy can go up by 1, and the lower two economies can even go up by 2 if you invest a lot. Note, those threshhold values are the amount the loanshark is investing, currently 10% of your deposit, so you'd need to deposit 500000 to raise a "starving" settlement up to "surviving". I might raise the values because the town's initial gold is its population multiplied by TOWN_GOLD_SCALAR, a global variable defined in "InternalSettings.h" and currently 10000, which means even the smallest, most pathetic town with a population of 200 will have 2000000 gold. Having said that, look through "InitTowns.c" - population, and therefore initial gold, does not necessarily relate to the town economy. And random events don't necessarily change the town's gold to match the economy change, which means that over time, the link between town gold and town economy breaks even more.

In any case, here's the result of depositing about 8.8 million with the Speightstown loanshark. For comparison, also shown is Cayman's current status.
deposit_results.jpg cayman_status.jpg
Speightstown goes from economy -1 (struggling) to +1 (prospering) because the loanshark puts about 880000 into local businesses. Speightstown's "struggling" gold was nearly 6.5 million before the deposit. Cayman has 7.4 million and economy +2 (wealthy), the highest possible rating. (This is a well-advanced game in which random events have had a few years to play havoc with towns' gold reserves and economies.)
 

Attachments

  • Usurer_dialog.c
    25.1 KB · Views: 108
Version 2 attached. In this one, the fraction of your deposit which the loanshark invests in local business is now a variable defined at the top of the file:
Code:
   float NPC_INVEST_RATE = 0.1;   // If you deposit money, the loanshark invests this much of it into local business...
   int NPChar_Investment;       // ... and this is the amount invested
Then, at case "deposit_exit":
Code:
           NPChar_Investment = makeint(sti(Pchar.Quest.Deposits.(NPC_Area).Sum) * NPC_INVEST_RATE);
           SetTownGold(NPC_Area, GetTownGold(NPC_Area) + NPChar_Investment); // GR: Some of deposit invested into town gold
           switch (GetTownEconomy(GetTownFromID(NPC_Area)))
           {
               case TOWN_ECONOMY_STARVING:
                   if (NPChar_Investment > 10000) AdjustTownEconomy(GetTownFromID(NPC_Area), 1);
                   if (NPChar_Investment > 50000) AdjustTownEconomy(GetTownFromID(NPC_Area), 1);
               break;
               case TOWN_ECONOMY_STRUGGLING:
                   if (NPChar_Investment > 50000) AdjustTownEconomy(GetTownFromID(NPC_Area), 1);
                   if (NPChar_Investment > 500000) AdjustTownEconomy(GetTownFromID(NPC_Area), 1);
               break;
               case TOWN_ECONOMY_SURVIVING: if (NPChar_Investment > 500000) AdjustTownEconomy(GetTownFromID(NPC_Area), 1); break;
               case TOWN_ECONOMY_PROSPERING: if (NPChar_Investment > 1000000) AdjustTownEconomy(GetTownFromID(NPC_Area), 1); break;
               // No entry for TOWN_ECONOMY_WEALTHY as that's the maximum economy level!
           }
Depending on the town's current economy and how much you deposit, the economy can go up by 1, and the lower two economies can even go up by 2 if you invest a lot. Note, those threshhold values are the amount the loanshark is investing, currently 10% of your deposit, so you'd need to deposit 500000 to raise a "starving" settlement up to "surviving". I might raise the values because the town's initial gold is its population multiplied by TOWN_GOLD_SCALAR, a global variable defined in "InternalSettings.h" and currently 10000, which means even the smallest, most pathetic town with a population of 200 will have 2000000 gold. Having said that, look through "InitTowns.c" - population, and therefore initial gold, does not necessarily relate to the town economy. And random events don't necessarily change the town's gold to match the economy change, which means that over time, the link between town gold and town economy breaks even more.

In any case, here's the result of depositing about 8.8 million with the Speightstown loanshark. For comparison, also shown is Cayman's current status.
View attachment 39049 View attachment 39050
Speightstown goes from economy -1 (struggling) to +1 (prospering) because the loanshark puts about 880000 into local businesses. Speightstown's "struggling" gold was nearly 6.5 million before the deposit. Cayman has 7.4 million and economy +2 (wealthy), the highest possible rating. (This is a well-advanced game in which random events have had a few years to play havoc with towns' gold reserves and economies.)

Pls, how i do that?
I want to know town population an gold town

1659892572735.png
 
I did that using "console.c", though I can't remember off-hand exactly what commands I used.

But you should be able to find a town's population by talking to one of its citizens. Look for a permanent resident, who probably won't be carrying a weapon. There are also random visitors who do carry weapons and who have different things to say, such as random game hints, trying to sell you things or begging for money; these will never tell you the population. You may need to talk to a permanent resident several times before the conversation offers the chance to ask about the colony.

And you should be able to get some idea of the town's gold by talking to the store or shipyard because they use the town's gold rather than their personal wealth.
 
Is Barbados in the current build set to be eternally struggling? I've noticed a constant low amount of goods with both traders.
 
I did that using "console.c", though I can't remember off-hand exactly what commands I used.

But you should be able to find a town's population by talking to one of its citizens. Look for a permanent resident, who probably won't be carrying a weapon. There are also random visitors who do carry weapons and who have different things to say, such as random game hints, trying to sell you things or begging for money; these will never tell you the population. You may need to talk to a permanent resident several times before the conversation offers the chance to ask about the colony.

And you should be able to get some idea of the town's gold by talking to the store or shipyard because they use the town's gold rather than their personal wealth.
it is difficult to find the population. Find a citizen and have a dialogue where he provides the population. It is impossible if the city you want to know the economic data of is the enemy. So I had an idea, is there a way to add a simple spy mechanic? I thought about whether to put a character in the fort, or in the city hall that is a spy. then you talk to him and he tells you the data of a certain colony. Hence if it is an allied colony it provides the precise data, if it is an enemy colony it provides approximate data. I want to do this, but I have no idea how to do it. I even know a little bit and c++. but i get lost when i look at the codes
 
Is Barbados in the current build set to be eternally struggling? I've noticed a constant low amount of goods with both traders.
Speightstown should be "Surviving", similar to Sao Jorge and Kralendijk, though its population is smaller so its initial gold is lower. Bridgetown is "Struggling" and also has a relatively small population. Random events can improve or reduce the economies - check the tavern news.

it is difficult to find the population. Find a citizen and have a dialogue where he provides the population. It is impossible if the city you want to know the economic data of is the enemy.
It is not impossible. Forts and ships now have a small but non-zero chance of seeing through your false flag so you probably don't want to sail to the port, but you can moor at a nearby beach, walk to town, then talk to citizens.

Adding a spy would be very difficult and not worth the effort to gain information which you can get freely from citizens anyway. Besides, there would need to be a chance that the spy has been caught. Anyway, you'd still need to get into the town to contact your spy - but then you can just talk to citizens in the town. ;)
 
Back
Top