View difference between Paste ID: GJTZ7QKv and uHWfkdQW
SHOW: | | - or go back to the newest paste.
1
'http://gtabkmodding.blogspot.in/
2
'https://www.facebook.com/GTABKModding
3
'https://www.youtube.com/c/BKModdingForGTA
4
5
'QuickSilver script by GTA BK Modding
6
7
'Scripting, Ideas and Testing By
8
'GTA BK Modding(Me) :)
9
10
'QuickSilver Model By
11
'Sweet3d (http://gtaivpedworkshop.blogspot.in/)
12
13
'QuickSilver Retexture By
14
'Fanta Vy (https://www.youtube.com/channel/UCRTcjRrUodFz93c4QezDN5A)
15
16
'Requested By
17
'GTA Daman and Diu Stories (https://www.facebook.com/GTADDS)
18
19
'Note: I grouped all the declared variables so it may be easy for the reader to understand
20
'This was a complex code and i made it as simple as possible ;)
21
22
'Thanks Rockstar for this amazing game
23
24
Imports System
25
Imports GTA
26
Imports System.Drawing
27
Imports System.Windows.Forms
28
Imports System.Collections.Generic
29
Imports System.IO
30
'Imports SlimDX.XInput
31
Imports System.Text
32
33
Public Class QuickSilver
34
    Inherits Script
35
    'Booleans
36
    Public QuickSilverOn As Boolean = False
37
    Public QuickSilverEnemy As Boolean = False
38
    Private EffectsEnabled As Boolean = False
39
    Private EnemyEnableWeapons As Boolean = False
40
    Public UseQuickSilverModel As Boolean = False
41
    Public DecisionTaken As Boolean = False
42
    Public TimeScaleOn As Boolean = False
43
    Public TimeScaleZero As Boolean = False
44
    Public EnemyTimeScale As Boolean = False
45
    'End Booleans
46
    'Generals
47
    Private iniFile As String
48
    Private QuickSilver As Int32
49
    Private Speed As Int32
50
    Private bTimeScale As Int32
51
    Private bTimeScaleIncrease As Int32
52
    Private bTimeScaleDecrease As Int32
53
    Private EnemySpawnKey As Int32
54
    Private Group As Group = Player.Group
55
    Shared TRandom As Random = New Random(System.DateTime.Now.Millisecond)
56
    Shared TRandom2 As Random = New Random(System.DateTime.Now.Second)
57
    Public TimeAux As Date
58
    Private EffectsID As Int32
59
    Dim rndAnim As New Random()
60
    'End Generals
61
    'Peds
62
    Public PedModel As Model = "m_y_cowboy_01"
63
    Public allyPed As Ped = Nothing
64
    Public enemyPed As Ped = Nothing
65
    'End Peds
66
    'Doubles
67
    Private TimeScale As Double
68
    Private PlayerSpeedValue As Double
69
    Private EnemySpeedValue As Double
70
    Private timeWaitSearchTargets As Double = 0
71
    Private targetAuxRoll As Double = 0
72
    Private Decide As Double = 0
73
    Private Decide2 As Double = 0
74
    'End Doubles
75
    'Vector3s
76
    Private RunDir As Vector3
77
    Private enemyForce As Vector3
78
    Private tmpPos As Vector3
79
    Private EnemyKickForce As Vector3
80
    'End Vector3s
81
82
    Public Sub New()
83
        Me.Interval = 10
84
        Native.Function.Call("REQUEST_MODEL", 3721179013)
85
        Native.Function.Call("REQUEST_MODEL", 1862763509)
86
        If Settings.GetValueString("QuickSilverKey", "Main") = "" Then Settings.SetValue("QuickSilverKey", "Main", Keys.M)
87
        If Settings.GetValueString("UseQuickSilverModel", "Main", "") = "" Then Settings.SetValue("UseQuickSilverModel", "Main", "1")
88
        If Settings.GetValueString("EnemySpawnKey", "Main", "") = "" Then Settings.SetValue("EnemySpawnKey", "Main", Keys.PageDown)
89
        If Settings.GetValueString("Speed", "General", "") = "" Then Settings.SetValue("Speed", "General", 8)
90
        If Settings.GetValueString("bTimeScale", "General", "") = "" Then Settings.SetValue("bTimeScale", "General", Keys.R)
91
        If Settings.GetValueString("bTimeScaleIncrease", "General", "") = "" Then Settings.SetValue("bTimeScaleIncrease", "General", Keys.E)
92
        If Settings.GetValueString("bTimeScaleDecrease", "General", "") = "" Then Settings.SetValue("bTimeScaleDecrease", "General", Keys.Q)
93
        If Settings.GetValueString("EffectsEnabled", "General", "") = "" Then Settings.SetValue("EffectsEnabled", "General", "1")
94
        If Settings.GetValueString("EnemyEnableWeapons", "General", "") = "" Then Settings.SetValue("EnemyEnableWeapons", "General", "1")
95
        Settings.Save()
96
        QuickSilver = Settings.GetValueKey("QuickSilverKey", "Main", Keys.M)
97
        UseQuickSilverModel = Settings.GetValueKey("UseQuickSilverModel", "Main", "1") = "1"
98
        EnemySpawnKey = Settings.GetValueKey("EnemySpawnKey", "Main", Keys.PageDown)
99
        Speed = Settings.GetValueKey("Speed", "General", 8)
100
        bTimeScale = Settings.GetValueKey("bTimeScale", "General", Keys.R)
101
        bTimeScaleIncrease = Settings.GetValueKey("bTimeScaleIncrease", "General", Keys.E)
102
        bTimeScaleDecrease = Settings.GetValueKey("bTimeScaleDecrease", "General", Keys.Q)
103
        EffectsEnabled = Settings.GetValueString("EffectsEnabled", "General", "1") = "1"
104
        EnemyEnableWeapons = Settings.GetValueString("EnemyEnableWeapons", "General", "1") = "1"
105
        TimeScale = 0.2
106
        EnemySpeedValue = 1.75F
107
    End Sub
108
109
    Shadows Sub keyDown(ByVal sender As Object, ByVal e As GTA.KeyEventArgs) Handles MyBase.KeyDown
110
        If e.Key = QuickSilver Then
111
            QuickSilverOn = Not QuickSilverOn
112
            If QuickSilverOn Then
113
                If UseQuickSilverModel Then
114
                    Player.Model = New Model("m_y_cowboy_01")
115
                End If
116
                Player.NeverGetsTired = True
117
                Native.Function.Call("SET_CHAR_DEFAULT_COMPONENT_VARIATION", Player.Character, True)
118
                msg("Quicksilver!!!", 2000)
119
            Else
120
                If UseQuickSilverModel Then
121
                    Player.Model = New Model("m_y_cowboy_01")
122
                End If
123
                Player.Character.Task.ClearAllImmediately()
124
                Player.NeverGetsTired = False
125
                Native.Function.Call("SET_CHAR_DEFAULT_COMPONENT_VARIATION", Player.Character, True)
126
                Native.Function.Call("SET_CHAR_ALL_ANIMS_SPEED", Player.Character, 1.0)
127
                Native.Function.Call("Set_Char_Move_Anim_Speed_Multiplier", Player.Character, 1.0)
128
                Native.Function.Call("Set_Char_Climb_Anim_Rate", Player.Character, 1.0)
129
                Game.TimeScale = 1.0
130
                TimeScale = Nothing
131
                msg("Niko!!!", 2000)
132
            End If
133
        End If
134
        If e.Key = EnemySpawnKey Then
135
            QuickSilverEnemy = Not QuickSilverEnemy
136
            If QuickSilverEnemy Then
137
                EnemyEvent()
138
            End If
139
        End If
140
        If QuickSilverOn Then
141
            If e.Key = bTimeScale Then
142
                TimeScaleOn = Not TimeScaleOn
143
            End If
144
        End If
145
    End Sub
146
147
    Private Sub EnemyEvent()
148
        If QuickSilverEnemy Then
149
            msg("Creating New enemy", 2000)
150
            tmpPos = World.GetNextPositionOnPavement(Player.Character.Position.Around(50))
151
            If tmpPos.DistanceTo(Player.Character.Position) > 50 Then tmpPos = Player.Character.Position.Around(50)
152
            If Exists(enemyPed) Then enemyPed.Delete()
153
            Wait(100)
154
            enemyPed = World.CreatePed(PedModel, tmpPos.ToGround)
155
            If Exists(enemyPed) Then
156
                enemyPed.AttachBlip()
157
                enemyPed.AttachBlip.Color = BlipColor.Cyan
158
                enemyPed.BecomeMissionCharacter()
159
                enemyPed.CurrentRoom = Player.Character.CurrentRoom
160
                enemyPed.SetPathfinding(True, True, True)
161
                enemyPed.AlwaysDiesOnLowHealth = False
162
                enemyPed.Enemy = True
163
                enemyPed.WillDoDrivebys = True
164
                enemyPed.PriorityTargetForEnemies = True
165
                enemyPed.CanSwitchWeapons = True
166
                enemyPed.DuckWhenAimedAtByGroupMember = True
167
                enemyPed.WillFlyThroughWindscreen = True
168
                enemyPed.Accuracy = 100
169
                enemyPed.StartKillingSpree(alsoAttackPlayer:=True)
170
                enemyPed.Task.FightAgainst(Player.Character)
171
                enemyPed.MaxHealth = 18000
172
                enemyPed.Armor = 18000
173
                enemyPed.Health = 18000
174
                enemyPed.MakeProofTo(False, True, False, False, False)
175
                If Not EnemyEnableWeapons Then
176
                    enemyPed.Weapons.RemoveAll()
177
                Else
178
                    enemyPed.Weapons.MP5.Ammo = 300
179
                    enemyPed.Weapons.MP5.Select()
180
                    If enemyPed.Weapons.MP5.Ammo = 0 Then
181
                        enemyPed.Weapons.RocketLauncher.Ammo = 50
182
                        enemyPed.Weapons.Grenades.Ammo = 50
183
                        enemyPed.Weapons.AssaultRifle_M4.Ammo = 600
184
                        enemyPed.Weapons.DesertEagle.Ammo = 1500
185
                        enemyPed.Weapons.BarettaShotgun.Ammo = 80
186
                    End If
187
                End If
188
            End If
189
        End If
190
    End Sub
191
192
    Shadows Sub keyUp(ByVal sender As Object, ByVal e As GTA.KeyEventArgs) Handles MyBase.KeyUp
193
    End Sub
194
195
    Public Sub Effects(ByVal EffectsPed As Ped)
196
        Native.Function.Call("TRIGGER_PTFX_ON_PED_BONE", "qub_sm_explode_blue", EffectsPed, 0, 0, 0, 0, 0, 0, Bone.Spine, 0.25)
197
        Native.Function.Call("TRIGGER_PTFX_ON_PED_BONE", "qub_sm_explode_blue", EffectsPed, 0, 0, 0, 0, 0, 0, Bone.LeftArmRoll, 0.25)
198
        Native.Function.Call("TRIGGER_PTFX_ON_PED_BONE", "qub_sm_explode_blue", EffectsPed, 0, 0, 0, 0, 0, 0, Bone.RightArmRoll, 0.25)
199
        Native.Function.Call("TRIGGER_PTFX_ON_PED_BONE", "qub_sm_explode_blue", EffectsPed, 0, 0, 0, 0, 0, 0, Bone.LeftFoot, 0.25)
200
        Native.Function.Call("TRIGGER_PTFX_ON_PED_BONE", "qub_sm_explode_blue", EffectsPed, 0, 0, 0, 0, 0, 0, Bone.RightFoot, 0.25)
201
        Native.Function.Call("TRIGGER_PTFX_ON_PED_BONE", "qub_sm_explode_blue", EffectsPed, 0, 0, 0, 0, 0, 0, Bone.RightHand, 0.25)
