I'm trying to test if a specific unit enters a range of any unit in a unit group. The unit group is a group of 35 enemies that don't change (unless they die) but the single unit is constantly being created and destroyed, but there is only ever one in the game, so I figured a variable was the way to go. You press space, it creates a unit and then sets that unit to the variable of type 'Unit' with the name 'Missile' and this works perfectly fine.
My problem is that when I try to put in 'Unit - Any Unit Enters a distance of 0.5 from Missile' it doesn't allow the 'Missile' part, it will only take a value or a function, not a variable. The variable is global and works in the first slot and in all other triggers and actions.
Can someone explain this to me, direct me to somewhere that explains it or give me a work-around/fix for this?
I haven't used custom script much, if at all, so I'm not quite sure how to implement what you're suggesting.
I tried putting in a 'Custom Script' into the 'Initialisation' function with 'TriggerAddEventUnitRange(gt_KillEnemy, null, gv_missile, 0.5, true);' as the script.
It compiles and runs but it still doesn't seem to do anything I've told it to do in the trigger.
Do unit comes within range of unit type of missile.
Also, to make this work:
TriggerAddEventUnitRange(gt_KillEnemy, null, gv_missile, 0.5, true)
globaltrigger_KillEnemy has to be gt_TheTriggerNameYouHaveWithoutSpaces
Also, can you paste the triggers accociated with the problem?
I can't make it do 'Unit comes within range of unit type of missile' because that returns a type when it's asking for a unit.
The trigger is called 'Kill Enemy' so 'gt_KillEnemy' is right, right?
Shoot
Events
UI - Player 1 presses Space key Down with shift Allow, control Allow, alt Allow
Local Variables
Conditions
Shot Fired == false
(Viking (Fighter Mode) [32.00, 16.00] is hidden) == false
Actions
Unit - Create 1 Missile for player 1 at (Position of Viking (Fighter Mode) [32.00, 16.00]) facing 90.0 degrees (No Options)
Variable - Set Missile = (Last created unit)
General - Custom Script: TriggerAddEventUnitRange(gt_KillEnemy, null, ...
Unit - Order Missile to ( Move targeting ((Position of Missile) offset by 100.0 towards 90.0 degrees)) (Replace Existing Orders)
Variable - Set Shot Fired = true
Kill Enemy
Events
Local Variables
Conditions
((Triggering unit) is alive) == true
(Missile is alive) == true
Or
Conditions
(Unit type of (Triggering unit)) == Brood Lord
(Unit type of (Triggering unit)) == Corruptor
(Unit type of (Triggering unit)) == Mutalisk
Actions
Unit - Kill (Triggering unit)
Unit - Kill Missile
Variable - Set Shot Fired = false
Unit Group - Pick each unit in Enemies and do (Actions)
Actions
Unit - Set (Picked unit) Movement Speed to (((Picked unit) Movement Speed (Current)) + 0.075)
Not sure how to put single line breaks with this thing.
I tried putting it after setting a unit to 'Missile' and it works sometimes, but it just seems to kill random units in the group after the first few kills.
To make it return a unit type, just search for Unit Type of Unit, then select the unit type you need.
To make it spaced, do < code> and then < /code> without the spaces. Make sure you select Safe HTML on the bottom for the type of markup
@obliviron:
I meant 'TriggerAddEventUnitRange(gt_KillEnemy, null, gv_missile, 0.5, true);' is asking for a unit where it says 'gv_missile' so I can't make it accept a unit type there.
Reposting the code here.
Shoot
Events
UI - Player 1 presses Space key Down with shift Allow, control Allow, alt Allow
Local Variables
Conditions
Shot Fired == false
(Viking (Fighter Mode) [32.00, 16.00] is hidden) == false
Actions
Unit - Create 1 Missile for player 1 at (Position of Viking (Fighter Mode) [32.00, 16.00]) facing 90.0 degrees (No Options)
Variable - Set Missile = (Last created unit)
General - Custom Script: TriggerAddEventUnitRange(gt_KillEnemy, null, ...
Unit - Order Missile to ( Move targeting ((Position of Missile) offset by 100.0 towards 90.0 degrees)) (Replace Existing Orders)
Variable - Set Shot Fired = true
Kill Enemy
Events
Local Variables
Conditions
((Triggering unit) is alive) == true
(Missile is alive) == true
Or
Conditions
(Unit type of (Triggering unit)) == Brood Lord
(Unit type of (Triggering unit)) == Corruptor
(Unit type of (Triggering unit)) == Mutalisk
Actions
Unit - Kill (Triggering unit)
Unit - Kill Missile
Variable - Set Shot Fired = false
Unit Group - Pick each unit in Enemies and do (Actions)
Actions
Unit - Set (Picked unit) Movement Speed to (((Picked unit) Movement Speed (Current)) + 0.075)
Since that wasn't working, I tried a different approach.
Since it wasn't liking the variable, instead of creating and destroying the missile, I put a missile out of sight on the map which, when you hit space, is moved to the position of the unit that's shooting it and told to move in the direction it was fired. When it hits a unit, it hides the missile, creates a new missile and kills it in order to show an explosion.
I'm trying to test if a specific unit enters a range of any unit in a unit group. The unit group is a group of 35 enemies that don't change (unless they die) but the single unit is constantly being created and destroyed, but there is only ever one in the game, so I figured a variable was the way to go. You press space, it creates a unit and then sets that unit to the variable of type 'Unit' with the name 'Missile' and this works perfectly fine.
My problem is that when I try to put in 'Unit - Any Unit Enters a distance of 0.5 from Missile' it doesn't allow the 'Missile' part, it will only take a value or a function, not a variable. The variable is global and works in the first slot and in all other triggers and actions.
Can someone explain this to me, direct me to somewhere that explains it or give me a work-around/fix for this?
Thanks.
Try to create the event after you defined the variable with use of custom script. That would look something like this:
Variable - Set Missile = xyz
Custom Script: TriggerAddEventUnitRange(gt_yourTriggerThatNeedsTheEvent, null, gv_missile, 0.5, true);
I haven't used custom script much, if at all, so I'm not quite sure how to implement what you're suggesting.
I tried putting in a 'Custom Script' into the 'Initialisation' function with 'TriggerAddEventUnitRange(gt_KillEnemy, null, gv_missile, 0.5, true);' as the script.
It compiles and runs but it still doesn't seem to do anything I've told it to do in the trigger.
@SoupyTwist: Go
you have to run this custom script each time after setting the missile var to a new unit and not in map init
@obliviron: Go
I can't make it do 'Unit comes within range of unit type of missile' because that returns a type when it's asking for a unit.
The trigger is called 'Kill Enemy' so 'gt_KillEnemy' is right, right?
Shoot Events UI - Player 1 presses Space key Down with shift Allow, control Allow, alt Allow Local Variables Conditions Shot Fired == false (Viking (Fighter Mode) [32.00, 16.00] is hidden) == false Actions Unit - Create 1 Missile for player 1 at (Position of Viking (Fighter Mode) [32.00, 16.00]) facing 90.0 degrees (No Options) Variable - Set Missile = (Last created unit) General - Custom Script: TriggerAddEventUnitRange(gt_KillEnemy, null, ... Unit - Order Missile to ( Move targeting ((Position of Missile) offset by 100.0 towards 90.0 degrees)) (Replace Existing Orders) Variable - Set Shot Fired = true
Kill Enemy Events Local Variables Conditions ((Triggering unit) is alive) == true (Missile is alive) == true Or Conditions (Unit type of (Triggering unit)) == Brood Lord (Unit type of (Triggering unit)) == Corruptor (Unit type of (Triggering unit)) == Mutalisk Actions Unit - Kill (Triggering unit) Unit - Kill Missile Variable - Set Shot Fired = false Unit Group - Pick each unit in Enemies and do (Actions) Actions Unit - Set (Picked unit) Movement Speed to (((Picked unit) Movement Speed (Current)) + 0.075)
Not sure how to put single line breaks with this thing.
@Talon0815: Go
I tried putting it after setting a unit to 'Missile' and it works sometimes, but it just seems to kill random units in the group after the first few kills.
To make it return a unit type, just search for Unit Type of Unit, then select the unit type you need. To make it spaced, do < code> and then < /code> without the spaces. Make sure you select Safe HTML on the bottom for the type of markup
Shoot Events UI - Player 1 presses Space key Down with shift Allow, control Allow, alt Allow Local Variables Conditions Shot Fired == false (Viking (Fighter Mode) [32.00, 16.00] is hidden) == false Actions Unit - Create 1 Missile for player 1 at (Position of Viking (Fighter Mode) [32.00, 16.00]) facing 90.0 degrees (No Options) Variable - Set Missile = (Last created unit) General - Custom Script: TriggerAddEventUnitRange(gt_KillEnemy, null, ... Unit - Order Missile to ( Move targeting ((Position of Missile) offset by 100.0 towards 90.0 degrees)) (Replace Existing Orders) Variable - Set Shot Fired = true
Kill Enemy Events Local Variables Conditions ((Triggering unit) is alive) == true (Missile is alive) == true Or Conditions (Unit type of (Triggering unit)) == Brood Lord (Unit type of (Triggering unit)) == Corruptor (Unit type of (Triggering unit)) == Mutalisk Actions Unit - Kill (Triggering unit) Unit - Kill Missile Variable - Set Shot Fired = false Unit Group - Pick each unit in Enemies and do (Actions) Actions Unit - Set (Picked unit) Movement Speed to (((Picked unit) Movement Speed (Current)) + 0.075)
Since that wasn't working, I tried a different approach. Since it wasn't liking the variable, instead of creating and destroying the missile, I put a missile out of sight on the map which, when you hit space, is moved to the position of the unit that's shooting it and told to move in the direction it was fired. When it hits a unit, it hides the missile, creates a new missile and kills it in order to show an explosion.
Enters/ Leave Events must use a static object.... doesnt ussually like variables.
By static object I mean something that is pre-placed in the terrain editor.
What you can do is make a region. And during your game move this region around as needed.....
@SouLCarveRR: Go
Thanks, thought my game was just broken or something. I've already solved the problem though, thanks anyway.