Jump to content

Priest Praying for Resources


Recommended Posts

I would like to develop the following feature myself if I could figure out the api and logic around the action development.I was thinking of adding a new function to the priest unit. I wish to add the ability that he pray for resources. The action will put the priest in a praying position that every 1 minute the person increase one of his resources (wood or food or metal or stone) by a defined amount.

I would love and comment about this feature, any instruction how to develop it. I am trying to figure the api and the changes I need to do using

http://trac.wildfiregames.com/ticket/999 since that is the implementation of heal for the priest but since no documentation on the apis is available I am getting stuck.

Link to comment
Share on other sites

I would like to develop the following feature myself if I could figure out the api and logic around the action development.I was thinking of adding a new function to the priest unit. I wish to add the ability that he pray for resources. The action will put the priest in a praying position that every 1 minute the person increase one of his resources (wood or food or metal or stone) by a defined amount.

I would love and comment about this feature, any instruction how to develop it. I am trying to figure the api and the changes I need to do using

http://trac.wildfiregames.com/ticket/999 since that is the implementation of heal for the priest but since no documentation on the apis is available I am getting stuck.

First of all: please note that this functionality most likely will not be added into 0 A.D. even if there will be a patch for it, because we already have trading which is basically the same generating-resources-from-nothing but with more strategic elements, like you need to carefully place markets (on the maximum possible distance to get maximal gain (which raises non-linear depending on distance), but making sure that trade routes are safe enough or risking) or trade with allies which provide more gain etc. And if I correctly understand your idea you just need to create a priest, move him into a safe place and start generating resources.

But if you want to implement this just to make yourself familiar with the code or want to make a mini-mod, this sounds like a good exercise. This is probably a good document to get acquainted with simulation architecture: http://trac.wildfiregames.com/wiki/SimulationArchitecture .

From quick thinking you will need to implement following things: a simulation component, unit ai functionality, gui representation and interaction between simulation and gui parts (via GuiInterface and commands).

More detailed:

Simulation part:

1. Add a simulation component like 'Priest', it can contain some settings and logic (see binaries/data/mods/public/simulation/components)

2. Add your component to some templates (see binaries/data/mods/public/simulation/templates, probably to binaries/data/mods/public/simulation/templates/template_unit_support_healer.xml), this will define which units should have this functionality

3. Pass some info from simulation scripts to gui scripts via binaries/data/mods/public/simulation/components/GuiInterface.js : GetEntityState , like:


var cmpPriest = Engine.QueryInterface(ent, IID_Priest);
if (cmpPriest)
{
ret.priest = <...>
}

4. Add a command into binaries/data/mods/public/simulation/helpers/Commands.js : ProcessCommand (this is what will be called by gui part):


case "pray":
<...>

5. Implement UnitAI functionality (binaries/data/mods/public/simulation/components/UnitAI.js): what unit should do in the praying state (i.e. generate resources after time intervals, this will use functionality from Priest component)

Gui part:

Add a command into binaries/data/mods/public/gui/session/utility_functions.js : getEntityCommandsList , like:


if (entState.priest)
{
commands.push({
"name": "pray",
"tooltip": "Pray for resources",
"icon": "pray.png"
});
}

I'm not sure, but I think this should display a button under unit's portrait and bind click to it with sending 'pray' command into simulation part.

In all these places you can look how other things around are implemented.

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