Trigger trouble - what's wrong with this?

Users who are viewing this thread

Khalid ibn Walid

Sergeant Knight at Arms
OK, I've been having some serious trigger troubles the last couple of days. I'm at the end of my tether, so I could really use some help here:

Here's the setup: I've got three abbeys (Leno, Bobbio, Nonantola, under the constants of "brother_towns"). The game starts off with the abbey hospices empty. In the course of the first day, there is a trigger which selects one abbey, places a pilgrim in the abbey hospice awaiting an escort. When you find her & agree to escort her, the abbey_pilgrims_active turns to 1, a "pt_abbey_pilgrims" (= abbey_pilgrims_id) is generated which you then escort to the destination.

The debate about the destination, the escorting, etc. is all done & works.

The problem I'm having is abbey selection to place the pilgrim in the hospice. I wrote up the following trigger text:

(0.5, 0, 0.0, [[store_num_parties_of_template, reg(2), "pt_abbey_pilgrims"], [lt,reg(2), 1],
[eq, "$pilgrim_at_abbey", 0],
[eq, "$abbey_pilgrims_active", 0]],
[[store_random,reg(5),num_brother_towns],
[val_add,reg(5),brother_towns_begin],
[assign, "$next_abbey", reg(5)]]),

(0.02, 0, 0.0, [[eq, "$next_abbey", "p_bobbio_abbey"],
[eq, "$pilgrim_at_abbey", 0]],
[[add_troop_to_site, "trp_bobbio_pilgrim", "scn_bobbio_hospice", 4],
[assign,"$pilgrim_at_abbey",1]
]),

(0.02, 0, 0.0, [[eq, "$next_abbey", "p_nonantola_abbey"],
[eq, "$pilgrim_at_abbey", 0]],
[[add_troop_to_site, "trp_nonantola_pilgrim", "scn_nonantola_hospice", 4],
[assign,"$pilgrim_at_abbey",1]
]),

(0.02, 0, 0.0, [[eq, "$next_abbey", "p_leno_abbey"],
[eq, "$pilgrim_at_abbey", 0]],
[[add_troop_to_site, "trp_leno_pilgrim", "scn_leno_hospice", 4],
[assign,"$pilgrim_at_abbey",1]
]),

Now, this text does select the abbey and places the pilgrim there. The problem is it doesn't seem to deactivate after that. Instead, it continues selecting more abbeys and placing pilgrims. And, of course, if two pilgrims are placed in the same abbey, we get an assertion error.

Let me be clear: I only want one pilgrim in the game. I want the hospice she's at to be random to force the player to look for her. I want no more pilgrims created in the hospices until that first pilgrim is taken care of.

["pt_abbey_pilgrims" (=$abbey_pilgrims_id) is merely the spawned pilgrims once the escorting thing is agreed to, "$abbey_pilgrims_active" is the string once the escorting is activated. ]

My trouble seems to be that "$pilgrim_at_abbey" string doesn't seem to do its job. It should start off at 0, and once the first pilgrim is placed, click to 1 and prevent the addition of more pilgrims.

Methinks it's the first line that has the problem. The conditions are continuously evaluated as true even after a pilgrim is placed.

Can anybody help?
 
I am assuming that somewhere above these triggers is a variable declaration for "$pilgrim_at_abbey"? I've had plenty of trouble with assertion errors when introducing new variables if I don't declare them first. Also, I tend to keep my minimum time to trigger fire to 1 decimal place. 0.02 time periods is awful short. These may or may not work for you, but your code looks sound to me.
 
Aha! I got around it. It seems it was fussy about the timing. If the choice of the abbey was made at 0.5, then the distpatching of the pilgrim had to be 0.52, not 0.02. I don't know why it works that way, but it does.

Yeah, the triggers are a weird file. The conditions bloc don't seem to work the same way as in the regular dialogs. With dialogs, if conditions are not met, it just forget the whole thing and moves on to the next line. With the triggers file, if conditions are not met, it seems to go into a internal debate about it and tries to do it anyway, with horrible assertion consequences.

You're right about ensuring things are defined. e.g. I've learnt to avoid putting any _id lines in the conditions bloc unless I am absolutely 100% sure that _id was created already.
 
Back
Top Bottom