[H5 EDITOR] Troubleshooting topic

Maps and the art of mapmaking.
Najibarr
Leprechaun
Leprechaun
Posts: 21
Joined: 22 Oct 2006

Unread postby Najibarr » 20 Nov 2006, 02:00

In the console do you get the error "file not found" if you do, it doesn't find your .txt file.

What you have to do is described at :
http://www.celestialheavens.com/forums/ ... 5167#85167
To make your .txt file usable.

User avatar
Sixy
Leprechaun
Leprechaun
Posts: 37
Joined: 26 May 2006
Location: Budapest, Hungary

Unread postby Sixy » 20 Nov 2006, 07:47

The problem is that I can't open the console. I changed the part in my input.cfg file (in the My Documents folder) into:

// general
bind jd_button_0 'ESC'
bind jd_button_0 'ENTER'
bind jd_button_0 'NUM_ENTER'
bind jd_button_0 'E'
bind esc_pressed 'ESC'
bind enter_pressed 'ENTER'
bind enter_pressed 'NUM_ENTER'
bind show_console '`'

But when I press ` nothing happens. (It's ALT+7 on my keyboard, but I tried all the other keyboard combinations as well.) What's wrong with it?

meows
Peasant
Peasant
Posts: 75
Joined: 11 Oct 2006

Unread postby meows » 25 Nov 2006, 01:09

Need new eyes on this code.. i keep getting error ; expected
on this line
if IsPlayerHeroesInRegion(PLAYER_1,region[0], (;) expected here.. but that is wrong as it doesn't work either.

Code: Select all

name=GetPlayerHeroes(1);
check_assassins=0
check_ambush=0
region = { "ambush", "assassins2"}   -- Indexes are assigned automatically

--function Ambush
function Ambush()
  while 1 do 
	     if  IsPlayerHeroesInRegion(PLAYER_1,region[0], then
		     BlockGame();
StartCombat( name[0], nil, 2, 113, 13 , 113, 15, nil, nil);
	     check_assassins=0
         --SetPlayerResource(PLAYER_1, 6, 200);
         UnblockGame();
           break;
    else sleep(1)
     end;  	
   end;
end;	


startThread(Ambush);
[/code]

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

Unread postby Pitsu » 25 Nov 2006, 09:11

Code: Select all

	     if  IsPlayerHeroesInRegion(PLAYER_1,region[0], then
		
This one clearly misses a ")"
if IsPlayerHeroesInRegion(PLAYER_1,region[0]) then
Avatar image credit: N Lüdimois

Najibarr
Leprechaun
Leprechaun
Posts: 21
Joined: 22 Oct 2006

Unread postby Najibarr » 25 Nov 2006, 15:50

What is that command i never saw it in the editor... but it clearly need a boolean value like if isplayerheroesinregion(playerid,regionname) == true then

why don't you use a real command like IsObjectInRegion :

Code: Select all

name=GetPlayerHeroes(1);
check_assassins=0
check_ambush=0
region = { "ambush", "assassins2"}   -- Indexes are assigned automatically

--function Ambush
function Ambush()
  while 1 do
        if  IsObjectInRegion(name[0], region[0]) == true then
           BlockGame();
StartCombat( name[0], nil, 2, 113, 13 , 113, 15, nil, nil);
        check_assassins=0
         --SetPlayerResource(PLAYER_1, 6, 200);
         UnblockGame();
           break;
    else sleep(1)
     end;     
   end;
end;   


startThread(Ambush);

ct605
Leprechaun
Leprechaun
Posts: 6
Joined: 06 Jan 2006

Unread postby ct605 » 26 Nov 2006, 02:09

I am hoping someone can help me with some basics to get map scripting started. The message box discussion back on page 4 or so was very helpful, but I still have two questions.

1. When I try to set map objectives (or quest hut completion) to a value like accumulate creatures that requires parameters, I cannot set the parameters. In map properties, I get a single line for parameters that gives no value options, rather than the expandable list that is shown in the manual. What am I missing?

2. I am wanting a script that, for every combat, will count the the number of a particular creature in a particular hero's army before and after the fighting. I assume I would place that script as a combat script in the hero properties. In the manual I see two commands (one for scripts before creatures are placed on the battle field, one after creatures are placed but before fighting). Both scripts have nil as a parameter, and I cannot tell how to use them since I would expect a trigger to have a script it calls. And I cannot find anything to cause actions to occur after combat. Can anyone offer advice.

Finally, it is obvious to me that my stumbling block with scripting in HoMM V is nether with programming logic, nor with syntax; it's with where code is and where to put code (object oriented stuff somewhat alien to this old fortran programmer). Both the Lua website and the editor manuals are quite thorough with syntax, I'm fine with programming logic, and I think I've figured out the basic idea of triggers and handler functions, but does anyone know of a basic tutorial that can help with the other stuff involved in scripting?

Najibarr
Leprechaun
Leprechaun
Posts: 21
Joined: 22 Oct 2006

Unread postby Najibarr » 26 Nov 2006, 05:12

about the first question : You have to manually add the parameters by right clicking on the parameter tab and pressing "add". I think the number of parameter for each objective is clearly explained in the editor theory guide so you shouldn't have any problem.

about the second one i didn't see any function to do your particular thing but i guess what you could do is :
-- I've never used the combat script yet so i dunno if it works like the map script but any way this is just my first idea how it could be done.

Code: Select all

variation = 0
initialnumber = GetCreatureNumber(unitName);
finalnumber = 0
function count()
   if GetCreatureNumber(unitName) ~= initialnumber then -- if the number of creature changed
     variation = initialnumber - GetCreatureNumber(unitName)
   end;
   if GetDefenderCreatures() == nil then -- I'm really really not sure about this so worth checking if it actually works
   finalnumber = initialnumber - finalnumber;
   break;
   end;
end;
startThread(count); -- really dunno if you can actually put those in the combat script 
I dunno if it would work but here are some issues :
- Why would you want to do that, could you please tell me more info
- i don't think you'll be able to use the values in the map script after or if what i've wrote make sense because i think it would work for 1 combat but after that the values would be reset to 0 if the combat script starts again
- one solution would be to use the map script, if you know the creature id

that could be :

Code: Select all

variation = 0
initialnumber = GetHeroCreatures(heroName, creatureID);

function count()
   if GetHeroCreatures(heroName, creatureID) > initialnumber then -- if the number of creature increased 
     print('the hero got some reinforcement')
     initialnumber = GetHeroCreatures(heroName, creatureID);
   elseif GetHeroCreatures(heroName, creatureID) < initialnumber then
     variation = variation + (initialnumber - GetCreatureNumber(unitName)); -- remove the "variation + " if you want to do a specific variation number for each combat or keep it if you want to do a total variation
     --whatever action you'd like to make it do here
   end;
end;
startThread(count);
Only issues here are to know the heroname and the creatureID but i guess you already knows that
Maybe a little performance issue since the function never ends.

Oh, one thing is that it doesn't take in consideration if you give the creatures from your hero to another hero it will take it just like you've just lost them for whatever reason. Maybe with a loop that takes all the heroes and calculate the total amount of creatures of that type it would fix it but actually no since if you put the creatures in garrison or if you put the hero in garrison you'll get a bad result. (in the specific case of if you put the hero in garrison and you exit the town with the hero still in garrison the game wont find the hero and the script will crash and stop working) There again you could add a if with GetTownHero(townName); to solve a part of this problem.

hmmm anyway, lol i guess it is a very complex thing you ask there hehe so just give me more information :)

the best tutorial is to download every single map and look in their mapscript.lua file (or open the map with the editor and check the map script) and look and learn. Find their tricks and learn!

User avatar
Sixy
Leprechaun
Leprechaun
Posts: 37
Joined: 26 May 2006
Location: Budapest, Hungary

Unread postby Sixy » 26 Nov 2006, 14:33

Aaaaaargh!

Something happened to my map file, at I cannot open it anymore. The system sais there's an error in the file. If I take a look at it (with a viewer), the last part of the file is simply missing! I even cannot open it with WinZip... Could someone help me fixing the file, or at least bring back some part of it? I've been working on my map for weeks now, and it would be so horrifying if everything disappeared... Please, someone, help me!

My ruined map (as a zip file) could be downloaded from:

http://users.atw.hu/swdotf/trp.zip

EEEEEEEEEEEEEEEERGH!

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

Unread postby Pitsu » 26 Nov 2006, 15:05

Sixy, you may have a look into the subdirectories of /Editor/ catalogue. Somewhere there may be the map files unpacked. If that is true, you may try to create a new h5m file (I guess you know the directory structure of h5m files?) of them and maybe you are lucky.
Avatar image credit: N Lüdimois

User avatar
Sixy
Leprechaun
Leprechaun
Posts: 37
Joined: 26 May 2006
Location: Budapest, Hungary

Unread postby Sixy » 26 Nov 2006, 15:25

No, the folder disappeared when I last tried to open the map with the editor. But thank God, on another forum someone fixed the file, so I've got it all back. : )

By the way, it's very-very-very kind of you to answer so quickly, so thank you! : )

(Back to work, I've got one more month for finishing my contest-map...)

myythryyn
Assassin
Assassin
Posts: 293
Joined: 05 Sep 2006

Unread postby myythryyn » 26 Nov 2006, 15:43

sixy i strongly recommend you keep a system of backups for your map files.

the editor is not stable. it does and will crash, say its saving when its not and you loose all your work, and create corrupted save files.

this happened to me many times now.

what i do is i keep four backups of my map file that i alternate from and i save every half hour of work i do so i wont loose much if that happens.

when im scripting i keep a working copy of the script in word, as i add script, i copy and paste the new script into the word document.
trust me, only just yesterday this saved me having to retype in a half hour of script when the editor crashed while saving. i would have lost all that new script if i didnt have a copy of it in word.

meows
Peasant
Peasant
Posts: 75
Joined: 11 Oct 2006

Unread postby meows » 27 Nov 2006, 09:43

alavris wrote:I thought it may be helpful for someone, so I will post here my reply to question PM'ed me by Fiur about making thumbnail images:
I've just tried to make these thumbnail images. So now I know it's easy :) I just copied these files from "Heritage" map to my alavris.h5m file:

mM4_pic.dds
mM4_2_pic.dds
mM4_3_pic.dds
mM4_4_pic.dds
mM4_pic.xdb
mM4_2_pic.xdb
mM4_3_pic.xdb
mM4_4_pic.xdb

I think that thumbnail images work only when there are 4 DDS files, but I haven't tried other situation... The next step is to replace this line in map-tag.xdb:

Code: Select all

<thumbnailImages/>
with this text:

Code: Select all

<thumbnailImages>
		<Item href="/mM4_pic.xdb#xpointer(/Texture)"/>
		<Item href="/mM4_2_pic.xdb#xpointer(/Texture)"/>
		<Item href="/mM4_3_pic.xdb#xpointer(/Texture)"/>
		<Item href="/mM4_4_pic.xdb#xpointer(/Texture)"/>
	</thumbnailImages>
That's all :)
.
Question what size are these pictures supposed to be?
Thanks

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

Unread postby Pitsu » 27 Nov 2006, 09:57

meows wrote: Question what size are these pictures supposed to be?
Thanks
You can check the first post here.
Avatar image credit: N Lüdimois

ct605
Leprechaun
Leprechaun
Posts: 6
Joined: 06 Jan 2006

Unread postby ct605 » 27 Nov 2006, 15:45

Najibarr,

Thanks for a thorough answer to my earlier query.

Regarding finding parameters, I thought I had tried everything conceivable -- I overlooked right clicking, and that answers a number of questions, both present and future!

As for my second question, I have a map in which i know exactly which creatures will be available to each hero, but I don't want to allow a hero to dismiss or trade creatures. If a hero does such, I think I can forcibly reset them, but I need to be able to detect when creatures are lost in combat (I'll also have to deal with the issue of hiring creatures -- but one thing at a time! Also my map has very limited hiring opportunities so this issue might be easier than one would expect.) Your response here has also been very helpful -- I had not considered opening a thread active through the entire combat (maybe because my programming instincts are to avoid un-ending threads). I guess it just seems to me that this should not be so hard since in the heroes IV editor it would have been easy. I'll try some of these ideas over the next few days as I get a chance. Thanks again.

meows
Peasant
Peasant
Posts: 75
Joined: 11 Oct 2006

Unread postby meows » 27 Nov 2006, 19:52

Pitsu wrote:
meows wrote: Question what size are these pictures supposed to be?
Thanks
You can check the first post here.
Many thanks Pitsu

meows
Peasant
Peasant
Posts: 75
Joined: 11 Oct 2006

Unread postby meows » 02 Dec 2006, 00:28

Working with secondary objectives. This code works.. However. only the First objective will display in the game. Is it my triggers? I am not sure how they work yet.

Code: Select all

function Kill_Mummy1()	
	Trigger( REGION_ENTER_AND_STOP_TRIGGER, "Kill_Mummys", nil );
    MessageBox ("/Maps/SingleMissions/Ashers World one/mummyregion.txt");
SetObjectiveState("mummy1", OBJECTIVE_ACTIVE);
Trigger (OBJECTIVE_STATE_CHANGE_TRIGGER, "mummy1", "objectivecomplete1" );
end;

--------------------------------------------------------------------------
function objectivecomplete1 (heroname) 

if GetObjectiveState ("mummy1") == OBJECTIVE_COMPLETED then 
 SetObjectPosition("mummy2live",21,43,0);
    SetObjectiveState('mummy2',OBJECTIVE_ACTIVE);
Trigger (OBJECTIVE_STATE_CHANGE_TRIGGER, "mummy2", "objectivecomplete2" );
end;
end; 

 
-----------------------------------------------------------------------------
function objectivecomplete2 (heroname) 
if GetObjectiveState ("mummy2") == OBJECTIVE_COMPLETED then 
	SetObjectPosition("mummy3live",23,42,0);
    SetObjectiveState('mummy3',OBJECTIVE_ACTIVE);
Trigger( OBJECTIVE_STATE_CHANGE_TRIGGER, "mummy2", nil); 
Trigger (OBJECTIVE_STATE_CHANGE_TRIGGER, "mummy3", "objectivecomplete3" );
end; 
end; 



-----------------------------------------------------------------------------------------------------
function objectivecomplete3 (heroname) 
if GetObjectiveState ("mummy3") == OBJECTIVE_COMPLETED then
    MessageBox ("/Maps/SingleMissions/Ashers World one/mummys.txt");
-- end;
Trigger( OBJECTIVE_STATE_CHANGE_TRIGGER, "mummy3", nil); 
end; 
end; 
[/code]

meows
Peasant
Peasant
Posts: 75
Joined: 11 Oct 2006

Unread postby meows » 02 Dec 2006, 00:37

Najibarr wrote:What is that command i never saw it in the editor... but it clearly need a boolean value like if isplayerheroesinregion(playerid,regionname) == true then

why don't you use a real command like IsObjectInRegion :

Code: Select all

name=GetPlayerHeroes(1);
check_assassins=0
check_ambush=0
region = { "ambush", "assassins2"}   -- Indexes are assigned automatically

--function Ambush
function Ambush()
  while 1 do
        if  IsObjectInRegion(name[0], region[0]) == true then
           BlockGame();
StartCombat( name[0], nil, 2, 113, 13 , 113, 15, nil, nil);
        check_assassins=0
         --SetPlayerResource(PLAYER_1, 6, 200);
         UnblockGame();
           break;
    else sleep(1)
     end;     
   end;
end;   


startThread(Ambush);
I did try IsObjectInRegion and it didin't work either,, thats why I tried the off the wall code. the code works perfectly in game when just calling a single region.,. i was trying to combine 5 regions into one call to StartCombat but can't get it to work,,
Last edited by meows on 02 Dec 2006, 02:15, edited 1 time in total.

myythryyn
Assassin
Assassin
Posts: 293
Joined: 05 Sep 2006

Unread postby myythryyn » 02 Dec 2006, 01:17

meows

to make objectives visable in the game you also have to have this line after you activate it

SetObjectiveVisible ("obj1", true);

meows
Peasant
Peasant
Posts: 75
Joined: 11 Oct 2006

Unread postby meows » 02 Dec 2006, 02:13

myythryyn wrote:meows

to make objectives visable in the game you also have to have this line after you activate it

SetObjectiveVisible ("obj1", true);
Aye thanks.. but the problem is still Objective 1 (mummy1)
does work perfectly.. but the trigger in it to start objective 2
(mummy2) does not activate..

any one know how triggers work?
I need a sample i think.

Najibarr
Leprechaun
Leprechaun
Posts: 21
Joined: 22 Oct 2006

Unread postby Najibarr » 02 Dec 2006, 14:04

meows wrote: I did try IsObjectInRegion and it didin't work either,, thats why I tried the off the wall code. the code works perfectly in game when just calling a single region.,. i was trying to combine 5 regions into one call to StartCombat but can't get it to work,,
Don't you just have to add more condition to the "if" i mean :

Code: Select all

name=GetPlayerHeroes(1);
check_assassins=0
check_ambush=0
region = { "ambush", "assassins2"}   -- Indexes are assigned automatically

--function Ambush
function Ambush()
  while 1 do
        if  IsObjectInRegion(name[0], region[0]) == true and IsObjectInRegion(name[0], region[1]) == true and IsObjectInRegion(name[0], region[2]) == true and IsObjectInRegion(name[0], region[3]) == true and IsObjectInRegion(name[0], region[4]) == true then
           BlockGame();
StartCombat( name[0], nil, 2, 113, 13 , 113, 15, nil, nil);
        check_assassins=0
         --SetPlayerResource(PLAYER_1, 6, 200);
         UnblockGame();
           break;
    else sleep(1)
     end;     
   end;
end;   


startThread(Ambush);


Return to “Mapmaking Guild”

Who is online

Users browsing this forum: No registered users and 0 guests