Current time: 10.04.2025, 01:38 Hello There, Guest! (LoginRegister)
Language: english | russian  

Post Reply 
Threaded Mode | Linear Mode
Updating the erm help, please contribute
Author Message
Valery Offline

Posts: 2196
Post: #1

What I found so far, please add anything that could simplify scripters life and is not in erm help actually.


;If OB:T = 34 (hero). #get object under hero / erm snippet
  1. !!UN:C6919480/4/?y20;
  2. !!VRy20:+136736;
  3. !!VRy21:S[hero number]*1170+y20;
  4. !!VRy22:Sy21+12; y22 points to object type
  5. ; +16; y[NN] would point to object subtype
  6. !!VRy23:Sy21+20; y23 points to object control word (real OB:C)
  7. !!UN:Cy23/4/?y24; get object type under hero...

;Fix day of, all erm help is wrong about:

  1. Day (1..n): !!VRv1:Sc;
  2. Day (0..n): !!VRv1:Sc -1;
  3. Day of the month (0..27): !!VRv1:Sc -1 %28;
  4. Week of the month (0..3): !!VRv1:Sc -1 %28 :7;
  5. Week of the month (1..4): !!VRv1:Sc -1 %28 :7 +1;

; redraw town screen
  1. !!UN:C6919500/4/?y1; // TownManager
  2. !!SN:E6117392/2/y1; // RedrawTownScreen

;change battlefield during battle
  1. ; one way: call WoG function
  2. !!BA:B^file.pcx^;
  3. !!SN:E7740298/1; call 0x761B8A (result is v1)
  4. !!UN:C6919200/4/?y1; get [0x699420]
  5. !!VRy1:+78948; +0x13464
  6. !!UN:Cy1/4/v1; // set result
  7. ; another way: allocate Era string
  8. ; make new temporary array of 1 string, set its 0th element to our string and get its address to y2
  9. !!SN:M-1/1/1/0 Mv1/0/^file.pcx^ Mv1/?y2/0;
  10. !!UN:C6919200/4/?y1; get [0x699420]
  11. !!VRy1:+78948; +0x13464
  12. !!UN:Cy1/4/y2; // set string address

;Mop function, find hero portrait for DL
  1. !!FU48750:P[hero_mumber]/1/2;
  2. !!IF:M^Маленький потртет %Z1
  3. Большой портрет %Z2^;
  4. !?FU48750;
  5. x1 - hero number
  6. x2 - small portrait to z[number]
  7. x3 - large portrait to z[number]
  8. !!VRx1:*92+8144112;
  9. !!UN:Cx1/4/?y1;
  10. !!VRx1:+4;
  11. !!UN:Cx1/4/?y2;
  12. !!VRx2:*512+9597416;
  13. !!VRx3:*512+9597416;
  14. !!DO48751/1/512/1:Py1/x2 Py2/x3;
  15. !?FU48751;
  16. !!UN:Cx1/1/?y1 Cx2/1/y1;
  17. !!VRx16&y1=0:S600;
  18. !!VRx1:+1;
  19. !!VRx2:+1;

