Created
July 24, 2023 15:08
-
-
Save JuniorDjjr/6793591e3fb321b5e45bcbb4f38bdd0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SCRIPT_START | |
{ | |
LVAR_INT scplayer | |
LVAR_FLOAT startX startY endX endY x y z resultX resultY f | |
LVAR_FLOAT step current maxDeviation | |
LVAR_INT blip blipList i k bPlayerNeverGetsTired iMedal pMedalString pSwimTime bStarted bReached | |
GET_PLAYER_CHAR 0 (scplayer) | |
WHILE TRUE | |
WAIT 0 | |
IF TEST_CHEAT "STRAIGHTLINE" | |
READ_INT_FROM_INI_FILE "CLEO\Straight Line Mission.ini" "Mission" "PlayerNeverGetsTired" bPlayerNeverGetsTired | |
IF bPlayerNeverGetsTired = TRUE | |
SET_PLAYER_NEVER_GETS_TIRED 0 TRUE | |
ENDIF | |
CREATE_LIST DATATYPE_INT blipList | |
READ_FLOAT_FROM_INI_FILE "CLEO\Straight Line Mission.ini" "Mission" "StartX" startX | |
READ_FLOAT_FROM_INI_FILE "CLEO\Straight Line Mission.ini" "Mission" "StartY" startY | |
READ_FLOAT_FROM_INI_FILE "CLEO\Straight Line Mission.ini" "Mission" "EndX" endX | |
READ_FLOAT_FROM_INI_FILE "CLEO\Straight Line Mission.ini" "Mission" "EndY" endY | |
GET_DISTANCE_BETWEEN_COORDS_2D startX startY endX endY (step) | |
step /= 1000000.0 | |
ADD_CLEO_BLIP RADAR_SPRITE_RUNWAY_LIGHT startX startY FALSE 50 255 0 255 (blip) | |
LIST_ADD blipList blip | |
ADD_CLEO_BLIP RADAR_SPRITE_RUNWAY_LIGHT endX endY FALSE 255 50 0 255 (blip) | |
LIST_ADD blipList blip | |
current = 0.0 | |
WHILE current < 1.0 | |
LERP startX endX current (x) | |
LERP startY endY current (y) | |
ADD_CLEO_BLIP RADAR_SPRITE_RUNWAY_LIGHT x y TRUE 255 255 0 100 (blip) | |
LIST_ADD blipList blip | |
current += step | |
ENDWHILE | |
iMedal = 0 | |
GET_LABEL_POINTER Buffer (pMedalString) | |
GET_LABEL_POINTER BufferB (pSwimTime) | |
STRING_FORMAT pMedalString "Platinum" | |
bStarted = FALSE | |
timera = 0 | |
bReached = FALSE | |
maxDeviation = 0.0 | |
WHILE NOT TEST_CHEAT "STRAIGHTLINE" | |
WAIT 0 | |
GET_CHAR_COORDINATES scplayer x y z | |
IF bStarted = TRUE | |
CLEO_CALL NearestPointOnFiniteLine 0 (x y 0.0 startX startY 0.0 endX endY 0.0) (resultX resultY f) | |
GET_DISTANCE_BETWEEN_COORDS_2D x y resultX resultY (f) | |
IF f > maxDeviation | |
maxDeviation = f | |
ENDIF | |
IF f >= 15.0 | |
IF f >= 20.0 | |
IF iMedal < 1 | |
iMedal = 1 //gold | |
STRING_FORMAT pMedalString "Gold" | |
ENDIF | |
IF f >= 40.0 | |
IF f < 100.0 | |
IF iMedal < 2 | |
iMedal = 2 //silver | |
STRING_FORMAT pMedalString "Silver" | |
ENDIF | |
ELSE | |
IF iMedal < 3 | |
iMedal = 3 //bronze | |
STRING_FORMAT pMedalString "Bronze" | |
ENDIF | |
ENDIF | |
ENDIF | |
PRINT_FORMATTED_NOW "Distance: ~r~%.2f ~w~~n~%s" 1000 f pMedalString | |
ELSE | |
PRINT_FORMATTED_NOW "Distance: ~y~%.2f ~w~~n~%s" 1000 f pMedalString | |
ENDIF | |
ELSE | |
PRINT_FORMATTED_NOW "Distance: ~g~%.2f ~w~~n~%s" 1000 f pMedalString | |
ENDIF | |
DRAW_WEAPONSHOP_CORONA resultX resultY z 0.3 CORONATYPE_SHINYSTAR FLARETYPE_NONE 255 255 0 | |
IF IS_CHAR_SWIMMING scplayer | |
i = timera / 1000 | |
IF i > 50 | |
STRING_FORMAT pSwimTime "Swiming:~r~ %is" i | |
IF i >= 60 | |
IF iMedal < 3 | |
iMedal = 3 //bronze | |
STRING_FORMAT pMedalString "Bronze" | |
ENDIF | |
ENDIF | |
ELSE | |
STRING_FORMAT pSwimTime "Swiming: %is" i | |
ENDIF | |
DRAW_STRING $pSwimTime DRAW_EVENT_AFTER_HUD 500.0 300.0 0.5 1.0 TRUE FONT_SUBTITLES | |
ELSE | |
timera = 0 | |
ENDIF | |
IF LOCATE_CHAR_ANY_MEANS_2D scplayer endX endY 10.0 10.0 FALSE | |
bReached = TRUE | |
BREAK | |
ENDIF | |
ELSE | |
GET_DISTANCE_BETWEEN_COORDS_2D x y startX startY (f) | |
DRAW_WEAPONSHOP_CORONA startX startY z 2.0 CORONATYPE_SHINYSTAR FLARETYPE_NONE 50 255 0 | |
PRINT_FORMATTED_NOW "Waiting for start point: Distance: %f" 1000 f | |
IF f <= 5.0 | |
bStarted = TRUE | |
timera = 0 | |
ENDIF | |
ENDIF | |
ENDWHILE | |
i = 0 | |
GET_LIST_SIZE blipList (k) | |
WHILE i < k | |
GET_LIST_VALUE_BY_INDEX blipList i (blip) | |
REMOVE_CLEO_BLIP blip | |
i += 1 | |
ENDWHILE | |
DELETE_LIST blipList | |
IF bPlayerNeverGetsTired = TRUE | |
SET_PLAYER_NEVER_GETS_TIRED 0 FALSE | |
ENDIF | |
IF bReached = TRUE | |
PRINT_FORMATTED_NOW "Max deviation: %.3f meters" 5000 maxDeviation | |
PLAY_MISSION_PASSED_TUNE 1 | |
timera = 0 | |
WHILE timera < 5000 | |
WAIT 0 | |
DRAW_STRING_EXT $pMedalString DRAW_EVENT_AFTER_FADE 320.0 220.0 1.0 2.0 TRUE FONT_PRICEDOWN TRUE ALIGN_CENTER 640.0 TRUE 255 255 255 255 1 0 0 0 0 255 0 0 0 0 255 | |
ENDWHILE | |
ENDIF | |
ENDIF | |
ENDWHILE | |
} | |
SCRIPT_END | |
/* | |
public static Vector3 ClosestPointOnLineSegment( float px, float py, float pz, float ax, float ay, float az, float bx, float by, float bz ) | |
{ | |
float apx = px - ax; | |
float apy = py - ay; | |
float apz = pz - az; | |
float abx = bx - ax; | |
float aby = by - ay; | |
float abz = bz - az; | |
float abMag = abx * abx + aby * aby + abz * abz; // Sqr magnitude. | |
if( abMag < Mathf.Epsilon ) return new Vector3( ax, ay, az ); | |
// Normalize. | |
abMag = Mathf.Sqrt( abMag ); | |
abx /= abMag; | |
aby /= abMag; | |
abz /= abMag; | |
float mu = abx * apx + aby * apy + abz * apz; // Dot. | |
if( mu < 0 ) return new Vector3( ax, ay, az ); | |
if( mu > abMag ) return new Vector3( bx, by, bz ); | |
return new Vector3( ax + abx * mu, ay + aby * mu, az + abz * mu ); | |
} | |
*/ | |
{ | |
LVAR_FLOAT px py pz ax ay az bx by bz //In | |
LVAR_FLOAT f abx aby abz apx apy apz abMag mu resultX resultY resultZ | |
NearestPointOnFiniteLine: | |
//float apx = px - ax; | |
//float apy = py - ay; | |
//float apz = pz - az; | |
apx = px - ax | |
apy = py - ay | |
apz = pz - az | |
//float abx = bx - ax; | |
//float aby = by - ay; | |
//float abz = bz - az; | |
abx = bx - ax | |
aby = by - ay | |
abz = bz - az | |
//float abMag = abx * abx + aby * aby + abz * abz; // Sqr magnitude. | |
f = abx * abx | |
abMag += f | |
f = aby * aby | |
abMag += f | |
f = abz * abz | |
abMag += f | |
//if( abMag < Mathf.Epsilon ) return new Vector3( ax, ay, az ); | |
IF abMag < 0.00000001 | |
CLEO_RETURN 0 (ax ay az) | |
ENDIF | |
//abMag = Mathf.Sqrt( abMag ); | |
SQRT abMag (abMag) | |
//abx /= abMag; | |
//aby /= abMag; | |
//abz /= abMag; | |
abx /= abMag | |
aby /= abMag | |
abz /= abMag | |
//float mu = abx * apx + aby * apy + abz * apz; // Dot. | |
f = abx * apx | |
mu += f | |
f = aby * apy | |
mu += f | |
f = abz * apz | |
mu += f | |
//if( mu < 0 ) return new Vector3( ax, ay, az ); | |
IF mu < 0.0 | |
CLEO_RETURN 0 (ax ay az) | |
ENDIF | |
//if( mu > abMag ) return new Vector3( bx, by, bz ); | |
IF mu > abMag | |
CLEO_RETURN 0 (bx by bz) | |
ENDIF | |
//return new Vector3( ax + abx * mu, ay + aby * mu, az + abz * mu ); | |
f = abx * mu | |
f += ax | |
resultX += f | |
f = aby * mu | |
f += ay | |
resultY += f | |
f = abz * mu | |
f += az | |
resultZ += f | |
CLEO_RETURN 0 (resultX resultY resultZ) | |
} | |
Buffer: | |
DUMP | |
00 00 00 00 00 00 00 00 | |
00 00 00 00 00 00 00 00 | |
ENDDUMP | |
BufferB: | |
DUMP | |
00 00 00 00 00 00 00 00 | |
00 00 00 00 00 00 00 00 | |
00 00 00 00 00 00 00 00 | |
00 00 00 00 00 00 00 00 | |
ENDDUMP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment