From 0c406f4e8d5d32fcdd257f1183571cd78358aac5 Mon Sep 17 00:00:00 2001 From: cecilkorik Date: Sun, 26 Nov 2017 15:43:56 -0500 Subject: [PATCH] initial version --- .hgignore | 0 patch_7dtd.py | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 .hgignore create mode 100644 patch_7dtd.py diff --git a/.hgignore b/.hgignore new file mode 100644 index 0000000..e69de29 diff --git a/patch_7dtd.py b/patch_7dtd.py new file mode 100644 index 0000000..1a18a93 --- /dev/null +++ b/patch_7dtd.py @@ -0,0 +1,88 @@ +import os +import sys +import time +from datetime import datetime +from xml.etree import ElementTree + +steampaths = ['C:\\games_ssd\\steam', 'D:\\games\\steam', 'C:\\games\steam', 'C:\\program files (x86)\\steam', 'C:\\program files\\steam'] +steamcommon = '\\steamapps\\common\\7 Days To Die\\Data\\Config' + +found_steam = None + +for sp in steampaths: + if os.path.exists(sp + steamcommon): + found_steam = sp + break + +if not found_steam: + print "Failed to find 7DTD on steam..." + sys.exit(1) + +gamepath = found_steam + steamcommon + "\\" + +ents = ElementTree.parse(gamepath + 'entityclasses.xml') +eroot = ents.getroot() +for entity in eroot.iter('entity_class'): + ename = entity.get('name') + for prp in entity.iter('property'): + pname = prp.get('name') + if pname == 'ApproachSpeed': + pv = float(prp.get('value')) + if pv <= 0.2: + """ No modifications to speeds already set to 0.2 or less """ + continue + + ptv = prp.get('pretweak_value') + if ptv != None: + pv = float(ptv) + else: + prp.set('pretweak_value', str(pv)) + + + if pv > 0.9: + prp.set('value', str('0.4')) + else: + prp.set('value', str('0.2')) + + elif pname == 'NightApproachSpeed': + pv = float(prp.get('value')) + if pv <= 0.2: + """ No modifications to speeds already set to 0.2 or less """ + continue + + ptv = prp.get('pretweak_value') + if ptv != None: + pv = float(ptv) + else: + prp.set('pretweak_value', str(pv)) + + + if pv > 0.9: + prp.set('value', str('0.6')) + else: + prp.set('value', str('0.4')) + + elif pname == 'PanicSpeed': + pv = float(prp.get('value')) + if pv <= 0.2: + """ No modifications to speeds already set to 0.2 or less """ + continue + + if ename[:6] == 'animal' and ename != 'animalBear': + """ Animals are pretty ok as-is, except bears which are assholes """ + continue + + ptv = prp.get('pretweak_value') + if ptv != None: + pv = float(ptv) + else: + prp.set('pretweak_value', str(pv)) + + if pv > 0.9: + prp.set('value', str('0.6')) + else: + prp.set('value', str('0.3')) + + + +ents.write(gamepath + "entityclasses.xml") \ No newline at end of file