IPB Style© Fisana

Jump to content


Priest Praying for Resources


  • Please log in to reply
3 replies to this topic

#1 Trumbun

Trumbun

  • Community Newbie

  • Tiro
    (2 posts)

Posted 01 April 2012 - 01:51 PM

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



#2 V4ru

V4ru

  • Community Members

  • Tiro
    (6 posts)

Posted 01 April 2012 - 06:20 PM

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

#3 fcxSanya

fcxSanya

  • WFG Programming Team

  • Centurio
    (646 posts)

Posted 01 April 2012 - 06:22 PM

View PostTrumbun, on 01 April 2012 - 01:51 PM, said:

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

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.
Alexander Olkhovskiy [ aka fcxSanya ]
Wildfire Games Programmer
E-mail: fcxsanya at wildfiregames dot com

#4 Trumbun

Trumbun

  • Community Newbie

  • Tiro
    (2 posts)

Posted 03 April 2012 - 06:05 AM

Thanks fcxSanya.

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users