AI Leader Message Upon Being Attacked?
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.
-
- Posts: 9
- Joined: November 6th, 2020, 4:45 am
AI Leader Message Upon Being Attacked?
I've been looking through the mainline campaigns, trying to find how this would be done, but have either missed it or not seen it.
So I put the question to the gurus here:
Is there a way to have a message pop up when you enter a hex adjacent to and/or when you attack the boss for the first time? I'd love to have another tool at my disposal to show angry AI bosses. Maybe something similar to this:
Could I maybe filter it so it only proc's the first time a hex is entered adjacent to an AI leader? I don't know... Thinking out loud here. Thanks!
PS. Everyone here helping out in the WML Workshop is amazing. You're all the best. I am so looking forward to eventually releasing a campaign.
So I put the question to the gurus here:
Is there a way to have a message pop up when you enter a hex adjacent to and/or when you attack the boss for the first time? I'd love to have another tool at my disposal to show angry AI bosses. Maybe something similar to this:
Code: Select all
[event]
name=enter_hex
[filter]
side=1
???
[/filter]
[message]
speaker=aileader
message= _ "Stay back, invaders! You'll die for this!"
[/message]
[/event]
Could I maybe filter it so it only proc's the first time a hex is entered adjacent to an AI leader? I don't know... Thinking out loud here. Thanks!
PS. Everyone here helping out in the WML Workshop is amazing. You're all the best. I am so looking forward to eventually releasing a campaign.
Re: AI Leader Message Upon Being Attacked?
I'd use a subfilter to filter the adjacent unit:
By default, all events fire only once. So this will only trigger the first time a side 1 unit enters the hex next to aileader. Note that this will also trigger if (for example a skirmisher unit) moves past the enemy! If you want to avoid this, you should use
Displaying a message when the boss is attacked for the first time is even simpler:
This will trigger once, when a side 1 unit attacks aileader for the first time.
Code: Select all
[event]
name=enter_hex
[filter]
side=1
[filter_adjacent]
id=aileader
[/filter_adjacent]
[/filter]
... message stuff
[event]name=moveto
instead of enter_hex.Displaying a message when the boss is attacked for the first time is even simpler:
Code: Select all
[event]
name=attack
[filter]
side=1
[/filter]
[filter_second]
id=aileader
[/filter_second]
... message stuff
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Re: AI Leader Message Upon Being Attacked?
To answer a question you didn't ask (but might, perhaps, have been wondering about), it's also possible to make the AI leader respond differently to different units...
Disclaimer: not historically accurate.
In this case, if you attack with a horde including Brutus, Ghost (who, in my mind, is an actual ghost, or at least a very sneaky assassin), and several other units, Caesar will say all three things.
If you want to make him only say something to the first attacker, then you nee to put it all inside the same event. You can use various conditionals (I would recommend [if] or [switch]) inside of the event to make it do different things depending on who the attacker is. I find [if] a pain to type and read, so I tend to avoid it. I've never actually used [switch], but it looks neat. If you are interested, you can read more about them here: https://wiki.wesnoth.org/ConditionalActionsWML
Code: Select all
[event]
name=attack
[filter]
id=Brutus
[/filter]
[filter_second]
id=Caesar
[/filter_second]
[message]
speaker=Caesar
message= _ "You too, Brutus?"
[/message]
[/event]
[event]
name=attack
[filter]
id=Ghost
[/filter]
[filter_second]
id=Caesar
[/filter_second]
[message]
speaker=Caesar
message= _ "What hit me?"
[/message]
[/event]
[event]
name=attack
[filter]
side=1
[not]
id=Brutus, Ghost
[/not]
[/filter]
[filter_second]
id=Caesar
[/filter_second]
[message]
speaker=Caesar
message= _ "Ouch!"
[/message]
[/event]
In this case, if you attack with a horde including Brutus, Ghost (who, in my mind, is an actual ghost, or at least a very sneaky assassin), and several other units, Caesar will say all three things.
If you want to make him only say something to the first attacker, then you nee to put it all inside the same event. You can use various conditionals (I would recommend [if] or [switch]) inside of the event to make it do different things depending on who the attacker is. I find [if] a pain to type and read, so I tend to avoid it. I've never actually used [switch], but it looks neat. If you are interested, you can read more about them here: https://wiki.wesnoth.org/ConditionalActionsWML
-
- Posts: 9
- Joined: November 6th, 2020, 4:45 am
Re: AI Leader Message Upon Being Attacked?
This is gold. I did not ask but you answered the question I wish I had.Pilauli wrote: ↑November 19th, 2020, 9:15 am To answer a question you didn't ask (but might, perhaps, have been wondering about), it's also possible to make the AI leader respond differently to different units...Disclaimer: not historically accurate.Code: Select all
[event] name=attack [filter] id=Brutus [/filter] [filter_second] id=Caesar [/filter_second] [message] speaker=Caesar message= _ "You too, Brutus?" [/message] [/event] [event] name=attack [filter] id=Ghost [/filter] [filter_second] id=Caesar [/filter_second] [message] speaker=Caesar message= _ "What hit me?" [/message] [/event] [event] name=attack [filter] side=1 [not] id=Brutus, Ghost [/not] [/filter] [filter_second] id=Caesar [/filter_second] [message] speaker=Caesar message= _ "Ouch!" [/message] [/event]
In this case, if you attack with a horde including Brutus, Ghost (who, in my mind, is an actual ghost, or at least a very sneaky assassin), and several other units, Caesar will say all three things.
If you want to make him only say something to the first attacker, then you nee to put it all inside the same event. You can use various conditionals (I would recommend [if] or [switch]) inside of the event to make it do different things depending on who the attacker is. I find [if] a pain to type and read, so I tend to avoid it. I've never actually used [switch], but it looks neat. If you are interested, you can read more about them here: https://wiki.wesnoth.org/ConditionalActionsWML