devilutionX icon indicating copy to clipboard operation
devilutionX copied to clipboard

Unique->MonsterType mapping is not position independent

Open AJenbo opened this issue 2 years ago • 3 comments

Operating System

Windows x64

DevilutionX version

1.5.1

Describe

Modifying the order of monsters will cause the unique monsters type to point to the incorrect monster as it does not search by ID but instead just indexes directly into the table.

image

To Reproduce

Order the monsdat.tsv by one of the columns alphabetically should give some interesting unique monsters :)

Expected Behavior

No response

Additional context

No response

AJenbo avatar Nov 19 '23 01:11 AJenbo

So should an id column be added to maintain order?

DakkJaniels avatar Nov 19 '23 22:11 DakkJaniels

There already is an ID colum (at least in the TSV data), we just need to search the array for the right monster rather then just assuming that it's on MonsterData[MT_BASEMONSTER]

for (auto &baseMonster : MonsterData) {
   if (baseMonster.ID == MT_BASEMONSTER)
    // oh here it is
}

If it's not in the struct then it need to be added and we need to parse for it. We should probably also add a MT_CUSTOMMONSTER or something like that so new monsters won't have to pretend to be some original monster type.

On a related not currently the game will crash and burn if you try to cut down the list. So we probably should handle cases where a monster type isn't found (but just concluding that there won't be a Snotspill quest if there is no Fallen Ones, or something to that effect.

AJenbo avatar Nov 20 '23 00:11 AJenbo

... looks like we do need to add it :) https://github.com/diasurgical/devilutionX/blob/c4792be7635c7d40009ab864ceb99a574487f16b/Source/monstdat.cpp#L482

AJenbo avatar Nov 20 '23 04:11 AJenbo