Heroes V map editor questions

Maps and the art of mapmaking.
User avatar
Asheera
Round Table Knight
Round Table Knight
Posts: 4506
Joined: 06 Jul 2008
Location: The Shadows
Contact:

Unread postby Asheera » 01 Sep 2008, 21:14

As a side note, GetGameVar and SetGameVar are useful only when you need to exchange a variable between multiple scripts (example: the main map script modifies a variable which is shared and used in a combat script as well)

A global script variable like I gave example above is GLOBAL but only to the script you're currently in. Variables defined through SetGameVar and retrieved with GetGameVar are GLOBAL for the entire game session.
No matter how powerful one becomes, there is always someone stronger. That's why I'm in a constant pursuit of power, so I can be prepared when an enemy tries to take advantage of me.

Hamza al-Assad
Lurker
Lurker
Posts: 1
Joined: 15 Sep 2008

Spell Question

Unread postby Hamza al-Assad » 15 Sep 2008, 03:26

Hi all, this is my first post and I'm hoping I'm getting it in the right spot.

I'm trying to build a map with towns that have preplanned spells in the guilds. Can't do it... According to the search I've done here, the solution is to click the 'Spells' tab in the object properties box. But there is no such tab. Instead I've got: Garrison, Town Specialization, Script, Player, Buildings and Garrison Hero.

I'm sorry for such a lame question, but I don't know where to look and the manual is not very helpful.

User avatar
John.Galt
Pixie
Pixie
Posts: 141
Joined: 29 Jul 2008
Location: The Utopia of Greed

Unread postby John.Galt » 29 Sep 2008, 02:33

Hey, Question:

Is there any way to make a script function that would ask a riddle for example, that the player would have to answer? I have no idea if this is even possible, let alone how to do it.
I swear - by my life, and my love of it - that I will never live for the sake of another man, nor ask another man to live for mine.

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 Sep 2008, 03:18

Franzy mentioned a new undocumented functinon TalkBoxForPlayers that could possibly be useed for that. I'm not really clear on what all the function does. Otherwise you could try using several QuestionBox functions.

viewtopic.php?t=9219
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."

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

Unread postby Franzy » 29 Sep 2008, 08:09

If you mean typing in answer, it is NOT possible in H5, and never will be. If you mean choosing one answer from a given set (like Sphinx), it's possible. Use TalkBox for that, as GOW suggested.

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

Unread postby rdeford » 29 Sep 2008, 13:36

With help from Franzy's postings, I wrote a working talk box for players that displays four choices for the player to choose from. Here is the code (Sorry about the line wraps; It looks better in the editor.):

Code: Select all

		

pFilter = {1, 2, 4, 8};  -- player 1-4 filter constants for multiplayer functions

pFlt = pFilter[pNum];			-- get the player filter

