Add script for extracting list of sheets required for R2 pallete. Add script for parsing and generating sitem names

merge/2021-11-19
kaetemi 3 years ago
parent ec63cdc818
commit c41cdd76ff
No known key found for this signature in database
GPG Key ID: 9873C4D40BB479BC

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,43 @@
import re
paletteLuaFile = "R:\\code\\ryzom\\common\\data_common\\r2\\r2_palette.lua"
sitemExpr = r"[^\"]+.sitem"
creatureExpr = r"\"[^\"]+.creature\""
pf = open(paletteLuaFile, "r")
paletteLua = pf.read()
pf.close()
sitemMatches = re.findall(sitemExpr, paletteLua)
sitemMap = {}
for k in sitemMatches:
ka = k.split(":")
for kk in ka:
sitemMap[kk] = True
sitemMatches = list(dict.fromkeys(sitemMap))
sitemMatches.sort()
# print(sitemMatches)
lf = open("sitem_list.txt", "w")
lf.flush()
for k in sitemMatches:
lf.write(k + "\n")
lf.close()
creatureMatches = re.findall(creatureExpr, paletteLua)
creatureMap = {}
for k in creatureMatches:
ka = k.split("\"")
for kk in ka:
if kk != "":
creatureMap[kk] = True
creatureMatches = list(dict.fromkeys(creatureMap))
creatureMatches.sort()
# print(creatureMatches)
lf = open("creature_list.txt", "w")
lf.flush()
for k in creatureMatches:
lf.write(k + "\n")
lf.close()

@ -0,0 +1,93 @@
import os, re
sitemPath = "R:\\leveldesign\\game_element"
creaturePath = "R:\\leveldesign\\game_elem"
fileMap = {}
def listPath(path):
for p in os.listdir(path):
fp = path + "\\" + p
if os.path.isdir(fp):
listPath(fp)
elif os.path.isfile(fp):
fileMap[p] = fp
listPath(sitemPath)
listPath(creaturePath)
sitemExpr = r"[^\" ]+.sitem"
creatureExpr = r"[^\" ]+.creature"
missing = {}
sitemProcessed = {}
sitemParents = {}
def processSitemSheet(name):
if not name in sitemProcessed:
if not name in fileMap:
missing[name] = True
else:
f = open(fileMap[name], "r")
sheet = f.read()
f.close()
sitemProcessed[name] = True
matches = re.findall(sitemExpr, sheet)
for n in matches:
sitemParents[n] = True
processSitemSheet(n)
with open("sitem_list.txt", "r") as f:
for l in f:
lt = l.strip()
processSitemSheet(lt)
sitemParentsSorted = list(dict.fromkeys(sitemParents))
sitemParentsSorted.sort()
lf = open("sitem_parents.txt", "w")
lf.flush()
for k in sitemParentsSorted:
lf.write(k + "\n")
lf.close()
creatureProcessed = {}
creatureParents = {}
def processcreatureSheet(name):
if not name in creatureProcessed:
if not name in fileMap:
if not "$hands" in name and not "$level" in name and not "palette." in name and "." in name:
missing[name] = True
else:
f = open(fileMap[name], "r")
sheet = f.read()
f.close()
creatureProcessed[name] = True
matches = re.findall(creatureExpr, sheet)
for n in matches:
creatureParents[n] = True
processcreatureSheet(n)
with open("creature_list.txt", "r") as f:
for l in f:
lt = l.strip()
processcreatureSheet(lt)
creatureParentsSorted = list(dict.fromkeys(creatureParents))
creatureParentsSorted.sort()
lf = open("creature_parents.txt", "w")
lf.flush()
for k in creatureParentsSorted:
lf.write(k + "\n")
lf.close()
missingSorted = list(dict.fromkeys(missing))
missingSorted.sort()
lf = open("missing_sheets.txt", "w")
lf.flush()
for k in missingSorted:
lf.write(k + "\n")
lf.close()

@ -0,0 +1,26 @@
_default_NPC_caracteristics.creature
icf.sitem
icf_2.sitem
icf_3.sitem
icm.sitem
icm_2.sitem
icm_3.sitem
ict.sitem
ict_2.sitem
ict_3.sitem
icz.sitem
icz_2.sitem
icz_3.sitem
object_barrier_T.creature
object_homin_body_fyros_F.creature
object_homin_body_fyros_H.creature
object_homin_body_matis_F.creature
object_homin_body_matis_H.creature
object_homin_body_tryker_F.creature
object_homin_body_tryker_H.creature
object_homin_body_zorai_F.creature
object_homin_body_zorai_H.creature
object_merchant_RM_fyros.creature
object_merchant_RM_matis.creature
object_merchant_RM_tryker.creature
object_merchant_RM_zorai.creature

@ -0,0 +1,2 @@
- Run extract_palette.py to generate sitem_list.txt and creature_list.txt from the R2 palette
- Run extract_parents.py to generate the parents txt files from the above, and missing sheets

@ -0,0 +1,54 @@
; based on item_words_en.txt
@0
ic item crafted
bc brick crafted
i item npc
@1
f fyros
m matis
t tryker
z zorai
c common
r refugee
kam kami
kar karavan
b tribe
@2
a armor
s shield
m melee
p ammo
; armor
@3
l light
c caster
h heavy
m medium
@4
b boots
g gloves
p pants
s sleeves
v vest
; shield
@3
; weapons
@3
1 1handed
2 2handed
@4
b smashing
p piercing
s slashing
;@5
;_2 mediumq
;_3 highq

@ -0,0 +1,283 @@
# base scheme
# see item_words_en.txt
scheme = {
"": [
{
"i": "item",
"b": "brick",
},
{
"f": "fyros",
"m": "matis",
"t": "tryker",
"z": "zorai",
"c": "common",
"r": "refugee",
"kam": "kami",
"kar": "karavan",
"b": "boss tribe",
"h": "high tribe",
"cf": "crafted fyros",
"cm": "crafted matis",
"ct": "crafted tryker",
"cz": "crafted zorai",
"cc": "crafted common",
"cr": "crafted refugee", # i cr a b a Refugee Boots
"ckam": "crafted kami",
"ckar": "crafted karavan",
"cb": "crafted boss tribe",
"ch": "crafted high tribe",
},
{
"a": "armor",
"ah": "heavy armor",
"am": "medium armor",
"al": "light armor",
"ac": "caster armor",
"s": "shield",
"m": "melee",
"r": "range",
"p": "range ammo",
"j": "jewelry",
"sb": "buckler shield",
"ss": "large shield",
},
{
"_2": "mq",
"_3": "hq",
"e": "electric",
"b": "burning",
"w": "waving",
"l": "living",
},
{
"_2": "mq",
"_3": "hq",
"e": "electric",
"b": "burning",
"w": "waving",
"l": "living",
},
{
"_2": "mq",
"_3": "hq",
"e": "electric",
"b": "burning",
"w": "waving",
"l": "living",
},
],
"melee": [
{},
{},
{},
{
"1": "one-handed",
"2": "two-handed",
},
{
# "b": "smashing",
# "p": "piercing",
# "s": "slashing",
"bm": "blunt mace",
"bs": "blunt staff",
"pd": "piercing dagger",
"ps": "piercing spear",
"pp": "piercing pike",
"sa": "slashing axe",
"ss": "slashing sword",
"ms": "magic amplifier",
},
{},
{},
{},
{},
{},
],
"range": [
{},
{},
{},
{
"1b": "one-handed bowpistol",
"1p": "one-handed pistol",
"2a": "two-handed autolauncher",
"2b": "two-handed bowrifle",
"2h": "two-handed harpoon",
"2l": "two-handed launcher",
"2r": "two-handed rifle",
},
{
"b": "smashing",
"p": "piercing",
"s": "slashing",
},
{},
{},
{},
{},
{},
],
"armor": [
{},
{},
{},
{
"b": "boots",
"g": "gloves",
"p": "pants",
"s": "sleeves",
"v": "vest",
"h": "helmet",
},
{
"a": "color0",
"e": "color1",
"g": "color2",
"r": "color3",
"t": "color4",
"u": "color5",
"v": "color6",
"w": "color7",
},
{},
{},
{},
],
"jewelry": [
{},
{},
{},
{
"a": "anklet",
"b": "bracelet",
"d": "diadem",
"e": "earring",
"p": "pendant",
"r": "ring",
},
{},
{},
{},
{},
{},
{},
],
}
def addTags(sub, depth, tags):
for i in range(len(tags) - 1, -1, -1):
tag = tags[i]
if tag in scheme:
s = scheme[tag]
largest = 0
for k in s[depth]:
if len(k) >= largest and sub.startswith(k):
largest = len(k)
if largest > 0:
for k in s[depth]:
if len(k) >= largest and sub.startswith(k):
tags += s[depth][k].split(" ")
return k
return ""
def parse(name):
tags = [ "" ]
sub = name
depth = 0
while len(sub) > 0:
add = addTags(sub, depth, tags)
if len(add) == 0:
return tags + [ "incomplete", "_" + sub ]
sub = sub[len(add):]
depth += 1
return tags[1:]
def generate(tags):
ref = [ "" ] + tags
found = {}
name = ""
depth = 0
while True:
all = True
for t in tags:
if not t in found:
all = False
break
if all:
break
any = False
for i in range(len(ref) - 1, -1, -1):
tag = ref[i]
if tag in scheme:
s = scheme[tag]
largest = 0
least = 999
for k in s[depth]:
count = 0
count2 = 0
st = s[depth][k].split(" ")
for t in st:
if t in ref and not t in found:
count += 1
if t not in ref:
count2 += 1
if count > largest:
largest = count
least = count2
if count == largest and count2 < least:
least = count2
if largest > 0:
for k in s[depth]:
count = 0
count2 = 0
st = s[depth][k].split(" ")
for t in st:
if t in ref and not t in found:
count += 1
if t not in ref:
count2 += 1
if count >= largest and count2 <= least:
for t in st:
if t in ref and not t in found:
#print("tag:" + t)
found[t] = True
#print("name: " + k)
any = True
name += k
break
if any:
break
if not any:
return name + "_incomplete"
depth += 1
return name
# print("ictr2r")
# print(parse("ictr2r"))
#
# print("iczp2ap")
# print(parse("iczp2ap"))
#
# print("iczr2a")
# print(parse("iczr2a"))
#
# print("ictm1pdw")
# print(parse("ictm1pdw"))
missing = {}
with open("missing_sheets.txt", "r") as f:
for l in f:
missing[l] = True
with open("sitem_list.txt", "r") as f:
for l in f:
if not l in missing:
name = l.strip().split(".")[0]
tags = parse(name)
gen = generate(tags)
# if "incomplete" in tags:
# if gen != name:
print(name + " -> " + gen)
print(tags)

