How to make AI recruit at a given 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
Marcgal

How to make AI recruit at a given location?

Post by Marcgal »

Sorry for the vague thread subject, let me clarify things.

I want enemies to appear in packs, from the edge of the map. Just as if each was placed with unit placement map_passable on a single hex.

But I don’t wanna manually place the units. Instead, I’d like the AI to decide which unit should appear, just as if it was recruiting them.

Approach #1: Place a leader at the given hex, place castle overlay around him, let him recruit for one turn then remove castle overlay.

Problems: • What if the leader can’t recruit everything in one turn because there happen to be other units in his “castle”? • I can’t afford one side per one bulk of enemies. This approach risks that instead of a pack of enemies appearing I will have other leaders recruiting more units instead, https://wiki.wesnoth.org/AI_Recruitment ... le_leaders

Approach #2: Place a castle overlay all over the map, so that I’m sure the AI can recruit any amount of units it chooses and is not blocked by other units. Whenever AI recruits, remove this unit in prerecruit event, and place it next to the leader with unit placement map_passable (not leader_passable cuz which leader?) Remove the castle overlay as soon as the AI has no more gold for recruitment.

Problems: • I need to be sure the AI ONLY recruits, and doesn’t move anything before it finishes recruiting: is it possible to configure it like so? • Same problem with mutliple leaders recruitment.

To fix the multple leader recruitmen problem: Remove cancrecruit yes from all units of the side bar this one leader that should recruit, restore canrecruit yes to those units immediately afterwards.

Any ideas how to do this? Because I think there just got to be a better way than these ideas of mine.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: How to make AI recruit at a given location?

Post by zookeeper »

Marcgal wrote:But I don’t wanna manually place the units.
Why not? It's not very complicated, in fact I think it's pretty much guaranteed to be less complicated and more robust than trying to do it via AI recruitment.

Certainly if you do know that's how you really need/want to do it for whatever reason then fine, but... it's kinda hard to see how that could be the case.
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: How to make AI recruit at a given location?

Post by beetlenaut »

Marcgal wrote:Approach #1: Place a leader at the given hex, place castle overlay around him, let him recruit for one turn then remove castle overlay.
I agree with zookeeper, but if you must, this is probably the way I would do it.
Marcgal wrote:What if the leader can’t recruit everything in one turn because there happen to be other units in his “castle”?
Find a location for the leader to appear where there isn't another unit in the way.
Marcgal wrote:I can’t afford one side per one bulk of enemies... I need to be sure the AI ONLY recruits, and doesn’t move anything before it finishes recruiting
Maybe create a temporary team. Flip all units of the team that needs to recruit to that team, then flip them back when the recruiting team is out of free castle hexes.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Marcgal

Re: How to make AI recruit at a given location?

Post by Marcgal »

The reason I didn’t want to manually place units is that in this way I could at best place random units. Hopefully letting the AI choose which units should appear will lead to better results (= more challenging for the player).
Smok
Posts: 53
Joined: June 14th, 2016, 11:52 am

Re: How to make AI recruit at a given location?

Post by Smok »

Approach #3: Place leader at any hex, give him castle overlay. Use prerecruit event to teleport recruited uints to destination.
Post Reply