How to force IA factions to start playing when spotted?
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.
How to force IA factions to start playing when spotted?
Hello, Wesnoth Forum!
I'm an old Wesnoth player (I can't be able to count how many days I know this fantastic game), but this is my very first post here, so hello, world!
In the past few days, I started to study the WML, and I was able to create my first scenario (a simple one Vs. one in which all you have to do is defeat the enemy leader).
I'm thinking now about a new feature in my campaign that I'd like to implement:
Consider the image below, with the addition of the fog of war.
I want the IA leaders to start playing only when one of the player's units spots leader number 2.
In particular, the plot of this scenario is that the player meets leader number 2 on his way, and since he's under attack by the other ones, the player offers to help him.
I already read that exists the sighted event that I think it's perfect for doing part of the job, but how to force some factions to start to play only after an event occurs (in this case, the player spotting the leader 2)?
Thanks a lot in advance!
I'm an old Wesnoth player (I can't be able to count how many days I know this fantastic game), but this is my very first post here, so hello, world!
In the past few days, I started to study the WML, and I was able to create my first scenario (a simple one Vs. one in which all you have to do is defeat the enemy leader).
I'm thinking now about a new feature in my campaign that I'd like to implement:
Consider the image below, with the addition of the fog of war.
I want the IA leaders to start playing only when one of the player's units spots leader number 2.
In particular, the plot of this scenario is that the player meets leader number 2 on his way, and since he's under attack by the other ones, the player offers to help him.
I already read that exists the sighted event that I think it's perfect for doing part of the job, but how to force some factions to start to play only after an event occurs (in this case, the player spotting the leader 2)?
Thanks a lot in advance!
- Spannerbag
- Posts: 535
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: How to force IA factions to start playing when spotted?
Hi Alopex95,
That said, it might be better to have side 2 active from the start so that battle can commence prior to the player sighting the side?
You'll have to decide what works best for you.
Sooo, finally (ta-rah!) we get to the sighted event (side 1 sees side 2). Something like the code below should provide the basic framework (the example uses
However another option (which might possibly be more fun for the player) would be to convert side 2 to player control once sighted (i.e. set side 2
Anyway, hope this helps!
Cheers!
-- Spannerbag
Just a thought:Alopex95 wrote: ↑November 25th, 2022, 2:00 pm Consider the image below, with the addition of the fog of war.
I want the IA leaders to start playing only when one of the player's units spots leader number 2.
In particular, the plot of this scenario is that the player meets leader number 2 on his way, and since he's under attack by the other ones, the player offers to help him.
I already read that exists the sighted event that I think it's perfect for doing part of the job, but how to force some factions to start to play only after an event occurs (in this case, the player spotting the leader 2)?
Thanks a lot in advance!
My understanding is that you have the player (side 1 I guess) and 3+ ai sides (2, 3 & 4 say) in fog of war.
When player sights side 2's leader, side 2 becomes active however when this occurs is not under your control but depends on the player's actions and you exlained that side 2 would already be under attack from other sides, so the possibility exists that side 2's leader could be killed before the player sights it.
Hence it might be advisable to have some logic to ensure that side 2 is viable by the time it "wakes up" when sighted by the player.
One easy way is to simply have the enemy side(s)
... and the same for side 4 (I don't think you can specify multiple sides in
However if the only side 2 unit on map is the leader and the enemy is configured to
As for keeping side 2 inactive until sighted this can be done in various ways including; setting gold and income to zero, When player sights side 2's leader, side 2 becomes active however when this occurs is not under your control but depends on the player's actions and you exlained that side 2 would already be under attack from other sides, so the possibility exists that side 2's leader could be killed before the player sights it.
Hence it might be advisable to have some logic to ensure that side 2 is viable by the time it "wakes up" when sighted by the player.
One easy way is to simply have the enemy side(s)
[avoid]
side 2's leader until the player sights side 2 then remove the [avoid]
as part of the sighted event (so side 2 can, presumably, recruit a keep full of units and thus protect its leader). This method is used in scenario 1 of Heir to the Throne. To remove an [avoid]
without an id is possible using this code:
Code: Select all
[modify_ai] # Clear side 3 [avoid]
side=3
action=delete
path=aspect[avoid].facet[*]
[/modify_ai]
[modify_ai]
).However if the only side 2 unit on map is the leader and the enemy is configured to
[avoid]
it then the side will not be seen as under attack when sighted, so I think [avoid]
alone will not suffice?controller=null
or even having the leader as a regular unit until sighted then modify it to have canrecruit=yes
- it really depends which best suits your design.That said, it might be better to have side 2 active from the start so that battle can commence prior to the player sighting the side?
You'll have to decide what works best for you.
Sooo, finally (ta-rah!) we get to the sighted event (side 1 sees side 2). Something like the code below should provide the basic framework (the example uses
[modify_side]
but [modify_ai]
might be needed instead or as well as [modify_side]
depending on what you want to do).Code: Select all
[event]
name=sighted
[filter]
side=2
[/filter]
[filter_second]
side=1
[/filter_second]
[modify_side]
side=2
... code to make side 2 active ...
[/modify_side]
... dialogue and other stuff (e.g. spawn side 2 units immediately?)...
[/event]
controller=human
).Anyway, hope this helps!
Cheers!
-- Spannerbag
Re: How to force IA factions to start playing when spotted?
Welcome to the forum. This is how I would do it. It's a little different than what you wanted, but maybe it'll give you some ideas.
I would require the side 1 player to move any unit onto a particular tile (village tile, castle tile, whatever), and then Leader 2 would arrive in the keep and offer to help.
First put Leader 2 in
recall
instead of on the map. Notice the x,y. Also, use hidden
to hide the side from the Status Table.
Code: Select all
[side]
side=2
type=Heavy Infantryman
name= _ "Baron Blake"
id=AlliedLeaderSide2
x,y=recall,recall # 14,5
facing=sw
controller=ai
team_name="Baron's Army"
user_team_name= _ "Good Guys"
recruit=Peasant
hidden=yes
moves=0 # current turn only
gold=60
color=purple
[/side]
moveto
event to make the Leader appear in their keep.Code: Select all
[event]
name=moveto
[filter]
side=1
x,y=12,5 # < -- maybe mention in objectives
[/filter]
[message]
speaker=unit
message= _ "Who will help us battle our foes?"
[/message]
[recall]
id=AlliedLeaderSide2
x,y=14,5
# show=no
[/recall]
[modify_side]
hidden=no
[/modify_side]
[message]
speaker=AlliedLeaderSide2
message= _ "I will help you!"
[/message]
[/event]
[event]
modify_side
makes them appear in the Status Table.Edit: Oh, Spannerbag just posted a great answer while I was testing my code. That's one of the nice things about WML: there are a lot of different ways to do things, and you will develop your own style.
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.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
Re: How to force IA factions to start playing when spotted?
Hey, guys!
Wow, thanks for your precious replies! I will try your suggestions and let you know if I succeed to accomplish my goal!
I'm sorry if maybe I wasn't clear enough about what I'm trying to do, but here's the accurate use case I'm thinking about:
Cheers!
Wow, thanks for your precious replies! I will try your suggestions and let you know if I succeed to accomplish my goal!
I'm sorry if maybe I wasn't clear enough about what I'm trying to do, but here's the accurate use case I'm thinking about:
- Leader 1 (i.e. the human) spots Leader 2 (an ally of the player);
- A short cutscene starts, in which Leader 2 is facing the invasion of the other three enemies (leaders 3, 4 and 5);
- At this point, side numbers 2, 3, 4 and 5 start to play (because before, all of these leaders were "blocked" or not active). I want the attack by the three IA leaders against IA leader 2 begins only after the player spots the latter;
- Now the player has to defeat leaders 3, 4 and 5 and saves leader 2 (so now the winning conditions would be to defeat the three IA enemies and the defeat conditions are the death of the player and his ally).
Cheers!
- Spannerbag
- Posts: 535
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: How to force IA factions to start playing when spotted?
Hi again - and welcome to the forum (oops, sorry, forgot this in previous post).
If not, you could just start as normal and have initial dialogue setup the scenario?
(It would be a lot easier to code! )
You're very welcome and please feel free to ask any question, (most of the) folks here don't bite
As Helmet said there are often many ways to do the same thing.
FWIW, I tend to change stuff a lot during playtesting because for the player this will be the first and probably only time they encounter whatever situation you've set up and won't have the familiarity with the scenario that the developer has. When you've played something several times it's easy to overlook this (at least for me...).
The paramount consideration (for me anyway) is that it must be challenging and fun, so I question what every element (units, map, events, storyline etc.) contributes to the scenario. If I can't see how it entertains or challenges the player I leave it out. I also try very hard not to replicate what others have done but don't always achieve this. Further my development pace is very slow so I often find by the time I publish stuff others have independently done something similar to me
I'm currently working on two separate campaigns, both well over halfway done - the second was intended to be a small, quick, simple and easy one as a break from the bigger and more complex first one. The second one is now almost as big and even more complex than the first!
So beware: if you let it, WML will expand to occupy the available (head) space!
Anyway I've wittered on long enough and will shut up now.
Cheers!
-- Spannerbag
Just another thought: is there anything else player 1 can do besides ally with side 2 and fight the other sides?Alopex95 wrote: ↑November 26th, 2022, 12:26 pm Hey, guys!
Wow, thanks for your precious replies! I will try your suggestions and let you know if I succeed to accomplish my goal!
I'm sorry if maybe I wasn't clear enough about what I'm trying to do, but here's the accurate use case I'm thinking about:
- Leader 1 (i.e. the human) spots Leader 2 (an ally of the player);
- A short cutscene starts, in which Leader 2 is facing the invasion of the other three enemies (leaders 3, 4 and 5);
- At this point, side numbers 2, 3, 4 and 5 start to play (because before, all of these leaders were "blocked" or not active). I want the attack by the three IA leaders against IA leader 2 begins only after the player spots the latter;
- Now the player has to defeat leaders 3, 4 and 5 and saves leader 2 (so now the winning conditions would be to defeat the three IA enemies and the defeat conditions are the death of the player and his ally).
If not, you could just start as normal and have initial dialogue setup the scenario?
(It would be a lot easier to code! )
You're very welcome and please feel free to ask any question, (most of the) folks here don't bite
As Helmet said there are often many ways to do the same thing.
FWIW, I tend to change stuff a lot during playtesting because for the player this will be the first and probably only time they encounter whatever situation you've set up and won't have the familiarity with the scenario that the developer has. When you've played something several times it's easy to overlook this (at least for me...).
The paramount consideration (for me anyway) is that it must be challenging and fun, so I question what every element (units, map, events, storyline etc.) contributes to the scenario. If I can't see how it entertains or challenges the player I leave it out. I also try very hard not to replicate what others have done but don't always achieve this. Further my development pace is very slow so I often find by the time I publish stuff others have independently done something similar to me
I'm currently working on two separate campaigns, both well over halfway done - the second was intended to be a small, quick, simple and easy one as a break from the bigger and more complex first one. The second one is now almost as big and even more complex than the first!
So beware: if you let it, WML will expand to occupy the available (head) space!
Anyway I've wittered on long enough and will shut up now.
Cheers!
-- Spannerbag
Re: How to force IA factions to start playing when spotted?
OK, I wrapped up your pieces of advice and managed to write the following snippet:
The sighted event seems to work pretty well, but I still can't implement a way to make IAs start playing after the sighted event is triggered.
I tried to implement
Last but not least, I also put
So, all these ways make the player arrives in the middle of the battle. It's something I do not want to happen because the battle for the defence of leader 2 has to begin after the latter is sighted.
Any suggestions?
EDIT:
Code: Select all
#textdomain wesnoth-A_Land_To_Free
[scenario]
id=disorder
next_scenario=null
name=_"Disorder."
map_data="{~add-ons/A_Land_To_Free/maps/a_land_to_free.map}"
turns=30
[side]
side=1
controller=human
team_name="player"
user_team_name= _ "Humans"
id=Taldas
name= _ "Taldas"
type="Lieutenant"
unrenameable=yes
canrecruit=yes
recruit="Spearman, Bowman, Cavalryman"
gold=100
fog=yes
[/side]
[side]
side=2
controller=ai
team_name="city_of_brill"
user_team_name= _ "City of Brill"
id="Rodolph"
name= _ "Rodolph"
type= "Longbowman"
unrenameable=yes
canrecruit=yes
recruit="Peasant, Bowman"
gold=100
fog=yes
[/side]
[side]
side=3
controller=ai
team_name="bandits"
user_team_name= _ "Bandits of Brill"
id="Fasa"
name= _ "Fasa"
type= "Outlaw"
unrenameable=yes
canrecruit=yes
recruit="Footpad, Thug, Thief"
gold=100
[/side]
[side]
side=4
controller=ai
team_name="bandits"
user_team_name= _ "Bandits of Brill"
id="Ion"
name= _ "Ion"
type= "Outlaw"
unrenameable=yes
canrecruit=yes
recruit="Footpad, Thug, Thief"
gold=100
[/side]
[side]
side=5
controller=ai
team_name="bandits"
user_team_name= _ "Bandits of Brill"
id="Ion"
name= _ "Han"
type= "Outlaw"
unrenameable=yes
canrecruit=yes
recruit="Footpad, Thug, Thief"
gold=100
[/side]
[event]
name=start
[message]
speaker=Taldas
message= _ "A new adventure begins! Let's explore this land!"
[/message]
[objectives]
[objective]
description= _ "Explore the land"
condition="win"
[/objective]
[objective]
description= _ "Death of your leader"
condition="lose"
[/objective]
[objective]
description= _ "Turns run out"
condition="lose"
[/objective]
[/objectives]
[/event]
[event]
name=sighted
[filter]
side=2
[/filter]
[filter_second]
side=1
[/filter_second]
[modify_side]
# code to let the battle begins. But how? :-(
[/modify_side]
# dialogue :-)
[message]
speaker=Fasa
message= _ "It's time to put an end to your government of incompetence, Rodolph! Guys, let's take control of the city!"
[/message]
[message]
speaker=Rodolph
message= _ "You traitors scums! How can you do this in such a desperate time? Men, to arms!"
[/message]
[message]
speaker=Taldas
message= _ "We must help this city!"
[/message]
[/event]
[event]
name=die
[filter]
id=Taldas
[/filter]
[message]
speaker=Taldas
message= _ "I have to... Argh..."
[/message]
[endlevel]
result=defeat
[/endlevel]
[/event]
[/scenario]
I tried to implement
canrecruite=no
to all the other sides, but in this way, the scenario ends a few seconds later (because maybe no enemies are left in the scenario itself, and so the system automatically gives the victory to the player). I also tried to put gold=0
, but since the sides have villages nearby, after occupying some of them they can start recruiting with no problem. Last but not least, I also put
village_gold=0
, but this doesn't either prevent the three enemies to attack leader 2 and vice versa.So, all these ways make the player arrives in the middle of the battle. It's something I do not want to happen because the battle for the defence of leader 2 has to begin after the latter is sighted.
Any suggestions?
EDIT:
For now, this is exactly what I need to do!Spannerbag wrote: ↑November 26th, 2022, 2:13 pm Just another thought: is there anything else player 1 can do besides ally with side 2 and fight the other sides?
If not, you could just start as normal and have initial dialogue setup the scenario?
(It would be a lot easier to code! )
Thanks a lot for your kindness and your help! I appreciate it!Spannerbag wrote: ↑November 26th, 2022, 2:13 pm You're very welcome and please feel free to ask any question, (most of the) folks here don't bite
Last edited by Alopex95 on November 27th, 2022, 7:05 pm, edited 1 time in total.
Re: How to force IA factions to start playing when spotted?
Spannerbag, I suggest that you start on a third campaign, one that will stay small this time.Spannerbag wrote: ↑November 26th, 2022, 2:13 pm I'm currently working on two separate campaigns, both well over halfway done - the second was intended to be a small, quick, simple and easy one as a break from the bigger and more complex first one. The second one is now almost as big and even more complex than the first!
Here's a quick solution.
In the beginning, have side 2 start on the same team as the bandits. No battle will occur between them, if you do that. Then, when you want the battle to start, change side 2 so that it's no longer an ally of the bandits.
Use
modify_side
.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.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
Re: How to force IA factions to start playing when spotted?
Another way is to petrify the inactive side units.
Re: How to force IA factions to start playing when spotted?
Another idea.
Repeat this in the beginning of every turn, until you make it stop. Units can't attack each other if they can't move. Don't start two opposed units in adjacent hexes, of course.
Code untested.
Repeat this in the beginning of every turn, until you make it stop. Units can't attack each other if they can't move. Don't start two opposed units in adjacent hexes, of course.
Code: Select all
[modify_unit]
[filter]
side=3,4,5
[/filter]
moves=0
[/modify_unit]
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.
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
- Spannerbag
- Posts: 535
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: How to force IA factions to start playing when spotted?
Heh, like I could ever manage to do thatHelmet wrote: ↑November 26th, 2022, 5:01 pmSpannerbag, I suggest that you start on a third campaign, one that will stay small this time.Spannerbag wrote: ↑November 26th, 2022, 2:13 pm I'm currently working on two separate campaigns, both well over halfway done - the second was intended to be a small, quick, simple and easy one as a break from the bigger and more complex first one. The second one is now almost as big and even more complex than the first!
Cheers!
-- Spannerbag
- Spannerbag
- Posts: 535
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: How to force IA factions to start playing when spotted?
Hi again,
just yet another thought: if you "wake up" the ai sides when they are sighted they will begin recruiting. It will be obvious to the player that the battle is just beginning (fine if that's what you want of course).
If you want to give the impression of a battle already underway you could scatter random units of varying degrees of reduced hitpoints around but in my experience this isn't convincing or satisfying for various reasons (e.g. units can be sighted but don't do anything until leader is sighted or pop into existence depending on how you implement this). Firing the sighted event when any ai unit is sighted is an option but then you'd need to clear the fog around side 2 leader (maybe, not sure if fog obscures a speaking unit?).
If you want to have a "proper" battle underway, what you could do is first research the flow of the start of the battle.
Disable the fog and let the ai sides play for a few turns (you just set your human controlled side to be allied to everyone and the ai will ignore you). The ai will do similar moves every time early on (at least in my experience).
From this you will get an idea of how many turns the side 2 leader can expect to survive before it's in danger of being killed.
If need be you can tweak gold, recruitment, terrain etc. to increase or decrease this.
As a safety measure you can also force the enemy ai sides to
Give side 2 a keep surrounded by castles and include
Then, have initial dialogue inform the player something is going on, e.g. have a scout say something like "Whilst exploring south of here through the fog I saw shapes moving and heard the clash of battle! What are your orders?"
Set
When side 2 leader is sighted you can modify the
It's not a small chunk of work but it'd mean that the player would experience a proper battle in progress.
Bet you're sorry you asked now
Cheers!
-- Spannerbag
just yet another thought: if you "wake up" the ai sides when they are sighted they will begin recruiting. It will be obvious to the player that the battle is just beginning (fine if that's what you want of course).
If you want to give the impression of a battle already underway you could scatter random units of varying degrees of reduced hitpoints around but in my experience this isn't convincing or satisfying for various reasons (e.g. units can be sighted but don't do anything until leader is sighted or pop into existence depending on how you implement this). Firing the sighted event when any ai unit is sighted is an option but then you'd need to clear the fog around side 2 leader (maybe, not sure if fog obscures a speaking unit?).
If you want to have a "proper" battle underway, what you could do is first research the flow of the start of the battle.
Disable the fog and let the ai sides play for a few turns (you just set your human controlled side to be allied to everyone and the ai will ignore you). The ai will do similar moves every time early on (at least in my experience).
From this you will get an idea of how many turns the side 2 leader can expect to survive before it's in danger of being killed.
If need be you can tweak gold, recruitment, terrain etc. to increase or decrease this.
As a safety measure you can also force the enemy ai sides to
[avoid]
side 2 leader.Give side 2 a keep surrounded by castles and include
radius=1
in the [avoid]
to ensure side 2 can always recruit and the leader cannot be be killed early on. This might make the battle look odd later when it's possible that you end up with enemy units clustered around the keep but patiently waiting for side 2 to recruit new units for them to kill rather than entering the castle hexes and killing the leader...Then, have initial dialogue inform the player something is going on, e.g. have a scout say something like "Whilst exploring south of here through the fog I saw shapes moving and heard the clash of battle! What are your orders?"
Set
[objectives]
to something like Discover what is going on with a turn limit of a few turns (probably slightly less than whatever your flow research produced) so that within that time the player will see a convincing looking battle. Hints as to which way to go (paths or cobbles) might help the player. Also you need to allow enough time for the player to have a reasonable chance of locating side 2 leader. Plus you'll need a defeat clause (or something) to cater for when the player fails to locate the side 2 leader within the time (turn) limit, the TURNS_RUN_OUT macro will help with [objectives]
but you'll also need a time over event to actually do something if the player does run out of time.When side 2 leader is sighted you can modify the
[objectives]
as part of the sighted event logic. (You might also need to use [show_objectives]
to ensure the new objectives display in a timely manner....)It's not a small chunk of work but it'd mean that the player would experience a proper battle in progress.
Bet you're sorry you asked now
Cheers!
-- Spannerbag
- Celtic_Minstrel
- Developer
- Posts: 2207
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: How to force IA factions to start playing when spotted?
My suggestion would be to place this in the AI side definitions:
Then add this in a sighted event:
Code: Select all
[ai]
ai_algorithm=idle_ai
[/ai]
Code: Select all
[modify_side]
side=2 # or whatever side number was sighted
[ai]
ai_algorithm=ai_default_rca
[/ai]
[/modify_side]
Re: How to force IA factions to start playing when spotted?
HUGE thanks for all your suggestions! Wow, you guys gave me so many precious pieces of advice!
I solved the problem using @Celtic_Minstrel suggestion, and it works like a charm!
Cheers and thanks again!
I solved the problem using @Celtic_Minstrel suggestion, and it works like a charm!
Cheers and thanks again!
Re: How to force IA factions to start playing when spotted?
Hey, everyone!
Just another (and last, I promise! ) little query I'm wondering while finalizing my scenario: I'm trying to implement a condition when the
Here's what I've tried so far, but without any great results:
First, I tried with a
Second, I tried with the same event but putting a
I think that the
So, how can I set an event which will be fired after the defeat of a particular team?
Thanks always for your precious pieces of advice!
P.S.: I can open a new thread for this question if using this is against the forum rules.
Just another (and last, I promise! ) little query I'm wondering while finalizing my scenario: I'm trying to implement a condition when the
bandits
team is defeated because the scenario has to continue after our hero frees the city from them.Here's what I've tried so far, but without any great results:
First, I tried with a
name=die
event with a filter team_name="bandits"
;Second, I tried with the same event but putting a
filter
with id=OneBandit
and a filter_second
with id=AnotherBandit
(despite the bandit's leaders being three, but I was doing some tests).I think that the
die
event can be applied only to single units, so is this maybe the problem in my code?So, how can I set an event which will be fired after the defeat of a particular team?
Thanks always for your precious pieces of advice!
P.S.: I can open a new thread for this question if using this is against the forum rules.
Re: How to force IA factions to start playing when spotted?
Hello, Spannerbag!Spannerbag wrote: ↑November 27th, 2022, 2:54 am Hi again,
just yet another thought: if you "wake up" the ai sides when they are sighted they will begin recruiting. It will be obvious to the player that the battle is just beginning (fine if that's what you want of course).
If you want to give the impression of a battle already underway you could scatter random units of varying degrees of reduced hitpoints around but in my experience this isn't convincing or satisfying for various reasons (e.g. units can be sighted but don't do anything until leader is sighted or pop into existence depending on how you implement this). Firing the sighted event when any ai unit is sighted is an option but then you'd need to clear the fog around side 2 leader (maybe, not sure if fog obscures a speaking unit?).
If you want to have a "proper" battle underway, what you could do is first research the flow of the start of the battle.
Disable the fog and let the ai sides play for a few turns (you just set your human controlled side to be allied to everyone and the ai will ignore you). The ai will do similar moves every time early on (at least in my experience).
From this you will get an idea of how many turns the side 2 leader can expect to survive before it's in danger of being killed.
If need be you can tweak gold, recruitment, terrain etc. to increase or decrease this.
As a safety measure you can also force the enemy ai sides to[avoid]
side 2 leader.
Give side 2 a keep surrounded by castles and includeradius=1
in the[avoid]
to ensure side 2 can always recruit and the leader cannot be be killed early on. This might make the battle look odd later when it's possible that you end up with enemy units clustered around the keep but patiently waiting for side 2 to recruit new units for them to kill rather than entering the castle hexes and killing the leader...
Then, have initial dialogue inform the player something is going on, e.g. have a scout say something like "Whilst exploring south of here through the fog I saw shapes moving and heard the clash of battle! What are your orders?"
Set[objectives]
to something like Discover what is going on with a turn limit of a few turns (probably slightly less than whatever your flow research produced) so that within that time the player will see a convincing looking battle. Hints as to which way to go (paths or cobbles) might help the player. Also you need to allow enough time for the player to have a reasonable chance of locating side 2 leader. Plus you'll need a defeat clause (or something) to cater for when the player fails to locate the side 2 leader within the time (turn) limit, the TURNS_RUN_OUT macro will help with[objectives]
but you'll also need a time over event to actually do something if the player does run out of time.
When side 2 leader is sighted you can modify the[objectives]
as part of the sighted event logic. (You might also need to use[show_objectives]
to ensure the new objectives display in a timely manner....)
It's not a small chunk of work but it'd mean that the player would experience a proper battle in progress.
Bet you're sorry you asked now
Cheers!
-- Spannerbag
Yes, that's exactly what I did in this scenario! When it begins, the player simply has to move forward in the land, but after sighting the city's leader, who's facing a popular revolt, the objectives changed and the updated ones are promptly shown to the user (these include also the survival of the city leader).
And I did this as one of the first things in this scenario because I agree with you when you say that this improves a lot the game experience (and the same happens also in many, many other Wesnoth campaigns).
What a nice touch to give to a campaign, isn't it?