Last active
January 5, 2024 17:34
-
-
Save JuniorDjjr/863e11e6e6e6f394ba7259d789e0e4f2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Horror Noises by Junior_Djjr - MixMods.com.br | |
// You need: https://forum.mixmods.com.br/f141-gta3script-cleo/t5206-como-criar-scripts-com-cleo | |
SCRIPT_START | |
{ | |
LVAR_INT scplayer i iAlpha bLoaded hAudio bRandomVolume bCreateGhost hGhostChar iTimesNear bNearLastTime bOnlyOnCamera iNearLimit iGhostModel | |
LVAR_FLOAT f fHorrorness x y z randX randY fMaxIntensity fVolume fVolumeMult fTransitionPathDistance fTransitionGroundDistance fMinPathDistance fMaxGroundDistance fRecreateGhostInDistance fLastGhostX fLastGhostY | |
READ_FLOAT_FROM_INI_FILE "CLEO\Horror Noises.ini" "Settings" "TransitionPathDistance" (fTransitionPathDistance) | |
READ_FLOAT_FROM_INI_FILE "CLEO\Horror Noises.ini" "Settings" "TransitionGroundDistance" (fTransitionGroundDistance) | |
READ_FLOAT_FROM_INI_FILE "CLEO\Horror Noises.ini" "Settings" "MinPathDistance" (fMinPathDistance) | |
READ_FLOAT_FROM_INI_FILE "CLEO\Horror Noises.ini" "Settings" "MaxGroundDistance" (fMaxGroundDistance) | |
READ_FLOAT_FROM_INI_FILE "CLEO\Horror Noises.ini" "Settings" "MaxIntensity" (fMaxIntensity) | |
READ_FLOAT_FROM_INI_FILE "CLEO\Horror Noises.ini" "Settings" "VolumeMult" (fVolumeMult) | |
READ_INT_FROM_INI_FILE "CLEO\Horror Noises.ini" "Settings" "RandomVolume" (bRandomVolume) | |
READ_INT_FROM_INI_FILE "CLEO\Horror Noises.ini" "Settings" "CreateGhost" (bCreateGhost) | |
READ_INT_FROM_INI_FILE "CLEO\Horror Noises.ini" "Settings" "OnlyOnCamera" (bOnlyOnCamera) | |
IF fMaxIntensity <= 0.0 | |
TERMINATE_THIS_CUSTOM_SCRIPT | |
ENDIF | |
hAudio = -1 | |
hGhostChar = -1 | |
timera = 10000 | |
GET_PLAYER_CHAR 0 (scplayer) | |
WHILE TRUE | |
WAIT 0 | |
fVolume = 0.0 | |
IF bOnlyOnCamera = TRUE | |
AND IS_CHAR_IN_ANY_CAR scplayer | |
GOTO NoHorrorness | |
ENDIF | |
GET_CHAR_COORDINATES scplayer (x y z) | |
IF CLEO_CALL GetHorrornessThisCoord 0 (x y z fMinPathDistance fTransitionPathDistance fMaxGroundDistance fTransitionGroundDistance)(fHorrorness) | |
//fHorrorness = 1.0 | |
IF GOSUB LoadStuffIfNeeded | |
CONTINUE | |
ENDIF | |
//PRINT_FORMATTED_NOW "horrorness %.3f" 1 fHorrorness | |
IF bCreateGhost = TRUE | |
IF fHorrorness > 0.6 | |
IF DOES_CHAR_EXIST hGhostChar | |
IF GOSUB CheckPhotographed | |
GOSUB DeleteGhost | |
ELSE | |
GOSUB MayDeleteGhost | |
ENDIF | |
ELSE | |
GOSUB MayCreateGhost | |
ENDIF | |
ELSE | |
GOSUB DeleteGhost | |
ENDIF | |
ENDIF | |
GET_CURRENT_CAMERA_MODE i | |
IF i = CAMERAMODE_CAMERA | |
OR bOnlyOnCamera = FALSE | |
IF bRandomVolume = FALSE | |
fVolume = fHorrorness | |
ENDIF | |
IF DOES_CHAR_EXIST hGhostChar | |
IF LOCATE_CHAR_DISTANCE_TO_CHAR scplayer hGhostChar 5.0 | |
AND HAS_CHAR_SPOTTED_CHAR_IN_FRONT scplayer hGhostChar | |
fHorrorness *= 15.0 | |
IF timera > 10000 | |
OR LOCATE_CHAR_DISTANCE_TO_CHAR scplayer hGhostChar 2.0 | |
GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS scplayer 0.0 2.0 0.0 x y z | |
SET_CHAR_COORDINATES_NO_OFFSET hGhostChar x y z | |
FIX_CHAR_GROUND_BRIGHTNESS_AND_FADE_IN hGhostChar TRUE TRUE FALSE | |
IF bNearLastTime = FALSE | |
iTimesNear++ | |
bNearLastTime = TRUE | |
timera = 0 | |
ENDIF | |
ENDIF | |
IF iTimesNear > 0 | |
IF timera > 600 | |
OR iTimesNear > iNearLimit | |
SET_CHAR_SAY_CONTEXT_IMPORTANT scplayer 344 0 0 0 (i) | |
TASK_PLAY_ANIM_NON_INTERRUPTABLE scplayer "HIT_wall" "PED" 4.0 FALSE FALSE FALSE FALSE -1 | |
DAMAGE_CHAR scplayer 20 FALSE | |
GOSUB DeleteGhost | |
ENDIF | |
ENDIF | |
ELSE | |
GOSUB ResetNearGhostTime | |
ENDIF | |
ENDIF | |
f = fHorrorness * fMaxIntensity | |
iAlpha =# f | |
//PRINT_FORMATTED_NOW "alpha %i" 1 iAlpha | |
GENERATE_RANDOM_FLOAT_IN_RANGE 0.0 60.0 randX | |
GENERATE_RANDOM_FLOAT_IN_RANGE 0.0 30.0 randY | |
x = 640.0 | |
y = 448.0 | |
x += randX | |
y += randY | |
IF RANDOM_PERCENT 50 | |
x *= -1.0 | |
ENDIF | |
GENERATE_RANDOM_INT_IN_RANGE 0 150 (i) | |
iAlpha -= i | |
IF iAlpha > 0 | |
CLAMP_INT iAlpha 0 255 (iAlpha) | |
GENERATE_RANDOM_INT_IN_RANGE 1 6 (i) | |
DRAW_SPRITE i 320.0 224.0 x y (255 255 255 iAlpha) | |
USE_TEXT_COMMANDS 0 | |
IF bRandomVolume = TRUE | |
f =# iAlpha | |
f /= fMaxIntensity | |
fVolume = f | |
ENDIF | |
ENDIF | |
ELSE | |
GOSUB ResetNearGhostTime | |
ENDIF | |
ELSE | |
NoHorrorness: | |
IF bCreateGhost = TRUE | |
IF DOES_CHAR_EXIST hGhostChar | |
GOSUB DeleteGhost | |
ENDIF | |
ENDIF | |
ENDIF | |
GOSUB UpdateVolume | |
ENDWHILE | |
ResetNearGhostTime: | |
timera = 10000 | |
bNearLastTime = FALSE | |
RETURN | |
MayDeleteGhost: | |
IF NOT LOCATE_CHAR_DISTANCE_TO_CHAR scplayer hGhostChar fRecreateGhostInDistance | |
//OR IS_KEY_JUST_PRESSED VK_KEY_Y //debug | |
OR IS_CHAR_IN_ANY_CAR scplayer | |
GOSUB DeleteGhost | |
ENDIF | |
RETURN | |
DeleteGhost: | |
DELETE_CHAR hGhostChar | |
hGhostChar = -1 | |
GOSUB ResetNearGhostTime | |
iTimesNear = 0 | |
timerb = 0 | |
UNLOAD_SPECIAL_CHARACTER_FROM_ID iGhostModel | |
RETURN | |
MayCreateGhost: | |
IF timerb > 3500 | |
AND NOT IS_CHAR_IN_ANY_CAR scplayer | |
timerb = 0 | |
GENERATE_RANDOM_FLOAT_IN_RANGE -30.0 30.0 (x) | |
GENERATE_RANDOM_FLOAT_IN_RANGE -30.0 30.0 (y) | |
GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS scplayer x y 0.0 (x y z) | |
z += 50.0 | |
GET_GROUND_Z_FOR_3D_COORD x y z (z) | |
IF z > 0.0 | |
GET_CLOSEST_CAR_NODE x y z (randX randY f) | |
GET_DISTANCE_BETWEEN_COORDS_3D x y z randX randY f (f) | |
IF f > 30.0 | |
GET_DISTANCE_BETWEEN_COORDS_2D x y fLastGhostX fLastGhostY (f) | |
IF f > 30.0 | |
IF IS_MODEL_AVAILABLE_BY_NAME "hnsghst" | |
GET_MODEL_DOESNT_EXIST_IN_RANGE 15000 15024 (iGhostModel) | |
LOAD_SPECIAL_CHARACTER_FOR_ID iGhostModel "hnsghst" | |
LOAD_ALL_MODELS_NOW | |
CREATE_CHAR PEDTYPE_MISSION1 iGhostModel x y z hGhostChar | |
FIX_CHAR_GROUND_BRIGHTNESS_AND_FADE_IN hGhostChar TRUE TRUE TRUE | |
SET_CHAR_COLLISION hGhostChar FALSE | |
FREEZE_CHAR_POSITION_AND_DONT_LOAD_COLLISION hGhostChar TRUE | |
SET_CHAR_VISIBLE hGhostChar FALSE | |
GENERATE_RANDOM_FLOAT_IN_RANGE 40.0 60.0 (fRecreateGhostInDistance) | |
//ADD_BLIP_FOR_CHAR hGhostChar i | |
fLastGhostX = x | |
fLastGhostY = y | |
GENERATE_RANDOM_INT_IN_RANGE 2 5 (iNearLimit) | |
//PRINT_STRING_NOW "criou" 1000 | |
ELSE | |
PRINT_STRING_NOW "~r~Fail to create ped 'hnsghst'" 2000 | |
ENDIF | |
ENDIF | |
ENDIF | |
ENDIF | |
ENDIF | |
RETURN | |
CheckPhotographed: | |
GET_CURRENT_CAMERA_MODE i | |
IF i = CAMERAMODE_CAMERA | |
SET_CHAR_VISIBLE hGhostChar TRUE | |
GET_CHAR_COORDINATES scplayer x y z | |
GET_CHAR_COORDINATES hGhostChar randX randY z | |
GET_ANGLE_FROM_TWO_COORDS x y randX randY (f) | |
f += 180.0 | |
SET_CHAR_HEADING hGhostChar f | |
ELSE | |
SET_CHAR_VISIBLE hGhostChar FALSE | |
ENDIF | |
IF HAS_CHAR_BEEN_PHOTOGRAPHED hGhostChar | |
RETURN_TRUE | |
RETURN | |
ENDIF | |
RETURN_FALSE | |
RETURN | |
LoadStuffIfNeeded: | |
IF bLoaded = FALSE | |
LOAD_TEXTURE_DICTIONARY hornois | |
LOAD_SPRITE 1 "noise1" | |
LOAD_SPRITE 2 "noise2" | |
LOAD_SPRITE 3 "noise3" | |
LOAD_SPRITE 4 "noise4" | |
LOAD_SPRITE 5 "noise5" | |
hAudio = -1 | |
IF fVolumeMult > 0.0 | |
IF NOT LOAD_AUDIO_STREAM "CLEO\Horror Noises\white_noise.mp3" (hAudio) | |
IF NOT LOAD_AUDIO_STREAM "CLEO\Horror Noises\white_noise.wav" (hAudio) | |
hAudio = -1 | |
ENDIF | |
ENDIF | |
ENDIF | |
IF NOT hAudio = -1 | |
fVolume = 0.0 | |
SET_AUDIO_STREAM_VOLUME hAudio fVolume | |
SET_AUDIO_STREAM_STATE hAudio 1 | |
SET_AUDIO_STREAM_LOOPED hAudio TRUE | |
ENDIF | |
bLoaded = TRUE | |
RETURN_TRUE | |
ENDIF | |
RETURN_FALSE | |
RETURN | |
UpdateVolume: | |
IF NOT hAudio = -1 | |
GET_AUDIO_SFX_VOLUME (f) | |
f *= fVolumeMult | |
f *= fVolume | |
CLAMP_FLOAT f 0.0 1.0 (f) | |
SET_AUDIO_STREAM_VOLUME hAudio f | |
//PRINT_FORMATTED_NOW "volume %f" 1000 f | |
ENDIF | |
RETURN | |
} | |
SCRIPT_END | |
{ | |
LVAR_FLOAT inX inY inZ fMinPathDistance fTransitionPathDistance fMaxGroundDistance fTransitionGroundDistance //In | |
LVAR_INT i | |
LVAR_FLOAT f x y z fDistance fNight fIntensity fGroundDistance | |
GetHorrornessThisCoord: | |
GET_DAY_NIGHT_BALANCE fNight | |
fNight -= 0.95 | |
IF fNight > 0.0 | |
fNight *= 20.0 | |
GET_CLOSEST_CHAR_NODE inX inY inZ (x y z) | |
GET_DISTANCE_BETWEEN_COORDS_3D inX inY inZ x y z (fDistance) | |
IF fDistance > fMinPathDistance | |
GET_GROUND_Z_FOR_3D_COORD inX inY inZ (z) | |
IF z = 0.0 | |
z = 1000.0 | |
ELSE | |
IF z < 0.0 | |
z = 0.0 | |
ENDIF | |
ENDIF | |
GET_DISTANCE_BETWEEN_COORDS_3D inX inY inZ, inX inY z (fGroundDistance) | |
fGroundDistance -= fMaxGroundDistance | |
CLAMP_FLOAT fGroundDistance 0.0 1000.0 (fGroundDistance) | |
fGroundDistance /= fTransitionGroundDistance | |
CLAMP_FLOAT fGroundDistance 0.0 1.0 (fGroundDistance) | |
fDistance -= fMinPathDistance | |
fDistance /= fTransitionPathDistance | |
fIntensity = fDistance * fNight | |
CLAMP_FLOAT fIntensity 0.0 1.0 (fIntensity) | |
fIntensity -= fGroundDistance | |
CLAMP_FLOAT fIntensity 0.0 1.0 (fIntensity) | |
IF fIntensity > 0.0 | |
RETURN_TRUE | |
CLEO_RETURN 0 (fIntensity) | |
ENDIF | |
ENDIF | |
ENDIF | |
RETURN_FALSE | |
CLEO_RETURN 0 (0.0) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment