Jump to content

Gold: Resource


Alexandermb
 Share

Recommended Posts

  • 1 year later...
On 3/26/2018 at 6:55 PM, wowgetoffyourcellphone said:

3. Coin. This is the trading, bartering, and tributing resource. You can also find it in treasures and via loot [especially enemy economic units or economic buildings]. Buying and selling resources occurs in Coin, and Coin is the resource you gather via trading. You use Coin to hire mercenaries and do other things, like buy better weapons and pay your guard units [champions].

 

Added the coin resource to Delenda Est. Lots of changes need to be made (like tech costs and stuff), but it's in.

special_treasure_coin.png.0e9b081676401e9ad9823ac62e476d20.png

screenshot0066.thumb.jpg.f61763f37b16a01e693d83a36b7d2f3c.jpg

I wish the game had a "coin purse" sound effect (when selecting coin treasures or sending tribute notification).

I'll be making Blacksmith techs heavy in metal costs. I'm mulling simplifying techs at the Blacksmith too, but that's an aside. Coin will be used to buy slaves, hire mercenaries, and pay your Champions. You acquire coin through trade/barter, finding coin treasures, and taxing your villagers and merchants. Taxes can be increased or decreased, which also has a slight inverse effect on gathering rates. Right now I do it with tech pairs at the Civic Center, but it would be cool to implement some kind of slider in the far future.

I converted the old "Persian" metal treasures to coin treasures, since they represent finished goods, wares, etc. Then made a new "iron weapons" actor to replace the "Persian wares" actors as the metal treasures:

screenshot0067.thumb.jpg.35adbbcc47b1ddfcd78b3ad047455355.jpg

Metal treasures have the Anvil portrait now. Pegasus and the Golden Fleece have been converted to Glory treasures now, instead of metal. :) 

Edited by wowgetoffyourcellphone
  • Like 3
Link to comment
Share on other sites

23 minutes ago, wowgetoffyourcellphone said:

Added the coin resource to Delenda Est. Lots of changes need to be made (like tech costs and stuff), but it's in.

special_treasure_coin.png.0e9b081676401e9ad9823ac62e476d20.png

screenshot0066.thumb.jpg.f61763f37b16a01e693d83a36b7d2f3c.jpg

I wish the game had a "coin purse" sound effect (when selecting coin treasures or sending tribute notification).

I'll be making Blacksmith techs heavy in metal costs. I'm mulling simplifying techs at the Blacksmith too, but that's an aside. Coin will be used to buy slaves, hire mercenaries, and pay your Champions. You acquire coin through trade/barter, finding coin treasures, and taxing your villagers and merchants. Taxes can be increased or decreased, which also has a slight inverse effect on gathering rates. Right now I do it with tech pairs at the Civic Center, but it would be cool to implement some kind of slider in the far future.

I converted the old "Persian" metal treasures to coin treasures, since they represent finished goods, wares, etc. Then made a new "iron weapons" actor to replace the "Persian wares" actors as the metal treasures:

screenshot0067.thumb.jpg.35adbbcc47b1ddfcd78b3ad047455355.jpg

Metal treasures have the Anvil portrait now. Pegasus and the Golden Fleece have been converted to Glory treasures now, instead of metal. :) 

talking about that some mission or scenario can be nicce have artifacts that's disappears after be garrisoned or sending to some localization, like Ctesiphon mission in Pax Romana campaign. 

mission scort or recovery a chest of gold.

Link to comment
Share on other sites

While trading seems like a reasonable possibility, that doesn't work that well when considering the fact that merchants would usually sell their goods and bring back other ones for an even greater profit.  Personally, I'd say that there could be a few different ways producing coins, but one that hasn't been mentioned is having the player has a mint that converts metal into coins when active.  Similarly to the taxes, maybe the player could set tariffs for their trade.

  • Like 1
Link to comment
Share on other sites

3 hours ago, wowgetoffyourcellphone said:

taxing your villagers and merchants

So there is a trickle of coin I guess? Then it would seem logical that mercenaries and champions would have a negative trickle of coin, as their salary? Or is it just a one-time payment to recruit them?

 

2 hours ago, Nescio said:

Did you manage to do this?

Looking at his code he didn't, although I'm happy to be proven wrong!

I've fiddled around in the resource code and I have succeeded in ensuring that traders can only trade coin, but it is not finished yet. There is a JS-warning of which I cannot get rid of during initialisation and one can still press the arrows on the trade menu (although that just throws an error and coin is set to 100% again). So it basically works :)

All resources can still be bartered and send to allies though. If you (or someone else) are (is) interested in the code I can upload it here?

Link to comment
Share on other sites

7 minutes ago, Freagarach said:

I've fiddled around in the resource code and I have succeeded in ensuring that traders can only trade coin, but it is not finished yet. There is a JS-warning of which I cannot get rid of during initialisation and one can still press the arrows on the trade menu (although that just throws an error and coin is set to 100% again). So it basically works 

Can you share the error message and/or the code maybe it's something we can fix :)

Link to comment
Share on other sites

7 minutes ago, stanislas69 said:

