Heroes of Might and Magic Community
visiting hero! Register | Today's Posts | Games | Search! | FAQ/Rules | AvatarList | MemberList | Profile


Age of Heroes Headlines:  
5 Oct 2016: Heroes VII development comes to an end.. - read more
6 Aug 2016: Troubled Heroes VII Expansion Release - read more
26 Apr 2016: Heroes VII XPack - Trial by Fire - Coming out in June! - read more
17 Apr 2016: Global Alternative Creatures MOD for H7 after 1.8 Patch! - read more
7 Mar 2016: Romero launches a Piano Sonata Album Kickstarter! - read more
19 Feb 2016: Heroes 5.5 RC6, Heroes VII patch 1.7 are out! - read more
13 Jan 2016: Horn of the Abyss 1.4 Available for Download! - read more
17 Dec 2015: Heroes 5.5 update, 1.6 out for H7 - read more
23 Nov 2015: H7 1.4 & 1.5 patches Released - read more
31 Oct 2015: First H7 patches are out, End of DoC development - read more
5 Oct 2016: Heroes VII development comes to an end.. - read more
[X] Remove Ads
LOGIN:     Username:     Password:         [ Register ]
HOMM1: info forum | HOMM2: info forum | HOMM3: info mods forum | HOMM4: info CTG forum | HOMM5: info mods forum | MMH6: wiki forum | MMH7: wiki forum
Heroes Community > Heroes 3.5 - WoG and Beyond > Thread: ERM help and discussion
Thread: ERM help and discussion This Popular Thread is 407 pages long: 1 50 100 150 ... 193 194 195 196 197 ... 200 250 300 350 400 407 · «PREV / NEXT»
felipe
felipe


Known Hero
Editing Heroes Without Limits
posted March 13, 2013 02:56 PM

Quote:
Just tested, does not work with arenas. I think when you place a new one, it is given number 0 by default and then no matter what number you give it, it still remains stored somewhere. So every arena placed will be set to visited if you visit one. But surely works with objects having their own receiver.


It works with:

!?FU22503;

!!UN:U4/-1/?y6;
!!FU&y6=0:E;
!!UN:U4/-1/-1/9501;
!!OBv9501/v9502/v9503:Cv9504; [give it a number not used]
!!VRv9504:Sv9504 +1;


Now I have lot of diferent arenas in the game. Nice!

Thanks JimV and Salamander

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Salamandre
Salamandre


Admirable
Omnipresent Hero
Wog refugee
posted March 13, 2013 03:00 PM

I don't understand what you did.
____________
Era II mods and utilities

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Bersy
Bersy


Honorable
Supreme Hero
posted March 13, 2013 04:13 PM

He assigned indexes to all arenas in range of 0..number of arenas - 1. I think that real arena list is smaller, so part of memory is reused and part is corrupted. It will lead to unexpected crashes in the future.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
JimV
JimV


Responsible
Supreme Hero
posted March 13, 2013 04:21 PM
Edited by JimV at 16:35, 13 Mar 2013.

Quote:

!!UN:U4/-1/?y6;
!!FU&y6=0:E;
!!UN:U4/-1/-1/9501;
!!OBv9501/v9502/v9503:Cv9504; [give it a number not used]
!!VRv9504:Sv9504 +1;



Good work, but a couple of minor comments:
!!VRv9504:Sv9504 +1; could be slightly improved to !!VRv9504:+1;

However, I don't think there is a need to use v9504 at all:

!?TM2&(some day and once conditions); (or some other trigger)
!!UN:U4/-1/?y6; get y6=number of Arenas
!!FU&y6=0:E;
!!VRv9501:S-1; initialize for UN:U search
!!VRy6:-1; reset y6 for 0 to N-1 DO
!!DO22503/0/y6/1:P;

!?FU22503; x16=0 to N-1
!!UN:U4/-1/-1/9501; get location of next Arena in v9501-3
!!OBv9501/v9502/v9503:Cx16; [give it a number not used]

That is, besides v9504, the get/check of y6 in FU22503 seems redundant to me - if the number of Arenas was zero we wouldn't be in FU22503, or shouldn't be.

There are many ways to accomplish something in ERM, and the most important thing is the accomplishment, but it is more efficient to remove unnecessary operations.

P.S. Bersy's comment above was not showing when I started this. ERM Help (quoted previously) states that this procedure may or may not work, so it depends on what the data structure for Arenas is and how much of it is established by the UN:I placement command. The Bersy Rule would of course be definitive, but that depends on whether Bersy was speaking ex cathedra or not. I may do some memory searches to try to find out.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Salamandre
Salamandre


Admirable
Omnipresent Hero
Wog refugee
posted March 13, 2013 04:26 PM

I need a script splitting my creatures in 4, 5 or 6 equal stacks. The way I did it was:

a) check creature ID/no/exp in clicked slot
b) Find how many empty slots are available and exit if not enough
c) do the split according to player choice
d) count the total number of split creatures and compare to initial number
e) adjust if rounded up or down
f) to enable the split dialog, ctrl+left-click on any slot having creatures in.

It works but with one backside: I am not able to make it work if player already has same creature in two or more slots, therefore my script exits if such possibility. Because when I count the final result, it gets corrupted if another stack with same ID was already there. I would need some input about, or at least directions to take, or maybe I can just leave as it is and keep warning messages?

Split.erm

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
JimV
JimV


Responsible
Supreme Hero
posted March 13, 2013 04:56 PM
Edited by JimV at 17:42, 13 Mar 2013.

One option would be to use seven variables, preferably in a continuous sequence, e.g. v1-v7, to "flag" slots which will contain the split-up troops. This would include the original slot that was clicked and blank slots only. For example, suppose v1-v7 was initialized to zeroes, then the slots were checked and the original slots plus the blank slots have been flagged with ones. Then, for example, v1-v7 = 0 1 1 0 1 0 0 means that the second, third, and fifth slots are available to hold split troops.

Then a processing DO-loop would be set for all seven slots (DOxx/0/6), but unflagged slots would be skipped:

...
!!DOxxx/0/6/1:P...

!?FUxxx; x16=slot #
!!VRy1:Sx16+1; index to v1-v7 table
!!FU&vy1=0:E;
...

I would be inclined to first count the number of blank slots and limit the choice offered to 2-(number of blank slots +1), but I see another comment has been posted while I typed this so I will click Submit.

P.S. False alarm, my email was just giving me a late notice of a comment that was already showing when I started this.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Salamandre
Salamandre


Admirable
Omnipresent Hero
Wog refugee
posted March 13, 2013 05:11 PM
Edited by Salamandre at 17:17, 13 Mar 2013.

I am not sure I know how to flag a slot, for instance this is how I fill them:

!?FU989370;
;x1 hero ID
;x2 creature ID
;x3 initial number
;x4 experience
;x5 number after split
;x6 split choice
!!if&x6=1:; split in 4 stacks
!!FU&v8796=4:E; exit after filling four slots
!!HEx1:C0/x16/?y1/?y2/?y3/2;
!!HEx1&y2<1:C0/x16/x2/x5/x4;
!!VRv8796&y2<1:+1;
!!en:;

The original slot: I delete creatures then add again the split result in.

Edit: ah, flag with vx16+1, right? Will be v1-v7.
____________
Era II mods and utilities

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
JimV
JimV


Responsible
Supreme Hero
posted March 13, 2013 05:27 PM
Edited by JimV at 17:29, 13 Mar 2013.

Quote:

ZVSE

!?CM0&-200;
!!UN:U4/0/?y-1; get the number of arenas on map
!!IF:M^There are %Y-1 arenas^;
[insert here exit if y-1 already at maximum]
!!VRy-1:+1; <--?
!!UN:I10/10/0/4/0; place arena
!!OB10/10/0:Cy-1; give it a number not used
!!IF:V200/1; disable script


