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 ... 165 166 167 168 169 ... 200 250 300 350 400 407 · «PREV / NEXT»
Salamandre
Salamandre


Admirable
Omnipresent Hero
Wog refugee
posted October 19, 2012 03:41 PM
Edited by Salamandre at 19:58, 19 Oct 2012.

This script is driving me crazy. I get error castle out of range, but when reload + F12, no error. What would be better ways to store AI starting town and avoid problems later? What I do is this:

(loop each first day of the week and change all AI towns to his starting town type)
!?FU15002;
!!UN:U98/-1/-1/1; [castle coordinates]
!!VRv300:Cv1/v2/v3; use later in do loop (15010)
!!CA1:O?y1;  Owner
!!FU&y1<0:E; exit if neutral
!!OW:Iy1/?y2; 1 AI/0 human
!!FU&y2<>1:E; Only AI
!!OW:C?y3; current player
!!if&y1=y3:;  if owner=current player
 !!OW:Ny3/0/?y2; get first AI town number
 !!CA0/y2:T?y4; get type
 !!CA1:T?y5;
 !!CA1&y4<>y5:Ty4 I0; change to that faction type if not same
[..]

I also tried CA300, same problem. I added checks to display AI first town number (CA0/y2) and see if value is corrupt somehow. The problem is that each time I add checks and refresh scripts, error does not show. Will try with a different timer (I was using universal TM2, maybe there is the problem), run out of solutions. This happens to me on XXL map, I ran a test on XL map with 7 AI, end turn for 3 months, no error and towns match each AI.
____________
Era II mods and utilities

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


Responsible
Supreme Hero
posted October 19, 2012 08:30 PM
Edited by JimV at 20:31, 19 Oct 2012.

I'll just reiterate what my experience has been, which may not be relevant:

I did something similar in the map "Ice Arrow". Petar wanted all of Hell Zealot's (Red) Towns to turn into Infernos, except for Towers:

ZVSE

* Convert all towns  owned by Red (except Towers) to Inferno towns

* uses Timer 6 and FU102
* uses v1-v4 for temporary use

!#TM6:S2/999/1/1; Red Timer, every day from 2 on

!?TM6;
!!UN:U98/-1/?v1; get total # of towns on map
!!VRv2:S-1; must initialize v2<0 for "next" search
* note if v1=0 DO102 should stop without any executions (I think)
!!DO102/1/v1/1:P98/-1;

** function to check map town objects
!?FU102;  x1=type, x2=subtype
!!UN:Ux1/x2/-1/2; put coordinates of next type x1/x2 object --> (v2,v3,v4)
!!CA2:O?y1; check owner=y1
!!FU&y1<>0:E; exit it Red not the owner
!!CA2:T?y2; y2=town type (Tower=2)
!!FU&y2=2:E; exit if Tower
!!CA2:T3;

Neither Petar nor I ever noticed a problem with this in our playtests, nor did any other players report any problems. The map was XL, WoG 3.58f.

In the Dragon Peaks mod, I had a problem with one of the WoG scripts which checks every Town, in random XL maps, under Era 2.3. At some point in the game after several months, the UN:U command failed at the last Town on the map. A few days later the problem would correct itself. I added a patch to the script to skip the last Town when the problem occurred.

