<- [[crpl:crplreference| CRPL reference]] <- [[crpl:crplreference#movement_commands|Movement Commands]] ===== SetTargetOffsetY ===== ^Arguments^Result^Notation^ |Y pixel offset| |''y1 -- ''| === Description === Changes where beams and snipers appear to strike without affecting target selection. This means that fake spores could be created that appear to dramatically arc through the air without the need for players to put all their beam towers at the top of the map. Offset is measured in pixels, there is eight pixels to a square. positive is in the up direction. === Examples === #External variables allowing us to determine the speed and destination of our fake spores $Tx:50 $Ty:50 $Payload:20 $Speed:1.0 #Alpha goes from 0 to 1 as the spore goes from start to end <-alpha <-step add ->alpha #When it hits one, blow up <-alpha 1 gte if TRUE ->destruct Self 1 damage endif #Precisely with pixel accuracy set the position of the spore Self CONST_PIXELCOORDX <-startX 1 <-alpha sub mul <-endX <-alpha mul add SetUnitAttribute Self CONST_PIXELCOORDY <-startY 1 <-alpha sub mul <-endY <-alpha mul add SetUnitAttribute #Calculate the height of our arc. Here we set the arc height to 100 pixels 1 <-alpha 2 mul 1 sub dup mul sub 100 mul ->height #Offset our image to the height. self "main" <-height SetImagePositionY #Offset targeting to the height. <-height SetTargetOffsetY #Change the size of the image based on the height. self "main" <-height 50 add 75 div dup SetImageScale :awake once 0 ->alpha FALSE ->destruct #These are the unit constants that absolutely must be set for this type of enemy. #You will probably want to set others as well. self CONST_TAKEMAPSPACE FALSE SetUnitAttribute self CONST_BEAMTARGET TRUE SetUnitAttribute #Calculate start and end coordinates in pixel space CurrentCoords CellToPixel ->startY ->startX <-Tx <-Ty CellToPixel ->endY ->endX <-startX <-endX sub dup mul <-startY <-endY sub dup mul add sqrt ->dist #Determine move speed based on distance and desired speed <-Speed <-dist 100 add div ->step endonce :destroyed <-destruct if #if we landed, release creeper CurrentCoords <-Payload AddCreeper "Weapons15" PlaySound else #if we did not, forget the creeper "Explosion4" PlaySound endif