[H5 EDITOR] Troubleshooting topic

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

Unread postby Franzy » 28 Nov 2010, 21:44

Cannot change hero class by script.

bkknight2602
Pixie
Pixie
Posts: 100
Joined: 23 May 2010
Location: Texas

Unread postby bkknight2602 » 28 Nov 2010, 22:53

lol
I don't want to change it, just have code determine which type it is. :)

bkknight2602
Pixie
Pixie
Posts: 100
Joined: 23 May 2010
Location: Texas

Unread postby bkknight2602 » 02 Dec 2010, 16:36

A new puzzling problem. I have written some code with the gracious help of Franzy.
The problem that I am having is that the code DOES NOT WORK on one specfic hero, Findan, on one specific map(Amontillado). I spent several hours trying debug on my desk top, since I am unable to access the console on this lap top. The time was not well spent, as I entered the code with Findan on another map and THE CODE WORKS.
I then added another hero to the Amontillado map and ran the code again. Similar results, nothing altered with Findan, but the newly added hero was successfully altered.
Now why is Findan able to be altered one one map but not anther?

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

Unread postby Franzy » 02 Dec 2010, 20:38

You use the same code? Copy-paste? Maybe it's just a misprint.

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

Unread postby Franzy » 02 Dec 2010, 20:40

As for determining hero class (sorry I misunderstood that as defining) not sure if there a function for that, but you can always check if the hero in question has a class skill (i.e. necromancy for necromancers, counterstrike for knights etc)

bkknight2602
Pixie
Pixie
Posts: 100
Joined: 23 May 2010
Location: Texas

Unread postby bkknight2602 » 02 Dec 2010, 23:59

Maybe I wasn't clear, but the code worked on ALL other heroes except Findan. The code worked on Findan on other maps, just not this one. Well I didn't solve the problem, but was able to get the code to work on Findan by making Findan as a town garrison hero instead of a field object.

I knew you would figure out the answer to my other question, checing the primary skill should work.

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

Unread postby Franzy » 03 Dec 2010, 18:24

Well, dunno... I once had similar problems with Kha-Beleh, but I always thought it's because hyphenated name. Probably a strange-glitch-by-Nival-that-wil-never-be-corrected-or-even-understood.

bkknight2602
Pixie
Pixie
Posts: 100
Joined: 23 May 2010
Location: Texas

Unread postby bkknight2602 » 06 Dec 2010, 16:36

New question:
I have some code to execute when a town is captured

function towncapture(oldowner, newowner, herotowncapture)
print("Enter town capture funtion");
if GetCurrentPlayer() == numhumanplayer then
print(oldowner);
print(newowner);
print(herotowncapture);
GiveArtefact(herotowncapture, artefactID);
print("Leave town capture function");
end;
end;
Trigger(OBJECT_CAPTURE_TRIGGER, "townname", "towncapture");

The print statements "help" me through the debugging. Using the GetObjectOwner("townname"); before and after the town is captured indicates in this case 0 and 1---so the townname is captured. However, NONE of the print statements appear in the console. It seems like the function never activated.

The documentation indicates that:

One or more parameters can follow the even type, determining, the events of which of the ingame
objects have to be handled. The number and meaning of these parameters depend on the
even type:
for OBJECT_CAPTURE_TRIGGER and OBJECT_TOUCH_TRIGGER--the on-map object’s name

When the trigger works, the following parameters are sent to the handler function:
OBJECT_CAPTURE_TRIGGER--the old owner of the object, the new owner of the object, the name
of the hero who captured it (if any), and the name of the object itself

Any suggestins?

bkknight2602
Pixie
Pixie
Posts: 100
Joined: 23 May 2010
Location: Texas

Unread postby bkknight2602 » 06 Dec 2010, 19:18

bkknight2602 wrote:New question:
I have some code to execute when a town is captured

