Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// You need: https://forum.mixmods.com.br/f141-gta3script-cleo/t5206-como-criar-scripts-com-cleoplus
SCRIPT_START
{
LVAR_INT scplayer i j k iSeed iRandomLevel hVeh iType iWheelSet iSlot iTotalSlots pLabel iModel iVehModel bIsOffCity bUseFinalRandom bThisVehicleHasPartsInitialized iClass iFindProgress bOnRace
LVAR_INT iFullTuningFinalPercent iLevels[5] bDisableNitro
/*
*
*
* ATTENTION:
* This was created editing NPC Tuning, this isn't a real script yet and need improvements.
*
*
*/
// Wheel sets
CONST_INT ANY_SET -1
CONST_INT WHEEL_SET_TF 0 // Transfender
CONST_INT WHEEL_SET_WAA 1 // Wheel Arch Angel
CONST_INT WHEEL_SET_LLC 2 // Loco Low Co.
CONST_INT WHEEL_SET_MORE 3 // More...
// Upgrade types
CONST_INT UPGRADE_HOOD 0
CONST_INT UPGRADE_VENT 1
CONST_INT UPGRADE_SPOIL 2
CONST_INT UPGRADE_SIDESKIRT 3
CONST_INT UPGRADE_BULLFRNT 4
CONST_INT UPGRADE_BULLREAR 5
CONST_INT UPGRADE_LIGHTS 6
CONST_INT UPGRADE_ROOF 7
CONST_INT UPGRADE_NITRO 8
CONST_INT UPGRADE_HYDRAULICS 9
CONST_INT UPGRADE_STEREO 10
CONST_INT UPGRADE_UNKNOWN 11
CONST_INT UPGRADE_WHEELS 12
CONST_INT UPGRADE_EXHAUST 13
CONST_INT UPGRADE_BUMPFRNT 14
CONST_INT UPGRADE_BUMPREAR 15
CONST_INT UPGRADE_MISC 16
CONST_INT UPGRADE_ALLWHEELS 17
CLEO_CALL StoreAllWheels 0 ()()
WHILE TRUE
WAIT 0
iFindProgress = 0
WHILE GET_ANY_CAR_NO_SAVE_RECURSIVE iFindProgress (iFindProgress hVeh)
GOSUB ProcessCar
ENDWHILE
ENDWHILE
// We can't process this on car create event, because we need to check driver and if the car is script controlled
ProcessCar:
// This will jump 1 frame, because garages delays 1 frame to reput tuning parts
IF GET_EXTENDED_CAR_VAR hVeh AUTO 1 (i)
IF i = 0
SET_EXTENDED_CAR_VAR hVeh AUTO 1 1
ELSE
RETURN
ENDIF
ELSE
INIT_EXTENDED_CAR_VARS hVeh AUTO 1
RETURN
ENDIF
GET_CAR_MODEL hVeh (iVehModel)
GET_VEHICLE_SUBCLASS hVeh (i)
IF NOT i = VEHICLE_SUBCLASS_AUTOMOBILE
OR iVehModel = SWATVAN
OR iVehModel = TRASH
OR iVehModel = BANDITO
OR iVehModel = TRACTOR
RETURN
ENDIF
GET_VEHICLE_CLASS hVeh (iClass)
IF iVehModel = BOBCAT
OR iVehModel = SADLER
iClass = 1
ENDIF
// This will ignore uncommon cars, like bfinject and tractor
GET_CAR_ANIMGROUP hVeh (i)
IF NOT i = CAR_ANIMGROUP_STANDARD_CAR
AND NOT i = CAR_ANIMGROUP_LOW_CAR
AND NOT i = CAR_ANIMGROUP_CONVERTIBLE
AND NOT i = CAR_ANIMGROUP_VAN
RETURN
ENDIF
// Init parts list
bThisVehicleHasPartsInitialized = FALSE
IF IS_CAR_STREET_RACER hVeh
iWheelSet = WHEEL_SET_WAA
ELSE
IF IS_CAR_LOW_RIDER hVeh
iWheelSet = WHEEL_SET_LLC
ELSE
iWheelSet = WHEEL_SET_TF
ENDIF
ENDIF
iType = UPGRADE_ALLWHEELS
GOSUB InstallThisType
RETURN
///////////////////////////////////////////////////////////////////////////////////////////////
InstallThisType:
CLEO_CALL GetLabelFromType 0 (iType iWheelSet)(pLabel)
CLEO_CALL CountSlots 0 (pLabel iType iWheelSet)(iTotalSlots)
IF iTotalSlots > 0
//GET_CAR_RANDOM_SEED hVeh (iSeed)
CLEO_CALL CalculateRandomSeed 0 (hVeh)(iSeed)
GENERATE_RANDOM_INT_IN_RANGE_WITH_SEED iSeed 0 iTotalSlots (iSlot)
CLEO_CALL GetUpgradeIDFromMemorySlot 0 (pLabel iSlot)(iModel)
IF iModel > 0
GET_CURRENT_CAR_MOD hVeh iType i
IF i <= 0
IF iType = UPGRADE_ALLWHEELS
IF NOT iClass = 1 // poorfamily
IF iModel = 1078 // wheel_lr3
OR iModel = 1076 // wheel_lr4
IF NOT IS_CAR_LOW_RIDER hVeh
iModel = 1096 //wheel_gn3
ENDIF
ENDIF
ENDIF
ENDIF
IF iClass = 4
iModel = 1025 // wheel_or1
ELSE
IF iModel = 1025 // wheel_or1
iModel = 1096 //wheel_gn3
ELSE
IF iModel = 1085 //wheel_gn2
GET_CAR_MODEL hVeh (i)
GET_CAR_MODEL_VALUE i (i)
IF i < 90000
iModel = 1076 // wheel_lr4
ENDIF
ENDIF
ENDIF
ENDIF
//IF IS_MODEL_IN_CDIMAGE iModel
//REQUEST_VEHICLE_MOD iModel
//LOAD_ALL_MODELS_NOW
//WRITE_INT_TO_INI_FILE iModel "CLEO/NPC Vehicle.ini" "Log" "Wheel"
ADD_VEHICLE_MOD hVeh iModel (i)
//MARK_VEHICLE_MOD_AS_NO_LONGER_NEEDED iModel
//ENDIF
ENDIF
ENDIF
ENDIF
RETURN
}
SCRIPT_END
{
LVAR_INT hVeh // In
LVAR_INT iSeed i
LVAR_FLOAT x y z
CalculateRandomSeed:
GET_CAR_COORDINATES hVeh x y z
i =# x
iSeed += i
i =# y
iSeed += i
i =# z
iSeed += i
CLEO_RETURN 0 (iSeed)
}
{
LVAR_INT label type nShop // In
LVAR_INT totalSlots value i j
CountSlots:
IF type = UPGRADE_ALLWHEELS
AND nShop < 0
REPEAT 4 i
CLEO_CALL GetLabelFromType 0 (17 i)(label)
IF CLEO_CALL LabelNotEmpty 0 (label)
totalSlots++
ENDIF
ENDREPEAT
CLEO_RETURN 0 (totalSlots)
ENDIF
WHILE TRUE
READ_MEMORY label 2 FALSE (value)
IF value > 0
AND NOT value = 0xFFFF
totalSlots++
ELSE
BREAK
ENDIF
label += 0x2
ENDWHILE
CLEO_RETURN 0 (totalSlots)
}
{
LVAR_INT label //In
LVAR_INT value
LabelNotEmpty:
READ_MEMORY label 2 FALSE (value)
IF value = 0xFFFF
RETURN_FALSE
CLEO_RETURN 0
ENDIF
IS_THING_GREATER_THAN_THING value 0
CLEO_RETURN 0
}
{
LVAR_INT label slot //In
LVAR_INT id offset
GetUpgradeIDFromMemorySlot:
offset = slot * 2
offset += label
READ_MEMORY offset 2 FALSE (id)
CLEO_RETURN 0 (id)
}
{
LVAR_INT nVehModType nShop //In
LVAR_INT pLabel
GetLabelFromType:
IF nShop >= 0
AND nVehModType = UPGRADE_ALLWHEELS
SWITCH nShop
CASE WHEEL_SET_TF
GET_LABEL_POINTER TMemory_Wheels_TF (pLabel)
BREAK
CASE WHEEL_SET_WAA
GET_LABEL_POINTER TMemory_Wheels_WAA (pLabel)
BREAK
CASE WHEEL_SET_LLC
GET_LABEL_POINTER TMemory_Wheels_LLC (pLabel)
BREAK
CASE WHEEL_SET_MORE
GET_LABEL_POINTER TMemory_Wheels_MORE (pLabel)
BREAK
DEFAULT
GET_LABEL_POINTER TMemory_Wheels_TF (pLabel)
BREAK
ENDSWITCH
CLEO_RETURN 0 (pLabel)
ENDIF
IF nVehModType < 0
CLEO_RETURN 0 (-1)
ENDIF
GET_LABEL_POINTER TMemory_Wheels_MORE (pLabel)
CLEO_RETURN 0 (pLabel)
}
{
LVAR_INT nTotal i pLabel wheel[15]
StoreAllWheels:
REPEAT 4 i
CLEO_CALL GetLabelFromType 0 (17 i)(pLabel)
CLEO_CALL StoreWheelsInSet 0 (i pLabel)()
ENDREPEAT
CLEO_RETURN 0
}
{
LVAR_INT nSetID pLabel // In
LVAR_INT nTotal x pSet wheelId
StoreWheelsInSet:
pSet = nSetID * 0x1E
pSet = pSet + 0x00B4E3F8
nSetID = nSetID * 2
nSetID = nSetID + 0x00B4E470
READ_MEMORY nSetID 2 FALSE nTotal
IF NOT nTotal = 0
x = 0
WHILE x < nTotal
READ_MEMORY pSet 2 FALSE wheelId
IF IS_MODEL_IN_CDIMAGE wheelId
REQUEST_VEHICLE_MOD wheelId
WRITE_MEMORY pLabel 2 wheelId FALSE
ENDIF
pSet += 0x2
pLabel += 0x2
x++
ENDWHILE
ENDIF
LOAD_ALL_MODELS_NOW
CLEO_RETURN 0
}
TMemory_Wheels_TF:
DUMP
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 //8
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 //16
FF FF FF FF
ENDDUMP
TMemory_Wheels_WAA:
DUMP
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 //8
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 //16
FF FF FF FF
ENDDUMP
TMemory_Wheels_LLC:
DUMP
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 //8
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 //16
FF FF FF FF
ENDDUMP
TMemory_Wheels_MORE:
DUMP
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 //8
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 //16
FF FF FF FF
ENDDUMP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment