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

Auto-incremented EntityPickup variants attempt to populate variant 0, which already has function in the base game #436

Open
Xalum opened this issue Feb 17, 2022 · 6 comments
Labels
bug Something isn't working xml Involves XML files

Comments

@Xalum
Copy link

Xalum commented Feb 17, 2022

I've recently been exploring using entity ID auto-incrementation to make my mods impossible to ID clash, however I have noticed something. When using variant auto-incrementation, regardless of entity type, the variant will auto-increment from 0. For most entity types this is a non-issue, however, entity 5.0.n has special behaviour used for spawning random pickups.

If you want to auto-increment pickup variants you have to first add a filler entry that absorbs variant 0, so that the rest of your entries can auto-increment safely. This isn't a huge issue, but it's something that may dissuade a newer modder away from using ID auto-incrementation, and is something that every mod that wants to use this feature will have to do. Populating the variant 0 pickup in the base game entities2.xml would alleviate this entirely.

@Zamiell
Copy link

Zamiell commented Mar 11, 2022

For all other types, is using variant 0 okay? e.g. for familiars, tears, etc.?

@Xalum
Copy link
Author

Xalum commented Mar 11, 2022

Familiars (type 3) are fine, Effects (type 1000) are fine, Slots (type 6) are fine.

Auto-incrementation works completely different for NPCs so this does not apply there.

I haven't ever done it with any other special entity types (1, 2, 4, 7, 8, 9), since generally speaking there isn't a good reason to make variants of them over just using data tags. Tears especially aren't a great idea since some tear effects are linked to their variants rather than a tear flag (haemolachria).

@Xalum
Copy link
Author

Xalum commented Mar 12, 2022

I'm also realising now that variant 0 for Players, Tears, Bombs, Knives, & Projectiles is already populated, so this doesn't apply to them at all.

It's only an issue for pickups since variant 0 has function without being populated.

@Zamiell
Copy link

Zamiell commented Mar 20, 2022

If you want to auto-increment pickup variants you have to first add a filler entry that absorbs variant 0, so that the rest of your entries can auto-increment safely.

I discovered today that doing this is not safe. In other words, having an entity of

<entity name="Placeholder Pickup" id="5" />

or

<entity name="Placeholder Pickup" id="5" variant="0" />

in your content/entities2.xml file both accomplish the same thing of making "Placeholder Pickup" be equal to 5.0.
However, this can crash the game under certain conditions.

Steps to reproduce:

g guppy's eye
l Game():Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_CHEST, Vector(200, 200), Vector.Zero, nil, 0, 106995962)

If you remove the placeholder pickup from your content/entities2.xml file, then the game will no longer crash.

@Xalum
Copy link
Author

Xalum commented Mar 20, 2022

This crashes because your 5.0 entity doesn't have an anm2path for guppy's eye to render

@Zamiell
Copy link

Zamiell commented Jan 21, 2023

According to Xalum, effects (in addition to pickups) are not safe for auto-incrementation, which doesn't seem to be documented anywhere. He says that this is presumably because of EffectVariant.STARFLASH (40).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working xml Involves XML files
Projects
None yet
Development

No branches or pull requests

3 participants