Submerge ability not working as expected

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
Spannerbag
Posts: 43
Joined: December 18th, 2016, 6:14 pm

Submerge ability not working as expected

Post by Spannerbag » September 25th, 2019, 3:13 pm

Hi everyone,
I'm stuck... again...

I've hit a bit of interface weirdness and would like to check I'm not doing something stupid.

In my scenario there are several water villages owned by an enemy side.
Originally these were guarded by hidden (ABILITY_SUBMERGE) units in deep water, but this (I guess) was responsible for a long delay at turn end (i.e. hidden units being processed by the ai).
So instead I thought I'd spawn them to see if that speeded things up (I haven't been able to confirm that supposition yet because of this issue sigh).

Gameplay logic
The first time one of these villages is captured by the player various things happen including creating hidden (ABILITY_SUBMERGE) guardian units (side=9) in surrounding deep water.
Also, these are controlled by a specific side=2 unit and when this unit is killed (required in victory conditions) any surviving side=9 units are unallied to side=2 (side=9 team_name is changed).
When the side=2 controlling unit is killed the guardians are created (if not already present). Any surviving side=9 guardians are "unguardianed".

So, there are 2 pathways to spawning the guardians (the actual spawn logic is a one-time event so multiple calls are OK):

1: First village capture
In this case the guardians are created after the player's unit completes movement. No matter which village is captured there will be at least one guardian adjacent. In this case there is no Ambushed! alert, but adjacent guardians are unhidden. This all works as expected.

2: Side=2 controller dies
In this case a last breath is used to create the guardians (if neccessary), unally sides 2 and 9, and "unguardian" the guardians.
With one exception, this all works. Here's the actual code:

Code: Select all

# Serpent controller death: serpents become independent
  [event]
    name=last breath
    [filter]
      id=serpent_controller
    [/filter]
    [filter_condition]		# Skip if all serpents killed
      [have_unit]
        side=9			# 1+ serpent alive
      [/have_unit]
      [or]
        [have_location]
          terrain=Wwg^Vm	# No liberated villages (serpents not yet created)
          count=5
        [/have_location]
      [/or]
    [/filter_condition]
    [modify_side]
      side=9
      team_name=Serpents	# Will now attack orcs
      [ai]
        aggression=0.8		# Much more aggressive
        [goal]
          [criteria]		# The serpents hate their erstwhile masters
            race=goblin,orc,wolf
          [/criteria]
          value=25
        [/goal]
      [/ai]
    [/modify_side]
    [fire_event]
      name=spawn_serpents	# Create guardian serpents if not yet created
    [/fire_event]
    [modify_unit]
      [filter]
        side=9
      [/filter]
      [status]
        guardian=no
      [/status]
    [/modify_unit]
    [message]
      speaker=unit
      message= _ "Aargh!  I cannot maintain control!  They are free!"
    [/message]
  [/event]
The issue is that after the above logic, if a side=1 unit encounters a hidden guardian they get an Ambushed! alert but the hidden unit remains hidden (even though the player's unit is adjacent to it!).

I have commented out both [modify_side] and [modify_unit] but this behaviour remains. I also moved the spawn event after [modify_side] and still no joy. Also tried [redraw] but again no change.

The only other consideration is that the player (side=1) has shroud=yes but the entire map is unshrouded in prestart and area in question is never subsequently shrouded. But did unshroud the area anyway, again to no effect :(

Code: Select all

# Setup initial conditions
  [event]
    name=prestart
...
#
# Unshroud everywhere
    [remove_shroud]
      side=1
      x=0-81
      y=0-61
    [/remove_shroud]

Finally, if a unit attacks the hidden (adjacent) unit the attack (side=1) unit the side=9 unit is still hidden and no animation or damage floating text is issued (i.e. still hidden or under shroud). I'm almost out of ideas. Am I missing something here?

If anyone wants a screen grab I have one (I don't have a suitable web server to host it on).
Basically it shows a unit next to a highlighted blank hex but the right hand panel gives details of the hidden unit.

Any suggestions, comments etc. would be greatly appreciated. (Keep telling yourself I'll finish it one day...)

Cheers!
UMC Campaign: After EI
I suspect the universe is simpler than we think and stranger than we can know.

Spannerbag
Posts: 43
Joined: December 18th, 2016, 6:14 pm

Re: Submerge ability not working as expected *** FIXED, dunno why ***

Post by Spannerbag » September 25th, 2019, 10:50 pm

Hi again,

Well, this is odd. I decided to go for consistency so, after creating all the side=9 units I unhid them all:

Code: Select all

# Create guardian serpents
# [unhide_unit] seems to fix units not unhiding if created via controller death?
  [event]
    name=spawn_serpents
    [unit]
      side=9
... units created here ...
    [/unit]
    [unhide_unit]
      side=9
    [/unhide_unit]
  [/event]
Now it works??? I'm happy that I've blundered into a fix but I'm b*gg*r*d if I know why!
It's almost as if these units have been doubly hidden - but it still works via village capture?
The units are in deep water so are hidden - even after [unhide_unit].
If anyone can explain to me wtf (that's why the..) this works, I'd be really interested to know.

Heh, a bit of luck for once :D
UMC Campaign: After EI
I suspect the universe is simpler than we think and stranger than we can know.

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

Re: Submerge ability not working as expected

Post by beetlenaut » September 27th, 2019, 12:29 am

The hide_unit tag doesn't change the game or the unit or its effects at all. It just stops the unit from being shown to the player. It has no relation to ambush abilities.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide

Spannerbag
Posts: 43
Joined: December 18th, 2016, 6:14 pm

Re: Submerge ability not working as expected

Post by Spannerbag » September 29th, 2019, 8:35 pm

Hi beetlenaut,
beetlenaut wrote:
September 27th, 2019, 12:29 am
The hide_unit tag doesn't change the game or the unit or its effects at all. It just stops the unit from being shown to the player. It has no relation to ambush abilities.
That's what I was (or rather wasn't) seeing: the units behaved as expected, they simply weren't visible, i.e. as per hide_unit (as fas as I can tell).
Mmm... maybe unhide_unit is doing what I hoped redraw might do and redraw/redisplay the units in question?

But you're quite right: what I tried to do wasn't sensible - but I was out of better ideas :-?

Anyhows, thanks for the info - appreciated!

Cheers!
UMC Campaign: After EI
I suspect the universe is simpler than we think and stranger than we can know.

User avatar
Celtic_Minstrel
Developer
Posts: 1529
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Submerge ability not working as expected

Post by Celtic_Minstrel » October 3rd, 2019, 4:34 am

If what you want to do is to hide a unit as if they were using an ambush ability, the following code should work:

Code: Select all

[modify_unit]
	hidden=yes
[/modify_unit]
And of course changing yes to no would reverse the effect.

This is wrong, see following posts.
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.

User avatar
josteph
Developer
Posts: 738
Joined: August 19th, 2017, 6:58 pm

Re: Submerge ability not working as expected

Post by josteph » October 3rd, 2019, 3:24 pm

Isn't that hidden something different? In the test scenario, the enemy Wose is ambushing but has hidden=no.

gfgtdf
Developer
Posts: 1190
Joined: February 10th, 2013, 2:25 pm

Re: Submerge ability not working as expected

Post by gfgtdf » October 3rd, 2019, 3:37 pm

yes hidden does something different. It was originally only made for animations during events.
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.

User avatar
Celtic_Minstrel
Developer
Posts: 1529
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Submerge ability not working as expected

Post by Celtic_Minstrel » October 4th, 2019, 12:24 am

Oh, the hidden key is [hide_unit], huh? If the goal is to make them not hidden despite being on a terrain that matches their stealth ability, then you can use uncovered=yes (it goes in a [status] tag, either in [unit] or [modify_unit]).

I guess there's no way to forcibly hide them on a terrain that doesn't match their stealth ability, though; to do that you'd need to actually add a new stealth ability that does match the terrain (like Heir to the Throne does to the orcs in one scenario).
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.

Spannerbag
Posts: 43
Joined: December 18th, 2016, 6:14 pm

Re: Submerge ability not working as expected

Post by Spannerbag » October 6th, 2019, 7:34 pm

Hi all,

Just a quick update: I eventually decided to go back to creating the hidden units at the start of the scenario (with status=guardian) rather than creating them later.

Creating them mid-scenario meant that the player would have no warning that the waterborne nasties were there. Now, it is nearly certain that at least some will be revealed by another ai side (also opposed to the waterborne nasties' side) well before the player has any chance to do so. But at least unit visibility works. (Yes, I could use team_name to prevent the ambush but then this causes other issues around village capture...)
Ah well, it's supposed to be an easy-ish scenario...

A second reason for the creation at scenario start was to see if this had any effect on the looong pause after all ai sides have finished movement and combat but before turn end (the waterborne nasties are the last side to be processed).
Sadly it made no difference - it may well be that my laptop is somewhat underpowered to cope swiftly with the 9 turn end events, all with [filter_condition] and quite a few with first_time_only=no.

I've not extensively tested the gameplay in the later stages of this scenario yet but perhaps when some of the first_time_only=yes turn end events have fired the delay will reduce?
When I eventually finish this epic then if other people encounter the same issue I'll look into it further.

Cheers!
UMC Campaign: After EI
I suspect the universe is simpler than we think and stranger than we can know.

Post Reply