Json configuration for spells

Looks like spells from other spells are working, but only by id. If I use id, than battle is not
freezing. seems like json parser doesn’t parse spells by name to spells by id:

			"advanced":
			{
				"description": "Gives to shooters ability to shoot by explosive shells.",
	 
				"cost": 13,
				"power": 10,
				"aiValue": 9,
				"range": "0",
	
				"targetModifier":{"smart":true},
	 
				"effects":
				{
					"speed":
					{
						"type": "SPELL_LIKE_ATTACK",
						"subtype":21,
						"val":3,
						"duration": "N_TURNS"
					}
				}
			},

I wanted to ask.
Is 0.96 spell modding is the same as of 05.27.2014 version?
Or there were some improvements?
Like adventure spells or summon spells still not work?
PS By adventure spells i mean buff something like spell giving LAND_MOVEMENT bonus until end of turn to hero.

No changes yet.

Will upload updated mod with new spells to Launcher when it’s ready.

I wanted to make “spell” that will give army +1 morale (in 0.97b)

{
	"battleHymnChampions":
	{
		"type": "combat", 
		"name": "Champions March",
		"school":
		{
			"air": false,
			"earth": false,
			"fire": false,
			"water": false
		},
		"level": 1,
		"power": 10,
		
		"defaultGainChance": 3, 
		"gainChance":
		{
			"castle": 7
		},
 
"immunity":{"MIND_IMMUNITY":true},
		"absoluteImmunity":{"NON_LIVING":true,"UNDEAD":true},
 
		"flags" : {"positive": true,"offensive":false,"damage":false},
 		"animation":{
			"affect":"Battle Hymns/Champions/Coin_with_sword.def"]
		},
		//graphics - OPTIONAL; object;
		"graphics":
		{
			"iconBook": "Battle Hymns/Champions/back0.bmp",
			"iconScroll": "Battle Hymns/Champions/back1.bmp",
			"iconScenarioBonus": "Battle Hymns/Champions/back2.bmp",
			"iconEffect": "Battle Hymns/Champions/back3.bmp"
		},
		"sounds":
		{
			//OPTIONAL; resourse path, casting sound
			"cast":"Battle Hymns/Champions/Win"
		},
		
		"targetType": "CREATURE",
 
		"levels":
		{
			"none":
			{
				"description": "Champion March increases army morale by +1.",
	 
				"cost": 2,
				"power": 10,
				"aiValue": 5,
				"range": "X",
	
				//"targetModifier":{"smart":true},
	 
				"effects":
				{
					"attacks":
					{
						"type": "MORALE",
						"val": 1,
				//		"duration": "N_TURNS",
				"propagator":"HERO"
					}
				}
			},
			"basic":
			{
				"description": "Champion March increases army morale by +1.",
	 
				"cost": 2,
				"power": 10,
				"aiValue": 5,
				"range": "X",
	
			//	"targetModifier":{"smart":true},
	 
				"effects":
				{
					"attacks":
					{
						"type": "MORALE",
						"val": 1,
			//			"duration": "N_TURNS"
					"propagator":"HERO"
					}
				}
			},
			"advanced":
			{
				"description": "Champion March increases army morale by +1.",
	 
				"cost": 2,
				"power": 10,
				"aiValue": 5,
				"range": "X",
	
			//	"targetModifier":{"smart":true},
	 
				"effects":
				{
					"attacks":
					{
						"type": "MORALE",
						"val":2,
			//			"duration": "N_TURNS"
					"propagator":"HERO"
					}
				}
			},
			"expert":
			{
				"description": "Champion March increases army morale by +1.",
	 
				"cost": 2,
				"power": 10,
				"aiValue": 5,
				"range": "X",
	
			//	"targetModifier":{"smart":true},
	 
				"effects":
				{
					"attacks":
					{
						"type": "MORALE",
						"val":3,
			//			"duration": "N_TURNS"
					"propagator":"HERO"
					}
				}
			},
		}
	}
 
}

