Scripting suggestions (Lua, (V)ERM)

#16

Another smaller script from ERA.
Conflux rebalacing.

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

ZVSE
ERMS_ScriptDate=2.10(October).2012
_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
#17

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”
#18

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.

#19

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).

#20

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

ZVSE

!?MF1;                                  [Magogs Fireball-Attack doesnt damage own troops]
!!SN:W^Magog_Fireball_Enable^/?y1;
!!FU&y1=0:E;
!!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]

!!SN:W^Magog_Fireball_Enable^/?y1;
!!FU&y1=0:E;
!!BG:A?y1;                              [Aktion in y1]
!!MR:S?y2 F?y3;
!!if&y1=7/y2=21/y3<=105:;               [Fireball always does 105 damage]
!!MR:N?y10;
!!BMy10:I?y11;
!!MR&y11=0:F100;                        [Disable Magic damage for attacker side from Fireball]
!!en;


!?FU(OnBattleRegeneratePhase);
!!SN:W^Magog_Fireball_Switch^/-1;
!!BA:Q?y1;
!!FU&y1=1:E;                            [Exit in Quick Combat]

!!SN:X?y1;                              [Event parameter]
!!BMy1:T?y2;                            [Acting Monster Type]
!!SN&y2=45:W^Magog_Fireball_Switch^/y1;

!?CM4;
*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]
!!SN:W^Magog_Fireball_Switch^/?y3;
!!FU&y3=-1:E;
!!BMy3:T?y4;                            [Acting Monster Type]
!!if&y4=45:;

!!VRz1:S^Should the Magog Fireball attack damage own troops^;
!!VRz2:S^Yes^;
!!VRz3:S^No^;

!!VRv3:S0;
!!IF:G1/3/0/1/2/3/0/0/0/0/0/0/0/0/0/;
!!SN&v3=1:W^Magog_Fireball_Enable^/0;
!!SN&v3=2:W^Magog_Fireball_Enable^/1;
!!en:;

!?BA0;
!!SN:W^Magog_Fireball_Enable^/1;

Yes, I know - UN:C :frowning:

#21

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.

#22

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.

#23
** 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
#24

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

#25

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

#26

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]

#27

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]
#28

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

#29

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

#30

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

#31

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

#32

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)?

#33

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" ]
				},
#34

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

#35

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😭