Hey, got this new issue as Im not entirely sure how I should go about doing this.
At the moment I have a unit with the ability to merge with other units (simply using archon warp) and an edited ability larva -> morph (making two of the same unit). This allows me basically to make units become a single unit and split up easily. Now, when units are split (i.e. original unit dies (just like the larva or egg) and two newly made units are created (in a similar way zerglings spawn from eggs), I want the energy of the original unit to be split among the new units evenly. As for the merging, I wish to add the energy of both units together into the new unit.
I thought of using the data editor but as far Ive seen no such fields exist. So I thought about using the trigger editor. My issue with this approach is that I find it hard to check which unit uses the ability (original unit) and what units are created by that ability (is there such a preset/variable in the trigger editor?). This is because if I use as event "Unit uses ability", I still require some way to check which two units were actually created by the ability.
A more drastic solution is to create new units using the trigger editor and have the ability function as a dummy ability, the problem with this approach however is that the trigger editor creates units in such a way that they never collide with other units. I actually want this to happen, where the engine of SC2 has to figure out how to place the units and eventually push all units away (just like with the Force fields of Sentry). If it is possible to recreate this scenario using the trigger editor I think I'm set, but so far my research has been fruitless.
Did you see the event?
<<code lua>>
Unit Uses Ability
Unit: Any Unit
Ability: (No Value)
Stage: Generic1 - Any
Include Shared Abilities: Ignore
<</code>>
Yes and Ive tried something with it. My point is that Im not sure how to refer to the 'newly' created units from that ability. Once the event is triggered, the created units arent already out afaik.
Did you try storing the triggering unit in a variable? Global perhaps?
Nope,
but I'm really wondering why there isn't a built-in variable that refers to the units created using an ability. That is my only real issue as I'm not sure how to. Checking whether a unit is created isnt an option as there also other means to create the same units. Adding additional conditions such as (unit is close to this unit) also isn't, because units are completely bunched up. It really has to be a way to check what units were created using an ability. The only other options that will give the same effect if when the trigger editor allows for spawning a unit at the same position as another unit (as the create unit seems to spawn units only next to other units, and when you have many of them, they will just spawn on the outer circle, as far as Ive seen).
update
Found a way to do it trigger style. But we need to find out two new issues, 1st is finding out how to give only a part of the energy (couldnt see arithmetics mmh?) and what ability the unit should have (I did force field of sentry and oddly enough it spawns 7 units instead of just one!)
Fusion
Events
Unit - Any Unit uses Marauder - Use Stimpack at Morph14 - Abilities End stage (Include shared abilities)
Local Variables
UnitsSelected = (Selected units for player (Owner of (Triggering unit))) <Unit Group>
EnergyNew = ((Triggering unit) Energy (Current)) <Real>
Conditions
(Number of Living units in (Selected units for player (Owner of (Triggering unit)))) > 1
Actions
Unit Group - Pick each unit in UnitsSelected and do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Distance between (Position of (Triggering unit)) and (Position of (Picked unit))) <= 3.0
Then
Variable - Set EnergyNew = (EnergyNew + ((Picked unit) Energy (Current)))
Unit - Remove (Picked unit) from the game
Unit Group - Remove (Picked unit) from UnitsSelected
Else
Unit - Remove (Triggering unit) from the game
Unit - Create 1 Roach for player (Owner of (Triggering unit)) at (Position of (Triggering unit)) using default facing (Ignore Placement)
Unit - Set (Last created unit) Energy to EnergyNew
Unit Group - Add (Last created unit) to UnitsSelected
Unit Selection - Select UnitsSelected for player (Owner of (Triggering unit))
As you can see I use the marauder stimpack ability (more precisely a copy thereof) for the trigger.
My intention is that once a player has selected a group of units and clicks the ability of stimpack the following happens:
The triggering unit 'fuses' with any other unit in its direct approximity (range 3), essentially a new unit is created (roach in this case) with the energy combined of all units in its approximity + the triggering unit (basically, if triggering has 50 energy and another unit has 100 energy, the fused unit has 150 energy). The problem that I face is that the same variable is used for the whole group, essentially leading to energy out of nothing in some cases.
What do you guys propose on fixing this?
Another solution might be using 'smart cast', but I cant really find any such field in the data editor (or that looks like it). Before I totally swap over and try to look for an ability that is selfcast + smartcast, I was curious whether someone knows whether there is one? :D
The problem with your trigger is that you are initializing the EnergyNew value to the energy of the triggering unit. However, the triggering unit is part of the "UnitsSelected" group, so his energy gets added AGAIN when you do the "Pick Each Unit" loop. For that matter, "Remove Triggering Unit" is redundant, since he will already have been picked and removed, but that won't really break anything.
Initialize the variable to 0 instead and it should add up properly.
The problem with your trigger is that you are initializing the EnergyNew value to the energy of the triggering unit. However, the triggering unit is part of the "UnitsSelected" group, so his energy gets added AGAIN when you do the "Pick Each Unit" loop. For that matter, "Remove Triggering Unit" is redundant, since he will already have been picked and removed, but that won't really break anything.
Initialize the variable to 0 instead and it should add up properly.
----
Hey, thats actually a very good point haha. Damn shouldve thought the 'pick all units'- part more thoroughly :D
Thanks
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hey, got this new issue as Im not entirely sure how I should go about doing this.
At the moment I have a unit with the ability to merge with other units (simply using archon warp) and an edited ability larva -> morph (making two of the same unit). This allows me basically to make units become a single unit and split up easily. Now, when units are split (i.e. original unit dies (just like the larva or egg) and two newly made units are created (in a similar way zerglings spawn from eggs), I want the energy of the original unit to be split among the new units evenly. As for the merging, I wish to add the energy of both units together into the new unit.
I thought of using the data editor but as far Ive seen no such fields exist. So I thought about using the trigger editor. My issue with this approach is that I find it hard to check which unit uses the ability (original unit) and what units are created by that ability (is there such a preset/variable in the trigger editor?). This is because if I use as event "Unit uses ability", I still require some way to check which two units were actually created by the ability.
A more drastic solution is to create new units using the trigger editor and have the ability function as a dummy ability, the problem with this approach however is that the trigger editor creates units in such a way that they never collide with other units. I actually want this to happen, where the engine of SC2 has to figure out how to place the units and eventually push all units away (just like with the Force fields of Sentry). If it is possible to recreate this scenario using the trigger editor I think I'm set, but so far my research has been fruitless.
Any ideas?
Thanks & Greetings
Did you see the event?
@koffiegast: Go
Did you try storing the triggering unit in a variable? Global perhaps?
Nope,
but I'm really wondering why there isn't a built-in variable that refers to the units created using an ability. That is my only real issue as I'm not sure how to. Checking whether a unit is created isnt an option as there also other means to create the same units. Adding additional conditions such as (unit is close to this unit) also isn't, because units are completely bunched up. It really has to be a way to check what units were created using an ability. The only other options that will give the same effect if when the trigger editor allows for spawning a unit at the same position as another unit (as the create unit seems to spawn units only next to other units, and when you have many of them, they will just spawn on the outer circle, as far as Ive seen).
update
Found a way to do it trigger style. But we need to find out two new issues, 1st is finding out how to give only a part of the energy (couldnt see arithmetics mmh?) and what ability the unit should have (I did force field of sentry and oddly enough it spawns 7 units instead of just one!)
New issue concering the fusion of units:
Fusion
Events
Unit - Any Unit uses Marauder - Use Stimpack at Morph14 - Abilities End stage (Include shared abilities)
Local Variables
UnitsSelected = (Selected units for player (Owner of (Triggering unit))) <Unit Group>
EnergyNew = ((Triggering unit) Energy (Current)) <Real>
Conditions
(Number of Living units in (Selected units for player (Owner of (Triggering unit)))) > 1
Actions
Unit Group - Pick each unit in UnitsSelected and do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Distance between (Position of (Triggering unit)) and (Position of (Picked unit))) <= 3.0
Then
Variable - Set EnergyNew = (EnergyNew + ((Picked unit) Energy (Current)))
Unit - Remove (Picked unit) from the game
Unit Group - Remove (Picked unit) from UnitsSelected
Else
Unit - Remove (Triggering unit) from the game
Unit - Create 1 Roach for player (Owner of (Triggering unit)) at (Position of (Triggering unit)) using default facing (Ignore Placement)
Unit - Set (Last created unit) Energy to EnergyNew
Unit Group - Add (Last created unit) to UnitsSelected
Unit Selection - Select UnitsSelected for player (Owner of (Triggering unit))
As you can see I use the marauder stimpack ability (more precisely a copy thereof) for the trigger.
My intention is that once a player has selected a group of units and clicks the ability of stimpack the following happens:
The triggering unit 'fuses' with any other unit in its direct approximity (range 3), essentially a new unit is created (roach in this case) with the energy combined of all units in its approximity + the triggering unit (basically, if triggering has 50 energy and another unit has 100 energy, the fused unit has 150 energy). The problem that I face is that the same variable is used for the whole group, essentially leading to energy out of nothing in some cases.
What do you guys propose on fixing this?
Another solution might be using 'smart cast', but I cant really find any such field in the data editor (or that looks like it). Before I totally swap over and try to look for an ability that is selfcast + smartcast, I was curious whether someone knows whether there is one? :D
Thanks in advance
@koffiegast: Go
The problem with your trigger is that you are initializing the EnergyNew value to the energy of the triggering unit. However, the triggering unit is part of the "UnitsSelected" group, so his energy gets added AGAIN when you do the "Pick Each Unit" loop. For that matter, "Remove Triggering Unit" is redundant, since he will already have been picked and removed, but that won't really break anything.
Initialize the variable to 0 instead and it should add up properly.
Quote from MasterDinadan:
@koffiegast: Go
The problem with your trigger is that you are initializing the EnergyNew value to the energy of the triggering unit. However, the triggering unit is part of the "UnitsSelected" group, so his energy gets added AGAIN when you do the "Pick Each Unit" loop. For that matter, "Remove Triggering Unit" is redundant, since he will already have been picked and removed, but that won't really break anything.
Initialize the variable to 0 instead and it should add up properly.
----
Hey, thats actually a very good point haha. Damn shouldve thought the 'pick all units'- part more thoroughly :D
Thanks