Enabling arbitrary units to gather and claim treasures

– by BilboBeutlin
Created: 8th June 2006
Last Edited: 8th June 2006

There is a treasure without guardians, but no explorer or settler nearby to claim it?

Ever wondered what to do with scouts after the map is explored, even Capitol’s Spies are enabled? They hang around, but now can be of service.

This guide shows how to give any unit the ability to collect nuggets and gather from farms.

0) The Theory
Q: Can I give any unit an arbitrary ability?
A: In principle: Yes (Radio Eriwan *g*).

At least the known units’ abilities are ‘exchangeable’ – can be adapted on arbitrary units. With tricks (and advanced know-how) it’s even possible to create ‘new’ effects (actions). But of course one has to know what the game engine makes possible. And just that’s the secret of modding gurus … to analyze and understand the code – and to modify it to sometimes unexpected results. But certainly we can’t create some totally new things – the basics must be within the given code.

No action is executed if it isn’t explicitely defined in the unit’s anim file. The ‘secret’ is the <anim> trigger

    <tag type="what">when</tag>

what is the instruction for the game engine which action should be processed, when is the point in time within the animation (loop).

This anim gets ‘fine-tuned’ in the tactics file mainly with instructions for the (havoc) physics, damage engine or other methods like gather, heal, build, …

In most cases that was enough – the unit’s proto merely adjusts some values or adds appropriate tags/flags to make the action properly working.

1) The Prototype
We begin with the easiest modification: the unit’s proto in Data\proto.xml

Claiming nuggets needs no further definitions, this will be made later in tactics and anim file.

Gathering requires some additional statements, we have to define the ‘CarryCapacity’ for each ressource. The value isn’t important, we only have to make sure that the unit can carry a certain ressource at all. Depending from wanted ressource we add:

    <CarryCapacity resourcetype ='Food'>1.00</CarryCapacity>
    <CarryCapacity resourcetype ='Wood'>1.00</CarryCapacity>
    <CarryCapacity resourcetype ='Gold'>1.00</CarryCapacity>

For the gathering rate(s) the tactics values are taken, but we may insert optionally eg.

    <ProtoAction>
        <Name>Gather</Name>
        <Rate type ='Mill'>1.25</Rate>
        <Rate type ='Plantation'>1.25</Rate>
    </ProtoAction>

2) The Tactics File
Every proto action needs a definition/reference in the unit’s tactics file.
We find the unit’s associated tactics file(name) in the proto tag <Tactics>{unit}.tactics</Tactics>. The tactics file’s home location is the directory Data\tactics\. But if not yet edited, it is probably still in a .bar archive. Normally it has to be extracted from Data\Data.bar – but check also DataP.bar for a perhaps patched version.
Note, that some units have a shared tactics file which is used concurrently by other units. In this case it could be advantageous to create a unit-unique tactics file: after editing save the tactics file under different {name}.tactics and adapt the proto tag <Tactics> accordingly.

For the nugget/treasure action we add

    <action>
        <name>Discover</name>
        <type>Discover</type>
        <anim>Pickup</anim>
        <maxrange>0.2</maxrange>
        <rate type="AbstractNugget">1.0</rate>
        <active>0</active>
    </action>

<name> is the reference from/to proto, <anim> must be a valid entry in anim file.
<active>0 means: the action isn’t allowed by default, has to be enabled in techtree.

For the farm gathering we add

    <action>
        <name stringid="42178">Gather</name>
        <type>Gather</type>
        <anim>GatherFarm</anim>
        <maxrange>0.5</maxrange>
        <rate type="Plantation">1.0</rate>
        <rate type="Mill">1.0</rate>
    </action>

For implementing more methods than only farm gathering, see for reference Data\tactics\settler.tactics

Finally the actions have to be defined in each <tactic> section – we add

        <action>Gather</action>
        <action>Discover</action>

3) The Anim File

The rationale for adding new anims is the fact, that a model (skeleton) can use ‘loaned’ external animation routines and can have also additional attachments.
The proto tag <AnimFile> links to the corresponding animation file in AoE3’s folder Art\. The anim files are usually in Art\Art1.bar, but check also DataP.bar for possible updates.

