Creating custom resource

I want to create a custom resource that is produce automatically in a factions homeworld.  For instance I want to create the resource called Soymilk.  I want each faction's homeworld to produce a specific amount say 4.  I also want to ensure that to create the larger ships hull, you would need 1 soymilk for each ship.  This way, I can limit the amount of the larger classes of ships to a specific number per factions.

Can someone point me to some resources or tutorial on how I can do this?  Maybe some tutorial on how to create custom resources and one to show how to edit ship hulls to require specific resources?

Thanks.

5,172 views 2 replies
Reply #1 Top

As far as adding a resource requirement to something, you'll want to add

    <Stats>
      <EffectType>DurantiumCost</EffectType>
      <Target>
        <TargetType>Ship</TargetType>
      </Target>
      <BonusType>Flat</BonusType>
      <Value>1</Value>
    </Stats>

to the component, replacing the effect type with the equivalent for your resource; the <Value>1</Value> line indicates the amount of the resource required (in this case, 1 unit). I am uncertain of whether or not this will work on ship hulls, and I'm not certain of whether or not you can make this happen only for one faction rather than all of them if you add this to a ship hull, as ShipHullStatDefs.XML does not appear to include separate entries for each faction. However, as ShipHullDefs.XML appears to allow you to choose which entry in ShipHullStatDefs.XML to point to, I suspect you could create a CustomSmall entry in ShipHullStatDefs.XML (or some other appropriate entry) with the resource requirement and have all the entries in ShipHullDefs.XML for your custom race point to the appropriate nonstandard entry.

I am uncertain of whether or not you can add strategic resources using planetary improvements, but if you can I suspect that what you want to add is

<EffectType>Durantium</EffectType>
<Target>
       <TargetType>StrategicResource</TargetType>
</Target>
<BonusType>Flat</BonusType>
<Value>1</Value>

with the effect type changed to reflect the appropriate resource and the value changed to reflect how much you want the improvement to provide.

As far as creating a new strategic resource goes, I would suggest starting by looking at StrategicResourceDefs.XML, copying that to a mod folder, duplicating an entry, and changing the duplicated entry to be your strategic resource. You will probably also need to edit StrategicResourceArtDefs.XML and possibly StrategicIconDefs.XML. It is possible that this might allow your strategic resource to spawn on the main map; as I've never tried this, I'm not sure.

Reply #2 Top

Thanks for that, very helpful in getting my feet wet in modding.

 

my goal is to really limit the amount warships the different factions can spawn.  Keeps the game more intimate and makes warship seem more formidable.