new campaign's questions and ideas

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
ChrundleTheGreat
Posts: 84
Joined: May 3rd, 2023, 1:25 am
Location: The land of chapaqueños

new campaign's questions and ideas

Post by ChrundleTheGreat »

hi everybody!! :)
im working on a new short, yet complicated campaign to teach myself more complex wml stuff:
  • the campaign its only two scenarios long
  • the campaign uses no amlas
  • the campaign follows the story of a mage
  • he recruits small lvl one one "orbs",
  • the orbs are recruited using xp and not gold
  • the mage has very high maximum xp, (9999 or so)
  • all xp goes to the mage, whether the enemy unit is killed by the mage or the orbs
  • not the mage nor the orbs lvl up
  • orbs have weak attacks and are not very durable, but have zone of control
  • each orb can be used (one time only) as a spell,
  • the orb then dies.
  • this spells can be:
    • fireball: an strong area attack.
    • freeze: a medium area attack that slows down enemies
    • healing: it heals 8 points to any nearby units
    (maybe ill add more later...)
id like your advice on how i could begin with this, :) .
if you think its a good/bad idea or you have suggestions i would apreciate the feedback.
anything really is appreciated...
thanks y'all!
--chrundle
User avatar
ChrundleTheGreat
Posts: 84
Joined: May 3rd, 2023, 1:25 am
Location: The land of chapaqueños

Re: new campaign's questions and ideas

Post by ChrundleTheGreat »

oh and the story takes place on a labyrinth, for anyone who's interested...
its a bit inspired by harry potter...
User avatar
Ravana
Forum Moderator
Posts: 3189
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: new campaign's questions and ideas

Post by Ravana »

Start by creating unit types.
User avatar
ChrundleTheGreat
Posts: 84
Joined: May 3rd, 2023, 1:25 am
Location: The land of chapaqueños

Re: new campaign's questions and ideas

Post by ChrundleTheGreat »

Ravana wrote: May 11th, 2024, 9:19 pm Start by creating unit types.
i made a unit for the orbs (Emperor zombie knight helped), it works well enough although it waits until a second attack is made in order to transfer xp to my mage unit...

Code: Select all

#textdomain wesnoth-wmlg

[unit_type]
    id=magic_orb
    name= _ "magic_orb"
    race=mechanical
    hitpoints=30
    movement=6
    experience=100
    {AMLA_DEFAULT}
    level=1
    cost=10
    alignment=neutral
    advances_to=null
    movement_type=smallfly
    usage=archer
    image="units/orb.png"
  


    
    [attack]
        name=beam
        description=_ "beam"
        icon="attacks/beam-sky-1.png"
        type=pierce
        range=ranged
		[specials]
            {WEAPON_SPECIAL_MAGICAL}
        [/specials]
        damage=4
        number=6
		movement_used=0
    [/attack]
    

	[event]
		name=attack end
		[filter]
			side = 1
			[not]
			id=tommas
			[/not]
			[/filter]
			{VARIABLE xp_transfer $unit.experience}
			[modify_unit]
			[filter]
			id=$unit.id
			[/filter]
			experience=0
			[/modify_unit]
			[modify_unit]
			[filter]
			id=tommas
			[/filter]
			[effect]
			apply_to=experience
			increase=$xp_transfer
			[/effect]
			[/modify_unit]
			first_time_only=no
	[/event]
	[event]
			name=attack end
			first_time_only=no
			[filter_second]
				side = 1
				[not]
				id=tommas
				[/not]
				[/filter_second]
				{VARIABLE xp_transfer $second_unit.experience}
				[modify_unit]
				[filter]
				id=$second_unit.id
				[/filter]
				experience=0
				[/modify_unit]
				[modify_unit]
				[filter]
				id=tommas
				[/filter]
				[effect]
				apply_to=experience
				increase=$xp_transfer
				[/effect]
				[/modify_unit]
		[/event]
[/unit_type]
User avatar
ChrundleTheGreat
Posts: 84
Joined: May 3rd, 2023, 1:25 am
Location: The land of chapaqueños

Re: new campaign's questions and ideas

Post by ChrundleTheGreat »

im also facing the main next two issues; i want to recruit with xp, not gold, and i want a menu for transforming orbs into spells...
any ideas?
User avatar
Ravana
Forum Moderator
Posts: 3189
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: new campaign's questions and ideas

Post by Ravana »

You could update gold to be equal to xp. If you recruit, reduce xp. If you fight, increase gold.
white_haired_uncle
Posts: 1444
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: new campaign's questions and ideas

Post by white_haired_uncle »

