Jump to content

Making a new unit to be produced at the forge


Recommended Posts

Hello,

I am just getting into modding and have looked at the wiki tutorials.  I am modding SVN.

Now, I am running into trouble in getting a unit to be produced from the gaul forge.  My intention is to make the Gaul forge produce a unit that can garrison in ally forges and give them a resource and research time discount.  I created the following directories in my new mod folder:

  • simulation/templates/units/gaul/
    • gaul_armorer_cart.xml
  • simulation/templates/structures/gaul
    • forge.xml
  • simulation/data/auras

I wasn't sure if it was necessary, but I also included the "parent" units in the mod folder directories as well.  (Do I need to do that?) So in the templates folder I have: 

  • gaul/forge.xml Parents: template_structure.xml,template_structure_military.xml, template_structure_military_forge.xml 
  • units/gaul/gaul_armorer_cart.xml Parents: template_unit.xml, template_unit_support.xml

Besides creating the structure, unit, and aura, I also edited template_structure_military.xml to allow for garrison of Support units, as that is what my new unit is.  That worked fine because I can garrison a woman in there now.

When I play as Gauls and click on the forge, there are no options to do anything and I get a bunch of errors:

GetTemplateData@gui/session/session.js:233:25
setupButton@gui/session/selectionpanels.js:984:33
setupUnitPanel@gui/session/unit_commands.js94:35
updateUnitCommands@gui/session/unit_commands.js:152:18
updateSelectionDetails@gui/session/selection_details.js:537:20
updateGUIObjects@gui/session/session.js:730:2
onSimulationUpdate@gui/session/session.js:680:2
__eventhandler54 (SimulationUpdate)@session SimulationUpdate1.1
Error calling component script function ScriptCall
Errors executing script event "SimulationUdate"
JavaScript error: gui/session/session.js:225:34

1528832337_forgewithnoabilities.thumb.png.f5e24d93c2ad8ab6519b0455a9573dfb.png

I looked at the JavaScript files but am way out of my depth in terms of knowing what to do about it.
 

 

For the unit, I intended on just using the trade cart icon and visual actor, without changing them. 

  • Do I need to make directories for the trade cart icon and visual actor and put them in my new mod folder if I am not adjusting any of their values?
  • Is there something else I need to do to make my unit appear in the gaul forge to make it producible?

 

Below is my code:

forge.xml

Spoiler

<?xml version="1.0" encoding="utf-8"?>
<Entity parent="template_structure_military_forge">
  <Identity>
    <Civ>gaul</Civ>
    <SpecificName>Gobanion</SpecificName>
  </Identity>
  <ProductionQueue/>
  <Trainer>
    <BatchTimeModifier>0.8</BatchTimeModifier>
     <Entities datatype="tokens">
        units/gaul/gaul_armorer_cart           |Update.  I corrected this from "units/gaul_armorer_cart" to indicate that the file is found in the gaul folder under units.|
        </Entities>

    </Trainer>
  <VisualActor>
    <Actor>structures/gauls/blacksmith.xml</Actor>
  </VisualActor>
</Entity>

gaul_armorer_cart.json (aura)

Spoiler

{
  "affectedPlayers": ["ExclusiveMutualAlly"],
  "affects": [ "forge" ],
  "auraDescription": "When garrisoned in an ally's forge, the Structure's technologies have −40% resource cost and −60% research time.",
  "auraName": "Products from Gaul",
  "modifications": [
    {
      "value": "Researcher/TechCostMultiplier/food",
      "multiply": 0.6
    },
    {
      "value": "Researcher/TechCostMultiplier/wood",
      "multiply": 0.6
    },
    {
      "value": "Researcher/TechCostMultiplier/stone",
      "multiply": 0.6
    },
    {
      "value": "Researcher/TechCostMultiplier/metal",
      "multiply": 0.6
    },
    {
      "value": "Researcher/TechCostMultiplier/time",
      "multiply": 0.4
    }
  ],
  "overlayIcon": "art/textures/ui/session/auras/build_bonus.png",
  "type": "garrison"
}

template_structure_military_forge.xml

Spoiler

