[H5 EDITOR] Troubleshooting topic

Maps and the art of mapmaking.
User avatar
josip
Leprechaun
Leprechaun
Posts: 4
Joined: 12 Oct 2006

Unread postby josip » 12 Oct 2006, 15:12

Hi experts !

I have created a new single player map.

First I've tried to script something quite simple but it didn't work.

So I just have copied and pasted the example provided by the manual:

function Meeting( heroname )
if heroname == "Arthur" then
SetPlayerResource( PLAYER_1, GOLD, 10000 );
AddHeroCreatures( heroname, CREATURE_ARCHANGEL, 1 );
Trigger( REGION_ENTER_AND_STOP_TRIGGER, "meeting", nil );
end;
end;
Trigger( REGION_ENTER_AND_STOP_TRIGGER, "meeting", "Meeting" );


I have created a region and named it "meeting".

I have named my hero "Arthur".

I've tested the script in game and... nothing.

In the editor, when I perform a "check script", I have two errors:

Function Meeting not defined, line 1
Function CREATURE_ARCHANGEL not defined, line 4

Now, I have an headache.

Could you please help me ?

(Excuse my bad english, I'm belgian)





It seems that the game

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

Unread postby alavris » 12 Oct 2006, 15:26

Probably, you've changed hero name in wrong place... Here's what must be done:

Open object properties tree. To do this, mark by the cursor the hero on the map. When it's red, press CTRL+SPACE. Now, add name of the hero in this tree. It's important to do it here, because done in hero properties window will not work.
.

User avatar
josip
Leprechaun
Leprechaun
Posts: 4
Joined: 12 Oct 2006

Unread postby josip » 12 Oct 2006, 16:54

alavris wrote:Open object properties tree. To do this, mark by the cursor the hero on the map. When it's red, press CTRL+SPACE. Now, add name of the hero in this tree. It's important to do it here, because done in hero properties window will not work.
.
Hello alavris.

That's what I had done. But no result.

User avatar
Marzhin
Pit Lord
Pit Lord
Posts: 1207
Joined: 06 Jan 2006
Location: Montreuil, France
Contact:

Unread postby Marzhin » 12 Oct 2006, 17:04

josip wrote:
alavris wrote:Open object properties tree. To do this, mark by the cursor the hero on the map. When it's red, press CTRL+SPACE. Now, add name of the hero in this tree. It's important to do it here, because done in hero properties window will not work.
.
Hello alavris.

That's what I had done. But no result.
Maybe you should use the scripting name of the hero ?

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

Unread postby alavris » 12 Oct 2006, 17:16

Marzhin wrote:Maybe you should use the scripting name of the hero ?
That's what we actually were talking about :)
josip wrote:That's what I had done. But no result.
Maybe the problem is here:
HOMM5_Script_Functions.pdf wrote:REGION_ENTER_AND_STOP_TRIGGER – the hero enters the region (and must stay within it)
REGION_ENTER_WITHOUT_STOP_TRIGGER – the hero enters the region (and does not have to stay within it)
So, maybe your hero that enters the region, doesn't stop there? Try it again using REGION_ENTER_WITHOUT_STOP_TRIGGER.
.

User avatar
josip
Leprechaun
Leprechaun
Posts: 4
Joined: 12 Oct 2006

Unread postby josip » 12 Oct 2006, 21:02

I have tried each kind of region trigger with no success.

So I have tried the most simple script:

GiveExp( "Arthur", 4000 );

I am sure that my hero is named Arthur.

If I open the .h5m file, I find a file "name.1.txt" that contains the name "Arthur". So it should work, but.... no !

If I perform a check test, I have the result :

Function GiveExp not defined, line 1


And more amazing, I have started the game with console enabled to see the code history. The console says :

(script error) Hero Arthur not exists


Incredible but I'm sure of the name of my hero.


Is it possible that the problem come with the language of my keayboard ?

As an example, to enable console, I had to write :

bind show_console '`'

But in game the console is opened only if I press the key "²". That is because the "²" key on a belgian keyboard is at the place of the "`" key on english keyboard.


I'm stuck :(

myythryyn
Assassin
Assassin
Posts: 293
Joined: 05 Sep 2006

Unread postby myythryyn » 12 Oct 2006, 23:09

what was arthur's name before you customized it?
many times the game wants the heroscript name.

http://www.heroesofmightandmagic.com/he ... ames.shtml

this link has all the hero names. try that, and if its not that, then then its definetly something else. maybe the example in the manual was just a generic one.

User avatar
josip
Leprechaun
Leprechaun
Posts: 4
Joined: 12 Oct 2006

Unread postby josip » 13 Oct 2006, 00:34

myythryyn wrote:what was arthur's name before you customized it?
many times the game wants the heroscript name.

http://www.heroesofmightandmagic.com/he ... ames.shtml

this link has all the hero names. try that, and if its not that, then then its definetly something else. maybe the example in the manual was just a generic one.
Thanks you very much. You got it.

So, my hero was Nur. I had changed his name to Arthur both in the hero properties (Space menu) and in properties tree (CTRL+Space menu). I wrote my script with the name "Arthur" and it didn't work.

Now I still use the hero Nur but in hero properties I have changed his name to Arthur (this name appears in game).

AND in the properties tree I have changed his name to Astral, according to the list you have submitted.

In my script I used the name Astral.

It works.

So I'm gonna try a more complicated script.

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

Unread postby alavris » 13 Oct 2006, 04:26

myythryyn wrote:many times the game wants the heroscript name.

http://www.heroesofmightandmagic.com/he ... ames.shtml
Oh, I've never heard about it 8| So, Marzhin, you were right :)
.

the_teacher
Leprechaun
Leprechaun
Posts: 5
Joined: 18 Oct 2006

SINGLE VS MULTI SCRIPTS

Unread postby the_teacher » 18 Oct 2006, 12:06

im sorry if this quention was asked and answerred before, maybe i skipped that post,but here it is:

EXACLTY SAME scripts that work fine in single maps , copy-pasted into a multiplayer maps, seem to not work at all, not a single one of them.
both maps are test ones, just one is designed for single , the other for multi as initial setting.

is there any other option/setting that could make those scripts working in multiplayer maps?


ty

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

Re: SINGLE VS MULTI SCRIPTS

Unread postby Grumpy Old Wizard » 18 Oct 2006, 13:01

the_teacher wrote:im sorry if this quention was asked and answerred before, maybe i skipped that post,but here it is:

EXACLTY SAME scripts that work fine in single maps , copy-pasted into a multiplayer maps, seem to not work at all, not a single one of them.
both maps are test ones, just one is designed for single , the other for multi as initial setting.

is there any other option/setting that could make those scripts working in multiplayer maps?


ty
No, I don't think there is anything you can do to make scripts work in a multiplayer map. Nival disabled scripts in multiplay to help prevent cheating.

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."

the_teacher
Leprechaun
Leprechaun
Posts: 5
Joined: 18 Oct 2006

Unread postby the_teacher » 18 Oct 2006, 13:10

ty u for help, i can sleep well now :)

