Resource production for buildings like horses for stables.

Johnen

Chieftain
Joined
Jul 27, 2013
Messages
41
Hello! I'd like to know how would it be possible to code certain buildings to produce resources, like having stables grant a steady income of +1 horses?
 
So this is kind of tricky. The basic answer is you need a Modifier that adds the resource when the building is built. The modifier I think you need is MODIFIER_SINGLE_CITY_GRANT_RESOURCE_IN_CITY.

The hard part tho is dealing with the possibility of the player selling the building and building it a second time. In theory you'd want to delete the resource when they sell the building, but I dont know if thats possible to do.
 
I've already figured it out and got a stable to actually give you the horse resource, so once you build it you get horses and they are now fully removed from the map.
 
I've already figured it out and got a stable to actually give you the horse resource, so once you build it you get horses and they are now fully removed from the map.

And how do you deal with the problems that isau mentioned?
 
And how do you deal with the problems that isau mentioned?

Here's what I added to the Buildings file:

Code:
    <Modifiers>
       <!-- Stable horse resource -->
       <Row>
           <ModifierId>STABLE_GRANT_HORSES</ModifierId>
           <ModifierType>MODIFIER_SINGLE_CITY_GRANT_RESOURCE_IN_CITY</ModifierType>
       </Row>
    </Modifiers>

Code:
    <ModifierArguments>
        <!-- Adjust stable horses -->
        <Row>
            <ModifierId>STABLE_GRANT_HORSES</ModifierId>
            <Name>ResourceType</Name>
            <Value>RESOURCE_HORSES</Value>
        </Row>
        <Row>
            <ModifierId>STABLE_GRANT_HORSES</ModifierId>
            <Name>Amount</Name>
            <Value>1</Value>
        </Row>
    </ModifierArguments>

Code:
    <BuildingModifiers>
        <!-- Adjust city stable horse modifier -->
        <Row>
            <BuildingType>BUILDING_STABLE</BuildingType>
            <ModifierId>STABLE_GRANT_HORSES</ModifierId>
        </Row>
    </BuildingModifiers>

That's about it. I'm also pretty sure that someone could also tinker with PrereqBuilding="------------" for units so that you'd need certain district improvements before you can build specific units in a city. It makes no sense that you can build some horsemen in a city with no stable or tanks in a city with no factory but right now I ran in to a major problem.
 
Back
Top Bottom