Sign in to follow this  
Followers 0
Trumbun

Priest Praying for Resources

4 posts in this topic

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.

Share this post


Link to post
Share on other sites

Increasing the speed of gathering a resource for a amount of time would be more realistic in my opinion, rather than giving instant resources.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Thanks fcxSanya.

About the conversion in the forum I think some already suggested it for building etc.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0