Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

modding question

A topic by DexLex created Nov 22, 2017 Views: 601 Replies: 9
Viewing posts 1 to 4
(3 edits)

hi, how i can add my building\unit to race? and resources in existing biome?

as I understand include availables in "h_r_human" file. why not include in building\unit scripts, and resources discription include biomes list.

Developer

I really should have gotten around to documenting the XML format, but it's tedious work.

So, you want to add a building/unit to an existing race? "h_r_human" is the race definition. The "available_unit" entries aren't used that much, only for determining what settlers the race can produce. "available_structure" is the more important one, as that populates the list of structures you can place. New units should be added through a structure. The "id" attribute on "available_structure" needs to correspond with the "id" on a "structure_data" element somewhere in the xml files. The actual names of the files are only important for over-writing files through mods, you can name a new XML file whatever you'd like.

Adding a new Structure

  1. Crate a manifest file for the mod (you can copy and modify manifest.xml in BaseMod.zip)
  2. Create a new XML file, it should contain "game_data" at the root, then the "structure_data" for your new structure.
  3.  Copy "h_r_human" into your mod, and add a new "available_structure" element, with an "id" matching that of your new structure.
  4. Create a zip archive (it has to be a zip, not a rar) of the files in the mod.
  5. Put the zip file in the "mods" folder and load it.

Adding a New Unit

  1. Follow the same steps as "Adding a new Structure", but don't create the zip archive yet.
  2. Define the new unit in a new file, with "game_data" at root, and "unit_data" underneath it. "h_u_militia" is a good example to follow.
  3. In the new structure, add the ability to support the new unit. Look in "h_s_barracks_melee" for an example. You need a "unit_support" element in the "operation" element, with the "unit" attribute matching the "id" of the new unit added in step 2.
  4. Create and load the zip file, as steps 4 & 5 in "Adding a new structure"


When you build that new structure it will train and support he new unit.

Note: "h_s_barracks_melee", and many of the other structure definition files in BaseMod.zip contain multiple structure definitions. You can do this if you like, I find it handy to keep the entire upgrade chain of a structure type together.

Hopefully this clears things up a little.

Developer

Adding new Resources

This is more of a multi-step process.

  1. Create a new data file (again with "game_data" at root), and add the resource element: <resource name="My New Resource" />.
  2. Define the new terrain (this can be in the same data file, or another one): <terrain id="my_new_resource_terrain" image="t_new_resource" cleared_image="t_new_resource" map_image="map_grass" is_walkable="true" is_swimable="false" move_cost="1" resource="My New Resource"/>
    1. The values of "image" and "cleared_image" should correspond to an image file in the mod.
    2. The value of "resource" should be the same as the name of your new resource.
  3. Copy "wg_biomes" into your mod, and add the terrain to whatever biomes you want.
  4. Zip and load the mod as noted in my previous reply.

Side Note: Thanks for asking these questions, it's made me realize how crummy the ModApi is for modifying data instead of creating new data. I'll work up a better system for this but it will probably be a few weeks.

thanks for the side note.

 in biome worldgen <noise_mapping id="oretype" ideal_value="X" /> what is it? 

when one value used, generate first mod biome and not generate other.

Developer

The world generator is based on noise maps (here's an overview) that have values between 0 and 1, there are several maps defined in "wg_noisemaps" in BaseMod.zip. (you can add new ones too). "noise_mapping" maps the values of noise maps to a biome, when the world is generating biomes are picked based on their noise mappings. The biome closest to all of it's "ideal_value"s is chosen.

desert, for example has:

<noise_mapping id="height" ideal_value="0.6" />
<noise_mapping id="rain" ideal_value="0.0" />

That means that an area that's fairly high in elevation and low in rainfall will tend to be desert. 

For comparison, grassland has:

<noise_mapping id="height" ideal_value="0.6"/>
<noise_mapping id="rain" ideal_value="0.4"/>

Both of these biomes have the same value for height, but different values for rain. If the "rain" noise map has a value of 0.1 in the area, then "desert" will be a better match, and will be picked. If the "rain" noise map has a value of "0.3" in the area, then "grassland" will be a closer match.

The noise mapping you pasted, uses the "oretype" noise map. That noise map controls what type of ore-type resources appear in the ground. This tends to make some areas rich in limestone, and others rich in copper.

Does that all make sense?

yeah thanks.

(3 edits)

hello again. new mutate data question. how i can smaller this?

<mutators>
    <add_element parent_type="race" parent_id_attribute="id" parent_id_value="race_human">
        <available_structure id="human_cm"/>
    </add_element>
    <add_element parent_type="race" parent_id_attribute="id" parent_id_value="race_human">
        <available_structure id="human_tm"/>
    </add_element>
    <add_element parent_type="race" parent_id_attribute="id" parent_id_value="race_human">
        <available_structure id="human_wb"/>
    </add_element>
    <add_element parent_type="race" parent_id_attribute="id" parent_id_value="race_human">
        <available_structure id="human_bs"/>
    </add_element>
</mutators>

below not work (work only "human_cm")

<mutators>
    <add_element parent_type="race" parent_id_attribute="id" parent_id_value="race_human">
        <available_structure id="human_cm"/>
        <available_structure id="human_tm"/>
        <available_structure id="human_wb"/>
        <available_structure id="human_bs"/>
    </add_element>
</mutators>

and, structure data "needs_road_access" not working? i set true and nothing changes.

ps: in some cases, when click on error view in main menu, game crashes and crash log full spam. sample:

<mutators>
    <add_element parent_type="race" parent_id_attribute="id" parent_id_value="race_human">
        <available_structure id="human_tm" id="human_wb" id="human_bs" id="human_cm"/>
    </add_element>
</mutators>
Developer

Right now add_element will only add the first descendant. That was the simplest approach from a code standpoint. I could make it able to add multiple, but it doesn't seem like that big an issue to me.

needs_road_access is only used for UI feedback for the player. If a structure has needs_road_access set to true, then you'll see a warning icon in the game if the structure doesn't have a walkable hex (road or empty) adjacent to it.

<available_structure id="human_tm" id="human_wb" id="human_bs" id="human_cm"/>

Duplicate attributes aren't allowed in XML, and due to the way the data mutators are executed that XML file is parsed (and throws an error) for every datafile loaded.

Did I get everything? Thanks for all of the questions, by the way.

oh okay. 
is there a possibility add requirements building beside? (bridge required road or gate \ watermill required road to get sprite position\ or  if there is a nearby river, farm more produces food )

Developer

I'm planning on something like that for the Boats Update. If you have something specific in mind I could slip it in earlier.