otter
Leprechaun
Leprechaun
Posts: 3
Joined: 21 Oct 2006
Location: Poland

Unread postby otter » 21 Oct 2006, 22:14

Hello all experts and greets 2 all HOM&M fans! :)

I have the following problem with my script: I wanted to replace all army of one hero with specified units so I wrote the following code:

Code: Select all

function ReplaceArmy(heroname)
	AddHeroCreatures(heroname, 1, 1);--want to make sure that at least one unit exist during cleaning of all units
	for i=2,CREATURES_COUNT do -- not i=1 since we want one unit remain to delete it at the end-> make sure hero will not be left w/o units during cleaning
		if (GetObjectCreatures(heroname, i) > 0) then
			RemoveHeroCreatures(heroname, i, GetObjectCreatures(heroname, i));--did GetObjectCre.. instead of big number cause in my version with 'quantity' bigger that actual creatures count script stopped to work so I had to pass exact number of creatures and not even one more..
		end;
	end;

	-- now all units should be cleared except for peasants
	AddHeroCreatures(heroname, CREATURE_SCOUT, 20);
	RemoveHeroCreatures(heroname, 1, GetObjectCreatures(heroname, 1)); 
	AddHeroCreatures(heroname, CREATURE_WITCH, 15);
	AddHeroCreatures(heroname, CREATURE_MINOTAUR, 5);
	AddHeroCreatures(heroname, CREATURE_RIDER, 3);
