Files
ForeverCore/tools/dungeon_tactics/emit.py
T
Karrz1 ff699fb5cf Sync with WoW Forever 0.1.34: Blizzlike core
Brings forever up to date with our 0.1.34 code for the WoW Forever client 1.60.1.70862.
Blizzlike only: fixes from real game data (packet captures, live hotfixes, player caches, Wowhead and Questie data,
VMaNGOS for the vanilla world) and server fixes. No custom items or custom content; every rate and option defaults
to Blizzard's behaviour.

What is new since 2ae1313e, in short:
- Clients 70790, 70840 and 70862: message numbers, mail, guild window, charters, contact list, add-on whispers.
- Crash and exploit fixes: guild ranks, loot of emptied veins, quest lookups, taxi mask, battleground templates,
  vendor free buys, item sell price, auction house, falling out of the world, bnetserver request limit.
- Classes, talents, pets and buffs from the live game data and Blizzard's hotfixes of November.
- Quests, NPCs, spawns, trainers, loot, fishing, events, Merchant's Favor crates and writs, sealed crate turn-ins.
- Dungeon and raid scripts (Molten Core, Blackwing Lair, Zul'Gurub, Ahn'Qiraj, Shadowfang Keep, Deadmines ...).
- Pathing fixes that help pets and NPCs.
- Russian creature names, quest titles and quest texts.
- README: Blizzlike stance, branches, repack.
2026-11-09 17:27:57 +00:00

181 lines
10 KiB
Python

# Writes the C++ data files (Bot/Dungeon/Tactics/DungeonTacticsData_<key>.cpp, DungeonTacticsMaps.inc) and the per-dungeon docs.
import glob, os, re
import gen_tactics as g
TAG_BITS = ['nuke', 'dmg', 'aoe', 'ground', 'dot', 'heal', 'hot', 'fear', 'stun', 'root', 'snare', 'sleep', 'silence', 'charm', 'summon', 'buff',
'shield', 'debuff', 'curse', 'enrage', 'charge', 'drain', 'stealth', 'cleave', 'knock', 'disarm', 'interrupt', 'immune']
TAG_CPP = {t: t.capitalize() for t in TAG_BITS}
COUNTER = [(1, 'Interrupt'), (2, 'Dispel'), (4, 'Purge'), (8, 'StepOut'), (16, 'StopDamage')]
CC = [(1, 'Polymorph'), (2, 'Sap'), (4, 'FreezeTrap'), (8, 'Shackle'), (16, 'Banish'), (32, 'Hibernate'), (64, 'ScareBeast')]
DISPEL = {None: 'None', 'magic': 'Magic', 'curse': 'Curse', 'poison': 'Poison', 'disease': 'Disease'}
def q(s):
s = s.encode('ascii', 'replace').decode('ascii').replace('\\', '\\\\').replace('"', '\\"')
return '"%s"' % s
def orflags(prefix, items, zero='None'):
return ' | '.join('%s::%s' % (prefix, n) for n in items) if items else '%s::%s' % (prefix, zero)
def tags_cpp(tags):
return orflags('Tag', [TAG_CPP[t] for t in TAG_BITS if t in tags])
def cast_ms(s):
return 'kCastUnknown' if s['cast'] is None else str(s['cast'])
def spell_line(s):
flags = []
if s['ranged']: flags.append('Ranged')
if s['conf'] in ('u', 'a'): flags.append('Unverified')
if s['scripted']: flags.append('Scripted')
amount = s['dmg'] or s['heal']
return '{ %d, %s, %d, %s, %s, Disp::%s, Tgt::%s, When::%s, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %s, %d, %d, %s },' % (
s['spell'], q(s['name']), s['school'], cast_ms(s), tags_cpp(s['tags']), DISPEL[s['dispel']], s['tgt'], g.WHEN[s['when']],
s['first'][0], s['first'][1], s['repeat'][0], s['repeat'][1], s['hp'][0], s['hp'][1], s['tgt_hp'][0] if s['tgt_hp'] else 0,
s['rng'][0], s['rng'][1], amount, s['tick'],
orflags('Ctr', [n for b, n in COUNTER if s['counter'] & b]), s['sev'], s['hold'], orflags('SF', flags))
def mob_flags(m):
f = []
if m['boss']: f.append('Boss')
if m['heals_allies']: f.append('Healer')
if m['caster']: f.append('Caster')
if m['summoner']: f.append('Summoner')
if m['buffer']: f.append('Buffer')
if m['flee']: f.append('Flees')
if m['cc_priority']: f.append('CcPriority')
if m['cpp']: f.append('CppScript')
if m['scripted_calls']: f.append('Scripted')
return orflags('Mob', f)
def mob_note(m):
n = []
if m['flee']: n.append('flees at %d%% health and runs to other packs' % m['flee'])
if m['cpp']: n.append('behaviour is in a C++ script not carried here')
return '; '.join(n)
def write_cpp(key, d, mobs, out_dir):
L = []
L.append('// Dungeon tactics: %s (map %d). GENERATED by tools/dungeon_tactics/gen_tactics.py from VMaNGOS data; do not edit by hand.' % (d['name'], d['map']))
L.append('// Scenario: %s. Reading guide: doc/dungeon_tactics/README.md, per-mob table: doc/dungeon_tactics/%s.md.' % (d['scenario'], key))
L.append('')
L.append('#include "DungeonTactics.h"')
L.append('')
L.append('namespace Playerbot::Tactics {')
L.append('')
L.append('namespace {')
L.append('')
for m in mobs:
if m['spells']:
L.append('constexpr SpellTactic kSpells_%s_%d[] = {' % (key, m['entry']))
L.append(' // spell, name, school, cast_ms, tags, dispel, target, when, first_min, first_max, repeat_min, repeat_max, hp_max, hp_min, ally_hp_max, range_min, range_max, amount, tick, counters, severity, holds_schools, flags')
for s in m['spells']:
L.append(' ' + spell_line(s))
L.append('};')
if m['summons']:
L.append('constexpr uint32_t kSummons_%s_%d[] = { %s };' % (key, m['entry'], ', '.join(str(x['entry']) for x in m['summons'])))
L.append('')
L.append('constexpr MobTactic kMobs_%s[] = {' % key)
L.append(' // entry, name, level_min, level_max, rank, type, unit_class, spawns, flags, flee_hp, cc, priority, mechanic_immune, school_immune, spells, spell_count, summons, summon_count, note')
for m in sorted(mobs, key=lambda x: x['entry']):
sp = 'kSpells_%s_%d' % (key, m['entry']) if m['spells'] else 'nullptr'
su = 'kSummons_%s_%d' % (key, m['entry']) if m['summons'] else 'nullptr'
L.append(' { %d, %s, %d, %d, %d, %d, %d, %d, %s, %d, %s, %d, 0x%xu, 0x%xu, %s, %d, %s, %d, %s },' % (
m['entry'], q(m['name']), m['lvl'][0], m['lvl'][1], m['rank'], m['type'], m['cls'], min(m['spawns'], 65535), mob_flags(m), m['flee'],
orflags('Cc', [n for b, n in CC if m['cc'] & b]), m['prio'], m['mech_imm'], m['school_imm'], sp, len(m['spells']), su, len(m['summons']), q(mob_note(m))))
L.append('};')
L.append('')
L.append('} // namespace')
L.append('')
L.append('extern MapTactics const kTactics_%s;' % key)
L.append('MapTactics const kTactics_%s = { %d, %s, kMobs_%s, sizeof(kMobs_%s) / sizeof(kMobs_%s[0]) };' % (key, d['map'], q(d['name']), key, key, key))
L.append('')
L.append('} // namespace Playerbot::Tactics')
path = os.path.join(out_dir, 'DungeonTacticsData_%s.cpp' % key)
open(path, 'w', newline='\n').write('\n'.join(L) + '\n')
def write_inc(out_dir):
keys = sorted(re.match(r'DungeonTacticsData_(\w+)\.cpp', os.path.basename(p)).group(1) for p in glob.glob(os.path.join(out_dir, 'DungeonTacticsData_*.cpp')))
L = ['// GENERATED by tools/dungeon_tactics/gen_tactics.py: one line per DungeonTacticsData_<key>.cpp.']
L += ['PB_TACTICS_MAP(%s)' % k for k in keys]
open(os.path.join(out_dir, 'DungeonTacticsMaps.inc'), 'w', newline='\n').write('\n'.join(L) + '\n')
def secs(ms): return ('%g' % (ms / 1000.0))
def timer(s):
f, r = s['first'], s['repeat']
parts = []
if s['when'] != 'combat': parts.append(s['when'])
if s['rng'][1]: parts.append('victim %d-%d y' % s['rng'])
if s['tgt_hp']: parts.append('ally under %d%%' % s['tgt_hp'][0])
if s['hp'] != (100, 0): parts.append('self health %d%%-%d%%' % s['hp'])
if r[1]: parts.append('every %s s' % (secs(r[0]) if r[0] == r[1] else '%s-%s' % (secs(r[0]), secs(r[1]))))
if f[1] and s['when'] == 'combat': parts.append('first at %s s' % (secs(f[0]) if f[0] == f[1] else '%s-%s' % (secs(f[0]), secs(f[1]))))
return ', '.join(parts) or 'once'
def counters_text(s):
out = []
if s['counter'] & 1: out.append('interrupt')
if s['counter'] & 2: out.append('dispel from victim')
if s['counter'] & 4: out.append('purge from mob')
if s['counter'] & 8: out.append('step out')
if s['counter'] & 16: out.append('hold damage')
return ', '.join(out)
def write_doc(key, d, mobs, S, doc_dir):
L = ['# %s (map %d)' % (d['name'], d['map']), '',
'Scenario `%s`. Generated by `tools/dungeon_tactics/gen_tactics.py`; do not edit by hand. Reading guide: [README](README.md).' % d['scenario'], '']
bosses = [m for m in mobs if m['boss']]
bosses.sort(key=lambda m: d['bosses'].index(m['entry']))
L += ['## Bosses', '']
for m in bosses: L += mob_block(m, d) + ['']
L += ['## Trash, most important first', '',
'Kill priority 5 = heals or controls the party, 4 = summons or hard-hitting caster, 3 = buffs allies or drains, 2 = caster, 1 = everything else.', '']
trash = [m for m in mobs if not m['boss']]
trash.sort(key=lambda m: (-m['prio'], m['name']))
for m in trash: L += mob_block(m, d) + ['']
open(os.path.join(doc_dir, '%s.md' % key), 'w', newline='\n').write('\n'.join(L).rstrip() + '\n')
def mob_block(m, d):
t = g.TYPE_NAME.get(m['type'], str(m['type']))
head = '### %s (%d)' % (m['name'], m['entry'])
info = 'level %s, %s, %s%s, %d spawn%s' % ('%d' % m['lvl'][0] if m['lvl'][0] == m['lvl'][1] else '%d-%d' % m['lvl'], t, 'elite' if m['rank'] == 1 else 'rare elite' if m['rank'] == 2 else 'boss' if m['rank'] >= 3 else 'normal',
'', m['spawns'], '' if m['spawns'] == 1 else 's')
L = [head, info + '. Kill priority %d.' % m['prio']]
notes = []
mech = g.decode_mask(m['mech_imm'], g.MECH)
if m['rank'] < 3 and mech: notes.append('immune to: ' + ', '.join(mech))
if m['school_imm']:
notes.append('immune schools: ' + ', '.join(g.SCHOOL_NAMES[i] for i in range(7) if (m['school_imm'] >> i) & 1))
cc = [n for b, n in CC if m['cc'] & b]
if cc and not m['boss']: notes.append('can be crowd controlled by: ' + ', '.join(cc))
if m['cc_priority']: notes.append('**crowd control this one first**')
if m['flee']: notes.append('flees at %d%% health and runs to other packs: finish it with ranged or burst, do not chase' % m['flee'])
if m['heals_allies']: notes.append('heals its allies: interrupt the heals or kill first')
if m['summoner']: notes.append('summons adds')
if m['cpp']: notes.append('behaviour is in a C++ script this table does not carry')
if m['scripted_calls']: notes.append('runs a scripted action list (its casts are included below)')
for n in notes: L.append('- ' + n)
if m['spells']:
L += ['', '| Spell | School | Cast | Does | When | Counter |', '|---|---|---|---|---|---|']
for s in m['spells']:
nm = ('%s (%d)' % (s['name'], s['spell'])) if s['name'] else 'spell %d' % s['spell']
if s['conf'] in ('u', 'a'): nm += ' *'
sch = ', '.join(g.SCHOOL_NAMES[i] for i in range(7) if (s['school'] >> i) & 1) or '?'
cast = '?' if s['cast'] is None else 'instant' if s['cast'] == 0 else '%s s' % secs(s['cast'])
what = ', '.join(sorted(s['tags'])) or 'melee / unknown'
if s['dmg']: what += ' ~%d dmg' % s['dmg']
if s['heal']: what += ' ~%d heal' % s['heal']
if s['tick']: what += ' ~%d/tick' % s['tick']
if s['dispel']: what += ' (%s)' % s['dispel']
if s['hold']: what += ' [holds off: %s]' % ', '.join(g.SCHOOL_NAMES[i] for i in range(7) if (s['hold'] >> i) & 1)
L.append('| %s | %s | %s | %s on %s | %s | %s |' % (nm, sch, cast, what, s['tgt'].lower(), timer(s), counters_text(s) or ('severity %d' % s['sev'] if s['sev'] else '-')))
if s['note']: L.append('| | | | *%s* | | |' % s['note'])
return L
def write(result, cpp_dir, doc_dir, S):
os.makedirs(cpp_dir, exist_ok=True); os.makedirs(doc_dir, exist_ok=True)
for key, (d, mobs) in result.items():
write_cpp(key, d, mobs, cpp_dir)
write_doc(key, d, mobs, S, doc_dir)
write_inc(cpp_dir)
print('wrote', ', '.join(result))