TalkBoxForPlayers
		( 
			pFlt, -- show talk box to chosen player
			'/Textures/Interface/Sphinx/SphinxIcon.(Texture).xdb#xpointer(/Texture)', --iconRef 
			'', 	-- iconTooltipRef ref to txt file with text that will appear when hovering mouse above icon
			path..'ssMainText.txt', -- textRef - text that would be shown beside icon (no show, bug)
			path..'ssAddText.txt', 	-- text that is shown below the buttons with options 
			'ssChoiceHandler', 		-- callback - name of a function that will be envoked when player hits OK button. 
			0, 		-- mode
			path..'ssCaptionText.txt', -- titleTextRef - Caption text in the upper part of dialog (not mandatory)
			path..'ssSelectionText.txt',  -- selectTextRef - Text that will be shown above options (not mandatory
			0, 		-- default option sent when player clicks OK without making selection
			path..'ssOption1.txt', -- optionTextRef - text for options. 5 options possible
			path..'ssOption2.txt',
			path..'ssOption3.txt',
			path..'ssOption4.txt'
		);
function ssChoiceHandler(playerID, choice) 
	print("player is ", playerID, " -- choice is ", choice);
	
	if choice == 1 then
		for i=1, 4 do	
			local pSta = GetPlayerState(i); 	-- active players are 1
			if pSta == 1 then
				local pRes = GetPlayerResource(i, WOOD);	
				SetPlayerResource(i, WOOD, pRes + (3 * gSSbase));
				local pRes = GetPlayerResource(i, ORE);	
				SetPlayerResource(i, ORE, pRes + (3 * gSSbase));	
			end;
		end;
	end;

	if choice == 2 then
		for i=1, 4 do	
			local pSta = GetPlayerState(i); 	-- active players are 1
			if pSta == 1 then
				local pRes = GetPlayerResource(i, MERCURY);	
				SetPlayerResource(i, MERCURY, pRes + (2 * gSSbase));
				local pRes = GetPlayerResource(i, CRYSTAL);	
				SetPlayerResource(i, CRYSTAL, pRes + (2 * gSSbase));	
			end;
		end;
	end;
	
	if choice == 3 then
		for i=1, 4 do	
			local pSta = GetPlayerState(i); 	-- active players are 1
			if pSta == 1 then
				local pRes = GetPlayerResource(i, SULFUR);	
				SetPlayerResource(i, SULFUR, pRes + (2 * gSSbase));
				local pRes = GetPlayerResource(i, GEM);	
				SetPlayerResource(i, GEM, pRes + (2 * gSSbase));	
			end;
		end;
	end;
	
	if choice == 4 then
		for i=1, 4 do	
			local pSta = GetPlayerState(i); 	-- active players are 1
			if pSta == 1 then
				local pRes = GetPlayerResource(i, GOLD);	
				SetPlayerResource(i, GOLD, pRes + (1500 * gSSbase));
			end;
		end;
	end;
	MessageBoxForPlayers(PLAYERFLT_ALL,{ path.."supplyShip.txt"; pNum = playerColors[playerID], res = resName[choice]},nil );
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

User avatar
John.Galt
Pixie
Pixie
Posts: 141
Joined: 29 Jul 2008
Location: The Utopia of Greed

Unread postby John.Galt » 04 Oct 2008, 18:04

Is there a way to prevent a hero from getting a specific skill?

For example, I'm strictly controlling the troops the hero can have, but he is a ranger, so I want to prevent him from getting Battle Commander, which would give him war dancers every week.
I swear - by my life, and my love of it - that I will never live for the sake of another man, nor ask another man to live for mine.

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

Unread postby Franzy » 05 Oct 2008, 09:20

No.

This can only be done by a mod.

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

Unread postby Franzy » 05 Oct 2008, 09:21

By the way, war commander only gives war dancers ONCE (when you choose the perk on level-up). The number of dancers you get does depend on week number, though.

User avatar
John.Galt
Pixie
Pixie
Posts: 141
Joined: 29 Jul 2008
Location: The Utopia of Greed

Unread postby John.Galt » 06 Oct 2008, 17:45

Oh... There was some ambiguous wording on the skill wheel. I just changed the hero type to warlock, lol.

So, new question: Is there any way to make lava passable? I've got the whole elemental thing going on and a part of the map is devoted to fire elementals, so I want their territory to be lava and the water elementals to be water...
I swear - by my life, and my love of it - that I will never live for the sake of another man, nor ask another man to live for mine.

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

Unread postby Franzy » 07 Oct 2008, 06:47

Any tile can be made passable with a little trick. Just create a dubble (your own copy) of an object you want to make "ghosty" (fully passable) then open its properties tree, locate property "BlockedTiles" and clear all entries. Voila.

I would recommend to do the trick only with static objects (trees, mountains, etc), cause active objects (dolmens, towns, dwellings, etc) also have ActiveTiles. And I am not sure if you can safely remove them.

Beware that hero will pass THRUGH ghosty objects, not walking on their surface.

P.S. I hope you know how to make object dubbles. If not, read the thread, it was discussed many times. Also it's described in editor manual.

User avatar
John.Galt
Pixie
Pixie
Posts: 141
Joined: 29 Jul 2008
Location: The Utopia of Greed

Unread postby John.Galt » 13 Oct 2008, 15:26

It's not an object though, but rather an unpassable terrain...
I swear - by my life, and my love of it - that I will never live for the sake of another man, nor ask another man to live for mine.

User avatar
Belchior
Peasant
Peasant
Posts: 57
Joined: 17 May 2009
Location: Finland
Contact:

Unread postby Belchior » 25 May 2009, 19:13

What is wrong about this?
first one the angel join note works, but other textboxes not show?
is it have to be wrote scripts in right order on script editor?
i mean if this angel join comes later than "orchnote" and before "exporgold"
???
-------------------------------------------------------------------------------
----------------angel join note------------------------------------------------
function angeljoining(h,rg)
if h == "Nicolai" then
Trigger( REGION_ENTER_AND_STOP_TRIGGER, "rgnangeljoin", nil );
MessageBox("Maps/SingleMissions/Demon Urgash/angeljoinnote.txt");
GiveExp( "Nicolai", 8000 );
GiveResources( "Nikolai", 10000, 6 );
end;
end;

Trigger( REGION_ENTER_AND_STOP_TRIGGER, "rgnangeljoin", "angeljoining" );
------------------------------------------------------------------------------
------------------------------------------------------------------------------
function expgoldnote(h,rg)
if h == "Nicolai" then
Trigger( REGION_ENTER_AND_STOP_TRIGGER, "rgnexpgoldnote", nil );
MessageBox("Maps/SingleMissions/Demon Urgash/expgold.txt");
GiveExp( "Nicolai", 2000 );
GiveResources( "Nikolai", 10000, 6 );
end;
end;

Trigger( REGION_ENTER_AND_STOP_TRIGGER, "rgnexpgoldnote", "expgoldnote" );
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
function orchold(h,rg)
if h == "Nicolai" then
Trigger( REGION_ENTER_AND_STOP_TRIGGER, "rgnorchold", nil );
MessageBox("Maps/SingleMissions/Demon Urgash/orchold.txt");
end;
end;

Trigger( REGION_ENTER_AND_STOP_TRIGGER, "rgnorchold", "orchold" );
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------

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

Unread postby Franzy » 26 May 2009, 05:25

Is GiveResources your own function?

Everything seems fine. There might be problems with region names though. They should match exactly, so watch trailing spaces and letter case.

Also, as I told you already, look what the console says. It points out error AND the line number. No need to play guess games.

User avatar
Belchior
Peasant
Peasant
Posts: 57
Joined: 17 May 2009
Location: Finland
Contact:

Unread postby Belchior » 26 May 2009, 12:07

well thats why i asking because console not so errors..
and that giveresources are not my. but its not problem there because other fuctions work perfectly even that is there..

i have looked regions aswell..hmm maybe im too hesitated.. maybe i need to look very sharp.. because mistakes come.. and i had erros what i solved a lot. triple check is good :)
btw whole script is now 132 lines long and those are last ones and they not show..
AND script starts. all other work.. so its not big mistake because scripth work else good..