Can you share the error message and/or the code maybe it's something we can fix :)

WARNING: JavaScript warning: globalscripts/Resources.js line 33
reference to undefined property data.tradable

And for this to make sense you need my Resources.js so you can find it attached. The strange part is that it all works as advertised, yet it does give the warning. This is the warning sent on initialisation.

The (second) error:

ERROR: Invalid trading goods: ({coin:95, food:5, wood:0, stone:0, metal:0})

comes from the Player.js component, the SetTradingGoods-function and comes from the fact that the arrow button is clickable, so SetTradingGoods is called trying to get the percentage of food up, but I have coded earlier that only coin is tradable. So I would very much like to have an option to disable the arrow if the resource is not tradable, but I haven't found it yet ;)

Resources.js

Link to comment
Share on other sites

16 minutes ago, Freagarach said:

WARNING: JavaScript warning: globalscripts/Resources.js line 33 reference to undefined property data.tradable

Without the resource files I would assume you forgot to set all resources to be tradable or not.  Example:

{
	"code": "stone",
	"name": "Stone",
	"description": "Mine from rocks, stone quarries or ruins.",
	"order": 3,
	"subtypes": {
		"rock": "Rock",
		"ruins": "Ruins"
	},
	"truePrice": 100,
	"aiAnalysisInfluenceGroup": "sparse"
}
		if (data.tradable == "true")

Would trigger an error because there is no tradable property. So either set it to false where you don't need it  :) or add

		if (data.tradable && data.tradable == "true")

Also not that it's likely that there is some cast occuring there

data.tradable == true <=> data.tradable == "true"

but not

data.tradable === "true"

In the json, you can write true without quotes. That's a luxury you do not have in XML.

21 minutes ago, Freagarach said:

The (second) error:


ERROR: Invalid trading goods: ({coin:95, food:5, wood:0, stone:0, metal:0})

comes from the Player.js component, the SetTradingGoods-function and comes from the fact that the arrow button is clickable, so SetTradingGoods is called trying to get the percentage of food up, but I have coded earlier that only coin is tradable. So I would very much like to have an option to disable the arrow if the resource is not tradable, but I haven't found it yet ;)

I guess this would come from Player.js ?

Player.prototype.SetTradingGoods = function(tradingGoods)
{
	let resCodes = Resources.GetCodes();
	let sumProba = 0;
	for (let resource in tradingGoods)
	{
		if (resCodes.indexOf(resource) == -1 || tradingGoods[resource] < 0)
		{
			error("Invalid trading goods: " + uneval(tradingGoods));
			return;
		}
		sumProba += tradingGoods[resource];
	}

	if (sumProba != 100)
	{
		error("Invalid trading goods: " + uneval(tradingGoods));
		return;
	}

	this.tradingGoods = [];
	for (let resource in tradingGoods)
		this.tradingGoods.push({
			"goods": resource,
			"proba": tradingGoods[resource]
		});
};

You just need to check that

	for (let resource in tradingGoods)
	{
		if(Resources.GetTradables().some(res => res == resource))
		   continue;
		if (resCodes.indexOf(resource) == -1 || tradingGoods[resource] < 0)
		{
			error("Invalid trading goods: " + uneval(tradingGoods));
			return;
		}
		sumProba += tradingGoods[resource];
	}


 and
                                                                           
for (let resource in tradingGoods)
{
	if(Resources.GetTradables().some(res => res == resource))
		   continue;                                                                       
                                                                           
	this.tradingGoods.push({
		"goods": resource,
		"proba": tradingGoods[resource]
	});                                                                 
}

 

Also i don't think I have seen any link to your mod, is it publicly hosted somewhere ?

 

 

Link to comment
Share on other sites

2 hours ago, stanislas69 said:

Without the resource files I would assume you forgot to set all resources to be tradable or not.  Example:

That is indeed what I did not do. But I thought it was strange that the warning was posted only once every time the Resource.js was processed, because I only added the tradable-data to the coin resource. But that is of no concern anymore ;)

2 hours ago, stanislas69 said:

You just need to check that

That would indeed get rid of the error message, but I don't think the error is bad at the moment, because I have yet to find a way to prevent a player from pressing the arrow-button. Now a player is visually warned that the changes (s)he makes won't be saved ;)

 

2 hours ago, stanislas69 said:

Also i don't think I have seen any link to your mod, is it publicly hosted somewhere ?

That's right, it is only stored on my hard-drive. It is a submod of DE, with elements from e.g. 0abc (like entities costing resources steadily) and Batalion-mod (like morale and fatigue systems) together with many of my own thoughts on how to make the game more realistic. It is probably totally unbalanced and I use it only to code features and test fun stuff, like: When hitting delete a unit converts to GAIA, because it is strange for a unit to kill itself on the lightly taken decision of some girl/guy behind a computer screen :D

Edited by Freagarach
typo
  • Like 1
Link to comment
Share on other sites

11 minutes ago, Freagarach said:

That would indeed get rid of the erro message, but I don't think the error is bad at the moment, because I have yet to find a way to prevent a player from pressing the arrow-button. Now a player is visually warned that the changes (s)he makes won't be saved ;)

