| 07-28-2004, 09:34 AM | #1 |
ok guys, I have no experience in triggering whatsoever, besides a few tryouts. But I already ran into a problem. That was a long time ago, but it starts bugging me again. I want to create a map in which a party leader is controlled by the player (your-average-rpg style) but his fellow party members are controlled by the computer. I was using the old StarCraft workaround of creating a Region somewhere, and triggering it to reposition on the hero unit constantly. I know that is not very clean coding, but I want the computer characters to move to random locations withing that region whenever the hero moves away from them, the "follow" command is not enough. the problem now is, that while there is a condition that triggers when a unit "leaves" a region, there is no condition "unit not in region" (as far as I know). Since the repositioning of my Hero region does not count as leaving for the npcs, the "move to random location withing hero Region" order isn't triggered. The NPCs just remain standing where they are when I move my Hero away from them. help is greatly appreciated Any suggestions?? |
| 07-28-2004, 09:40 AM | #2 |
Boolean comparison - unit in region. |
| 07-28-2004, 10:28 AM | #3 |
ok, that works if I specifically select the NPC, in the condition, but I would like to create a flexible trigger, that is fired whenever a unit by player X is not in region. with boolean comparison being a condition, not an event I can not refer to any triggering units. what I'm trying to say is, I'm having difficulties selecting the units that are outside of the region. If I create an if/then/else action I cannot refer to the unit. It's impossible to get "any unit outside the region". I can only have a check if "random units owned by player 2 are in the region", but since player2 has more than one unit this doesn't help me. I need a way to specifically find out which unit is outside the region, but I can't think of anything I hope you understand what I mean |
| 07-28-2004, 11:16 AM | #4 |
Code:
Set TempUnitGroupVariable = units owned by player matching condition - owned by (Player 1) matching ((matching unit) is in (hero region) equal to false)
Unit Group - pick every unit in TempUnitGroupVariable and do actions
loop - actions:
set TempPointVariable = random point in (hero region)
order picked unit to move to TempPointVariable
custom script: call RemoveLocation( udg_TempPointVariable )
custom script: call DestroyGroup( udg_TempUnitGroupVariable )Here are a bunch of trigger actions that do what you need, done without memory leaks. There is no event, however, so you should use this in a periodic trigger (running something like every two seconds). |
| 07-28-2004, 11:49 AM | #5 |
ok that works now, but when I try to order the units to "attack-move to" (target) they endlessly keep on walking back and forth, even if they are in the region already. As if they were patroling. this doesn't happen with the normal move order I got absolutely no idea on this, it shouldn't happen i guess... |
| 07-28-2004, 02:50 PM | #6 |
you could try to use unit groups, just add all units of the party to a unit group variable, e.g. "party". then, fire a trigger that uses "pick every unit in unit group and do actions", using "party. In there you can check for every unit if it is in the hero region, if not you order it to move there. use "picked unit" to do that. |