EDIT:
-------------------------------------------------------------------------------------------------
ääh i found problem and solve it.
region area was too small :)

User avatar
Belchior
Peasant
Peasant
Posts: 57
Joined: 17 May 2009
Location: Finland
Contact:

Unread postby Belchior » 26 May 2009, 15:22

New question. i have seen this some where in this forum but not find which topic it was..
so..
how i can make monster as a normal object what dont attack me but acts like friendly unit, and when my hero touch it, textbox appears and then give spell and then vanish from map

i dea is that i want make vampire to give me vampirism spell when i "talk" with him :)

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

Unread postby Franzy » 27 May 2009, 10:39

1) Name your monster, e.g. "thevampire"
2) Add these lines to your script:

function speaktovampire(obj,h)
MessageBox(...)
TeachHeroSpell(h, SPELL_VAMPIRISM);
end;

SetObjectEnabled("thevampire",nil)
Trigger(OBJECT_TOUCH_TRIGGER,"thevampire","speaktovampire");

(lines can contain errors, check them by referencing the manuals, but the idea is correct)

3) You may also want to add custom description to the monster and change cursor from "sword" to "interaction", there functions for that.

User avatar
Belchior
Peasant
Peasant
Posts: 57
Joined: 17 May 2009
Location: Finland
Contact:

Unread postby Belchior » 27 May 2009, 17:29

when i go to vampire i cannot go to him.. i can see sword coming on it but when i double click i cannot move to him...
here is a code...
-------vampire speak--------------------------------------------------------
function speaktovampire(obj,h)
MessageBox("Maps/SingleMissions/Demon Urgash/kuiskaus.txt" );
TeachHeroSpell(h, SPELL_VAMPIRISM);
end;

SetObjectEnabled("thevampire",nil)
Trigger(OBJECT_TOUCH_TRIGGER,"thevampire","speaktovampire");
and i have change vampire name "thevampire" in monsters properties when i click it and map properties tree appereas at this monster only. there is "name" option so i though it that what u say?

console not say nothing.
AND i not found info in " script functions" manual..

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

Unread postby Franzy » 27 May 2009, 20:51

Correct script, should work:
------vampire speak--------------------------------------------------------
function speaktovampire(h)
MessageBox("Maps/SingleMissions/Demon Urgash/kuiskaus.txt" );
TeachHeroSpell(h, SPELL_VAMPIRISM);
end;

SetObjectEnabled("thevampire",nil)
Trigger(OBJECT_TOUCH_TRIGGER,"thevampire","speaktovampire");

User avatar
Belchior
Peasant
Peasant
Posts: 57
Joined: 17 May 2009
Location: Finland
Contact:

Unread postby Belchior » 30 May 2009, 17:19

This one solved...
Last edited by Belchior on 31 May 2009, 10:40, edited 1 time in total.


Return to “Mapmaking Guild”

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest