-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu_vehiclespawner.go
executable file
·109 lines (97 loc) · 2.09 KB
/
menu_vehiclespawner.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package main
import (
"fmt"
. "gtasamod/directcalls"
. "gtasamod/types"
)
const mincar = 400
const maxcar = 611
var lastcar VehicleID
var currcar VehicleID = MODEL_HYDRA //initialise
var currspawn *CVehicle
var angle float32
var keeprotating bool
func menu_vehiclespawn_setup() {
currspawn = nil
lastcar = -1
keeprotating = true
AddFn(func(gi *GameInternals) bool {
if currspawn != nil {
Matrix_SetRotateZOnly(currspawn.Pos, angle)
angle += 0.07
}
return keeprotating
})
}
func menu_vehiclespawn(c uint32) bool {
switch c {
//currcar is zero because no button is pressed
case ArrLeft:
currcar = clampcar(mincar, currcar-1, maxcar, false)
case ArrRight:
currcar = clampcar(mincar, currcar+1, maxcar, true)
case Esc:
//remove spawned car
if currspawn != nil {
//delete car
Vehicle_Destroy(currspawn)
currspawn = nil
}
fallthrough
case Enter:
//keep spawned car
if currspawn != nil {
//turn indestructible off
currspawn.VehicleFlags.CanBeDamagedToggle()
currspawn.PhysFlags.CollidableToggle(true)
}
keeprotating = false
Hud_SetHelpMessage("\x00", false, false, false) //clear
return false
}
if currcar != lastcar {
if currspawn != nil {
//delete car
Vehicle_Destroy(currspawn)
}
//spawn new car
currspawn = Cheat_NewVehicle((int32)(currcar))
if currspawn != nil {
//disable destructability
currspawn.VehicleFlags.CanBeDamagedToggle()
currspawn.PhysFlags.CollidableToggle(false)
}
lastcar = currcar
}
Hud_SetHelpMessage(fmt.Sprintf("CarID: %d\nName: %s", currcar, currcar.String()), false, true, false)
return true
}
func init() {
NewMenu(F9, menu_vehiclespawn, menu_vehiclespawn_setup)
}
func clampcar(min, current, max VehicleID, up bool) VehicleID {
switch current {
case 449, 537, 538, 569, 570, 590:
//crashy id, skip
if up {
current++
} else {
current--
}
return clampcar(min, current, max, up)
default:
break
}
//nether the min-est nor the max-est is crashy, so no issue
if max < min {
//sanity
return min
}
if current < min {
return min
}
if current > max {
return max
}
return current
}