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
beetlenaut
Developer
Posts: 2813
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: thinking about petrify

Post by beetlenaut »

Heindal wrote: November 14th, 2022, 7:44 pm wouldn't the counter for both just go up and up and up because the variable and individual variable for the unit?
I don't get what you mean because the only variable I am using is the internal unit variable, and there isn't a counter. Our ideas were pretty similar. (I considered using a foreach loop, which would have made the code even closer.) The internal variable is the biggest difference. Yours will work better if someone changes the turns manually during testing though.

I did think to test mine with multiple units getting frozen and unfrozen at different times, and it worked.
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 »

Thanks for the unit code. There's some advanced stuff in there.
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
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: thinking about petrify

Post by Helmet »

It originally wanted the frozen unit to stay frozen 2 turns, but I haven't been able to get beetlenaut's code to work.

So I went in a different direction. I tried to make it work with [switch] and a new status that I called halfway_thawed, but couldn't get that to work either.

So this is what the Frostbite monster's code looks like now...

Basically, the monster temporarily freezes opponents so they can't do anything for the rest of the turn. The frozen units automatically thaw at the beginning of the new turn, and floating text says, "thawed" (beetlenaut's idea). Temporarily freezing units into inaction is powerful, but I don't think it's over-powered. I think it's troublesome, like poison and slow.

Code: Select all

[event]
    name=new_turn
    first_time_only=no

    [floating_text]
        [filter]
            status=petrified
        [/filter]
        text= _ "thawed"
        color="0,127,255" {COLOR_HEAL}
    [/floating_text]
    [unpetrify]
        side=2
    [/unpetrify]
[/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
Ravana
Forum Moderator
Posts: 2933
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: thinking about petrify

Post by Ravana »

Sculpt works for 2 turns already and is easy to adjust turn_of_unstoning=$"($turn_number| + 2)".
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 15th, 2022, 8:45 am Sculpt works for 2 turns already and is easy to adjust turn_of_unstoning=$"($turn_number| + 2)".
I noticed that. The code seemed to be what I wanted: a powerful attack, but with a temporary effect. But I couldn't get it to work, even a little.

Right at the top, there isn't even an opening tag for [specials]. It looks like some of the code is missing.

History has indicated that I can't debug code that is too advanced, too clever or too convoluted. It either works right out of the box, or it doesn't. If I have to figure-out what lines are missing, like beetlenaut expected me to do, the code will remain non-functional.

Code: Select all

#define WEAPON_SPECIAL_AE_MAG_SCULPT
    # wmlxgettext: [attack]
    # wmlxgettext: [specials]
    [petrifies]
        id=sculpts
        name= _ "sculpts"
        description=_"This attack petrifies the target, turning it to stone for two turns. Units that have been petrified may not move or attack. When this effect wears off, the unit is slowed for 1 turn. Inactive in rpg."
        [filter_self]
            lua_function=wesnoth.wml_conditionals.AE_not_rpg
        [/filter_self]
    [/petrifies]
[/specials]
# wmlindent: start ignoring
[/attack]
# wmlindent: stop ignoring

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 »

It's a macro that's used in some of the unit definitions, for example in units/EoMa_units/Sky_Kingdom/Sculptor.cfg:

Code: Select all

    [attack]
        name=gaze
        description= _ "petrifyng spell"
        type=cold
        [specials]
            {WEAPON_SPECIAL_AE_MAG_SCULPT}
            {WEAPON_SPECIAL_MAGICAL}
        [/specials]
        damage=2
        number=2
        range=ranged
        icon=attacks/sculpt.png
    [/attack]
Sculpts wears off during a turn belonging to the unit that did the petrification, which means it can still be excessively overpowered in scenarios where the enemy has a few powerful hero units. An example would be Survival Extreme, where each player has a single superpowered hero - the hero gets petrified, misses their next turn, and then gets petrified again without being able to move at all (at least we caught that in alpha-testing :lol: ).
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 15th, 2022, 1:39 pm Sculpts wears off during a turn belonging to the unit that did the petrification, which means it can still be excessively overpowered in scenarios where the enemy has a few powerful hero units.
That makes sense. The more powerful the unit, the greater the impact of the unit not doing anything helpful on the battlefield. I've been play-testing almost entirely with peasants, ha ha.
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: 2933
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: thinking about petrify

Post by Ravana »

Code: Select all

        [filter_self]
            lua_function=wesnoth.wml_conditionals.AE_not_rpg
        [/filter_self]
Says that this ability should not be active in RPG era. If you do not create era with RPG support, then you can remove this filter. Otherwise I can tell more how it works.
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 15th, 2022, 5:03 pm

Code: Select all

        [filter_self]
            lua_function=wesnoth.wml_conditionals.AE_not_rpg
        [/filter_self]
Says that this ability should not be active in RPG era. If you do not create era with RPG support, then you can remove this filter. Otherwise I can tell more how it works.
Thank you, Ravana! Removing the [filter_self] code was the answer. The code works now.

I play-tested it a while. Wow, 2 turns is so much better than 1. And I like how the unit unpetrifies and moves, so it has the opportunity to run away or attack.

I thought it might be cool if the word "thawed" floated above the unit a moment before it unpetrifies. My code didn't work, though. I tried several different things. One mistake caused the word "thawed" to appear in every hex. :shock:

I suspect my filtering for x,y is the problem.

I wonder if the word "thawed" will overlap the 2 points of healing which appear above the unpetrified unit? That might not look good...
If it looks bad, could healing for the thawed unit be turned-off for that unit, for that turn only? I kinda doubt it.

Code: Select all

            [then]
                [floating_text]
                    x=$this_item.x|
                    y=$this_item.y|
                    text= _ "thawed"
                    color="0,127,255"
                [/floating_text]
                [unpetrify]
                    id=$sculpt_unit_information[$i].id
                [/unpetrify]

                {MODIFY_UNIT id=$sculpt_unit_information[$i].id status.slowed yes}
           
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
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: thinking about petrify

Post by Helmet »

Ravana wrote: November 15th, 2022, 5:03 pm

Code: Select all

        [filter_self]
            lua_function=wesnoth.wml_conditionals.AE_not_rpg
        [/filter_self]
Says that this ability should not be active in RPG era. If you do not create era with RPG support, then you can remove this filter. Otherwise I can tell more how it works.
Thank you, Ravana! Removing the [filter_self] code was the answer. The code works now.

I play-tested it a while. Wow, 2 turns is so much better than 1. And I like how the unit unpetrifies and moves, so it has the opportunity to run away or attack.

I thought it might be cool if the word "thawed" floated above the unit a moment before it unpetrifies. My code didn't work, though. I tried several different things. One mistake caused the word "thawed" to appear in every hex. :shock:

I suspect my filtering for x,y is the problem.

I wonder if the word "thawed" will overlap the 2 points of healing which appear above the unpetrified unit? That might not look good...
If it looks bad, could healing for the thawed unit be turned-off for that unit, for that turn only? I kinda doubt it, but thought I'd ask.

Code: Select all

            [then]
                [floating_text]
                    x=$this_item.x|
                    y=$this_item.y|
                    text= _ "thawed"
                    color="0,127,255"
                [/floating_text]
                [unpetrify]
                    id=$sculpt_unit_information[$i].id
                [/unpetrify]

                {MODIFY_UNIT id=$sculpt_unit_information[$i].id status.slowed yes}
           
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 15th, 2022, 6:13 pm My code didn't work, though.
There is no $this_item with the {FOREACH} macro. That's for the [foreach] tag. You should change this to the tag version because the macro version is going to be removed soon. The code $sculpt_unit_information[$i] is equivalent to $this_item. You might be able to just search and replace to change those, but you will have to look up the macro and the tag to see how they specify the array to use. (The macro is in core/macros/deprecated-utils.cfg.)

Edit: Forgot this.
Helmet wrote: November 15th, 2022, 6:13 pm could healing for the thawed unit be turned-off for that unit, for that turn only?
Maybe. Try turning the unit's "resting" key to "no" before the floating text happens.
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 15th, 2022, 6:26 pm...Try turning the unit's "resting" key to "no" before the floating text happens.
Thanks for helping. I looked in the deprecated code, and saw stuff about animated campfires and so forth. And I didn't find anything in the Wiki on resting=, so I don't know what to do with it. It's not a modify_unit key. I changed the x,y filter and it didn't do anything.

Code: Select all

            [then]
                [floating_text]
                    x=$this_item[$i].x|
                    y=$this_item[$i].y|
                    text= _ "thawed"
                    color="0,127,255"
                [/floating_text]
                [unpetrify]
                    id=$sculpt_unit_information[$i].id
                [/unpetrify]
                . . .
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: 2933
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: thinking about petrify

Post by Ravana »

You can store unit by id, and access its x and y after that. I also noticed that my code does not work, there needs to be {VARIABLE_OP i sub 1} after clear_variable. Otherwise every second unit will be unpetrified at later turn. clear_variable shifts indexes back by one, so currently 5 units take 3 turns to be all unpetrified.
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 15th, 2022, 7:22 pm You can store unit by id, and access its x and y after that.
Thanks. I tried a few variations, but none worked. This was the third...

Code: Select all

            [then]
                [store_unit]
                    [filter]
                        id=$unit.id
                    [/filter]
                    resting=no
                [/store_unit]
                [floating_text]
                    x=$unit.x
                    y=$unit.y
                    text= _ "thawed"
                    color="0,127,255"
                [/floating_text]
                [unpetrify]
                    id=$sculpt_unit_information[$i].id
                [/unpetrify]
                {MODIFY_UNIT id=$sculpt_unit_information[$i].id status.slowed yes}
Ravana wrote: November 15th, 2022, 7:22 pmI also noticed that my code does not work, there needs to be {VARIABLE_OP i sub 1} after clear_variable. Otherwise every second unit will be unpetrified at later turn. clear_variable shifts indexes back by one, so currently 5 units take 3 turns to be all unpetrified.
Uh oh.
Last edited by Helmet on November 15th, 2022, 7:36 pm, edited 1 time in total.
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: 2933
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: thinking about petrify

Post by Ravana »

id=$unit.id - who is $unit? Where you store it?
Post Reply