Specialist / Building Output

FredMB

Chieftain
Joined
Oct 28, 2010
Messages
84
Location
Vancouver, Canada
Hello Everyone

This is my first post here. I hope I'm in the right section. I'm currently working on a balance mod. Right now I'm modding buildings and specialists. Is there a way to make specialists and buildings output anything else than food / gold / production / science / culture? I'm mostly interested in making certain specialists (which I created) and building provide an output of resources.

For example I'd like to make a Forge increase the iron output by one or a stable increase the horse output by one. Actually what I'd really like is to have that extra output made available when a specialist is assigned to a building. So for example the forge gives an extra 15% production. Assigning an engineer to the forge would also provide an extra five iron for example. Another example I have in mind would be to create a specialist for the barracks (already done) and make it so that when that specialist is assigned the barracks gives new units 30 xp instead of 15.

Is this at all possible? I've tried messing around with tables, yield and specialist yield amongst a few, with no luck. Could this be done in LUA?

Any input would be greatly appreciated.
 
i know that you can have lua check to make sure your conditions are met for the resource bonus you want to give, just not sure if adding resources can be done.

i'd imagine it would be done with SetNumResource or ChangeNumResource, though i haven't gotten around to trying these yet
 
EDIT: I removed the code as it wasn't working to shorten the thread.

Ok I did some more digging. This post is quite long and I apologize in advance. I think I found the code that governs what specialists do in

CityView.lua. The code of interest is under the section:

-- Filled Specialist Slots

The code itself is the following:

Now in the XML file I defined my new specialist (soldier) and what resource I'd like him to produce (with a new table SpecialistSoldierYields).

I've also assigned 2 specialist slots to the palace to know if this works from the beginning. (It does, I can assign my soldier specialist to the

palace but he won't actually give me an extra resource). It all looks like this:

And I also found the following function:
function ChangeResourceAmount (string ,control)

I just need to make it all fit together.

Any help would be appreciated.

Thanks

Fred
 
have a check at the begining of each turn if there is a soldier active, if so then changeresource to the correct amount, add a flag variable that you've checked for this and added the resources.

also at the start of each turn check if there is a flag active, make sure the soldier is still active, if not remove the extra resource

the initial extra resources though would need a better event to be called in, maybe there's a onspecialistchange, something like that
 
That sounds like a great idea and I'll give it a try as plan B. I'm trying to set up an instant feedback type of change where assigning the specialist to a slot would immediately update the resource total, just like it does for gold, production, science and whatnot. Looking more at the code I posted it seems to be only related to updating the tooltip when you hover the cursor over the specialist. I don't think the code actually sets up the bonuses in game, it only updates the UI to show the changes. "ToolTipString" makes more sense now.

Thanks for your feedback.

I'll have to keep digging.
 
Thats a great idea with the specialists. :)

For immediate update to the resource try the functions SpecialistAssigned and SpecialistRemoved in the CityView.lua (i think those are the right functions). I did something about a month ago with having the courthouse produce happiness using a new yield and this method.

If you look for (greyTiger's) Courthouse mod in the mod browser then take a look at my modified CityView.lua it should be possible to do what you want.

Best of luck with the mod.
 
Hey GreyTiger thanks for the post. Unfortunately I still haven't solved the problem. From my digging it looks like resources are tied to the terrain. In order to have a resource you actually have to find it somewhere on the map first. You can modify the amount of resources by using a trait for example Russia but you can't make a resource appear out of nowhere without it being placed on the map first. This is done with AssignStartingPlots.lua, just about the most complicated file in the game. All that being said I've stopped trying to make it work. I can make a specialist do pretty much anything, as long as it has to do with gold, science, culture, etc...
 
Thanks Whys' Mod looks awesome. Shorter than I would have imagined too. I just don't have the LUA skills to pull off something like that though. Good to know it's out there.
 
Back
Top Bottom