Author Topic: Coding Help (random enemy units)  (Read 232 times)

SnowGoem

  • Newbie
  • *
  • Posts: 1
Coding Help (random enemy units)
« 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.

GoodMorning

  • Community Guild
  • *****
  • Posts: 3227
  • (Pusillanimous)
Re: Coding Help (random enemy units)
« Reply #1 on: March 25, 2018, 08:36:34 pm »
There isn't a single command. This will probably do something similar...

Code: [Select]
: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
A narrative is a lightly-marked path to another reality.