aliens

Author Topic: [question]Link between spawned unit and his creator.  (Read 2089 times)

Offline Nord

  • Commander
  • *****
  • Posts: 1746
  • The Gate is open.
    • View Profile
[question]Link between spawned unit and his creator.
« on: July 07, 2023, 10:24:14 pm »
Is there some way to gain attributes of shooting unit when "spawn-gun"(any weapon with "spawnUnit") is used?
My idea was to use global variable, set when gun shoot and used when unit creates. But no script hook on missing shot, as i can see.
Maybe another way?
Thanks.

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: [question]Link between spawned unit and his creator.
« Reply #1 on: July 08, 2023, 11:39:07 am »
I see that now this data is lost, but I will propagate it to spawned unit and item that it will be always available.

Offline Nord

  • Commander
  • *****
  • Posts: 1746
  • The Gate is open.
    • View Profile
Re: [question]Link between spawned unit and his creator.
« Reply #2 on: July 08, 2023, 03:45:35 pm »
That would be great.

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: [question]Link between spawned unit and his creator.
« Reply #3 on: July 17, 2023, 02:45:34 am »
In recent nightly I push change that allow tracking `previousOwner` on spawned items and units.
Now when items spawn another item, then kills done by this new items will count toward owner of first item.
For units its do not propagate this way as new unit is "self owned" but you can check in script what unit
created it.

Offline Nord

  • Commander
  • *****
  • Posts: 1746
  • The Gate is open.
    • View Profile
Re: [question]Link between spawned unit and his creator.
« Reply #4 on: July 18, 2023, 11:02:03 am »
but you can check in script what unit
created it.
How?

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: [question]Link between spawned unit and his creator.
« Reply #5 on: July 18, 2023, 04:08:53 pm »
function in script `.getPreviousOwner` in both `BattleUnit` and `BattleItem`, it get unit what created this unit/item

Offline Nord

  • Commander
  • *****
  • Posts: 1746
  • The Gate is open.
    • View Profile
Re: [question]Link between spawned unit and his creator.
« Reply #6 on: July 18, 2023, 06:31:17 pm »
Got it. Thanks.