HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Hey Trigger Experts try this one!

05-29-2002, 08:59 PM#1
Guest
I have 4 different types of monsters.

Skeleton Red
Skeleton Blue
Skeleton Green
Skeleton Yellow.

This is the trigger I have so far.

----
Event - Unit enters Blue Region

Conditions - Unit-type of (entering unit) Equal to Skeleton Blue

Actions - Unit Order (Entering Unit) to move to Next Blue Region.
----

Now I also have a whole bunch of monsters like for example

Wolf Blue
Wolf Red
Wolf Green
Wolf Yellow

Is there ANY way to make a trigger with a condition like this (for example yellow type monsters)

Conditions - Unit-type of (entering unit) Equal to "MONSTERTYPE"+Yellow

It would be really helpful otherwise I would have to make a trigger for each and every monster which would be a pain.
05-29-2002, 09:29 PM#2
weaaddar
Use an array immy I think i could figure it out oink if you give me a whack at your map.
05-30-2002, 01:54 AM#3
Guest
Nope didn't work for me when i test.
05-30-2002, 02:28 AM#4
Guest
I would suggest trying:

Event:
Unit enters region
Condition:
Unit belongs to unit group (units in (playable map area) matching condition (unit-type of (matching unit) equal to (yellow skeleton OR unit-type equal to yellow wolf OR etc.)))
Action:
Move to such and such area

That's about the quickest way you'll probably be able to do it.
05-30-2002, 06:52 PM#5
weaaddar
Or use an array that has it be part of yellow units. In an array you could define that yellowunit[1]=yellowskele etc.
05-30-2002, 07:49 PM#6
dataangel
To elaborate on using arrays, setup a trigger like this, with a variable called "placeholder" being an integer, "placeholder" unit being some random unit on your map that isn't a skeletonyellow that you know won't die,"yellowarray" being an array of units, and numYellows being an integer with an initial value of 1:

Event
Map Initialization
Action
yellowarray[1] = placeholderunit

Event
Unit enters playable map area
Condition
Unit is of skeleton yellow
Actions
(BTW, != means does not equal)

set variable placeholder = 0

For each integer A 1 to numYellows if yellowarray[Integer A] != Unit of type skeletonyellow then set variable placeholder = Integer A

if placeholder != 0 then set variable yellowarray[placeholder] = triggering unit

if placeholder = 0 then set variable numYellows = numYellows+1
if placeholder = 0 then set variable yellowarray[numYellows] = triggering unit


Then you need another trigger like this:

Event
Unit Dies
Condition
Unit type of triggering unit is skeletonyellow
Action
For each integer A 1 to numYellows if triggering unit = yellowarray[Integer A] then set variable placeholder2 = Integer A

if placeholder2 = numYellows then set variable numYellows = numYellows - 1 else do nothing

set variable yellowarray[placeholder2] = placeholderunit


There you have it. BTW, the reason I have another placeholder integer variable is because if both triggers run at the same time you don't want it to get mixed up. Now just setup these triggers for each color type, and then when you want to see if the unit is a yellow unit, just check to see if it's in the yellow array like this:

for each integer A 1 to numYellows if triggering unit = yellowarray[Integer A] then set variable GoAheadWithTrigger = True else do nothing.

Then just put "If GoAheadWithTrigger = True" in front of all the rest of the actions in the trigger.

It may take alot of work to setup but in the end, it could save you alot of extra trigger work depending on how many colors you add and how many things they have to do.
05-30-2002, 08:05 PM#7
weaaddar
wow data angel heh I'm much too lazy to actually have showed the code but thanks for doing the work for me. Nice explanation too