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: New to scripting - need help!
Thread: New to scripting - need help! This thread is 2 pages long: 1 2 · NEXT»
brunoverde
brunoverde

Tavern Dweller
posted March 17, 2013 05:51 PM
Edited by brunoverde at 17:52, 17 Mar 2013.

New to scripting - need help!

Hi guys,

I've just joined this community and I see it's very active and helpful.

I've just started trying to script with ERM, but I cannot manage to progress.

I read some guides here and there but I didn't manage to find one that could help a beginner.

Anyway what I'd like to create (as a start) is to place in the map some unused objects in the editor and script them with ERM.

Specifically I'd like to place in the map 4 or 5 objects of the same type and subtype that work like a dragon utopia or a creature bank (but with custom creatures and rewards).

Too bad I'm blocked on giving those objects a name with a script :/

I can change the name of a specific object on a map placed at coords X/Y/Z but I don't know how to change the name of multiple objects of the same type at once
(for example: let's say I want to rename all dragon utopias into angel utopias - is there a way I can do it without the need to write a script for every dragon utopia places into the map?)

Probably it's too much for a beginner like me... but is there someone here who can help me?

Thanks in advance and sorry for the bad english

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


Responsible
Supreme Hero
posted March 17, 2013 08:35 PM

The best quide is the manual, ERM Help, if you want to learn ERM. In my case I first spent about a week reading the introduction and tutorials and then reading every command to see what kinds of things were possible, before attempting my first project. This approach has made me a reasonable good ERM scripter, whereas some others spend months asking questions and avoiding reading ERM Help for themselves and practicing with the commands. So I think I know which approach works best, but others disagree.

Anyway, the command you want is the HT receiver, which sets the hint text for every object of a given type and subtype. Of course to understand what types and subtypes are you will have to read the OB receiver as well as its tutorial. Also you will have to know about z-variables (see the tutorials and the Flags and Variables section of ERM Help), and to chose "permanent" variables (variables which are dedicated to only one use throughout a game) which are not claimed by WoG scripts by checking the List of the Claimed.

If your English reading ability is not good, it will be difficult to read ERM Help in English (there is also a Russian version, and maybe others that I do not know about), but of course answers here will also be in English, for the most part.

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


Admirable
Omnipresent Hero
Wog refugee
posted March 17, 2013 09:30 PM
Edited by Salamandre at 21:39, 17 Mar 2013.

Quote:

I'd like to place in the map 4 or 5 objects of the same type and subtype that work like a dragon utopia

I don't know how to change the name of multiple objects of the same type at once


Sometimes people requesting help look to me like coming from Mars, they found wog 5 minutes ago and they want to script already. I mean, entire wog is based on renaming same type objects, how can anyone just not even take a look and see how for example the modified utopias  "dungeons of dragonmasters" are given same name, I can't get it...You play once wog, you see things, you open script with similar name, check for that name, and see what is around as code. Then you copy the code in your test map, change names or whatever and see what happens. Then ask if unclear.

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

Tavern Dweller
posted March 17, 2013 09:50 PM
Edited by brunoverde at 21:50, 17 Mar 2013.

Ok ok.. I see you are angry with me.. but the problem is that I don't even know where to put my hands on to get "the code" of the dragonmaster utopias.

I mean it's easy for you as you are good at these things... but for a beginner is very hard, even after reading guides and whatsover.

I'm doing my best to try to learn ERM and I was asking you just a few hints, no more than that.

I'm sorry if I upset you with my question, I'll keep trying on my own.

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


Admirable
Omnipresent Hero
Wog refugee
posted March 17, 2013 09:52 PM

I am not upset, I just read you:

Quote:
I've just started trying to script with ERM


When I see someone saying this, I assume he knows how to open scripts, where they are located, where is the guide. If you did not even make a single piece of code, then reformulate your question, but your main post suggest you know the basics.
____________
Era II mods and utilities

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


Responsible
Supreme Hero
posted March 17, 2013 10:11 PM

Quote:
... the problem is that I don't even know where to put my hands on to get "the code" of the dragonmaster utopias.


Read the first Basic Tutorial in ERM Help:
---copy and paste from ERM Help starts------------------
How to...  CREATE YOUR FIRST SCRIPT
Erm For Dummies, by Qurqirish Dragon

...

For example, I wrote a script that modifies the Card of Prophecy (this is script34.erm in your /data/s folder) to play around with a hero's stats, when entering battle.
------------end of copy and paste----------------------

This tells you that the standard WoG scripts are in the subfolder data/s. You can also find out which WoG script number contains the Dungeon of the Dragon Master, in the List of the Claimed section. (ERM Help is an HTML document, so you can use the Ctrl-F browser search command to look for key words on a particular page.)

All the information you need is in ERM Help. You just have to read it carefully, and practice the commands. For example, under the HT Receiver there are a couple sample scripts using HT which you could put into a test map and try out.

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

Tavern Dweller
posted March 17, 2013 10:22 PM
Edited by brunoverde at 22:23, 17 Mar 2013.

Thanks

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

Tavern Dweller
posted March 18, 2013 07:31 PM
Edited by brunoverde at 19:34, 18 Mar 2013.

I managed to create something but I cannot understand how to disable the object after the hero has visited it.

Anyway here's the code (don't laugh at me for the poor coding):

