It appears from intensive testing that Snipers may or may not continue to fire at moving targets (CRPL cores) that dynamically set their own CONST_SNIPERTARGET to 0 once hit. As far as I can tell this is entirely random, as some snipers won't and others will.
To verify, you have to time it so that the sniper aquires the target and fires while the target is in mid-jump. When it's "on the ground" it seems to work perfectly fine.
Or am I forgetting something fundamental about how CRPL handles
if ... else ... endif statements?
Spaghetti code below:
Spoiler
# Jumper.crpl
# Author: GameGibu
# ------------------------------------------
once
if ( IsEditMode ) ShowTraceLog endif
$Amt:20
$Interval:15
$Frequency:300
$Range:20
$Movetime:2.0
$Stuntime:150
"
" ->nl
0 ->myTime
0 ->isInJump
0 ->jumpStart
CurrentCoords ->startY ->startX
SetUnitAttribute( Self CONST_CREATEPZ 0 )
SetUnitAttribute( Self CONST_CELLWIDTH 5 )
SetUnitAttribute( Self CONST_CELLHEIGHT 5 )
SetUnitAttribute( Self CONST_SNIPERTARGET 1 )
SetUnitAttribute( Self CONST_SNIPERIGNORELOS 0 )
SetUnitAttribute( Self CONST_BEAMTARGET 1 )
SetUnitAttribute( Self CONST_MAXHEALTH 30.0 )
SetUnitAttribute( Self CONST_HEALTH 30.0 )
#SetUnitAttribute( Self CONST_HEALRATE 1.0 )
#GetUnitAttribute( Self CONST_MAXHEALTH ) Trace
SetImageScale( Self "main" 2.0 2.0 )
SetImage( Self "main" "CustomEmitter" )
SetPopupText( "Amt: " <-Amt concat <-nl concat "Interval: " concat <-Interval asfloat 30.0 div concat )
endonce
@run
:run
<-myTime 1 add ->myTime
if ( <-isInJump not <-myTime <-Interval mod eq0 and )
AddCreeper( CurrentCoords <-Amt )
endif
<-stunnedTimer 1 sub ->stunnedTimer
ClearTraceLog Trace ( "myTime = " <-myTime concat ) Trace ( "stunnedTimer = " <-stunnedTimer concat )
if ( Self CONST_HEALTH GetUnitAttribute Self CONST_MAXHEALTH GetUnitAttribute lt )
SetUnitAttribute( Self CONST_SNIPERTARGET 0 )
#SetUnitAttribute( Self CONST_BEAMTARGET 0 )
<-Stuntime ->stunnedTimer
Trace ( <-stunnedTimer )
if ( <-isInJump )
#AbortMove
SetUnitAttribute( Self CONST_SNIPERIGNORELOS 0 )
endif
endif
if ( <-stunnedTimer 0 gt )
SetText( "Stunned" )
SetUnitAttribute( Self CONST_SNIPERTARGET 0 )
SetUnitAttribute( Self CONST_HEALTH GetUnitAttribute( Self CONST_MAXHEALTH ) )
#if ( <-stunnedTimer <-Stuntime eq )
# 14 CurrentPixelCoords GetImagePositionZ( Self "main" ) 1.0 sub 2.0 2.0 1.0 <-Stuntime 30 mul div CreateEffect
#endif
else
SetText( "" )
endif
if ( <-stunnedTimer <-Stuntime 3 mul neg gt )
Trace2 ( <-Stuntime 3 mul neg <-stunnedTimer )
SetUnitAttribute( Self CONST_SNIPERTARGET 0 )
"CONST_SNIPERTARGET = " GetUnitAttribute( Self CONST_SNIPERTARGET ) concat Trace
Trace ( "Invince" )
#SetText( "" )
else
Trace2 ( <-Stuntime 3 mul neg <-stunnedTimer )
SetUnitAttribute( Self CONST_SNIPERTARGET 1 )
"CONST_SNIPERTARGET = " GetUnitAttribute( Self CONST_SNIPERTARGET ) concat Trace
Trace ( "Not Invince" )
endif
if ( <-myTime <-Frequency mod eq0 <-isInJump not and <-stunnedTimer 0 gt not and )
Trace ( "Attempting Jump..." )
RandCoordsInRange( CurrentCoords <-Range ) ->TargY ->TargX
if ( <-TargX <-TargY @IsInField <-TargX <-TargY GetVoid or )
0 ->isInJump
5 0 do
if ( <-TargX <-TargY @IsInField <-TargX <-TargY GetVoid or not )
1 ->isInJump
<-myTime ->jumpStart
else
Trace ( "Could not jump to position: " <-TargX concat " " concat <-TargY concat )
RandCoordsInRange( CurrentCoords <-Range ) ->TargY ->TargX
endif
loop
else
1 ->isInJump
<-myTime ->jumpStart
endif
endif
if ( <-isInJump )
#SetText( "isInJump" )
if ( <-myTime <-jumpStart sub eq0 )
SetImageScale( Self "main" 1.9 dup )
endif
if ( <-myTime <-jumpStart sub 1 eq )
SetImageScale( Self "main" 1.7 dup )
endif
if ( <-myTime <-jumpStart sub 2 eq )
<-TargX <-TargY dup2 CellToPixel <-startX <-startY CellToPixel Distance <-Movetime 30 mul div QueueMove
if ( <-stunnedTimer <-Stuntime neg 3 mul lt )
SetUnitAttribute( Self CONST_SNIPERIGNORELOS 1 )
SetUnitAttribute( Self CONST_BEAMTARGET 1 )
endif
endif
if ( <-myTime <-jumpStart sub 3 eq )
endif
if ( <-myTime <-jumpStart sub dup 2 gt swap <-Movetime 30.0 mul floor 2 add lt and )
#ShowTraceLog
#GetImageScale( Self "main" )
#0.5 add ->ys 0.5 add ->xs
<-myTime <-jumpStart sub 2 add ->xvar
-8.0 <-Movetime asfloat 30.0 mul 2.0 pow div <-xvar 2.0 pow mul 8.0 <-Movetime asfloat 30.0 mul div <-xvar mul add 2.0 add ->sc
SetImageScale( Self "main" <-sc <-sc )
endif
if ( <-myTime <-jumpStart sub 5 eq )
endif
if ( <-myTime <-jumpStart sub 6 eq )
endif
if ( <-myTime <-jumpStart sub 7 eq )
endif
if ( <-myTime <-jumpStart sub 8 eq )
endif
if ( <-myTime <-jumpStart sub 9 eq )
endif
if ( <-myTime <-jumpStart sub <-Movetime 30.0 mul 2 add gte )
0 ->isInJump
SetUnitAttribute( Self CONST_SNIPERIGNORELOS 0 )
SetUnitAttribute( Self CONST_BEAMTARGET 0 )
SetImageScale( Self "main" 2.0 2.0 )
CurrentCoords ->startY ->startX
endif
else
#SetText( "" )
endif
:IsInField #Args: X, Y
GetFieldCell neq0 swap neq0 and swap neq0 and swap neq0 and