[H5 Tote] How do I create "in game/original" flyin

Maps and the art of mapmaking.
User avatar
Jonas
Conscript
Conscript
Posts: 219
Joined: 14 Jan 2009

[H5 Tote] How do I create "in game/original" flyin

Unread postby Jonas » 15 Jan 2009, 00:26

Hi everybody!

After years of playing H5 I've got in to the mapmaking buisiness - at last. With no programming skills at start but a quite usefull brain I have started to learn the script writing.

Q = where to find the file(s) in data.pak for the original flying signs (morale, luck, etc) you see when you touch a tattered flag for example?

I have been looking everywhere (I think) and there is nowhere to find any hint.

I'm currently using...

ShowFlyingSign(path.."morale2up.txt", heroName, PLAYER_1, 3);

... where the text file says "+2 morale", but it's a little bit boring with all these flying texts.

I also want to say thanks to franzy, rdeford, pitsu, and alot more people for making such great maps witch have inspired me to jump into the dark hole of scripting.

Maybe in a month or two I can get my first map up for testing. It will not be much fighting, more puzzling. I'm already up att over 500 lines of scripting in one month (first two weeks was just confusing).

Eh... and another thing. Does anyone know of any good examples of combat scripts - haven't got in to that thing yet.

/Jonas

User avatar
Kalah
Retired Admin
Retired Admin
Posts: 20078
Joined: 24 Nov 2005

Unread postby Kalah » 15 Jan 2009, 01:46

We would be delighted to help you test and publish your map when it's ready. See this page for instructions (in case you didn't already know) when the time comes. :)

I don't know much about H5 map making myself, I'm afraid... standing by for other members to jump in..
In War: Resolution, In Defeat: Defiance, In Victory: Magnanimity, In Peace: Goodwill.

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

Unread postby Franzy » 15 Jan 2009, 08:28

First of all, the game handles all special flying signs (+X to attack, morale, luck, resources, exp, etc) automatically, when you give the bonus to a hero. So, when you use command GiveHeroBattleBonus(heroName,COMBAT_BONUS_MORALE,2) the game will show the sign "+2 to morale" without additional effort from you. The same is true when giving hero skills, exp, spells. The only exception are creatures. The game CAN show creatures icons, but it does not :(
NB: if I am not mistaken, one guy from russian forum said he managed to force the game to show creature icons by adding heroname as another parameter in function like this:
GiveHeroCreatures('Zehir',1,1,'Zehir');
But I never tried this for myself, don't know if it really works.

Finally, messages with icons are protected methods, and can only be called by game procedures. They can not be called by user scripts, nothing can be done here unless Nival guys implement new script functions in future patches (if there will be any). So don't bother looking for those icons, you won't be able to use them in flying signs.

As for combat scripts, try map 'Ruins in the desert' or my map 'Mercenaries'. Some campaign maps also contain nice combat scripts.

User avatar
Jonas
Conscript
Conscript
Posts: 219
Joined: 14 Jan 2009

Unread postby Jonas » 15 Jan 2009, 23:46

Thanks for the answer Franzy!

Even though I can't recall that I saw anything come "flying" before I put my own command in, but i'll check again. And i will also try the line about add creatures you mentioned, just for fun.

(... as I went back to see what else you wrote I relized that I had used ChangeHeroStat instead of GiveHeroBattleBonus - ok, it makes sense)

[EDIT]
Ok, now I understand! I have to use both ChangeHeroStat (to change the stat) and GiveHeroBattleBonus (to make the flying "morale icon" to show). But I couldn't get GiveHeroBattleBonus to work with COMBAT_BONUS_MORALE, instead I had to use STAT_MORALE.
[END EDIT]

I've been looking alot at your Mercenaries-map, but this far only at the map-script - which is quite complex. Damn, it's hard to get a grip of tables. I've been reading the LUA documentation, but it gets a little bit abstract. Scripting is like math - you don't understand, you don't understand, you don't underst... eureka! Then everything seems very logic (when you understand) ;)

I guess I'll come back for more questions later on.

/Jonas
:leo: A man who carries a cat by the tail learns something he can learn in no other way.
Mark Twain

User avatar
Jonas
Conscript
Conscript
Posts: 219
Joined: 14 Jan 2009

Unread postby Jonas » 16 Jan 2009, 13:57

