determine when a unit is approached

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
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

determine when a unit is approached

Post by turin »

I have a scenario in Fall of Silvium where your objective is to bring your leader adjacent to the enemy leader. Currently, I have the enemy leader be passive, and I just filter on a moveto to the hexes around him. However, this makes for irritating and unintuitive gameplay - you defeat his main force, then you have to spend five turns struggling towards him through forest, with little resistance. It would be much better if he was not passive, and instead went to the battle line and fought you.

The problem is, I don't know any way (at least, not any way that isn't really complex to program and will make the game go rather slow) to determine when a unit goes adjacent to a moving target. :? Is there any way that will take less than 1000 lines?

Another way I could do it is trigger it upon an attack event instead of a moveto event - but, if I do that, I would want the attack to never actually take place... how do you interrupt an attack upon it triggering? If I have an [endlevel] inside the [event], will the attack still proceed, or will the scenario end before the attack takes place?
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
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: determine when a unit is approached

Post by zookeeper »

turin wrote:The problem is, I don't know any way (at least, not any way that isn't really complex to program and will make the game go rather slow) to determine when a unit goes adjacent to a moving target. :? Is there any way that will take less than 1000 lines?
How about this (obviously substitute the macros with something that you use, but that part should be rather simple)? To make a version that doesn't trigger on every single moveto in the scenario, you can duplicate it to two similar events that only trigger on EnemyLeader and side 1 movetos.

Code: Select all

[event]
	name=moveto
	first_time_only=no
	
	{STORE_UNIT description=EnemyLeader}
	
	[store_locations]
		x,y=$EnemyLeader.x,$EnemyLeader.y
		radius=1
		
		[filter]
			side=1
		[/filter]
		
		variable=adjacent_to_enemy
	[/store_locations]
	
	{IF adjacent_to_enemy.length greater_than_equal_to 1 (
		[then]
			{DEBUG_MSG "Side 1 unit standing next to EnemyLeader"}
		[/then]
	)}
[/event]
User avatar
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

Post by turin »

I like being able to undo, personally. And I do view it as a rather big deal when one can't - almost a fatal flaw in a scenario...
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
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

turin wrote:I like being able to undo, personally. And I do view it as a rather big deal when one can't - almost a fatal flaw in a scenario...
Add an [allow_undo][/allow_undo] then.
Post Reply