[H4 Editor] Bug with placed events

Maps and the art of mapmaking.

Moderator: Moderators

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 549
Joined: 21 Jul 2014

[H4 Editor] Bug with placed events

Postby iLiVeInAbOx05 » Oct 2 2014, 14:46

Has anyone noticed a bug with placed events and editing the scripts associated with them?

So I've been working on scripting for random battles, and to do them I need to place a LOT of placed events, covering the area where the random battles can happen.

I've noticed a problem with the editor where it seems to attach the same script to a placed event twice, sometimes three times, and I haven't quite figured out what the bug causing this is so that I can avoid it.

I'm wondering if it has something to do with putting a placed event on the ground, setting its properties to the battle script, and then putting the placed event back on the palette to be used again. It seems like if I modify, or even open, the script again, that the old script isn't removed and now there are two of (almost) the same scripts attached to a single placed event. When stepping on the event, both are triggered simultaneously, which causes extremely odd behaviour in game.

Anyone seen this bug before / know exactly what causes it? I plan to create a test map this weekend and really figure this out, but any other knowledge would be appreciated.

User avatar
Duzeom_
Conscript
Conscript
Posts: 234
Joined: 07 Mar 2011

Postby Duzeom_ » Oct 3 2014, 17:14

Is there one event in the current square?

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 549
Joined: 21 Jul 2014

Postby iLiVeInAbOx05 » Oct 3 2014, 19:10

Duzeom_ wrote:Is there one event in the current square?


Yep. I realize I mentioned before about placing more than one placed event in the same space to do some initialization, but that was for something other than the random chance battles.

This particular problem has me extremely confused and I am confident it's a bug in the editor. I just need to figure out exactly how to reproduce it so that I can avoid it.

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 549
Joined: 21 Jul 2014

Postby iLiVeInAbOx05 » Oct 4 2014, 1:08

After a little bit of testing today I was able to reproduce this bug.

What I learned: If you have a placed event script that calls a triggerable event script, you should avoid using a display message within that triggered script and only call the display message from the placed event sequence itself.

It seems like the display message within the triggered event doesn't stop all of the subsequent steps in your scripts from waiting until you click the check box to proceed, so some things seem to happen twice, once before you click the check box on the display message event, and once after.

I ended up having two, sometimes three combats called when there was only one combat in the script. Possibly a threading issue!

User avatar
Duzeom_
Conscript
Conscript
Posts: 234
Joined: 07 Mar 2011

Postby Duzeom_ » Oct 4 2014, 8:49

I have never encounter such behaviour. Could you send a test map?

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 549
Joined: 21 Jul 2014

Postby iLiVeInAbOx05 » Oct 4 2014, 15:12

Hi Duzeom, sent you a pm.

User avatar
Duzeom_
Conscript
Conscript
Posts: 234
Joined: 07 Mar 2011

Postby Duzeom_ » Oct 4 2014, 16:48

Ok I tested it and as far as I can see - and probably you noticed it also - message command is bugged, because it doesn't stop movement of your hero on the map. So when the message triggers - your hero is basicaly still moving and can trigger few next placed events. Solution is to erase these text messages, or lower the probability of battle.

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 549
Joined: 21 Jul 2014

Postby iLiVeInAbOx05 » Oct 4 2014, 17:34

Duzeom_ wrote:Ok I tested it and as far as I can see - and probably you noticed it also - message command is bugged, because it doesn't stop movement of your hero on the map. So when the message triggers - your hero is basicaly still moving and can trigger few next placed events. Solution is to erase these text messages, or lower the probability of battle.


Right, your hero keeps moving, BUT, the number of steps he takes before you click the display message check box has no bearing on how many times the following scripts are triggered.

I've let me hero take 5+ steps after the script triggered, and only ended up with one extra battle. I've had my hero take one step before clicking the check box, and had two extra battles trigger.

The probability of a battle doesn't get reset until AFTER a combat, which means each successive step should trigger the combat scripts to run again, but that doesn't seem to be what is happening.

Also, if you put the display message script in the random battle placed event, it works exactly as it should. The hero stops, and after you click the check box the battle starts.

It almost seems like the event calling the triggered script doesn't wait for it to return, which would result in one extra battle (the previous returned level int, and then the new one after the script returns), but I had 3 combats triggering when I tested it today.

So I still think the best solution is to not use display message events in triggered scripts called from placed events.

User avatar
Duzeom_
Conscript
Conscript
Posts: 234
Joined: 07 Mar 2011

Postby Duzeom_ » Oct 5 2014, 16:14

You should write test with simpler script - for example a triggered script would only add 1 t oa number and print message, or so. This way it would be easier to debug it. Now it is too complacated to debug it - because Heroes scripts are hard to understand in the editor.

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 549
Joined: 21 Jul 2014

Postby iLiVeInAbOx05 » Oct 6 2014, 16:52

Duzeom_ wrote:You should write test with simpler script - for example a triggered script would only add 1 t oa number and print message, or so. This way it would be easier to debug it. Now it is too complacated to debug it - because Heroes scripts are hard to understand in the editor.


Good idea. I'll try testing placed events that call a triggered script which only prints a message and go from there.

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 549
Joined: 21 Jul 2014

Postby iLiVeInAbOx05 » Oct 8 2014, 4:27

Okay, so I created a triggered script which only displayed a message, and called the script in a couple different places. I even called the script at the beginning of my placed event.

The results were the same: When the hero walks over the placed event, the text displays, but the hero keeps walking.

Don't know if it is a bug in the editor itself or in the way the game handles placed events which call triggered scripts, but either way the lesson is:

Do not use display events in a triggered script if that script is going to be called by a placed event.

User avatar
Karmakeld
CH Staff
CH Staff
Posts: 1084
Joined: 12 Nov 2011

Postby Karmakeld » Oct 9 2014, 19:49

if you move your text to your hero/town/army instead of map properties, it will stop the hero.
I now remember having encountered the same issue years ago.
But you can use my suggested work around. just make sure it's placed on something the player owns, (= no dead heroes/armies or lost town(s)).
Last edited by Anonymous on Oct 13 2014, 19:52, edited 1 time in total.
I'm silent in seven languages - and I got all my familys fear.
Everytime you throw dirt, you loose a little ground

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 549
Joined: 21 Jul 2014

Postby iLiVeInAbOx05 » Oct 10 2014, 2:51

Oh okay I'll have to give that a test, too :D

The only reason I ran into this bug was because I was trying to put some debug messages into one of my random battle scripts which is just a triggered script.

I can't think of a reason that the display message event would have to be in a triggered script when dealing with placed events. It can just as easily go in the placed event script.


Return to “Mapmaking Guild”

Who is online

Users browsing this forum: No registered users and 3 guests