55 lines
2.4 KiB
Python
55 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Source spells whose aura can only ever sit on its own caster.
|
|
|
|
Rule (source Spell.dbc, 1.12 disk layout): every non-empty effect has
|
|
ImplicitTargetA 1 (TARGET_SELF) and ImplicitTargetB 0, no effect is a party/raid
|
|
area aura, and at least one effect is APPLY_AURA (6). Such an aura's caster is
|
|
its holder, so native AuraApplication would send NOCASTER with a CastID and no
|
|
CastUnit. The client plays aura state kits (Shadowform, Divine Shield, Ice
|
|
Block, Evasion ...) only with that caster context, never with an empty CastUnit.
|
|
|
|
usage: source_self_only_aura_profile.py <Spell.dbc> <output.hpp>
|
|
"""
|
|
import struct
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
from turtle_data import spell_layout
|
|
|
|
AREA = {35, 65, 119, 128, 129, 143}
|
|
|
|
|
|
def load(path):
|
|
data = Path(path).read_bytes()
|
|
if data[:4] != b'WDBC':
|
|
raise ValueError('not a WDBC file')
|
|
count, fields, size, _ = struct.unpack_from('<4I', data, 4)
|
|
return [struct.unpack_from('<%dI' % fields, data, 20 + i * size) for i in range(count)]
|
|
|
|
|
|
def self_only(row, layout):
|
|
effects = [(row[layout['Effect'] + i], row[layout['ImplicitTargetA'] + i], row[layout['ImplicitTargetB'] + i]) for i in range(3)]
|
|
used = [e for e in effects if e[0]]
|
|
return bool(used) and any(e[0] == 6 for e in used) and all(a == 1 and b == 0 and e not in AREA for e, a, b in used)
|
|
|
|
|
|
def main(source, output):
|
|
layout = spell_layout()
|
|
spells = sorted(r[0] for r in load(source) if 0 < r[0] <= 0x7fffff and self_only(r, layout))
|
|
body = ',\n'.join(','.join(map(str, spells[i:i + 16])) for i in range(0, len(spells), 16))
|
|
Path(output).write_text(
|
|
'// Generated by ops/source_self_only_aura_profile.py from the source Spell.dbc.\n'
|
|
'// Auras that can only sit on their own caster: present with native self-cast\n'
|
|
'// context (CastID + NOCASTER, no CastUnit) so the client plays their state kits.\n'
|
|
'#pragma once\n#include <algorithm>\n#include <cstdint>\n#include <iterator>\n'
|
|
'namespace gateway::source_self_only_aura_profile {\n'
|
|
'inline constexpr uint32_t Spells[]={\n' + body + '};\n'
|
|
'inline bool contains(uint32_t spell){return std::binary_search(std::begin(Spells),std::end(Spells),spell);}\n'
|
|
'}\n')
|
|
print(len(spells), 'self-only aura spells')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main(*sys.argv[1:3])
|