ZVSE
!#VRz850:S^Abyss (Not Visited)^;
!#VRz851:S^Abyss (Visited)^;
!#HT40/1:T850;

!?OB40/1;
!!HE-1:O?v5003;
!!IF:Q1/21/115/2^There are some valuable wrecks in the abyss but they are defended by some powerful monsters.

Do you want to leave or fight for the treasure?^;

!!FU&-1:E;

!!VRv5004:Sc +5 *2;
!!VRv5005:R5;
!!VRv5006:Sc +3 :4;
!!VRv5007:Sc +5 :3;
!!VRv5008:Sc +5 *100 +500;

!!HE-1:P?v5000/?v5001/?v5002;

!!HE-1:Tv5000/v5001/v5002/115/v5004;

!!HE-1:O?y-2;
!!FU&v5003<>y-2:E;

!!IF&-1:Q500/v5005/v5007/7/v5006/6/v5008/1^After killing those monsters you found:^;

!!OW:Ry-2/v5005/dv5007;
!!OW:Ry-2/7/dv5006;
!!OW:Ry-2/6/dv5008;

!!VRv5004:S0;
!!VRv5005:S0;
!!VRv5006:S0;
!!VRv5007:S0;
!!VRv5008:S0;

!!OBv5000/v5001/v5002:H851;


I tried to use !!OBv5000/v5001/v5002:S; to disable it, but it doesn't work, anyone can help me please?

Thanks

P.S. I'm WoGifing the map at the start (I want it to work with wog scripts)

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


Legendary Hero
walking to the library
posted March 18, 2013 07:33 PM

You could disable smilies with the red button.
____________
"I heard the latest HD version disables playing Heroes. Please reconsider."-Salamandre

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

Tavern Dweller
posted March 18, 2013 07:34 PM
Edited by brunoverde at 19:35, 18 Mar 2013.

Quote:
You could disable smilies with the red button.


Thanks

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


Admirable
Omnipresent Hero
Wog refugee
posted March 18, 2013 08:33 PM
Edited by Salamandre at 20:34, 18 Mar 2013.

What you are looking for is PO receiver (changes the value of the square).  Try this:

!?OBx/y/z; (xyz=coordinates)
!!PO998:N?v1; check PO value, will return zero first time

;following actions will trigger on second visit
!!IF&v1=1:M^second visit^;
!!FU&v1=1:E;

;following actions will trigger on first visit
!!IF:M^first visit^;
[here script fight with HE:T]
!!HE-1:O?y1; is hero alive after fight?
!!FU&y1<0:E; exit if not
!!PO998:N1; set PO value to 1 if hero has won, so object now has different behavior.

____________
Era II mods and utilities

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

Tavern Dweller
posted March 18, 2013 08:52 PM

Thanks Salamandre it worked perfectly

One more question: is it correct the way I change the hint text from "not visited" to "visited" or is there a "better" way to do it?

Thanks again!

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


Admirable
Omnipresent Hero
Wog refugee
posted March 18, 2013 08:56 PM
Edited by Salamandre at 21:00, 18 Mar 2013.

Just add after:

!!PO998:N1;
!!OB998:H851;

About v998, if it is not clear, read in OB:

