-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgen_spawn_randomizer.py
70 lines (60 loc) · 2.56 KB
/
gen_spawn_randomizer.py
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
from bl3hotfixmod import Mod
from bl3data import BL3Data
import os, random
# Utils: spawnoptions.txt and bpchars.txt
# Some enemy spawns may not be under and /Enemies directory (see Dandelion's CrewChallenges/Kill/ directory)
# Some enemies can't be killed (Mime Bots, Event Enemies, Riders from DLC3), look into this (removing or making them killable) (took some out entirely for right now)
# Looking into SpawnerStyles (very experimental), would involve randomizing where the SpawnOptions are used too (like on what maps)
def SpawnRandom():
mod=Mod('spawn_randomizer.bl3hotfix',
'Spawn Randomizer',
'SSpyR',
[
'Mod that randomizes enemies spawns to varying success'
],
lic=Mod.CC_BY_SA_40
)
data=BL3Data()
dir=os.path.dirname(os.path.realpath(__file__))
if "\\" in dir:
dir=dir.replace('\\', '/')
dir=dir+'/utils/'
bpchars=open(os.path.join(dir, 'bpchars.txt')).readlines()
spawnoptions=open(os.path.join(dir, 'spawnoptions.txt')).readlines()
for spwop in spawnoptions:
auxchar=bpchars.copy()
allexports=data.get_data(spwop)
try:
optdata=data.get_exports(spwop, 'SpawnOptionData')[0]
for idx, option in enumerate(optdata['Options']):
export_idx=option['Factory']['export']
randchar=random.choice(auxchar)
bpchar=randchar
index=auxchar.index(bpchar)
del auxchar[index]
cond=bpchar.split('/')
cond='.'+cond[len(cond)-1]+'_C'
bpchar=bpchar+cond
factory = allexports[export_idx-1]
location=None
try:
location=factory['SpawnExtent']
except KeyError:
print('No Spawn Extent')
mod.reg_hotfix(Mod.EARLYLEVEL, 'MatchAll',
str.rstrip(spwop),
'Options.Options[{}].Factory.Object..AIActorClass'.format(idx),
Mod.get_full_cond(bpchar, 'BlueprintGeneratedClass')
)
mod.newline()
#if location != None:
# location['z']=900
# heightnum=location['z']
# mod.reg_hotfix(Mod.EARLYLEVEL, 'MatchAll',
# str.rstrip(spwop),
# 'Options.Options[{}].Factory.Object..SpawnExtent'.format(idx),
# location
# )
# mod.newline()
except IndexError:
print('No Exports of Type SpawnOptionData')