@@ -11,13 +11,19 @@ public class BicycleCity : Script
11
11
int bikesPercentage ;
12
12
bool aggressiveDrivers ;
13
13
bool aggressiveCyclists ;
14
+ bool cyclistsBreakLaws ;
14
15
DateTime lastTime ;
15
16
string [ ] availableBicycles = { "BMX" , "CRUISER" , "FIXTER" , "SCORCHER" , "TRIBIKE" , "TRIBIKE2" , "TRIBIKE3" } ;
16
- VehicleDrivingFlags customDrivingStyle = VehicleDrivingFlags . AvoidEmptyVehicles |
17
- VehicleDrivingFlags . AvoidObjects |
18
- VehicleDrivingFlags . AvoidPeds |
19
- VehicleDrivingFlags . AvoidVehicles |
20
- VehicleDrivingFlags . StopAtTrafficLights ;
17
+ VehicleDrivingFlags aggressiveDrivingStyle = VehicleDrivingFlags . AvoidEmptyVehicles |
18
+ VehicleDrivingFlags . AvoidObjects |
19
+ VehicleDrivingFlags . AvoidPeds |
20
+ VehicleDrivingFlags . AvoidVehicles |
21
+ VehicleDrivingFlags . StopAtTrafficLights ;
22
+ VehicleDrivingFlags lawBreakerDrivingStyle = VehicleDrivingFlags . AllowGoingWrongWay |
23
+ VehicleDrivingFlags . AllowMedianCrossing |
24
+ VehicleDrivingFlags . AvoidEmptyVehicles |
25
+ VehicleDrivingFlags . AvoidObjects |
26
+ VehicleDrivingFlags . AvoidVehicles ;
21
27
22
28
public BicycleCity ( )
23
29
{
@@ -27,6 +33,7 @@ public BicycleCity()
27
33
bikesPercentage = 100 ;
28
34
aggressiveDrivers = settings . GetValue ( "Main" , "AggressiveDrivers" , false ) ;
29
35
aggressiveCyclists = settings . GetValue ( "Main" , "AggressiveCyclists" , false ) ;
36
+ cyclistsBreakLaws = settings . GetValue ( "Main" , "CyclistsBreakLaws" , false ) ;
30
37
lastTime = DateTime . UtcNow ;
31
38
Tick += OnTick ;
32
39
}
@@ -40,16 +47,17 @@ void OnTick(object sender, EventArgs e)
40
47
int bicycles = 0 ;
41
48
foreach ( Vehicle vehicle in allVehicles )
42
49
{
43
- if ( vehicle . Model . IsBicycle && vehicle . Driver != null && ! vehicle . Driver . IsPlayer )
50
+ if ( vehicle . Driver == null || vehicle . Driver . IsPlayer )
51
+ continue ;
52
+ if ( vehicle . Model . IsBicycle )
44
53
bicycles ++ ;
45
54
else if ( ! vehicle . Model . IsTrain && ! vehicle . Model . IsBoat &&
46
55
! vehicle . Model . IsHelicopter && ! vehicle . Model . IsPlane &&
47
- ! Function . Call < bool > ( Hash . IS_ENTITY_A_MISSION_ENTITY , vehicle ) &&
48
- vehicle . Driver != null && ! vehicle . Driver . IsPlayer )
56
+ ! Function . Call < bool > ( Hash . IS_ENTITY_A_MISSION_ENTITY , vehicle ) )
49
57
{
50
58
canChange . Add ( vehicle ) ;
51
59
if ( aggressiveDrivers )
52
- Function . Call ( Hash . SET_DRIVE_TASK_DRIVING_STYLE , vehicle . Driver , ( int ) customDrivingStyle ) ;
60
+ Function . Call ( Hash . SET_DRIVE_TASK_DRIVING_STYLE , vehicle . Driver , ( int ) aggressiveDrivingStyle ) ;
53
61
}
54
62
}
55
63
int toChange = ( bicycles + canChange . Count ) * bikesPercentage / 100 - bicycles ;
@@ -74,8 +82,14 @@ void OnTick(object sender, EventArgs e)
74
82
newVehicle . MaxSpeed = 10 ;
75
83
canChange [ i ] . Delete ( ) ;
76
84
driver . SetIntoVehicle ( newVehicle , VehicleSeat . Driver ) ;
77
- Function . Call ( Hash . TASK_VEHICLE_DRIVE_WANDER , driver , newVehicle , ( float ) random . Next ( 4 , 8 ) ,
78
- aggressiveCyclists ? ( int ) customDrivingStyle : ( int ) DrivingStyle . Normal ) ;
85
+ int drivingStyle ;
86
+ if ( cyclistsBreakLaws )
87
+ drivingStyle = ( int ) lawBreakerDrivingStyle ;
88
+ else if ( aggressiveCyclists )
89
+ drivingStyle = ( int ) aggressiveDrivingStyle ;
90
+ else
91
+ drivingStyle = ( int ) DrivingStyle . Normal ;
92
+ Function . Call ( Hash . TASK_VEHICLE_DRIVE_WANDER , driver , newVehicle , ( float ) random . Next ( 4 , 8 ) , drivingStyle ) ;
79
93
Function . Call ( Hash . SET_PED_KEEP_TASK , driver , true ) ;
80
94
driver . MarkAsNoLongerNeeded ( ) ;
81
95
newVehicle . MarkAsNoLongerNeeded ( ) ;
0 commit comments