Knuckle Cracker

Creeper World 3 => The Coder's Corner => Topic started by: Tyler21 on March 03, 2015, 12:15:49 PM

Title: Core CRPL that is triggered by runners
Post by: Tyler21 on March 03, 2015, 12:15:49 PM
Greetings!

I am close to fininshing my first map, but my skills in CRPL are still very poor, so I want to ask your help.
I'd like to create a core that can detect nearby runners and will execute further commands upon detection. Something similar to the IsCreeperInRange command.
I have already searched this forum but could not find anything useful and I assume that there is no built-in command for that. Do you have any suggestions how to implement this? Is there a way to identify unique runners instead of the runner nests? Or are the runners hard-coded?

Thanks!

p.s. I just registered today and this is my first post on the CW forum ever, even though I am a huge fan of CW since 2009.
Title: Re: Core CRPL that is triggered by runners
Post by: warren on March 03, 2015, 03:19:55 PM
Runners count as units. You can use GetEnemyUnitsInRange to see them then filter using GetUnitType. As units, you can track them individually by memorising their unit ID.

Edit: if they don't show up in GetEnemyUnitsInRange, they will with GetAllUnitsInRange.

Here is a quick code. May contain bugs:


CurrentCoords 8 FALSE GetAllUnitsInRange 0 do
  ->unit
  <-unit GetUnitType "RUNNER" eq if
    @activate
  endif
loop
Title: Re: Core CRPL that is triggered by runners
Post by: Tyler21 on March 03, 2015, 04:23:02 PM
Thanks for the quick reply! It works perfectly!