Well the menu is populated automatically, I'm not sure but I think my fix would prevent them from being displayed at all :)

12 minutes ago, Freagarach said:

That's right, it is only stored on my hard-drive. It is a submod of DE, with elements from e.g. 0abc (like entities costing resources steadily) and Batalion-mod (like morale and fatigue systems) together with many of my own thoughts on how to make the game more realistic. It is probably totally unbalanced and I use it only to code features and test fun stuff, like: When hitting delete a unit converts to GAIA, because it is strange for a unit to kill itself on the lightly taken decision of some girl/guy behind a computer screen

That's an interesting concept :)

Link to comment
Share on other sites

1 hour ago, stanislas69 said:

Well the menu is populated automatically, I'm not sure but I think my fix would prevent them from being displayed at all :)

Sadly not. It does a good job in preventing the error message, but I can still click the arrow there. If I do that it gives the error that sumProba != 100, which is logical because I get 5% off the coin, but it can't add it anywhere ;) FYI, I've changed the error message so I could discriminate between them.

1 hour ago, stanislas69 said:

That's an interesting concept :)

Thank you!

Link to comment
Share on other sites

5 minutes ago, Freagarach said:

Sadly not. It does a good job in preventing the error message, but I can still click the arrow there. If I do that it gives the error that sumProba != 100, which is logical because I get 5% off the coin, but it can't add it anywhere ;) FYI, I've changed the error message so I could discriminate between them.

Mmmh I guess something else displays the barter panel using the list of resources files.

Link to comment
Share on other sites

32 minutes ago, stanislas69 said:

Mmmh I guess something else displays the barter panel using the list of resources files.

Yep, and grep was my friend here again. I managed to exclude all other resources (except coin) from the trade menu. I'll now try to make sure one can only pay for resources with coin, as I've noticed that some people would like that (I don't but hey I'm almost there I guess).

Thanks once again!

  • Like 1
Link to comment
Share on other sites

11 hours ago, Nescio said:

Did you manage to do this?

If you want this (that all resources can only be bartered into coin and vice versa, that is wat you want right?) you need to change

barterButton.Buy.hidden

in the menu.js in gui/session to

	if (g_BarterSell == "coin"){
		barterButton.Buy.hidden = isSelected;}
	else {barterButton.Buy.hidden = resourceCode != "coin";}

provided that you want coin to be bartered. I could also write some code to do this more cleanly, if anyone wants that? More cleanly: setting up a barterable parameter in the resource. But since I'm not going to use this I stop here for now.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

9 hours ago, Freagarach said:

I could also write some code to do this more cleanly, if anyone wants that? More cleanly: setting up a barterable parameter in the resource.

Ideally so that other mods in the future can have the maximum amount of control over any new resources they add to the game, I think the core game should allow the resource files to have flags for "trade": true and "barter": false, "tribute": etc. Basically what you suggested. That's so DE (and other mods) don't have to maintain custom variations of core javascript files. 

Edited by wowgetoffyourcellphone
Link to comment
Share on other sites

8 hours ago, Freagarach said:

If you want this (that all resources can only be bartered into coin and vice versa, that is wat you want right?) you need to change


barterButton.Buy.hidden

in the menu.js in gui/session to


	if (g_BarterSell == "coin"){
		barterButton.Buy.hidden = isSelected;}
	else {barterButton.Buy.hidden = resourceCode != "coin";}

provided that you want coin to be bartered. I could also write some code to do this more cleanly, if anyone wants that? More cleanly: setting up a barterable parameter in the resource. But since I'm not going to use this I stop here for now.

This works. :) Is there a way to remove Glory from both trading and bartering? 

Link to comment
Share on other sites

9 hours ago, Freagarach said:

If you want this (that all resources can only be bartered into coin and vice versa, that is wat you want right?)

Yes, exactly. I've introduced a silver resource in my 0abc mod in 2017 and limiting barter and trade is something I like to have.

9 hours ago, Freagarach said:

I could also write some code to do this more cleanly, if anyone wants that? More cleanly: setting up a barterable parameter in the resource. But since I'm not going to use this I stop here for now.

47 minutes ago, wowgetoffyourcellphone said:

Ideally so that other mods in the future can have the maximum amount of control over any new resources they add to the game, I think the core game should allow the resource files to have flags for "trade": true and "barter": false, etc. Basically what you suggested. That's so DE (and other mods) don't have to maintain custom variations of core javascript files. 

That would certainly be nice to have in the default distribution. It's not inconceivable more mods intend to use a currency resource.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

43 minutes ago, wowgetoffyourcellphone said:

This works. :) Is there a way to remove Glory from both trading and bartering?

Aye, it can be done. But it needs quite some files to be changed, so I'm not sure this is the right place to post that? If anyone wants to make a ticket for it I'm happy to upload my code there.

The only part I see some challenges ahead is the bartering, because there are both a selling row and a buying row and a modder might want to be able to sell food for wood, but not food for coin or something. Hmm :unsure:

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...