[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: Problem with unit destruction trigger



On 17.01.2007 21:10, Z wrote:
> I've attached a small test map.
> 
> I was attempting to implement another idea I had that involves activating a 
> trigger when a certain enemy unit type is destroyed.
> 
> In the test map, I have two enemy (player 2) scouts. When the first scout 
> is destroyed, nothing happens. When the second scout is destroyed, the 
> event is triggered as expected.
> 
> 
> Oops. As I was writing this, I just realized it was meant to check if ALL 
> units of a type have been destroyed. A quick re-work of the map verified this.

Indeed. That's what the trigger is supposed to do.

> I wanted to use a destruction trigger to increase research capability:
> 
> Imagine a new, lone factory with nothing but infantry. The enemy finds the 
> outpost and starts to invade. The only way to gain research capability and 
> fight back effectively would be to destroy an enemy's unit. Destroy one of 
> their scouts, and your researchers would be able to dissect it and use this 
> information to produce scouts at your factory in a turn or two.
> 
> This could still be done quite easily by attaching the trigger to a 
> specific unit's destruction, but wouldn't be nearly as useful.
> 
> Would it be a huge change to make another flag for the unit destruction 
> trigger that meant "any unit of type X"?

Because of the way event triggers work (an early design flaw if you wish),
this would not work well. Trigger in CF do not test for events, they always
test for conditions. Therefore you can check "has unit X been destroyed"
or "have all units of type Y been destroyed", but not "has any unit
been destroyed" (unless all units have been destroyed...). The trigger
would have to check for an event ("unit of type Z destroyed"), but since
the trigger runs at some time after the event has occured, it cannot
check for the absence of something unless it is completely absent.
Or, trying to phrase it a little differently: If the trigger finds 2
scouts, does that mean a scout has been destroyed? You can't tell if
you don't know about the game state when the trigger last ran. Since
triggers do not keep such state, they cannot check for these things.

Jens