• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Unsolved] Problem with a trigger

Status
Not open for further replies.
Level 8
Joined
Jan 16, 2008
Messages
156
Hi everyone,

I'm helping out a bit with a SC2 map and created a trigger for an extension mod that would go through melee maps and make every base have a single gas (ie delete one of the gas geysers).

I've spent a bit of time on it and it doesn't work properly, it seems to randomly delete geysers. I'm sure there is a bug somewhere I am not seeing, so I'd appreciate if someone else would look it over:

Code:
Gas Delete
    Events
        Game - Map initialization


    Local Variables
        Gas = (Empty unit group) <Unit Group>
        GasIndex = 0 <Integer>
        GasUnit = No Unit <Unit[100]>

    Conditions

    Actions
        Unit Group - Pick each unit in (Vespene Geyser units in (Entire map) owned by player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount) and do (Actions)
            Actions
                Unit Group - Add (Picked unit) to Gas
                Variable - Set GasIndex = (GasIndex + 1)
                Variable - Set GasUnit[GasIndex] = (Picked unit)

        Unit Group - Pick each unit in (ProtossVespeneGeyser (Unknown) units in (Entire map) owned by player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount) and do (Actions)
            Actions
                Unit Group - Add (Picked unit) to Gas
                Variable - Set GasIndex = (GasIndex + 1)
                Variable - Set GasUnit[GasIndex] = (Picked unit)

        Unit Group - Pick each unit in (PurifierVespeneGeyser (Unknown) units in (Entire map) owned by player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount) and do (Actions)
            Actions
                Unit Group - Add (Picked unit) to Gas
                Variable - Set GasIndex = (GasIndex + 1)
                Variable - Set GasUnit[GasIndex] = (Picked unit)

        Unit Group - Pick each unit in (ShakurasVespeneGeyser (Unknown) units in (Entire map) owned by player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount) and do (Actions)
            Actions
                Unit Group - Add (Picked unit) to Gas
                Variable - Set GasIndex = (GasIndex + 1)
                Variable - Set GasUnit[GasIndex] = (Picked unit)

        Unit Group - Pick each unit in (Vespene Geyser (Space Platform) units in (Entire map) owned by player Any Player matching Excluded: Missile, Dead, Hidden, with at most Any Amount) and do (Actions)
            Actions
                Unit Group - Add (Picked unit) to Gas
                Variable - Set GasIndex = (GasIndex + 1)
                Variable - Set GasUnit[GasIndex] = (Picked unit)

        General - Pick each integer from 1 to GasIndex, and do (Actions)
            Actions
                Unit Group - Pick each unit in Gas and do (Actions)
                    Actions
                        General - If (Conditions) then do (Actions) else do (Actions)
                            If
                                (Picked unit) != GasUnit[(Picked integer)]
                                1 <= (Distance between (Position of (Picked unit)) and (Position of GasUnit[(Picked integer)])) <= 100
                            Then
                                Unit Group - Remove GasUnit[(Picked integer)] from Gas
                                Unit - Remove GasUnit[(Picked integer)] from the game
                            Else

The idea here is to pick every geyser and add it to a unit group, and also index every geyser in an array. Then I loop through every indexed gas geyser in the array and for each indexed gas geyser I loop through all the units in the gas unit group. If the geysers aren't the same (the indexed geyser isn't the same unit as one picked in the unit group) and are within a certain distance, it deletes one of them.

Thanks for any and all info.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
100 is a massive distance, with the biggest maps only being 256*256. There will almost always be more than 1 base within 100 radius of a geyser. Try with a smaller distance, such as 16, which may still bug on some team maps.

Alternatively instead of removing both geysers you could adjust their resource rate to act like 1.
 
Status
Not open for further replies.
Top