PDA

View Full Version : Just curious



DragonsLover
May 10th, 2011, 01:33
I'm testing about the stats at the end of levels to insure that they're okay. There are some of them, I have no idea on what they're about.

How the dungeon efficiency is calculated?
What's the style and how it is calculated?
What's the rating and how it is calculated?
How the amount of "Backs stabbed" is calculated?
How the amount of "Hopes dashed" is calculated?
How the amount of "Promises broken" is calculated?
How the amount of "Lies Told" is calculated?
How the score is calculated?

I have also noticed that 2 of the level stats are missing. Those are: "Creatures left" and "Last Creature Attracted". Would it be possible to include them into KeeperFX?

I'm testing the others. I found that there's a little mistake about the "Imps Deployed" stat, which in fact, should be "Number of Imps" instead. Some others are weirdly calculated. If you slap a creature to death, it doesn't count as a "Battles Lost", but if you kill your creature with Cave-In, for example, then "Battles Lost" is increased by one. :confused: I think it should be here "Number of your creatures that died (except by slapping)".

mefistotelis
May 10th, 2011, 11:47
See frontend.cpp (https://code.google.com/p/keeperfx/source/browse/trunk/keeperfx/src/frontend.cpp?spec=svn343&r=343):


void frontstats_initialise(void)
{
struct Dungeon *dungeon;
//_DK_frontstats_initialise();
dungeon = get_my_dungeon();
dungeon->lvstats.time2 = timeGetTime();
dungeon->lvstats.num_creatures = dungeon->num_active_creatrs;
dungeon->lvstats.imps_deployed = dungeon->num_active_diggers;
dungeon->lvstats.battles_won = dungeon->battles_won;
dungeon->lvstats.battles_lost = dungeon->battles_lost;
dungeon->lvstats.money = dungeon->total_money_owned;
dungeon->lvstats.dngn_breached_count = dungeon->times_broken_into;
dungeon->lvstats.doors_destroyed = dungeon->field_945;
dungeon->lvstats.rooms_destroyed = dungeon->rooms_destroyed;
dungeon->lvstats.dungeon_area = dungeon->total_area;
dungeon->lvstats.ideas_researched = (dungeon->field_117D >> 8);
dungeon->lvstats.creatures_scavenged = dungeon->field_98B;
dungeon->lvstats.creatures_summoned = dungeon->field_98D;
dungeon->lvstats.spells_stolen = dungeon->spells_stolen;
dungeon->lvstats.gold_pots_stolen = dungeon->gold_pots_stolen;
dungeon->lvstats.field_15C = calculate_efficiency(my_player_number);
dungeon->lvstats.field_160 = calculate_rating(my_player_number);
dungeon->lvstats.field_164 = calculate_style(my_player_number);
dungeon->lvstats.doors_unused = calculate_doors_unused(my_player_number);
dungeon->lvstats.traps_unused = calculate_traps_unused(my_player_number);
dungeon->lvstats.num_rooms = calculate_num_rooms(my_player_number);
dungeon->lvstats.field_174 = (dungeon->lvstats.time2 - dungeon->lvstats.time1) / 1000;
dungeon->lvstats.num_entrances = calculate_entrances(my_player_number);
dungeon->lvstats.hopes_dashed = game.play_gameturn;
memcpy(&frontstats_data, &dungeon->lvstats, sizeof(struct LevelStats));
}

DragonsLover
May 10th, 2011, 13:43
I know. I saw. But it doesn't tell how the stats are calculated.

I'll look further into the code then, I guess.

DragonsLover
May 10th, 2011, 22:09
I do a little bump 'cause I have detected something wrong into the game code, in the "frontend.cpp" file.

In the "calculate_rating" function, btwon and btlost are swapped!!! btwon should be the amount of battles won and btlost should be the amount of battles lost, and not the opposite. I don't know if it's normal or not.

And I can't find the places where "backs_stabbed" and "lies_told" are used, but I'm sure they're used somewhere because I once got "Backs stabbed" value to 3 on the first level (unless there's some kind of data leak). Also, I found how the score is calculated, but there's a missing value for "gameplay_score". When "compute_player_final_score" is called, it takes the "field_AE9" table as a parameter and I have no idea what it is. Finally, I don't catch how the "Promises Broken" works. I know it's about "imps doing nothing", but then, before it increases the value by 1, the game checks if, correct me if I'm wrong:
- game.play_gameturn - cctrl->long_9A <= 1 (where I have no idea what it's all about)
- The last thing he did must be nothing
- No tasks are available for him to do
- He doesn't toke
- He must not choose a random destination on a valid adjacent slab

I tried, for example, to tag a gold seam and wait for the imps to reach it so that I untag it before they start digging, but it doesn't work. I also tried to drop one of them into a tiny island surrounded by lava while he was carrying gold, no such luck as well. I'm asking: is it working properly?

mefistotelis
May 17th, 2011, 15:53
In the "calculate_rating" function, btwon and btlost are swapped!!! btwon should be the amount of battles won and btlost should be the amount of battles lost, and not the opposite. I don't know if it's normal or not.
Only names are swapped; code is correct. Will fix.


And I can't find the places where "backs_stabbed" and "lies_told" are used, but I'm sure they're used somewhere because I once got "Backs stabbed" value to 3 on the first level (unless there's some kind of data leak).
Remember that not whole game is rewritten. These are still calculated inside DLL.


Also, I found how the score is calculated, but there's a missing value for "gameplay_score". When "compute_player_final_score" is called, it takes the "field_AE9" table as a parameter and I have no idea what it is.
I will try to give better names to the variables, or add some comments.


Finally, I don't catch how the "Promises Broken" works. I know it's about "imps doing nothing", but then, before it increases the value by 1, the game checks if, correct me if I'm wrong:
- game.play_gameturn - cctrl->long_9A <= 1 (where I have no idea what it's all about)
- The last thing he did must be nothing
- No tasks are available for him to do
- He doesn't toke
- He must not choose a random destination on a valid adjacent slab
The first condition probably means that the imp just started to be idle. I can't remember now.