Command Help

Official forum of the Wake of Gods mod to Heroes of Might and Magic III.
User avatar
Cavorite
Leprechaun
Leprechaun
Posts: 15
Joined: 08 Jan 2006
Location: Calgary, Alberta Canada

Command Help

Unread postby Cavorite » 19 Jan 2006, 13:16

Is there a way to detect when the (end of turn) button is pushed?

Like:
If the end of turn is pushed
then if it is day 7
then if the dendoid dwelling still has men in it
you did not visit the dendoid dwelling this week.

I need a script see script help for explaination.

User avatar
Gaidal Cain
Round Table Hero
Round Table Hero
Posts: 6972
Joined: 26 Nov 2005
Location: Solna

Unread postby Gaidal Cain » 19 Jan 2006, 13:30

I think there should be some way using the commands for mouseclicks, but you really only need it if you want to display that message at the end of a week. If you only want to check on the dwelling, there is no such need.
You don't want to make enemies in Nuclear Engineering. -- T. Pratchett

User avatar
Cavorite
Leprechaun
Leprechaun
Posts: 15
Joined: 08 Jan 2006
Location: Calgary, Alberta Canada

Unread postby Cavorite » 20 Jan 2006, 01:06

What I need is this:

The hero (and there can be only one) visits a dendroid dwelling.
If the hero visits and collects the dendroids 3 weeks in a row a sawmill will be built nearby.

I know how to build the sawmill but I need a way to check if the dendroids were picked up each week. If there is an eiser way of accomplishing this please let me know.

If I can check the dwelling on day 7 to see if dendroids are present and do this 3 weeks in a row, I will know when to build the sawmill.

Please help, I have been working on this one for a long time.

User avatar
Gaidal Cain
Round Table Hero
Round Table Hero
Posts: 6972
Joined: 26 Nov 2005
Location: Solna

Unread postby Gaidal Cain » 20 Jan 2006, 09:24

OK, I see. While your way seems to be possible, I'd take another route. First, does the hero actually needs to buy dendroids, or is it enough that he visits theiur dwelling? I'm going to go with the latter, but if it's the former, you only have to add a check to see hom many dendroids there are in the dwelling.

What you do is that you use two variables, one that keeps the last week the dwelling was visited, and one that keeps the number of times it has been visited in a row. Whenever the hero visits the dwelling, you check when the last time he visited was. If it was last week, you increase the other variable by one. If it wasn't last week, you set it to one. Then you check that variable- if it's 3, you build the sawmill. The code would go something like below. I'll use v1 and v2 for number of times visited and last week visited (in that order), but you can of course exchange them to whatever you want.

Code: Select all

!#VRv1:S0;
!#VRv2:S0; (initialize variables (v2=0 for convenience- don't have to have separate check for week 1))
!?OBx/y/z;
!!FU&v1=3:E; (this is just to skip everything if the mill already have been built)
!!VRy1:Sc-1 :7; (Get current week minus one)
!!VRv1&y1=v2:+1;
!!VRv1&y1<>v2:S1; (if didn't visit last week, set number of times visited to 1- you're here now)
!!VRv2:Sy1+1; (v2 now holds the week for visit)
(build sawmill if v2=3)
Hope this helps :)
You don't want to make enemies in Nuclear Engineering. -- T. Pratchett

User avatar
Qurqirish Dragon
Genie
Genie
Posts: 1011
Joined: 06 Jan 2006
Location: Flying the skies of Ohlam

Unread postby Qurqirish Dragon » 20 Jan 2006, 14:49

Gaidal Cain wrote:OK, I see. While your way seems to be possible, I'd take another route. First, does the hero actually needs to buy dendroids, or is it enough that he visits theiur dwelling? I'm going to go with the latter, but if it's the former, you only have to add a check to see hom many dendroids there are in the dwelling.

What you do is that you use two variables, one that keeps the last week the dwelling was visited, and one that keeps the number of times it has been visited in a row. Whenever the hero visits the dwelling, you check when the last time he visited was. If it was last week, you increase the other variable by one. If it wasn't last week, you set it to one. Then you check that variable- if it's 3, you build the sawmill. The code would go something like below. I'll use v1 and v2 for number of times visited and last week visited (in that order), but you can of course exchange them to whatever you want.

