Inevitable questions.

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.
SmokemJags
Posts: 580
Joined: February 14th, 2006, 3:24 am
Location: New Avalon
Contact:

Inevitable questions.

Post by SmokemJags »

So the campaign is finally coming along, going through the usual debugging and cleaning up...

A few things popped up and I thought I'd ask for pointers.

Before that... how do I make two AI sides on the same team?
I tried teamname=x for both, didn't work.

Heh nevermind, apparently I made a typo. It works, I got them to be allies and stop killing each other.

First off, what is the format for assigning traits to pre-placed units?
For example...

Code: Select all

[unit]
	type=Orcish Leader
	description=Stuk'Moj
	x,y=8,8
	[/unit]
Creates an orcish leader at 8,8.

How do I give him traits, such as loyalty, resilence, et cetera? I don't know what the syntax is. (I tried trait= and traits= to no avail)
I tried looking it up in other campaigns, couldn't find it...
Is it even possible? I should hope so.
And if not... why not?

Secondly...
How do you tell AI to stand still?

God... again nevermind. I think I found the code to make this work, and found the code to give them traits and make them stand still both in the Ford of Abez scenario.
Wow this is awesome... is there a limit to how many times you can assign traits to a unit?
I've stacked STRONG 4 times and it worked... I don't intend to go past giving them the normal two traits, but I am curious. Is there a limit?

I just thought I'd leave my findings here in case anyone else ever needed to ask those questions, rather than deleting them. *shrug*



And now something I actually couldn't find...

How do you tell the AI to run to a hex instead of moving to attack your units?
toms tried it with the following code:

Code: Select all

[ai]
		recruitment_pattern=fighter,healer,archer
		aggression=0.4
		village_value=0.3
		caution=0.4
		[leader_goal]
		x,y=50,14
		[/leader_goal]
		[protect_leader]
		radius=1
		value=0.7
		[/protect_leader]
[/ai]
But that didn't work, they still moved to attack my units anyways.

Actually, while I'm asking. Where can I find the definitions for the values given to 'aggression', 'village_value', and 'caution'?
Like... what exactly does .4 mean and how different is it from .7 or .2? Where would I look that up?
"A wise man speaks when he has something to say. A fool speaks when he has to say something."
SmokemJags
Posts: 580
Joined: February 14th, 2006, 3:24 am
Location: New Avalon
Contact:

Post by SmokemJags »

My campaign requires you to hunt down a few elves before they reach a certain hex and 'escape' off the map.

If I wanted to give them a trait that slows them down so they're easier to hunt down..

Code: Select all

#define TRAIT_WEARY
	[trait]
	id=weary
	name= _ "weary"
		[effect]
		apply_to=movement
		increase=-2
		[/effect]
	[/trait]
#enddef
Would this be the correct trait to add to my traits.cfg file.
And if so...
Would it become a trait that can be normally and randomly assigned when recruiting units?
That would be a problem. :shock:
Is there a way to make this trait not do that, to limit it to this campaign only and limit it so that it doesn't become an option in the random trait pool?

Maybe make a file called 'traits' in my Unnatural Corruption util folder...
Would that work?




Another solution I can think of... make 'special' units that are identical to the ones that normally exist, but reduce their movement in their cfg files.
I kinda would like to play with the traits though because it would allow me to experiment with other various traits, but also limit them to this campaign.
"A wise man speaks when he has something to say. A fool speaks when he has to say something."
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

[leader_goal] should force the leader to go to a given area.

To place a unit with traits, use {TRAIT_RESILENT},{TRAIT_INTELLEGENT},{TRAIT_STRONG},{TRAIT_QUICK}.
But if the unit is a leader, you create a [side.

Ai configuration: This is pretty much.
village_value=betwen 0 and 1, how much should the ai try to get villages
aggression=between 0 and 1(more makes not much sense), and with more aggression the ai tries more things. (less cowardly at fightning, but also at capturing villages)
the quite opposite is caution. The default number is 0.25. With more, he will not try risks.
leader_value= how much the ai tries to attack/kill leaders. I´m not sure, but it´s normal between 1 and 5.
time_of_day= When you start with this, you can write an own ai for each time of the day, but then you have to put each of them in seperate ai tags.
[protect_location] You give a x and an y number, a raadius and value=...
To make the leader not running out of his castle, use passive_leader=yes.

If you want the ai to recruit more archers and healers (example) than fighters, use this:
recruitment_pattern=archer,healer,archer,healer,fighter
To find out what kind of unit a unit is, look at its cfg file and usage=. There you will find fighter,archer,mixed_fighter (not sure if the underscore is right),healer and scout.
First read, then think. Read again, think again. And then post!
SmokemJags
Posts: 580
Joined: February 14th, 2006, 3:24 am
Location: New Avalon
Contact:

Post by SmokemJags »

[leader_goal] should force the leader to go to a given area.
The Ranger attacking my units seems to think otherwise. Sorry. :P

Thx for the info on aggression, village value, caution.
The default values for all three are .25?

I haven't seen leader_value yet, but I'll keep that in mind.

time_of_day...
so with that you can tell an AI to be .9 aggressive at night but .1 aggressive during the day?
Can you post an example of what that code looks like within the AI brackets?

I'll remember passive leader, that will come into play further down the road.
Yea I understand how the recruiting priority works, thx anyways.
"A wise man speaks when he has something to say. A fool speaks when he has to say something."
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

No, only the caution default is 0.25. The others, I think are 0.5.

time_of_day:Exactly what you said.
To make the ai 0.9 aggressive atnight and 0.1 at day:
[ai]
time_of_day=morning
aggression=0.1
[/ai]
[ai]
time_of_day=afternoon
aggression=0.1
[/ai]
[ai]
time_of_day=dusk
aggression=0.5
[/ai]
[ai]
time_of_day=first_watch
aggression=0.9
[/ai]
[ai]
time_of_day=second_watch
aggression=0.9
[/ai]
[ai]
time_of_day=dawn
aggression=0.5
[/ai]
(i gave him 0.5 at neutral time)
First read, then think. Read again, think again. And then post!
SmokemJags
Posts: 580
Joined: February 14th, 2006, 3:24 am
Location: New Avalon
Contact:

Post by SmokemJags »

The scenario is coming together very nicely but...

It really needs to be have the elves (leader and normal units) run to hex 50,14 and not have them attacking the player...

[leader_goal]
Isn't working. I tried putting a town at 50,14. AI still uses the ranger leader to attack my troops rather than heading for the hex.

Anyone know how that might be done?
I checked the only scenario I can think of 'Liberty1' and that also uses the leader goal code...

In my campaign it currently looks like...

Code: Select all

	[ai]
		recruitment_pattern=fighter,healer,archer
		[leader_goal]
		x,y=50,14
		[/leader_goal]
		[protect_leader]
				[filter]
				description=Elóndra
				[/filter]
				radius=1
				value=1
		[/protect_leader]
	[/ai]
Right now.

It would be nice to have the individual units also run to this hex, but I can live without that feature.
I do really need the leader to head that way though, so any help would be welcome.
Last edited by SmokemJags on March 18th, 2006, 7:48 am, edited 2 times in total.
"A wise man speaks when he has something to say. A fool speaks when he has to say something."
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

SmokemJags wrote:Anyone know how that might be done?
Yep. I'll get to it when I get back, in 5 or so hours, unless someone else already has by then.
SmokemJags
Posts: 580
Joined: February 14th, 2006, 3:24 am
Location: New Avalon
Contact:

Post by SmokemJags »

Awesome, I'll be looking forward to that. 8)
Everything else in the first scenario is complete, including testing difficulty levels.

Once I have this final piece, it's on to the next scenario! :D
"A wise man speaks when he has something to say. A fool speaks when he has to say something."
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

Well, my hobbies took more time than I thought. Now, let's see, stay tuned...

I don't think there's a hard limit on the number of traits.
SmokemJags wrote:How do you tell the AI to run to a hex instead of moving to attack your units?
This is a bit tricky. [leader_goal] only works for leaders, and it's not at all reliable. The leader might not attempt to move there immediately, but only at some point, and it probably won't take big risks to attempt that either. But luckily, there's a new feature which allows you to force an AI unit's movement. This might not work in 1.1.1 (I recall there was a bug in the implementation), but in SVN it should work (and in the 1.1.2 version, too, whenever that comes out).

You can set the coordinates where you want a unit to go to that unit's unit variables goto_x and goto_y. It works exactly like setting your own unit to move to a destination that takes longer than one turn to reach - the unit will move along that set path in the beginning of the player's turn. So, in order to set an AI unit on a course to a destination you want, put something like this in an event:

Code: Select all

{MODIFY_UNIT description=Joe goto_x 18}
{MODIFY_UNIT description=Joe goto_y 4}
That would make Joe, in the beginning of it's side's next turn, attempt to move to 18,4. The macro is from the WML Utilities page. If you don't feel like setting all the AI units (if there are plenty or a variable amount) to try to cluster up to the same destination (which might be what you want, though), you might want to use the [ai] parameters to make them a bit more pacifistic.
SmokemJags wrote:Actually, while I'm asking. Where can I find the definitions for the values given to 'aggression', 'village_value', and 'caution'?
Like... what exactly does .4 mean and how different is it from .7 or .2? Where would I look that up?
The AiWML page would be a good start.
SmokemJags
Posts: 580
Joined: February 14th, 2006, 3:24 am
Location: New Avalon
Contact:

Post by SmokemJags »

I've always hated macros... heh.
I can't really tell if I've done it right and it's not working because it's 1.1.1 or because I've done something wrong.

I'll probably just come back to this once 1.1.2 comes out and try getting it working there.

Just to see if I'm doing it right...
I added:

Code: Select all

{@campaigns/Unnatural_Corruption/utils/macros.cfg}
to the campaign cfg file as well as the 1turncoat.cfg scenario file.

I put the modify unit code inside of the opening dialogue event.

Code: Select all

		{MODIFY_UNIT description=Elóndra goto_x 50} 
		{MODIFY_UNIT description=Elóndra goto_y 14}
		
		[message]
			description=Elóndra
			message= _ "You are a most honorable orc, Muk'Itter.  Perhaps we shall meet again."
		[/message]
And I cut and pasted

Code: Select all

#define MOVE_UNIT FILTER TO_X TO_Y
    [store_unit]
        [filter]
            {FILTER}
        [/filter] 
        variable=MOVE_UNIT_temp
        kill=no
    [/store_unit]
    [scroll_to]
        x=$MOVE_UNIT_temp.x
        y=$MOVE_UNIT_temp.y
    [/scroll_to]
    [hide_unit]
        x=$MOVE_UNIT_temp.x
        y=$MOVE_UNIT_temp.y
    [/hide_unit]
    {VARIABLE_OP x_coords format ("$MOVE_UNIT_temp.x|,{TO_X}")}
    {VARIABLE_OP y_coords format ("$MOVE_UNIT_temp.y|,{TO_Y}")}
    [move_unit_fake]
        type=$MOVE_UNIT_temp.type
        x=$x_coords
        y=$y_coords
    [/move_unit_fake]
    [teleport]
        [filter]
            {FILTER}
        [/filter]
        x,y={TO_X},{TO_Y}
    [/teleport]
    [unhide_unit][/unhide_unit]
    [redraw][/redraw]
#enddef
Into a file called macros.cfg in the utils folder.
"A wise man speaks when he has something to say. A fool speaks when he has to say something."
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

You don't need the MOVE_UNIT macro in your macros.cfg, you need the MODIFY_UNIT.

You can test whether this works in your 1.1.1 by setting the goto_x and goto_y on one of the player-controlled units, instead of an AI-controlled one. If your own unit is set on the path correctly, then it's just that you need to wait for the 1.1.2 version. If setting the destination that way doesn't work even for human-controlled units, then there's a bug in your WML somewhere.
SmokemJags
Posts: 580
Joined: February 14th, 2006, 3:24 am
Location: New Avalon
Contact:

Post by SmokemJags »

This one then?

Code: Select all

[macros]
# MODIFY_UNIT alters a unit variable (such as unit.x, unit.type,
# unit.side), handling all the storing and unstoring.
#
# Example that flips all spearmen to side 2:
# {MODIFY_UNIT type=Spearman side 2}
#define MODIFY_UNIT FILTER VAR VALUE
    [store_unit]
        [filter]
            {FILTER}
        [/filter]
        variable=MODIFY_UNIT_store
        kill=yes
    [/store_unit]
    {FOREACH MODIFY_UNIT_store MODIFY_UNIT_i}
        [set_variable]
            name=MODIFY_UNIT_store[$MODIFY_UNIT_i].{VAR}
            value={VALUE}
        [/set_variable]
        [unstore_unit]
            variable=MODIFY_UNIT_store[$MODIFY_UNIT_i]
            find_vacant=no
        [/unstore_unit]
    {NEXT MODIFY_UNIT_i}
    {CLEAR_VARIABLE MODIFY_UNIT_store}
#enddef

[/macros]
That's the entire macros.cfg

This is what I put into the scenario.cfg

Code: Select all

		{MODIFY_UNIT type=Orcish Archer goto_x 50} 
		{MODIFY_UNIT type=Orcish Archer goto_y 14}
That should send all orcish archers to that location, but it didn't work.
Must be a bug as you said.

Where is a good place to put the event that triggers giving these units the order to head to that location? I want them to head in that direction from the very start of the scenario, so I put it into

Code: Select all

[event]
	name=start
...
[/event]
Along with some dialogue and other stuff like unit teleporting.
Last edited by SmokemJags on March 18th, 2006, 11:58 pm, edited 3 times in total.
"A wise man speaks when he has something to say. A fool speaks when he has to say something."
User avatar
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

Post by turin »

Uh.... why do you have [macros] and [/macros] around the stuff in your macro.cfg file? :? Those aren't WML tags. If you delete them, it should work.
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm
SmokemJags
Posts: 580
Joined: February 14th, 2006, 3:24 am
Location: New Avalon
Contact:

Post by SmokemJags »

Took out the [macro] tags
I thought it was like
[story] and [/story] tags in the story.cfg.

Orcish Archer still without movement orders though.

Tried

Code: Select all

		{MODIFY_UNIT description=Flichter goto_x 50} 
		{MODIFY_UNIT description=Flichter goto_y 14}
For the individual unit as well, neither makes him budge.
"A wise man speaks when he has something to say. A fool speaks when he has to say something."
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

SmokemJags wrote:

Code: Select all

      {MODIFY_UNIT type=Orcish Archer goto_x 50}
      {MODIFY_UNIT type=Orcish Archer goto_y 14}

That should send all orcish archers to that location, but it didn't work.
Must be a bug as you said.
That definitely doesn't work, as you're giving the macro 4 arguments instead of 3. Try "(type=Orcish Archer)" instead of "type=Orcish Archer".
SmokemJags wrote:Where is a good place to put the event that triggers giving these units the order to head to that location? I want them to head in that direction from the very start of the scenario, so I put it into

Code: Select all

[event]
   name=start
...
[/event]
Better put it into a new turn or side turn event, so that the destination gets updated (to the same one) every turn, in case they get cleared somehow.
Post Reply