This code didn’t work at all until I added “propagator”:“HERO”.
That’s strange, because creatures have reaction on bonus “Morale”.

But the way, we have section “school”

Is there no “mind” magic?
And this is not very good for future modding (where modding of secondary skills will be added).
I suggest change “air”,“earth”,“fire”,“water” magic schools IDs to secondary skill IDs.
Like

		"school":
		{
			"airMagic": false,
			"earthMagic": false,
			"fireMagic": false,
			"waterMagic": false
		},

For example, I want to make spell, that will require “artillery” skill. Then I will write
“artillery”:true, and levels of spell will depend on level of Artillery skill

PPS There is no duration “ONE_TURN”, duration is calculated from spell power. I wanted to make battle hymns spells work only 1 turn… :mrgreen:

  1. custom duration will be allowed only for scripted spells.
  2. Spell should have at least one school and custom schools are not planned at all yet
  3. need complete mod to try to fix “didn’t work at all until …”
  1. OK, I’ll say it for future. I just throught that set of durations isn’t complete:
PERMANENT 
## ONE_BATTLE //at the end of battle 
## ONE_DAY //at the end of day 
## ONE_WEEK //at the end of week (bonus lasts till the end of week, thats NOT 7 days 
## N_TURNS //used during battles, after battle bonus is always removed 
## N_DAYS 
## UNITL_BEING_ATTACKED //removed after attack and counterattacks are performed 
## UNTIL_ATTACK //removed after attack and counterattacks are performed 
## STACK_GETS_TURN //removed when stack gets its turn - used for defensive stance 
## COMMANDER_KILLED 
  1. It works without selecting any school. But there is a bug during spell book drawing of icons:-)
  2. Will create mod with this spell and send to you.

Thats why Ive said “should” :wink:

In attachment.

  1. In spell Champions Marsch propagator HERO is commented.
    So when spell is cast, green counter appears, but morale is not increased. And in creatue window there is no icon of active spell.
    In spell Bard Song propagator is not commented, so luck is applied.
  2. These hymns are not assigned to any magic school, so in magic book this is corruption - there are only 4 defs for spell level indicatings (for each school), so it goes outside of array schoolBorders] and takes cadre from another def (Schools.def) that should not be there.
    I think there must be check - is spell school is not set, that do not try to load graphics from schoolBorders.
    hymns-mod.zip (61.8 KB)

In theory it is of course possible, but a bit harder than trivial :). Spell school is not just required primary skill

struct SpellSchoolInfo
{
	ESpellSchool id; //backlink
	Bonus::BonusType damagePremyBonus;
	Bonus::BonusType immunityBonus;	
	std::string jsonName;
	SecondarySkill::ESecondarySkill skill;
	Bonus::BonusType knoledgeBonus;			
};

(non including interface logic).

Or then allow some time to add new Spell Schools Info with Secodary Skills.
To change AIR_SPELL_DMG_PREMY to SPELL_DMG_PREMY with “subtype”:"spellSchool.air"
and so on.
Magic Book problem

  1. Leave it be - 4 elemental magics will have their own pages, and all other schools will go to united combat spells pages.
  2. Move magic book to json, so user can make other schools pages.
    Or cause, it will require a lot of work, don’t expect it to 1.0 version.
    It will require to move secondary skills bonuses to json also.

This may be implemented in part 6 (current is 4; 5 will be about adventure spells) of spell refactoring.

Would You Implement Reinforcements Spell?
it allows to teleport creatures from Town to Hero which is not visiting it.

there is mod in ERA which replaces Disguise by Reinforcements, but we may add it as separate spell.

My plan after current refactoring of spells is implement scripting.

That’s really great news :smiley:.

Adventure map spells are working, this is really great.
But I have question.

