Modding FAQ


#159

Ah, I see :frowning: Thanks for the explanation though!

The thing is that I wanted to make my mod 100% open-source.

Each name being a separate item sounds too cumbersome - how about adding a “new_names” array instead, which would add names to the “names” array instead of replacing the whole thing?


#160

I hope vcmi team will keep the changes to modding format to minimum, only adding new fields :mrgreen:

Than change all names, rewriting standart names written in proprietary lods:-)


#161

From few reasons I’m looking a way to add my creature +1 attack per turn during battle (so atack is +1 to base in first turn, +2 to base in second, +3 in third and so on…). I thought it’s possible only via new special spell.
So I wrote such creature ability:

			"casts" :
			{
				"type" : "CASTS",
				"val" : 20
			},
			"attackBooster":
			{
			"type" : "ENCHANTER",
			"subtype" : "spell.attackBooster",
			"val" : 1,
			"addInfo" : 1
			}

And here’s my spell atackBooster:

		"levels":
		{
			"base":
			{
				"power": 10,
				"aiValue": 20,
				"range": "0",
				"targetModifier":
				{
					"smart": false
				}
			},
			"none":
			{
				"description": "Attack",
	 
				"cost": 0,
				"effects":
				{
					"plusOneAttack":
					{
						"type": "PRIMARY_SKILL",
						"duration": "N_TURNS"],
						"val" : 1,
						"subtype" : "primSkill.attack",
						"valueType" : "ADDITIVE_VALUE"
					}
				}
			},
			"basic":
			{
				"description": "Attack",	 
				"cost": 0,
	 
				"effects":
				{
					"plusOneAttack":
					{
						"type": "PRIMARY_SKILL",
						"duration": "N_TURNS"],
						"val" : 1,
						"subtype" : "primSkill.attack",
						"valueType" : "ADDITIVE_VALUE"
					}
				}
			},
			"advanced":
			{
				"description": "Attack",
	 
				"cost": 0,
	 
				"effects":
				{
					"plusOneAttack":
					{
						"type": "PRIMARY_SKILL",
						"duration": "N_TURNS"],
						"val" : 1,
						"subtype" : "primSkill.attack",
						"valueType" : "ADDITIVE_VALUE"
					}
				}
			},
			"expert":
			{
				"description": "Attack",
	 
				"cost": 0,

				"effects":
				{
					"plusOneAttack":
					{
						"type": "PRIMARY_SKILL",
						"duration": "N_TURNS"],
						"val" : 1,
						"subtype" : "primSkill.attack",
						"valueType" : "ADDITIVE_VALUE"
					}
				}
			}

But, +1 attack is granted only fist turn, which is lame, becaure I can give my creature +1 attack permament. Is there any way to give prograssive +1 attack per turn?


#162

Hmm, change duration from “N_TURNS” to “PERMANENT”? The disruption ray spell works quite similar.


#163

Doesn’t work either :frowning:


#164

I’ll leave it here to not left it just on slack: DISRUPTING_RAY is heavily hardcoded.
For now VCMI can’t handle duplicate bonuses.

Reasonable amount of work would be needed to make it work.


#165

By the way, I have a question.
If i’ll set

{
"type":"SPELL_IMMUNITY",
"subtype":"spell.visions"
}

to hero, will it be immune to Visions spell?


#166

No. Immunity for Vision is never checked.


#167

No immunities do not work on adventure spells.


#168

I wanted to introduce HotA’s Warehouses into VCMI. So I’ve written code:

{
	"warehouses" :{	
		"name": "Warehouses",
		"handler": "oncePerWeek",
		"types" : {
			"crystalWarehouse" : {
				"name": "Warehouse of Crystal",
				"producedResources" : "crystal",
				"producedValue" : 6,
				"rmg" : {
					"value"		: 500,
					"rarity"	: 70
				},
				"templates" : {
					"avwrhscr" : { "animation" : "avwrhscr", 
					"visitableFrom" :  "---", "+++", "+++" ], 
					"mask" : "0VV","VVV","VBA"], 
//					"allowedTerrains": "sand"]
					}					
				}
			}			
		}	
	}
}