Note: v998/v999/v1000 variables will store the location of the current object visited. Also, you can refer to it easily with an indirect reference (for example: !!OB998:...

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

Tavern Dweller
posted March 18, 2013 08:59 PM

Thanks!

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

Tavern Dweller
posted March 18, 2013 09:09 PM
Edited by brunoverde at 11:52, 19 Mar 2013.

Yeah I read about that in the help, but thanks anyway for the explanation (because now I know how to use it).

Ehm.. I have another question (I hope the last and I think I can say I finally finished my first scripted object):

I need to change the sound (currently it plays nothing) when the hero visits the object.

I tried to put

!!OB998:T49;
!!OB998:S;

first after !!FU&v1=1:E; and then before it, but in both cases the sound of the magic well plays only after the hero has visited the object.

Where do have I to put those two lines in the code for allowing the music to play also when the object is not visited?

------------------------

Edit: nevermind... I found out that those two lines of code disable the "second visit".

Anyway I just need to put the sound on the object and I'm done!

------------------------

Edit2: I'm not able to find out a way to play a sound when visiting the object :( Can anyone illuminate me?

Another question sorry: I tried to place on the battlefield some other monsters with the BU receiver but it didn't work.

I read the guide http://heroescommunity.com/viewthread.php3?TID=29297 and it says you need to use the !!BU after a !?BG trigger but the battle is started with the command !!HE-1:T in my case.

So what should I do? Have I to change how the battle starts or is it possible to add some monsters anyway without using the !?BG trigger?

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


Admirable
Omnipresent Hero
Wog refugee
posted March 19, 2013 01:21 PM

If you use for example HE:T1/1/0, so location is fixed, then use

!?BA&v998=1/v999=1/v1000=0;

or

!?BG0&v998=1/v999=1/v1000=0;

or

!?BR&v998=1/v999=1/v1000=0;

Under !?BR, you can summon with !!BU, but pay attention as BR stores the battle turn number in v997. If you want to understand the pattern, make a map with a few death chambers, play it and compare what you see inside with the death chamber script, it has all you want inside. There are also endless maps with full done scripts from which you can learn a lot.

If location is not fixed and is random, you can flag it, after checking object type etcetera, then add the conditional flag to BA/BG/BR. There is not a single command doing what you want, but a bunch of them.
____________
Era II mods and utilities

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

Tavern Dweller
posted March 22, 2013 07:33 PM
Edited by brunoverde at 19:36, 22 Mar 2013.

Thanks for the help, I think that in these days I improved a lot!

But now I'm stuck again :/

I'd like to create a place (Mystical Cave) where I can change the specialization of the hero who visit it.

But I have two problems:

1 - The picture and the functionality of the specialization works but I'm not able to change the text of it.

I tried with !!UN:G2 but it doesn't work (maybe I'm doing it wrong?)

2 - I'd like this object to teach a certain specialization (randomly chosen) and if the player wants to learn it but he has not enough mithril nothing happens (the hero can revisit the place when he wants and he knows that the specialisation taught will be always the same) else if the player chooses to not learn that specialization he can the Mystical Cave will be inacessible until the start of next week and when a new week begins the Mystical Cave will teach another specialization (randomly chosen again). Is there a way to keep the specialization and a way to change it at the start of the next week?

2.a - If 2 is not possible I "just" need a way to make things change on a new week.

