@@ -10,32 +10,33 @@ namespace BicycleCity
10
10
{
11
11
public class BicycleCity : Script
12
12
{
13
- int bikesPercentage ;
14
- bool aggressiveDrivers ;
15
- bool aggressiveCyclists ;
16
- bool cyclistsBreakLaws ;
17
- bool cheeringCrowds ;
18
- int cheeringCrowdsSlope ;
19
- bool stopPedAttacks ;
20
- int lastTime = Environment . TickCount ;
21
- int lastPaparazzi = Environment . TickCount ;
22
- List < Ped > fans = new List < Ped > ( ) ;
23
- string [ ] availableBicycles = { "BMX" , "CRUISER" , "FIXTER" , "SCORCHER" , "TRIBIKE" , "TRIBIKE2" , "TRIBIKE3" } ;
24
- VehicleDrivingFlags aggressiveDrivingStyle = VehicleDrivingFlags . AvoidEmptyVehicles |
25
- VehicleDrivingFlags . AvoidObjects |
26
- VehicleDrivingFlags . AvoidPeds |
27
- VehicleDrivingFlags . AvoidVehicles |
28
- VehicleDrivingFlags . StopAtTrafficLights ;
29
- VehicleDrivingFlags lawBreakerDrivingStyle = VehicleDrivingFlags . AllowGoingWrongWay |
30
- VehicleDrivingFlags . AllowMedianCrossing |
31
- VehicleDrivingFlags . AvoidEmptyVehicles |
32
- VehicleDrivingFlags . AvoidObjects |
33
- VehicleDrivingFlags . AvoidVehicles ;
13
+ private readonly int bikesPercentage ;
14
+ private readonly bool aggressiveDrivers ;
15
+ private readonly bool aggressiveCyclists ;
16
+ private readonly bool cyclistsBreakLaws ;
17
+ private readonly bool cheeringCrowds ;
18
+ private readonly int cheeringCrowdsSlope ;
19
+ private readonly bool stopPedAttacks ;
20
+ private readonly bool cantFallFromBike ;
21
+ private int lastTime = Environment . TickCount ;
22
+ private int lastPaparazzi = Environment . TickCount ;
23
+ private readonly List < Ped > fans = new List < Ped > ( ) ;
24
+ private readonly string [ ] availableBicycles = { "BMX" , "CRUISER" , "FIXTER" , "SCORCHER" , "TRIBIKE" , "TRIBIKE2" , "TRIBIKE3" } ;
25
+ private readonly VehicleDrivingFlags aggressiveDrivingStyle = VehicleDrivingFlags . AvoidEmptyVehicles |
26
+ VehicleDrivingFlags . AvoidObjects |
27
+ VehicleDrivingFlags . AvoidPeds |
28
+ VehicleDrivingFlags . AvoidVehicles |
29
+ VehicleDrivingFlags . StopAtTrafficLights ;
30
+ private readonly VehicleDrivingFlags lawBreakerDrivingStyle = VehicleDrivingFlags . AllowGoingWrongWay |
31
+ VehicleDrivingFlags . AllowMedianCrossing |
32
+ VehicleDrivingFlags . AvoidEmptyVehicles |
33
+ VehicleDrivingFlags . AvoidObjects |
34
+ VehicleDrivingFlags . AvoidVehicles ;
34
35
35
36
public BicycleCity ( )
36
37
{
37
38
ScriptSettings settings = ScriptSettings . Load ( @".\Scripts\BicycleCity.ini" ) ;
38
- bikesPercentage = settings . GetValue ( "Main" , "BikesPercentage" , 50 ) ;
39
+ bikesPercentage = settings . GetValue ( "Main" , "BikesPercentage" , 0 ) ;
39
40
if ( bikesPercentage < 0 ) bikesPercentage = 0 ;
40
41
if ( bikesPercentage > 100 ) bikesPercentage = 100 ;
41
42
aggressiveDrivers = settings . GetValue ( "Main" , "AggressiveDrivers" , false ) ;
@@ -44,11 +45,12 @@ public BicycleCity()
44
45
cheeringCrowds = settings . GetValue ( "Main" , "CheeringCrowds" , true ) ;
45
46
cheeringCrowdsSlope = settings . GetValue ( "Main" , "CheeringCrowdsSlope" , 8 ) ;
46
47
stopPedAttacks = settings . GetValue ( "Main" , "StopPedAttacks" , false ) ;
48
+ cantFallFromBike = settings . GetValue ( "Main" , "CantFallFromBike" , true ) ;
47
49
Tick += OnTick ;
48
50
Aborted += OnAbort ;
49
51
}
50
52
51
- void OnTick ( object sender , EventArgs e )
53
+ private void OnTick ( object sender , EventArgs e )
52
54
{
53
55
if ( Environment . TickCount >= lastTime + 1000 )
54
56
{
@@ -152,7 +154,7 @@ void OnTick(object sender, EventArgs e)
152
154
{
153
155
if ( fan != null )
154
156
{
155
- if ( fan . Position . DistanceTo ( Game . Player . Character . Position ) > 150f || isEnemy ( fan ) )
157
+ if ( fan . Position . DistanceTo ( Game . Player . Character . Position ) > 150f || IsEnemy ( fan ) )
156
158
{
157
159
fan . Delete ( ) ;
158
160
fans . Remove ( fan ) ;
@@ -165,7 +167,7 @@ void OnTick(object sender, EventArgs e)
165
167
166
168
if ( stopPedAttacks )
167
169
foreach ( Ped ped in World . GetNearbyPeds ( Game . Player . Character , 100f ) )
168
- if ( isEnemy ( ped ) )
170
+ if ( IsEnemy ( ped ) )
169
171
ped . Delete ( ) ;
170
172
171
173
lastTime = Environment . TickCount ;
@@ -175,14 +177,17 @@ void OnTick(object sender, EventArgs e)
175
177
foreach ( Ped fan in fans )
176
178
if ( fan != null && ! fan . IsRunning )
177
179
fan . Heading = ( Game . Player . Character . Position - fan . Position ) . ToHeading ( ) ;
180
+
181
+ if ( cantFallFromBike )
182
+ Function . Call ( Hash . SET_PED_CAN_BE_KNOCKED_OFF_VEHICLE , Game . Player . Character , 1 ) ;
178
183
}
179
184
180
- bool isEnemy ( Ped ped )
185
+ private bool IsEnemy ( Ped ped )
181
186
{
182
187
return ( ped . GetRelationshipWithPed ( Game . Player . Character ) == Relationship . Hate && ped . IsHuman ) || ped . IsInCombat || ped . IsInMeleeCombat || ped . IsShooting ;
183
188
}
184
189
185
- void OnAbort ( object sender , EventArgs e )
190
+ private void OnAbort ( object sender , EventArgs e )
186
191
{
187
192
Tick -= OnTick ;
188
193
0 commit comments