| 08-28-2002, 12:54 AM | #1 |
Guest | Let's say I wish to make an upgrade to increase the movement speed of Knights. This post starts out as a mini tutorial, but I have a question at the end, so please skip there if you already know all this ;) I would do this by creating two new units: first, the new Knight, with a higher movement speed. I'd add the editor suffix "(faster)" to tell them apart. Also I'd create an upgrade unit which can be called anything and look like anything since it will not appear in the game. The important things for this unit are the cost, build time, and tool tips. Also choosing a spiffy interface icon wouldn't hurt. I'd then make use two triggers, something like this. --- Event: Player finishes training a unit. Cond: Unit type of trained unit = Knight Action: Replace trained unit with Knight (faster) --- Event: - Player finishes training a unit. Condition: - Unit type of Trained unit = Knight Speed Upgrade Actions: - Remove trained unit from the game. - Make Knight Speed Upgrade unavailable for player - Pick every Knight and replace each with Knight (faster) - Turn on trigger "New Knight" --- ... where the trigger "New Knight" is, of course, the name of the first trigger, which starts out disabled. Basically when this quasiupgrade finishes, we disable training additional Knight speed upgrade units, replace all our old slow knights and start a trigger watching for newly trained knights to replace. A similar way we could do it, with just one trigger is to make both types of Knights trainable at the barracks (or wherever), but start with fast knights disabled. When the upgrade unit finishes, instead of a trigger turning on another trigger, we can just disable production of "Knight (slow)" and enable production of "Knight (faster)". Both methods work well. However, since this upgrade is a unit, it's trained like one, meaning the player can queue up units to be built before or after it. Genuine Warcraft upgrades do not work like this -- instead they basically disable the whole building unit the upgrade is done, but fine, I don't have a problem with someone deciding "okay, I'll build two knights here, then next in the queue I'll put the speed upgrade, and then once that's done, build another knight." (Although to be perfectly honest, I don't even want faster knights, it's just a convenient example for the sake of this post. ;)) What the problem is, is that the player can queue up multiple Knight Speed Upgrades. Although once the first one is done, further construction of the unit will be disabled, this does not disable the ones that are already waiting in the queue. They have no effect other than wasting however much the upgrade costs, but it's a very ugly detail. I would like to know, is there a way I can disable this behavior with triggers? I was thinking of detecting a Train "Knight Speed Upgrade Unit" order and disabling the unit at the start rather than completion, and similarly detecting a Cancel order to reenable the unit once again. But, I don't see a way to detect either of these. Another approach might be to empty the building queue once the upgrade is completed, but it would be important to give a refund for any units queued up, and I have no idea how I would do this anyway. (Perhaps replacing the training structure with a new training structure of the same type? It's worth a shot...) If anyone can suggest a workaround (anything short of altering the unimportable .slk files!), please let me know. Any help is appreciated. -- Ralp (no 'H') |
| 08-28-2002, 12:57 AM | #2 |
Guest | Make a new trigger that makes it unavailable for training when they START training, rather than when they finish. EDIT: Oh wait... I'll read the whole post next time, I promise... Anyway "begins training a unit" is selectable in Player-Owned Unit Event. |
| 08-28-2002, 03:16 AM | #3 |
Guest | Right, but, how do I detect that the unit that's starting to be trained is the upgrade, and not, say, a footman? Neither Event response "Triggering Unit" nor "Trained Unit" seems to apply. |
| 08-28-2002, 11:52 PM | #4 |
Yes. The action you're looking for is called limit units by type. Either convert to custom text and find the function name or DL goldenurg's trigger thingy from this website. |
