Scripting suggestions (Lua, (V)ERM)


Another smaller script from ERA.
Conflux rebalacing.

Growth Pixie/Sprite: 15,
Growth of all Elementals: 5,
Firebirds/Phoenixes are treated as ‘elementals’.

_WARNING_#1=IMPORTANT! This file is not in a plain text format. NEVER use any editor except ERM_S for making any kind of changes!
ERMS_PoweredBy=ERM Scripter v. 2004.10.5.945
** Author orig.  : Algor
** Name          : Conflux balancing
** Name rus.     : Áŕëŕíńčđîâęŕ Ńîďđ˙ćĺíč˙
** Options       : 781
** Dialogs       : -
** Variables     : -
** Tmp variables : -
** Timers        : -
** Functions     : -
** PO-values     : -

!?PI;                         [ďîńň-číńňđóęöč˙]
!!UN:P781/?y1;                [ďđîâĺđ˙ĺě âęëţ÷ĺíŕ ëč îďöč˙ 781 â y1]
!!FU&y1=0:E;                  [âűőîä ĺńëč îďöč˙ íĺ âęëţ÷ĺíŕ]
!!MA:G118/?y11 G119/?y12 G112/?y13 G127/?y14 G115/?y15 G123/?y16 G113/?y17 G125/?y18; [y11-y18 ďđčđîńňű Ôĺé,AWE-Ýëĺěĺíňŕëĺé]
!!VRy11:-5;                   [čçěĺí˙ĺě ďđčđîńňű äî íóćíűő çíŕ÷ĺíčé]
!!VRy12:-5;                   [...]
!!VRy13:-1;                   [...]
!!VRy14:-1;                   [...]
!!VRy15:-1;                   [...]
!!VRy16:-1;                   [...]
!!VRy17:+1;                   [...]
!!VRy18:+1;                   [...]
!!VRy11&y11<1:S1;             [íĺ äŕĺě čě îďóńęŕňüń˙ íčćĺ 1]
!!VRy12&y12<1:S1;             [...]
!!VRy13&y13<1:S1;             [...]
!!VRy14&y14<1:S1;             [...]
!!VRy15&y15<1:S1;             [...]
!!VRy16&y16<1:S1;             [...]
!!MA:G118/y11 G119/y12 G112/y13 G127/y14 G115/y15 G123/y16 G113/y17 G125/y18; [Îáíîâëĺíčĺ ďđčđîńňîâ: Ôĺč-15, AWFE-Ýëĺěĺíňŕëč-5]
!!MA:X130/?y1;                [y1 - ôëŕăč îăí. ďňčö]
!!VRy2:Sy1 &16;               [ďîëó÷ŕĺě ôëŕă "ćčâîĺ ńóůĺńňâî"]
!!VRy1:-y2;                   [óáčđŕĺě ôëŕă "ćčâîĺ ńóůĺńňâî"]
!!VRy1:|131072;               [óńňŕíŕâëčâŕĺě ôëŕă "ýëĺěĺíňŕëü"]
!!MA:X130/y1;                 [îáíîâë˙ĺě ôëŕă îăí. ďňčö]
!!MA:X131/?y1;                [y1 - ôëŕăč ôĺíčęńîâ]
!!VRy2:Sy1 &16;               [ďîëó÷ŕĺě ôëŕă "ćčâîĺ ńóůĺńňâî"]
!!VRy1:-y2;                   [óáčđŕĺě ôëŕă "ćčâîĺ ńóůĺńňâî"]
!!VRy1:|131072;               [óńňŕíŕâëčâŕĺě ôëŕă "ýëĺěĺíňŕëü"]
!!MA:X131/y1;                 [îáíîâë˙ĺě ôëŕă ôĺíčęńîâ]

** end

