Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// You need: https://forum.mixmods.com.br/f16-utilidades/t179-gta3script-while-true-return_true-e-return_false
// You are allowed to use this script in other mods. Keep credits: Junior_Djjr (MixMods.com.br)
SCRIPT_START
{
LVAR_INT scplayer hObjDummy hObjBase hObjHousing hObjBulb hSearchLight isBack isSearchlightOn hour min iInterior
LVAR_FLOAT x y z basePosX basePosY basePosZ fObjRotZ fStartAngle fMinAngle fMaxAngle fObjSize fLightOffset fLightTargetOffset
CONST_FLOAT MAX_RADIUS 800.0
CONST_INT MAX_HOUR 20
CONST_INT MIN_HOUR 6
CONST_INT MODEL_A51_SPOTBASE 2889
CONST_INT MODEL_A51_SPOTHOUSING 2888
CONST_INT MODEL_A51_SPOTBULB 2887
CONST_INT MODEL_TRAFFICCONE 1238
GET_PLAYER_CHAR 0 scplayer
WHILE TRUE
WAIT 750
GET_AREA_VISIBLE iInterior
IF iInterior = 0
IF LOCATE_CHAR_ANY_MEANS_3D scplayer -2381.5232 2215.9561 20.7552 MAX_RADIUS MAX_RADIUS 500.0 FALSE
GOSUB Activate_Lighthouse_Bayside
ENDIF
IF LOCATE_CHAR_ANY_MEANS_3D scplayer 154.2315 -1952.0558 46.4557 MAX_RADIUS MAX_RADIUS 500.0 FALSE
GOSUB Activate_Lighthouse_SantaMaria
ENDIF
IF LOCATE_CHAR_ANY_MEANS_3D scplayer 2323.7825 1283.1709 97.0 MAX_RADIUS MAX_RADIUS 500.0 FALSE
GET_TIME_OF_DAY hour min
IF hour >= 22
OR hour <= 6
GOSUB Activate_Light_Pyramid
ENDIF
ENDIF
ENDIF
ENDWHILE
Activate_Light_Pyramid:
basePosX = 2323.7825
basePosY = 1283.1709
basePosZ = 97.2
CREATE_SEARCHLIGHT (basePosX basePosY basePosZ) (basePosX basePosY 200.0) 20.0 0.8 (hSearchLight)
SET_SEARCHLIGHT_CLIP_IF_COLLIDING hSearchLight FALSE
WHILE LOCATE_CHAR_ANY_MEANS_3D scplayer basePosX basePosY basePosZ MAX_RADIUS MAX_RADIUS 500.0 FALSE
WAIT 0
GET_TIME_OF_DAY hour min
IF hour < 22
AND hour > 6
BREAK
ENDIF
ENDWHILE
DELETE_SEARCHLIGHT hSearchLight
RETURN
Activate_Lighthouse_Bayside:
basePosX = -2381.5232
basePosY = 2215.9561
basePosZ = 14.0
fObjSize = 1.0
fStartAngle = 180.0
fMinAngle = 100.0
fMaxAngle = 260.0
fLightOffset = 3.1
fLightTargetOffset = 120.0
GOSUB RunSearchlight
RETURN
Activate_Lighthouse_SantaMaria:
basePosX = 154.23
basePosY = -1952.0
basePosZ = 48.9
fObjSize = 0.6
fStartAngle = 180.0
fMinAngle = 90.0
fMaxAngle = 200.0
fLightOffset = 1.5
fLightTargetOffset = 100.0
GOSUB RunSearchlight
RETURN
RunSearchlight:
isSearchlightOn = FALSE
CREATE_OBJECT_NO_OFFSET MODEL_TRAFFICCONE basePosX basePosY basePosZ (hObjDummy)
SET_OBJECT_VISIBLE hObjDummy FALSE
CREATE_OBJECT_NO_OFFSET MODEL_A51_SPOTBASE basePosX basePosY basePosZ (hObjBase)
CREATE_OBJECT_NO_OFFSET MODEL_A51_SPOTHOUSING basePosX basePosY basePosZ (hObjHousing)
CREATE_OBJECT_NO_OFFSET MODEL_A51_SPOTBULB basePosX basePosY basePosZ (hObjBulb)
SET_OBJECT_SCALE hObjBase fObjSize
SET_OBJECT_SCALE hObjHousing fObjSize
SET_OBJECT_SCALE hObjBulb fObjSize
CLEO_CALL DontSaveObject 0 (hObjDummy)
CLEO_CALL DontSaveObject 0 (hObjBase)
CLEO_CALL DontSaveObject 0 (hObjHousing)
CLEO_CALL DontSaveObject 0 (hObjBulb)
fObjRotZ = fStartAngle
SET_OBJECT_HEADING hObjDummy fObjRotZ
SET_OBJECT_HEADING hObjBase fObjRotZ
SET_OBJECT_HEADING hObjHousing fObjRotZ
SET_OBJECT_HEADING hObjBulb fObjRotZ
WHILE LOCATE_CHAR_ANY_MEANS_3D scplayer basePosX basePosY basePosZ MAX_RADIUS MAX_RADIUS 500.0 FALSE
AND iInterior = 0
WAIT 0
GET_TIME_OF_DAY hour min
GET_AREA_VISIBLE iInterior
IF isSearchlightOn = TRUE
IF isBack = TRUE
fObjRotZ -=@ 0.3
ELSE
fObjRotZ +=@ 0.3
ENDIF
IF fObjRotZ > fMaxAngle
isBack = TRUE
fObjRotZ = fMaxAngle
ELSE
IF fObjRotZ < fMinAngle
isBack = FALSE
fObjRotZ = fMinAngle
ENDIF
ENDIF
SET_OBJECT_HEADING hObjDummy fObjRotZ
GET_OFFSET_FROM_OBJECT_IN_WORLD_COORDS hObjDummy 0.0 fLightTargetOffset -30.0 (x y z)
POINT_SEARCHLIGHT_AT_COORD hSearchLight x y z 100.0
IF hour < MAX_HOUR
AND hour > MIN_HOUR
DELETE_SEARCHLIGHT hSearchLight
isSearchlightOn = FALSE
ENDIF
ELSE
IF hour >= MAX_HOUR
OR hour <= MIN_HOUR
CREATE_SEARCHLIGHT (basePosX basePosY basePosZ) (basePosX basePosY basePosZ) 25.0 fObjSize (hSearchLight)
ATTACH_SEARCHLIGHT_TO_SEARCHLIGHT_OBJECT hSearchLight hObjBase hObjHousing hObjBulb 0.0 fLightOffset 0.7
SET_SEARCHLIGHT_CLIP_IF_COLLIDING hSearchLight FALSE
isSearchlightOn = TRUE
ENDIF
ENDIF
ENDWHILE
IF isSearchlightOn = TRUE
DELETE_SEARCHLIGHT hSearchLight
ENDIF
DELETE_OBJECT hObjDummy
DELETE_OBJECT hObjBase
DELETE_OBJECT hObjHousing
DELETE_OBJECT hObjBulb
RETURN
}
SCRIPT_END
{
LVAR_INT hObj //In
LVAR_INT pObj
DontSaveObject:
GET_OBJECT_POINTER hObj pObj
pObj += 0x13C //
WRITE_MEMORY pObj 1 6 FALSE
CLEO_RETURN 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment