[H5 EDITOR] Troubleshooting topic

Maps and the art of mapmaking.
User avatar
Pitsu
Round Table Hero
Round Table Hero
Posts: 1830
Joined: 22 Nov 2005

Unread postby Pitsu » 18 Nov 2007, 11:56

King Imp, one of the maps that you downloaded must contain "large message boxes" mod. To get the messageboxes back to tiny ones remove the map from your H5 directory.
Avatar image credit: N Lüdimois

User avatar
Mnc
Leprechaun
Leprechaun
Posts: 21
Joined: 15 Oct 2007

allied teams

Unread postby Mnc » 19 Nov 2007, 11:36

hey there, im making allied map and i want it that way so you cant swap team color flag like, you got red + blue against orange + green, but you can swap red + green if you want, and i dont want that :disagree: coz the map placed things suffer and its akward.

what should i do? i tryed many tricks already but no result :(
Making maps is Art and true beuty lies in them..

User avatar
rdeford
Assassin
Assassin
Posts: 299
Joined: 17 Apr 2007
Location: Sequim, USA
Contact:

Unread postby rdeford » 19 Nov 2007, 13:07

@ Mnc

I just created a test multi-player map from scratch that works as you wish. Here is what I did:
  • 1. Placed 4 towns on the map.

    2. Selected a town, pressed the Space Bar, and set the player-owner to player_1.

    3. Repeated for each of the other towns to give each town a unique player-owner (player_2, player_3, or player_4).

    4. Viewed map properties, selected the Teams tab, set 2 teams, then set player_1 and player_2 on team-1, and then player_3 and player_4 on team-2.

    5. Viewed map properties, selected the Players tab, and set player_1 to have a main town, be human playable only, and set the Race to match the town.

    6. Repeated for player_2, player_3, and player_4.
The map worked as you desire. I could not change the flag for any player, and I could not change the membership for either team.

I have had a problem with the editor not saving the teams settings correctly. When this problem happens, I open the map with the editor a second time and set up the teams correctly. It seems to save the settings correctly the second time. So, if your map does not work as you desire, open it up again and redo your settings if necessary.
rdeford, Mage Of Soquim

“Forgiving and being forgiven, loving and being loved,
living and letting live, is the simple basis for it all."

Ernest Holmes 1984

User avatar
Mnc
Leprechaun
Leprechaun
Posts: 21
Joined: 15 Oct 2007

Unread postby Mnc » 19 Nov 2007, 14:17

rdeford wrote:
  • 1. Placed 4 towns on the map.

    2. Selected a town, pressed the Space Bar, and set the player-owner to player_1.

    3. Repeated for each of the other towns to give each town a unique player-owner (player_2, player_3, or player_4).

    4. Viewed map properties, selected the Teams tab, set 2 teams, then set player_1 and player_2 on team-1, and then player_3 and player_4 on team-2.

    5. Viewed map properties, selected the Players tab, and set player_1 to have a main town, be human playable only, and set the Race to match the town.

    6. Repeated for player_2, player_3, and player_4.
That what i thought i done already, i better try look if something is out of order here, but since you got your test map working thats one good news for me, maybe I success too

<working>

edit: hurrey i got it working, i changed at map properties tree each players flag color speficly and took off from each players setting "CanBeDisabled" its working now as i wanted, thanks rdeford must had been something very little i didnt notice, i also had on few player settings "NO_TYPE_TOWN" but i switched it to random_town. ;)
Making maps is Art and true beuty lies in them..

King Imp
Swordsman
Swordsman
Posts: 570
Joined: 06 Jan 2006

Unread postby King Imp » 19 Nov 2007, 23:22

Pitsu wrote:King Imp, one of the maps that you downloaded must contain "large message boxes" mod. To get the messageboxes back to tiny ones remove the map from your H5 directory.


Yup, that fixed it. Thanks Pitsu.

I'm still annoyed though that the editor has the ability to mess up other maps simply from being in the directory. That and it is so annoying when it decides to change maps by itself from no teams to teams and vice versa.

User avatar
Pitsu
Round Table Hero
Round Table Hero
Posts: 1830
Joined: 22 Nov 2005

Unread postby Pitsu » 13 Jan 2008, 20:02

Objectives that are not MANUAL type can have several types of rewards. Is it possible to have several of them simultaneously? For example experience and resource? I could not get it working in testing, but the editor guide hints otherwise and i do not see why not.
Avatar image credit: N Lüdimois

Franzy
War Dancer
War Dancer
Posts: 362
Joined: 07 Sep 2007
Location: Moscow, Russia
Contact:

Unread postby Franzy » 14 Jan 2008, 18:52

I'm making a series of demo maps that contain various interesting scripting examples. The first one is called "Watchers". Monsters on this map constantly turn to face the hero. Note that the angle is accurate, not with a step of 90 or 45 degrees. This is to show that it's possible to survive without any mathematical functions like sin, cos, exp or, like in this case, without arctan.

The map is here: http://dreamforge.by.ru/files/WatchersDemo.rar (10 kb)

User avatar
rdeford
Assassin
Assassin
Posts: 299
Joined: 17 Apr 2007
Location: Sequim, USA
Contact:

Unread postby rdeford » 14 Jan 2008, 22:15

@ Franzy,

I am totally impressed! This is mighty fine scripting. I wish the comments were in English, but the code is a so logically organized that I think I could use it without being able to read the comments. Thanks for the inspiring example.
rdeford, Mage Of Soquim

“Forgiving and being forgiven, loving and being loved,
living and letting live, is the simple basis for it all."

Ernest Holmes 1984

User avatar
rdeford
Assassin
Assassin
Posts: 299
Joined: 17 Apr 2007
Location: Sequim, USA
Contact:

Unread postby rdeford » 14 Jan 2008, 23:25

Pitsu wrote:Objectives that are not MANUAL type can have several types of rewards. Is it possible to have several of them simultaneously? For example experience and resource? I could not get it working in testing, but the editor guide hints otherwise and i do not see why not.
I couldn't get it to work by setting the objective parameters. But, using the script, I was able to get the desired effect by adding this function:

Code: Select all

-- objective type = AWARD_EXPERIENCE, Experience parameter = 1000
-- function grants an additional reward of crystal resource when objective is completed
function objGiftTest()
	if GetObjectiveState("multRewardTest", PLAYER_1) == OBJECTIVE_COMPLETED then
		local qty = GetPlayerResource(PLAYER_1, CRYSTAL);
		SetPlayerResource(PLAYER_1, CRYSTAL, qty + 30);
	end;
end;
  Trigger(OBJECTIVE_STATE_CHANGE_TRIGGER, "multRewardTest", "objGiftTest");
Of course, the award given by the function could be expanded to include just about any type of multiple reward desired.
rdeford, Mage Of Soquim

“Forgiving and being forgiven, loving and being loved,
living and letting live, is the simple basis for it all."

Ernest Holmes 1984

Franzy
War Dancer
War Dancer
Posts: 362
Joined: 07 Sep 2007
Location: Moscow, Russia
Contact:

Unread postby Franzy » 15 Jan 2008, 00:57

Well those comments just describe the idea of how to compute angle without having any arc-function :) If you are interested, here is what I did (get prepared for a load of maths):

Let's say we have a radius-vector from the monster to the hero. It has two components: dx and dy. We know that tan(alpha) = dy/dx (alpha is the angle we need). Unfortunately, HOMM5 script language does not know any math functions except for square root. That's why one has to use series decompositions.
I used a series decomposition of arctan:
arctan(x) = x - x^3/3 + x^5/5 - x^7/7 ...
The trouble is this series converges only if -1<x<1, and it converges really slow when x is close to 1 or -1.
I came to the following solution: I simply turn the radius-vector for such an angle beta that it would fall into the sector (-pi/6,pi/6) by multiplying it on a rotation matrix T=[cos(beta),-sin(beta); sin(beta),cos(beta)]. Of course I remeber the angle beta (it's called "addangle" in the script) to add it later. Why I used sector (-pi/6,pi/6) though (-pi/4, pi/4) would seem a more logical choice? Because of the slow convergence I mentioned earlier. This series converges quite fast in this sector, you only need 4-5 members of the series to achieve a precision of 5-6 digits.

After I compute angle (in radians) and add angle beta, I simply translate it into degrees (cause homm5 function require angles in degrees, not radians). Then I add another 90 degrees, cause 0 degrees for Nival means facing south, while all humanity believes that 0 means facing east :)

That's all. Other parts of the script are quite conventional - cycling thru monsters and turning them every n time segments...

the_teacher
Leprechaun
Leprechaun
Posts: 5
Joined: 18 Oct 2006

trigger

Unread postby the_teacher » 13 Feb 2008, 09:54

a question for scripting gurus:
i added few scripts to a map which , individually, are working ok, and they consist in triggering some functions everyday.

i know syntax is ok, but somehow i cannot make them all work together :

trigger(NEW_DAY_TRIGGER, 'action1');
trigger(NEW_DAY_TRIGGER, 'action2');
trigger(NEW_DAY_TRIGGER, 'action3');

i read somewhere this is requiring a trick in order to check for every singel action on a new day as intended, not only the first to trigger, the rest of them being ignored like they never existed.

i would very much apprecate any help, its the last step i need to accomplish my work.

ty

User avatar
Pitsu
Round Table Hero
Round Table Hero
Posts: 1830
Joined: 22 Nov 2005

Re: trigger

Unread postby Pitsu » 13 Feb 2008, 10:58

the_teacher wrote: trigger(NEW_DAY_TRIGGER, 'action1');
trigger(NEW_DAY_TRIGGER, 'action2');
trigger(NEW_DAY_TRIGGER, 'action3');
Indeed you cannot have more than one trigger associated to an event. Whenever a new day starts or a hero is removed, an specified object is touched or any other event occurs two scripts may not run simultaneously. But you can do an extra function that specifies the functions that need to run. In your case:

Code: Select all

Function dailyevents()
action1; -- runs function action1 
action2; -- once action1 script is checked, function action2 is triggered
action3; 
end;

trigger(NEW_DAY_TRIGGER, 'dailyevents'); -- every day runs function dailyevents. 
--action1, action2 and action3 should specify at which date they 
 --execute and they should NOT have any kind of 
--trigger(NEW_DAY_TRIGGER, nil or whatever); command in them.
Avatar image credit: N Lüdimois

the_teacher
Leprechaun
Leprechaun
Posts: 5
Joined: 18 Oct 2006

Unread postby the_teacher » 13 Feb 2008, 12:02

so basically it will be only one trigger for multiactions and , as i understood, the action2 won't require any special conditions coming from action1 in order to be executed, it just waits in line : action1/end; action2/end;.., action x/end;.. within same function triggered on a new day.

ty very much, i will try it today

edit: i forgot to mention that once an action was checked and and conditions fullfilled to take place it should turn to nil and never triggers again.
i used to use

functionx = nil;

when i tried with separate functions, hope i find a way to disable independently once they happen if i include them all in same function

User avatar
rdeford
Assassin
Assassin
Posts: 299
Joined: 17 Apr 2007
Location: Sequim, USA
Contact:

Unread postby rdeford » 13 Feb 2008, 12:47

@ the_teacher

Pitsu is exactly correct in his approach.

Here is an actual code sample from the script for the map I'm currently working on:

Code: Select all

function dawn()
	replinishTraders();	-- replenish trader resource amounts
	shutDownMinesNW(); 	-- shutdown mines with no workers
	shutDownFeedersND();-- shutdown feeders when no days of service remain
	attackFeedersNI(); 	-- attack a feeder if no insurance policy is in force
	shutDownMinesNF();	-- shutdown mines when there arn't enough active feeders
	generateWorkers();	-- generate workers in Union Hall based on active feeders
	setInsuranceAmt();	-- ratchet premiums upwards
	checkInsurance();	-- inform player when policy expires
	sabotageMinesAI();	-- AI players sabotage mines periodically to make things fun
	attackMinesAI();	-- AI commandos size mines periodically to make things fun
	lowerMoral();		-- worker moral deteriorates daily
	holdFestival();		-- raise worker moral if festival has been purchased
	workerTurnover();	-- workers quit because of low moral
	bankIntrestCk();	-- see if player earns any interest
	
end;
  Trigger(NEW_DAY_TRIGGER, "dawn");
Here is the code for one of the functions called by the dawn() function:

Code: Select all

function bankIntrestCk()
	local day = GetDate(DAY_OF_WEEK) 
	local int = bankAccount * 0.1

	interestTemp = interestTemp + int

	if day == 1 and bankAccount > 0 then
		local mo = GetDate(MONTH);
		local wk = GetDate(WEEK) - 1;
		bankAccount = bankAccount + interestTemp;
		interestTotal = interestTotal + interestTemp;
		MessageBox( { path.."intrestPaid.txt"; month = mo, week = wk, 
					intWeek = interestTemp, balance = bankAccount, intTotal = interestTotal });
		interestTemp = 0
	end;

	if day == 1 and interestTotal >= 1000000 then
		SetObjectiveState("profit", OBJECTIVE_COMPLETED, PLAYER_1);
	end;
end;
rdeford, Mage Of Soquim

“Forgiving and being forgiven, loving and being loved,
living and letting live, is the simple basis for it all."

Ernest Holmes 1984

Astenan
Leprechaun
Leprechaun
Posts: 2
Joined: 20 Feb 2008

Unread postby Astenan » 20 Feb 2008, 15:54

I've got usual problem with the map : scripting...

So, I'm trying to go simple script : "the message appears when hero enters a region" but i'm getting "ERROR:Empty text file (or something like that)" on the console when entering the region. I might be writing wrong script or path to the file , i just don't know.

Could someone tell me how should this script look like for my map, using all paths and stuff. I tried to do it like it was done in TheVirginOfPonce but i must miss something. Please have a look at the map, scripts and give me some clues what's wrong there. (the map is really in beginning state, but there wont be any real point in doing other parts if i cant make the script)

map: http://rapidshare.com/files/93437705/Exiles1.h5m.html
script:

path = "Maps/SingleMissions/Exiles1/"
function Impaled()
MessageBox(path.."Scene1.txt");
Trigger (REGION_ENTER_AND_STOP_TRIGGER, "Everstan", nil );
end;
Trigger (REGION_ENTER_AND_STOP_TRIGGER, "Everstan", "Impaled" );


I'd really apreciate if someone can make this thing work....


EDIT : map made in ToE v3.0 (well, basic ToE without updates...)

User avatar
rdeford
Assassin
Assassin
Posts: 299
Joined: 17 Apr 2007
Location: Sequim, USA
Contact:

Unread postby rdeford » 20 Feb 2008, 19:41

Astenan wrote:I've got usual problem with the map : scripting...

Dang! This code looks like it should work just fine. I had so much trouble believing that it wouldn't work that I downloaded your map and tried it myself. Sure enough, I got the empty text error. I will make it work and post a reply. Just give me a little time. By the way, The Virgin of Ponce was my very first map, and I now have a better way to get the path that works automatically even when you save the map under a different name:

Code: Select all

path = GetMapDataPath(); -- makes saving under a new name easier
Try this way yourself while I fiddle around with your script to figure out why it won't work.
rdeford, Mage Of Soquim

“Forgiving and being forgiven, loving and being loved,
living and letting live, is the simple basis for it all."

Ernest Holmes 1984

User avatar
rdeford
Assassin
Assassin
Posts: 299
Joined: 17 Apr 2007
Location: Sequim, USA
Contact:

Unread postby rdeford » 20 Feb 2008, 20:19

rdeford wrote: Try this way yourself while I fiddle around with your script to figure out why it won't work.
OK, I got it to work. Basically, I had to create a new resource file.

Here is what I did: I opened your Scene1 file for editing and copied the entire text. Then I added a new resource file, gave it the name Scene1a, pasted the text into it, and saved it.

I tested it with your map and it worked fine. Here is the code:

Code: Select all

path = "Maps/SingleMissions/Exiles1/";

function Impaled()
	MessageBox(path.."Scene1a.txt");
	Trigger (REGION_ENTER_AND_STOP_TRIGGER, "Everstan", nil );
end;
  Trigger (REGION_ENTER_AND_STOP_TRIGGER, "Everstan", "Impaled" );
As you can see, everything is identical except for the new file name "Scene1a.txt"

The question is, why didn't your original work? I don't know. I suspect that the game system somehow couldn't follow the path that the editor was able to follow when I opened the file for editing. This same malfunction happened to me once when I saved the map in a directory other than the H5 Maps directory to make a backup copy, then went back to continue work on the original.

These days, I make a separate folder for my backup copies of a map. And, I get out of the editor and use the Windows right-click and drag method to copy the map file in the H5 Maps directory into my backup directory. I use Windows to change the backup file name to give it a revision number, but leave the original in the H5 map directory alone. For example: resourceWar 01, resourceWar 02, resourceWar 03, and so forth.

If ever I need to use a backup copy (e.g., resourceWar 03), I simply delete the original resourceWar from the H5 Maps directory and copy the backup copy into the H5 Maps directory. Then I use Windows to delete the " 03" from the file name, leaving the .h5m extension alone.
rdeford, Mage Of Soquim

“Forgiving and being forgiven, loving and being loved,
living and letting live, is the simple basis for it all."

Ernest Holmes 1984

Astenan
Leprechaun
Leprechaun
Posts: 2
Joined: 20 Feb 2008

Unread postby Astenan » 20 Feb 2008, 23:12

Yup, it works that way. You are a real lifesaver sir. Thank you.

Knowing that editor makes special text files is a really useful info. Seems Nival is really trying to make things be more difficult. One thing is certain - I made file "Scene1.txt" in windows notepad, while the working one, just as you said, had to be made in editor.

User avatar
rdeford
Assassin
Assassin
Posts: 299
Joined: 17 Apr 2007
Location: Sequim, USA
Contact:

Unread postby rdeford » 21 Feb 2008, 01:10

Astenan wrote:Yup, it works that way. You are a real lifesaver sir. Thank you.

Knowing that editor makes special text files is a really useful info. Seems Nival is really trying to make things be more difficult. One thing is certain - I made file "Scene1.txt" in windows notepad, while the working one, just as you said, had to be made in editor.
You are welcome. Glad to help.

It is fairly easy to add resource files. My latest map has 134 and counting. After doing about a dozen, it gets routine.

They really aren't trying to make things more difficult; there is a method behind their madness. Having all the text in external files instead of inside the script, makes it much easier to do translation.

I use MS Word to do spell checking on the text files for my map. I open both Word and the M5 editor at the same time. Then I open the resource text file in a H5 edit window, copy the text, paste it into the open Word doc, and do the spell check with Word's spell checker. Then, select all the text in the Word, copy it, then delete the text in the M5 edit window, paste the text into it, then close the M5 edit window and save. It takes me about an hour to spell check the files in a complex map.
rdeford, Mage Of Soquim

“Forgiving and being forgiven, loving and being loved,
living and letting live, is the simple basis for it all."

Ernest Holmes 1984

User avatar
ransomdl
Leprechaun
Leprechaun
Posts: 34
Joined: 15 Oct 2006

Unread postby ransomdl » 24 Feb 2008, 21:38

[quote="rdeford"][quote="Astenan"]Yup, it works that way. You are a real lifesaver sir. Thank you.

Knowing that editor makes special text files is a really useful info. Seems Nival is really trying to make things be more difficult. One thing is certain - I made file "Scene1.txt" in windows notepad, while the working one, just as you said, had to be made in editor.[/quote]

You are welcome. Glad to help.

It is fairly easy to add resource files. My latest map has 134 and counting. After doing about a dozen, it gets routine.

They really aren't trying to make things more difficult; there is a method behind their madness. Having all the text in external files instead of inside the script, makes it much easier to do translation.

I use MS Word to do spell checking on the text files for my map. I open both Word and the M5 editor at the same time. Then I open the resource text file in a H5 edit window, copy the text, paste it into the open Word doc, and do the spell check with Word's spell checker. Then, select all the text in the Word, copy it, then delete the text in the M5 edit window, paste the text into it, then close the M5 edit window and save. It takes me about an hour to spell check the files in a complex map.[/quote]

----------------------
rdeford, Mage Of Soquim

I am attempting to write a script into the Player Castle script tab to provide resources on a given day of the week to Player_1 and the script written reads as follows:

function Time_event()
if(GetDate(DAY_OF_WEEK)==5)then;
GivePlayerResource(PLAYER_1,GOLD,1000);
GivePlayerResource(PLAYER_1,SULFER,10);
end;

When playing the game, the script does not provide the resource to Player_1. Any suggestions of what I am doing wrong.

randsomdl
ransomdl
Warlock


Return to “Mapmaking Guild”

Who is online

Users browsing this forum: No registered users and 10 guests