Knuckle Cracker

Creeper World 3 => The Coder's Corner => Topic started by: DeSangre on October 11, 2017, 02:05:44 AM

Title: DestroyAllEnemyUnits help
Post by: DeSangre 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
Title: Re: DestroyAllEnemyUnits help
Post by: GoodMorning 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:


:destroyed
    0 DestroyAllEnemyUnits
Title: Re: DestroyAllEnemyUnits help
Post by: DeSangre on October 11, 2017, 12:49:52 PM
Thanks GoodMorning, I'm so dumb lol! :(