I think the reason that this did not work is that objects are numbered from zero to (N-1) (where N is the total number of those objects on the map), not 1 to N. By numbering the new object as N+1 you skipped N.

As I see it (assumes flagging has been done previously, in v1-v7):

Quote:
!?FU989370;
;x1 hero ID
;x2 creature ID
;x3 initial number
;x4 experience
;x5 number after split
;x6 split choice
!!VRy1:Sx16+1; index to v1-v7 flags (assumes v1-v7 used)
!!FU&vy1=0:E; don't use slot x16 if it wasn't flagged

!!if&x6=1:; split in 4 stacks
!!FU&v8796=4:E; exit after filling four slots
!HEx16...no need to check--it was flagged for use
!!HEx1&y2<1:C0/x16/x2/x5/x4;
!!VRv8796&y2<1:+1;
!!en:;

... and so on


 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Salamandre
Salamandre


Admirable
Omnipresent Hero
Wog refugee
posted March 13, 2013 05:32 PM
Edited by Salamandre at 17:35, 13 Mar 2013.

Got it to work:

!?FU989370;[split action]
;x1 hero ID
;x2 creature ID
;x3 initial number
;x4 experience
;x5 number after split
;x6 split choice
!!if&x6=1:; split in 4 stacks
!!FU&v8796=4:E; exit after filling four slots
!!HEx1:C0/x16/?y1/?y2/?y3/2;
!!HEx1&y2<1:C0/x16/x2/x5/x4;
!!VRv8796&y2<1:+1;
!!VRy4&y2<1:Sx16+1;
!!VRvy4&y2<1:S1;

!!en:;

Then when count, it will ignore flagged slots:

!?FU989371; get the total number after split
;x1 hero ID
;x2 creature ID
;x3 initial number
;x4 experience
!!HEx1:C0/x16/?y1/?y2/?y3/2;
!!VRy4:Sx16+1;
!!FU&vy4=0:E;

!!if&y1=x2:;
!!VRv8797:+y2; count creatures after split
!!en:;

Thanks, I see while I was typing you posted already.
____________
Era II mods and utilities

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
JimV
JimV


Responsible
Supreme Hero
posted March 13, 2013 05:40 PM

Good work.

I did the test that I said Felipe should do: put several Arenas on a test map, and checked their OB:C numbers. The numbers were 0 to N-1, so it appears that OB:C = object number for Arenas (this is not always true, ERMers beware). I would add Arenas to the ERM Help notes about UN:I (use OB:C to set them up), except for the Bersy Rule.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Salamandre
Salamandre


Admirable
Omnipresent Hero
Wog refugee
posted March 13, 2013 06:10 PM
Edited by Salamandre at 18:14, 13 Mar 2013.

Meh, there is a terrible glitch. If we ctrl+left click while dragging the stack into another stack, the commands get confused, as the slot clicked is no more the original. The optimal solution would be ctrl + right click as this can't change a slot place, but looks like this code is not supported.

I will probably use double trigger as in Phoenix mod. Right-click on tactics icon and select split choice. Then when ctrl + left click on troop, no dialog, directly split.
____________
Era II mods and utilities

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
JimV
JimV


Responsible
Supreme Hero
posted March 13, 2013 06:24 PM

I don't know why I would ctrl-left-click to drag a troop as I always click to select a slot then click the slot I wish to move it to, but no doubt there is a good reason. If so, there are also Alt-Click, Ctrl-Alt-click, et cetera. Also it might be possible to combine Ctrl and right-click using Bersy's FU trigger to detect a keypress (the Ctrl key). I think there is a routine in XFiles to check for a keypress or mouse-button press also. (A callable check to see if a key or mouse button is up or down.)

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Salamandre
Salamandre


Admirable
Omnipresent Hero
Wog refugee
posted March 13, 2013 06:38 PM
Edited by Salamandre at 18:44, 13 Mar 2013.