end;
unfortunately it behaves strangely (fast, simple example, but in both castles, Haven and Necro, tested heroes had two units in their armies):
- for haven units (I tested 2 first heroes) it looks ok (all added creatures exists), but peasant stays
- for necro units (again, tested with 2 first heroes) I have only 20 scouts and 1 peasant in the army... :(

can somebody help me? reproduce the effects or show me my mistake?

thnx in advance and welcome :)
otter

edit: I forgot to write that this script is only used for newly created heroes (bought in tavern or when game was started) so for sure they have no more than 3-4 unit in army..

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

Unread postby alavris » 22 Oct 2006, 09:15

Witam przyjaciela z Polski! ;)

Here's my code:

Code: Select all

function ReplaceArmy(heroname)	
	for i=1,91 do
		if (GetObjectCreatures(heroname, i) > 0) then
			RemoveHeroCreatures(heroname, i, GetObjectCreatures(heroname, i));
		end;
	end;
	AddHeroCreatures(heroname, CREATURE_SCOUT, 20);
	for i=1,91 do
		if (GetObjectCreatures(heroname, i) == 1) then
			RemoveHeroCreatures(heroname, i, 1);
			print("creature[", i, "] removed");
		end;
	end;
	AddHeroCreatures(heroname, CREATURE_WITCH, 15);
	AddHeroCreatures(heroname, CREATURE_MINOTAUR, 5);
	AddHeroCreatures(heroname, CREATURE_RIDER, 3);	
end;

Trigger(PLAYER_ADD_HERO_TRIGGER, PLAYER_1, "ReplaceArmy");
There is one bug that in my opinion will always happen: when you buy hero with only one type of creatures, one stack with one unit of this creature will not be removed.

This part of my code should remove this bug but it doesn't:

Code: Select all

	for i=1,91 do
		if (GetObjectCreatures(heroname, i) == 1) then
			RemoveHeroCreatures(heroname, i, 1);
			print("creature[", i, "] removed");
		end;
	end;
Print command works, but RemoveHeroCreatures command doesn't work in this unique situation. I think it's in-game bug.
.

otter
Leprechaun
Leprechaun
Posts: 3
Joined: 21 Oct 2006
Location: Poland

Unread postby otter » 22 Oct 2006, 10:30

A witam :) Witam i pozdrawiam :)