For example, this spell (and all adventure spells rising some value) gives + to morale. I cast it 3 times, and it gives +6 morale on expert. I want to allow only 1 cast per turn for hero (or I cast it 20 times and will get +60 morale :mrgreen: till end of turn.
I tried to use “counters” but it doesn’t help. Is there is a way to prevent it from multiple casts?

{
	"armyPrayer":
	{
		"type": "adventure", 
		"name": "Army Prayer",
		"school":
		{
			"air": true,
			"earth": false,
			"fire": false,
			"water": false
		},
		"level": 3,
		"power": 10,
		
		"defaultGainChance": 3, 
		"gainChance":
		{
			"castle": 4
		},
 
		//counterstrike animation?
	"counters": {"spell.armyPrayer":true},

 
		"flags" : {"indifferent": true,"positive":true},
 
		//graphics - OPTIONAL; object;
		"graphics":
		{
			"iconBook": "!Map-spells/ArmyPrayer/back0.bmp",
			"iconScroll": "!Map-spells/ArmyPrayer/back1.bmp",
			"iconScenarioBonus": "!Map-spells/ArmyPrayer/back2.bmp",
			"iconEffect": "!Map-spells/ArmyPrayer/back3.bmp"
		},

		
		"targetType": "NO_TARGET",
 
		"levels":
		{
			"none":
			{
				"description": "Gives army +1 morale until end of turn.",
	 
				"cost": 8,
				"power": 10,
				"aiValue": 5,
				"range": "X",
	
				"targetModifier":{"smart":false},
	 
				"effects":
				{
					"attacks":
					{
						"type": "MORALE",
						"val": 1,
						"duration": "ONE_DAY",
//						"propagator":"HERO"
					},
//					"morale":
//					{
//					"type":"MORALE",
//					"val":1,
//					"duration":"ONE_DAY"
//					}
				}
			},
			"basic":
			{
				"description": "Gives army +1 morale until end of turn.",
	 
				"cost": 7,
				"power": 10,
				"aiValue": 5,
				"range": "X",
	
				"targetModifier":{"smart":false},
	 
				"effects":
				{
					"attacks":
					{
						"type": "MORALE",
						"val": 1,
						"duration": "ONE_DAY",
	//					"propagator":"HERO"
					},
//					"morale":
//					{
//					"type":"MORALE",
//					"val":1,
//					"duration":"ONE_DAY"
//					}
				}
			},
			"advanced":
			{
				"description": "Gives army +1 morale until end of turn.",
	 
				"cost": 6,
				"power": 10,
				"aiValue": 5,
				"range": "X",
	
				"targetModifier":{"smart":false},
	 
				"effects":
				{
					"attacks":
					{
						"type": "MORALE",
						"val": 1,
						"duration": "ONE_DAY",
		//				"propagator":"HERO"
					},
//					"morale":
//					{
//					"type":"MORALE",
//					"val":1,
//					"duration":"ONE_DAY"
//					}
				}
			},
			"expert":
			{
				"description": "Gives army +1 morale until end of turn.",
	 
				"cost": 8,
				"power": 10,
				"aiValue": 5,
				"range": "X",
	
				"targetModifier":{"smart":false},
	 
				"effects":
				{
					"attacks":
					{
						"type": "MORALE",
						"val": 2,
						"duration": "ONE_DAY",
		//				"propagator":"HERO"
					},
//					"morale":
//					{
//					"type":"MORALE",
//					"val":1,
//					"duration":"ONE_DAY"
//					}
				}
			}
		}
	}
 
}

I don’t think it’s possible yet as limit for Dimension Door is hardcoded.

How about adding “castLimit”:n (limit of cast per day) to spell levels configuration?
It will help dimension door too…

  1. maximum morale is +3
  2. this (configuration for adv spell) feature is not complete and anything may change.
  3. any suggestions for adventure spell configuration will be rejected until scripting will be implemented. Consider adventure spell configuration as internal engine feature an NOT intended for modding.

That’s one cool feature, so i’ll play with it :mrgreen:
Can AI use these custom spells for adventure map?
As for me, I can limit spell casting by my will :sunglasses: