| 08-06-2002, 12:12 PM | #1 |
I really need help with a trigger in my new Dungeon Keeper map. Look it's like this: -For example you have just built 6 barracks (can be any other building) IN GAME (so not in the world editor) -You want a unit-type (like the satyr hellcaller, so not like Summoned units, which is a classification) to go to the nearest barracks, and play it's attack animation. Does anyone know how to script this? Since the buildings are built in game i don't know how to script this since i can't use regions. |
| 08-06-2002, 12:34 PM | #2 |
Guest | Make a Unit Variable called LastBarracks. If you're placing them via triggers in the game, it's easy. Just add a line that says: Set LastBarracks=Last Created Unit Right after the action that places it. If you're constructing it via peasants, etc., then it's a tad more complicated, but still easy. Event- Player-Owned Unit Event A unit owned by (Player 1 (Red)) (Finishes constructing a structure) [Repeat that for all the players you want to possibly get attacked] Condition- Unit-Type Comparison Unit-Type of (Constructed building) is equal to (Barracks) Action- Set Variable Set LastBarracks=Constructed Building. Then just order the Satyr to walk up to LastBarracks and play the attack animation. |
| 08-06-2002, 12:38 PM | #3 |
the problem is, they are NOT placed via triggers or placed in the map editor, but just created by peasants IN-GAME, like in a melee game, and the satyrs are also trained IN-GAME, so this makes it more complicated i think. Also i don't want the satyr to walk up to the last created barracks, but to the NEAREST barracks. Anyone have any ideas? |
| 08-06-2002, 03:35 PM | #4 |
Design a trigger that detects when a Barracks is built. Save that Barracks in a variable. Since it's potentially a large number of barracks, make it an Array. (Every time the trigger runs, just increment a counter, so the game knows where to put the next barracks.) I have no idea how to check distance, but I'm almost certain it's a possibility. Then it's just a matter of determining which distance is smallest and going to that barracks, yes? |
| 08-06-2002, 05:54 PM | #5 |
Thanks for all your help guys, i've almost solved the problem except one thing. I need a region to move, and it doesn't. This is how i scripted it. Possibility 1: Trigger 1: Add building to training Event Unit-A unit owned by player 1 (red) finishes construction Condition (Unit-type of (Constructed Structure) Equal to Training Room (building in question) Action Unit Group - Add triggering unit to TrainingRoom (unit group variable) Region- Center Training Grounds <gen> on (Position of (Triggering unit)) Possibility 2: Trigger 2: Training Grounds Event Time - Every 2.00 seconds of game Condition (TrainingRoom) is Empty equal to false (TrainingRoom is the unit groop where the buildings are stored) Action Region-Center Training Grounds <gen> (region in question) on Position of Random Unit in Training Room Now why won't it work? All the other @#$%^% actions in the same triggers work, except the Region that is supposed to move. The Region properties are normal, it only has an ambient sound. Anyone know how to solve this? |
| 08-06-2002, 05:58 PM | #6 |
Try making the region a variable, (setting a region variable=training grounds then using that variable in place of training grounds) Dunno if that'll work but I know some things with regions moving are rather strange...There is a distance function in the math part so you can just go through the entire barracks array and check distances from satyr in question to barracks and pick the largest one (though with a large number of barracks or satyr this could get ugly) |
| 08-06-2002, 06:09 PM | #7 |
Keeping in mind, of course, that the CLOSEST barracks is not always the easiest one to get to. |
| 08-06-2002, 08:13 PM | #8 |
I tried everything and NOTHING is working. I even tried to create new regions upon building a structure, but this doesn't work either. THIS IS @#$%^%$#$%^&%$%^&&%%^&& ANNOYING ME! Now i have to think of an entirely new system. |
| 08-06-2002, 08:17 PM | #9 |
If you want, you could email me the map (or simply attach it) and I could take a look at it. I can't promise anything, but at least it's something. ::shrug:: |
