thinking about petrify

The place to post your WML questions and answers.

Moderator: Forum Moderators

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.
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

thinking about petrify

Post by Helmet »

I was toying with the idea of making a unit that kinda petrifies. I'm working on a faction of snow monsters called snowgolems. I have seven types so far, all level 1 and with sprites. I was thinking it might be cool to add an eighth type that freezes an enemy unit solid. "Petrified" only means one thing, though: turned to stone. It doesn't mean frozen solid. So I would have to create a new status called "frozen."

What are your thoughts on petrify? Is it too powerful? I've never played with a unit that petrifies before, or fought against one (unless I forgot). But it seems pretty powerful.

I like the idea of a unit freezing solid, though. And I could pretty much copy the code for petrify. Thoughts? Do you like petrify?

If a unit was frozen solid, should there be a way to un-freeze them? How could it be done, exactly?

If an enemy Leader was frozen solid, would the scenario be un-winnable, because the Leader can't be killed?

Thanks for your input.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
octalot
General Code Maintainer
Posts: 777
Joined: July 17th, 2010, 7:40 pm
Location: Austria

Re: thinking about petrify

Post by octalot »

What in gameplay terms would be the difference between petrify and this new status? If it's just flavor-text, do you really need the new status?

Note that petrify is partially implemented in the engine's C++ code, complete with an extra color for HP bars in the attack predictions window, and code for ending the fight early. There's a lot more scope for writing abilities in WML now than there were when the petrify ability was added (which seems to be in version 0.6.99.2), and it's certainly possible to interrupt the fight early in WML now, but the extra color can't be done in WML.
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: thinking about petrify

Post by Helmet »

octalot wrote: November 13th, 2022, 9:17 pm What in gameplay terms would be the difference between petrify and this new status? If it's just flavor-text, do you really need the new status?

Note that petrify is partially implemented in the engine's C++ code, complete with an extra color for HP bars in the attack predictions window, and code for ending the fight early. There's a lot more scope for writing abilities in WML now than there were when the petrify ability was added (which seems to be in version 0.6.99.2), and it's certainly possible to interrupt the fight early in WML now, but the extra color can't be done in WML.
Thanks for the input. I've been tinkering with petrify and I wasn't able to change it to freeze after all. Your post confirms my suspicions: petrify is hard-coded and not a macro, so changing it would be an epic undertaking.

To answer your question, I wanted to change the status for flavor-text purposes only. That's it.

So I'm now thinking I'll use petrify, as is. Who knows, maybe people in Wesnoth use the word "petrified" to describe people turned to stone and people turned to ice. :)

I've been play-testing my new unit with the petrify attack. The petrified units actually appear frozen; it's awesome. Is there a way to make all petrified units slightly blue, though? It's not a big deal, but if it's easy, I'll do it.

For example, in a swamp-based scenario I made, I used this code to make the color of a Giant Mudcrawler appear more swampy.

Code: Select all

            [modifications]
				[object]
					[effect]
						apply_to=image_mod
						add="BLEND(30,180,250,10%)"
					[/effect]
				[/object]
	     [/modifications]
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
Ravana
Forum Moderator
Posts: 2934
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: thinking about petrify

Post by Ravana »

As one hit kill its obviously too powerful. Different abilities limit it by duration or by petrifying both attacker and defender.
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: thinking about petrify

Post by Helmet »

Ravana wrote: November 13th, 2022, 11:17 pm As one hit kill its obviously too powerful. Different abilities limit it by duration or by petrifying both attacker and defender.
I like the idea of the petrify status lasting only 1 turn. Plus, it would make sense, if petrify also represented being frozen. It would be as if a unit got itself frozen in battle, but then thawed.

I found an event from long ago, from the BSH Era (Beyond Southern Hells), that might contain some of the code I'd need to put a time limit on petrify, but I'm not sure how to extract it. There's a lot of code to consider. By the way, I don't know the name of the BSH unit or who wrote the code. This is all that I found in my Dropbox account when I did a search for petrify.

How could petrify be modified to last 1 turn?

Code: Select all

# BSH 
# stoned units slowly lose whatever energy sustains their 'life' unless helped by a healer, healers can restore them, 
# and if they're present when it's back to full the stoning wears off
[event]
  name=side turn
  first_time_only=no
[store_unit]
  [filter]
  side=$side_number
    [filter_wml]
      [status]
        petrified=yes
      [/status]
    [/filter_wml]
  [/filter]
  variable=stoneds
[/store_unit]
{FOREACH stoneds i}
[if]
  [have_unit]
          x,y=$stoneds[$i].x,$stoneds[$i].y
    [filter_adjacent]
      #lets be nice like zookeper proposed and let allies do it too
      #side=$stoneds[$i].side
      is_enemy=no
      [filter_wml]
        [abilities]
          [heals]
            value=8
          [/heals]
        [/abilities]
     [/filter_wml]
     #alternative to allow above 8, but not below
     #[not][filter_wml][abilities][heals]value=1[/heals][/abilities][/filter_wml][/not][/and]
     #[and][not][filter_wml][abilities][heals]value=2[/heals][/abilities][/filter_wml][/not][/and]
     #[and][not][filter_wml][abilities][heals]value=3[/heals][/abilities][/filter_wml][/not][/and]
     #[and][not][filter_wml][abilities][heals]value=4[/heals][/abilities][/filter_wml][/not][/and]
     #[and][not][filter_wml][abilities][heals]value=5[/heals][/abilities][/filter_wml][/not][/and]
     #[and][not][filter_wml][abilities][heals]value=6[/heals][/abilities][/filter_wml][/not][/and]
     #[and][not][filter_wml][abilities][heals]value=7[/heals][/abilities][/filter_wml][/not][/and]
    [/filter_adjacent]
  [/have_unit]
[then]
#unpetrify if health is full and we're healed
#if it's not ful heal it
  [if]
    [variable]
      name=stoneds[$i].hitpoints
      greater_than_equal_to=$stoneds[$i].max_hitpoints
    [/variable]
    [then]
      [unpetrify]
        x,y=$stoneds[$i].x,$stoneds[$i].y
      [/unpetrify]
    [/then]
    [else]
    {VARIABLE_OP stoneds[$i].hitpoints add 8}
    #dont heal over the max
    [if]
    [variable]
      name=stoneds[$i].hitpoints
      greater_than=$stoneds[$i].max_hitpoints
    [/variable]
      [then]
        {VARIABLE stoneds[$i].hitpoints $stoneds[$i].max_hitpoints}
      [/then]
    [/if]
      [unstore_unit]
    variable=stoneds[$i]
    text="8"
    green=128
    [/unstore_unit]
    [/else]
  [/if]
[/then]
[else]
  {VARIABLE_OP stoneds[$i].hitpoints add -4}
  [unstore_unit]
    variable=stoneds[$i]
    text="-4"
    red=128
    green=128
    blue=128
  [/unstore_unit]
  [if]
    [variable]
    name=stoneds[$i].hitpoints
    less_than_equal_to=0
    [/variable]
    [then]
    [kill]
    x,y=$stoneds[$i].x,$stoneds[$i].y
    animate=yes
    fire_event=yes
    [/kill]
    [/then]
  [/if]

[/else]
[/if]
  {NEXT i}
  {CLEAR_VARIABLE stoneds} 
[/event]

Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
beetlenaut
Developer
Posts: 2813
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: thinking about petrify

Post by beetlenaut »

Helmet wrote: November 13th, 2022, 10:14 pm I wasn't able to change it to freeze after all...changing it would be an epic undertaking.
Can't you use a weapon special called "freeze," and an event that petrifies the unit if it gets hit by it? I think the only other place "petrify" would show up would be in the status icon's tool tip (which I'm pretty sure you can't change from within a scenario no matter how epic you are). However, if you use some floating cyan text that tells the player what happened, I doubt most of them would bother checking the tool tip in the first place.
Helmet wrote: November 13th, 2022, 10:14 pm Is there a way to make all petrified units slightly blue, though?
You showed how to do this. Just put it in an attack_end event, and use the color shift object if the unit or second_unit has a petrified status. Remove the object when you unpetrify.
Helmet wrote: November 13th, 2022, 11:46 pm How could petrify be modified to last 1 turn?
You could have a turn_refresh event that uses [unpetrify] on all the units that have that status. Or you could use [modify_unit][effect] to remove the status manually. You could also use an internal unit variable that counts up each turn and only removes the status if two or three turns have gone by. Or you could use the same kind of variable to store the turn on which the status will disappear. (If you want a more powerful freeze attack, that is.) There are lots of options, so I'm not sure what difficulty you are having. I also don't see how the posted code is relevant in any way.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: thinking about petrify

Post by Helmet »

beetlenaut wrote: November 14th, 2022, 5:25 am There are lots of options, so I'm not sure what difficulty you are having.
I suppose the difficulty lies in having, as you said, "lots of options," including not using petrify at all, but not knowing which one is best for my snowgolem faction. And so I asked for people's thoughts on petrify. A lot of people on the forum have invented new units, after all.

Ravana mentioned petrify was over-powered and suggested making it time-limited. I think that's a good idea.

I like your idea of making a weapon special called "freeze."
beetlenaut wrote: November 14th, 2022, 5:25 am I also don't see how the posted code is relevant in any way.
Well, this part dealt with ending unpetrify...

Code: Select all

[unpetrify]
        x,y=$stoneds[$i].x,$stoneds[$i].y
[/unpetrify]
I suspect that somebody already made a version of petrify that automatically expires in a turn or two. If anybody knows of such a code, could you post it? My spare time just decreased a lot, and I'd like to spend it on animating the attack of an angry snowman, not writing code for my "frostbite" unit that has little to no probability of working.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
Lord-Knightmare
Discord Moderator
Posts: 2337
Joined: May 24th, 2010, 5:26 pm
Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
Contact:

Re: thinking about petrify

Post by Lord-Knightmare »

What are your thoughts on petrify? Is it too powerful? I've never played with a unit that petrifies before, or fought against one (unless I forgot). But it seems pretty powerful.

I like the idea of a unit freezing solid, though. And I could pretty much copy the code for petrify. Thoughts? Do you like petrify?

If a unit was frozen solid, should there be a way to un-freeze them? How could it be done, exactly?

If an enemy Leader was frozen solid, would the scenario be un-winnable, because the Leader can't be killed?
1. Petrify (unless accompanied with some unpetrify event), is arguably very significant. Petrifying a unit renders them unattackable. So petrified enemy leaders cannot be killed, petrified heroes cannot be killed. Petrified side leader cannot be killed. In Scenarios, it's very rare and mostly eventWML/plot related.

2. You need a refreshing event. Try checking IftU S22.

3. Yes, unless you have any alternate win condition, the scenario will be unwinnable.


Also, if you want to investigate frozen. There is a UMC which has it. Sojournings of Grog (excuse, my typos if any).
So I'm now thinking I'll use petrify, as is. Who knows, maybe people in Wesnoth use the word "petrified" to describe people turned to stone and people turned to ice.
Actually, it was called "Stoned" before. But you can see why it had to be renamed... :P
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: thinking about petrify

Post by Helmet »

Lord-Knightmare wrote: November 14th, 2022, 2:13 pm Also, if you want to investigate frozen. There is a UMC which has it. Sojournings of Grog...
Thanks for all the helpful information.

I've always wanted to play Sojournings of Grog, but was dissuaded by the huge number of scenarios (21), as I often reach a scenario that I can't get past and become stuck. But after you mentioned SoG, I downloaded the campaign and started it, just to see what it was like. Boy, I could tell right away this is a good campaign. Sometimes you just know within minutes.

Before I started it, I was thinking, "I bet Grog will start the campaign as a Troll Whelp, even though that wouldn't make sense."

NOPE. 8)
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
beetlenaut
Developer
Posts: 2813
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: thinking about petrify

Post by beetlenaut »

Helmet wrote: November 14th, 2022, 2:12 pm I suspect that somebody already made a version of petrify that automatically expires in a turn or two. If anybody knows of such a code, could you post it? My spare time just decreased a lot, and I'd like to spend it on animating the attack of an angry snowman, not writing code for my "frostbite" unit that has little to no probability of working.
I, on the other hand, am off for a couple days, so I have some free time.

Code: Select all

[event]
    name=prestart
    [set_menu_item]
        id=freeze
        description= _ "Freeze"
        [command]
        
            # Logic code
            [petrify]
                x,y=$x1,$y1
            [/petrify]
            [modify_unit]
                [filter] 
                    x,y=$x1,$y1
                [/filter]
                [set_variable]
                    name="thaw_on_turn"
                    value="$($turn_number + 2)"  # 2 can be other values
                [/set_variable]
                
                # Interface code
                [object]
                    id=freeze_color_shift
                    [effect]
                        apply_to=image_mod
                        replace="CS(0,127,255,30%)"
                    [/effect]
                [/object]
            [/modify_unit]
            [floating_text]
                # For correct translations to be possible, this adjective actually
                # needs to be gendered. See UtBS dehydration utils for examples.
                x,y=$x1,$y1
                text= _ "frozen"
                color="0,127,255"
            [/floating_text]
        [/command]
    [/set_menu_item]
[/event]

#define WML_FILTER
    [filter_wml]
        [variables]
            thaw_on_turn=$turn_number
        [/variables]
    [/filter_wml]
#enddef

[event]
    name=turn_refresh
    first_time_only=no
    
    # Logic code
    [unpetrify]
        {WML_FILTER}
    [/unpetrify]
    [modify_unit]
        [filter]
            {WML_FILTER}
        [/filter]
        [clear_variable]
            name=thaw_on_turn
        [/clear_variable]
    [/modify_unit]
    
    # Interface code
    [floating_text]
        [filter]
            {WML_FILTER}
        [/filter]
        text= _ "thawed"
        {COLOR_HEAL}
    [/floating_text]
    [remove_object]
        # Look at the cautionary note for [remove_object] on the wiki.
        {WML_FILTER}
        object_id=freeze_color_shift
    [/remove_object]
[/event]
The logic for this is pretty simple. Making stuff show up on the screen is the longer part. It turns out that image shifting doesn't work right because petrified units are grayscaled by the engine. (I left it in because it still makes the image look more like ice than rock.) You would have to write your own version of petrify to change that. I don't have that much free time. Obviously, you would put this in a weapon special instead of a menu item, but I will leave that up to you.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: thinking about petrify

Post by Helmet »

beetlenaut wrote: November 14th, 2022, 5:44 pm...I, on the other hand, am off for a couple days, so I have some free time.
Thank you!
beetlenaut wrote: November 14th, 2022, 5:44 pm The logic for this is pretty simple. Making stuff show up on the screen is the longer part. It turns out that image shifting doesn't work right because petrified units are grayscaled by the engine. (I left it in because it still makes the image look more like ice than rock.) You would have to write your own version of petrify to change that. I don't have that much free time. Obviously, you would put this in a weapon special instead of a menu item, but I will leave that up to you.
For the most part, the code works, but there's a bug or two.

When my Frostbite unit (the unit with the freeze WEAPON_SPECIAL) hits an enemy unit and petrifies him, the text rising from the unit says "petrify" instead of "freeze." But if I right-click on a unit and select "freeze" from the menu, the unit will petrify and the text will say "freeze."

I'm guessing you added the right-click menu option for play-testing purposes?

Units that get "frozen" through combat do not thaw 2 turns later; however, units that were frozen via the right-click menu will thaw 2 turns later.

There's an odd thing happening, too. It seems like a unit that has thawed will have the color-change applied a second time, so they change from slightly blue-gray, which looks nice, to extremely blue -- which looks a little too blue.

Also, the color change doesn't revert to normal. The thawed unit remains frozen-looking after it resumes running around the map. :)

This was only my second WEAPON_SPECIAL, so maybe I did something wrong. I'm including it, just in case. I placed it in the macro folder, near the WML_FILTER you wrote.

Code: Select all

#define WEAPON_SPECIAL_FREEZE_TYPE TYPE
    [petrifies]
        id=freeze # ({TYPE})
        name= _ "freeze"
        description= _ "This attack encases an opponent within a layer of ice."
        type={TYPE}
    [/petrifies]
#enddef

#define WML_FILTER
    [filter_wml]
        [variables]
            thaw_on_turn=$turn_number
        [/variables]
    [/filter_wml]
#enddef
Thanks again for your help. By far, these were the most interesting wml bugs I've ever seen. :)
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
beetlenaut
Developer
Posts: 2813
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: thinking about petrify

Post by beetlenaut »

I have to admit that I didn't test it very thoroughly, so there may be bugs. However, the problems you are describing come from the fact that the weapon special petrifies the unit a second time. Please look at the code I wrote and make sure you understand what it's doing.

You will need a dummy special and an attacker_hits event that runs the code in the menu item. (Which is for testing.) You may want to use a separate defender_hits event too, but I'm pretty sure you could combine them. If you put event(s) in the [unit_type], they will automatically be copied into the scenario when one of those units enters the map.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: thinking about petrify

Post by Helmet »

Okay. I can probably fix it. :shock:

Fortunately, it's easier to de-bug code that doesn't produce this phrase: "Scenario failed to load."
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
Heindal
Posts: 1343
Joined: August 11th, 2011, 9:25 pm
Location: Germany, Karlsruhe
Contact:

Re: thinking about petrify

Post by Heindal »

I wonder about this code. Wouldn't thaw_on_turn be just useful when you have single unit? If a new unit would be attached with frozen, wouldn't the counter for both just go up and up and up because the variable and individual variable for the unit?

For my frozen state, I'm just using "new turn" to check if my units get unfrozen (by chance) and use a dummy-ability for that.
This works fine and for all units individually.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
Post Reply