Translate 1.x-style abilities. We still need to do specials.
This commit is contained in:
parent
7d188ec30f
commit
9123181799
1 changed files with 46 additions and 0 deletions
|
@ -801,6 +801,52 @@ def hack_syntax(filename, lines):
|
|||
in_sound = False
|
||||
if in_sound:
|
||||
lines[i] = ""
|
||||
# Upconvert ancient ability declarations from 1.x
|
||||
converting = False
|
||||
level = None
|
||||
abilities = []
|
||||
lastability = None
|
||||
# TODO: special=plague(unitname) -> {WEAPON_SPECIAL_PLAGUE_TYPE unitype}
|
||||
# TODO: special=plague -> {WEAPON_SPECIAL_PLAGUE}
|
||||
for i in range(len(lines)):
|
||||
if "no-syntax-rewrite" in lines[i]:
|
||||
break
|
||||
if "[unit]" in lines[i]:
|
||||
abilities = []
|
||||
converting = True
|
||||
elif "[/unit]" in lines[i]:
|
||||
if abilities:
|
||||
if verbose:
|
||||
print "Lifting obsolete abilities:", " ".join(abilities)
|
||||
ws = leader(lines[i])
|
||||
insertion = ws + baseindent + "[abilities]\n"
|
||||
for ability in abilities:
|
||||
if ability == "leadership":
|
||||
if level is None:
|
||||
print "warning: can't convert ancient leadership ability"
|
||||
else:
|
||||
insertion += ws + baseindent*2 + "{ABILITY_LEADERSHIP_LEVEL_"+level+"}\n"
|
||||
elif ability in ("cures", "heals", "regenerates",
|
||||
"skirmisher", "illuminates",
|
||||
"teleport", "ambush",):
|
||||
insertion += ws + baseindent*2 + "{ABILITY_" + + "}\n"
|
||||
else:
|
||||
print "Don't know how to convert '%d'" % ability
|
||||
insertion += ws + baseindent + "[/abilities]\n"
|
||||
lines[lastability] = insertion
|
||||
modcount += 1
|
||||
converting = False
|
||||
elif lines[i].count("=") == 1:
|
||||
(tag, value) = lines[i].strip().split("=")
|
||||
if tag == "level":
|
||||
level = value
|
||||
if tag == "ability":
|
||||
abilities.append(value)
|
||||
lastability = i
|
||||
lines[i] = ""
|
||||
if tag == "special":
|
||||
print "%s, line %d, %s: can't translate 1.x-style specials" \
|
||||
% (filename, i+1, `lines[i].strip()`)
|
||||
# Upconvert old radius usage
|
||||
if "1.3.7" in versions and "older" not in versions:
|
||||
radius_pos = wmlfind("radius=", WmlIterator(lines, filename))
|
||||
|
|
Loading…
Add table
Reference in a new issue