summaryrefslogtreecommitdiff
path: root/devtools/goldsrc_port_scripts/goldsrc_qc_9way_blends.py
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /devtools/goldsrc_port_scripts/goldsrc_qc_9way_blends.py
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'devtools/goldsrc_port_scripts/goldsrc_qc_9way_blends.py')
-rw-r--r--devtools/goldsrc_port_scripts/goldsrc_qc_9way_blends.py87
1 files changed, 87 insertions, 0 deletions
diff --git a/devtools/goldsrc_port_scripts/goldsrc_qc_9way_blends.py b/devtools/goldsrc_port_scripts/goldsrc_qc_9way_blends.py
new file mode 100644
index 0000000..19869d9
--- /dev/null
+++ b/devtools/goldsrc_port_scripts/goldsrc_qc_9way_blends.py
@@ -0,0 +1,87 @@
+
+# This script converts old 9 way blends that look like this:
+#
+# $sequence crouch_tommy_shoot "crouch_tommy_shootupL" "crouch_tommy_shootup" "crouch_tommy_shootupR" "crouch_tommy_shootmidL" "crouch_tommy_shootmid" "crouch_tommy_shootmidR" "crouch_tommy_shootdownL" "crouch_tommy_shootdown" "crouch_tommy_shootdownL" blend XR 45 -45 fps 30 origin 0 0 17 { event 7002 1 "1" }
+#
+# to this:
+#
+# $sequence crouch_tommy_shoot {
+# "crouch_tommy_shootupL" "crouch_tommy_shootup" "crouch_tommy_shootupR"
+# "crouch_tommy_shootmidL" "crouch_tommy_shootmid" "crouch_tommy_shootmidR"
+# "crouch_tommy_shootdownL" "crouch_tommy_shootdown" "crouch_tommy_shootdownL"
+# blendwidth 3 blend body_yaw -45 45 blend body_pitch -65 65
+# fps 30 origin 0 0 17 { event 7002 1 "1" }
+# }
+
+import sys
+import re
+import string
+
+if len( sys.argv ) < 3:
+ print "Requires 2 parameters: <input file> <output file>"
+ sys.exit( 1 )
+
+
+# Read in the file.
+f = open( sys.argv[1], "rt" )
+lines = f.readlines()
+f.close()
+
+
+# Do the search/replace.
+def named( re, name ):
+ return r'(?P<' + name + r'>' + re + ')'
+
+def ident( animName ):
+ if animName:
+ return named( r'\"?\S+\"?', animName )
+ else:
+ return r'\"?\S+\"?'
+
+
+ws = r'\s*'
+
+# THIS IS THE FIRST PASS - ADDS THE 9-WAY BLENDS
+if 1:
+ nineNames = [ws+ident('a'+str(i)) for i in range(1,10)]
+ sequenceAndAnims = named( r'\s*', 'prefix' ) + r'\$sequence' + ws + ident('animName') + string.join( nineNames, '' )
+
+ # NOTE THERE IS A KNOWN BUG HERE - extra NEEDS TO INCLUDE THE 'blend xr -45 45' STUFF SO WE CAN STRIP IT OUT
+ extra = ws + ident('blend') + named( '.+', 'extra' )
+ myRE = re.compile( sequenceAndAnims + extra )
+
+ #lines = ['$sequence crouch_pistol_aim "crouch_pistol_aimupL" "crouch_pistol_aimup" "crouch_pistol_aimupR" "crouch_pistol_aimmidL" "crouch_pistol_aimmid" "crouch_pistol_aimmidR" "crouch_pistol_aimdownL" "crouch_pistol_aimdown" "crouch_pistol_aimdownR" loop blend XR 45 -45 fps 30 origin 0 0 17']
+
+ outLines = []
+ for curLine in lines:
+ m = myRE.match( curLine )
+ if m and (m.group('blend') == 'blend' or m.group('blend') == 'loop'):
+ prefix = m.group('prefix')
+ curLine = prefix + '$sequence %s {\n' % m.group('animName')
+ curLine += prefix + '\t%s %s %s\n' % ( m.group('a1'), m.group('a2'), m.group('a3') )
+ curLine += prefix + '\t%s %s %s\n' % ( m.group('a4'), m.group('a5'), m.group('a6') )
+ curLine += prefix + '\t%s %s %s\n' % ( m.group('a7'), m.group('a8'), m.group('a9') )
+ curLine += prefix + '\tblendwidth 3 blend body_yaw -45 45 blend body_pitch -65 65\n'
+ curLine += prefix + '\t' + m.group( 'extra' ) + '\n'
+ curLine += prefix + '}\n\n'
+
+ outLines.append( curLine )
+
+# THIS IS THE SECOND PASS - IT ADDS THE UPPER-BODY WEIGHTLISTS
+if 0:
+ lookFor = named( r'\s*', 'start' ) + named( r'blendwidth 3 blend body_yaw -45 45 blend body_pitch -65 65', 'mid' ) + named( r'\s*', 'end' )
+ myRE = re.compile( lookFor )
+
+ outLines = []
+ for curLine in lines:
+ m = myRE.match( curLine )
+ if m:
+ curLine = curLine + m.group('start') + 'weightlist upperbody\n'
+
+ outLines.append( curLine )
+
+
+# Save the output file.
+f = open( sys.argv[2], "wt" )
+f.writelines( outLines )
+f.close()