HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Structure control trigger help

11-08-2003, 04:57 PM#1
Panto
Greetings.

I'd like to have structures change ownership to any unit that gets near them. What's a good way to accomplish this?

I can't use preplaced regions, since the structures are built during the game, so I can't use the "Unit enters region" event. Also, the "Unit comes within x of unit" also won't work unaided, since I'd have to set a variable for every structure built, and have a separate event for each variable.
11-08-2003, 05:16 PM#2
Ligature
Hey! A chance to use this cool action! Someone pointed this out I think last week... what it amounts to is you can apply all the "Specific Unit Events" to units Not pre-placed on the map.

All's you gotta do is make a unit array for these buildings. Then have triggers like this:

Trigger 0 is your trigger. Trigger 0 has no Events at all, but you pretend it will be running on Event - Unit comes within range. You do all the actions you want to happen when a unit comes within range of a building.

Trigger 1 runs on map initialization - it picks every unit on the map of your building type and adds it to the array, giving the unit a custom value that records its index in the array. For each unit that is picked it adds one to the number of units in the array. THEN it uses action "Trigger - Add New Event" to add a "Unit comes within range" to Trigger 0 For each and every unit in the array!

Trigger 2 runs when a unit enters the playable map area and the unit is of the type your building type - it adds the unit to the array and gives it a custom value that records its index in the array. It adds one to the number of units in the array. It adds a new event to trigger 0 for the unit.

Trigger 3 runs when one of your buildings dies - it removes the unit from the array and bumps all the units above it in numerical order down one, and changes all their custom values, and sets the number of units in the array down one, and sets the old final member of the array to No Unit.


I'm probably missing something and this is really rough but it should give you the basic idea. Hope it helps!
11-08-2003, 05:27 PM#3
Panto
That's absolutely excellent. Where did you hear about this originally?
11-08-2003, 05:34 PM#4
Ligature
It was way down in this thread.
11-08-2003, 08:56 PM#5
Vexorian
What about the select hero/ select unit abilities (the ones used by neutral shops) ?
11-08-2003, 09:54 PM#6
Panto
I was considering those, Lord Vexorian, but since I'm making this map in RoC and the select-unit version of that ability didn't exist then, I don't think I can use those to pull it off.
11-08-2003, 11:23 PM#7
Panto
Ligature, the one problem that I'm having adapting your trigger concept is that there are effectively two triggering units: the unit that is approaching and the unit that is being approached. How can I differentiate between these in the trigger?
11-08-2003, 11:39 PM#8
Ligature
Well, if you've got "Event - Unit comes within Range of MyUnit[n]" I think "triggering unit" is the unit that comes within range of MyUnit[n]...

As for which MyUnit has been approached, I don't think there's a function for that... you could Pick all units within X distance of triggering unit and do it that way.
11-08-2003, 11:40 PM#9
Ligature
Oh wait... RoC? I'm not even sure these actions exist outside of TFT...
11-08-2003, 11:56 PM#10
Panto
Yea... it doesn't look like enough of the right triggers do exist in RoC. I may yet have to give in and do it for TFT intead.
11-11-2003, 03:20 AM#11
Panto
So, I've still got a problem. Let's pretend I've got a trigger set up that dynamically adds events to another trigger. The events are "A unit comes within x.xx of (the building)". The trigger needs to change control of the building to the owner of the unit that comes within range.

So, if I'm using Triggering unit to describe the unit that comes within range, then I have no way to describe the building itself. But, if Triggering unit refers to the building, then I have no way to get the owner of the unit coming within range, since I can't get the unit itself.

Solutions?
11-11-2003, 12:49 PM#12
Vexorian
Unfortunnally in a xunit comes within yunit event, (triggering unit) reffers to (xunit) and there is no way to get yunit, that is really bad because with a way to know yunit I would be able to create custom auras in a very efficient way.
11-11-2003, 01:04 PM#13
Panto
Unfortunately that's more or less the impression that I got.

Aight, how about alternative ways to create the same effect? This one's pretty much on the edge of my trigger knowledge, so I'm having trouble coming up with feasible solutions.