Author Topic: DestroyAllEnemyUnits help  (Read 99 times)

DeSangre

  • Newbie
  • *
  • Posts: 11
DestroyAllEnemyUnits help
« on: October 11, 2017, 02:05:44 am »
Hello guys,
I want DestroyAllEnemyUnits to trigger when the unit in which this script is running gets destroyed.

Currently it's not working, although GetCellOccupiedCount  worked for me in other examples.
Anything I'm missing? :)

CurrentCoords GetCellOccupiedCount 1 lt if
once
DestroyAllEnemyUnits(0)
endonce
endif

GoodMorning

  • Map Maker
  • *****
  • Posts: 3031
  • (Pusillanimous)
Re: DestroyAllEnemyUnits help
« Reply #1 on: October 11, 2017, 04:02:46 am »
Well, the short answer is that after the unit is destroyed, the script is not run.

Fortunately, there's a function for exactly this:

When a unit is destroyed, it runs any :destroyed functions in attached scripts.

You will want:

Code: [Select]
:destroyed
    0 DestroyAllEnemyUnits
A narrative is a lightly-marked path to another reality.

DeSangre

  • Newbie
  • *
  • Posts: 11
Re: DestroyAllEnemyUnits help
« Reply #2 on: October 11, 2017, 12:49:52 pm »
Thanks GoodMorning, I'm so dumb lol! :(