I know about the situation with one unit remaining during clearing, that is why
I added peasants (creatures with number 1), then removed all other creatures (except for peasants - I started my loop from 2), added scouts, removed peasants and added remaining units (remove comments from my code it is not looking clearly right now). In your case you have to loop through all in-game creatures twice so my solution seems to be little faster, but the problem remains: none of these solutions works :(

If it is in-game bug then I have to live with it. Thanx for your effort.

Najibarr
Leprechaun
Leprechaun
Posts: 21
Joined: 22 Oct 2006

Unread postby Najibarr » 22 Oct 2006, 17:48

Alavis your code works if you put a sleep before the ==1 part so the code would be :

Code: Select all

function ReplaceArmy(heroname)   
   for i=1,91 do
      if (GetObjectCreatures(heroname, i) > 0) then
         RemoveHeroCreatures(heroname, i, GetObjectCreatures(heroname, i));
      end;
   end;
   AddHeroCreatures(heroname, CREATURE_SCOUT, 20);
   AddHeroCreatures(heroname, CREATURE_WITCH, 15);
   AddHeroCreatures(heroname, CREATURE_MINOTAUR, 5);
   AddHeroCreatures(heroname, CREATURE_RIDER, 3);   
   sleep(1)
   for i=1,91 do
      if (GetObjectCreatures(heroname, i) == 1) then
         RemoveHeroCreatures(heroname, i, 1);
         print("creature[", i, "] removed");
      end;
   end;
end; 
you'll get only 2 bugs :
1- when you hire a hero and you put it in garrison and then exit town(the hero is still in garrison), the game wont find the hero.
2- when you hire a dungeon hero you'll have 21 scouts instead of 20 so you should add :

Code: Select all

sleep(1)
if (GetObjectCreatures(heroname, 71) == 21) then
   RemoveHeroCreatures(heroname, 71, 1);
end;
Last edited by Najibarr on 22 Oct 2006, 18:04, edited 1 time in total.

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

Unread postby alavris » 22 Oct 2006, 17:59

Nice trick Najibarr :-D Thanks!

otter
Leprechaun
Leprechaun
Posts: 3
Joined: 21 Oct 2006
Location: Poland

Unread postby otter » 22 Oct 2006, 21:54

Hi!

Thanx for that trick with sleep, everything is working now also with my version of this script. It looks like game has some synchronization problems.

anyway:

Code: Select all

function ReplaceArmy(heroname)
	AddHeroCreatures(heroname, 1, 1);
	for i=2,CREATURES_COUNT-1 do
		if (GetObjectCreatures(heroname, i) > 0) then
			sleep(1);
			RemoveHeroCreatures(heroname, i, GetObjectCreatures(heroname, i));
		end;
	end;
	AddHeroCreatures(heroname, CREATURE_SCOUT, 20);
	RemoveHeroCreatures(heroname, 1, GetObjectCreatures(heroname, 1));
	AddHeroCreatures(heroname, CREATURE_WITCH, 15);
	AddHeroCreatures(heroname, CREATURE_MINOTAUR, 5);
	AddHeroCreatures(heroname, CREATURE_RIDER, 3);
end;
There is only one loop in it and additionally you can avoid 2nd problem which was mentioned by Najibarr.

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

Unread postby Grumpy Old Wizard » 29 Oct 2006, 13:23

In my Seize the Throne map I have a script that is not working as I intended. I intended the script to display a message when the human player loses his main heroe, make the player lose, and display the message summary.

The script does make the human player lose but then the computer players continue their turns. The player can hit escape to chose game options, like exit to main menue, load, or exit to desktop, but the game summary is not displayed.

I am certain that at some point I did have a script that caused the mission summary to be displayed after the player lost, but I am not certain what I changed.

Perhaps another pair of eyes can find the problem.

function MainHeroAlive (heroname, herokiller)
if heroname == humanmainheroe then

MessageBox('Maps/SingleMissions/Seize The Throne/LoseGame.txt'); --player loses if he loses his first hero pick
Loose ();
end;
Trigger (PLAYER_REMOVE_HERO_TRIGGER, whoishuman);
end;

Trigger (PLAYER_REMOVE_HERO_TRIGGER, whoishuman, "MainHeroAlive");

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:

Unread postby alavris » 29 Oct 2006, 14:32

Maybe instead of this

Code: Select all

Trigger (PLAYER_REMOVE_HERO_TRIGGER, whoishuman);
write this:

Code: Select all

Trigger (PLAYER_REMOVE_HERO_TRIGGER, whoishuman, nil);
Maybe it will work now...
.


Return to “Mapmaking Guild”

Who is online

Users browsing this forum: No registered users and 0 guests