Not that useful for VCMI, if you just changing particular entities in !?PI it is better to use JSON. However it should work with a few exceptions:

  • !!UN:P - not planned for now, may be in feature.
  • !!MA:X/16 - aka Living trait is not present in VCMI, I`ve ignored it for now. Could be done as “not NON_LIVING”

Another examples:

Creatures placed in town garrisons grow their count by 2% every day
Map dwellings have 25% chance to offer upgraded creatures
Neutral armies are supplied with neutral heroes with some of stats and spells for the time of battle
Speed reverse - slow creatures get huge speed while fast such as archangels / phoenixes etc. get very slow (speed 3 or similar)
Neutral creatures in battle get +10% boost to all statistics every month (fighting pikemen in 2nd month results in them having 11 hitpoitns instead of 10 etc.)

I do not try to give wanted/practical scripts, but “various different kinds” ones.


If these scripts are not wanted/practical, then they should be simple enough to be used as tests (like that one with !!MA, you sent me some time ago).


Magog Fireball-Attack does not damage own troops - script by PerryR


!?MF1;                                  [Magogs Fireball-Attack doesnt damage own troops]
!!BG:N?y1;                              [Get attacking stack number]
!!MF:N?y4;                              [Get defending stack number]
!!BMy1:I?y5;                            [Get attacking stack side]
!!BMy4:I?y6;                            [Get defending stack side]
!!UN:C42149568/4/?y10;                  [Judgement basis (028326c0)]
!!MF&y10=4454752/y5=y6:E0;              [Disable taking damage if Magog Fireball and own team]

!?MR2;                                  [Magogs Fireball-Cast that comes with Stack Expierence doesnt damage own troops]

!!BG:A?y1;                              [Aktion in y1]
!!MR:S?y2 F?y3;
!!if&y1=7/y2=21/y3<=105:;               [Fireball always does 105 damage]
!!MR&y11=0:F100;                        [Disable Magic damage for attacker side from Fireball]

!!FU&y1=1:E;                            [Exit in Quick Combat]

!!SN:X?y1;                              [Event parameter]
!!BMy1:T?y2;                            [Acting Monster Type]

*Show choice in Battle when right clicking defend icon
!!CM:F?y1 I?y2;
!!FU|y1<>512/y2<>2010:E;                [Exit if not rightclick on defend Icon]
!!BMy3:T?y4;                            [Acting Monster Type]

!!VRz1:S^Should the Magog Fireball attack damage own troops^;



Yes, I know - UN:C :frowning:


Magic resistance is a complex thing in VCMI, to early for such script. For such feature it is better to make Magog cast modded fireball with smart targeting.


Well, similar scripts exist in original WoG somewhere, just they are probably not very interesting for most people. Maybe @misiokles can find their ERM equivalents.

** function to make hero x16's monster stacks grow by 4%, to 10000


!!OW:C?y1; [get current player]
!!HEx16:O?y2; [get hero's owner]
!!DO700/0/6/1&y1=y2:Px16; [handle each slot if it's this hero's player's turn]

** end of function

** function to make slot x16 of hero x1's army grow by 4%, to 10000


!!HEx1:C0/x16/?y1/?y2; [get y1 type y2 qty]
!!VRy3:Sy2 *104 :100; [add 4%]
!!VRy3&y3>10000/y2<10000:S10000; [limit to 10000]
!!HEx1&y2<10000:C0/x16/y1/y3; [store new qty]

** end of function 
** function to invert the speed of monster x16


!!MA:Sx16/?y1; [get speed]
!!VRy2:S3; [default of 3 for very fast monsters]
!!VRy3:S700 +y1;
!!VRy2&y1<20:Svy3; [look up new speed]
!!MA&x16<145|x16>149:Sx16/y2; [set speed, except for war machines]

** end of function

Looks like missing v700-v7xx initialization, might be useful as a test


77 wog - map (10.7 KB)
It’s somewhere in this big script… :frowning:


found it

!!VRv700:C25/21/18/15/13/11/9/7/6/5; [table of new monster speeds]
!!DO693/0/173/1&3:P; [invert monster speeds]


Maybe this script will be more usefull.

   Display Hero Movement

 [If you right-click on the movement button, you'll
 [see the current hero's remaining movement points]

 [If you right-click on a hero's movement bar, you'll]
 [see the corresponding hero's remaining movement points]

 [Adventure Map right-click trigger]
!!UN:P25/?y-1; [See if script is enabled: y-1]
!!FU|y-1<>1/-999:E; [Exit if script isn't enabled or not your turn]
!!IF:V3/0 V4/0; [Initialize Flags 3 & 4 to False]
!!CM:I?v1; [Area clicked: v1]
!!IF&v1=7:V3/1; [Set Flag 3 to True if hero movement button is right-clicked]
!!IF&v1>=20/v1<=24:V4/1; [Set Flag 4 to True if a hero movement bar is right-clicked]
!!OW&3:A-1/?v2; [Current hero: v2]
!!VRv4&4:Sv1 -20; [Hero list number (0-4): v4]
!!OW&4:O-1/v4/?v2; [Hero number: v5]
!!IF&4/v2>=0:V3/1; [Set Flag 3 to True if movement bar is right-clicked by a valid hero]
!!HEv2&3/v2>=0:W?v3 B0/?z1; [Store movement points: v3 and hero's name: z1]
!!UN&3:A98/9/2; [Set Boots of Speed text: z2]
!!UN&3:A98/9/0; [Restore Boots of Speed text]
!!CM&3:R0;  [Disable standard right-click operation]


 [End of Display Hero Movement]

No GUI stuff for now, !!CM:I is evil anyway (it returns a number of particular GUI element (!), this is very bad for VCMI)


A script to change the orginal Battlefields in the game (6.8 MB)
(sorry, I’m too dumb to use github :frowning:


Cool, if it works. And is there is a way to use town siege backgrounds depending on terrain?


Made this work, except !#UN:G1/139/2 (It should change CCreature::abilityText but that field is not used anywhere)


By the way is there is posible to alter this script and add backgrounds to custom map terrain patches and custom banks and dwellings (they dont have fixed ids and subids)?


For me, such feature should be available in standart, vcmi way :slight_smile: By additional line in json.

	"core:creatureBank" : 
		"types" : 
			"object" : 
				"name" : "Object",
				"templates" : {
					"base" : { 
					"animation" : "object.def", 
					"visitableFrom" : [ "+++", "+++", "+++" ], 
					"mask" : [ "VVV", "VVV", "VBA" ],
					"allowedTerrains": [ "sand", "subterra", "rough", "lava" ] 
                                       "background": [ "pic1", "pic2", "picX" ]

The question is how much more “additional lines” do we want to be in configuration?


Its a good idea, but what is about obstacles on battlefields?
Or to give each obstacle string id name and to add to object also array of obstacles ids

PS Obstacles refresh is dead😭