Spawning main heroes

Maps and the art of mapmaking.
Franzy
War Dancer
War Dancer
Posts: 362
Joined: 07 Sep 2007
Location: Moscow, Russia
Contact:

Unread postby Franzy » 02 Sep 2010, 18:37

Of course. Why else would it be here?

tofiffe
Peasant
Peasant
Posts: 93
Joined: 21 Mar 2010

Unread postby tofiffe » 04 Sep 2010, 07:01

ok then what is it?

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

Unread postby Franzy » 05 Sep 2010, 07:13

Are you kidding? Open the manual. There are several sections there. Advanture map functions, combat functions, functions added in the addons.

Browse the combat section, it's right there:

GetHeroName.

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

Unread postby Franzy » 05 Sep 2010, 07:15

Also, start reading function descriptions :) IsHuman is not applicable to heroes, it's applicable to side. Which can be either attacker or defender.

tofiffe
Peasant
Peasant
Posts: 93
Joined: 21 Mar 2010

Unread postby tofiffe » 05 Sep 2010, 08:29

sry then...i'm so bored of reading :P
ok i fixed the code, but now the spell is casted, but the opponents creatures aren't poisoned at all...


and btw, i wanted to make a function that teaches heroes new spells every day, but it seems that some numbers are invalid...for example:16, 22, 47 don't exist. is there any other way to teach a hero all the spells he is able to learn in current state? it's realy annoying to have to restart the script and add if i~=(number) and i~=(another number)...

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

Unread postby Franzy » 05 Sep 2010, 19:29

Sure. The code in a thread is executed separately, so if it terminates with an error it does not affect the whole script. So, to teach a hero all the spells you can write:

function teachspell(hero,spell)
TeachHeroSpell(hero,spell);
end;

for i=1,100 do --don't remeber number of spells actually
startThread('teachspell','Ohtarig',i)
end;

tofiffe
Peasant
Peasant
Posts: 93
Joined: 21 Mar 2010

Unread postby tofiffe » 06 Sep 2010, 13:55

ok, the wrong spell id's still show up, but the spells are learned anyway :D
now for some reason, the hero gets all the spells in existance, even if he has no skill for that magic school.

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

Unread postby Franzy » 06 Sep 2010, 19:41

Probably you oughtta check if a hero has appropriate skill... No way to do it easily, at least I don't know one.

tofiffe
Peasant
Peasant
Posts: 93
Joined: 21 Mar 2010

Unread postby tofiffe » 07 Sep 2010, 17:13

so for every spell whether hero has the school or not? that's a lot of work...

PS: what is the function for a loop?

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

Unread postby Franzy » 07 Sep 2010, 18:21

for i=x,y do ... end
while ... do ... end

tofiffe
Peasant
Peasant
Posts: 93
Joined: 21 Mar 2010

Unread postby tofiffe » 08 Sep 2010, 13:59

nope, not like that..i mean that the action would be repeating all the time...

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

Unread postby Franzy » 08 Sep 2010, 18:29

You mean every second or every turn?

For every second (not recommended, the will lag) use separate thread with infinite loop inside:

function myfunc()
while not nil do
--do something
sleep(20);
end;
end;

startThread(myfunc);

For every turn, use new day trigger.

tofiffe
Peasant
Peasant
Posts: 93
Joined: 21 Mar 2010

Unread postby tofiffe » 09 Sep 2010, 13:56

ok thanks :)

what about the objects people place on the map that look just like buildings in towns? any idea how to do that?

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

Unread postby Franzy » 09 Sep 2010, 19:02

Yes. You create your own objects. Copy an existing pne then change it anyway you want icluding its appearance. It was explained million times how to do that in this forum, search it.

tofiffe
Peasant
Peasant
Posts: 93
Joined: 21 Mar 2010

Unread postby tofiffe » 10 Sep 2010, 18:00

pne? what is that?

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

Unread postby Franzy » 10 Sep 2010, 19:19

existing one.

tofiffe
Peasant
Peasant
Posts: 93
Joined: 21 Mar 2010

Unread postby tofiffe » 11 Sep 2010, 07:35

i somehow don't get it...

i know you click on new on the advmapsharedm but then what?

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

Unread postby Franzy » 12 Sep 2010, 14:14

Not new. This way all the fields are blank. Copy (ctrl C) and paste (ctrl V). Then change what ever you need.

tofiffe
Peasant
Peasant
Posts: 93
Joined: 21 Mar 2010

Unread postby tofiffe » 12 Sep 2010, 16:21

still don't get it...copy from other maps? or what?

is there a written tutorial for this?
[EDIT]: and for searching on the forums...i actualy don't have a clue what this could be named...

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

Unread postby Franzy » 12 Sep 2010, 17:59

No, you copy any existing object that have similar properties that you would like your object to have. All the maps have common base of standard object, no need for another map hence.

Try searching 'new object' or 'adding object'


Return to “Mapmaking Guild”

Who is online

Users browsing this forum: No registered users and 7 guests