The basic outlook is determined in the section <component> ModelComp ... <assetreference type="GrannyModel"> . Usually each anim uses this in the statement <component>ModelComp. The pure animation itself is defined in <assetreference type="GrannyAnim">. For this GrannyAnim we can use arbitrary granny files from other units or the animation library – certainly they should be suitable for our model.

Each <anim> can have different attachments like weapons, tools, bags, hats, … The difficulty is to determine the hooks/bones model<->attachment to get a satisfying outlook. We can lookup in other anim files or use the GrannyViewer to find suitable connection points.

The nugget pickup anim is ‘loaned’ from explorer animation. We insert

    <anim>
        Pickup
        <assetreference type="GrannyAnim">
            <file>animation_library\explorer\pickup_explorer_A</file>
            <tag type="SpecificSoundSet" checkvisible="1" set="GatherFruit">0.35</tag>
        </assetreference>
        <component>ModelComp</component>
    </anim>

The gather anim is much more complex. Just the apparent most trivial things often have the most complicated structure. All gather animations have several sub-animations which have to be implemented. For our scout we want to use farm gathering only. Here we already need a whole bunch of sub-anims. We insert

    <anim>
        GatherFarm
        <assetreference type="GrannyAnim">
            <file>animation_library\villager\villager_male_gatherfarmhoe</file>
            <tag type="SpecificSoundSet" checkvisible="1" set="GatherFarm">0.18</tag>
            <tag type="SpecificSoundSet" checkvisible="1" set="GatherFarm">0.30</tag>
            <tag type="SpecificSoundSet" checkvisible="1" set="GatherFarm">0.40</tag>
            <tag type="SpecificSoundSet" checkvisible="1" set="GatherFarm">0.65</tag>
            <tag type="SpecificSoundSet" checkvisible="1" set="GatherFarm">0.76</tag>
            <tag type="SpecificSoundSet" checkvisible="1" set="GatherFarm">0.89</tag>
        </assetreference>
        <assetreference type="GrannyAnim">
            <file>animation_library\villager\villager_male_gatherfarmsow</file>
        </assetreference>
        <assetreference type="GrannyAnim">
            <file>animation_library\villager\villager_male_gatherfarmweed</file>
        </assetreference>
        <component>ModelComp</component>
    </anim>
    <anim>
        GatherFarmWalk
        <assetreference type="GrannyAnim">
            <file>animation_library\villager\villager_male_gatherfarmwalk</file>
            <tag type="FootstepLeft" footprinttype="HumanLeft">0.20</tag>
            <tag type="FootstepRight" footprinttype="HumanRight">0.50</tag>
        </assetreference>
        <component>ModelComp</component>
    </anim>
    <anim>
        GatherFarmHoe
        <assetreference type="GrannyAnim">
            <file>animation_library\villager\villager_male_gatherfarmhoe</file>
            <tag type="SpecificSoundSet" checkvisible="1" set="GatherFarm">0.18</tag>
            <tag type="SpecificSoundSet" checkvisible="1" set="GatherFarm">0.30</tag>
            <tag type="SpecificSoundSet" checkvisible="1" set="GatherFarm">0.40</tag>
            <tag type="SpecificSoundSet" checkvisible="1" set="GatherFarm">0.65</tag>
            <tag type="SpecificSoundSet" checkvisible="1" set="GatherFarm">0.76</tag>
            <tag type="SpecificSoundSet" checkvisible="1" set="GatherFarm">0.89</tag>
        </assetreference>
        <component>ModelComp</component>
    </anim>
    <anim>
        GatherFarmSow
        <assetreference type="GrannyAnim">
            <file>animation_library\villager\villager_male_gatherfarmsow</file>
        </assetreference>
        <component>ModelComp</component>
    </anim>
    <anim>
        GatherFarmWeed
        <assetreference type="GrannyAnim">
            <file>animation_library\villager\villager_male_gatherfarmweed</file>
        </assetreference>
        <component>ModelComp</component>
    </anim>

If you want to add other gathering methods like eg. lumbering, mining, hunting,… you have to insert appropriate anims – take villager anims as template.

In this example I have waived attachments like eg. a hoe. It didn’t fit really – sometimes the hoe was hovering above head and other ugly appearances. In doubt the pure anim without attachment looks better than a filthy improvisation.