elemental arise developement

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
zakariore
Posts: 2
Joined: September 26th, 2019, 7:11 am

elemental arise developement

Post by zakariore »

Hello, i creation a new faction with a lot elemental and i would like to do them fuse like air element + fire element = electric elemental.

but i dont know how, maybe sombody can help me, i want to make that with a trait who will do:

1- check the adjacent title and if:
- there is an units with the same side and with is xp bar at 50% or more

2- show the panel with the fusion and check the require units af the fusion:
- if the units fit with a fuse, light the possible fuse

and when the fuse is check , "kill" them and pop the new units.

if someone has a tip or a way to do it, i would like to know.

thank you

User avatar
Pentarctagon
Forum Administrator
Posts: 4243
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: elemental arise developement

Post by Pentarctagon »

Moved to the WML Workshop.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code

Shiki
Developer
Posts: 289
Joined: July 13th, 2015, 9:53 pm
Location: Germany

Re: elemental arise developement

Post by Shiki »

That's not too easy. The Wesnoth way of doing that is to let the unit advance.

One can do almost anything in Wesnoth, but it usually ends in getting nothing else done, as you are too busy creating something nonstandard.
Writing a panel is something of the advanced things, a trait by itself can only change very basic things.
Here's something which is similar to what you described (using units from mainline):

Code: Select all

    [event]
        name=moveto
        first_time_only=no

        [filter]
            id=$unit.id
            type=Peasant
            formula=" self.experience > self.max_experience / 2 "
            [filter_adjacent]
                side=$unit.side
                type=Mage
                formula=" self.experience > self.max_experience / 2 "
            [/filter_adjacent]

            # or the other way around
            [or] 
                id=$unit.id
                type=Mage
                formula=" self.experience > self.max_experience / 2 "
                [filter_adjacent]
                    side=$unit.side
                    type=Peasant
                    formula=" self.experience > self.max_experience / 2 "
                [/filter_adjacent]
            [/or]
        [/filter]

        # Experience can not be checked directly in a [filter]
        # [filter_wml] can check it though.
        # However, [filter_wml]  can only check if it is equal to some value.
        # Not whether it's samler or greater than a value.
        # (i.e. whether it's the half of max_experience)
        # Thus using the formula to check for experience.

        # The "unit" variable is managed by the engine and will be cleared, saving for later.
        {VARIABLE fusion.x $unit.x}
        {VARIABLE fusion.y $unit.y}                    

        # We know the location of one unit involved, and
        # that another unit of the other type is next to it.
        # But there can be more than one … what then, which to take?
        # (I have seen code which removes then all :-p)
        
        # In this example: Letting the player choose
        # 1st unit was chosen by moving the unit
        # 2nd unit is chosen by right-click (and also, whether to fuse at all)


        [set_menu_item]
            id=fusion
            description= _ "Fusion with $unit.language_name on $fusion.x,$fusion.y"
            #image= …

            # Note: x1 & y1 are the location where the player right-clicked.
            [show_if]
                [have_unit]
                    x=$x1
                    y=$y1
                    side=$side_number
                    type=Peasant
                    formula=" self.experience > self.max_experience / 2 "
                    [filter_adjacent]
                        x=$fusion.x
                        y=$fusion.y
                        side=$side_number
                        type=Mage
                        formula=" self.experience > self.max_experience / 2 "
                    [/filter_adjacent]

                    # or the other way around
                    [or] 
                        x=$x1
                        y=$y1
                        side=$side_number
                        type=Mage
                        formula=" self.experience > self.max_experience / 2 "
                        [filter_adjacent]
                            x=$fusion.x
                            y=$fusion.y
                            side=$side_number
                            type=Peasant
                            formula=" self.experience > self.max_experience / 2 "
                        [/filter_adjacent]
                    [/or]
                [/have_unit]
            [/show_if]
            
            [command]
                # do here the fusion
                [kill]
                    x=$fusion.x
                    y=$fusion.y
                [/kill]

                [modify_unit]
                    [filter]
                        x=$x1
                        y=$y1
                    [/filter]

                    type=Young Ogre
                    attacks_left=0
                    moves=0
                [/modify_unit]

                [clear_menu_item]
                    id=fusion
                [/clear_menu_item]
                {CLEAR_VARIABLE fusion}
            [/command]
        [/set_menu_item]

        # To not block undoing.
        # This should not cause OutOfSync errors.
        # But it may – undoing is tricky.
        [on_undo]
            [clear_menu_item]
                id=fusion
            [/clear_menu_item]
            {CLEAR_VARIABLE fusion}
        [/on_undo]

        [allow_undo][/allow_undo]
    [/event]

    # Clean up, in case fusion was not used.
    [event]
        name=scenario end,side turn end
        first_time_only=no

        [clear_menu_item]
            id=fusion
        [/clear_menu_item]
        {CLEAR_VARIABLE fusion}
    [/event]
Now you know where Ogres come from :eng:
That got quite some code though. If you want things like that, better learn Lua instead of WML. It's better suited for "doing stuff". Even more so if you want a panel or things which you didn't see somewhere else yet.

PS: Do you know the existing elemental factions? That are mostly the ones listed here.

zakariore
Posts: 2
Joined: September 26th, 2019, 7:11 am

Re: elemental arise developement

Post by zakariore »

Thank you for the reply,

Now i have an idea of how to do and i know how the ogres from :lol:

i know the elemental faction of ageless era but my faction has some differences like the fusion and other trait i make.

Post Reply