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 » 27 Jul 2010, 04:14

What exactly you want to achieve?

tofiffe
Peasant
Peasant
Posts: 93
Joined: 21 Mar 2010

Unread postby tofiffe » 27 Jul 2010, 09:25

that the script checks what faction does the player have, then every day it ads a number of creatures, depending on hero faction and day number.

and on day 1 it moves player 3 hero to a location and when he dies, next hero is moved to the location.

the script has 524 lines, it'd be hard to write all of it in here, i can send it on your PM if you want.

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

Unread postby Franzy » 27 Jul 2010, 17:37

Ok, here how it works with hero remove on an example:

Trigger(PLAYER_REMOVE_HERO_TRIGGER,PLAYER_2,"player2losehero");

function player2losehero(fallen,killer)


if (fallen=="Sufi") and (killer==hero) then
----
end;

if (fallen=="Biara") then
------
end;


end;

tofiffe
Peasant
Peasant
Posts: 93
Joined: 21 Mar 2010

Unread postby tofiffe » 28 Jul 2010, 09:23

ok, but the function doesn't get triggered on day 2 by new_day_trigger, so any heroes would be on reach of others.

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

Unread postby Franzy » 28 Jul 2010, 17:23

What?

tofiffe
Peasant
Peasant
Posts: 93
Joined: 21 Mar 2010

Unread postby tofiffe » 29 Jul 2010, 09:47

i got 2 triggers for it, one is the new day trigger, then the trigger is disabled, so only the player remove hero trigger works.

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

Unread postby Franzy » 29 Jul 2010, 17:06

So what is the problem?

tofiffe
Peasant
Peasant
Posts: 93
Joined: 21 Mar 2010

Unread postby tofiffe » 30 Jul 2010, 09:13

the new day trigger doesn't trigger it.

the function was supposed to teleport the ai hero to surface, where the other heroes are. that would be the only way to kill one of ai heroes that the hero remove trigger would start to work...

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

Unread postby Franzy » 30 Jul 2010, 18:10

When you start the game, open game console. That's where all the errors are reported. You'll even have the line number :)

tofiffe
Peasant
Peasant
Posts: 93
Joined: 21 Mar 2010

Unread postby tofiffe » 31 Jul 2010, 16:29

i know, but the script is executed without errors, that's why i don't know what's wrong..

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

Unread postby Franzy » 31 Jul 2010, 20:41

The hero you talk about is by chance Kha-Beleh?

tofiffe
Peasant
Peasant
Posts: 93
Joined: 21 Mar 2010

Unread postby tofiffe » 01 Aug 2010, 12:11

nope, all the player_3 heroes are all dwarves, and heroes from player 1 and two are not the campaign ones...i realy tried it all, but nothing seems to work...

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

Unread postby Franzy » 01 Aug 2010, 15:57

Post your code here or pm it to me. I the parts concerning the problem.

tofiffe
Peasant
Peasant
Posts: 93
Joined: 21 Mar 2010

Unread postby tofiffe » 02 Aug 2010, 09:36

ok i seem to have found the problem:
startThread("assault");
but it doesn't start the function, explanation:
Warning! StartThread first parameter must be a function.

i renamed the function already, still the same. Now what the hell is wrong here? The first and only parameter _IS_ a function...but it won't start...i tried removing the quotes, but nothing happened. same warning, the script gets executed, the creatures are added, but only what should be started for first time by this startThread does not execute.

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

Unread postby Franzy » 02 Aug 2010, 19:59

No "!

Like this

startThread(assault)

tofiffe
Peasant
Peasant
Posts: 93
Joined: 21 Mar 2010

Unread postby tofiffe » 03 Aug 2010, 06:40

well i tried this already, but it says the same...

script error! value was nil when getting global with name assault!
warning: StartThread first parameter must be a function.

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

Unread postby Franzy » 03 Aug 2010, 17:24

Post function assault heading.

tofiffe
Peasant
Peasant
Posts: 93
Joined: 21 Mar 2010

Unread postby tofiffe » 04 Aug 2010, 11:08

function assault()
if IsHeroAlive("Bersy") then
SetObjectPosition( "Bersy",60, 54, 0 );
MoveHero( "Bersy", 12, 23, 0 );
elseif IsHeroAlive("Ottar") then
for i=1,7 do
LevelUpHero(c);
end;
SetObjectPosition( "Ottar",60, 54, 0, 0 );
MoveHero( "Ottar", 12, 23, 0 );
elseif IsHeroAlive("Una") then
for i=2,7 do
LevelUpHero(c);
end;
SetObjectPosition( "Una",60, 54, 0, 0 );
MoveHero( "Una", 12, 23, 0 );
elseif IsHeroAlive("Ingvar") then
for i=3,7 do
LevelUpHero(c);
end;
SetObjectPosition( "Ingvar",60, 54, 0, 0);
MoveHero( "Ingvar", 12, 23, 0 );
elseif IsHeroAlive("Skeggy") then
for i=4,7 do
LevelUpHero(c);
end;
SetObjectPosition( "Skeggy",60, 54, 0, 0 );
MoveHero( "Skeggy", 12, 23, 0 );
elseif IsHeroAlive("Brand") then
for i=5,7 do
LevelUpHero(c);
end;
SetObjectPosition( "Brand",60, 54, 0, 0 );
MoveHero( "Brand", 12, 23, 0 );
elseif IsHeroAlive("Vegeyr") then
for i=6,7 do
LevelUpHero(c);
end;
SetObjectPosition( "Vegeyr",60, 54, 0, 0 );
MoveHero( "Vegeyr", 12, 23, 0 );
elseif IsHeroAlive("Egil") then
LevelUpHero(c[7]);
SetObjectPosition( "Egil",60, 54, 0, 0 );
MoveHero( "Egil", 12, 23, 0 );
else
WinTeam(TEAM_2 );
end;
end;


and why do i now get an error: wrong type argument 1 when calling funciton ChangeHeroStat? I don't even use that in my whole script...i only added a few lines, the script still has an error if i remove them...

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

Unread postby Franzy » 04 Aug 2010, 18:47

Function LevelUpHero() is just a wrapper for changeherostat function, and what you give it is not a heroname obviously.

Also ANYTIME you intend to do something to anobject you just moved or created (in your case) you HAVE TO place sleep(1) between these two. Like this:

SetObjectPosition( "Brand",60, 54, 0, 0 );
sleep(1);
MoveHero( "Brand", 12, 23, 0 );

tofiffe
Peasant
Peasant
Posts: 93
Joined: 21 Mar 2010

Unread postby tofiffe » 07 Aug 2010, 07:09

thanks, i'll try this...

what does the sleep number actualy do?

EDIT: i found the problem...if there is no player two, the GiveHeroExp(b[0], 20200); can't work and the script is not executed...i'll add If IsHeroAlive(b[0]); to prevent this...but the b[0] is wrong argument, why? i use the b=GetPlayerHeroes(PLAYER_3); before it...


Return to “Mapmaking Guild”

Who is online

Users browsing this forum: No registered users and 4 guests