dabber's questions: vision to location

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.
Post Reply
User avatar
dabber
Posts: 464
Joined: April 2nd, 2014, 6:41 pm

dabber's questions: vision to location

Post by dabber »

Maybe these are more design questions than WML questions, but I feel like I'm missing something, so I'll ask anyway. Is there an easy way to set a side's current gold to a specific value, instead of adding to it? I seem to have figured out how to do it below, but I'm surprised there isn't a more direct way to do this.
This came up because I end up significantly in negative gold, which makes an an early finish bonus largely useless. So I'm thinking of forcing current gold to be >0 in the victory event. Am I missing something in code, or does no one ever want this sort of thing because my problem is really a scenario design failure?

Code: Select all

#define ZERO_GOLD SIDE
    [store_gold]
        side={SIDE}
        variable=gold
    [/store_gold]
    [set_variable]
        name=gold
        multiply=-1
    [/set_variable]
    [gold]
        side={SIDE}
        amount=$gold
    [/gold]
    {CLEAR_VARIABLE gold}
#enddef

#define ZERO_NEGATIVE_GOLD SIDE
    [store_gold]
        side={SIDE}
        variable=gold
    [/store_gold]
    [if]
        [variable]
            name=gold
            greater_than=0
        [/variable]
        [then]
            {ZERO_GOLD {SIDE}}
        [/then]
    [/if]
    {CLEAR_VARIABLE gold}
#enddef
Last edited by dabber on January 23rd, 2024, 9:41 am, edited 21 times in total.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: dabber's questions: set gold, useless bonus

Post by zookeeper »

You can set a side's gold with [modify_side].
User avatar
dabber
Posts: 464
Joined: April 2nd, 2014, 6:41 pm

Re: dabber's questions: set gold, useless bonus

Post by dabber »

Well I feel dumb. :)
User avatar
dabber
Posts: 464
Joined: April 2nd, 2014, 6:41 pm

Re: dabber's questions: split recall list

Post by dabber »

What is the best way to go about splitting the recall list into two separate parts, selected by the user? The only method I can come up with is to create a dummy scenario with a fixed amount of gold, where the player recalls troops from the full list. The troops recalled become group 1 and the troops not recalled become group 2. But the dummy scenario seems, well, dumb.

Again this isn't exactly a WML question, but where else would I ask it?
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: dabber's questions: split recall list

Post by zookeeper »

dabber wrote:What is the best way to go about splitting the recall list into two separate parts, selected by the user? The only method I can come up with is to create a dummy scenario with a fixed amount of gold, where the player recalls troops from the full list. The troops recalled become group 1 and the troops not recalled become group 2. But the dummy scenario seems, well, dumb.
Well, that would depend on how you need things to work. If you need to have group A for scenario X and group B for scenario X+1, then the simplest way may be to make everyone not recalled in X available in X+1; that's how it's done in The South Guard.
dabber wrote:Again this isn't exactly a WML question, but where else would I ask it?
Eh, I think this is as good a place as any.
User avatar
dabber
Posts: 464
Joined: April 2nd, 2014, 6:41 pm

Re: dabber's questions: leader stay in keep

Post by dabber »

I'm now spent over an hour reading AI documentation, and I'm both excited and brain fogged by the possibilities. But I didn't find what I'm after...
How do I let a side leader move and attack, but always stay inside his castle? I don't want him to be passive, because he's a bad dude, but I also want him to stop being an idiot and walking out into the open when he's got a 60% defense castle he could attack from.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: dabber's questions: leader stay in castle

Post by zookeeper »

The simplest way to do that would be to manipulate movement costs so that the leader can't leave the castle on their own turn. Example from DiD in 1.11.16, where Darken Volk only gets to move inside his own castle and an adjacent village, all other surrounding terrain being flat:

Code: Select all

    # This helps prevent Darken from getting himself killed easily by preventing
    # him from leaving his castle
    [event]
        name=side 2 turn refresh
        first_time_only=no

        [modify_unit]
            [filter]
                id=Darken Volk
            [/filter]

            [movement_costs]
                flat=99
            [/movement_costs]
        [/modify_unit]

        [event]
            name=side turn end

            [modify_unit]
                [filter]
                    id=Darken Volk
                [/filter]

                [movement_costs]
                    flat=1
                [/movement_costs]
            [/modify_unit]
        [/event]
    [/event]
I'm not sure what it was, but there was some reason for why it was better to do it like that instead of as proper AI behavior.
Anonymissimus
Inactive Developer
Posts: 2461
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: dabber's questions: leader stay in castle

Post by Anonymissimus »

An extremely easy way is putting max_moves=1 into the leader definition (usually in the [side] tag).
That probably doesn't allow the leader to heal but works very well for that it is so simple. AI leaders also generally move back to their keep after an attack, so if there are 6 castle tiles around the keep, the leader should never leave 60% def.
I think I've never seen an AI leader attacking in a consecutive turn, after moving out of the keep, and not just because there was gold for recruitment.
Works generally better than passive_leader etc too, those settings are too bug-prone.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
User avatar
dabber
Posts: 464
Joined: April 2nd, 2014, 6:41 pm

Re: dabber's questions: leader go off to fight

Post by dabber »

How can I get a leader to finish recruiting and then follow his last wave of recruits into battle? He's a level 3 fighter, he doesn't have enough income to ever get back to positive gold, but he sits in his keep instead of joining battle. Sure he'll launch out occasionally for one attack, but then he returns to the keep.
Do I have to kill him and create another unit with the same name? Only thing I've thought of. Would it even work?
User avatar
FaeLord
Posts: 343
Joined: March 2nd, 2012, 3:12 pm
Location: Seattle, WA

Re: dabber's questions: leader go off to fight

Post by FaeLord »

Setting the leader's aggression high using the [ai] tag will increase his likelyhood of attacking. But I don't know of anything that will make a leader follow his troops into battle after recruiting. You could simulate that action by giving the leader some move to goals, again using the [ai] tag.

-=FL=-
Wesnoth stole my summer . . . again.
User avatar
James_The_Invisible
Posts: 533
Joined: October 28th, 2012, 1:58 pm
Location: Somewhere in the Northlands, fighting dark forces
Contact:

Re: dabber's questions: leader go off to fight

Post by James_The_Invisible »

If you are on Wesnoth 1.11.x, you can you use leader_ignores_keep. But you should set it to yes after he recruits the last wave else he would recruit only in first turn. Like this (not tested):

Code: Select all

[modify_side]
  side=2 # change this to the right side if needed
  [ai]
    leader_ignores_keep=yes
  [/ai]
[/modify_side]
Last edited by James_The_Invisible on August 17th, 2014, 3:29 pm, edited 1 time in total.
User avatar
SkyOne
Posts: 1310
Joined: January 3rd, 2009, 7:23 pm

Re: dabber's questions: leader go off to fight

Post by SkyOne »

dabber wrote:Do I have to kill him and create another unit with the same name?
You can modify him as canrecruit=no in a certain event, instead of killing him.
Fate of a Princess/feedback thread: "What is in own heart that is the most important, not who you are."
Drake Campaign: Brave Wings/feedback thread, Naga Campaign: Return of the Monster, Saurian Campaign: Across the Ocean
Northern Forces - now on 1.12 server
User avatar
dabber
Posts: 464
Joined: April 2nd, 2014, 6:41 pm

Re: dabber's questions: leader go off to fight

Post by dabber »

I did the canrecruit=no modification first, but it didn't work.

James, thanks! That sounds like exactly what I want. The new AI options melted my brain last week so I didn't notice that one.
User avatar
dabber
Posts: 464
Joined: April 2nd, 2014, 6:41 pm

Re: dabber's questions: leader go off to fight

Post by dabber »

I must be missing something obvious here, but how do I make a scenario end once all the enemies are dead, not just their leaders? I can set victory_when_enemies_defeated=no but then the scenario never ends.
User avatar
James_The_Invisible
Posts: 533
Joined: October 28th, 2012, 1:58 pm
Location: Somewhere in the Northlands, fighting dark forces
Contact:

Re: dabber's questions: leader go off to fight

Post by James_The_Invisible »

I did this in my campaign this way:

Code: Select all

[event]
   name=die
   first_time_only=no
  [filter]
    side=3
  [/filter]
  [if]
    [have_unit]
      side=3
    [/have_unit]
    [else]
      [endlevel]
        result=victory
        bonus=yes
        {NEW_GOLD_CARRYOVER 40}
      [/endlevel]
    [/else]
  [/if]
[/event]
(victory_when_enemies_defeated must be set to no for this to work.)
Post Reply