function towncapture(oldowner, newowner, herotowncapture)
print("Enter town capture funtion");
if GetCurrentPlayer() == numhumanplayer then
print(oldowner);
print(newowner);
print(herotowncapture);
GiveArtefact(herotowncapture, artefactID);
print("Leave town capture function");
end;
end;
Trigger(OBJECT_CAPTURE_TRIGGER, "townname", "towncapture");

The print statements "help" me through the debugging. Using the GetObjectOwner("townname"); before and after the town is captured indicates in this case 0 and 1---so the townname is captured. However, NONE of the print statements appear in the console. It seems like the function never activated.

The documentation indicates that:

One or more parameters can follow the even type, determining, the events of which of the ingame
objects have to be handled. The number and meaning of these parameters depend on the
even type:
for OBJECT_CAPTURE_TRIGGER and OBJECT_TOUCH_TRIGGER--the on-map object’s name

When the trigger works, the following parameters are sent to the handler function:
OBJECT_CAPTURE_TRIGGER--the old owner of the object, the new owner of the object, the name
of the hero who captured it (if any), and the name of the object itself

Any suggestins?
I tried and succeded with an object other than a town--in this case a military fortress
function towncapture(oldowner, newowner, herotowncapture)
print("Enter town capture funtion");--Printed this time
if GetCurrentPlayer() == numhumanplayer then
print(oldowner);--Printed Nil (On a second attempt deleted oldowner parameter and function was entered but not executed properly)
print(newowner);--Printed 1
print(herotowncapture);--Printed Mardigo
GiveArtefact(herotowncapture, artefactID);--Artefact given to Mardigo
print("Leave town capture function");--Printed this time
end;
end;
Trigger(OBJECT_CAPTURE_TRIGGER, "havenfortress", "towncapture");

So the function does work, just not on a town.
Any other suggestions?

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

Unread postby Franzy » 06 Dec 2010, 21:19

The trigger works with town alright, problem is elsewhere. You see, when a hero captures the town he automatically enters it. And when a hero enters a town, he is removed from the map and the list of currect objects. So you can not enteract with him, that's why giving him an artifact doesn't work :). You need to find a workaround :)

bkknight2602
Pixie
Pixie
Posts: 100
Joined: 23 May 2010
Location: Texas

Unread postby bkknight2602 » 07 Dec 2010, 02:44

Well perhaps another Ubisoft glitch, as I continued the map and lo behold, the code worked on all towns, except two. I rechecked the names and spellings were correct, so I'm not sure what happened.

I thought about another piece of code and stumped for the time being:
HeroName = "True";
function deployhero()
for i = 0 to length(playernames) - 1 do
if GetPlayerStat(playernames, STAT_EXPERIENCE) >= 15000 then
GetObjectPosition(playernames);
if HeroName == "True" then
DeployReserveHero("Orrin", --I want to deploy 3 squares north and 3 squares east of playernames
HeroName = "False";
end;
end;
end;
end;

I tried putting x + 3, y + 3, z after the name:
DeployReserveHero("Orrin",x + 3, y + 3, z);
The thought woud be the handler would have the position as an x, y, z from the GetObjectPosition
That didn't work and the error message "trying to perform arithmetic on a Nil value".
Any thoughts on how to access the handlers "position" and use it in the DeployReserveHero function?

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

Unread postby Franzy » 07 Dec 2010, 05:38

First of all, turn back a page - I told you what the problem is with towns.
Second of all, you missed something here. You call x,y and z... but what are they? They should be placed here:

x,y,z = GetObjectPosition(playernames);

bkknight2602
Pixie
Pixie
Posts: 100
Joined: 23 May 2010
Location: Texas

Unread postby bkknight2602 » 07 Dec 2010, 13:02

Ah that worked, thanks.

The code worked in all but two towns on this particular map, giving the artefact after defeating the previous owner.

ZanBon
Leprechaun
Leprechaun
Posts: 17
Joined: 23 Jun 2008

Town turning to ruins

Unread postby ZanBon » 17 Dec 2010, 11:24

Hello,

working on my 3rd map I want to change a town into town ruins after its defeat.I'm sure I've seen it in some map but can't remember which one.

I suppose it is a scripting function but I suck when it comes down to that.
I also suppose it could be somewhere among the 40 pages of that thread, I tried looking, but failed miserably. :)

So any help would be great, thank you. :)

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

Unread postby Franzy » 18 Dec 2010, 09:08

The function called TransformTown.

bkknight2602
Pixie
Pixie
Posts: 100
Joined: 23 May 2010
Location: Texas

Random town code

Unread postby bkknight2602 » 31 Oct 2011, 22:17

Is there a way to code adding respective creatures to random towns(ie peasant to random generated Haven, familiar to to a random generated Inferno etc)? I have done this with specific towns but random???

meows
Peasant
Peasant
Posts: 75
Joined: 11 Oct 2006

Re: Random town code

Unread postby meows » 01 Nov 2011, 17:22

bkknight2602 wrote:Is there a way to code adding respective creatures to random towns(ie peasant to random generated Haven, familiar to to a random generated Inferno etc)? I have done this with specific towns but random???
Just use the custom Town name I believe.. I could be wrong though

bkknight2602
Pixie
Pixie
Posts: 100
Joined: 23 May 2010
Location: Texas

Re: Random town code

Unread postby bkknight2602 » 03 Nov 2011, 00:29

meows wrote:
bkknight2602 wrote:Is there a way to code adding respective creatures to random towns(ie peasant to random generated Haven, familiar to to a random generated Inferno etc)? I have done this with specific towns but random???
Just use the custom Town name I believe.. I could be wrong though
Thanks but that doesn't work.

bkknight2602
Pixie
Pixie
Posts: 100
Joined: 23 May 2010
Location: Texas

Another coding issue

Unread postby bkknight2602 » 03 Nov 2011, 00:29

Ok, here is another coding issue.
I have some code relating to a TRIGGER_OBJECT_TOUCH and it can be visited many times, the code works great, but I want to write into the code that any hero may only visit it once per week (like a stable or fountain).
playernames = GetPlayerHeroes(numhumanplayer);--numhumanpalyer is the player number of the human
if mod(GetDate(DAY),7) == 0 then
for i = 0, length(playernames) do
herotouch(playernames) = false
end;
end;---To clear a visit flag
function object_touched(herotouch)
--Do some things
herotouch(heroname) = true--To add a visit flag
end;
Trigger(OBJECT_TOUCH_TRIGGER, "object_touched", "message_box_object_touched");
This does not work, I get an error last read "="--In the for loop expected ";"

Any ideas?

bkknight2602
Pixie
Pixie
Posts: 100
Joined: 23 May 2010
Location: Texas

New coding question

Unread postby bkknight2602 » 29 Jul 2012, 12:54

I have a map in which the player has several faction choices, as with most games. I tried to tweak the game a bit by selecting a certain town and using the fllowing code (piece) to transform the town to the selected faction and then to transfer ownership to the selected faction. Here are the bits that are pertainent.
numhumanplayer = GetCurrentPlayer();
if numhumanplayer == 1 then
TransformTown("Town1", 5);
elseif numhumanplayer == 2 then
TransformTown("Town1", 0);
elseif numhumanplayer == 3 then
TransformTown("Town1", 1);
elseif numhumanplayer == 4 then
TransformTown("Town1", 6);
elseif numhumanplayer == 5 then TransformTown("Town1", 2);
elseif numhumanplayer == 6 then
TransformTown("Town1", 7);
elseif numhumanplayer ==7 then
TransformTown("Town1", 3);
SetObjectOwner("Town1", 7);
elseif numhumanplayer == 8 then
TransformTown("Town1", 4);
end;

I'm currently playing player 7, so that is why the code is more complete in that block. The question pertains to the set owner statement. The town is transformed but the code does not shift ownership. I tried it on some other towns(without transforming them) and that worked. So why does the set owner not work on the transformed town?


Return to “Mapmaking Guild”

Who is online

Users browsing this forum: No registered users and 1 guest