Franzy:
NB: if I am not mistaken, one guy from russian forum said he managed to force the game to show creature icons by adding heroname as another parameter in function like this:
GiveHeroCreatures('Zehir',1,1,'Zehir');
But I never tried this for myself, don't know if it really works.
There is no command like GiveHeroCreatures, but i've tried with both AddHeroCreatures and AddObjectCreatures (on hero) with no luck. It returns an error on the fourth parameter (heroName).
:leo: A man who carries a cat by the tail learns something he can learn in no other way.
Mark Twain

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

Unread postby Franzy » 20 Jan 2009, 08:29

Well, I wrote all commands from memory without looking at any references, and my memory is quite, hm, flimsy :) But I see you've made out what I meant :)

One note. If you use both ChangeHeroStat AND GiveHeroCombatBonus, hero will get double bonus - permanent one and temporary one (until next battle).

BTW, do you use 3.1 patch? Many commands were extended with the patch. As for flying icons, adding heroname as last parameter usually works.

For example, SetPlayerResource(PLAYER_1,ORE,GetPlayerResource(PLAYER_1,ORE)+5,Heroname) will show +5 ore icon flying off hero with Heroname name.

User avatar
Asheera
Round Table Knight
Round Table Knight
Posts: 4506
Joined: 06 Jul 2008
Location: The Shadows
Contact:

Unread postby Asheera » 20 Jan 2009, 13:06

Franzy wrote:Many commands were extended with the patch. As for flying icons, adding heroname as last parameter usually works.

For example, SetPlayerResource(PLAYER_1,ORE,GetPlayerResource(PLAYER_1,ORE)+5,Heroname) will show +5 ore icon flying off hero with Heroname name.
Didn't know that, thanks Franzy ;)

How do you discover those things anyway? It's pretty hard when they're not documented, you know :D (or does someone from Nival help you?)
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.

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

Unread postby Franzy » 20 Jan 2009, 13:24

The info is from largest russian gaming portal AG.ru forum. One guy from H5 dev team visits H5 Editor topic often and communicates easily. If you have any questions, feel free to ask, I'll redirect them to the guy.

User avatar
Asheera
Round Table Knight
Round Table Knight
Posts: 4506
Joined: 06 Jul 2008
Location: The Shadows
Contact:

Unread postby Asheera » 20 Jan 2009, 13:41

Well I have two questions. One is LUA related and the other regarding H5's scripting abilities.

Do functions work in tables? Something like:

Code: Select all

for i = 1, numDwellings do
  functions[i] = function(hero, dwelling)
    local player = GetObjectOwner(hero)

    -- do some other stuff
  end

  SetObjectEnabled("Dwelling"..i, nil)

  Trigger(OBJECT_TOUCH_TRIGGER, "Dwelling"..i, "functions["..i.."]")
end
Also are there any functions to retrieve the adventure map dwelling properties? Such as town ID, level, creature(s), etc.

Something like:

Code: Select all

GetAdvDwellingTownID(dwelling)
GetAdvDwellingLevel(dwelling)
GetAdvDwellingCreatures(dwelling)
If there aren't, I hope they will be introduced in a future patch version, if there will be any.
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.

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

Unread postby Franzy » 20 Jan 2009, 14:15

Well, I can answer this :)
I'm afraid, you can't define arrays of functions. Though you can define array of function names. Like this:

Code: Select all

qqq = {'qwerty','asdfgh','zxcvbn'}

function qwerty()
end;

function asdfgh()
end;

function zxcvbn()
end;

for i=1,3 do 
 Trigger(OBJECT_TOUCH_TRIGGER,'object'..i,qqq[i]);
As for dwellings routines, there are none :*( Because of object unification, I believe. There are functions only for town dwellings.

User avatar
Asheera
Round Table Knight
Round Table Knight
Posts: 4506
Joined: 06 Jul 2008
Location: The Shadows
Contact:

Unread postby Asheera » 20 Jan 2009, 14:28

Ok thanks anyway :)
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.

User avatar
Jonas
Conscript
Conscript
Posts: 219
Joined: 14 Jan 2009

Unread postby Jonas » 22 Jan 2009, 16:50

Franzy wrote: One note. If you use both ChangeHeroStat AND GiveHeroCombatBonus, hero will get double bonus - permanent one and temporary one (until next battle).

BTW, do you use 3.1 patch? Many commands were extended with the patch. As for flying icons, adding heroname as last parameter usually works.
Stupid question: does GiveHeroCombatBonus only "show" in battles, 'cause I didn't see it affect my stat like a tattered flag. But to be honest I haven't spent so much time looking in to it, I'm deep in the learning procedeure of scripting - thoose things has to come later on, when I start play-testing the map.

Yes, I have installed the patch and longing for another one. A wish-list for changes would be, this far:

* to make all objects movable - not only stones, trees etc (it can make a great effect by changing the z-value of a building and that would be nice to control in a script).

* And the stupid thing with: when you move an object like a rock or similar, the place where it was located is still unpassable - I hate it!

The past four days i've been playing around with scripting on my test-map and one thing that buggers me is, how to get multiple values like GetObjectPosition(hero/object) = x,y,z to load in a table (make the script do the work).

I have learned to use for i=n,nn do tablename = "objecttname"..i but that only works for one value. I have tried all kind of different approaches, with no luck. On one ocation I got close, putting the GetObjectPosition command in where the n are (for i=GetObjectPosition("name1"),GetObjectPosition("name10") do ... But that only stacked the same values (if the objects had the same x-value) at one index number.

I've read the LUA documentation and they have some examples when you need to store multiple values (ipairs, and something I don't remember right now) but it is a little bit to abstract for me to understand. If someone know something about this i would be pleased - but I need an explanation for all the parts so I can understand what I do (I don't like copy/paste).
:leo: A man who carries a cat by the tail learns something he can learn in no other way.
Mark Twain

User avatar
Asheera
Round Table Knight
Round Table Knight
Posts: 4506
Joined: 06 Jul 2008
Location: The Shadows
Contact:

Unread postby Asheera » 22 Jan 2009, 16:59

You can have a table inside a table inside a table ... etc

For example:

Code: Select all

A =
{
  X = {1, 2, 3},
  Y = {4, 5, 6},
  Z = {7, 8, 9}
}
To access the '5', just type A.Y[2]

Or alternatively you could write it as:

Code: Select all

A =
{
  [1] = {1, 2, 3},
  [2] = {4, 5, 6},
  [3] = {7, 8, 9}
}
And then to access the '8', just type A[3][2]


Just think of it like this: First you type the name of the table, A. Then what do you need to access from A? The third table, so write A[3]. Now you accessed the third sub-table from A, but you need its second value, so add [2], resulting in A[3][2].


Or did I say something completely different than your problem? Sorry if I didn't understand it correctly.
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.

User avatar
Jonas
Conscript
Conscript
Posts: 219
Joined: 14 Jan 2009

Unread postby Jonas » 22 Jan 2009, 18:25

I've learned that last night. :D But what I ment was, when you're using an empty table like "tablename = {}" you can use the "for"-function to fill it with information. That is what I want to do.

I have an 10x10 "minefield" with 100 chests covering all tiles and I just wanted to put the coordinates in a table - and not do it by hand. And the list is quite long, as you understand.

I gave up last night and did it anyway just to see if my idea of the "minefield" could work. I discovered the thing to pick information from a table inside a table when trying to get my formula to work - and it did!

Code: Select all

tilename = {};
tilepos = {{21,21,0},
	{22,21,0}, -- and so on up to 30,30,0 (room in forum)
for i=1,100 do
	tilename[i] = "t"..i;
end;	


function brickGameStart()
	ax,ay,az = GetObjectPosition(abas);
	for j=1,100 do
		
		if tilepos[j][1] == ax and tilepos[j][2] == ay-1 then
			SetObjectPosition(tilename[j], ax, (ay+1), az);
			break;
		end;	
	end;
end;
The idea is, when my hero approaches the first chest, the chest "jumps over his head" and sets behind him. Then my idea is to have a random calculator that randomly (obvious) puts a monster, a resource or an artifact in the space were the chest had been. But that's a later problem.

I uses enter and stop triggers, one for each row, but I wish that there was another way to trigger the function ( i don't want to use touch triggers).

Well I 'll come back later, 'cause a beautiful woman just called and wanted to have a beer with me at the pub - how could I resist!
:leo: A man who carries a cat by the tail learns something he can learn in no other way.
Mark Twain

User avatar
Asheera
Round Table Knight
Round Table Knight
Posts: 4506
Joined: 06 Jul 2008
Location: The Shadows
Contact:

Unread postby Asheera » 22 Jan 2009, 18:45

Hmm, so you want to fill tilepos automatically?

Code: Select all

for a=21, 30 do
  for b=21, 30 do
    tilepos[(a-21)*10 + b-20] = {a, b, 0}
  end
end
Is this what you want to do?
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.

User avatar
Jonas
Conscript
Conscript
Posts: 219
Joined: 14 Jan 2009

Unread postby Jonas » 22 Jan 2009, 21:19

Hmm, so you want to fill tilepos automatically?
Yes!

Your formula worked perfect in one way and in another not.

It gets all the coordinates correct to the table. But I'm using an index that starts from no 1 (the index numbers in 'tilename' and 'tilepos' has to be the same because the coordinates of the object indexnr is referring to the object name indexnr). Maybe there is something that I miss, that I have to adjust.

To be honest i have a couple of beers cruising around in my brain right now...

Can you please explain a bit what does what in your formula?

I understand that a=21,30 and b=21,30 is the x- and y-axis of the 10x10 square, but what happends then?

I know you are the "theory guy" in this forum and I think you have a lot to teach me in scripting theory. Maybe I shall get some sleep and take look at it tomorrow. But a big thanks.

Good night!
:leo: A man who carries a cat by the tail learns something he can learn in no other way.
Mark Twain

User avatar
Asheera
Round Table Knight
Round Table Knight
Posts: 4506
Joined: 06 Jul 2008
Location: The Shadows
Contact:

Unread postby Asheera » 22 Jan 2009, 22:01

What's the problem exactly? Because I can't find anything wrong...
Jonas wrote:Can you please explain a bit what does what in your formula?

I understand that a=21,30 and b=21,30 is the x- and y-axis of the 10x10 square, but what happends then?

I know you are the "theory guy" in this forum and I think you have a lot to teach me in scripting theory.
"Theory Gal" maybe :D

Ok it goes like this:

First you go through each column (y-axis) and then through each row (x-axis)

Then you'll have to find out a unique number (index) from that 'matrix' (composed of rows and columns)

Here's a short example to see how the matrix looks like (this one is 3x3), so you'll understand better:

Code: Select all

1 2 3
4 5 6
7 8 9
Let's take the 7th element (noted 7 there)

We have the following information: row 3, column 1

How can we find out the absolute index? (7 in our case)

Simple. Multiply the row index decreased by 1 by the size of one row, and add the column index to the result. Therefore, we do 3*2 + 1 = 7. I hope you see why, it's just some math.

And the only thing different in my formula there is that I had to adjust the numbers for the 21+ values instead of starting from 1. That's why there's an (a-21)*10 instead of (a-1)*10, and then a b-20. Now, I suppose you wonder why it's 20: because, actually, it should have been b-21 + 1 (because we start from 1, not 0), but that's an unnecessary operation so why not write it compactly b-20? :)
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.

User avatar
Jonas
Conscript
Conscript
Posts: 219
Joined: 14 Jan 2009

Unread postby Jonas » 22 Jan 2009, 23:05

Hi again!

Couldn't go to sleep before I got some understanding in the case.

I found out what the problem was. The result when I tested the formula it moved an object but it was the wrong one. Everything was turned 90 degrees clockwise, so I just swapped the a and b in

Code: Select all

tilepos[(b-21)*10 + a-20]
and it worked perfectly!

Thanks for the tremendous explanations, gal! ;)

You know, I've only been into this for a month and it was like 20 years ago since I studied math, but I'll learn more and more every day :proud:
:leo: A man who carries a cat by the tail learns something he can learn in no other way.
Mark Twain

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

Unread postby Franzy » 27 Jan 2009, 08:52

Yes, I have installed the patch and longing for another one. A wish-list for changes would be, this far:
Well, it seems there will never be a new OFFICIAL patch. As far as I know, all of the Homm5 team were either fired or transferred to other projects.

Maybe (MAYBE) in a year or two Nival will give the code to public and we will see UNOFFICIAL patches. Though this is highly unlikeble, as Nival never did this before with any of its previous games (and there were many).

Grim news :(

User avatar
Asheera
Round Table Knight
Round Table Knight
Posts: 4506
Joined: 06 Jul 2008
Location: The Shadows
Contact:

Unread postby Asheera » 27 Jan 2009, 13:19

Franzy wrote:Maybe (MAYBE) in a year or two Nival will give the code to public and we will see UNOFFICIAL patches. Though this is highly unlikeble, as Nival never did this before with any of its previous games (and there were many).
Can't Ubisoft force them? I mean, don't Ubisoft 'own' the source code as well?
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.


Return to “Mapmaking Guild”

Who is online

Users browsing this forum: No registered users and 0 guests