Jump to content

pop-chart: Total population in game summary


dpikt
 Share

Recommended Posts

Download here: https://github.com/dpikt/pop-chart

A mod that adds a chart for total population to the game summary. I couldn't find an existing mod that did this so I created my own :) 

chart.thumb.jpg.ae9173f3128257a8cf271b575c412344.jpg

I haven't tested it out on any machine other than my own, so let me know if you have trouble running it. Any other feedback appreciated as well. Cheers!

  • Like 3
  • Thanks 1
Link to comment
Share on other sites

Do domestic animals count towards unitsKilled or unitsLost? If not then it is fine.

Edit, seems like its fine:

	if (!cmpUnitEntityIdentity.HasClass("Domestic"))
		++this.unitsTrained.total;
//...
	if (cmpLostEntityIdentity.HasClass("Unit") && !cmpLostEntityIdentity.HasClass("Domestic"))
	{
		for (let type of this.unitsClasses)
			this.CounterIncrement(cmpLostEntityIdentity, "unitsLost", type);

I think the only thing that could add discrepancies are units that account for more than 1 population.

The dog is an issue tho, not Domestic.

Edited by badosu
  • Like 1
Link to comment
Share on other sites

@badosu good call on the dogs. That will make the count quite inaccurate in games where Britons players go with that strategy. 

Overall, the mod as-is is kind of a hack... ideally population count would be added as one of the player state "sequence" stats so we could get a more accurate number. Unfortunately that's a little beyond my understanding of the game code at the moment, but I'll take another crack at it this weekend. Also happy to merge a PR.

Link to comment
Share on other sites

If I understand correctly, what your mod is doing is add a “units trained minus units lost” graph? In that case the values are strictly incorrect (starting units are not trained, therefore the graph starts at 0). Moreover, units you delete yourself don't count towards “units lost”.

Link to comment
Share on other sites

13 hours ago, dpikt said:

Unfortunately that's a little beyond my understanding of the game code at the moment, but I'll take another crack at it this weekend.

You can take a look at StatisticsTracker.js -- especially at the difference how e.g. "lootCollected": this.lootCollected and "percentMapExplored": this.GetPercentMapExplored() are obtained -- and at Player.js. Those should contain (nigh) all information you need.

Feel free to ask questions! (You can also join #0ad-dev on IRC for a faster respons.)

Link to comment
Share on other sites

Well, with current information on sequences I'm not sure you are able to retrieve accurate enough for pop chart.

If you want to mod it further you can patch statisticstracker as freagarach mentioned accounting for `template.cost.populationBonus`.

You'd also have to patch where units are deleted to add a hook for statisticstracker to account for deleted units pop, search `EntitySelection.prototype.update = function() `

Link to comment
Share on other sites

@dpikt

Brilliant work, dude, very interested to see how you refine this in terms of the whole situation with count accuracy, but it's certainly a great start. Is there not a live running count of population through the game that can be plotted? I mean, the game keeps track of a pop count, and although it seems to reach it by different means, so does the FGOD mod, right? Or am I missing something silly here? 

  • Like 1
Link to comment
Share on other sites

The game keeps track for each player individually, you could also store it for yourself on the mod. Easier to just reuse the already built in statistics tracker which stores data in the format the graph can use. The problem is just to use the accurate way for pops.

You'd want to hook and add the template.cost.population whenever a unit is trained/killed/deleted.

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