-
Notifications
You must be signed in to change notification settings - Fork 1
/
Install_bshift_Support.sh
237 lines (189 loc) · 5.12 KB
/
Install_bshift_Support.sh
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
#!/bin/bash
# Sven Co-op support script for Valve games.
# Discord channel: https://discord.gg/y87qr6Y
# Forums: https://forums.svencoop.com/
init() {
# Install location:
# true: svencoop_addon, false: svencoop
addondir=false
# Don´t change anything below this line unless you know what are doing!!
# Set root for the script.
script_root="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Safeguard¹: CD to the correct dir, no matter from where the script is ran.
if [ "${PWD##*/}" != "svencoop" ];
then
cd "$script_root"
fi
# Safeguard²: prevent running this script outside svencoop folder if the above fails.
if [ "${PWD##*/}" != "svencoop" ];
then
echo "Error: Script running outside \"svencoop\" folder! Exiting..."
exit 1
fi
# Game name
gamename="Blue Shift"
# Get OS arch type
osarch=$(getconf LONG_BIT)
# Default ripent is 64-bit.
# We have to use the right binary otherwise patching will fail...
if [ "$osarch" == "64" ]
then
ripent=maps/ripent
else
ripent=maps/ripent_32
fi
# BS BSP Patcher binary
bsp=BShiftBSPConverter
# Destination path for maps
if [[ "$addondir" == true ]]
then
# svencoop_addon folder
instdir=svencoop_addon
else
# svencoop standard folder
instdir=svencoop
fi
# Blue Shift relative dir
bsdir="../../Half-Life/bshift"
# map list
maplist="
ba_tram1 ba_tram2 ba_tram3 \
ba_security1 ba_security2 ba_maint ba_elevator \
ba_canal1 ba_canal1b ba_canal2 ba_canal3 \
ba_yard1 ba_yard2 ba_yard3 ba_yard3a ba_yard3b ba_yard4 ba_yard4a ba_yard5 ba_yard5a ba_teleport1 \
ba_xen1 ba_xen2 ba_xen3 ba_xen4 ba_xen5 ba_xen6 \
ba_power1 ba_power2 \
ba_teleport2 \
ba_outro"
# Chapter 1: Living Quarters Outbound
# Chapter 2: Insecurity
# Chapter 3: Duty Calls
# Chapter 4: Captive Freight
# Chapter 5: Focal Point
# Chapter 6: Power Struggle
# Chapter 7: A Leap Of Faith
# Chapter 8: Deliverance
}
messages () {
echo ""
echo "-= Half-Life: $gamename map support for Sven Co-op =-"
echo ""
echo "Warning: around 60MB is used after installation."
echo ""
echo "Installation may take a few minutes depending on"
echo "your system performance. Please be patient."
echo ""
echo "----------------------------------------------------------------------------"
echo "IMPORTANT: To install $gamename support, you must own 'Half-Life:"
echo "$gamename' and have it fully downloaded and installed on Steam!"
echo "----------------------------------------------------------------------------"
echo ""
# It's time to choose! - GMan
for count in {5..1}; do echo -ne "Press CTRL+C to cancel or wait $count seconds..."'\r'; sleep 1; done; echo ""
clear
echo ""
echo "OS architecture: $osarch-bit"
echo "Install directory: $instdir"
echo "ripent binary: $ripent"
echo ""
echo ""
}
validation() {
command -v unzip >/dev/null 2>&1 || {
echo "Unzip not found."
echo "You can install by using \"sudo apt-get install unzip\""
echo "for Ubuntu and Debian, and \"yum install unzip\""
echo "for RedHat or CentOS."
exit 1
}
if [ ! -f "$ripent" ]
then
echo "Missing $ripent, cannot continue. Corrupted install?"
exit 1
else
if [[ ! -x "$ripent" ]]
then
chmod +x $ripent
fi
fi
if [ ! -f "$bsp" ]
then
echo "Missing $bsp, cannot continue. Corrupted install?"
exit 1
else
if [[ ! -x "$bsp" ]]
then
chmod +x $bsp
fi
fi
# Check if Blue Shift game directory exists
if [ -d "$bsdir" ];
then
echo "Found $gamename installation."
copybs
fi
for mcheck in $maplist; do
# Extra check: let's make sure we have all map files before doing anything!
if [ -f "../$instdir/maps/$mcheck.bsp" ]
then
echo "Found $mcheck in maps folder!"
else
# Show message about missing file to user and exit script.
echo ""
echo "Oops! Map file $mcheck.bsp is missing. Please make sure you"
echo "have a working $gamename installation and/or"
echo "all map files in maps folder before running this script!"
echo ""
exit 1
fi
done
echo ""
}
# Copy map files from original installation
copybs(){
# Create required folders if is a clean installation
if [ ! -d "../$instdir/gfx/env" ];
then
echo "Creating gfx/env/ directory..."
mkdir -p ../$instdir/gfx/env
fi
if [ ! -d "../$instdir/maps" ];
then
echo "Creating maps directory..."
mkdir -p ../$instdir/maps
fi
for copy in $maplist; do
echo "Copying $copy..."
cp "$bsdir/maps/$copy.bsp" "../$instdir/maps/$copy.bsp"
done
echo "Copying sky textures..."
cp $bsdir/gfx/env/* ../$instdir/gfx/env/
echo ""
}
# Patching / importing custom entities
patching() {
echo "Unzipping support files..."
unzip -o bshift_support.sven -d ../$instdir/maps >/dev/null 2>&1
for target in $maplist; do
echo "Patching $target..."
./$bsp "../$instdir/maps/$target".bsp >/dev/null 2>&1
./$ripent -import "../$instdir/maps/$target".bsp >/dev/null 2>&1
done
echo ""
}
# clean all the remaining mess :)
cleanup(){
echo "Cleaning up..."
rm ../$instdir/maps/ba_*.ent
echo ""
}
# Time to call the functions!
init
messages
validation
patching
cleanup
# We made it Mr Calhoun, we made it!
echo "All done! If you have any problems, ask"
echo "for help at https://forums.svencoop.com"
exit 0