Jump to content

How to show "killed units" counted in resources in post-game Summary?


Recommended Posts

Hello,

I'm new here and I would like to participate in some game details, especially on the post-game summary screen.

Currently working on a simple score system as described in another topic:

([Total number of resources ever gathered] + [enemy units and buildings destroyed in resource value] + [percentage map explored]) / divisor

I'm stuck at the second part:

[enemy units and buildings destroyed in resource value]

There is no such information in simulation/components/StatisticsTracker.js

Since I'm not a experienced programmer, is there anyone who know how to do this?

Regards

82XdSl.jpg

Edited by EMontana
Link to comment
Share on other sites

I don't know how to do it the best way, but I can tell you what I would try first.

In StatisticsTracker.js it already counts killed units and buildings. This needs to be extended to count the resources these units cost.

The cost for units can be found in the unit templates: 0ad/binaries/data/mods/public/simulation/templates

But maybe there's already a function that can be used for that. Probably you can find it in the AI scripts if they try to get enough resources to get a certain building or unit.

The question is if it should always count the original cost of units or if it should count what the enemy actually paid for the unit. This could differ if we get technologies that reduce costs for units.

Link to comment
Share on other sites

I think you can get the cost of a killed unit in StatisticsTracker.KilledEntity this way:


var cmpCost = Engine.QueryInterface(targetEntity, IID_Cost);
var costs = cmpCost.GetResourceCosts();

See binaries/data/mods/public/simulation/components/Cost.js for details.

There is already cmpTechnologyManager involved in Cost.prototype.GetResourceCosts, I'm not sure how the technology manager works, but I think it will return the current cost of unit/building of such type, i.e. how much the entity will cost if it will be created at the moment of the function call.

If you want to get the original cost, you can write another getter in Cost component to return unchanged costs from the template.

Finally I think the cost which was actually paid when unit/building was produced isn't stored anywhere, so you have to store it somewhere at the moment of building construction/unit training if you want to retrieve it later when the entity is killed/destroyed.

But for general statistics it should be ok to use original numbers from templates.

Link to comment
Share on other sites

  • 2 weeks later...

I think you can get the cost of a killed unit in StatisticsTracker.KilledEntity this way:

var cmpCost = Engine.QueryInterface(targetEntity, IID_Cost);

var costs = cmpCost.GetResourceCosts();

Thanks, that is what I've been looking for!

We now have 4 new counters in StatisticsTracker.js:

- unitsLostValue

- enemyUnitsKilledValue

- buildingsLostValue

- enemyBuildingsDestroyedValue

And a new tab in post-game summary screen named "Score", wich shows:

- economy score

- military score

- technology score

- total score

http://trac.wildfire...com/ticket/1721

Edited by EMontana
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...