HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Making Triggers 350 times?

04-24-2007, 04:04 AM#1
PsycoMarauder
Dear god guys, I'm 3/4 done with these hellishly repetitive triggers. I don't know why I didn't think of this 8 hours ago, but here are the triggers. They all work in conjunction. My problem is that I have to do this 125+ times per trigger, and I'm wondering if there is a more efficient way. Also, I was told my way will leak, and I certainly don't want that, so if you can post a more efficient and leak free version I'd love you long time.

Trigger:
Moving Killing Unit 1
Collapse Events
Unit - A unit Dies
Collapse Conditions
(Region[1] contains (Dying unit)) Equal to True
(Number of units in (Units in Region[1] matching (((Matching unit) is alive) Equal to True))) Less than or equal to 1
((Killing unit) is A structure) Equal to False
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Number of units in (Units within 512.00 of (Center of Region[1]) matching ((((Matching unit) is alive) Equal to True) and (((Unit-type of (Matching unit)) is A structure) Equal to False)))) Greater than or equal to 1
Collapse Then - Actions
Unit - Move (Random unit from (Units within 512.00 of (Center of Region[1]) matching ((((Matching unit) is A structure) Equal to False) and (((Matching unit) is alive) Equal to True)))) instantly to (Center of Region[1])
Else - Actions
If ((((Killing unit) is A structure) Equal to False) and ((All units of (Units in Region[1] matching (((Matching unit) is A structure) Equal to False)) are dead) Equal to True)) then do (Unit - Move (Killing unit) instantly to (Center of Region[1])) else do (Do nothing)


Trigger:
Changing Ownership 1
Collapse Events
Unit - A unit enters 1 <gen>
Collapse Conditions
(Number of units in (Units in 1 <gen> matching (((Matching unit) is alive) Equal to True))) Equal to 1
Collapse Actions
Unit - Change ownership of City[1] to (Owner of (Entering unit)) and Change color
Unit - Change ownership of Tower[1] to (Owner of (Entering unit)) and Change color

Trigger:
Leaving 1
Collapse Events
Unit - A unit leaves 1 <gen>
Collapse Conditions
(Number of units in (Units in Region[1] matching (((Matching unit) is alive) Equal to True))) Equal to 1
Collapse Actions
Unit - Move (Leaving unit) instantly to (Center of Region[1])
If you see any other errors, please point them out. Thanks alot guys.
04-24-2007, 08:59 AM#2
Sliderman
every time u do 'center of .....' u create a point, and this point stays in memory -> leak. You should create an array of points that u initialise.
Like this :
Collapse JASS:
local integer i = 1
loop
    exitwhen i > numberOfRegions
    set udg_centers[i] = GetRectCenter( udg_Region[i] )
endloop
And use centers[i] instead of creating a point each time.
04-24-2007, 11:49 AM#3
TheSecretArts
Woah, your trigger is kindof confusing, too many matching unit is equal to and number of matching unit and matching unit not equal too.
You could use Triggering Unit rather than Matching Unit.

What is the point of this (Number of units in (Units within 512.00 of (Center of Region[1]) matching ((((Matching unit) is alive) Equal to True) and (((Unit-type of (Matching unit)) is A structure) Equal to False)))) Greater than or equal to 1

when your trigger wont execute unless (Number of units in (Units in Region[1] matching (((Matching unit) is alive) Equal to True))) Less than or equal to 1

but then again, how big are the regions, is this like a risk game?
04-25-2007, 04:01 AM#4
PsycoMarauder
This is a risk game. Good point I, lol I don't need those conditions twice. The regions are very small, smaller than a normal circle of power. I don't know any JASS unfortunately. does your loop create a variable for each and every region? If so thats hilarious; I've manually created hundreds of variables, adding 1 each time. So as to the main point, which is manually creating each trigger over and over again, is there some jass function thing like the one posted by Slider that will automatically do each trigger?
04-25-2007, 10:52 AM#5
TheSecretArts
Create a region array and set up an init trigger that adds each region to the array and then you can loop through the array and you could have a trig like,
Trigger:
Collapse Events
A Unit enters a region
Conditions
Collapse Actions
Collapse For each integer A beteen 0 and <arraysize>, do actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Triggering Unit) is in Region[Integer A]
Collapse Then - Actions
(Your Actions Here)
Else - Actions
04-27-2007, 04:04 AM#6
PsycoMarauder
I did something similar before, however when I did the killing unit would transfer to a random region. This is caused by the interger A. Since its not specified, it will send to any region chosen for integer A. Of course, unless I missed something.
06-24-2007, 03:35 AM#7
TheSecretArts
hmm, it should move to the region... you could try move unit to position of dying / triggering unit... i think that works
06-24-2007, 04:46 AM#8
ClichesAreSt00pid
It sounds like you had used a random integer not an array.
06-24-2007, 08:40 AM#9
kharma
To do the same thing that Sliderman does in GUI -

Trigger:
Region Setup
Collapse Events
Map Initialisation
Conditions
Collapse Actions
For each (Integer A) from 0 to 349, do (Set Centres[(Integer A)] = (Centre of Regions[(Integer A)]

Centres[] is a point array and Regions is your region array. Whenever you need to do something at the centre of a region, use Centres[]. This will reduce your leaks.
06-25-2007, 12:01 PM#10
Anitarf
He would need to initialise the Regions array first, though.

This would be so much easier to do in Jass, you would just initialise a regions array and then your script could auto-generate the triggers needed. Or, with a preprocessor, you could use textmacros...

GUI sucks. Really. I can't think of a good way to do this in GUI, the best GUI way might actualy be to create 125 triggers manualy. Disastrous.
06-25-2007, 02:44 PM#11
TheSecretArts
dont even suggest using 175 triggers....
06-25-2007, 02:54 PM#12
Anitarf
No, I'm suggesting you use Jass.