ChrundleTheGreat wrote: May 15th, 2024, 7:21 pm
i made a unit for the orbs (Emperor zombie knight helped), it works well enough although it waits until a second attack is made in order to transfer xp to my mage unit...
You're using attack end, I wonder if that happens before or after the unit is granted experience. If it's before, he'll have nothing to give on the first attack (or the third, fifth...).

I've never seen [event] inside [unit_type]. Since your event doesn't have an id, I wonder if you get one (well, two in this case) for every unit that is created? That would be interesting. I'm sure tommas would approve.

I don't see a {CLEAR_VARIABLE xp_transfer} in there anywhere.

The indentation is lacking. If you're not familiar with it, I'd recommend you look at wmlindent.

I notice that a decent part of both of those events are the same. You might look into creating your own macro, or adding a third event and using [fire_event] (I suspect the latter approach might be frowned on). You're going to want to learn to create macros at some point, while it's not all necessary to do it here it would be a fine time to learn (or not, nothing wrong with the way you're doing it now, IMO).
ChrundleTheGreat wrote: May 15th, 2024, 7:28 pm im also facing the main next two issues; i want to recruit with xp, not gold, and i want a menu for transforming orbs into spells...
any ideas?
These are not the easiest things to do if you're new to WML. You seem to be making good progress, so I don't doubt you'll figure them out, but they're not trivial.

There are events that happen when recruit happens. You could probably intercept the recruiting process, check for adequate experience, adjust player gold and leader XP, etc. I'm not sure how you would block the recruit if leader doesn't have enough XP besides killing it, which is a little odd, you probably would want to disallow the recruiting at all ([allow_recruit] and [disallow_recruit] might help, although you'd get a "no units available to recruit" type message, not "you don't have enough XP, loser" message).

https://wiki.wesnoth.org/EventWML

Not sure what transforming orb (a unit) into a spell means. If a spell is just another unit, there's a [transform_unit] action and/or macro. If you mean kill the unit and give tommas an new one-time-only attack, that's doable, but it's going to be a little complicated.

Of course, when you say menu [set_menu_item] immediately comes to mind. Not sure how you would do it on a specific unit without using lua, though.
Last edited by white_haired_uncle on May 15th, 2024, 9:24 pm, edited 1 time in total.
Speak softly, and carry Doombringer.
User avatar
Ravana
Forum Moderator
Posts: 3189
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: new campaign's questions and ideas

Post by Ravana »

Macro is easy dirty way, but unless you have performance issues there is no need to optimize code with fire_event.

{CLEAR_VARIABLE xp_transfer} is part of code quality improvement, but does not affect what your code does. Both events start by resetting it anyways.
User avatar
ChrundleTheGreat
Posts: 84
Joined: May 3rd, 2023, 1:25 am
Location: The land of chapaqueños

Re: new campaign's questions and ideas

Post by ChrundleTheGreat »

white_haired_uncle wrote: May 15th, 2024, 9:08 pm
You're using attack end, I wonder if that happens before or after the unit is granted experience. If it's before, he'll have nothing to give on the first attack (or the third, fifth...).
yes! thats whats happening, how could i fix that?
white_haired_uncle wrote: May 15th, 2024, 9:08 pm I've never seen [event] inside [unit_type]. Since your event doesn't have an id, I wonder if you get one (well, two in this case) for every unit that is created? That would be interesting. I'm sure tommas would approve.

...

I notice that a decent part of both of those events are the same. You might look into creating your own macro, or adding a third event and using [fire_event] (I suspect the latter approach might be frowned on). You're going to want to learn to create macros at some point, while it's not all necessary to do it here it would be a fine time to learn (or not, nothing wrong with the way you're doing it now, IMO).
im using wml_guide as a template (by beetlenaut), and it suggested to include events in unit files, could you teach me about making macros?
white_haired_uncle wrote: May 15th, 2024, 9:08 pm These are not the easiest things to do if you're new to WML. You seem to be making good progress, so I don't doubt you'll figure them out, but they're not trivial.

There are events that happen when recruit happens. You could probably intercept the recruiting process, check for adequate experience, adjust player gold and leader XP, etc. I'm not sure how you would block the recruit if leader doesn't have enough XP besides killing it, which is a little odd, you probably would want to disallow the recruiting at all ([allow_recruit] and [disallow_recruit] might help, although you'd get a "no units available to recruit" type message, not "you don't have enough XP, loser" message).

Not sure what transforming orb (a unit) into a spell means. If a spell is just another unit, there's a [transform_unit] action and/or macro. If you mean kill the unit and give tommas an new one-time-only attack, that's doable, but it's going to be a little complicated.
thanks, i am still interested in learning, :) .
for now i guess "no units available to recruit" would do.
i was thinking a menu appears, you select a spell and the unit (orb) dies, leaving behind one out of three effects,
  • tommas recovers 10 hp
  • every unit around the dying orb takes a high amount of damage (fire type)
  • every unit takes a lower amount of damage and gets slowed down
white_haired_uncle wrote: May 15th, 2024, 9:08 pm
Of course, when you say menu [set_menu_item] immediately comes to mind. Not sure how you would do it on a specific unit without using lua, though.
:?
User avatar
ChrundleTheGreat
Posts: 84
Joined: May 3rd, 2023, 1:25 am
Location: The land of chapaqueños

Re: new campaign's questions and ideas

Post by ChrundleTheGreat »

Ravana wrote: May 15th, 2024, 7:46 pm You could update gold to be equal to xp. If you recruit, reduce xp. If you fight, increase gold.
how can i begin with this?
User avatar
Ravana
Forum Moderator
Posts: 3189
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: new campaign's questions and ideas

Post by Ravana »

Reducing xp after recruit is easier. Once you have that working I can help with Lua to
1) disable kill xp
2) disable fight xp
3) manually give kill and fight xp at attack end
4) update gold at attack end.
User avatar
ChrundleTheGreat
Posts: 84
Joined: May 3rd, 2023, 1:25 am
Location: The land of chapaqueños

Re: new campaign's questions and ideas

Post by ChrundleTheGreat »

could you explain how to do 3?
white_haired_uncle
Posts: 1444
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: new campaign's questions and ideas

Post by white_haired_uncle »

ChrundleTheGreat wrote: May 15th, 2024, 10:31 pm
white_haired_uncle wrote: May 15th, 2024, 9:08 pm
You're using attack end, I wonder if that happens before or after the unit is granted experience. If it's before, he'll have nothing to give on the first attack (or the third, fifth...).
yes! thats whats happening, how could i fix that?
I don't know that there is an event that happens "after attack end". The only thing I can think of is to:

1. Add a turn end event to transfer the XP from all orbs to tommas.
2. Add another attack event that transfers the XP. If you don't do this, you'll need to make sure orbs cannot advance (you should probably do that anyway).

Item 2 will probably require the use of [store_unit] with a filter to populate an array with all orbs on side 1 and then a for/foreach loop to run over that array. This is something you'll want to learn anyway.

[/quote]
ChrundleTheGreat wrote: May 15th, 2024, 10:31 pm im using wml_guide as a template (by beetlenaut), and it suggested to include events in unit files, could you teach me about making macros?
This explains it better than I can

https://wiki.wesnoth.org/PreprocessorRef
ChrundleTheGreat wrote: May 15th, 2024, 10:31 pm i was thinking a menu appears, you select a spell and the unit (orb) dies, leaving behind one out of three effects,
  • tommas recovers 10 hp
  • every unit around the dying orb takes a high amount of damage (fire type)
  • every unit takes a lower amount of damage and gets slowed down
You could use [set_menu_item] three times, or you could use [set_menu_item] and have it open a [message] with [option]s.

The trick is to only have the menu item available when an orb is selected, and to be able to identify which unit is selected when you do. I'll look into that.

Okay it looks like x1,y1 are set to the active tile when you open a menu item. The following will only show the menu item "Items" if the mouse is over a unit. You can modify this to check specifically if there is an orb there, and use x1,y1 in a filter to identify the orb:

Code: Select all

        [set_menu_item]
            id=3dropping
            description=_"Items"
            use_hotkey=yes
            [default_hotkey]
                key=i
                shift=yes
            [/default_hotkey]
            [show_if]
                [have_unit]
                    x,y=$x1,$y1
                    side=$side_number
                    [not]
                        [filter_wml]
                            [variables]
                                cant_pick=yes
                            [/variables]
                        [/filter_wml]
                    [/not]
                [/have_unit]
            [/show_if]
            [command]
                [show_inventory]
                    x,y=$x1,$y1
                [/show_inventory]
            [/command]
        [/set_menu_item]
Speak softly, and carry Doombringer.
User avatar
Ravana
Forum Moderator
Posts: 3189
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: new campaign's questions and ideas

Post by Ravana »

You do not need to do 3. If you do "Reducing xp after recruit" I will do 1-4 for you.
User avatar
lhybrideur
Posts: 408
Joined: July 9th, 2019, 1:46 pm

Re: new campaign's questions and ideas

Post by lhybrideur »

You could store xp in a variable in an attack event (start of the attack) and compare it to the xp in the attack_end even.
Then you reduce the xp by the difference and gives it to the leader.
Post Reply