<?xml version="1.0" encoding="utf-8"?>
<Entity parent="template_structure_military">
  <Cost>
    <BuildTime>120</BuildTime>
    <Resources>
      <wood>200</wood>
    </Resources>
  </Cost>
  <Footprint>
    <Square width="22.0" depth="22.0"/>
    <Height>12.0</Height>
  </Footprint>
  <GarrisonHolder>
    <Max>1</Max>
    <List datatype="tokens">Infantry Healer Support</List>
  </GarrisonHolder>
  <Health>
    <Max>2000</Max>
    <SpawnEntityOnDeath>decay|rubble/rubble_stone_4x4</SpawnEntityOnDeath>
  </Health>
  <Identity>
    <GenericName>Forge</GenericName>
    <SelectionGroupName>template_structure_military_forge</SelectionGroupName>
    <Tooltip>Research attack damage and damage resistance technologies.</Tooltip>
    <Classes datatype="tokens">-ConquestCritical</Classes>
    <VisibleClasses datatype="tokens">Town Forge</VisibleClasses>
    <Icon>structures/blacksmith.png</Icon>
    <RequiredTechnology>phase_town</RequiredTechnology>
  </Identity>
  <Loot>
    <wood>40</wood>
  </Loot>
  <Obstruction>
    <Static width="17.0" depth="17.0"/>
  </Obstruction>
  <ProductionQueue/>
  <Researcher>
    <Technologies datatype="tokens">
      soldier_attack_melee_01
      soldier_attack_melee_02
      soldier_attack_melee_03
      soldier_attack_melee_03_variant
      soldier_attack_ranged_01
      soldier_attack_ranged_02
      soldier_attack_ranged_03
      soldier_resistance_hack_01
      soldier_resistance_hack_02
      soldier_resistance_hack_03
      soldier_resistance_pierce_01
      soldier_resistance_pierce_02
      soldier_resistance_pierce_03
      archer_attack_spread
    </Technologies>
  </Researcher>
  <Sound>
    <SoundGroups>
      <select>interface/select/building/sel_forge.xml</select>
      <constructed>interface/complete/building/complete_forge.xml</constructed>
    </SoundGroups>
  </Sound>
  <TerritoryInfluence>
    <Radius>38</Radius>
    <Weight>30000</Weight>
  </TerritoryInfluence>
  <Vision>
    <Range>32</Range>
  </Vision>
  <VisualActor>
    <FoundationActor>structures/fndn_5x5.xml</FoundationActor>
  </VisualActor>
</Entity>

 


gaul_armorer_cart.xml

Spoiler

<?xml version="1.0" encoding="utf-8"?>
<Entity parent="template_unit_support">
    <Footprint replace="">
        <Square width="3" depth="6"/>
        <Height>4</Height>
    </Footprint>
    <Auras datatype="tokens">
        units/gaul_armorer_cart
    </Auras>
    <Cost>
        <BuildTime>15</BuildTime>
        <Resources>
            <food>50</food>
            <wood>100</wood>
            <metal>300</metal>
        </Resources>
    </Cost>
    <Health>
        <Max>100</Max>
    </Health>
    <Identity>
        <Civ>gaul</Civ>
        <Classes datatype="tokens">-ConquestCritical</Classes>
        <GenericName>Armorer</GenericName>
        <SpecificName>TBD</SpecificName>
        <SelectionGroupName>gaul_armorer_cart</SelectionGroupName>
        <Icon>units/celt_support_trader.png</Icon>
        <Tooltip>Garrison in an ally's forge to give them a discount.</Tooltip>
    </Identity>
    <VisualActor>
        <Actor>units/celts/trader.xml</Actor>
    </VisualActor>
    <Loot>
        <xp>10</xp>
        <food>10</food>
        <metal>100</metal>
    </Loot>
    <Position>
        <Anchor>pitch</Anchor>
    </Position>
    <Selectable>
        <Overlay>
            <Texture>
                <MainTexture>128x256/ellipse.png</MainTexture>
                <MainTextureMask>128x256/ellipse_mask.png</MainTextureMask>
            </Texture>
        </Overlay>
    </Selectable>
    <Sound>
        <SoundGroups>
            <order_trade>voice/{lang}/civ/civ_{phenotype}_trade.xml</order_trade>
            <trained>interface/alarm/alarm_create_worker.xml</trained>
        </SoundGroups>
    </Sound>
    <UnitAI>
        <CanGuard>false</CanGuard>
        <CanPatrol>false</CanPatrol>
        <Formations disable=""/>
    </UnitAI>
    <Vision>
        <Range>60</Range>
    </Vision>
</Entity>

 

Thank you so much for taking the time.

 

Edited by Philip the Swaggerless
update in the code of forge.xml
  • Like 3
Link to comment
Share on other sites

6 hours ago, Philip the Swaggerless said:

Do I need to do that?

Nope, you only need to include templates you change.

6 hours ago, Philip the Swaggerless said:

Do I need to make directories for the trade cart icon and visual actor and put them in my new mod folder if I am not adjusting any of their values?

Nope.

6 hours ago, Philip the Swaggerless said:

forge.xml

Correct (apart from that you don't need the ProductionQueue element, since that is defined in one of its parents.

6 hours ago, Philip the Swaggerless said:

gaul_armorer_cart.json (aura)

Reads correct.

6 hours ago, Philip the Swaggerless said:

template_structure_military_forge.xml

Correct (one can leave out the Healer class, since healers also have the Support class).

 

I feel like the clue is missing in your quoted errors, can you perhaps upload your interestinglog.html?

 

Oh, and nice you started modding! :D More modders is more better.

Link to comment
Share on other sites

10 hours ago, Philip the Swaggerless said:

I am just getting into modding and have looked at the wiki tutorials.  I am modding SVN.

This page is valuable it lists the components that can be added to entities and the XML syntax for their initialisation data.

A small collection of informative links can be found on the FAQ page

Link to comment
Share on other sites

Okay, I realized my error.  I had the directory wrong for the location of the aura file in my cart unit template code.  I've fixed that.  I can now produce the cart in-game and garrison it into an ally's forge.  However, there is no discount from the aura I made.  I'm pretty sure it is because I just typed "forge" in it's "affects line."

"affects": [ "forge" ],

Having looked at the components page that @Langbart so kindly linked, I see that "affects" requires a class.  So I need a class that will designate all forges but no other structure.  How do I achieve that?  Can I create a class?

18 hours ago, Freagarach said:

Correct (one can leave out the Healer class, since healers also have the Support class).

Actually, prior to adding "Support", I was not able to garrison a woman into the forge.  Women have the Support class.  After adding the Support class to the forge template I can now garrison women.  So I reasoned that because I made the cart as a Support class unit I would need to include that in the garrison part of the forge template.

 

11 hours ago, Gurken Khan said:

@Philip the SwaggerlessI have no idea, but maybe the Mauryan teacher can teach you something, if you can find out what he is doing in the forge. Good luck!

Yes, he was my cheat sheet. :) 

Link to comment
Share on other sites

5 hours ago, Philip the Swaggerless said:

Actually, prior to adding "Support", I was not able to garrison a woman into the forge.  Women have the Support class.  After adding the Support class to the forge template I can now garrison women.  So I reasoned that because I made the cart as a Support class unit I would need to include that in the garrison part of the forge template.

Yes, but your template also has the Healer class as being able to garrison. Now, healers have both the Healer and the Support class. You if you would only specify the Support class, healers still can garrison. So it becomes: "Infantry Support".

5 hours ago, Philip the Swaggerless said:

Having looked at the components page that @Langbart so kindly linked, I see that "affects" requires a class.  So I need a class that will designate all forges but no other structure.  How do I achieve that?  Can I create a class?

If you take a look at the Identity-node in template_structure_military_forge.xml one can see that there are classes defined. It should work when you use the "Forge" class as opposed to "forge".

  • Thanks 1
Link to comment
Share on other sites

7 hours ago, Freagarach said:

Yes, but your template also has the Healer class as being able to garrison. Now, healers have both the Healer and the Support class. You if you would only specify the Support class, healers still can garrison. So it becomes: "Infantry Support".

Ah, now I get it, lol. 

7 hours ago, Freagarach said:

If you take a look at the Identity-node in template_structure_military_forge.xml one can see that there are classes defined. It should work when you use the "Forge" class as opposed to "forge".