Normally we don't. But if player clicks on slot so is highlighted and while it drags in another slot which is occupied by other ID it holds suddenly ctrl, he gets a nice bonus, some extra %50 more creatures, as both slots get confused. Some may use it as exploit, yet I don't see how to prevent it with my skills. Ctrl+right-click would be optimal in this case, as it does not trigger any regular action.
____________
Era II mods and utilities

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Bersy
Bersy


Honorable
Supreme Hero
posted March 13, 2013 07:21 PM
Edited by Bersy at 19:57, 13 Mar 2013.

Answered you on wforum, Val.

Returning to Arena theme.

// HE:V - "visited" flags for objects
else if(Cmd=='V'){
{
Dword mask;
int v;
if((M.n[0]<0)||(M.n[0]>=10)){ MError("\"HE:V\"-wrong object type index (0...10)."); goto l_exit; }
if(Num==2){       // V#/# посещенность объектов
Apply(&p->Visited[M.n[0]],4,&M,1);
}else if(Num==3){ // V#/#/# посещенность объектов
if((M.n[1]<0)||(M.n[1]>=32)){ MError("\"HE:V\"-wrong object index (0...32)."); goto l_exit; }
mask=1;
for(i=0;i<M.n[1];i++) mask<<=1;
if(p->Visited[M.n[0]]&mask) v=1; else v=0;
if(Apply(&v,4,&M,2)) break;
if(v) p->Visited[M.n[0]]|=mask; // установим
else  p->Visited[M.n[0]]&=~mask;
}
}

You see, 10 types of objects.

From _Hero_ structure:

Dword  Visited[10];

Now it's obvious that dword is 32-bits container allowing up to 32 objects to be marked. It's not an array, so instead of crashes we will face invalid behavior of 33-th object and higher.

EDIT: Probably the best solution is to set objects with 32+ indexes to 31. Will be a documented safe bug called a feature.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
JimV
JimV


Responsible
Supreme Hero
posted March 13, 2013 07:59 PM
Edited by JimV at 20:01, 13 Mar 2013.

Thanks Bersy, that is what I thought (other visitable objects such as Trees of Knowledge are usually limited to 32). I will add this information to ERM Help (3.58f).

Bersy probably has a better way, but XFiles could be used for a Ctrl-RMB test:

ZVSE

* TestKeyGet, JHV, March 13, 2013

!?CM2; Hero screen right-click Flag
!!CM:F?v1 I?v2; v1=512 for R-C, v2=141 Flag
!!FU|v1<>512/v2<>141:E;
* Load dll and get ID
!!VRz1:S^XFiles.dll^; store dll name
!!SN:Lz1/?y1; now y1 holds dll ID [IMPORTANT: never use ?v1 in SN]
!!VRz1:S^KeyGet^; store function name
!!SN:Ay1/z1/?y2; get function address to y2
* call KeyGet(Key,IfDown), Key=16 for Shift, 17 for Ctrl, 18 for Alt
!!SN:Ey2/1/17/?y3;
!!IF:M^y3=%Y3^;

That is, using the latest version of XFiles.zip in this Box folder.

(I had MouseGet but not KeyGet until just now.)

XFiles was written for Era 1.8, so the zipped files have to be extracted into a Mod folder under Mods in Era 2. The test script shows what value is returned by KeyGet when testing for the Ctrl key after a right-click on the player flag in the Hero Screen.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Salamandre
Salamandre


Admirable
Omnipresent Hero
Wog refugee
posted March 13, 2013 08:09 PM
Edited by Salamandre at 21:01, 13 Mar 2013.

Thanks, Bersy also gave me code for ctr + right click. I think I managed it to work properly now, and it took me way more than 5 minutes, actually 4 hours of struggle and check x1-x6 to see where was wrong. Can you please test it and tell me if anything I missed?

;SPLIT STACKS when ctrl+click on a slot
!?CM2;
!!SN:L^user32.dll^/?y1 Ay1/^GetKeyState^/?y2 Ey2/1/17;
!!VRy1:Sv1&65535;
!!FU&y1<32768:E; exit if not ctrl hold
!!CM:I?y-40 F?y-41;
!!FU|y-40<68/y-40>74/y-41<>512:E; right click on army slots
!!VRv8795:C0/0/0/0/0; initialize counter for empty slots/counter for same type of creature etc
!!HE-1:N?y-42; [get active hero in y-42]
!!VRy-40:-68; now y-40=slot # from 0 to 6
!!HEy-42:C0/y-40/?y1/?y2/?y3/2; y1=type, y2=no., y3=experience
!!FU&y2<4:E; exit if less than 4 creatures
!!VRz1:S^Choose your split^;
!!VRz2:S^4 equal stacks (Utopia)^;
!!VRz3:S^5 equal stacks (Creature banks)^;
!!VRz4:S^6 equal stacks (AI combat)^;
!!VRz5:S^Leave^;
!!IF:G1/8/8/z1/z2/z3/z4/z5;
!!FU&v8=8:E;
!!VRv1:C0/0/0/0/0/0/0; index to flagged slots
!!VRy4:Sy2;
!!VRy4&v8=1::4; [4 stacks]
!!VRy4&v8=2::5; [5 stacks]
!!VRy4&v8=4::6; [6 stacks]
!!FU&y2<5/v8=2:E; [exit if less creatures in stack than the option selected]
!!FU&y2<6/v8=4:E;
!!DO989369/0/6/1:Py-42/y1; [find how many empty slots or if same creature in several slots]
!!IF&v8=1/v8795<3:M^You need 3 empty slots for this action!^;
!!FU&v8=1/v8795<3:E;
!!IF&v8=2/v8795<4:M^You need 4 empty slots for this action!^;
!!FU&v8=2/v8795<4:E;
!!IF&v8=4/v8795<5:M^You need 5 empty slots for this action!^;
!!FU&v8=4/v8795<5:E;
!!HEy-42:C0/y-40/-1/-1;
!!DO989370/0/6/1:Py-42/y1/y2/y3/y4/v8; [split]
!!DO989371/0/6/1:Py-42/y1/y2/y3;   [count splitted creatures and get total number]
!!if&v8797>y2:; if we got more
!!VRv8798:Sv8797-y2;
!!en:;
!!if&v8797<y2:;
!!VRv8798:Sy2-v8797;
!!en:;
!!DO989372/0/6/1&v8797>y2:Py-42/y1/y3/v8798;  [adjust the stack rounded up]
!!DO989373/0/6/1&v8979<y2:Py-42/y1/y3/v8798;  [adjust the stack rounded down]
!!CM:R0;
!!UN:R3/-1;

!?FU989369; find how many empty slots there are
;x1 hero id
;x2 initial creature ID
!!HEx1:C0/x16/?y1/?y2/?y3/2;
!!VRy4&y2<1:Sx16+1;
!!VRvy4&y2<1:S1;
!!VRv8795&y2<1:+1;

!?FU989370;  [split]
;x1 hero ID
;x2 creature ID
;x3 initial number
;x4 experience
;x5 number after split
;x6 split choice
!!if&x6=1:; split in 4 stacks
!!FU&v8796=4:E; exit after filling 4 slots
!!HEx1:C0/x16/?y1/?y2/?y3/2;
!!VRy4:Sx16+1;
!!FU&vy4<1:E;
!!HEx1:C0/x16/x2/x5/x4;
!!VRv8796:+1;
!!en:;
!!if&x6=2:; split in 5 stacks
!!FU&v8796=5:E; exit after filling 5 slots
!!HEx1:C0/x16/?y1/?y2/?y3/2;
!!VRy4:Sx16+1;
!!FU&vy4<1:E;
!!HEx1:C0/x16/x2/x5/x4;
!!VRv8796:+1;
!!en:;
!!if&x6=4:; split in 6 stacks
!!FU&v8796=6:E; exit after filling 6 slots
!!HEx1:C0/x16/?y1/?y2/?y3/2;
!!VRy4:Sx16+1;
!!FU&vy4<1:E;
!!HEx1:C0/x16/x2/x5/x4;
!!VRv8796:+1;
!!en:;

!?FU989371; get the total number after split
;x1 hero ID
;x2 creature ID
;x3 initial number
;x4 experience
!!HEx1:C0/x16/?y1/?y2/?y3/2;
!!VRy4:Sx16+1;
!!FU&vy4=0:E;
!!if&y1=x2:;
!!VRv8797:+y2; count creatures after split
!!en:;

!?FU989372; adjust if more
;x1 hero ID
;x2 creature ID
;x3 experience
;x4 adjust value
!!HEx1:C0/x16/?y1/?y2/?y3/2;
!!FU&y1<>x2:E;
!!VRy2:-v8798;
!!HEx1:C0/x16/y1/y2/y3/2;
!!VRx16:S99;
!!FU&x16=99:E;

!?FU989373; adjust if less
;x1 hero ID
;x2 creature ID
;x3 experience
;x4 adjust value
!!HEx1:C0/x16/?y1/?y2/?y3/2;
!!FU&y1<>x2:E;
!!VRy2:+v8798;
!!HEx1:C0/x16/y1/y2/y3/2;
!!VRx16:S99;
!!FU&x16=99:E;


 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Bersy
Bersy


Honorable
Supreme Hero
posted March 13, 2013 08:11 PM
Edited by Bersy at 20:12, 13 Mar 2013.

The proposed on wforum way was the following:

!!SN:L^user32.dll^/?y1 Ay1/^GetKeyState^/?y2 Ey2/1/17;
!!VRy1:Sv1&65535; 2-bytes WORD
!!FU&y1<32768:E; check the higher bit
; CTRL is pressed...


GetKeyState is user32.dll function, default WinAPI. Takes one argument only, so easy to use even in ERM, IMO.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Salamandre
Salamandre


Admirable
Omnipresent Hero
Wog refugee
posted March 13, 2013 08:25 PM
Edited by Salamandre at 20:30, 13 Mar 2013.

Hmm, my last problem is: after processing split, if I go from hero screen to another hero, it keeps the previous hero ID, tried to reset in function hero ID, not working.

Solved: OW:A-1/?y1 does not change, but HE-1:N?y1 does when switching from hero screen.
____________
Era II mods and utilities

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
JimV
JimV


Responsible
Supreme Hero
posted March 13, 2013 08:33 PM
Edited by JimV at 20:51, 13 Mar 2013.

Thanks Bersy, very elegant. In my version the returned value would be zero when the key is not pressed and usually -32677 (high bit set, sometimes other bits may be set) when the key is pressed. [Update - no, your test is better, I am assuming I am playing Heroes full-screen with no interruptions which I always am, but others may not be.]

I have updated the WoG 3.58 ERM Help (here), adding these words to the end of the UN Receiver table:

...
These objects will probably need additional set up with their specific object receiver to work correctly:

Arena (type=4, subtype=0) - Receiver: !!OB:C to set next higher object number (see NOTE)
...
Windmill (type=112, subtype=0) - Receiver: !!ML

NOTE: in most cases the total number of these objects is limited to 32 (object numbers 0-31), so any with object numbers greater than 31 will not work.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
majaczek
majaczek


Supreme Hero
Work at Magic Dimmension
posted March 14, 2013 02:36 PM

How does !!UN:R6 work exactly in battle screen. I used in in !?BG trigger - and it seems the later command may execute a bit later in battle queye (for example in my flash swinng script it may execute on already reborn target if timer is enough big)

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Jump To: « Prev Thread . . . Next Thread » This Popular Thread is 407 pages long: 1 50 100 150 ... 193 194 195 196 197 ... 200 250 300 350 400 407 · «PREV / NEXT»
Post New Poll    Post New Topic    Post New Reply

Page compiled in 0.5570 seconds