Change AI side from defend to attack during scenario

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
H-Hour
Posts: 222
Joined: April 14th, 2010, 12:27 pm

Change AI side from defend to attack during scenario

Post by H-Hour »

I am trying to get an allied AI side to stay and defend an area until an event happens in the game, at which point I want the AI side to leave its defended area and attack enemies.

I have the following in the [side] tag:

Code: Select all

[ai]
	aggression=0.2
	passive_leader=yes
	[avoid]
		[not]
			x=30
			y=4
			radius=4
		[/not]
	[/avoid]
[/ai]
Then in the a "new turn" [event] I have the following:

Code: Select all

[message]
	speaker=Ryden
	message = _ "Test"
[/message]
[modify_ai]
	side=3
	aggression=0.8
	passive_leader=no
	[avoid]
		x=30
		y=4
		radius=4
	[/avoid]
[/modify_ai]
I know this fires because the Test message appears. However, when I use the game state inspector, the ai data under the side still says:

Code: Select all

agression: 0.2
...
passive_leader: 1
Does anyone know what I'm doing wrong? Or is there a better way to accomplish what I want?
vghetto
Posts: 755
Joined: November 2nd, 2019, 5:12 pm

Re: Change AI side from defend to attack during scenario

Post by vghetto »

I think you have to delete the old avoid. I suggest you use one of the micro_ai to do what you want instead of [avoid]. probably zone_guardian then delete it on the new turn.
vghetto
Posts: 755
Joined: November 2nd, 2019, 5:12 pm

Re: Change AI side from defend to attack during scenario

Post by vghetto »

I apologies, i think my answer was confusing. about the aggression not changing, well you used modify_ai incorrectly. check the wiki on how to use modify_ai. Your code should have been [modify_side] with [ai] tags inside of it.
But even if you did that and checked the game inspector aspect, you would have seen both the first avoid block and the second avoid block defined. That is what I meant with you'd have to delete the first avoid block.
H-Hour
Posts: 222
Joined: April 14th, 2010, 12:27 pm

Re: Change AI side from defend to attack during scenario

Post by H-Hour »

Thanks, that's exactly what I needed!
User avatar
Celtic_Minstrel
Developer
Posts: 2213
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Change AI side from defend to attack during scenario

Post by Celtic_Minstrel »

vghetto wrote: April 22nd, 2020, 11:28 pm But even if you did that and checked the game inspector aspect, you would have seen both the first avoid block and the second avoid block defined. That is what I meant with you'd have to delete the first avoid block.
I'm fairly sure the second avoid block would be the one active, though… so deleting the first wouldn't be strictly necessary.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
vghetto
Posts: 755
Joined: November 2nd, 2019, 5:12 pm

Re: Change AI side from defend to attack during scenario

Post by vghetto »

I just tried this out with the trusty WML_Guide and what you said does indeed seem to be the case. Thank you.
Post Reply