Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// by Junior_Djjr
// You need: https://forum.mixmods.com.br/f16-utilidades/t179-gta3script-while-true-return_true-e-return_false
// And also: https://www.mixmods.com.br/2020/03/CLEOPlus.html
SCRIPT_START
{
LVAR_INT scplayer char timer time isBleeding i
LVAR_FLOAT x y z
CONST_INT HEALTH_TO_BLEED 50
// Extended vars constants, to make it easier to read
CONST_INT VAR_TIME_TO_STOP_BLEED 1
CONST_INT VAR_TIME_TO_PAUSE_OR_UNPAUSE_BLEED 2
CONST_INT VAR_BLEED_ENABLED 3
CONST_INT TOTAL_EXTENDED_VARS 3
/////////////////////////////////////////////
GET_PLAYER_CHAR 0 scplayer
WHILE TRUE
WAIT 0
GET_GAME_TIMER timer
// Process random chars
GET_ACTIVE_CAMERA_COORDINATES x y z
IF GET_RANDOM_CHAR_IN_SPHERE_NO_SAVE_RECURSIVE x y z 150.0 FALSE TRUE (char)
GOSUB ProcessChar
WHILE GET_RANDOM_CHAR_IN_SPHERE_NO_SAVE_RECURSIVE x y z 150.0 TRUE TRUE (char)
GOSUB ProcessChar
ENDWHILE
ENDIF
// Process also players
char = scplayer
GOSUB ProcessChar
IF IS_2PLAYER_GAME_GOING_ON
GET_PLAYER_CHAR 1 char
GOSUB ProcessChar
ENDIF
ENDWHILE
/////////////////////////////////////////////
ProcessChar:
// Check if var 1 is initialized
IF GET_EXTENDED_CHAR_VAR char AUTO VAR_TIME_TO_STOP_BLEED time
// If initialized, check the values
IF NOT time = 0 // not stopped yet
IF timer > time // current time is greater than stop time
GOSUB DisableBleed
ELSE
GET_EXTENDED_CHAR_VAR char AUTO VAR_TIME_TO_PAUSE_OR_UNPAUSE_BLEED time
IF timer > time // current time is greater than pause/unpause time
// Pause or unpause based on current state
GET_EXTENDED_CHAR_VAR char AUTO VAR_BLEED_ENABLED isBleeding
IF isBleeding = TRUE
GOSUB PauseBleed
ELSE
GOSUB UnpauseBleed
ENDIF
ENDIF
ENDIF
ELSE
// Initialized, processed, and stopped. Check to enable it again.
GET_EXTENDED_CHAR_VAR char AUTO VAR_BLEED_ENABLED isBleeding
IF isBleeding = -1 // Unable (already processed, disabled last time)
IF IS_CHAR_HEALTH_GREATER char HEALTH_TO_BLEED
SET_EXTENDED_CHAR_VAR char AUTO VAR_BLEED_ENABLED 0 // ok, we can enable it again when the health goes low back again
ENDIF
ELSE
// We can enable it again, so check it
IF NOT IS_CHAR_HEALTH_GREATER char HEALTH_TO_BLEED
GOSUB EnableBleed
ENDIF
ENDIF
ENDIF
ELSE
// If not initialized, check if is valid to initialize
IF NOT IS_CHAR_HEALTH_GREATER char HEALTH_TO_BLEED
// Initialize, and then set the value
INIT_EXTENDED_CHAR_VARS char AUTO TOTAL_EXTENDED_VARS
GOSUB EnableBleed
ENDIF
ENDIF
RETURN
PauseBleed:
GENERATE_RANDOM_INT_IN_RANGE 700 1000 i
time = timer + i // Time to unpause
SET_EXTENDED_CHAR_VAR char AUTO VAR_TIME_TO_PAUSE_OR_UNPAUSE_BLEED time
SET_CHAR_BLEEDING char OFF
SET_EXTENDED_CHAR_VAR char AUTO VAR_BLEED_ENABLED FALSE
RETURN
StartBleed:
UnpauseBleed:
GENERATE_RANDOM_INT_IN_RANGE 0 200 i
time = timer + i // Time to pause
SET_EXTENDED_CHAR_VAR char AUTO VAR_TIME_TO_PAUSE_OR_UNPAUSE_BLEED time
SET_CHAR_BLEEDING char ON
SET_EXTENDED_CHAR_VAR char AUTO VAR_BLEED_ENABLED TRUE
RETURN
EnableBleed:
SET_CHAR_BLEEDING char ON
GENERATE_RANDOM_INT_IN_RANGE 4000 8000 i
time = timer + i // Time to stop
SET_EXTENDED_CHAR_VAR char AUTO VAR_TIME_TO_STOP_BLEED time
GOSUB StartBleed
RETURN
DisableBleed:
SET_EXTENDED_CHAR_VAR char AUTO VAR_TIME_TO_STOP_BLEED 0 // disabled
SET_EXTENDED_CHAR_VAR char AUTO VAR_BLEED_ENABLED -1 // unable to enable again (wait for the health increase again)
SET_CHAR_BLEEDING char OFF
RETURN
}
SCRIPT_END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.