• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Unit Problem

Status
Not open for further replies.
Level 21
Joined
Jan 5, 2005
Messages
3,515
i have a problem with killing a unit.

scenario---

a player can type -game for a game, but there is a maximum of 4 players allow to type this. when they type it a unit is spawned for them and given a number by the trigger

set MiniGameUnit[player number of (triggering player)] = (last created unit)

i then want to make that if any unit that isnt the same type of as the MiniGameUnit, comes within the estimate base area of the MiniGameUnit they are exploded.

could someone give me a trigger for this please. i have tried using the even "unit is within range" however i cannot select MiniGameUnit because it appears you cannot use variable in events.

please help asap!

many thanks, Dan

ps. working replies will get gold :) :) :)
 
Level 21
Joined
Jan 5, 2005
Messages
3,515
hmm i have a problem with that however.

im using this trigger, but for some reason MiniGameUnits[interger A] keeps getting killed instantly.

Code:
Too Close
    Events
        Time - Every 0.50 seconds of game time
    Conditions
    Actions
        For each (Integer A) from 1 to 9, do (Actions)
            Loop - Actions
                Unit Group - Pick every unit in (Units within 50.00 of (Position of MiniGameUnits[(Integer A)]) matching ((Picked unit) Not equal to MiniGameUnits[(Integer A)])) and do (Actions)
                    Loop - Actions
                        Unit - Explode (Picked unit)
                        Set Lives[(Player number of (Player((Integer A))))] = (Lives[(Player number of (Player((Integer A))))] - 1)
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                Lives[(Player number of (Player((Integer A))))] Greater than 0
                            Then - Actions
                                Game - Display to (Player group((Player((Integer A))))) the text: ((Oh No! Life lost! Only  + (String(Lives[(Player number of (Player((Integer A))))]))) +  left!!)
                            Else - Actions
                                Game - Display to (Player group((Player((Integer A))))) the text: 0 Lives Left, You L...
 
Level 12
Joined
Jan 13, 2005
Messages
1,138
I do not understand the problem, but we can discuss it on saturday unless you are up and online in the early afternoon tomarrow or friday, around my lunch time.
 
Level 21
Joined
Jan 5, 2005
Messages
3,515
its ok, it took me a while but i fixed the problem with this trigger.

Code:
Too Close
    Events
        Time - Every 0.50 seconds of game time
    Conditions
    Actions
        For each (Integer A) from 1 to 9, do (Actions)
            Loop - Actions
                Unit Group - Pick every unit in (Units within 90.00 of (Position of MiniGameUnits[(Integer A)])) and do (Actions)
                    Loop - Actions
                        Unit Group - Add (Picked unit) to MiniGameUnitGroups[((Integer A) + 2)]
                Unit Group - Remove MiniGameUnits[1] from MiniGameUnitGroups[((Integer A) + 2)]
                Unit Group - Remove MiniGameUnits[2] from MiniGameUnitGroups[((Integer A) + 2)]
                Unit Group - Remove MiniGameUnits[3] from MiniGameUnitGroups[((Integer A) + 2)]
                Unit Group - Remove MiniGameUnits[4] from MiniGameUnitGroups[((Integer A) + 2)]
                Unit Group - Remove MiniGameUnits[5] from MiniGameUnitGroups[((Integer A) + 2)]
                Unit Group - Remove MiniGameUnits[6] from MiniGameUnitGroups[((Integer A) + 2)]
                Unit Group - Remove MiniGameUnits[7] from MiniGameUnitGroups[((Integer A) + 2)]
                Unit Group - Remove MiniGameUnits[8] from MiniGameUnitGroups[((Integer A) + 2)]
                Unit Group - Remove MiniGameUnits[9] from MiniGameUnitGroups[((Integer A) + 2)]
                Unit Group - Pick every unit in MiniGameUnitGroups[((Integer A) + 2)] and do (Actions)
                    Loop - Actions
                        Unit - Explode (Picked unit)
                        Set Lives[(Player number of (Player((Integer A))))] = (Lives[(Player number of (Player((Integer A))))] - 1)
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                Lives[(Player number of (Player((Integer A))))] Greater than 0
                            Then - Actions
                                Game - Display to (Player group((Player((Integer A))))) the text: ((Oh No! Life lost! Only  + (String(Lives[(Player number of (Player((Integer A))))]))) +  left!!)
                            Else - Actions
                                Game - Display to (Player group((Player((Integer A))))) the text: 0 Lives Left, You L...

i dont know if u want any gold ralle but thanks for the help none the less :D

Ps. For anyone who is intrested or trying to leanr triggerss, here is the final of my trigger, it includes a little camera thing ive added just so im not using to many periodic time events (because that causes lag), so you can ignor those (they are right at the start).

PPs. Ralle like how well im doing with my "for each interger A" things? not bad considering i only learnt them 1 day ago :wink:

Code:
Camera and Too Close Fire Dodge
    Events
        Time - Every 0.20 seconds of game time
    Conditions
        GameChoice[1] Equal to True
    Actions
        For each (Integer A) from 1 to 9, do (Actions)
            Loop - Actions
                If (CameraLock[(Integer A)] Equal to True) then do (Camera - Lock camera target for (Player((Integer A))) to MiniGameUnits[(Player number of (Player((Integer A))))], offset by (0.00, 0.00) using Default rotation) else do (Do nothing)
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        CameraLock[(Integer A)] Equal to False
                        CameraLockU[(Integer A)] Equal to True
                    Then - Actions
                        Camera - Reset camera for (Player((Integer A))) to standard game-view over 3.00 seconds
                        Set CameraLockU[(Integer A)] = False
                    Else - Actions
                Unit Group - Pick every unit in (Units within 90.00 of (Position of MiniGameUnits[(Integer A)])) and do (Actions)
                    Loop - Actions
                        Unit Group - Add (Picked unit) to MiniGameUnitGroups[((Integer A) + 2)]
                Unit Group - Remove MiniGameUnits[1] from MiniGameUnitGroups[((Integer A) + 2)]
                Unit Group - Remove MiniGameUnits[2] from MiniGameUnitGroups[((Integer A) + 2)]
                Unit Group - Remove MiniGameUnits[3] from MiniGameUnitGroups[((Integer A) + 2)]
                Unit Group - Remove MiniGameUnits[4] from MiniGameUnitGroups[((Integer A) + 2)]
                Unit Group - Remove MiniGameUnits[5] from MiniGameUnitGroups[((Integer A) + 2)]
                Unit Group - Remove MiniGameUnits[6] from MiniGameUnitGroups[((Integer A) + 2)]
                Unit Group - Remove MiniGameUnits[7] from MiniGameUnitGroups[((Integer A) + 2)]
                Unit Group - Remove MiniGameUnits[8] from MiniGameUnitGroups[((Integer A) + 2)]
                Unit Group - Remove MiniGameUnits[9] from MiniGameUnitGroups[((Integer A) + 2)]
                Unit Group - Pick every unit in MiniGameUnitGroups[((Integer A) + 2)] and do (Actions)
                    Loop - Actions
                        Unit - Explode (Picked unit)
                        Set Lives[(Player number of (Player((Integer A))))] = (Lives[(Player number of (Player((Integer A))))] - 1)
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                Lives[(Player number of (Player((Integer A))))] Greater than 0
                            Then - Actions
                                Game - Display to (Player group((Player((Integer A))))) the text: ((Oh No! Life lost! Only  + (String(Lives[(Player number of (Player((Integer A))))]))) +  left!!)
                            Else - Actions
                                Unit - Kill MiniGameUnits[(Integer A)]
                                Game - Display to (Player group((Player((Integer A))))) for 1.50 seconds the text: 0 Lives Left, You L...
                                Dialog - Clear GameDialog
                                Dialog - Change the title of GameDialog to Play Again?
                                Dialog - Create a dialog button for GameDialog labelled Yes
                                Set GameDialog_Butt[6] = (Last created dialog Button)
                                Dialog - Create a dialog button for GameDialog labelled No
                                Set GameDialog_Butt[4] = (Last created dialog Button)
                                Dialog - Show GameDialog for (Player((Integer A)))
                                Set GamePlayers = (GamePlayers - 1)
                                Set CameraLockU[(Integer A)] = True
                                Set CameraLock[(Integer A)] = False
                                Unit Group - Remove all units of MiniGameUnitGroups[((Integer A) + 2)] from MiniGameUnitGroups[((Integer A) + 2)]
                                Set MiniGameUnits[(Integer A)] = No unit
                                Multiboard - Set the text for (Last created multiboard) item in column 2, row 14 to GameType
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        GamePlayers Equal to 0
                                    Then - Actions
                                        Countdown Timer - Pause (Last started timer)
                                        Countdown Timer - Destroy (Last created timer window)
                                        Trigger - Turn off Unit Spawn and Move <gen>
                                        Trigger - Turn off Unit Spawn and Move 2 <gen>
                                        Trigger - Turn off Unit Spawn and Move 3 <gen>
                                        Trigger - Turn off Unit Spawn and Move 3 <gen>
                                        Set Level[1] = 0
                                        Set Level[2] = 0
                                        Unit Group - Remove all units of MiniGameUnitGroups[1] from MiniGameUnitGroups[1]
                                        Unit Group - Remove all units of MiniGameUnitGroups[2] from MiniGameUnitGroups[2]
                                        Unit Group - Pick every unit in (Units in Unit Make <gen>) and do (Unit - Kill (Picked unit))
                                    Else - Actions
                                        Countdown Timer - Hide (Last created timer window) for (Player((Integer A)))
                                Game - Display to (Player group((Player((Integer A))))) for 3.00 seconds the text: 0 Lives Left, You L...
                                Trigger - Turn off (This trigger)
 
Status
Not open for further replies.
Top