[H5 EDITOR] Troubleshooting topic

Maps and the art of mapmaking.

Moderator: Moderators

User avatar
Grumpy Old Wizard
Round Table Knight
Round Table Knight
Posts: 2205
Joined: 06 Jan 2006
Location: Tower Grump

Postby Grumpy Old Wizard » Sep 24 2006, 21:47

Well, I figured out how to make all positions playabe without converting my map to a multiplayer map. Now for the next problem.

My map is a 6 position single player map. The human can play any of those 6 positions and the computer plays the rest. It is not a multiplayer map, 2 players can't play at the same time.

Lol I have't named my map yet so it is still "A Test Map."

I am trying to do something which should be simple.

I am trying to display a message the first time a human player enters a region. I can't find a conditional for determining if a player is human or computer though.

GetCurrentPlayer returns:
PLAYER_NONE = 0
PLAYER_1 = 1
PLAYER_2 = 2
PLAYER_3 = 3
PLAYER_4 = 4
PLAYER_5 = 5
PLAYER_6 = 6
PLAYER_7 = 7
PLAYER_8 = 8

The region part should be simple, but how to see if the heroe entering the region is human or not escapes me. I named the region TownHint1.

function TownHint1( heroname )
If ???????? then
-- do this for the human player only
MessageBox("Maps/SingleMissions/A Test Map/TownHint.txt");
Trigger( REGION_ENTER_AND_STOP_TRIGGER, "townhint1", nil );
end;
end;

Trigger( REGION_ENTER_AND_STOP_TRIGGER, "townhint1", "TownHint1" );

GOW
Frodo: "I wish the ring had never come to me. I wish none of this had happened."
Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."

User avatar
alavris
Scout
Scout
Posts: 164
Joined: 06 Jan 2006
Location: Poland
Contact:

Postby alavris » Sep 25 2006, 10:29

Grumpy Old Wizard wrote:I am trying to display a message the first time a human player enters a region. I can't find a conditional for determining if a player is human or computer though.


I searched too, and I didn't find anything. It seems not to by any divide between human and computer players made by Nival. I think the only solution here is to make only one player id playable by human, or to allow not only human player to run this region script.
.

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

Postby Pitsu » Sep 25 2006, 14:21

GOW, i do not know whether the combat field IsHuman etc. commands that were suggested on ubi board work for you but one way to do it would be:

The human player is the first to move no matter of flag/player ID. Thus you should be able to define human by adding a simple line to the begin of the script file (not under a function or anything)

Code: Select all

omosapience = GetCurrentPlayer();


The first time the script file is read (day1 of human player turn) variable omosapience gets a value which should remain constant for the rest of game, unless you specifically build a script to change it.

Now, whenever you want to confirm that an even is triggered by human palyer you use:

Code: Select all

function blah
if GetCurrentPlayer() == omosapience then
bla blah
end

User avatar
Grumpy Old Wizard
Round Table Knight
Round Table Knight
Posts: 2205
Joined: 06 Jan 2006
Location: Tower Grump

Postby Grumpy Old Wizard » Sep 25 2006, 15:39

Pitsu wrote:GOW, i do not know whether the combat field IsHuman etc. commands that were suggested on ubi board work for you but one way to do it would be:

The human player is the first to move no matter of flag/player ID. Thus you should be able to define human by adding a simple line to the begin of the script file (not under a function or anything)

Code: Select all

omosapience = GetCurrentPlayer();


The first time the script file is read (day1 of human player turn) variable omosapience gets a value which should remain constant for the rest of game, unless you specifically build a script to change it.

Now, whenever you want to confirm that an even is triggered by human palyer you use:

Code: Select all

function blah
if GetCurrentPlayer() == omosapience then
bla blah
end


I haven't tried the combat script suggestion yet but your solution seems like it should work. I'll give it a try and report back later.

GOW
Frodo: "I wish the ring had never come to me. I wish none of this had happened."

Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."

User avatar
Grumpy Old Wizard
Round Table Knight
Round Table Knight
Posts: 2205
Joined: 06 Jan 2006
Location: Tower Grump

Postby Grumpy Old Wizard » Sep 25 2006, 17:48

I haven't been able to get it to work with my region scrip thus far, but my HOMM5 scripting sucks so probably something is wrong with it.

I have a region named TownHint1, and the text I want displayed is HavenHint.txt

Here is what I have tried:

whoishuman = GetCurrentPlayer(); --determine human player, always goes first


--display region hint for human player
function GiveHint()
if GetCurrentPlayer() == whoishuman then
MessageBox("Maps/SingleMissions/A Test Map/HavenHint1.txt");
Trigger( REGION_ENTER_AND_STOP_TRIGGER, "TownHint1", nil );
end;
end;

Trigger( REGION_ENTER_AND_STOP_TRIGGER, "TownHint1", "GiveHint");


This new scripting is killing me.

Other than the scripting I can finish the map tonight or tomorrow and start playtesting. Maybe this first map will just not have much in the way of scripting.

Well, I'm off to an appointment now.

GOW
Frodo: "I wish the ring had never come to me. I wish none of this had happened."

Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."

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

Postby Pitsu » Sep 26 2006, 6:12

Does your script trigger at wrong time (AI player turn) or not at all?

The script that did work for me:

Code: Select all

player = GetCurrentPlayer();

function messagie()
   if GetCurrentPlayer() == player then
      OpenCircleFog(25, 25, GROUND, 25, PLAYER_1);
      OpenCircleFog(25, 25, GROUND, 25, PLAYER_2);
   end;
end;

Trigger( REGION_ENTER_AND_STOP_TRIGGER, "area","messagie", nil );

User avatar
Grumpy Old Wizard
Round Table Knight
Round Table Knight
Posts: 2205
Joined: 06 Jan 2006
Location: Tower Grump

Postby Grumpy Old Wizard » Sep 26 2006, 7:22

Pitsu wrote:Does your script trigger at wrong time (AI player turn) or not at all?

The script that did work for me:

Code: Select all

player = GetCurrentPlayer();

function messagie()
   if GetCurrentPlayer() == player then
      OpenCircleFog(25, 25, GROUND, 25, PLAYER_1);
      OpenCircleFog(25, 25, GROUND, 25, PLAYER_2);
   end;
end;

Trigger( REGION_ENTER_AND_STOP_TRIGGER, "area","messagie", nil );


My script did not display any message at all. The heroe did stop when he encountered the region though so something was going on. I'm going to bang my head on it some more.

Edit: Actually the script was good. I had changed the name of the text file in the script but forgot to change the name of the file itself.

GOW
Frodo: "I wish the ring had never come to me. I wish none of this had happened."

Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."

User avatar
Grumpy Old Wizard
Round Table Knight
Round Table Knight
Posts: 2205
Joined: 06 Jan 2006
Location: Tower Grump

Postby Grumpy Old Wizard » Sep 26 2006, 17:04

Now for another problematic script. Well all scripts seem to be problematic for me at this point. :(

I'm trying to buff a neutral Haven town the first day of every week that it remains neutral. The name of the town is Vigil. I also tried assigning a name in the object properties and that did not help.

All troop types I am trying to add are already present in the town garrison.

I am trying to run this script from the town.

-- do this first day of every week if town is neutral
function BuffHaven()
if GetObjectOwner == PLAYER_NONE
if GetDate(DAY_OF_WEEK) == 1 then
AddObjectCreatures(Vigil, 1, 11); --peasant
AddObjectCreatures(Vigil, 3, 6); --archer
AddObjectCreatures(Vigil, 5, 5); --footman
AddObjectCreatures(Vigil, 7, 2); --griffon
AddObjectCreatures(Vigil, 9, 2); --priest
AddObjectCreatures(Vigil, 11, 1); --cavalier

end;
end;
end;
Trigger(NEW_DAY_TRIGGER, "BuffHaven");


What am I doing wrong?

Well, I was missing a then in the above script but that did not solve the problem. I also tried running the script from the map properties script instead of the town script but that did not work either.

-- do this first day of every week if town is neutral
function BuffHaven()
if GetObjectOwner == PLAYER_NONE then
if GetDate(DAY_OF_WEEK) == 1 then
AddObjectCreatures(SecondHaven, 1, 11); --peasant
AddObjectCreatures(SecondHaven, 3, 6); --archer
AddObjectCreatures(SecondHaven, 5, 5); --footman
AddObjectCreatures(SecondHaven, 7, 2); --griffon
AddObjectCreatures(SecondHaven, 9, 2); --priest
AddObjectCreatures(SecondHaven, 11, 1); --priest

end;
end;
end;
Trigger(NEW_DAY_TRIGGER, "BuffHaven");


GOW
Frodo: "I wish the ring had never come to me. I wish none of this had happened."

Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."

User avatar
alavris
Scout
Scout
Posts: 164
Joined: 06 Jan 2006
Location: Poland
Contact:

Postby alavris » Sep 26 2006, 18:00

Grumpy Old Wizard wrote:I also tried running the script from the map properties script instead of the town script but that did not work either.

When running the script from the map properties script instead of the town script, don't forget to add argument to function "GetObjectOwner".
.

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

Postby Pitsu » Sep 26 2006, 19:16

AddObjectCreatures(Vigil, 3, 6); --archer

I would use:

AddObjectCreatures( " Vigil " , 3, 6); --archer

If i am not mistaken, the quotes are needed for an object name, without them the script is seeking for a function or variable called Vigil.

Dunno if that is the key to get this script functional.

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

Postby Pitsu » Sep 26 2006, 19:18

alavris wrote:When running the script from the map properties script instead of the town script, don't forget to add argument to function "GetObjectOwner".
.


Right,

GetObjectOwner("Vigil") sounds a bit better than GetObjectOwner

User avatar
Grumpy Old Wizard
Round Table Knight
Round Table Knight
Posts: 2205
Joined: 06 Jan 2006
Location: Tower Grump

Postby Grumpy Old Wizard » Sep 26 2006, 19:49

Yeah! You guys rule. :)

I used the town name I assigned in properties ("SecondHaven") instead of the name assigned in the town itself ("Vigil".) I also altered the code a little since it is in the map properties script instead of the town script since there will probably be more stuff for me to do on the first day of every week.

Here is the working script:

-- do this first day of every week.
function NewDayTrigger()
if GetDate(DAY_OF_WEEK) == 1 then
if GetObjectOwner("SecondHaven") == PLAYER_NONE then --neutral
AddObjectCreatures("SecondHaven", 1, 11); --peasant
AddObjectCreatures("SecondHaven", 3, 6); --archer
AddObjectCreatures("SecondHaven", 5, 5); --footman
AddObjectCreatures("SecondHaven", 7, 2); --griffon
AddObjectCreatures("SecondHaven", 9, 2); --priest
AddObjectCreatures("SecondHaven", 11, 1); --cavalier
end;
end;
end;


Trigger(NEW_DAY_TRIGGER, "NewDayTrigger");


GOW
Frodo: "I wish the ring had never come to me. I wish none of this had happened."

Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."

User avatar
Psychobabble
Spectre
Spectre
Posts: 706
Joined: 06 Jan 2006
Location: Melbourne, Australia
Contact:

Postby Psychobabble » Sep 27 2006, 9:07

Two questions:

a) Is this all as complicated as it looks to a non-programmer like myself? Or is it possible for someone like me to pick the editor up and do basic scripts like making a text box or giving the player some resources?

b) If you want to do anything even moderately fancy with the editor, do you have to include a separate .pak file or can it all be done from inside the editor?

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

Postby Pitsu » Sep 27 2006, 9:35

Psychobabble wrote:a) Is this all as complicated as it looks to a non-programmer like myself? Or is it possible for someone like me to pick the editor up and do basic scripts like making a text box or giving the player some resources?


I would say it is not the easiest. The scripting language is powerful and flexible, but if a script does not work, there is little help for fixing it.
Edit: in other words: the scripting language is OK, but there is no control of what you write into the script file and how to debug if something does not work.

b) If you want to do anything even moderately fancy with the editor, do you have to include a separate .pak file or can it all be done from inside the editor?


I do not know how do define "moderately fancy". H5 editor is easily capable of things that were a far dream in H3/H4 editors but fails at some "elementary" stuff. Anyway, the map h5m files are archives and can have any kind of files in them, including ballast junk that is not necessary for the map. Thus as long as we are not into modding entire game (all maps) an additional .pak file sounds unneccessary.
Last edited by Pitsu on Sep 27 2006, 9:49, edited 1 time in total.

User avatar
alavris
Scout
Scout
Posts: 164
Joined: 06 Jan 2006
Location: Poland
Contact:

Postby alavris » Sep 27 2006, 9:36

Psychobabble wrote:a) Is this all as complicated as it looks to a non-programmer like myself? Or is it possible for someone like me to pick the editor up and do basic scripts like making a text box or giving the player some resources?

More complicated scripts needs only basics of programming (few hours of learning) to understand them and creatre your own. Simple scripts, like message box are written somewhere in this topic, so they need only copy/paste.

Psychobabble wrote:b) If you want to do anything even moderately fancy with the editor, do you have to include a separate .pak file or can it all be done from inside the editor?

Everything which is not mod, can be done in the editor. You don't need any .pak file :)
.

User avatar
Grumpy Old Wizard
Round Table Knight
Round Table Knight
Posts: 2205
Joined: 06 Jan 2006
Location: Tower Grump

Postby Grumpy Old Wizard » Sep 27 2006, 13:40

Psychobabble wrote:Two questions:

a) Is this all as complicated as it looks to a non-programmer like myself? Or is it possible for someone like me to pick the editor up and do basic scripts like making a text box or giving the player some resources?

b) If you want to do anything even moderately fancy with the editor, do you have to include a separate .pak file or can it all be done from inside the editor?


It has been a number of years since I have been involved in programming. I have been asking a lot of questions and Pitsu and alavris have been very helpful in getting my scripts to work and telling me how to do stuff.

You will find examples of a lot of things already posted. By examining and modifying those scripts you can probably do the majority of what you would want to do

I say take the plunge and learn with the rest of us. :)

Edit: Oh, you will find the terraforming abilities of the editor to be simply amazing. :-D

GOW
Frodo: "I wish the ring had never come to me. I wish none of this had happened."

Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."

User avatar
Psychobabble
Spectre
Spectre
Posts: 706
Joined: 06 Jan 2006
Location: Melbourne, Australia
Contact:

Postby Psychobabble » Sep 27 2006, 14:00

Ok, thx for the replies. It looks like it should be ok.

User avatar
Evenshade
Leprechaun
Leprechaun
Posts: 21
Joined: 06 Jan 2006

Postby Evenshade » Sep 27 2006, 15:51

Has anyone succeeded in getting their own PWL image to work for their map? I seem to have the procedure right (according to the tutorial), but whenever I go to provide the SrcName (i.e., the .tga file) for the texture, it just simply refuses to put the text of the filename in or load the file. I always just get a pure grey PWL background when I start the map ingame...

User avatar
alavris
Scout
Scout
Posts: 164
Joined: 06 Jan 2006
Location: Poland
Contact:

Postby alavris » Sep 27 2006, 16:25

Evenshade wrote:Has anyone succeeded in getting their own PWL image to work for their map? I seem to have the procedure right (according to the tutorial), but whenever I go to provide the SrcName (i.e., the .tga file) for the texture, it just simply refuses to put the text of the filename in or load the file. I always just get a pure grey PWL background when I start the map ingame...


I have the same situation. Maybe it's editor's bug or they just have not told everything in that official manual.
.

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

Postby Pitsu » Sep 27 2006, 20:04

Evenshade wrote:Has anyone succeeded in getting their own PWL image to work for their map? I seem to have the procedure right (according to the tutorial), but whenever I go to provide the SrcName (i.e., the .tga file) for the texture, it just simply refuses to put the text of the filename in or load the file. I always just get a pure grey PWL background when I start the map ingame...


Looks like the editor does not want to convert the tga and create proper references. By manually creating a dds file and proper reference files and adding them into h5m archive it can be done.

Image

1. Create tga and dds files of the image and place them into unpacked map directory where you have all other map files.

2. Create text file named for example PWL.(Texture).xdb with the following text (the parameters can later be edited in editor if i am not mistaken): Note the references to image files ("filename.tga or dds"). EDIT: in fact this is the file you can create in editor already. The editor simply refuses to put the image file references into it and leaves the "href=" blank.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<Texture>
   <SrcName href="filename.tga"/>
   <DestName href="filename.dds"/>
   <Type>REGULAR</Type>
   <ConversionType>CONVERT_TRANSPARENT</ConversionType>
   <AddrType>CLAMP</AddrType>
   <Format>TF_DXT1</Format>
   <Width>1024</Width>
   <Height>1024</Height>
   <MappingSize>0</MappingSize>
   <NMips>1</NMips>
   <Gain>0</Gain>
   <AverageColor>0</AverageColor>
   <InstantLoad>true</InstantLoad>
   <IsDXT>false</IsDXT>
   <FlipY>false</FlipY>
   <StandardExport>true</StandardExport>
   <UseS3TC>false</UseS3TC>
</Texture>


3. pack everything into a h5m archive again.

If it does not work like that, then i have forgotten to mention something. ;|


Return to “Mapmaking Guild”

Who is online

Users browsing this forum: No registered users and 5 guests