HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Unit within Range can't use variables?

01-04-2004, 01:42 AM#1
BladeBezerker
Hmm, I need to use variables for the event 'Unit - unit within range', but for some reason, the variables that I have made don't show up (can't be selected). I really need to use variables for this, so can someone help me? Or find a way around this? Please help!
01-04-2004, 02:42 AM#2
Grater
Are you using the right type of variables?
01-04-2004, 02:52 AM#3
Extrarius
There really isn't a way to do variables for this that is efficient.
01-04-2004, 03:10 AM#4
Quell
Code:
Add Event
    Events
        Unit - A unit enters ChooseUnit <gen>
    Conditions
    Actions
        Set myUnit = (Entering unit)
        Trigger - Add to In Range <gen> the event (Unit - A unit comes within 256.00 of myUnit)

Should work. By the way, you cannot use variables in events as far as I know.
01-04-2004, 03:24 AM#5
FyreDaug
Use UMSWE to add the part of the function, it will allow you to select a variable.
01-04-2004, 03:26 AM#6
BladeBezerker
Hmm, I'm not really understanding. What I want is to pick any random enemy unit on the map, when your hero comes within range of it, it does a spell. How would I do this?
01-04-2004, 03:29 AM#7
Grater
Oh oops sorry for my earlier ignorant reply. First create the trigger with the conditions and actions required - this trigger has no event.

Then make another trigger to add the specific unit event to the first trigger, the action will look like this:

Trigger - Add to Unit comes in range <gen> the event (Unit - A unit comes within 256.00 of MyUnitVariable)
01-04-2004, 05:04 AM#8
Quell
Quote:
Originally posted by BladeBezerker
Hmm, I'm not really understanding. What I want is to pick any random enemy unit on the map, when your hero comes within range of it, it does a spell. How would I do this?

I'm not really sure what you mean by "does a spell" but anyway...
Code:
Random Unit
    Events
        Time - Elapsed game time is 0.00 seconds
    Conditions
    Actions
        Unit Group - Pick every unit in (Random 1 units from (Units owned by Player 1 (Red) matching (((Picked unit) belongs to an enemy of Player 1 (Red)) Equal to True))) and do (Actions)
            Loop - Actions
                Set myUnit = (Picked unit)
        Trigger - Add to In Range <gen> the event (Unit - A unit comes within 256.00 of myUnit)



In Range
    Events
    Conditions
    Actions
        Game - Display to (All players) the text: myUnit in range of ...