I tried to look at script 1 (the one where mines changes resources every week and the one that let's you to revisit one-visit-objects) but I didn't find a way to make them work for me (or maybe I didn't understand how to use that code correctly).

I also tried to find a way with v2392 (it should be the day-variable) but I couldn't manage to find a way to do what I need.

Anyway here's the code:

!#VRz854:S^Mystical Cave (Not visited)^;
!#VRz855:S^Mystical Cave (Visited)^;
!#VRz856:S^{Traveller}

Increases hero's movement points per level:

{Basic Logistics}: +7 movement points per hero level
{Advanced Logistics}: +15 movement points per hero level
{Expert Logistics}: +23 movement points per hero level^;

!#HT63/61:T854;

!?OB63/61;
!!PO998:N?v1;

!!HE-1:O?v5020/N?v5022;
!!OW:Rv5020/7/?v5021;

!!IF&v1=2:M^Don't disturb me! I'm studing!^;
!!FU&v1=2:E;

!!IF&v1=1:M^A hero has already payed me for my studies. I have no more to offer you.^;

!!FU&v1=1:E;

!!VRv5016:S R1;

!!if&v5016=0:;
!!VRv5017:S R27;
!!VRv5018:S 20;
!!VRv5019:S v5017 *3 + 3;
!!el:;
!!VRv5017:S R196;
!!VRv5018:S 21;
!!VRv5019:S v5017;
!!en:;

!!IF:Q502/v5018/v5019/2^Hi brave hero!
I'm a researcher and I need 10 bars of Mithril to continue my work.

If you give me what I need I can teach you this specialization:^;

!!if&v5021>9:;
!!UN:G2/v5022/2/z856;
!!PO998:N1;
!!OB998:H855;
!!HE-1:X0/2; Here it should be v5016/v5017 - I used 0/2 to see if Logistics specilization worked.
!!OW&502:Rv5020/7/d-10;
!!FU&502:E;
!!el:;
!!IF&502:M^You don't have enough Mithril. Come back when you have more.^;
!!FU&502:E;
!!en:;

!!IF&-502:M^Ok... visit me next week and maybe I will find something that might interest you.^;

!!PO998:N2;
!!OB998:H856;

!!VRv5016:S0;
!!VRv5017:S0;
!!VRv5018:S0;
!!VRv5019:S0;

--------------------------------

Another thing:

!#VRz852:S^Ghost Cave (Not visited)^;
!#VRz853:S^Ghost Cave (Visited)^;
!#HT63/59:T852;

!?OB63/59;
!!PO998:N?v1;

!!IF&v1=1:M^{Ghost Cave}

The ghosts have abandoned this cave and nothing is left inside it.^;

!!FU&v1=1:E;

!!HE-1:O?v5009;

!!IF:Q1^{Ghost Cave}

As you approach to the cave you feel that something bad is going to happen.

Do you want to proceed or go back?^;

!!FU&-1:E;

!!VRv5010:Sc +6 :4;
!!VRv5011:Sc :10 +1;
!!VRv5012:Sc *6;

!!HE-1:P?v5013/?v5014/?v5015;

!!HE-1:Tv5013/v5014/v5015/69/v5010;
!?BA0&v998=v5013/v999=v5014/v1000=v5015;
!!BA:M1/2/156/v5011;
!!BA:M1/1/159/v5012;

!?BA1&v998=v5013/v999=v5014/v1000=v5015;
!!HE-1:O?y-2;
!!FU&v5009<>y-2:E;

!!IF:Q501/32/v5011/34/v5011/1^The ghosts have now left the cave. The fear is gone and now you feel stronger than before: ^;

!!HE-1:Fd0/dv5011/d0/dv5011;

!!VRv5010:S0;
!!VRv5011:S0;
!!VRv5012:S0;

!!PO998:N1;
!!OB998:H853;

This code works perfectly but I wanted to change the battlefield background in "evil fog".

If I put !!BA:B20 it doesn't work (see below)

!!HE-1:Tv5013/v5014/v5015/69/v5010;
!?BA0&v998=v5013/v999=v5014/v1000=v5015;
!!BA:B20;
!!BA:M1/2/156/v5011;
!!BA:M1/1/159/v5012;

Is it because the battlefield background is set with the !!HE-1:T receiver?
If so is there a way to change the battlefield background even if there is the !!HE receiver or do have I to use !!BA to start the battle?

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


Admirable
Omnipresent Hero
Wog refugee
posted March 22, 2013 08:18 PM

If you want to get a random specialization which lasts all the week, you need a time trigger (every 7 days) and a random value set for all week.

!?TM$;
!!VRy1:S0 R27;
!!SN:W^specialization^/y1; [this avoids using a regular variable]

Then when you visit the object, read the value:

!?OBx/y/z;
!!SN:W^specialization^/?y1; [y1 stores the random specialization]
[...]
And if hero has enough mithril
!!HE-1:X0/y1;

For the battlefield, make sure you don't use any mod which changes it, like Morn battlefields or wog option "new battlefields", it may overlap.

Also, in the time trigger, change the PO value of the garden to 0 every week, to offer again services.
____________
Era II mods and utilities

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

Tavern Dweller
posted March 22, 2013 08:47 PM

Thanks Salamandre!

I will try it out and I'll let you know

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

Tavern Dweller
posted March 27, 2013 03:05 PM

Here I am again :P

So... I created a Mithril Mine (here's the script)

ZVSE

!#VRz859:S^Mithril Mine^;
!#HT63/28:T859;

!#TM22:S2/999/1/1;

!?TM22;
!!VRv5036:S0;
!!VRv5037:S0;
!!VRv5038:S0;
!!UN:U63/28/?n;
!!DO29002/1/n/1:P;

!?FU29002;
!!UN:U63/28/-1/5036;
!!POv5036/v5037/v5038:O?y1;
!!if&y1>-1:;
!!OW:Ry1/7/d1;
!!el:;
!!en:;

!?OB63/28;
!!HE-1:O?y2;
!!PO998:Oy2;

It works perfectly but the flag (I mean the real flag not the flag ment as "variable") of the object (63 / 28) doesn't become of the color of the player who owns the mine.

Is it possible to make the color change depending on the owner? If so how?

I'd also like to know if there's a way to change the hint text of an object depending on the owner (e.g. Mithril Mine (owned by red player)) without using z variables... because I'm already at z859 and from what I learnt here http://heroescommunity.com/viewthread.php3?TID=32519 I cannot use any other than these 10 z variables (from 850 to 859).

Thanks

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Jump To: « Prev Thread . . . Next Thread » This thread is 2 pages long: 1 2 · NEXT»
Post New Poll    Post New Topic    Post New Reply

Page compiled in 0.0686 seconds