Oh yes,  there it is under "visible classes."  Nice,  thank you. 

Link to comment
Share on other sites

Just when I thought I had it...

I am trying to make it so that only allies can benefit from the cart garrison aura, not yourself.  Is it the case that type garrison auras affect the garrisoned building regardless of the "affectedPlayers" line?  I thougtht "ExclusiveAlly" would mean only my ally gets the bonus but I don't.  I even tried changing it to just "Enemy" and it still gave the discount myself to my ally.

Link to comment
Share on other sites

11 hours ago, Philip the Swaggerless said:

Just when I thought I had it...

I am trying to make it so that only allies can benefit from the cart garrison aura, not yourself.  Is it the case that type garrison auras affect the garrisoned building regardless of the "affectedPlayers" line?  I thougtht "ExclusiveAlly" would mean only my ally gets the bonus but I don't.  I even tried changing it to just "Enemy" and it still gave the discount myself to my ally.

I was wondering that too yesterday, but the "affectedPlayers" is not used for garrisoned-auras. That might or might not be called a bug. At least it is a feature that is worth implementing. -> Would you like to create a ticket on trac.wildfiregames.com for it, please?

Link to comment
Share on other sites

7 hours ago, Freagarach said:

I was wondering that too yesterday, but the "affectedPlayers" is not used for garrisoned-auras. That might or might not be called a bug. At least it is a feature that is worth implementing. -> Would you like to create a ticket on trac.wildfiregames.com for it, please?

I see.  Okay, I will create a ticket when I get the email to reset my password. I forgot it already lol  :frusty:

Link to comment
Share on other sites

  • 2 weeks later...
On 11/03/2022 at 12:06 AM, Philip the Swaggerless said:

Entity parent="template_structure_military_forge">
  <Identity>
    <Civ>gaul</Civ>
    <SpecificName>Gobanion</SpecificName>
  </Identity>
  <ProductionQueue/>
  <Trainer>
    <BatchTimeModifier>0.8</BatchTimeModifier>
     <Entities datatype="tokens">
        units/gaul/gaul_armorer_cart           |Update.  I corrected this from "units/gaul_armorer_cart" to indicate that the file is found in the gaul folder under units.|
        </Entities>

    </Trainer>
  <VisualActor>
    <Actor>structures/gauls/blacksmith.xml</Actor>
  </VisualActor>

I am not an expert either but the <ProductionQueue/> element seems strange to me. Shouldn't there be an opening and a closing statement like  <VisualActor>  </VisualActor> ?

Link to comment
Share on other sites

26 minutes ago, LetswaveaBook said:

<ProductionQueue/>

That means an empty production queue, i.e. the building doesn't produce anything. If you want to train units, then:

<ProductionQueue>

<Entities data='tokens'>

unit_a

</Entities>

</ProductionQueue>

In A26 it will be replaced with <Trainer> tag

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

5 hours ago, LetswaveaBook said:

I am not an expert either but the <ProductionQueue/> element seems strange to me. Shouldn't there be an opening and a closing statement like  <VisualActor>  </VisualActor> ?

 

4 hours ago, Yekaterina said:

That means an empty production queue, i.e. the building doesn't produce anything. If you want to train units, then:

<ProductionQueue>

<Entities data='tokens'>

unit_a

</Entities>

</ProductionQueue>

In A26 it will be replaced with <Trainer> tag

Thank you guys. I should've updated here, I was able to get it working.  The reason it wasn't working was because of the capitalization of Forge class

  • Like 1
Link to comment
Share on other sites

16 hours ago, LetswaveaBook said:

I am not an expert either but the <ProductionQueue/> element seems strange to me. Shouldn't there be an opening and a closing statement like  <VisualActor>  </VisualActor> ?

16 hours ago, Yekaterina said:

That means an empty production queue, i.e. the building doesn't produce anything.

The ProductionQueue is empty (A26) because the component is merely the user-facing interface now. It makes sure you can research technologies (Researcher component) and train entities (Trainer component) alongside eachother. In the future the element may get some content again (at least I have some ideas for that, so it depends on time).

  • 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...