I have not yet understood your problem well enough to know if it is identical to my Dragon Peaks problem (that is, if the error only occurs on the last Town). If so, then my guess would be that the problem is somehow due to Era vs. WoG 3.58f. (I don't think this is very likely, just that it would fit the pattern so far.) If not, then my guess (again, not a confident one) would be that the problem is specific to XXL maps. Of course, there could be many other possible causes: script interferences, plugin interferences, etc.

If the error does not cause a crash, one option for living with it would be to disable WoG error messages with UN:P904 during the process and re-enable them afterwards (as Bersy recommended for a similar problem).

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


Admirable
Omnipresent Hero
Wog refugee
posted October 19, 2012 08:38 PM
Edited by Salamandre at 20:58, 19 Oct 2012.

Changing towns type when we know already who's the player and what is his town is not a problem. I suspect the CA0/x to provide some error when we try to get what is his first town in the list. I have same trigger on neutral towns attack and never caused error, but sometimes it is ignored for no apparent reason (excluding first week captured when there may be no battle), and because this bug I had to add a timer which match all new towns.

;All AI towns will match his faction
!?BA1&-1000;  only vs neutral towns or AI-AI
!!BA:P?v300/?v301/?v302;
!!OBv300/v301/v302:T?y2;
!!FU&y2<>98:E; exit if not town
!!HE-1:O?v2;
!!FU&v2<0:E; exit if hero dead
!!OW:C?y1;  current player
!!OW:Ny1/0/?y2; get first AI town number
!!FU&y2<0:E;
!!CA0/y2:T?y3; get type of starting town
!!CA300:T?y4; get type of new town
!!CA300&y4<>y3:Ty3 I0; match


In fact, my question was about storing each AI starting town type, maybe there is a better way than constantly checking for?
____________
Era II mods and utilities

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


Responsible
Supreme Hero
posted October 19, 2012 09:10 PM
Edited by JimV at 21:12, 19 Oct 2012.

Doesn't the WOGERMLOG tell you what the CA0/[] value was at the point of the error? (Or if you converted to temporary v-variables, you could use EVME.)

However, there probably is another way to get the Town type for each faction. It must be stored somewhere since the Scenario Information shows it, so there ought to be a UN:C address for it (which I don't know). This would probably work better in the case that an AI player lost its starting Town, and its next Town was not the same type. In a custom map, an AI player could start without any Towns, but probably not in a random map.

Without knowing a UN:C address, I would probably check the Town type of each player on day 1 and save them in permanent variables.

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


Admirable
Omnipresent Hero
Wog refugee
posted October 19, 2012 09:50 PM
Edited by Salamandre at 03:02, 20 Oct 2012.

I assume his next town will be of same type with scripts everywhere changing every of his towns. I will try to get a log, so far tested quickly again XL map for 4 months, no error, so indeed could be related to XXL. Thanks for suggestions.

@Edit: ok, got it on XXL again, here is what log says:

y1="7"
y2="-1"
y3="7"
y5="2"
ERM syntax Error.
File: casdem
Line: 1737
Reason:
"CA$"-cannot find castle (out of range).

The AI was tower (y5=2 correct), player was pink so y3 correct too and after error all its town were changed to castle, which means the castle number returned as -1 and from then y4 is not set.

!!OW:Ny3/0/?y2; get first AI town number, returned -1
!!CA0/y2:T?y4;
!!CA1:T?y5; *this was correct in log
!!CA1&y4<>y5:Ty4 I0; y4 remains zero and town gets changed to castle

As usual, on reload all worked fine. This means I will have to put condition y2>-1 and see if this time still error.
____________
Era II mods and utilities

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


Responsible
Supreme Hero
posted October 20, 2012 03:15 AM

As a possible alternative to OW:N, I found a table of starting Town types which agrees with those shown in the Scenario Information screen, starting at y2=[0x699538]+0x1F6B0 (that is, read the value at y1=0x699538 with UN:Cy1/4/?y2, then add 0x1F6B0 to y2), then Red's Town type is UN:Cy2/4/?y10, Blue's at UN:C(y2+4)/4/?y11, et cetera. (I just found the addresses and haven't converted them to decimal.) Unused colors have the value -1. The addresses are the same for both WoG 3.58f and Era 2.3.

Maybe these values get glitched somehow also, but they might be worth a try.

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


Admirable
Omnipresent Hero
Wog refugee
posted October 20, 2012 03:52 AM

I don't know how to work with those...
____________
Era II mods and utilities

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


Honorable
Supreme Hero
posted October 20, 2012 12:52 PM

These are SoD 3.2 addresses, will work everywhere.

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


Responsible
Supreme Hero
posted October 20, 2012 04:41 PM
Edited by JimV at 16:47, 20 Oct 2012.

A (rushed, lightly-tested) example:

ZVSE

* TestTownTypes, JHV, Oct. 2012
* Starting Town Types Table: [699538]+1F6B0=[6,919,480]+128,688

!#UN:C6919480/4/?v2;
!#VRv2:+128688;
!#VRy1:S2; any color, 0-7, 2=Tan
!#VRy2:Sy1*4+v2; table has 4 bytes per color, starts at v2
!#UN:Cy2/4/?y3; y3=starting Town type (0-8 for Castle-Conflux, -1 for none) of color y1
!#IF:M^Tan's starting Town type number is %Y3.^;

!?GM0;
!!UN:C6919480/4/?v2;
!!VRv2:+128688;
!!VRy1:S2; any color, 0-7, 2=Tan
!!VRy2:Sy1*4+v2; table has 4 bytes per color, starts at v2
!!UN:Cy2/4/?y3; y3=starting Town type (0-8 for Castle-Conflux, -1 for none) of color y1
!!IF:M^Tan's starting Town type number is %Y3.^;

If the sample code is used in a DO-function where y1 is changed to x16 and x16 varies from color 0 (Red) to color 7 (Pink), and the associated Town types are stored somewhere, then the DO must be repeated under GM0 because the address of the table can change with every start of the Heroes III program. Probably I would just calculate the address in-line each time I needed the information.

Edit--that doesn't make sense, the address changes but stored values of Town types would not. I was trying to explain why GM0 is often needed with UN:C work, but the example was wrong, sorry.

New subject: in my current project the player has to drop artifacts (right-click on Adventure Screen). This brings up a menu of Backpack artifacts. As has been mentioned at the Era II thread, under Era 2.3 and I think 2.4, this menu reads the ARTIFACT.DEF from Mods/WoG/Data/hmm35wog.pac rather than Mods/.../Data/H3sprite.pac. So my new artifacts show as their old selves in the Backpack menu. My work-around until if-and-when Bersy changes this (may not be desireable, I don't know) is:

1) Add my modified artifacts DEF to hmm35wog.pac under the name JVARFACT.DEF.
2) Then, in my scripts, check to see of the user has done this, by checking the table of hmm35wog.pac contents. For the case of JVARFACT.DEF, the table value to check is at [0x2808444]+0xD3A0 (a different name would be at a different location, or if more modified DEF's are added to hmm35wog the location could change also).
3) If the script finds JVARFACT where it expects to, then and only then it changes the name ARTIFACT.DEF to JVARFACT.DEF at this location: 0x79DA89.

In my README, I will tell users they can try adding JVARFACT.DEF to hmm35wog.pac using MMARCHIVE (thanks yet again, Grayface) if they want to see the new artifacts in the Backpack-Drop Menu. Otherwise (unless their version of Era II does not have this issue), they will see old artifacts, but the Hint Text will give the new names.

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


Admirable
Omnipresent Hero
Wog refugee
posted October 20, 2012 05:08 PM

Artifact.def is read from custom pacs so far. Everything is read from custom mods except creatures icons in experience screen.
____________
Era II mods and utilities

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


Responsible
Supreme Hero
posted October 20, 2012 05:41 PM

In Era 2.3, my new artifacts (in H3sprite.pac/artifacts.def) show in the Hero Screen and other places but not in the Backpack menu which appears when you drop an artifact on the map. This was mentioned after the release of Era 2.4 on the Era II thread, so I guessed it still applied to Era 2.4, but maybe you have an newer release which fixes it. Are you saying that you have tried dropping artifacts from a Backpack onto the map and see modified icons in the Drop Menu?

(In this case users will not see a problem and will not have to resort to my work-around.)

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


Admirable
Omnipresent Hero
Wog refugee
posted October 20, 2012 05:43 PM
Edited by Salamandre at 17:47, 20 Oct 2012.

Aha I get it. Backpack when you try to drop, never tested that. Then I guess is the same problem as creature experience icons.

@Edit: you are right, just tested, sorry for confusion.
____________
Era II mods and utilities

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


Admirable
Omnipresent Hero
Wog refugee
posted October 22, 2012 07:14 AM

I am not sure how to use UN:C to store player starting towns. As OW:N is very unsafe (even with checks it gives me strange results between -1 and 0 and works ONLY(!) if I refresh scripts day before or reload) I had to redo the whole thing, the old and safe method:

!#VRv9455:C-1/-1/-1/-1/-1/-1/-1/-1; initialize players
first day, loop towns:
[...]
!!UN:U98/-1/?y6; loop towns
!!VRv1:S-1;
!!DO15019/1/y6/1:P;
[...]

!?FU15019;
;set AI starting town type
!!UN:U98/-1/-1/1;
!!CA1:O?y1 T?y2; owner and type
!!FU&y1<0:E; exit if neutral
!!VRv9455&y1=0:Sy2;
!!VRv9456&y1=1:Sy2;
!!VRv9457&y1=2:Sy2;
!!VRv9458&y1=3:Sy2;
!!VRv9459&y1=4:Sy2;
!!VRv9460&y1=5:Sy2;
!!VRv9461&y1=6:Sy2;
!!VRv9462&y1=7:Sy2;

In function giving AI a free town matching faction:

!?FU15006;
[...]
;x1=current player
!!FU15020:Px1;  
!!CA300&v9463>=0:Ox1 Tv9463 I0;  [if v9463=-1, AI had no starting town]
[...]

!?FU15020;
;x1=current player
;set v9463 to match current player starting town
!!VRv9463&x1=0:Sv9455;
!!VRv9463&x1=1:Sv9456;
!!VRv9463&x1=2:Sv9457;
!!VRv9463&x1=3:Sv9458;
!!VRv9463&x1=4:Sv9459;
!!VRv9463&x1=5:Sv9460;
!!VRv9463&x1=6:Sv9461;
!!VRv9463&x1=7:Sv9462;

I will try to free those global variable by using SN:W but for now I need to test the thing. There is kind of backside, if player starts with several towns, will store only the last one, but that's it. Any suggestions to compress the script?
____________
Era II mods and utilities

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


Responsible
Supreme Hero
posted October 22, 2012 02:16 PM

I think (dangerous to make assumptions about unknown code) it could all be replaced with:

!?FU15006;
[...]
;x1=current player (color)
!!UN:C6919480/4/?y1;
!!VRy1:+128688; address of starting-town-type table
!!VRy2:Sx1*4+y1; table has 4 bytes per color, starts at y1
!!UN:Cy2/4/?y3; y3=starting Town type (0-8 for Castle-Conflux, -1 for none) of color x1
!!CA300&y3>-1:Ox1 Ty3 I0;  [if y3=-1, AI had no starting town]
[...]

That is, if you aren't already using y1-y3 for something else.

In this version, the starting-town-table is read for each player each time the process is done, rather than reading it once at the start of the game. This saves a lot of code and some variables, and may not be a lot slower than reading the same table from stored v-variables.

I think the table I found is used to display the list of players and Towns in the Scenario Information screen, so as long as this screen is correct (I don't think it changes during a game, but haven't checked it a lot), the starting Town types based on this method should be correct.

There are always lots of ways to do things in ERM (as with thinking in general). The main thing is to keep trying until something works.

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


Admirable
Omnipresent Hero
Wog refugee
posted October 23, 2012 07:14 AM
Edited by Salamandre at 14:24, 23 Oct 2012.

Very elegant and it works, thank you. I use it in a function because this check for faction is present already in 3 locations (give free town, check each first day every town and after battle):

!?FU15020;
;x1=current player
!!UN:C6919480/4/?y1;
!!VRy1:+128688; address of starting-town-type table
!!VRy2:Sx1*4+y1; table has 4 bytes per color, starts at y1
!!UN:Cy2/4/?y3; y3=starting Town type
!!SN:W^AI town^/y3;

Then I check for this var and match in every script:
[...]
!!FU15020:Px1;  
!!SN:W^AI town^/?y4;  
!!CA300&y4>=0:Ox1 Ty4 I0;  
____________
Era II mods and utilities

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


Responsible
Supreme Hero
posted October 23, 2012 03:56 PM

Good example. I have added it to my set of code samples.

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


Famous Hero
posted October 31, 2012 01:21 PM
Edited by Siegfried at 13:41, 31 Oct 2012.

Problem

Update: Found it. My fault. Sorry.

Hi,

i got a strange problem. I moved all scripts to a backup folder and created a new script00.erm with erm_s.exe, just containing the line:

!#IF:M^DEBUG: Start^;

Nothing happened. I reloaded the original scripts and added this line to script00.erm, and it worked. I removed the line and created a new script99.erm, containing this line, nothing happened.

Another question: Is there any up to date erm documentation? My docujmentation contains nothing about UN:C command.

Regards,
Siegfried

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


Promising
Famous Hero
feanor on DF2.ru
posted October 31, 2012 03:18 PM

Quote:
My docujmentation contains nothing about UN:C command.

You doesn't need documentation for this command. With using it you will corrupt your immortal soul.

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


Responsible
Supreme Hero
posted October 31, 2012 03:26 PM

OxFea is probably correct, but here is what the latest ERM Help versions (both the one for WoG 3.58f/ERM 2.81 and the one for WoG 3.59/ERM 3.00 - the latter comes with Era 2, both are linked to on this thread and in Master_Learn's ERM Help FAQ thread, as a search will find) say:

C # / $1 / $2 ; Write/Read an integer at address #
  # - Address in memory (in decimal)
  $1 - Size of integer in bytes (1, 2 or 4)
  $2 - Integer to write (decimal) or name of variable to store value

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


Famous Hero
posted October 31, 2012 05:12 PM

@0xFEA: My necromancy skills will protect me from that

@JimV: Ah, so it all depends on a list of usable addresses. Is there one?

Next question: How could i check if a hero already has visited a specific mercenary camp? I know there is HE-1:V..., but that needs not only the object type, but also the object number. So how could i get the number from within an !?OB... trigger? I know i could store the primary skill level and re-check in a post trigger (if changed, than obviously was a fresh visit). But i need it before. I want some one-shot objects be revisitable up to a limit, with cost, where cost and limit depends on hero type, skills and speciality. I've already rewritten the witch hut script to ask if hero wants to learn skill (without offering advanced), but if hero has this skill as speciality then learning this skill here maximizes it.

 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 ... 165 166 167 168 169 ... 200 250 300 350 400 407 · «PREV / NEXT»
Post New Poll    Post New Topic    Post New Reply

Page compiled in 0.5010 seconds