Hey guys, i have lots of trigger based missile abilities, right now i'm using create unit -> launch effect and adding thread. But there are few situations when i need get owner of a missile that was launched through data (without thread that inherit caster unit) so if i store the creator's id in missile custom value how can i reference this unit? If i will use data tables would it lag like a hell? What are your advises?
If I'm understanding you correctly, it seems like you would need to give the creator unit an ID in a custom value (or otherwise a global variable,) then set the missile's custom value to that ID. Then you can run a check like "Custom Value 1 of Missile == Custom Value 1 of Shooter" to get your match.
If, for example, the missile kills another unit and you want to add minerals for the killing player, you could do something like this (pseudo-code):
EventsAnyUnitDiesConditionsUnitTypeof(triggeringunit)==GuyWithAMissileLauncherUnitTypeof(Killingunit)==MissileVariablesKiller(unit)=(novalue)ActionsPickeachunitinUnitsofType'Guy With A Missile Launcher'inEntireMapownedbyAnyPlayeranddoActionsIfCustomValue1of(Pickedunit)==CustomValue1of(Killingunit)ThenSetKiller=(Pickedunit)Modifyplayer(OwnerofKiller)minerals:+1SendActorMessagetoKiller:PlayAnimDanceLoopForeverBreakElse
You can use the "Unit Tag" function to return a unique integer associated with a unit.
You can't access a unit by its tag without looping through all the units and checking for the correct tag, or using a data structure to store the unit in, e.g. a data table as you suggested.
There is a UnitFromId(int) function in galaxyscript, but it only works with units that were pre-placed in the editor.
Hey guys, i have lots of trigger based missile abilities, right now i'm using create unit -> launch effect and adding thread. But there are few situations when i need get owner of a missile that was launched through data (without thread that inherit caster unit) so if i store the creator's id in missile custom value how can i reference this unit? If i will use data tables would it lag like a hell? What are your advises?
@abvdzh: Go
If I'm understanding you correctly, it seems like you would need to give the creator unit an ID in a custom value (or otherwise a global variable,) then set the missile's custom value to that ID. Then you can run a check like "Custom Value 1 of Missile == Custom Value 1 of Shooter" to get your match.
If, for example, the missile kills another unit and you want to add minerals for the killing player, you could do something like this (pseudo-code):
You can use the "Unit Tag" function to return a unique integer associated with a unit.
You can't access a unit by its tag without looping through all the units and checking for the correct tag, or using a data structure to store the unit in, e.g. a data table as you suggested.
There is a UnitFromId(int) function in galaxyscript, but it only works with units that were pre-placed in the editor.
Thanks, used checking loop solution