HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Unit Types In Range...

01-05-2004, 09:04 PM#1
AntJAB
Edit: See last post by me. Thanks!

I want a player to be able to make a building.
Whenever three units of the same type (three grunts, three footmen, etc.) come within rage (300ish) of the building, actions take place.

I can't figure out for the life of me how to get the conditions and events to observe for when three units of the same type are within range.

I've run through a bunch of different set-ups, and all I've gotten now is a big head ache.


Three units of the same type are within range of another (non-preset, but specific type) building.
--depending on the type of the units, the type of the unit created will be selected--
Kill those three units.
Create new unit at random point within range of building.


Also figureing out how to do the same thing, but with three specific unit types instead of one.

Grunt, Footman, and Archer come within range of (non-preset, specific type) building.
Kill Grunt, Footman, and Archer.
Create Ghoul at random point within range of building.


Thanks.
01-05-2004, 09:17 PM#2
Kaluo
you might just have to have variables for the building and an integer to add whenever a unit enters this 300'ish range.

Untitled Trigger 005
Events
Unit - A unit enters (Region centered at (Position of Grunt 0029 <gen>) with size (300.00, 300.00))
Conditions
Actions
Set num_units_building1 = (num_units_building1 + 1)
If (num_units_building1 Greater than or equal to 3) then do (Unit Group - Pick every unit in (Units in (Region centered at (Position of Grunt 0029 <gen>) with size (300.00, 300.00))) and do (Unit - Kill (Picked unit))) else do (Do nothing)

where grunt is the building. Of course if you want this as in a tower that would be massproduced youd need several building variables and would have a lengthy trigger to run whenever such a building was completed
01-06-2004, 12:32 AM#3
AntJAB
Hmm. Here, why don't I just tell you about the map.
Undetermend number of players yet.
Working name: "Fusion War Craft"

Every race has one additional building able to be built.
Easy trigger will be set so each player can only have one of such buildings built.
The idea of the building is it has the ability to "Fuse" together three units into a stronger unit.
I was thinking, once three Grunts (for example) come close to the building, they would be "Fused" into one Super Grunt.
This may not be the way, and could get confusing for players.

Now I'm stuck for ideas on how to impliment the way of picking which units you want to fuse.

Another idea floating around is that say you get the max of three heros. Perhaps those could be fused into one amazing Super Hero. (Bad Pun.)

Hope you get the idea.
01-06-2004, 12:37 AM#4
Newhydra
You could try adding an event (unit comes within range of <whatever building was just built>) each time one of the fusing buildings is bult, though I'm not sure offhand how to get the unit which you came into range of (not the entering unit...maybe can't)
01-06-2004, 12:38 AM#5
Kaluo
that may be difficult....
If specific units spawn specific other units you may need an integer - number of units next to building and then just use an array to store the three units inside, this could be checked pretty easily as a condition
01-06-2004, 02:52 PM#6
AntJAB
I'm at school right now, or I would of checked into some of these.
The only thing I can think of that would be fullproof would take a LONG time to do.
Individual variables for each unit type.

E - Building is BUILT
C - Owner of built building = to player 1
C - Building built = to FusionBuilding
A - Move Region [player1] to center of location of building built
A - (whatever trigger to make building no longer buildable)

E - Building is DESTROYED
C - Owner of destroyed building = to player 1
C - Building destroyed = to FusionBuilding
A - Move Region [player1] to center of [safe area on map]
A - Set <p1grunt> and <p1footman> and <p1archer> and <p1ghoul> and <p1etc...> to ZERO.
A - (whatever trigger to make building buildable again)

E - Unit ENTERS region
C - region = [player1]
C - owner of unit = to player 1
A - If unit type = to Grunt, add 1 to <p1grunt>, else do nothing.
A - If unit type = to Footman, add 1 to <p1footman>, else do nothing.
A - If unit type = to Archer, add 1 to <p1archer>, else do nothing.
A - Etc...

E - Unit LEAVES region
C - region = [player1]
C - owner of unit = to player 1
A - If unit type = to Grunt, subtract 1 from <p1grunt>, else do nothing.
A - If unit type = to Footman, subtract 1 from <p1footman>, else do nothing.
A - If unit type = to Archer, subtract 1 from <p1archer>, else do nothing.
A - Etc...

E - Unit enters region
C - region = [player1]
C - onwer of unit = player 1
A - wait 0.1 seconds
A - If <p1grunt> = 3, kill 3 Grunt in [player1] and create 1 Super Grunt in [player1], else do nothing
A - If <p1footman> = 3, kill 3 Footman in [player1] and create 1 Super Footman in [player1], else do nothing
A - Etc...

Tedius, but doable.
Any thoughts?
01-06-2004, 08:47 PM#7
Kaluo
i dont think you need to have individual variables for each unit type, just have a trigger that when unit enters the region around the building run a trigger that counts units and checks unit type. Still quite a bit of work but less than what you were saying
01-06-2004, 09:28 PM#8
Grater
Ugh this isn't that hard.
Code:
Basic Trigger
    Events
        Time - Every 1.00 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in (Units of type MagicFuser) and do (Actions)
            Loop - Actions
                Set TempGroup = (Units within 300.00 of (Position of (Picked unit)) matching ((Unit-type of (Matching unit)) Equal to Footman))
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Number of units in TempGroup) Greater than or equal to 3
                    Then - Actions
                        Unit Group - Pick every unit in (Random 3 units from TempGroup) and do (Actions)
                            Loop - Actions
                                Unit - Kill (Picked unit)
                        -------- Do whatever you need to here --------
                    Else - Actions
                -------- Repeat above for Grunts and Archers --------
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Units within 300.00 of (Position of (Picked unit)) matching ((Unit-type of (Matching unit)) Equal to Footman)) is empty) Equal to False
                        ((Units within 300.00 of (Position of (Picked unit)) matching ((Unit-type of (Matching unit)) Equal to Grunt)) is empty) Equal to False
                        ((Units within 300.00 of (Position of (Picked unit)) matching ((Unit-type of (Matching unit)) Equal to Archer)) is empty) Equal to False
                    Then - Actions
                        -------- Do whatever you need to here with the ghoul --------
                    Else - Actions
That should give you the basic idea. I also want to mention how much memory that trigger leaks, lots. So later I'll post a version that doesn't leak memory (but it'll be riddled with custom script and harder to understand)
01-06-2004, 10:13 PM#9
AntJAB
Hmm, I'm only just get accustomed to real triggering.
Thanks so much, I'll start toying with that.

With multiple players, I threw in some player checks for units.

Code:
Player 1 Fusions
    Events
        Time - Every 1.00 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in (Units owned by Player 1 (Red) of type Fusion Center) and do (Actions)
            Loop - Actions
                Set TempGroup = (Units within 200.00 of (Position of (Picked unit)) matching (((Unit-type of (Matching unit)) Equal to Footman) and ((Owner of (Matching unit)) Equal to Player 1 (Red))))
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Number of units in TempGroup) Greater than or equal to 3
                    Then - Actions
                        Unit Group - Pick every unit in TempGroup and do (Actions)
                            Loop - Actions
                                Unit - Create 1 Fused Footman for (Owner of (Picked unit)) at (Position of (Picked unit)) facing (Position of (Picked unit))
                                Unit - Kill (Picked unit)
                    Else - Actions
                        Set TempGroup = (Units within 200.00 of (Position of (Picked unit)) matching (((Unit-type of (Matching unit)) Equal to Knight) and ((Owner of (Matching unit)) Equal to Player 1 (Red))))
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Number of units in TempGroup) Greater than or equal to 3
                            Then - Actions
                                Unit Group - Pick every unit in TempGroup and do (Actions)
                                    Loop - Actions
                                        Unit - Create 1 Fused Footman for (Owner of (Picked unit)) at (Position of (Picked unit)) facing (Position of (Picked unit))
                                        Unit - Kill (Picked unit)
                            Else - Actions

And then it would continue for the rest of the units.
And I'm not so clear on memory leaks.
What exactly would be wrong with it?
Would it slow the map down, skip steps...
01-07-2004, 04:58 PM#10
AntJAB
What I did was on the right track, but several problems.
Creating a unit at the location of picked units makes a unit for every picked unit.
Creating a unit at the location of (Random unit from unit group) still makes a unit for every unit in the group.
I thought range of 200 would be around the picked unit, but it is from the center of picked unit, so will simply have to make that range bigger.
I know something has to be wrong with the trigger. Works half the time, other half not. I'm sure it has a terrible layout.
Also have to incorporate researchable upgrades at Fusion Center.
Examples:
Biogenics - Allows fusion of organic units.
Engineering - Allows fusion of mechanical units.
Divine Understanding - Allows fusion of Heros.

Something else to think of instead of just making the unit near the building...
Is there a way to make a building able to train units, but hide the unit icons? Like make the Fusion Center have the ability to train the fused units, but hide the button to make them and remove their hotkeys. ( I knwo the hotkeys an be done.)
That way when three units come in range, the units die, and a trigger orders the building to start making the fused unit.
If this could be done, upgrades for faster fusions could be considered.
Catalysts - Increased organic unit fusion speed.

Thanks for the help guys.
01-07-2004, 06:18 PM#11
Shark
consider the Sacrifice ability...instead of fusing 3 units, just make that unit cost aditional 4 food and 600 gold and looong build time....that way it simulates the other 2 units that would be fused together...
my two cents....
01-07-2004, 08:06 PM#12
AntJAB
Interesting idea, but not exactly what I'm looking for. I want the player to be able to make for example three barracks and mass produce footmen, thus mass producing Fused Footmen.
Thanks for the cents. 8))
01-07-2004, 08:27 PM#13
Kaluo
you cant hide the icon to produce the fused units, you could however make each requiring a research, ie unit 'fused footman' available when you have research 'bring three footmen here' this would also make the organic/mechanic researches easier. This just wouldnt work if you needed a ton of possible fuse combos, if so you might try making different fuse buildings
01-07-2004, 11:47 PM#14
AntJAB
I was hopign to keep away from multiple building, but now that I really got thinking about them...

Unit begins being trained
unit training owned by player 1
Unit being trained equal to Fused Footman
Pick building training unit
Set <TempGroup> equal to units within 400 of picked unit with conditions:
--unit equal Footman
--unit owned by player 1
If - <TempGroup> has 3 or more units
Then - Kill 3 random units in <TempGroup>
Else - Cancle unit being trained

Once I get some time on the comp I'll test this.
You guys have been great!

Noob trigger question alert! :bgrun:
I can't find a trigger to check what the trainging unit type is.
I can check for what the unit type of the building training the unit it.
I can find the unit type of a unit after it's done training.
But not one that is mid training.
01-08-2004, 02:26 AM#15
AntJAB
Now this is frustraiting.
This could work perfectly if I could just check for type of unit being trained! :bgrun:

Code:
Footman
    Events
        Unit - A unit Begins training a unit
    Conditions
        (Unit-type of (Triggering unit)) Equal to Fusion Center
        ----This is where I need to check for type of unit being trained.----
    Actions
        Set TempGroup = (Units within 400.00 of (Position of (Triggering unit)) matching (((Unit-type of (Matching unit)) Equal to Footman) and ((Owner of (Matching unit)) Equal to (Triggering player))))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in TempGroup) Greater than or equal to 3
            Then - Actions
                Unit - Kill (Random unit from TempGroup)
                Unit - Kill (Random unit from TempGroup)
                Unit - Kill (Random unit from TempGroup)
            Else - Actions
                ----This is where I need to tell the building to stop training the unit.----

If you notice where the comments are, that's where I need help. :bgrun:

And why is it that when I hit reply it sometimes instead just adds it on tot he end of my lost post as an edit? :////