@ -0,0 +1,374 @@
iccm1bm.sitem
iccm1pd.sitem
iccm1sa.sitem
iccm1ss.sitem
icf.sitem
icf_2.sitem
icf_3.sitem
icfacb_3.sitem
icfacp.sitem
icfacp_2.sitem
icfacp_3.sitem
icfacs_3.sitem
icfacv_3.sitem
icfahb.sitem
icfahb_2.sitem
icfahb_3.sitem
icfahg.sitem
icfahg_2.sitem
icfahg_3.sitem
icfahh.sitem
icfahh_2.sitem
icfahh_3.sitem
icfahp.sitem
icfahp_2.sitem
icfahp_3.sitem
icfahs.sitem
icfahs_2.sitem
icfahs_3.sitem
icfahv.sitem
icfahv_2.sitem
icfahv_3.sitem
icfalb.sitem
icfalb_2.sitem
icfalb_3.sitem
icfalg.sitem
icfalg_2.sitem
icfalg_3.sitem
icfalp.sitem
icfalp_2.sitem
icfalp_3.sitem
icfals.sitem
icfals_2.sitem
icfals_3.sitem
icfalv.sitem
icfalv_2.sitem
icfalv_3.sitem
icfamb.sitem
icfamb_2.sitem
icfamb_3.sitem
icfamg.sitem
icfamg_2.sitem
icfamg_3.sitem
icfamp.sitem
icfamp_2.sitem
icfamp_3.sitem
icfams.sitem
icfams_2.sitem
icfams_3.sitem
icfamv.sitem
icfamv_2.sitem
icfamv_3.sitem
icfm1bm.sitem
icfm1bm_2.sitem
icfm1bm_3.sitem
icfm1pd.sitem
icfm1pd_2.sitem
icfm1pd_3.sitem
icfm1ps.sitem
icfm1ps_2.sitem
icfm1ps_3.sitem
icfm1sa.sitem
icfm1sa_2.sitem
icfm1sa_3.sitem
icfm1ss.sitem
icfm1ss_2.sitem
icfm1ss_3.sitem
icfm2bm.sitem
icfm2bm_2.sitem
icfm2bm_3.sitem
icfm2ms.sitem
icfm2ms_2.sitem
icfm2ms_3.sitem
icfm2pp.sitem
icfm2pp_2.sitem
icfm2pp_3.sitem
icfm2sa.sitem
icfm2sa_2.sitem
icfm2sa_3.sitem
icfm2ss.sitem
icfm2ss_2.sitem
icfm2ss_3.sitem
icfsb.sitem
icfsb_2.sitem
icfsb_3.sitem
icfss.sitem
icfss_2.sitem
icfss_3.sitem
icm.sitem
icm_2.sitem
icm_3.sitem
icmacb_3.sitem
icmacp.sitem
icmacp_2.sitem
icmacp_3.sitem
icmacs_3.sitem
icmacv_3.sitem
icmahb.sitem
icmahb_2.sitem
icmahb_3.sitem
icmahg.sitem
icmahg_2.sitem
icmahg_3.sitem
icmahh.sitem
icmahh_2.sitem
icmahh_3.sitem
icmahp.sitem
icmahp_2.sitem
icmahp_3.sitem
icmahs.sitem
icmahs_2.sitem
icmahs_3.sitem
icmahv.sitem
icmahv_2.sitem
icmahv_3.sitem
icmalb.sitem
icmalb_2.sitem
icmalb_3.sitem
icmalg.sitem
icmalg_2.sitem
icmalg_3.sitem
icmalp.sitem
icmalp_2.sitem
icmalp_3.sitem
icmals.sitem
icmals_2.sitem
icmals_3.sitem
icmalv.sitem
icmalv_2.sitem
icmalv_3.sitem
icmamb.sitem
icmamb_2.sitem
icmamb_3.sitem
icmamg.sitem
icmamg_2.sitem
icmamg_3.sitem
icmamp.sitem
icmamp_2.sitem
icmamp_3.sitem
icmams.sitem
icmams_2.sitem
icmams_3.sitem
icmamv.sitem
icmamv_2.sitem
icmamv_3.sitem
icmm1bm.sitem
icmm1bm_2.sitem
icmm1bm_3.sitem
icmm1pd.sitem
icmm1pd_2.sitem
icmm1pd_3.sitem
icmm1ps.sitem
icmm1ps_2.sitem
icmm1ps_3.sitem
icmm1sa.sitem
icmm1sa_2.sitem
icmm1sa_3.sitem
icmm1ss.sitem
icmm1ss_2.sitem
icmm1ss_3.sitem
icmm2bm.sitem
icmm2bm_2.sitem
icmm2bm_3.sitem
icmm2ms.sitem
icmm2ms_2.sitem
icmm2ms_3.sitem
icmm2pp.sitem
icmm2pp_2.sitem
icmm2pp_3.sitem
icmm2sa.sitem
icmm2sa_2.sitem
icmm2sa_3.sitem
icmm2ss.sitem
icmm2ss_2.sitem
icmm2ss_3.sitem
icmsb.sitem
icmsb_2.sitem
icmsb_3.sitem
icmss.sitem
icmss_2.sitem
icmss_3.sitem
icravr.sitem
ict.sitem
ict_2.sitem
ict_3.sitem
ictacb_3.sitem
ictacp.sitem
ictacp_2.sitem
ictacp_3.sitem
ictacs_3.sitem
ictacv_3.sitem
ictahb.sitem
ictahb_2.sitem
ictahb_3.sitem
ictahg.sitem
ictahg_2.sitem
ictahg_3.sitem
ictahh.sitem
ictahh_2.sitem
ictahh_3.sitem
ictahp.sitem
ictahp_2.sitem
ictahp_3.sitem
ictahs.sitem
ictahs_2.sitem
ictahs_3.sitem
ictahv.sitem
ictahv_2.sitem
ictahv_3.sitem
ictalb.sitem
ictalb_2.sitem
ictalb_3.sitem
ictalg.sitem
ictalg_2.sitem
ictalg_3.sitem
ictalp.sitem
ictalp_2.sitem
ictalp_3.sitem
ictals.sitem
ictals_2.sitem
ictals_3.sitem
ictalv.sitem
ictalv_2.sitem
ictalv_3.sitem
ictamb.sitem
ictamb_2.sitem
ictamb_3.sitem
ictamg.sitem
ictamg_2.sitem
ictamg_3.sitem
ictamp.sitem
ictamp_2.sitem
ictamp_3.sitem
ictams.sitem
ictams_2.sitem
ictams_3.sitem
ictamv.sitem
ictamv_2.sitem
ictamv_3.sitem
ictm1bm.sitem
ictm1bm_2.sitem
ictm1bm_3.sitem
ictm1pd.sitem
ictm1pd_2.sitem
ictm1pd_3.sitem
ictm1ps.sitem
ictm1ps_2.sitem
ictm1ps_3.sitem
ictm1sa.sitem
ictm1sa_2.sitem
ictm1sa_3.sitem
ictm1ss.sitem
ictm1ss_2.sitem
ictm1ss_3.sitem
ictm2bm.sitem
ictm2bm_2.sitem
ictm2bm_3.sitem
ictm2ms.sitem
ictm2ms_2.sitem
ictm2ms_3.sitem
ictm2pp.sitem
ictm2pp_2.sitem
ictm2pp_3.sitem
ictm2sa.sitem
ictm2sa_2.sitem
ictm2sa_3.sitem
ictm2ss.sitem
ictm2ss_2.sitem
ictm2ss_3.sitem
ictsb.sitem
ictsb_2.sitem
ictsb_3.sitem
ictss.sitem
ictss_2.sitem
ictss_3.sitem
icz.sitem
icz_2.sitem
icz_3.sitem
iczacp.sitem
iczacp_2.sitem
iczacp_3.sitem
iczahb.sitem
iczahb_2.sitem
iczahb_3.sitem
iczahg.sitem
iczahg_2.sitem
iczahg_3.sitem
iczahh.sitem
iczahh_2.sitem
iczahh_3.sitem
iczahp.sitem
iczahp_2.sitem
iczahp_3.sitem
iczahs.sitem
iczahs_2.sitem
iczahs_3.sitem
iczahv.sitem
iczahv_2.sitem
iczahv_3.sitem
iczalb.sitem
iczalb_2.sitem
iczalb_3.sitem
iczalg.sitem
iczalg_2.sitem
iczalg_3.sitem
iczalp.sitem
iczalp_2.sitem
iczalp_3.sitem
iczals.sitem
iczals_2.sitem
iczals_3.sitem
iczalv.sitem
iczalv_2.sitem
iczalv_3.sitem
iczamb.sitem
iczamb_2.sitem
iczamb_3.sitem
iczamg.sitem
iczamg_2.sitem
iczamg_3.sitem
iczamp.sitem
iczamp_2.sitem
iczamp_3.sitem
iczams.sitem
iczams_2.sitem
iczams_3.sitem
iczamv.sitem
iczamv_2.sitem
iczamv_3.sitem
iczm1bm.sitem
iczm1bm_2.sitem
iczm1bm_3.sitem
iczm1pd.sitem
iczm1pd_2.sitem
iczm1pd_3.sitem
iczm1ps.sitem
iczm1ps_2.sitem
iczm1ps_3.sitem
iczm1sa.sitem
iczm1sa_2.sitem
iczm1sa_3.sitem
iczm1ss.sitem
iczm1ss_2.sitem
iczm1ss_3.sitem
iczm2bm.sitem
iczm2bm_2.sitem
iczm2bm_3.sitem
iczm2ms.sitem
iczm2ms_2.sitem
iczm2ms_3.sitem
iczm2pp.sitem
iczm2pp_2.sitem
iczm2pp_3.sitem
iczm2sa.sitem
iczm2sa_2.sitem
iczm2sa_3.sitem
iczm2ss.sitem
iczm2ss_2.sitem
iczm2ss_3.sitem
iczsb.sitem
iczsb_2.sitem
iczsb_3.sitem
iczss.sitem
iczss_2.sitem
iczss_3.sitem

@ -0,0 +1,32 @@
_c_ah.sitem
_c_al.sitem
_c_am.sitem
_c_ar.sitem
_c_m1bm.sitem
_c_m1pd.sitem
_c_m1ps.sitem
_c_m1sa.sitem
_c_m1ss.sitem
_c_m2bm.sitem
_c_m2ms.sitem
_c_m2pp.sitem
_c_m2sa.sitem
_c_m2ss.sitem
_c_sb.sitem
_c_ss.sitem
_gfa_c.sitem
_gfa_h.sitem
_gfa_l.sitem
_gfa_m.sitem
_gma_c.sitem
_gma_h.sitem
_gma_l.sitem
_gma_m.sitem
_gta_c.sitem
_gta_h.sitem
_gta_l.sitem
_gta_m.sitem
_gza_c.sitem
_gza_h.sitem
_gza_l.sitem
_gza_m.sitem
Loading…
Cancel
Save