Scripting suggestions (Lua, (V)ERM)

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

!?FU699;

!!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

!?FU700;

!!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

!?FU693;

!!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 rules.zip (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]
!!VRv710:C5/5/4/4/4/4/4/3/3/3;
!!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]
!?CM0;
!!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]
!!VRz2&3:Sz125004;
!!UN&3:A98/9/2; [Set Boots of Speed text: z2]
!!IF&3/v2>=0:Q1/8/98/4/z125005;
!!IF&3/-4/v2<0:Q1/-1/-1/4/z125006;
!!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 .newBattlefields.zip (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šŸ˜­

The basic idea is great. But iā€™d prefere to make that depend on various other things. So basically: Every peasant in heroes army gives only 1 gold per day. But if hero has estates, gives additionally 1/2/3/4 gold $ for specialists). If hero has gold producing artifacts, give another gold per peasant depending on artifact. Peasants in town may increase town income if market place is built. Peasants in town may increase resource silo production by 1 every 100 peasants. Peasants in town may add a weekly creature growth in that town if the grail is built. And so on :slight_smile:
Peasants in army of resource specialist may add more of that resource. If hero has resource producing artifact, add more of that resource per 100 peasants.

On current build this script about battlefields do not work. Can you share a working version? Please!

So you think we can build some working ERM script with things implemented so far? It is mostly VR so I am doubtful about it. Iā€™ve only seen a script showing a message when map starts.

with the erm inserted in vcmi you can do exactly what you can do with the erm in era 3?

No. It is just a small piece implemented for now and it is completely useless. And there is no active development here for now. If you have some very tiny useful script we can try to get it working but even this will take months. I have plans to get Android build working first