Skip to content

Instantly share code, notes, and snippets.

@JuniorDjjr
Last active January 5, 2024 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JuniorDjjr/0cf8a63f63a9ed81c5b35aa44f3d66c9 to your computer and use it in GitHub Desktop.
Save JuniorDjjr/0cf8a63f63a9ed81c5b35aa44f3d66c9 to your computer and use it in GitHub Desktop.
// by Junior_Djjr - MixMods.com.br
// You need: https://forum.mixmods.com.br/f16-utilidades/t179-gta3script-while-true-return_true-e-return_false
SCRIPT_START
{
LVAR_INT playerId scplayer iHealth p camMode i iCurHealth
LVAR_FLOAT fMinHealth fMaxHealth fCurHealth fCurHealthPercent
IF NOT READ_FLOAT_FROM_INI_FILE "CLEO/Low Life Animation.ini" "Settings" "MinHealth" (fMinHealth)
fMinHealth = 15.0
ENDIF
fMinHealth /= 100.0
REQUEST_ANIMATION LOWLIFE
LOAD_ALL_MODELS_NOW
WHILE TRUE
WAIT 0
playerId = 0
GOSUB Activate
IF IS_2PLAYER_GAME_GOING_ON
playerId = 1
GOSUB Activate
ENDIF
ENDWHILE
Activate:
GET_PLAYER_CHAR playerId scplayer
GOSUB GetHealthPercent
IF IS_CHAR_PLAYING_ANIM scplayer "STOMACH_HURT"
IF fCurHealthPercent > fMinHealth
OR IS_CHAR_IN_ANY_CAR scplayer
CLEO_CALL ClearSecondaryTask 0 (scplayer)
ELSE
IF CLEO_CALL CharOnFire 0 (scplayer)
CLEO_CALL ClearSecondaryTask 0 (scplayer)
ENDIF
ENDIF
ELSE
IF fCurHealthPercent < fMinHealth
AND NOT IS_CHAR_IN_ANY_CAR scplayer
AND IS_PLAYER_PLAYING 0
IF CLEO_CALL CharNotDoingAnim 0 (scplayer)
IF CLEO_CALL CharNotReloadingGun 0 (scplayer)
IF CLEO_CALL CharOnFire 0 (scplayer)
RETURN
ENDIF
IF IS_CHAR_PLAYING_ANIM scplayer IDLE_tired // any better solution?
RETURN
ENDIF
TASK_PLAY_ANIM_SECONDARY scplayer "STOMACH_HURT" "LOWLIFE" 4.0 0 0 0 1 -1
WAIT 500
ENDIF
ENDIF
ENDIF
ENDIF
RETURN
/////////////////////////////////////////////////
GetHealthPercent:
GET_CHAR_HEALTH scplayer iCurHealth
IF playerId = 0
READ_MEMORY 0xB7CEE7 1 FALSE (i) // Max health
ELSE
READ_MEMORY 0xB7D077 1 FALSE (i) // Max health
ENDIF
fMaxHealth =# i
fCurHealth =# iCurHealth
fCurHealthPercent = fCurHealth / fMaxHealth
RETURN
}
SCRIPT_END
{
//CLEO_CALL ClearSecondaryTask 0 (scplayer)
LVAR_INT hChar // in
LVAR_INT p
ClearSecondaryTask:
GET_PED_POINTER hChar p
p += 0x47C //m_pIntelligence
READ_MEMORY p 4 FALSE (p)
CALL_METHOD 0x601420 p 2 0 (1 0)
CLEO_RETURN 0
}
{
//IF CLEO_CALL CharOnFire 0 (scplayer)
LVAR_INT hChar // in
LVAR_INT p i
CharOnFire:
GET_PED_POINTER hChar (p)
i = p + 0x730 //m_pFire
READ_MEMORY i 4 FALSE (i)
IF NOT i = 0
RETURN_TRUE
CLEO_RETURN 0
ENDIF
RETURN_FALSE
CLEO_RETURN 0
}
{
//IF CLEO_CALL CharNotReloadingGun 0 (scplayer)
LVAR_INT hChar // in
LVAR_INT p i
CharNotReloadingGun:
GET_PED_POINTER hChar (p)
i = p + 0x718 //m_nActiveWeaponSlot
READ_MEMORY i 1 FALSE (i)
IF NOT i = 0
i *= 0x1C //sizeof CWeapon
i += p
i += 0x5A4 //CWeapon.m_nState
READ_MEMORY i 4 FALSE (i)
IF i = 2
RETURN_FALSE
CLEO_RETURN 0
ENDIF
ENDIF
RETURN_TRUE
CLEO_RETURN 0
}
{
//IF CLEO_CALL CharNotDoingAnim 0 (scplayer)
LVAR_INT hChar // in
LVAR_INT s p i
CharNotDoingAnim:
GET_PED_POINTER hChar s
p = s + 0x47C //m_pIntelligence
READ_MEMORY p 4 FALSE (p)
i = p + 0x4 //m_TaskMgr.m_primaryTasks dd 5 dup
i += 12 //[3] (primary anim)
READ_MEMORY i 4 FALSE (i)
IF i > 0
RETURN_FALSE
CLEO_RETURN 0
ELSE
i = p + 0x18 //m_TaskMgr.m_secondaryTasks dd 6 dup
i += 16 //[4] (secondary anim)
READ_MEMORY i 4 FALSE (i)
IF i > 0
RETURN_FALSE
CLEO_RETURN 0
ELSE
//i = s + 0x534
//READ_MEMORY i 4 FALSE (i)
//PRINT_FORMATTED_NOW "%i" 1000 i
//IF i > 1 // not idle
//CTask *__thiscall CPedIntelligence::GetTaskDuck(int this, char a2)
CALL_METHOD_RETURN 0x6010A0 p 1 0 (1)(i)
IF i > 0
RETURN_FALSE
CLEO_RETURN 0
ENDIF
//ENDIF
ENDIF
ENDIF
RETURN_TRUE
CLEO_RETURN 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment