[H5 EDITOR] Troubleshooting topic

Maps and the art of mapmaking.
bkknight2602
Pixie
Pixie
Posts: 100
Joined: 23 May 2010
Location: Texas

Unread postby bkknight2602 » 18 Aug 2010, 03:48

Franzy wrote:As for your other questions:
for 1 = 1, 1 do will generate an error

Yes, i was what I meant to type.

I believe you meant something like for i=1,1 do
This will run 1 time.
for i=1,0 do will run 0 times.

Did not understand you 3d question. Is it a suggestion?

You answered that part in that code is evaulated prior to any movement and not again until some trigger statement is used.

Also, day counting starts from 1, not 0.

P.S. To save you from a common mistake, NEW _DAY_TRIGGER does NOT triggers on the first day.

Found that one out by trial and error.
I did get the code to work(finally) and am in the process of making it shorter. One problem that has me stumped:

Trigger(NEW_DAY_TRIGGER, "addstuff");--Will change Trigger(PLAYER_ADD_HERO_TRIGGER, "addstuff");
if GetDate(DAY) == 1 then
startnumberofheroes = 0;
print("Prior to call");
playernames = GetPlayerHeroes(PLAYER_1);
print(length(playernames));
addstuff();
end;
print(GetDate(DAY));
function addstuff()
print(startnumberofheroes);
playernames = GetPlayerHeroes(PLAYER_1);
print(length(playernames));
for i = startnumberofheroes, length(playernames) - 1 do
GiveArtefact(playernames, 4);
GiveHeroWarMachine(playernames, 1);
GiveHeroWarMachine(playernames, 3);
GiveHeroWarMachine(playernames, 4);
print(playernames);
end;
startnumberofheroes = length(playernames);
end;

This DOES NOT work at scenario start, but does function at the new day(I'm going to change it to hire hero trigger).
The print statments are there to help me debug.
On game start the function has the error in calling a nil value, however the new day trigger works fine. All the variables have the correct values, I checked them in the console on day 1 and day 2.

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

Unread postby Franzy » 18 Aug 2010, 21:17

Remember, triggers pass various useful info to trigger handlers. So you can write:

Code: Select all

function addstufftonewguy(newguy)

GiveArtefact(newguy, 4); 
GiveHeroWarMachine(newguy, 1); 
GiveHeroWarMachine(newguy, 3); 
GiveHeroWarMachine(newguy, 4);

end;

Trigger(PLAYER_ADD_HERO_TRIGGER,PLAYER_1,'addstufftonewguy');

bkknight2602
Pixie
Pixie
Posts: 100
Joined: 23 May 2010
Location: Texas

Unread postby bkknight2602 » 18 Aug 2010, 21:50

Ok, but why doesn't the call work on day 1?

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

Unread postby Franzy » 19 Aug 2010, 17:43

No idea :) You should probably trace every line.

Also, do you know you can execute any script command in console by preceeding it with @ symbol? I usually try my code line by line (well the commands I'm not sure about) this way before putting it into script.

bkknight2602
Pixie
Pixie
Posts: 100
Joined: 23 May 2010
Location: Texas

Unread postby bkknight2602 » 19 Aug 2010, 22:17

From the print statements, it goes to the call and bombs out there. Does it need an argument? I also tried to move the call outside the if , but still didn't work.
Yes to the console testing, and the values were correct for the "for" statement, but still got the nil error message.
That function did work in both the new day trigger and add hero trigger(without the for statement of course), just didn't work on the call.

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

Unread postby Franzy » 22 Aug 2010, 17:21

Hm. Maybe lua can't manage forward calls. Try writing all the functions BEFORE you call them.

bkknight2602
Pixie
Pixie
Posts: 100
Joined: 23 May 2010
Location: Texas

Unread postby bkknight2602 » 22 Aug 2010, 23:12

Well I put the Triggers ate the end, the functions at the beginning and the if statement testing for day 1 after the fubctions.
All worked as expected, I would have thought the code order, once compiled did not make any difference. However, your idea was correct, again thanks.

While dabbling in all this code I have come up up with some interesting revalations:
We are able to "give" skills but not "perks" with code. I know the perks are a function of advanced and expert levels(skill level is at basic when coded). Do you know of any coding to either increase or test a skill level?

I have not found a way to program town construction. Any thoughts for this?

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

Unread postby Franzy » 23 Aug 2010, 03:36

You can add perks provided hero has appropriate skills using the very same GiveHeroSkill. You can learn skill's mastery using GetHeroSkillMastery. You can increase mastery by giving the very same skill one or two more times accordingly.

bkknight2602
Pixie
Pixie
Posts: 100
Joined: 23 May 2010
Location: Texas

Unread postby bkknight2602 » 24 Aug 2010, 12:35

Giving the primary skill 3 times worked, thanks.

Any thoughts or commands on town construction?

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

Unread postby Franzy » 24 Aug 2010, 19:31

Town building works differently. You specify building level there. 0 - no building, 1 - there is building, 2 - upgraded building, 3- second upgrade (for mage guilds, town halls, castles) etc. Name of the function is in the manual, don't remember.

bkknight2602
Pixie
Pixie
Posts: 100
Joined: 23 May 2010
Location: Texas

Unread postby bkknight2602 » 25 Aug 2010, 00:38

Right to specify in SetTownBuilding* or find the levels and limits with Get TownBuilding*.

You have helped me finding heroes names, but I don't see a function for town names. The function GetAllNames has four parameters:
0-heroes
1-??
2-??
3-Named functions
I was hoping this would give it to me, but alas it didn't.

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

Unread postby Franzy » 25 Aug 2010, 04:11

Unlike heroes, towns don't have innate names, you should assign them yourself. Just open town properties tree (ctrl+space) and write any id in the NAME field.

jojo
Leprechaun
Leprechaun
Posts: 1
Joined: 13 Sep 2010

Unread postby jojo » 13 Sep 2010, 13:46

hi, as I can't start a new post I'll try to ask it here =)
I'm trying to create some new arenas, but I can't find out how to increase the size of the objects (creatures, dwellings, etc)...
I've seen some shots with a SizePercent command... but I can't find it in the editor =/
any hint?

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

Unread postby Franzy » 14 Sep 2010, 15:30

Every object has a property called Scale or similar, don't remember. You can change size via it.

seth_krn3ll
Leprechaun
Leprechaun
Posts: 3
Joined: 15 Sep 2010

script error objective is not exists

Unread postby seth_krn3ll » 15 Sep 2010, 12:58

Hello there.

I need a little help here with a script error making me crazy.

I made a single player scenario map with two players wich can be both human or computer driven and i added some secondary objective to both of them.
All the objectives i assigned to player 0 (ingame player 1) works perfectly, but i am having troubles with objectives assigned to player 1 (ingame player 2).

The objectives are supposed to be set initially invisible and initially inactive and have to be activated by some triggers (actually two region_enters and one object_touch).
Now, when i test player 2 and activate the triggers i get this error script message:
(script)ERROR: objective 'strego_prison_1' is not exists

(script)ERROR: objective 'con_cittastrego' is not exists
where of course strego_prison_1 and con_cittastrego are the names of the triggered objectives. Same thing with the others.

here is the code of the triggering functions:

Code: Select all

--Mission script Start (attiva missione strego_prison_1)
function StregoPrison_1() 
    if GetCurrentPlayer() == omosapience and GetCurrentPlayer() == 2 then 
        MessageBox(path.."strego_prison_1_desc.txt"); 
        SetObjectiveState ("strego_prison_1", OBJECTIVE_ACTIVE); 
    end; 
	Trigger(REGION_ENTER_AND_STOP_TRIGGER, "strego_prison_1", nil); 
end; 
Trigger(REGION_ENTER_AND_STOP_TRIGGER, "strego_prison_1", "StregoPrison_1");
--Mission script End
--Mission script Start (completa missione strego_prison_1 e attiva missione strego_prison_2)
function StregoPrison_1_completed() 
    if GetCurrentPlayer() == omosapience and GetCurrentPlayer() == 2 then 
        MessageBox(path.."strego_prison_1_completed_desc.txt"); 
        SetObjectiveState ("strego_prison_1", OBJECTIVE_COMPLETED); 
    end; 
    Trigger (OBJECT_TOUCH_TRIGGER, "strego_prison_1", nil ); 
end; 
Trigger (OBJECT_TOUCH_TRIGGER, "strego_prison_1", "StregoPrison_1_completed" );
--Mission script End
--Mission script Start (completa missione strego_prison_2)
function StregoPrison_2()
    if GetCurrentPlayer() == omosapience and GetCurrentPlayer() == 2 then 
        MessageBox(path.."strego_prison_2_completed_desc.txt"); 
        SetObjectiveState ("strego_prison_2", OBJECTIVE_COMPLETED); 
    end; 
Trigger (OBJECT_TOUCH_TRIGGER, "strego_prison_2", nil ); 
end; 
Trigger (OBJECT_TOUCH_TRIGGER, "strego_prison_2", "StregoPrison_2" );
--Mission script End

I checked and those are the precise names i gave to those objectives (yes, names of the objects to touch are the same of objectives, it works for the other player's mission as well, so i guessed it would work there too), perfectly spelled and all.
I tried many things to get what is done wrong, this is one of the last checks:

Code: Select all

function StartStrego()
        walker = GetCurrentPlayer();
        if walker == 2 and omosapience == 2 then
	        MessageBoxForPlayers(PLAYERFLT_2,path.."startstrego.txt");
--start check about objectives not working
	        checkprison1 = GetObjectiveState("strego_prison_1", 2);
	        checkprison2 = GetObjectiveState("strego_prison_2", 2);
	        checkcitta = GetObjectiveState("con_cittastrego", 2);
	        print ('check prison1:',checkprison1,'check prison2:',checkprison2,'check citta:',checkcitta);
            SetObjectiveState ("strego_prison_1", OBJECTIVE_ACTIVE); 
            SetObjectiveState ("strego_prison_2", OBJECTIVE_ACTIVE); 
            SetObjectiveState ("con_cittastrego", OBJECTIVE_ACTIVE); 
--end check about objectives not working
	    end;
	    Trigger(REGION_ENTER_AND_STOP_TRIGGER, "startstrego", nil);
end;
Trigger(REGION_ENTER_AND_STOP_TRIGGER, "startstrego", "StartStrego");
The function is called at very start of map. The print command returned three "1", the SetObjectiveState returned one error:
(script)ERROR: objective 'strego_prison_1' is not exists
then nothing more.
The other two SetObjectiveState seems to be not processed at all. No active missions in the ingame panel.

If i go on with the game, when i reach the other triggers the console again says:
(script)ERROR: objective 'strego_prison_1' is not exists

(script)ERROR: objective 'con_cittastrego' is not exists
All seems to say those objectives are not at all present in the game or they are called different names, BUT if i set them to be initially visibile or active, they are visibile in the player active objective ingame panel list with their texts. Why then they are checked by GetObjectiveState ? Doesent it should say something like strego_prison_1 not existent?

I tried another check having objective strego_prison_1 initially ACTIVE and VISIBLE by default:

Code: Select all

function StartStrego()
        walker = GetCurrentPlayer();
        if walker == 2 and omosapience == 2 then
	        MessageBoxForPlayers(PLAYERFLT_2,path.."startstrego.txt");
--start check about objectives not working
	        checkprison1 = GetObjectiveState("strego_prison_1", 2);
	        checkprison2 = GetObjectiveState("strego_prison_2", 2);
	        checkcitta = GetObjectiveState("con_cittastrego", 2);
	        print ('first round - check prison1:',checkprison1,'check prison2:',checkprison2,'check citta:',checkcitta);
			SetObjectiveState ("strego_prison_1", OBJECTIVE_COMPLETED); 
            SetObjectiveState ("strego_prison_2", OBJECTIVE_ACTIVE); 
            SetObjectiveState ("con_cittastrego", OBJECTIVE_ACTIVE); 
	        checkprison1 = GetObjectiveState("strego_prison_1", 2);
	        checkprison2 = GetObjectiveState("strego_prison_2", 2);
	        checkcitta = GetObjectiveState("con_cittastrego", 2);
	        print ('second round - check prison1:',checkprison1,'check prison2:',checkprison2,'check citta:',checkcitta);
            SetObjectiveState ("strego_prison_2", OBJECTIVE_ACTIVE); 
            SetObjectiveState ("con_cittastrego", OBJECTIVE_ACTIVE); 
--end check about objectives not working
	    end;
	    Trigger(REGION_ENTER_AND_STOP_TRIGGER, "startstrego", nil);
end;
Trigger(REGION_ENTER_AND_STOP_TRIGGER, "startstrego", "StartStrego");
function is correctly triggered and messagebox show up.

console results:
first round - check prison1:2
check prison2:1
check citta:1
which means the game SEES strego_prison_1 objective as active and visible!

then:
(script)ERROR: objective 'strego_prison_1' is not exists
which means game DO NOT SEE strego_prison_1 objective as existent!

script stops there to work, the function is not processed on other lines, and the region is not deleted, so i can re-enter it again and again having the same results, included the messagebox.

So those objectives ARE existent and they works and the game knows it, and i can't understand why it seems not to find them at all when i try to modify their status by script.

I made some other tests and things seems really weird.

I made another brand new map just for test purposes. Added just two towns, two heroes and two secondary objectives, one for each player, along with regions to trigger them.

Well, as first player's task is correctly triggered, player 2 again can't trigger his secondary task. Same error message: task is not exists.

Now I wonder if really player_2 CANNOT trigger any Objective_Kind_Manual at all. I downloaded some maps and at best I found player_2 with secondary predefined tasks.

Some other tries i made:

1. I transformed the map from singleplayer to multiplayer type, thinking that maybe on multi also player_2 was able to get script managed (e.g. Objective_Kind_Manual) secondary missions. Nope: same results: task is not exists. Sounds possible that even in multiplayer games you cannot assign script triggered secondary missions to another player but player 1??? Well, not enough!
2. I said, ok, no secondary missions possible, then lets make them Primary missions. Guess what? Same chit. But in gods sake, is it possible that this game engine does not permit to have not predefined core managed kind of missions for all players BUT player one? I really hope its me making some kinda mistake somewhere...

Any hint anyone about where did i go wrong?
Does anyone knows of maps with player_2 having missions of Objective_Kind_Manual type? If so please give me the links so i can check how they works.

Thanks in advance

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

Unread postby Franzy » 15 Sep 2010, 18:44

You forgot to provide the third argument for SetObjectiveStatus function - the name of the player. By default they are applied to the first player, and the first player doesn't have that objective, as far as I got it. So simply add PLAYER_2 and you'll be fine.

seth_krn3ll
Leprechaun
Leprechaun
Posts: 3
Joined: 15 Sep 2010

Unread postby seth_krn3ll » 16 Sep 2010, 20:09

Franzy wrote:You forgot to provide the third argument for SetObjectiveStatus function - the name of the player. By default they are applied to the first player, and the first player doesn't have that objective, as far as I got it. So simply add PLAYER_2 and you'll be fine.
That is, gotcha.
I knew I was making some stupid error somehwre, thanks a lot Franzy. Now it all works fine.

A pity I made that map (my first one) with italian text, i would have loved to share it there.

seth_krn3ll
Leprechaun
Leprechaun
Posts: 3
Joined: 15 Sep 2010

Adding Map to Campaign

Unread postby seth_krn3ll » 16 Sep 2010, 20:27

BTW, given I was stuck there with that map I worked in the last two days at another project. This time the idea is a full campaign.

I made two single player scenarios map, intended to be the first two map episodes of the campaign. They works perfectly as scenarios, but i can't find the way to add them to the Campaign Map.

Here's how i proceed:
1. I open the H5mapeditor.
2. I click on Tools/Create Campaign (BTW, there is not an "edit-modify" campaign command, are campaign file supposed to be set at once and never more?)
3. A panel opens up. I can add campaign name and description and there's a ADD button to add the scenarios, so i click it.
4. another panel shows up, with a drop down menu where i suppose should apper the name of the scenarios you can add to your campaign, but my one is empty.

I tried adding some scenarios map to the Maps directory of the game, but just one of them shows up in that drop down menu. I opened its configuration files to try to understand what kind of parameters are different from all the others i have there but can't find it out.

The maps I intend to add to the campaign are (as far as now) two single player scenarios with one human-playable Orcish player, one or more AI-Players, some manual primary quests, teams locked... dunno what else to add. I tried changing all those parametrs, still they don't show up in the ADD drop down menu.

So my question is: anyone knows what are the requirements for a scenario map to be addable to a campaign (e.g. to show up in the drop down menu of the campaign mapeditor)?

EDIT:

Ok i finally get what was wrong. I post it here so if anyone else is so mad to start modding again for this old wonderful game maybe the info could be useful.

The reason why the campaign editor drop down did not show any of my latest maps is the setvar modifications in the editor config file in profiles.

The H5editor can be modified to resume some hidden functionalities (e.g. more editable functions, more objects etc.). Some of those modifications are explained in forum posts (also in this forum). One of them is to change the setvar value in the editor_a2.cfg file in profiles folder in the game directory. This will give some interesting stuff, but - at least for me - meant to make unusable the maps i created or modified for the campaign feature.
I just checked and if i save my maps with the correct value in editor_a2.cfg the maps are now usable for campaigns. Just in case anyone needs it, its here.

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

Unread postby Franzy » 17 Sep 2010, 15:46

seth_krn3ll wrote: A pity I made that map (my first one) with italian text, i would have loved to share it there.
You seem to be good with English :) Just translate and post it here. Translation is pretty easy in H5, simply open the map as the zip archive and translate all the txt-files.

I personally make maps in English first and only then translate them into my native language.

bkknight2602
Pixie
Pixie
Posts: 100
Joined: 23 May 2010
Location: Texas

Unread postby bkknight2602 » 28 Nov 2010, 21:38

A new question scripting coding.
I have looked thrugh the scripts and can't find how to programmically determine a heroes' "type" ie Knight, Warlock, Ranger, Necromancer etc.


Return to “Mapmaking Guild”

Who is online

Users browsing this forum: No registered users and 1 guest