glitch in hidden and uncovered

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
vghetto
Posts: 166
Joined: November 2nd, 2019, 5:12 pm

glitch in hidden and uncovered

Post by vghetto »

Hi,

Some of the hides units are glitching on me when they attack. you can see them move from one hex to the next, but once they attack they are still invisible.
This is happening with units like Shadows and Elvish Avengers.
When it's my turn to attack them, I'm attacking and reacting to an invisible hex.
I checked the game inspector and the units status is uncovered=yes and hidden=yes.
I'm not sure what's causing it, is this a known bug and is there anyway around it?
this is 1.14.9

Edit:
For now I opted to do the following, I don't know if this would resolve it or not.

All unit creation with [unit] now include hidden=no.
And I threw in these 2 events for good measure.

Code: Select all

        [event]
                name=attack
                id=hidden_unit_bug1
                first_time_only=no

                [unhide_unit]
                        status=uncovered
                [/unhide_unit]
                [redraw]
                [/redraw]
        [/event]
        [event]
                name=side turn end
                id=hidden_unit_bug2
                first_time_only=no

                [unhide_unit]
                        status=uncovered
                [/unhide_unit]
                [redraw]
                [/redraw]
        [/event]
question: is the [redraw] necessary in this situation?

User avatar
beetlenaut
Developer
Posts: 2446
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: glitch in hidden and uncovered

Post by beetlenaut »

You have confused two different things. The "hidden" attribute has nothing to do with the [hides] ability. It just shows whether or not the unit is drawn on the map. If it has hidden=yes, all other units will interact with it in a normal way, but they will interact with a blank hex. That's what is controlled with [hide_unit] and [unhide_unit]. The [hides] ability and status=uncovered are not related. (They are controlled by filters in the unit's [abilities] tag.)
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide

vghetto
Posts: 166
Joined: November 2nd, 2019, 5:12 pm

Re: glitch in hidden and uncovered

Post by vghetto »

I am confused.
What could flip a hidden from no to a yes? I don't have any [hide_unit] tags in my code and yet it was set to yes for the shadow.

I'm uploading the save file with the problem, if anyone is interested in looking further in this.
The shadows occupy hex 31,33 and 30,31.
Is it meant that the shadow remain invisible even if I attack it or they attack me? Doesn't feel right. That is what is happening on my version of wesnoth.
Attachments
WF.gz
(294.89 KiB) Downloaded 26 times

User avatar
beetlenaut
Developer
Posts: 2446
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: glitch in hidden and uncovered

Post by beetlenaut »

vghetto wrote:
May 4th, 2020, 4:18 am
What could flip a hidden from no to a yes?
I don't know, and I don't really want to start taking guesses. I have had a lot of bugs that seemed impossible, but there was always an explanation in the end. If you upload your code, I would be happy to take a look at it (if someone else doesn't get to it first), but I'm not looking through 200,000 lines of a save file to try to reconstruct it and figure out what went wrong! The save file won't open in the game without your code, but it would be unlikely to tell me enough to solve the problem anyway.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide

vghetto
Posts: 166
Joined: November 2nd, 2019, 5:12 pm

Re: glitch in hidden and uncovered

Post by vghetto »

No worries, I managed to reproduce it with this altered version of WML_Guide.
An Elvish avenger is placed in the forest on the right, when he emerges he's invisible to me.

In the replay (well at least for me when I ran it on my version of wesnoth) every time the avenger walks, I can see him, when he stops or attacks I can't see him. When I attack him I'm attacking an invisible hex.
This looks like a wesnoth bug to me.

Edit: I've explicitly set hidden=no in the [unit] creation. The save file will show it is hidden=yes.

Edit2: Further testing shows that the hidden attribute is set to yes if the unit is placed in a forest tile. If you edit the map and change the location of spawning to Gg then it won't glitch. the spawn location is 20,5

Edit3: I ran the test again on Shadows, units that spawned during the night will glitch and remain invisible during the day. shadow units that spawned during the day won't glitch at night or when they ambush or attack.

Best solution I can come up with is this:

Code: Select all

        [event]
                name=turn end
                id=hidden_unit_bug1
                first_time_only=no

                [unhide_unit]
                [/unhide_unit]
        [/event]
doing that in unit_placed event didn't work for some reason.
Attachments
WMLG-Darth Syntax-Auto-Save3.gz
(10.26 KiB) Downloaded 25 times
WMLG-Darth Syntax replay.gz
(6.41 KiB) Downloaded 24 times
01_Darth_Syntax.map
(1.57 KiB) Downloaded 24 times
01_Darth_Syntax.cfg
(1.66 KiB) Downloaded 24 times

User avatar
beetlenaut
Developer
Posts: 2446
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: glitch in hidden and uncovered

Post by beetlenaut »

Okay, I figured it out. You can't set "hidden" equal to anything. Even "no" or "false" is a string of text, and any non-empty string will evaluate as "true" in the C code. You can't use WML to create an actual binary "false", which is what [unhide_unit] does internally. Just take out the "hidden=no", and everything will work fine. If you really want a unit to be invisible to the user, use the tag instead of messing with the value directly.

The only reason placing the avenger on a non-forest hex does show the unit is because you used "animate=yes". That action must clear the hidden value (which makes sense). In a forest hex, an enemy unit doesn't actually get animated, so the hidden value doesn't get reset.

Anyway, it's not a glitch.

(Also, note that during unit creation, you can use upkeep=loyal instead of creating an object. It saves you six lines.)

Edit: I added a note on the wiki that says you shouldn't change the "hidden" value manually.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide

User avatar
Pentarctagon
Project Manager
Posts: 4376
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: glitch in hidden and uncovered

Post by Pentarctagon »

#4889 should be closed, then?
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code

User avatar
beetlenaut
Developer
Posts: 2446
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: glitch in hidden and uncovered

Post by beetlenaut »

Well, the game could be modified so that changing the "hidden" value manually works the way the OP expected, but I think a note on the wiki is probably sufficient. I would say the bug can be closed.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide

vghetto
Posts: 166
Joined: November 2nd, 2019, 5:12 pm

Re: glitch in hidden and uncovered

Post by vghetto »

Well, thank you for taking the time to look at this.
I was having this issue before I included hidden=no. The only reason I started adding hidden=no was because I wanted to fix this glitch.
I'm attaching the update for Shadow without the hidden=no
Look at the units that spawn after turn 7.

Edit: turn 6 rather
What I got is a mix of invisible and not invisible shadows during the day, the one I encircled was invisible in my version.
Are you seeing the same thing I am, or do they render correctly on your version?

Edit2: I just tried it out but this time I commented out animate=yes. All units rendered correctly, non were invisible during the day. I guess the source of the bug is animate=yes.
Attachments
WMLG-Darth Syntax replay.gz
(8.72 KiB) Downloaded 25 times
WMLG-Darth Syntax-Auto-Save7.gz
(14.18 KiB) Downloaded 24 times
01_Darth_Syntax.map
(1.56 KiB) Downloaded 27 times
01_Darth_Syntax.cfg
(1.78 KiB) Downloaded 26 times

User avatar
beetlenaut
Developer
Posts: 2446
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: glitch in hidden and uncovered

Post by beetlenaut »

vghetto wrote:
May 4th, 2020, 7:14 pm
I guess the source of the bug is animate=yes.
Yeah, I just figured that out myself. You did find a bug. The combination that doesn't work is: unit with nightstalk, spawned at night, animate=yes.

I included a very small test case. Put the file in a new folder (the name doesn't matter) in your add-ons folder.

Select "Tester" from the top of the campaign menu, and just hit "End Turn" a few times. Turns alternates between day and night. Two units spawn each turn: a nightgaunt with animate=no, and a shadow with animate=yes. Shadows spawned at night never appear, though they are selectable and do fight.
Attachments
_main.cfg
(1.39 KiB) Downloaded 26 times
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide

vghetto
Posts: 166
Joined: November 2nd, 2019, 5:12 pm

Re: glitch in hidden and uncovered

Post by vghetto »

Yep, I'm expecting animate=yes with an Elvish Avenger, or a Wose with a forest hex will have the same problem.
The thing is I don't want to drop the animate=yes in Wild Frontiers because it looks nice when the group as a whole spawns at the edge of the map. The location, terrain and time of spawning is also random. So, I opted for using [unhide_unit] in the events name=start and name=turn end as a workaround for this problem. But, I do hope it gets fixed eventually in wesnoth itself.
Thank you for putting up with my ramblings.

Post Reply