202
        Native.Function.Call("TRIGGER_PTFX_ON_PED_BONE", "qub_sm_explode_blue", EffectsPed, 0, 0, 0, 0, 0, 0, Bone.LeftHand, 0.25)
203
    End Sub
204
205
    Private Sub general_tick(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Tick
206
        If TimeScaleOn Then
207
            If TimeScale = 0 Then
208
                TimeScaleZero = Not TimeScaleZero
209
            End If
210
        End If
211
        If QuickSilverOn Then
212
            If Player.Character.isInAir = False AndAlso Player.Character.isRagdoll = False Then
213
                If Game.isGameKeyPressed(GameKey.Sprint) Then
214
                    PlayerSpeedValue = 1.75F
215
                    If (Game.isGameKeyPressed(GameKey.MoveForward) OrElse Game.isGameKeyPressed(GameKey.MoveLeft) OrElse Game.isGameKeyPressed(GameKey.MoveRight)) Then
216
                        RunDir.X = Player.Character.Direction.X * Speed '8
217
                        RunDir.Y = Player.Character.Direction.Y * Speed '8
218
                        RunDir.Z = Player.Character.Direction.Z
219
220
                        Player.Character.ApplyForce(RunDir)
221
                    End If
222
                    Native.Function.Call("set_char_all_anims_speed", Player.Character, PlayerSpeedValue)
223
                    If EffectsEnabled Then
224
                        Effects(Player.Character)
225
                    End If
226
                Else
227
                    If Player.Character.isInMeleeCombat Then
228
                        PlayerSpeedValue = 2.0F
229
                    Else
230
                        PlayerSpeedValue = 1.1F
231
                    End If
232
                    Speed -= 0.5
233
                    If Speed < 0 Then Speed = 0
234
                End If
235
            End If
236
            If TimeScaleOn Then
237
                Game.TimeScale = TimeScale
238
                msg("TimeScale: " & TimeScale.ToString, 2000)
239
                If TimeScale = 0.2 Then
240
                    Native.Function.Call("SET_CHAR_ALL_ANIMS_SPEED", Player.Character, 5.0F)
241
                    Native.Function.Call("Set_Char_Move_Anim_Speed_Multiplier", Player.Character, 5.0F)
242
                    Native.Function.Call("Set_Char_Climb_Anim_Rate", Player.Character, 5.0F)
243
                End If
244
                If Game.isKeyPressed(bTimeScaleIncrease) Then
245
                    TimeScale += 0.1
246
                    If TimeScale > 1.0 Then TimeScale = 1.0
247
                ElseIf Game.isKeyPressed(bTimeScaleDecrease) Then
248
                    TimeScale -= 0.1
249
                    If TimeScale < 0 Then TimeScale = 0
250
                End If
251
                If TimeScaleZero Then
252
                    Native.Function.Call("SET_CHAR_ALL_ANIMS_SPEED", Player.Character, 10.0F)
253
                    Native.Function.Call("Set_Char_Move_Anim_Speed_Multiplier", Player.Character, 10.0F)
254
                    Native.Function.Call("Set_Char_Climb_Anim_Rate", Player.Character, 10.0F)
255
                End If
256
            Else
257
                Native.Function.Call("SET_CHAR_ALL_ANIMS_SPEED", Player.Character, PlayerSpeedValue)
258
                Native.Function.Call("Set_Char_Move_Anim_Speed_Multiplier", Player.Character, PlayerSpeedValue)
259
                Native.Function.Call("Set_Char_Climb_Anim_Rate", Player.Character, PlayerSpeedValue)
260
                Game.TimeScale = 1.0
261
                TimeScale = 0.2
262
            End If
263
        End If
264
        If QuickSilverOn Then
265
            Player.MaxHealth = 100
266
            Player.Character.MaxHealth = 100
267
            Player.Character.Health = 100
268
            Player.MaxArmor = 100
269
            Player.Character.Armor = 100
270
            Dim Armor As Integer = Player.Character.Armor
271
            Dim Health As Integer = Player.Character.Health
272
            If (Player.Character.isAlive AndAlso Armor < 100) Then
273
                Player.Character.Armor += 0.5
274
            End If
275
            If (Player.Character.isAlive AndAlso Armor < Health) Then
276
                Player.Character.Health += 0.5
277
            End If
278
        End If
279
    End Sub
280
281
    Private Sub Enemy_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Tick
282
        If QuickSilverEnemy Then
283
            If Exists(enemyPed) Then
284
                If enemyPed.isIdle Then
285
                    enemyPed.StartKillingSpree(alsoAttackPlayer:=True)
286
                    enemyPed.Task.FightAgainst(Player.Character)
287
                End If
288
            End If
289
        End If
290
        If TimeScaleOn Then
291
            If TimeScale = 0 Then
292
                TimeScaleZero = Not TimeScaleZero
293
            End If
294
        End If
295
        If QuickSilverEnemy Then
296
            If Exists(enemyPed) Then
297
                If enemyPed.isDead AndAlso Not enemyPed.isAlive Then
298
                    If enemyPed.AttachBlip.Exists Then
299
                        enemyPed.AttachBlip.Delete()
300
                    End If
301
                End If
302
                If EffectsEnabled Then
303
                    If enemyPed.isAlive Then
304
                        Effects(enemyPed)
305
                    End If
306
                End If
307
                Decide = TRandom.Next(200, 400)
308
                If Decide <= 225 Then
309
                    DecisionTaken = True
310
                Else
311
                    DecisionTaken = False
312
                End If
313
                Dim AllPeds As Ped() = Nothing
314
                AllPeds = World.GetAllPeds
315
                If Exists(AllPeds) Then
316
                    For Each p As Ped In AllPeds
317
                        If Exists(p) AndAlso (p <> enemyPed) AndAlso (enemyPed.isAlive) AndAlso Not (enemyPed.isDead) AndAlso (p.isAlive) AndAlso Not Exists(p.CurrentVehicle) Then
318
                            If enemyPed.Position.DistanceTo(p.Position) < 2.0 Then
319
                                If DecisionTaken Then
320
                                    enemyPed.PreventRagdoll = True
321
                                    enemyPed.isRagdoll = False
322
                                    Dim MeleeAnimSet As AnimationSet
323
                                    Dim MeleeAnimName1 As String = "lowblow_r"
324
                                    Dim MeleeAnimName2 As String = "lowblow_l"
325
                                    MeleeAnimSet = New AnimationSet("melee_player_unarmed")
326
327
                                    Native.Function.Call("REQUEST_ANIMS", MeleeAnimSet.Name)
328
329
                                    If rndAnim.Next(0, 2) >= 1 Then
330
                                        enemyPed.Animation.Play(MeleeAnimSet, MeleeAnimName1, 8.0)
331
                                    Else
332
                                        enemyPed.Animation.Play(MeleeAnimSet, MeleeAnimName2, 8.0)
333
                                    End If
334
                                    If enemyPed.Animation.isPlaying(MeleeAnimSet, MeleeAnimName1) OrElse
335
                                     enemyPed.Animation.isPlaying(MeleeAnimSet, MeleeAnimName2) Then
336
                                        If (p.Position.DistanceTo(enemyPed.GetBonePosition(Bone.RightHand)) OrElse p.Position.DistanceTo(enemyPed.GetBonePosition(Bone.LeftHand))) < 1.0 Then
337
                                            enemyPed.Heading = Helper.DirectionToHeading(p.Position - enemyPed.Position)
338
                                            enemyPed.ApplyForce(Vector3.Normalize(p.Position - enemyPed.Position) * Speed)
339
                                            enemyForce.X = enemyPed.Direction.X * Speed '8
340
                                            enemyForce.Y = enemyPed.Direction.Y * Speed '8
341
                                            enemyForce.Z = enemyPed.Direction.Z
342
343
                                            p.ApplyForce(enemyForce)
344
                                            p.PreventRagdoll = False
345
                                            p.ForceRagdoll(2000, False)
346
                                            Native.Function.Call("damage_char", p, 20, 0)
347
                                        End If
348
                                    End If
349
                                    Wait(100)
350
                                    If p.Position.DistanceTo(enemyPed.Position) > 5.0 Then
351
                                        enemyPed.PreventRagdoll = False
352
                                    End If
353
                                    enemyPed.StartKillingSpree(alsoAttackPlayer:=True)
354
                                    enemyPed.Task.FightAgainst(Player.Character)
355
                                End If
356
                            End If
357
                        End If
358
                    Next
359
                End If
360
            End If
361
        End If
362
        If QuickSilverEnemy Then
363
            If Exists(enemyPed) Then
364
                If TimeScaleOn Then
365
                    Native.Function.Call("SET_CHAR_ALL_ANIMS_SPEED", enemyPed, 5.0F)
366
                    Native.Function.Call("Set_Char_Move_Anim_Speed_Multiplier", enemyPed, 5.0F)
367
                    Native.Function.Call("Set_Char_Climb_Anim_Rate", enemyPed, 5.0F)
368
                    If TimeScaleZero Then
369
                        Native.Function.Call("SET_CHAR_ALL_ANIMS_SPEED", enemyPed, 10.0F)
370
                        Native.Function.Call("Set_Char_Move_Anim_Speed_Multiplier", enemyPed, 10.0F)
371
                        Native.Function.Call("Set_Char_Climb_Anim_Rate", enemyPed, 10.0F)
372
                    End If
373
                Else
374
                    Native.Function.Call("SET_CHAR_ALL_ANIMS_SPEED", enemyPed, EnemySpeedValue)
375
                    Native.Function.Call("Set_Char_Move_Anim_Speed_Multiplier", enemyPed, EnemySpeedValue)
376
                    Native.Function.Call("Set_Char_Climb_Anim_Rate", enemyPed, EnemySpeedValue)
377
                End If
378
            End If
379
        End If
380
    End Sub
381
382
    Private Sub console_CMD(ByVal sender As Object, ByVal e As ConsoleEventArgs) Handles MyBase.ConsoleCommand
383
    End Sub
384
385
    Private Sub GraphicsEventHandler(ByVal sender As Object, ByVal e As GTA.GraphicsEventArgs) Handles MyBase.PerFrameDrawing
386
    End Sub
387
388
    Private Sub msg(ByVal sMsg As String, ByVal time As Int32)
389
        Native.Function.Call("PRINT_STRING_WITH_LITERAL_STRING_NOW", "STRING", sMsg, time, 1)
390
    End Sub
391
    Private Declare Auto Function GetPrivateProfileString Lib "Kernel32" _
392
         (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As StringBuilder, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
393
394
    Private Declare Auto Function WritePrivateProfileString Lib "Kernel32" _
395
        (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Integer
396
397
    Private Function ReadINI(ByVal key_name As String, ByVal section_name As String, ByVal default_value As String) As String
398
        Const MAX_LENGTH As Integer = 500
399
        Dim string_builder As New StringBuilder(MAX_LENGTH)
400
401
        GetPrivateProfileString(section_name, key_name, default_value, string_builder, MAX_LENGTH, iniFile)
402
403
        Return string_builder.ToString()
404
    End Function
405
406
    Private Sub WriteINI(ByVal key_name As String, ByVal section_name As String, ByVal value As String)
407
        WritePrivateProfileString(section_name, key_name, value, iniFile)
408
    End Sub
409
410
    Private Sub checkIniExists()
411
        If Not File.Exists(iniFile) Then
412
            File.CreateText(iniFile).Dispose()
413
414
            Wait(100)
415
        End If
416
    End Sub
417
418
    Private Function Read_INI_String(opt As String, categoy As String, def As String) As String
419
        If ReadINI(opt, categoy, "") = "" Then WriteINI(opt, categoy, def)
420
421
        Return ReadINI(opt, categoy, def)
422
    End Function
423
End Class