Open Die4Ever opened 2 years ago
blood = {'swappableItems':{}, 'swappableEnemies':{}, 'keyItems':{}, 'traps':{}, 'switches':{}}
import json
blood_sprites = json.load(open('blood_sprites.json'))
def add_sprite(k, spritenum, v):
d = dict(name=v['name'], category=v['category'], lowtag=k)
if 'repeats' in v:
d.update(xrepeat=v['repeats']['x'], yrepeat=v['repeats']['y'])
if d['category'] in ['weapons', 'ammo', 'items']:
blood['swappableItems'][spritenum] = d
elif d['category'] == 'keys':
blood['keyItems'][spritenum] = d
elif d['category'] == 'monsters':
blood['swappableEnemies'][spritenum] = d
elif d['category'] == 'traps':
blood['traps'][spritenum] = d
elif d['category'] == 'switches':
blood['switches'][spritenum] = d
for k,v in blood_sprites.items():
if 'tile_config' not in v:
continue
if 'tile' in v['tile_config']:
spritenum = v['tile_config']['tile']
add_sprite(k, spritenum, v)
elif 'tiles' in v['tile_config']:
for t in v['tile_config']['tiles']:
spritenum = t
add_sprite(k, spritenum, v)
for k in blood:
print('\n', k)
sprites = list(blood[k].keys())
sprites.sort()
for i in sprites:
s = blood[k][i]
data = 'SpriteInfo(\'' + s['name'] + '\', \'' + s['category'] + '\', lowtag=' + str(s['lowtag'])
if 'xrepeat' in s:
data += ', xrepeat=' + str(s['xrepeat']) + ', yrepeat=' + str(s['yrepeat'])
data += '),'
print(str(i) +': ', data, sep='')
print('')
def GetPicnumName(self, picnum: int) -> str:
valname = None
if self.gameMapSettings and picnum in self.gameMapSettings.swappableItems:
valname = self.gameMapSettings.swappableItems[picnum]['name']
elif self.gameMapSettings and picnum in self.gameMapSettings.swappableEnemies:
valname = self.gameMapSettings.swappableEnemies[picnum]['name']
if valname:
return valname# + ' ('+str(picnum)+')'
return str(picnum)
def DescribeSprite(self, sprite) -> str:
name = self.GetPicnumName(sprite.picnum)
# tuple gives parens so it looks better than a list
pos = tuple(sprite.pos)
category = ''
if self.gameMapSettings and sprite.picnum in self.gameMapSettings.swappableItems:
category = self.gameMapSettings.swappableItems[sprite.picnum].get('category', '')
elif self.gameMapSettings and sprite.picnum in self.gameMapSettings.swappableEnemies:
category = self.gameMapSettings.swappableEnemies[sprite.picnum].get('category', '')
info = ' \n' + str(sprite.picnum) + ": SpriteInfo('" + name + "', '" + category + "', lowtag=" + str(sprite.lowtag)
info += ', xrepeat=' + str(sprite.texcoords[0]) + ', yrepeat=' + str(sprite.texcoords[1])
info += '),\n'
if sprite.picnum not in self.gameMapSettings.swappableEnemies:
info = ''
return name + ' ' + str(pos) + desc
also needs the lowtag to go with the palette, at least for Blood
blood = {'swappableItems':{}, 'swappableEnemies':{}, 'keyItems':{}, 'traps':{}, 'switches':{}}
import json
blood_sprites = json.load(open('blood_sprites.json'))
def add_sprite(k, spritenum, v):
palettes = [v.get('palette', 0)]
category = None
d = dict(name=v['name'], category=v['category'], lowtag=k)
if 'repeats' in v:
d.update(xrepeat=v['repeats']['x'], yrepeat=v['repeats']['y'])
if d['category'] in ['weapons', 'ammo', 'items']:
category = 'swappableItems'
elif d['category'] == 'keys':
category = 'keyItems'
elif d['category'] == 'monsters':
category = 'swappableEnemies'
elif d['category'] == 'traps':
category = 'traps'
elif d['category'] == 'switches':
category = 'switches'
if not category:
print(k, spritenum, v, d)
return
if spritenum in blood[category] and 'palettes' in blood[category][spritenum]:
palettes = palettes + blood[category][spritenum]['palettes']
d['palettes'] = list(set(palettes))
blood[category][spritenum] = d
for k,v in blood_sprites.items():
if 'tile_config' not in v:
continue
if 'tile' in v['tile_config']:
spritenum = v['tile_config']['tile']
add_sprite(k, spritenum, v)
elif 'tiles' in v['tile_config']:
for t in v['tile_config']['tiles']:
spritenum = t
add_sprite(k, spritenum, v)
for k in blood:
print('\n\n', k)
sprites = list(blood[k].keys())
sprites.sort()
for i in sprites:
s = blood[k][i]
data = 'SpriteInfo(\'' + s['name'] + '\', \'' + s['category'] + '\', lowtag=' + str(s['lowtag'])
if 'xrepeat' in s:
data += ', xrepeat=' + str(s['xrepeat']) + ', yrepeat=' + str(s['yrepeat'])
if s['palettes'] != [0]:
data += ', palettes=' + str(s['palettes'])
data += '),'
print(str(i) +': ', data, sep='')
print('')
sys.exit(0)
for Blood: https://github.com/thomasrogers03/bloom/blob/master/bloom/resources/sprite_types.yaml
as json