Knuckle Cracker

Creeper World 3 => The Coder's Corner => Topic started by: SnowGoem on March 25, 2018, 07:32:39 PM

Title: Coding Help (random enemy units)
Post by: SnowGoem on March 25, 2018, 07:32:39 PM
Hey, is there a way to get the coordinates for a random enemy unit? I have looked and cannot find anything for that.
Title: Re: Coding Help (random enemy units)
Post by: GoodMorning on March 25, 2018, 08:36:34 PM
There isn't a single command. This will probably do something similar...


:RandEnemy #[ - UID]
    0 0 9999 GetEnemyUnitsInRange ->Count #All enemies
    0 <-Count RandInt ->Selection #Pick the "selection"-th enemy

    <-Count 0 do #Clear the rest of the stack
        <-Selection I eq if
            ->Pick #Save the chosen unit UID
        else
            pop #Discard everything else
        endif
    loop
    <-Pick #Return


http://knucklecracker.com/wiki/doku.php?id=crpl:docs:getenemyunitsinrange