Json config for artifacts

I’m finishing moving artifact bonuses from arthandler to specific config file. I’ve encountered two surprising facts about json parser during this:

  1. why it’s possible to create json file with vector as root element, but it’s not possible to read it?
  2. why there are three different implementations of bonus reading?
  1. There should be 2 possible implementations, one short (for old creature abilities from creatures.json) and one long, which is recommended.
    There is also reading creature exp bonuses from ZCREXP.txt which are quite different and Commander-specific short bonuses from commanders.json as far as I remember.

Also, all bonus fields in long format are optional, apart from type. There is no need to ever provide sourceID or sourcetype, it’d be easier to assign them automatically.

  1. Bug, should be easy to fix. But I suggest leaving current format as it (file with one “artifacts” entry) for consistency with other files (creatures, towns, heroes)

Any progress on artifact support? This should be easy feature I believe, most of things needed are already here.

In the following weeks I’d like to move all ratifact-related info (description, graphics) to CArtifact class and polish reading them from config, removing redundant info.

A guy named WItchking already wants to add some new artifacts :slight_smile:

I won’t work on VCMI for a few more weeks. When I come back I’ll probably focus on finishing campaign support as it’s almost done and quite important.

I was going to handle cutom graphics for artifacts, but it seems we the issue is same as for creature portraits. We need mechanism to access frames both from defs and free images (URI).
I’m not going to do same workaround as with creatures, but wait for Ivan to do the job… someday :->

Such mechanism was started in animRewrite branch but it is far from finished. So I still would suggest same workaround as for creatures - it is unlikely that we’ll run out of id’s before def URI system will be finished.

Perhaps I’ll continue work on it but definitely not this year - first I want to finish new towns and get rid from defHandler where possible (blocks both animRewrite branch as well as new content support).

That’s ok, take your time.
But I think that adding new creatures / artifacts should be completely automatic before we ask people to create independent mods for them in next release. Lack of compatibility between mods or backwards can kill all the modding before it starts off.

Completely agree with your post. But manual indexes are much better than no new content support at all. In worst case this will give some incorrect icons which can be fixed easily.

That can be avoided by:

  1. giving modders large ranges of available id’s, as many as they want - using ID’s like 1 000 000 may cause issues but any sane numbers will work - they don’t need to be continuous.
  2. Asking to write file names as well as id’s in config files (as you did with creatures) - to have some compatibility with future VCMI versions.

Some thoughts about art format: (as on wiki)

  • split “image” field into two:
  1. “image” for hero screen (original size)
  2. “popupImage” for popup messages (possibly bigger size)
    Second one can be optional or set to same as “image” (as with H3 arts)
  • "Combined artifacts identified by string"
    Implementation should be simple (like in new code for creature upgrades) but you’ll need to give name\ID to every artifact from H3 - can take a while to write all of them…

It looks that CArtPlace would need some changes to make creature-like icons work - it should use CAnimImage instead of blitAt() method. Drag-and-drop cursor won’t work as it either.
Send me test mod when loading is ready - I’ll fix that.

The mod seems to be correctly recognized by game already. However, game crashes at map start at the moment - serializer issues. I don’t have an idea for it right now.

Either way, iconIndex needs to be handled. Take a look.
witchking-arts.rar (4.15 KB)

Icon index should work.

Regarding package:
json with small 44px icons should be renamed to “artifact” - just like H3 .def with artifact icons
big icon is not used anywhere right now - right now there is no easy way to add it.

Regarding my commit - it made one quite old problem very notable. As result - hero window is quite slow to open at the moment. Will fix this soon - need to find some nice way to get rid of the delay.

Looks like map launched, but crashes at missing def. I suppose it’s the def of an artifact.

Now question: can we make adventure map def from artifact image, or it has to be separate file?

It has different size compared to hero screen image.
In H3:
Hero screen - 44x44 image, located inside artifact.def
Adventure map - 64x32 AVAXXXX.def, where XXXX is index of artifact.

Solution will be:

  1. Make or find def (json + pcx won’t work here unfortunately)
  2. Add field in art format with this filename
  3. Add code in ModHandler::reload(), similar to creatures (will think about something more general later)

Added support for def, but seemingly it does not work. Not sure why, tried to follow exact structure of Cove creatures.

Take a look at new mod.
witchking-arts.rar (5.39 KB)

Def is sprites/witchking/map/SOULPRISON but not SPRITES/SOULPRISON.

^ this

in artifact config entry “image”]“map”] should have full path - “witchking/map/SOULPRISON”
(SPRITES/ prefix will be added somewhere by image loader)

Ahh, so path is a part of artifact property. Tricky, not sure if that’s desired solution.

Theoretically it is possible to make most of/all of specified files paths completely optional and generate them by the game.

But this would need to decide how directory structure of mods will look like. For example aritfacts map images can be placed at


(IMO latest path is the best one)

I’d rather finish animRewrite first (to get rid of imageIndex’es) and wait for several VCMI-based mods to appear to see what is needed for them, what modders think about filesystem, etc.


Not sure if background has wrong color, or is not processed by engine?

Def Preview (from era) seems does not recognize transparent color too.

Def has errors. Used non standard transparency color (0,252,252) but def set up to standard colors.