Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐞 Incorrect initiative calculation when importing creatures from 5e.tools #480

Open
3 of 7 tasks
mahtaran opened this issue Feb 12, 2025 · 1 comment
Open
3 of 7 tasks

Comments

@mahtaran
Copy link

Check for existing bug reports before submitting.

  • I searched for existing Bug Reports and found no similar reports.

Expected Behavior

When importing a creature from 5e.tools with a custom initiative score, this should be reflected in the imported data.

Current behaviour

The information is not stored (and as such is lost).

Reproduction

Import the Assassin, which adds twice its proficiency bonus to its initiative.

Notice that the imported data does not include the initiative bonus.

JSON samples

5e.tools JSON (excerpt)

{
	"name": "Assassin",
	"source": "XMM",
	"page": 22,
	"size": [
		"S",
		"M"
	],
	"type": "humanoid",
	"alignment": [
		"N"
	],
	"ac": [
		16
	],
	"hp": {
		"average": 97,
		"formula": "15d8 + 30"
	},
	"speed": {
		"walk": 30
	},
	"initiative": {
		"proficiency": 2
	},
	"str": 11,
	"dex": 18,
	"con": 14,
	"int": 16,
	"wis": 11,
	"cha": 10,
	"save": {
		"dex": "+7",
		"int": "+6"
	},
	"skill": {
		"acrobatics": "+7",
		"perception": "+6",
		"stealth": "+10"
	},
	"passive": 16,
	"resist": [
		"poison"
	],
	"languages": [
		"Common",
		"Thieves' cant"
	],
	"cr": "8",
}

Fantasy statblocks JSON (excerpt)

{
    "image": null,
    "bestiary": true,
    "name": "Assassin",
    "source": [
      "XMM"
    ],
    "type": "humanoid",
    "size": "Small",
    "alignment": "neutral",
    "hp": 97,
    "hit_dice": "15d8 + 30",
    "ac": 16,
    "speed": "30 ft.",
    "stats": [
      11,
      18,
      14,
      16,
      11,
      10
    ],
    "damage_immunities": "",
    "damage_resistances": "poison",
    "damage_vulnerabilities": "",
    "condition_immunities": "",
    "saves": [
      {
        "dexterity": "7"
      },
      {
        "intelligence": "6"
      }
    ],
    "skillsaves": [
      {
        "acrobatics": "7"
      },
      {
        "perception": "6"
      },
      {
        "stealth": "10"
      }
    ],
    "senses": "passive Perception 16",
    "languages": "Common, Thieves' cant",
    "cr": "8",
  }

Which Operating Systems are you using?

  • Android
  • iPhone/iPad
  • Linux
  • macOS
  • Windows

Obsidian Version Check

1.8.4 and 1.8.4

Plugin Version

4.8.1

Confirmation

  • I have disabled all other plugins and the issue still persists.

Possible solution

If I understand the integration with the Initiative Tracker plugin well, it should suffice to add a modifier field to the imported data that reflects the correct initiative calculation.

The 5e.tools initiative calculation works as follows:

  • If the creature has no initiative key in the data, the Dexterity modifier is used.
  • If the creature has an initiative key in the data:
    • If the key is a number: use that as the initiative modifier
    • If the key is an object:
      • If the object has a key initiative which is a number: use that as the initiative modifier
      • The object is assumed to have a key proficiency which is a number: the initiative modifier is this number times the creature's proficiency bonus + the creature's Dexterity modifier

Pseudocode:

if (!creature.initiative) return getModifier(creature.dex);
if (typeof creature.initiative == "number") return creature.initiative;
if (typeof creature.initiative == "object") {
    if (typeof creature.initiative.initiative == "number") return creature.initiative.initiative;
    return creature.initiative.proficiency * getProficiencyBonus(creature.cr) + getModifier(creature.dex);
}
throw error;
@mahtaran
Copy link
Author

I am willing to make a PR for this, but before I spend time on that, your thoughts would be much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant