Two little 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.
Post Reply
User avatar
Casual User
Posts: 475
Joined: March 11th, 2005, 5:05 pm

Two little questions

Post by Casual User »

Good afternoon!

In the course of a short campaign I'm writing, I've come across two problems. I decided to post them here as I don't know how to fix them.

1. Speakers and death events

In one scenario, you have to battle a lich which, when 'killed', is actually only wounded and escapes through a trapdoor.

The problem is that I'd like for the unit that did the kill to inform you that the lich is getting away. Unfortunaltely, I can't predict whether the kill would be done on attacking (use 'speaker=unit') or on defense (use 'speaker=second_unit').

One way around it is to assign passive_leader=yes, which would assure that the kill would be on attack. This is what I'm using for now, but it's a little strange as the lich just basically sits there while your men jab him with daggers and swords and never uses his strongest attack...

Can anyone think of a different way of doing it?

2. Buggy WML

There's a piece of code that I can't get to work. It's supposed to recall units in a distinct order of selection based on unit type using [role].

Basically, it's supposed to assign guard1 as a role with certain unit types in priority, recall guard1, store guard1 killing him, assign guard2 as a role, etc...

But, it doesn't work. Or, more precisely, only one guard is recalled. I have a hunch that the roles guard2 and guard3 are assigned to the same unit, but I can't figure out why.

I should mention that I use the same algorithm in two scenarios, that it works in one and not in the other...

Code: Select all

#this one works, recalling foresters and scouts for a walk in woods#
[event]
(...)
[role]
role=guard1
type=ranger_l,skirmisher_l,woodsman_l,captain_l,footman_l,forester_l,guardsman_l,scout_l,man-at-arms_l
[/role]
[recall]
side=1
role=guard1
x,y=14,15
[/recall]
[store_unit]
kill=yes
variable=guard1
[filter]
x,y=14,15
[/filter]
[/store_unit]
[role]
role=guard2
type=ranger_l,skirmisher_l,woodsman_l,captain_l,footman_l,forester_l,guardsman_l,scout_l,man-at-arms_l
[/role]
[recall]
side=1
role=guard2
x,y=16,15
[/recall]
[store_unit]
kill=yes
variable=guard2
[filter]
x,y=16,15
[/filter]
[/store_unit]
[role]
role=guard3
type=ranger_l,skirmisher_l,woodsman_l,captain_l,footman_l,forester_l,guardsman_l,scout_l,man-at-arms_l
[/role]
[recall]
side=1
role=guard3
x,y=14,16
[/recall]
[store_unit]
kill=yes
variable=guard3
[filter]
x,y=14,16
[/filter]
[/store_unit]
[role]
role=guard4
type=ranger_l,skirmisher_l,woodsman_l,captain_l,footman_l,forester_l,guardsman_l,scout_l,man-at-arms_l
[/role]
[recall]
side=1
role=guard4
x,y=16,16
[/recall]
[store_unit]
kill=yes
variable=guard4
[filter]
x,y=16,16
[/filter]
[/store_unit]
[unstore_unit]
variable=guard4
x,y=16,16
[/unstore_unit]
[unstore_unit]
variable=guard3
x,y=14,16
[/unstore_unit]
[unstore_unit]
variable=guard2
x,y=16,15
[/unstore_unit]
[unstore_unit]
variable=guard1
x,y=14,15
[/unstore_unit]
[/event]

Code: Select all

#this one doesn't work, recalling one guard against two assassins#
[event]
name=prestart
(...)
[role]
role=guard1
type=captain_l,skirmisher_l,guardsman_l,ranger_l,footman_l,man-at-arms_l,woodsman_l,scout_l,forester_l
[/role]
[recall]
side=1
role=guard1
x,y=7,14
[/recall]
[store_unit]
kill=yes
variable=guard1
[filter]
x,y=7,14
[/filter]
[/store_unit]
[role]
role=guard2
type=captain_l,skirmisher_l,guardsman_l,ranger_l,footman_l,man-at-arms_l,woodsman_l,scout_l,forester_l
[/role]
[recall]
side=1
role=guard2
x,y=8,13
[/recall]
[store_unit]
kill=yes
variable=guard2
[filter]
x,y=8,13
[/filter]
[/store_unit]
[role]
role=guard3
type=captain_l,skirmisher_l,guardsman_l,ranger_l,footman_l,man-at-arms_l,woodsman_l,scout_l,forester_l
[/role]
[recall]
side=1
role=guard3
x,y=9,13
[/recall]
[store_unit]
kill=yes
variable=guard3
[filter]
x,y=9,13
[/filter]
[/store_unit]
[unstore_unit]
variable=guard1
x,y=7,14
[/unstore_unit]
[unstore_unit]
variable=guard2
x,y=8,13
[/unstore_unit]
[unstore_unit]
variable=guard3
x,y=9,13
[/unstore_unit]
[/event]
Thanks in advance.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

Casual User wrote:Unfortunaltely, I can't predict whether the kill would be done on attacking (use 'speaker=unit') or on defense (use 'speaker=second_unit').
the wiki wrote:die this event triggers when primary_unit is killed by secondary_unit.
So there's no difference whether the kill happens on defense or offense, AFAIK.
User avatar
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

Post by turin »

Roles are not one per unit - roles with the same filter will be applied to the same unit. If you want to assign roles to a series of units, you need to assign role 1, then store role 1, assign role 2, then store role 2, assign role 3, then store role 3, etc... then, after you're done with the roles, unstore all the units, and then recall in order role 1, role 2, role 3, etc.
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
Casual User
Posts: 475
Joined: March 11th, 2005, 5:05 pm

Post by Casual User »

@Turin:

Well, if you'll read the code more carefully, that's the algorithm I'm using:
-assign role guard1
-recall guard1
-store guard1 (with kill=yes)
-assign role guard2
...
-unstore guard1
-unstore guard2
-unstore guard3

That's my whole question. The same algorithm functions in the first piece of WML, but not in the second.

There's probably a typo or something, but I can't figure out what it is for the life of me.
User avatar
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

Post by turin »

*Shrug* I dunno. I admit I didn't read the code - didn't have time.

If you want to, look at how I did it in Sceptre of Fire scenario 8 (The Dragon). I used macros, but you'll be able to piece together what I did... but you're probably right about it being just at typo.
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
Post Reply