Code: Select all

!#VRv1:S0;
!#VRv2:S0; (initialize variables (v2=0 for convenience- don't have to have separate check for week 1))
!?OBx/y/z;
!!FU&v1=3:E; (this is just to skip everything if the mill already have been built)
!!VRy1:Sc-1 :7; (Get current week minus one)
!!VRv1&y1=v2:+1;
!!VRv1&y1<>v2:S1; (if didn't visit last week, set number of times visited to 1- you're here now)
!!VRv2:Sy1+1; (v2 now holds the week for visit)
(build sawmill if v2=3)
Hope this helps :)
One slight problem with this code- if you visit a second time in the same week, then v2 will not be the same as y1, and the counter will reset. After setting y1 to last week's number, you should add:

Code: Select all

!!VRy2:Sy1+1; (get current week)
and modify the "first time visited" line to:

Code: Select all

!!VRv1&y1<>v2/y2<>v2:S1; (if didn't visit last week or this week, set number of times visited to 1- you're here now)

User avatar
Cavorite
Leprechaun
Leprechaun
Posts: 15
Joined: 08 Jan 2006
Location: Calgary, Alberta Canada

UN Command

Unread postby Cavorite » 24 Jan 2006, 01:04

In the help file under the UN Command it says:
I#1/#2/#3/#4/#5...
up to 9 parametres Place an object.
#1 = x
#2 = y
#3 = Level
#4 = Type of object (see Format OB)
#5 = Subtype of object
If you use only 5 parameters you cannot set another terrain type and cancel redraw (terrain=-1, redraw=1)
#6 = Terrain type (see Format TR)
#7 = Redraw needed (1) or not (0)

Additional syntax: You can place an object which functions as object type/subtype but looks like an object type2/subtype2.
If you do so then:
#1 = x
#2 = y
#3 = Level
#4 = Type of object (see Format OB)
#5 = Subtype of object
#6 = Type2 of object to look like (see Format OB)
#7 = Subtype2 of object to look like
If you use only 7 parameters you cannot set another terrain type and cancel redraw (terrain=-1, redraw=1)
#8 = Terrain type (see Format TR)
#9 = Redraw needed (1) or not (0)
Well this is very confusing. The red part especially!
When I use 5 paramiters I place the sawmill but it is snow covered on grass???

Code: Select all

!!UN:I39/7/0/53/0;    **place lumber mill 
And I get an error when trying to use 7 paramiters.

Code: Select all

!!UN:I39/7/0/53/0/2/1;    **place lumber mill on grass & redraw
How does it know weather I want to use 7 parameters for placing an object with terraine and redraw
or
I want to place an object which functions as object type/subtype but looks like an object type2/subtype2 using 7 parameters?

Obviously it does not, because after the error message it places a red random monster dot where the sawmill should go?

What is the syntax for using this parameter? terrain=-1, redraw=1 and where does it go?
Please help me to understand this command?

User avatar
Fnord
Round Table Knight
Round Table Knight
Posts: 341
Joined: 27 Nov 2005
Location: Victoria, BC, Canada

Unread postby Fnord » 24 Jan 2006, 09:10

Okay, either the ERM Help or the command or both is screwed up and doesn't work the way it says it should with 6 or 7 parameters.

With 5 parameters, it's correct, but as you found out the terrain type doesn't necessarily match and you get odd results like the snow-terrain sawmill.

So here's what you do..you ignore the 5-7 parameter version of UN:I and instead use the 9 parameter version, but the trick is to use the same object type and subtype for both objects. So you place a sawmill that looks like a sawmill and then specify both the terrain type and redraw (as you were trying to do before). :D

In other words...

Code: Select all

!!UN:I39/7/0/53/0/53/0/2/1;
If you don't want to specify a terrain type, or if the object is in the object section that doesn't have a terrain type, use -1 for the terrain instead.
- Fnord

User avatar
Cavorite
Leprechaun
Leprechaun
Posts: 15
Joined: 08 Jan 2006
Location: Calgary, Alberta Canada

Unread postby Cavorite » 26 Jan 2006, 07:18

