Knuckle Cracker

Creeper World 3 => The Coder's Corner => Topic started by: wolkiewicz on July 17, 2015, 04:12:10 AM

Title: Spore targeting
Post by: wolkiewicz on July 17, 2015, 04:12:10 AM
Ok, two questions here:
1. Can I set something to target spore?
2. I wrote simple code:
$count:1
$payload:200
$del:1800

once
SetTimer0(5400)
endonce

if(GetTimer0 eq0)
CurrentCoords RandUnitCoords <-count <-payload CreateSpore
<-count 1 add ->count
<-del Delay
endif


And every spore target the same unit. How can I fix that?
Title: Re: Spore targeting
Post by: Tyler21 on July 17, 2015, 05:16:39 AM
1. No. Unless you create a spore-like CRPL core (see custom spore, check Grayzzur's maps (http://knucklecracker.com/forums/index.php?topic=14650.0))

2. Do you intend to launch an increasing number of spores or one spore every minute which increases in its health? Your script does the latter (the former can be achieved by the below loop). However, I have no clue here why separate RandUnitCoords calls result the same target. They shouldn't necessarily if there are multiple valid targets.


(I forgot that the n1 argument in the CreateSpore function defines its health, not the spore count. The var name <-count totally confused me :) )

2. Your code creates <-count number of spores and launches all of them at a RandUnitCoords coordinate. In order to launch multiple spores at different coordinates you have to implement a do loop.
For instance:
<-count 0 do
CurrentCoords RandUnitCoords 1 <-payload CreateSpore
loop

Note that in a do loop the limit comes first and the starting index is the second argument. Also note that the loop stops when the index reaches the limit, that is, <-count in your case. So the last index for which the script is executed is <-count -1. That's why you have to set 0 as the starting index (and not 1).


Title: Re: Spore targeting
Post by: warren on July 17, 2015, 05:29:16 PM
Several people have created custom spores (including myself). I would be shocked and appalled if there were no good examples on the wiki.

Also, your code will not likely malfunction the way Tyler21 predicts as the RandUnitCoords is inside your loop. However, I would be surprised if your code launched more than one spore as written.
Title: Re: Spore targeting
Post by: Tyler21 on July 17, 2015, 06:33:34 PM
Sorry, it's my bad, I corrected my original post.