In random maps object appears, can be visited but doesn’t produce anything… Any ideas what is wrong?


#169

Nothing is wrong, adding objects with new properties is not supported.


#170

But I suggested the example from wiki:
wiki.vcmi.eu/index.php?title=Obj … ype_format

In town section code “produce” is working, so I thought that “producedResources” and “producedValue” work too…


#171

Handler “oncePerWeek” has no configuration. It used only for MYSTICAL_GARDEN, WINDMILL, WATER_WHEEL

For new objects please try to use “configurable” handler, it is undocumented though.


#172

The code located here: github.com/vcmi/vcmi/blob/devel … or.cpp#L47


#173

Keep in mind that someday this code might be finished, refactored and current not-supported mods might stop working.


#174

Noted that, thank you both guys!


#175

Hi again!
I’ve found over the net a pack with new custom boat sprites. I’ve wanted to make mod that adds these sprites to the ‘core’ of existing boat graphics and allow game to randomly choose these ones in the moment of buiyng. So I’ve wriiten such code:

{
	"core:boat" : {
		"base" : {
			"base" : {
				"visitableFrom" :  "+++", "+-+", "+++" ],
				"mask" :  "VVV", "VAV" ]
			}
		},
		"types" : {
			"evil" : { 
				"templates" : {
					"AB01_.def" : 
					{ "animation" : "AB01_.def", //original h3 evil def
					  "editorAnimation": "avxboat0.def"
					},
					"boat07.def" :
					{ "animation" : "boat07.def",
					  "editorAnimation": "boat07ed.def"
					},
					"boat10.def" : 
					{ "animation" : "boat10.def",
					  "editorAnimation": "boat10ed.def"
					},
					"boat11.def" : 
					{ "animation" : "boat11.def",
					  "editorAnimation": "boat11ed.def"
					},
					"boat20.def" : 
					{ "animation" : "boat20.def",
					  "editorAnimation": "boat20ed.def"
					},
					"boat0a.def" : 
					{ "animation" : "boat0a.def",
					  "editorAnimation": "boat0aed.def"
					},
					"boat0c.def" : 
					{ "animation" : "boat0c.def",
					  "editorAnimation": "boat0ced.def"
					},
					"boat0f.def" : 
					{ "animation" : "boat0f.def",
					  "editorAnimation": "boat0fed.def"
					},
					"boat0l.def" : 
					{ "animation" : "boat0l.def",
					  "editorAnimation": "boat0led.def"
					}	
				}
			},	
			"good" : {
				"templates" : {
					"AB02_.def" : 
					{ "animation" : "AB02_.def", //original h3 good def
					  "editorAnimation": "avxboat1.def"
					},
					"boat00.def" : 
					{ "animation" : "boat00.def",
					  "editorAnimation": "boat00ed.def"
					},
					"boat01.def" : 
					{ "animation" : "boat01.def",
					  "editorAnimation": "boat01ed.def"
					},
					"boat02.def" : 
					{ "animation" : "boat02.def",
					  "editorAnimation": "boat02ed.def"
					},
					"boat04.def" : 
					{ "animation" : "boat04.def",
					  "editorAnimation": "boat04ed.def"
					},
					"boat06.def" : 
					{ "animation" : "boat06.def",
					  "editorAnimation": "boat06ed.def"
					},
					"boat09.def" : 
					{ "animation" : "boat09.def",
					  "editorAnimation": "boat09ed.def"
					},
					"boat0i.def" : 
					{ "animation" : "boat0i.def",
					  "editorAnimation": "boat0ied.def"
					},
					"boat0j.def" : 
					{ "animation" : "boat0j.def",
					  "editorAnimation": "boat0jed.def"
					},
					"boat0m.def" : 
					{ "animation" : "boat0m.def",
					  "editorAnimation": "boat0med.def"
					}
				}
			},	
			"neutral" : {
				"templates" : {
					"AB03_.def" : 
					{ "animation" : "AB03_.def", //original h3 neutral def
					  "editorAnimation": "avxboat2.def"
					},
					"boat03.def" : 
					{ "animation" : "boat03.def",
					  "editorAnimation": "boat03ed.def"
					},
					"boat05.def" : 
					{ "animation" : "boat05.def",
					  "editorAnimation": "boat05ed.def"
					},
					"boat08.def" : 
					{ "animation" : "boat08.def",
					  "editorAnimation": "boat08ed.def"
					},
					"boat0b.def" : 
					{ "animation" : "boat0b.def",
					  "editorAnimation": "boat0bed.def"
					},
					"boat0d.def" : 
					{ "animation" : "boat0d.def",
					  "editorAnimation": "boat0ded.def"
					},
					"boat0e.def" : 
					{ "animation" : "boat0e.def",
					  "editorAnimation": "boat0eed.def"
					},
					"boat0g.def" : 
					{ "animation" : "boat0g.def",
					  "editorAnimation": "boat0ged.def"
					},
					"boat0h.def" : 
					{ "animation" : "boat0h.def",
					  "editorAnimation": "boat0hed.def"
					},
					"boat0k.def" : 
					{ "animation" : "boat0k.def",
					  "editorAnimation": "boat0ked.def"
					}					
				}
			}	
		}
	}
}