I tried that and it worked.

Code: Select all

!!UN:I39/7/0/53/0/53/0/2/1;
Now I just need to try the timing thing. I'm not perfectly clear where the extra line you added above fits in?

Thanks

User avatar
Cavorite
Leprechaun
Leprechaun
Posts: 15
Joined: 08 Jan 2006
Location: Calgary, Alberta Canada

All told

Unread postby Cavorite » 26 Jan 2006, 07:38

If I understand where to insert the corrected lines of code, the script now looks like this... ?

Code: Select all

!#VRv1:S0; 
!#VRv2:S0; *** initialize variables (v2=0 for convenience- don't have to have separate check for week 1
 
!?OBx/y/z;     *** Object trigger x/y/z coordinates
!!FU&v1=3:E;   *** skip everything if the mill already built 
!!VRy1:Sc-1 :7; *** Get current week minus one 
!!VRv1&y1=v2:+1;********************** What does this line do???

!!VRv1&y1<>v2/y2<>v2:S1; *** if didn't visit last week or this week, set number of times visited to 1- you're here now 

!!VRy2:Sy1+1; *** get current week     
******************************Did I add this in the right place??
 
!!VRv2:Sy1+1; *** v2 now holds the week for visit
 
!!UN&v2=3:I39/7/0/53/0/53/0/2/1;  *** Build log mill looks like log mill on grass & redraw
Does that look like it will work?

User avatar
GrayFace
Round Table Hero
Round Table Hero
Posts: 1660
Joined: 29 Nov 2005

Unread postby GrayFace » 28 Jan 2006, 03:38

Try this.

Code: Select all

!#VRv100:S0-1; * Last visit week
!#VRv101:S0; * Number of visits

!$OBx/y/z;     *** Object trigger x/y/z coordinates 
!!FU&v101=3:E;   *** skip everything if the mill already built 
!!VRy1:Sc :7; * Current week
!!FU&y1=v100:E; * Exit if already hired at this week
* Part of code to check if the player has baught all the creatures. Remove it if it's enough just to visit the dwelling.
!!DWx/y/z:M0/d/?y2;
!!FU&y2>0:E;
* End of the part of code.
!!VRv101:+1;
!!VRv100:+1;
!!VRv101&v100<y1:S1; *** if didn't visit last week or this week, set number of times visited to 1- you're here now 
!!VRv100:Sy1; 
!!UN&v101=3:I39/7/0/53/0/53/0/2/1;  *** Build log mill looks like log mill on grass & redraw
My patches: MM6 MM7 MM8. MMExtension. Tools. Also, I love Knytt Stories and Knytt Underground. I'm also known as sergroj.

User avatar
Cavorite
Leprechaun
Leprechaun
Posts: 15
Joined: 08 Jan 2006
Location: Calgary, Alberta Canada

Unread postby Cavorite » 28 Jan 2006, 10:48

Yes, I tryed that and it seem to work fine. I changed a few of the variables so there was no conflict.

I noticed something else with another script that wasn't there before and there doesn't seem to be anything in conmmon. Perhaps you can advise...

Code: Select all

ZVSE

*** TIMER *** ---------------------------------------------------
!#TM7:S1/999/1/255;  *** Starts day 1, ends day 999, every day, all players
!?TM7;                           *** Timer Trigger
!!VRv32:Sc0;                 *** v32 contains current day.
!!VRv17&v32=1:S0;         *** If day=1 set v17 to 0
!!VRv18&v32=1:S0;         *** if day=1 set v18 to 0

------------------------
!!LE41/15/0&v32=v18:D1/1;        ** Disable event after fire.

!!IF&v18=v32:M^************************
The fire is out and the forest is safe.
Perhaps you could invistigate where those wizards were practicing?
************************^;
                                                ** text if 6 days after fire started
!!UN&v18=v32:O44/19/0;      ** delete enchanter from map
!!UN&v18=v32:O46/19/0;      ** delete enchanter from map
!!UN&v18=v32:O44/20/0;      ** delete enchanter from map
!!UN&v18=v32:I46/19/0/79/0;   ** Place lumber on map
!!UN&v18=v32:I44/20/0/79/0;   ** Place lumber on map
--------------------------------

!?LE41/15/0&999;        **event trigger
!!VRv17:+1;                   **add 1 to v17 
!!VRv18&v17=5:Sc0;     ** set current day into v18 when fire starts

!!IF&v17=5:M^********************
Those silly wizards have let their magic get out of hand.  
The forest is on fire.
********************^;
                                  **show text if v17=5
!!UN&v17=5:F43/16/0/44/17;     **make trees on fire if v17=5

!!LE41/15/0&v17>4:M^No telling how long that fire will last.^;
!!VRv18&v17=5:Sd+6;                  ** add 6 to when the fire started
This seems to work fine, except that the trees grow back 2 days after they become passable. If you happen to be in the area beyond the trees you become trapped by new trees.

Any ideas why the trees are comming back?

User avatar
GrayFace
Round Table Hero
Round Table Hero
Posts: 1660
Joined: 29 Nov 2005

Unread postby GrayFace » 31 Jan 2006, 12:26

The code doesn't seem to make them passable at all! What should it do exactly?
Anyway, here are the first corrections:

Code: Select all

ZVSE 

!#VRv17:S0;         *** Number of LE visits

!?TM7;                           *** Timer Trigger. Called only once now.
!!LE41/15/0:D1/1;

!!IF:M^************************ 
The fire is out and the forest is safe. 
Perhaps you could invistigate where those wizards were practicing? 
************************^; 
                                                ** text if 6 days after fire started 
!!UN:O44/19/0;      ** delete enchanter from map 
!!UN:O46/19/0;      ** delete enchanter from map 
!!UN:O44/20/0;      ** delete enchanter from map 
!!UN:I46/19/0/79/0;   ** Place lumber on map 
!!UN:I44/20/0/79/0;   ** Place lumber on map 
-------------------------------- 

!?LE41/15/0&999;        **event trigger 
!!VRv17:+1;

!!IF&v17=5:M^******************** 
Those silly wizards have let their magic get out of hand.  
The forest is on fire. 
********************^; 
                                  **show text if v17=5 
!!UN&v17=5:F43/16/0/44/17;     **make trees on fire if v17=5 

!!LE41/15/0&v17>4:M^No telling how long that fire will last.^; 
!!VRy1:Sd+6;
!!TM7:Sy1/y1/999/1;  *** Only one day for the first player. 
If the human player isn't the first or there can be more than one human player, tell me.
My patches: MM6 MM7 MM8. MMExtension. Tools. Also, I love Knytt Stories and Knytt Underground. I'm also known as sergroj.

User avatar
Cavorite
Leprechaun
Leprechaun
Posts: 15
Joined: 08 Jan 2006
Location: Calgary, Alberta Canada

Unread postby Cavorite » 02 Feb 2006, 19:48

I do not understand???

Can you please tell me what you have done and why?

Is this the complete script or did you want me to add this to my code above?

And if so where do I add it?

My map has only 1 hero on it.

this is what the code should do:

After an event is visited 5 times the fire starts and the text for the event changes.
After the fire goes out the enchanters beyond are removed from the map and replaced with piles of lumber and the event is disabled.

User avatar
GrayFace
Round Table Hero
Round Table Hero
Posts: 1660
Joined: 29 Nov 2005

Unread postby GrayFace » 03 Feb 2006, 09:20

Cavorite wrote: Can you please tell me what you have done and why?
The timer is now set up when the count down starts, but not at the game beginning as it was. This simplified the script much.
I haven't tasted what I've written.
Cavorite wrote: Is this the complete script or did you want me to add this to my code above?
This is the complete script.
Cavorite wrote: My map has only 1 hero on it.
That's good.
Cavorite wrote: this is what the code should do:

After an event is visited 5 times the fire starts and the text for the event changes.
After the fire goes out the enchanters beyond are removed from the map and replaced with piles of lumber and the event is disabled.
That's exactly what it did and does now, but you told about trees growing back 2 days after becoming passable.
My patches: MM6 MM7 MM8. MMExtension. Tools. Also, I love Knytt Stories and Knytt Underground. I'm also known as sergroj.


Return to “Wake of Gods”

Who is online

Users browsing this forum: No registered users and 4 guests