EMontana Posted November 4, 2012 Report Share Posted November 4, 2012 (edited) 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]) / divisorI'm stuck at the second part:[enemy units and buildings destroyed in resource value]There is no such information in simulation/components/StatisticsTracker.jsSince I'm not a experienced programmer, is there anyone who know how to do this?Regards Edited November 6, 2012 by EMontana Quote Link to comment Share on other sites More sharing options...
Yves Posted November 5, 2012 Report Share Posted November 5, 2012 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/templatesBut 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. Quote Link to comment Share on other sites More sharing options...
EMontana Posted November 5, 2012 Author Report Share Posted November 5, 2012 Thanks, I'll take a look in the AI scripts.To answer your question. I think it should count what the enemy actually paid for the unit, since we want to know how many of the enemy's recources we have destroyed.But for now I will stick to the original cost.Regards Quote Link to comment Share on other sites More sharing options...
fcxSanya Posted November 6, 2012 Report Share Posted November 6, 2012 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. Quote Link to comment Share on other sites More sharing options...
EMontana Posted November 16, 2012 Author Report Share Posted November 16, 2012 (edited) 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- enemyBuildingsDestroyedValueAnd a new tab in post-game summary screen named "Score", wich shows:- economy score- military score- technology score- total scorehttp://trac.wildfire...com/ticket/1721 Edited November 16, 2012 by EMontana Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.