Modding DSS - Preview of what is possible

News about the current development of DSS.

Modding DSS - Preview of what is possible

Postby StephanieRct » Thu Feb 07, 2013 5:25 pm

I often say DSS is highly moddable. But just how moddable is that exactly? Let's see how it works.
The game data is run by Xml files that define almost everything in the game. From resources to ship components, galaxy generators, AIs, weapons, all of it. All that in a readable, thus modifiable, Xml format.
So let's see what can actually be done. Here's a xml snippet describing a resource called "Food"
Code: Select all
    <Resource id="Food" icon="data:/icon/food.png">
        <Category value="Food" />
        <Attribute value="Ration">20</Attribute>

Things are pretty much self-explanatory. Id is an internal name for reference in other parts of the data file. Volume and mass are built-in attributes and "Ration" is a custom attribute.
This custom attribute is itself described beforehand as:
Code: Select all
    <ResourceAttribute id="Ration" icon="data:/icon/Ration.png">
        <Unit />
        <UnitShort />
      A ration represent the quantity of food needed by a person per cycle.
        <DisplayBar min="0" max="1000" />

All of these attributes are only for display purposes. They don't give any meaning to the game. The meaning of "Ration" will come later in how it will be used.

This resource must be produced somehow in the game. The process of creating a "Food" is at its turn described as:
Code: Select all
    <ResourceProcess id="FoodFarming">
        <DisplayName>Grow Food</DisplayName>
        <In />
            <Resource value="Food" qty="1" />

This means it takes 30 seconds to create 1 unit of "Food" from nothing. These plants grow pretty fast!

Now, not surprisingly, food is produced in farm. Farms are components that can be built on a station hub.
Code: Select all
    <Component id="Solar_FarmRect" precompiled="data:/component/base/SolarFarm.cmp" icon="data:/icon/hydroponicfarm.png">
        <Category value="SolarHubModuleRect" />
            <ResourceProcess value="FoodFarming" autoAdd="0" autoRepeat="1" />
            <ResourceProcess value="ExoticFoodFarming" autoAdd="0" autoRepeat="1" />
            <ResourceProcess value="GrowMedicinalPlant" autoAdd="0" autoRepeat="1" />
            <Resource value="Tools" qty="30" />
            <Resource value="HullPlating" qty="20" />
            <Resource value="HumanWorker" qty="20" />
        <Attribute value="Mass">1000</Attribute>
        <Attribute value="BuildTime">30</Attribute>

The precompiled attribute refer to a 3d object file. Things inside <Job></Job> are resources the component can produce. Cost is what the component needs to be built. And there's a couple of extra attributes.

Ok, so now we have a food resource and a farm to produce it. That's great but what purpose does food serve in the game? So far it has none, so we need to give it one. What I want it to do is sustain a population in a colony station. Every cycle of 5 minutes the population must consume food, or more exactly rations. If there's not enough rations, the population will suffer and eventually die. The game does nothing of that sort yet, population and colony station will be added in the xml file. The colony station is basically another <Component> so that is fine. Population is more tricky, it's an extra logic not implemented in the game itself. That is why the game can be extended with dll files.

Dlls are extra bits of code that comes in several kind of flavors depending on their usage. Galaxy generators, AIs, traders, action buttons (e.g. move and attack commands) are all handled in separated dlls. Components can be extended as well with a dll. Thus, "pop.dll" was created with the specific logic for handling the colony population. The code essentially waits 5 minutes, then goes through the host station's resource storage for any resources that has a "Ration" attribute and consumes what it needs to sustain the current population count. It also adds the new population from births, deaths from starvation, compute moral and other population related stuff.


Here's a small subset of the API available to the dlls, it gives a good idea of what can be done with a unit (PUnit) and it's resource storage (PResourceStorage).
Code: Select all
class PUnit : public PObject{
    void moveBy(const Vector3D& aDisplacement)const;
    void setLocal(const Matrix3DAffine& aLocal)const;
    const Matrix3DAffine& getLocal()const;
    const char * getDisplayName()const;
    PObject getMainTarget()const;
    PResourceStorage getStorage()const;
    void chase(const PUnit & aTarget)const;
    void chase()const;//chase current target
    void setController(UnitController * apCtrl)const;
    UnitController * getController()const;
    bool warpTo(PCluster& aDestination       )const;
    bool moveTo(const Vector3D& aDestination )const;
    bool moveTo(const Vector3D& aDestination , const Vector3DN& aDir)const;
    bool dockTo(const PUnitStation& aDestination, bool abIsAuto)const;
    bool moveToCluster(PCluster& aDestination)const;
    bool isIdle()const;
    enum enKillOption{
        eKillOption_None = 0,
        eKillOption_Explode = 1,
        eKillOption_DropResource = 2,
        eKillOption_Default = 3
    void kill(uint32 aKillOption = eKillOption_Default)const;
    PMetaUnit getMetaUnit()const;
    template< class T >
    T *queryFirstComponentLogic()const;

class PResourceStorage{
    ResourceQtyUnit remove(const PResource& aRes, ResourceQtyUnit aQty)const;
    ResourceQtyUnit add(const PResource& aRes, ResourceQtyUnit aQty)const;
    ResourceQtyUnit getQtyCanFit(const PResource& aRes)const;
    ResourceQtyUnit getQtyCanFitCapacity(const PResource& aRes)const;
    ResourceQtyUnit getQtyOf(const PResource& aRes)const;
    ResourceVolumeUnit getSpaceLeft()const;
    bool transferTo(const PResourceStorage& aTarget)const;
    template< class T >
    bool visitAll(T aFunc)const;

All entities: units, stations, fleets, players, sectors, etc have similar interfaces. What can be done with these dlls is pretty much endless.
The API will be available to players on day 1, along with some samples.

I'm looking forward to see what you will do to this game. :D
User avatar
Site Admin
Posts: 195
Joined: Thu Mar 29, 2012 10:03 am

Re: Modding DSS - Preview of what is possible

Postby Mathias » Fri Feb 08, 2013 9:09 am

Ah, so sustaining the population is what food does. I thought that's what cats are supposed to do :P

Anyway, thanks for the article! It's fantastic. the stuff about the API blows my mind.

For anybody who is into 3D, I just wanted to add, that adding custom 3d models is very simple well. We are currently using a modified ASE exporter for 3ds max + a tool to convert .ase to .cmp, which is what DSS reads. Both will be made available at day 1 as well I assume. Once exported, an asset - the turret station hub in this case - is then descibed in .xml like this:

Code: Select all
    <Component id="TurretHub4" precompiled="data:/component/base/TurretHub4.cmp" icon="data:/icon/BeamTurret.png">
        <DisplayName>Turret Hub</DisplayName>
        <Category value="HullStationTurret" />
            <Resource value="HullPlating" qty="10" />
        <CompSlot id="Hub0" category="Turret" pre="Point001" />
        <CompSlot id="Hub1" category="Turret" pre="Point002" />
        <CompSlot id="Hub2" category="Turret" pre="Point003" />
        <CompSlot id="Hub3" category="Turret" pre="Point004" />
        <Attribute value="Mass">100000</Attribute>
        <Attribute value="Cargo">100000</Attribute>
        <Attribute value="Shield" op="Add">5000</Attribute>
        <Attribute value="ShieldRegen" op="Add">10</Attribute>
        <Attribute value="Armor" op="Add">5000</Attribute>
        <Attribute value="ArmorRegen" op="Add">10</Attribute>
        <Attribute value="DockSpace">10</Attribute>
        <Attribute value="BuildTime">30</Attribute>

<CompSlot id="Hub0" category="Turret" pre="Point001" /> refers to a hardpoint, where turrets can be placed. These are placed using point helpers in Max:
hardpoints.jpg (66.31 KiB) Viewed 8161 times

And finally in the game:
turretingame.jpg (75.42 KiB) Viewed 8161 times
User avatar
Posts: 337
Joined: Thu Apr 05, 2012 12:29 pm

Re: Modding DSS - Preview of what is possible

Postby TanC » Tue Aug 06, 2013 1:29 pm

At least the XML makes sense. :geek: I've a ways to go in deciphering the .dlls though. :oops: But it looks straightforward enough!
Corvette Pilot
Posts: 8
Joined: Tue Aug 06, 2013 12:16 pm

Return to Dev News

Who is online

Users browsing this forum: No registered users and 1 guest