;safe functions equip/delete artifact
  1. !?FU338354; equip art
  2. ; x1 - hero or - 1 for current
  3. ; x2 - art type
  4. ; x3 - art subtype or -1 (usually for non-scrolls)
  5. ; x4 - slot or -1
  6. !!UN:C6919480/4/?y1; [y1 - BASE]
  7. !!VRy2:Sx1*1170+y1+136736; [y2 - pointer to hero structure]
  8. !!VRy5:S3*4+10784128-4; [y5 - pointer to y3]
  9. !!VRy3:Sx2; [artifact type = 5]
  10. !!VRy4:Sx3; [set y4 to subtype]
  11. !!SN:E5123184/2/y2/y5/x4;
  12. !?FU338357; unequip art
  13. ; x1 - hero or - 1 for current
  14. ; x2 - slot
  15. !!HE-1&x1=-1:N?x1;
  16. !!UN:C6919480/4/?y1; [y1 - BASE]
  17. !!VRy2:Sx1*1170+y1+136736; [y2 - pointer to hero structure]
  18. !!SN:E5123648/2/y2/x2;
  19. !?FU338355; check if artifact can be put in slot possible replacing existing art
  20. ; x1 - hero or - 1 for current
  21. ; x2 - art
  22. ; x3 - slot
  23. ; return v1 = 1 (yes) or 0 (no)
  24. !!UN:C6919480/4/?y1; [y1 - BASE]
  25. !!VRy2:Sx1*1170+y1+136736; [y2 - pointer to hero structure]
  26. !!SN:E5122736/2/y2/x2/x3;
  27. !!VRv1:&1;
  28. *******************************************************************************************
  29. !?FU338354; extract hero arts
  30. ; x1 - hero
  31. ; v1 - SN:M array of art/id pairs
  32. !!VRy1:S0; [y1 - slot]
  33. !!VRy10:S0; [y10 - array index]
  34. !!SN:M-1/28/0/0; [allocate array 14 * 2 of temp integer]
  35. !!VRy2:Sv1; [y2 - reslut]
  36. !!HEx1:A1/?y3/y1; [#4 y3 - art type]
  37. !!VRy4:S-1; [y4 - art subtype]
  38. !!if&y3>=1001:; [correct type/subtype for scrolls]
  39. !!VRy4:Sy3-1001;
  40. !!VRy3:S1;
  41. !!en:;
  42. !!FU338357&y3<>-1:Px1/y1; [unequip art if any]
  43. !!SN:My2/y10/y3; [save art info]
  44. !!VRy10:+1;
  45. !!SN:My2/y10/y4;
  46. !!VRy10:+1;
  47. !!VRy1:+1;
  48. !!VRy1&y1=13:S18;
  49. !!SN&y1<=18:G4;
  50. !!VRv1:Sy2;
  51. !?FU338353; equip hero arts from SN:M array
  52. ; x1 - hero
  53. ; x2 - SN:M array
  54. !!VRy1:S0; [y1 - slot]
  55. !!VRy2:S0; [y2 - array index]
  56. !!SN:Mx2/y2/?y3; [#2 y3, y4 - art type/subtype]
  57. !!VRy2:+1;
  58. !!SN:Mx2/y2/?y4;
  59. !!VRy2:+1;
  60. !!FU338354:Px1/y3/y4/y1; [equip art]
  61. !!VRy1:+1;
  62. !!VRy1&y1=13:S18;
  63. !!SN&y1<=18:G2;

;set scouting radius
  1. !!UN:C6547928/4/$; $=scouting radius, set to 0 to have next turn in fog. Backside: it affect all heroes so should be dependent of !?HL and default value is 5
;65000 objects allowed (XXL maps)
  1. !#UN:C4892718/1/183;
;pitlords summon horned demons
  1. !#UN:C5928811/1/49;


;DL addition:

Code:
A#1/#2/$/1    Change dialogue item characteristic.
#1 - item ID

#2    type    $
  3    Text    (string): new text of the item
  4    Def     (number): new cadre in Def
  11    Pcx     (string): new picture

#4  parameter should always be 1 (anyone care to explain why?)

Notes:
May be called in !?DL trigger and so may be used to customize the dialog on a fly.
(This post was last modified: 03.05.2015 22:24 by Valery.)
03.05.2015 22:15
Find all posts by this user Quote this message in a reply
Berserker Offline
Administrators

Posts: 16733
Post: #2

Quote:#4 parameter should always be 1 (anyone care to explain why?)
#4 Redraw dialog (1 or 0, 0 by default).


Скачать Герои 3 Эра и всё, что с ней связано / ERA 2.46f для старых модов
Поддержать проект
03.05.2015 22:28
Find all posts by this user Quote this message in a reply
gamecreator Offline

Posts: 7107
Post: #3

(03.05.2015 22:15)Valery Wrote:  What I found so far, please add anything that could simplify scripters life and is not in erm help actually.
SN:G may corrupt ERM conditions (if/el/en) if used from inside one.
And updated code for correct curse removal:
  1. !?FU1; правильно удаляет проклятье
  2. ; x1 = номер проклятья
  3. ; x2 = номер героя
  4. !!VRy1:S0; индекс
  5. !!UN:C7688945/4/?y2; получить поле проклятья (обычно 0x27FE810)
  6. !!UN:C7688968/4/?y3; получить поле героя (обычно 0x27FE814)
  7. !!UN:C7688927/4/?y4; получить максимальное количество проклятий
  8. !!FU&y1>=y4:E; проклятья закончились, ничего не найдено -> выход; начало цикла
  9. !!UN:Cy2/4/?y5; получить номер текущего проклятья
  10. !!UN:Cy3/4/?y6; получить номер текущего героя
  11. !!if&x1=y5/x2=y6:; нашли нужное проклятье
  12. !!SN:E7689874/1/x2/x1/y1; cdecl 0x755692(int hero, int curse, int index)
  13. !!HEx2&v1=0:Yx1/0/0/0; если функция сработала, то удалить информацию
  14. !!FU:E; конец функции
  15. !!en:; этот блок выходит из функции, конструкция el не нужна
  16. !!VRy1:+1; перейти к следующему проклятью
  17. !!VRy2:+20; 0x14 - размер структуры
  18. !!VRy3:+20; 0x14 - размер структуры
  19. !!SN:G4; перейти на начало цикла


When all gods have burnt to ashes in eternity of sorrow,
Demons gonna tear your soul because there is no tomorrow.
03.05.2015 23:01
Find all posts by this user Quote this message in a reply
Valery Offline

Posts: 2196
Post: #4

(03.05.2015 22:28)Berserker Wrote:  #4 Redraw dialog (1 or 0, 0 by default).

We never tested it with 0, and I saw nowhere that. Isn't it safer to say 1 is default?
(This post was last modified: 03.05.2015 23:18 by Valery.)
03.05.2015 23:17
Find all posts by this user Quote this message in a reply
gamecreator Offline

Posts: 7107
Post: #5

Wog sources say it's redraw. For example, you want to change several elements. If you redraw only when changing the last one, it would be much faster and smoother.


When all gods have burnt to ashes in eternity of sorrow,
Demons gonna tear your soul because there is no tomorrow.
03.05.2015 23:21
Find all posts by this user Quote this message in a reply
Valery Offline

Posts: 2196
Post: #6

Ah I see, thanks.

;find player starting town type
  1. !?FU15020;
  2. ;x1 current player
  3. !!UN:C6919480/4/?y1;
  4. !!VRy1:+128688; address of starting-town-type table
  5. !!VRy2:Sx1*4+y1; table has 4 bytes per color, starts at y1
  6. !!UN:Cy2/4/?y3; y3=starting Town type


; show oracle map
  1. !!UN:C6918840/4/?y1; [pAdvManager]
  2. !!SN:E4302672/2/y1; [ShowOracleMap]

;no ghosts will appear in town after demolishing all dwellings
  1. !?CM1;
  2. !!CA-1:U?y1;
  3. !!VRy1:*30+8630976+20;
  4. !!UN:Cy1/4/0;

;create DL dialog on holding mouse button
  1. !?FU9030;
  2. ;x1 DL #
  3. !!VRy1:Sv1;
  4. !!SN:E7510739/1/x1; [find HDlg -> v1]
  5. !!VRy2:Sv1; [v2 = HDlg]
  6. !!if&y2<>0:;
  7. !!SN:E5864096/1; [stop animation]
  8. !!UN:Cy2/4/?v1; [v1 = dialog]
  9. !!SN:E6245264/2/v1; [show while holding mouse button]
  10. !!SN:E5864272/1; [continue animation]
  11. !!SN:E7518240/2/y2; [destroy HDlg]
  12. !!en:;
  13. !!VRv1:Sy1;
(This post was last modified: 03.05.2015 23:33 by Valery.)
03.05.2015 23:25
Find all posts by this user Quote this message in a reply
Berserker Offline
Administrators

Posts: 16733
Post: #7

Valery, if you specify nothing, 0 is assumed. gamecreator is right, if you update several elements, use 1 only for the last one.
Meaning is: redraw the whole dialog after changing control state.


Скачать Герои 3 Эра и всё, что с ней связано / ERA 2.46f для старых модов
Поддержать проект
03.05.2015 23:26
Find all posts by this user Quote this message in a reply
Valery Offline

Posts: 2196
Post: #8

yes I understood, is that the error for missing redraw popped up only in 2.55.
03.05.2015 23:31
Find all posts by this user Quote this message in a reply
Berserker Offline
Administrators

Posts: 16733
Post: #9

Valery, we faced it in Phoenix even when Era had 1.xx versions. It comes from TE (2005). You were just lucky.


Скачать Герои 3 Эра и всё, что с ней связано / ERA 2.46f для старых модов
Поддержать проект
03.05.2015 23:42
Find all posts by this user Quote this message in a reply
Valery Offline

Posts: 2196
Post: #10

ok boss, all my DL have 4th parameter, I only forgot it once and I payed of my life and blood.

;must fix emerald tower script, right? As it is now, is big error:
  1. !?TM38;
  2. !!UN:P44/?y-1; [Check if script is enabled: y-1]
  3. !!FU&y-1<>1:E; [Exit if script isn't enabled]
  4. !!UN:U63/65/?v1; [Number of Emerald Towers: v1]
  5. !!VRv1:S-1; [Initialize v1 to -1 to work with new faster UN:U syntax]
  6. !!DO10910/1/v1/1&v1>0:P; [Loop through all Emerald Towers]
v1 stores number of towers and is set to -1 next command, then next command the loop is screwed. I fix it by replacing v1 with the usual y-1, ok?

  1. !!UN:U63/65/?y-1; [Number of Emerald Towers: y-1]
  2. !!VRv1:S-1; [Initialize v1 to -1 to work with new faster UN:U syntax]
  3. !!DO10910/1/y-1/1&y-1>0:P; [Loop through all Emerald Towers]

Amazing this error stayed there for 10 years.
(This post was last modified: 03.05.2015 23:55 by Valery.)
03.05.2015 23:48
Find all posts by this user Quote this message in a reply
Bes Offline

Posts: 5459
Post: #11

Quote:Function to change building position:

!!VRy1:S0; //city (e.g. Castle)
!!VRy2:S5; //building ID (e.g Tavern)

!!VRy6:S2; //frames num in new def
!!VRy3:S250; //new x
!!VRy4:S200; //new y

!!VRy5:Sy1 *44 +y2 *6 +6859276;

!!UN:Cy5/2/y6;
!!VRy5:+2;
!!UN:Cy5/2/y3;
!!VRy5:+2;
!!UN:Cy5/2/y4;

For more information try to see this post (with translator)
http://forum.df2.ru/index.php?showtopic=...t&p=192935
04.05.2015 00:26
Visit this user's website Find all posts by this user Quote this message in a reply
Valery Offline

Posts: 2196
Post: #12

Bersy, how to use in Komposer the erm format I see in some of the htm files? Like here in forum.
(This post was last modified: 04.05.2015 14:38 by Valery.)
04.05.2015 14:26
Find all posts by this user Quote this message in a reply
Berserker Offline
Administrators

Posts: 16733
Post: #13

I didn't include highlighting script there. Once solitaire345 did it. He also added SN commands from Era. I understood you correctly?
We could try, if you wish.


Скачать Герои 3 Эра и всё, что с ней связано / ERA 2.46f для старых модов
Поддержать проект
04.05.2015 15:06
Find all posts by this user Quote this message in a reply
Valery Offline

Posts: 2196
Post: #14

yes, solitaire used it in several receivers htm. Did this mean he had to implement it for only that file?

of course it looks better with, as all other codes examples are pure red. But if too much work, it will be enough as it is.
04.05.2015 15:14
Find all posts by this user Quote this message in a reply
Berserker Offline
Administrators

Posts: 16733
Post: #15

Not too much, but I'm currently feeling graaaay…fog.


Скачать Герои 3 Эра и всё, что с ней связано / ERA 2.46f для старых модов
Поддержать проект
04.05.2015 17:26
Find all posts by this user Quote this message in a reply
« Next Oldest | Next Newest »
Post Reply 


Forum Jump:

Powered by MyBB Copyright © 2002-2025 MyBB Group