New sprites appear in the editor map (see screenshot) but in game there aren’t any changes - when I buy the boat - standard h3 defs are show :frowning: Did not I understand what is “template” command for?
:frowning:



#176

Boat type for Shipyard is hardcoded and can’t be changed via config.


#177

Oh, too bad…
So let this mod can be treated as map editor plugin and in the future let mapmakers put these sprites on their maps :slight_smile:
mediafire.com/file/i8qre3db9 … s_v1.0.zip


#178

Hm… I’ve made another mod, which doesn’t work and I don’t know why :frowning:
Some time ago, J.M.Sower made Castle graphic depending on terrain.


Because VCMI can allow spawning objects depends on terrain type so I wrote a code:

{
	"core:castle" :
	{
		"town" :
		{
			"mapObject" :
			{
				"castle" : {
					"templates" :  
						{ 
							"dirt" :
								{
									"animation" : "castle-dirt/dirtCastleCastle.def",
									"allowedTerrains":  "dirt" ]
								},
							"snow" :
								{
									"animation" : "castle-snow/snowCastleCastle.def",
									"allowedTerrains":  "snow" ]
								},
							"grass" :
								{
									"animation" : "castle-grass/grassCastleCastle.def",
									"allowedTerrains":  "grass" ]
								},
							"lava" :
								{
									"animation" : "castle-lava/lavaCastleCastle.def",
									"allowedTerrains":  "lava" ]
								},
							"rough" :
								{
									"animation" : "castle-rough/roughCastleCastle.def",
									"allowedTerrains":  "rough" ]
								},
							"sand" :
								{
									"animation" : "castle-sand/sandCastleCastle.def",
									"allowedTerrains":  "sand" ]
								},
							"subterra" :
								{
									"animation" : "castle-subterra/subterraCastleCastle.def",
									"allowedTerrains":  "subterra" ]
								},
							"swamp" :
								{
									"animation" : "castle-swamp/swampCastleCastle.def",
									"allowedTerrains":  "swamp" ]
								}
						}
					},	
				"citadel" : { 
					"templates" : 
						{
							"dirt" :
								{
									"animation" : "castle-dirt/dirtCastleCitadel.def",
									"allowedTerrains":  "dirt" ]
								},
							"snow" :
								{
									"animation" : "castle-snow/snowCastleCitadel.def",
									"allowedTerrains":  "snow" ]
								},
							"grass" :
								{
									"animation" : "castle-grass/grassCastleCitadel.def",
									"allowedTerrains":  "grass" ]
								},
							"lava" :
								{
									"animation" : "castle-lava/lavaCastleCitadel.def",
									"allowedTerrains":  "lava" ]
								},
							"rough" :
								{
									"animation" : "castle-rough/roughCastleCitadel.def",
									"allowedTerrains":  "rough" ]
								},
							"sand" :
								{
									"animation" : "castle-sand/sandCastleCitadel.def",
									"allowedTerrains":  "sand" ]
								},
							"subterra" :
								{
									"animation" : "castle-subterra/subterraCastleCitadel.def",
									"allowedTerrains":  "subterra" ]
								},
							"swamp" :
								{
									"animation" : "castle-swamp/swampCastleCitadel.def",
									"allowedTerrains":  "swamp" ]
								} 
						}
					},	
				"fort" : { 
					"templates" :  
						{ 
						"dirt" :
								{
									"animation" : "castle-dirt/dirtCastleFort.def",
									"allowedTerrains":  "dirt" ]
								},
							"snow" :
								{
									"animation" : "castle-snow/snowCastleFort.def",
									"allowedTerrains":  "snow" ]
								},
							"grass" :
								{
									"animation" : "castle-grass/grassCastleFort.def",
									"allowedTerrains":  "grass" ]
								},
							"lava" :
								{
									"animation" : "castle-lava/lavaCastleFort.def",
									"allowedTerrains":  "lava" ]
								},
							"rough" :
								{
									"animation" : "castle-rough/roughCastleFort.def",
									"allowedTerrains":  "rough" ]
								},
							"sand" :
								{
									"animation" : "castle-sand/sandCastleFort.def",
									"allowedTerrains":  "sand" ]
								},
							"subterra" :
								{
									"animation" : "castle-subterra/subterraCastleFort.def",
									"allowedTerrains":  "subterra" ]
								},
							"swamp" :
								{
									"animation" : "castle-swamp/swampCastleFort.def",
									"allowedTerrains":  "swamp" ]
								} 
						}
					},	
				"village" : {
					"templates" :
						{ 
						"dirt" :
								{
									"animation" : "castle-dirt/dirtCastleVillage.def",
									"allowedTerrains":  "dirt" ]
								},
							"snow" :
								{
									"animation" : "castle-snow/snowCastleVillage.def",
									"allowedTerrains":  "snow" ]
								},
							"grass" :
								{
									"animation" : "castle-grass/grassCastleVillage.def",
									"allowedTerrains":  "grass" ]
								},
							"lava" :
								{
									"animation" : "castle-lava/lavaCastleVillage.def",
									"allowedTerrains":  "lava" ]
								},
							"rough" :
								{
									"animation" : "castle-rough/roughCastleVillage.def",
									"allowedTerrains":  "rough" ]
								},
							"sand" :
								{
									"animation" : "castle-sand/sandCastleVillage.def",
									"allowedTerrains":  "sand" ]
								},
							"subterra" :
								{
									"animation" : "castle-subterra/subterraCastleVillage.def",
									"allowedTerrains":  "subterra" ]
								},
							"swamp" :
								{
									"animation" : "castle-swamp/swampCastleVillage.def",
									"allowedTerrains":  "swamp" ]
								} 
						}
					},	
				"capitol" : {
					"templates" :
						{ 
						"dirt" :
								{
									"animation" : "castle-dirt/dirtCastleCapitol.def",
									"allowedTerrains":  "dirt" ]
								},
							"snow" :
								{
									"animation" : "castle-snow/snowCastleCapitol.def",
									"allowedTerrains":  "snow" ]
								},
							"grass" :
								{
									"animation" : "castle-grass/grassCastleCapitol.def",
									"allowedTerrains":  "grass" ]
								},
							"lava" :
								{
									"animation" : "castle-lava/lavaCastleCapitol.def",
									"allowedTerrains":  "lava" ]
								},
							"rough" :
								{
									"animation" : "castle-rough/roughCastleCapitol.def",
									"allowedTerrains":  "rough" ]
								},
							"sand" :
								{
									"animation" : "castle-sand/sandCastleCapitol.def",
									"allowedTerrains":  "sand" ]
								},
							"subterra" :
								{
									"animation" : "castle-subterra/subterraCastleCapitol.def",
									"allowedTerrains":  "subterra" ]
								},
							"swamp" :
								{
									"animation" : "castle-swamp/swampCastleCapitol.def",
									"allowedTerrains":  "swamp" ]
								} 
						}
				}	
			
			}
		}
	}
}

Aim was to generate diffirent Castle defs at particular terrains in random maps. But… mod doesn’t work :frowning:
Castle always is set with standard grass base and defs aren’t placed in map editor.
Maybe someone skilled will look at my mod in free time…
www53.zippyshare.com/v/iM4b7ZuS/file.html