Compare commits

..

13 Commits

11 changed files with 2101 additions and 11 deletions

BIN
agent-0_0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

BIN
agent-0_big.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

BIN
agent-1_0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

BIN
agent-1_big.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

1892
agents.json Normal file

File diff suppressed because it is too large Load Diff

78
agents.py Normal file
View File

@@ -0,0 +1,78 @@
import psycopg2, json
"""
CREATE TABLE IF NOT EXISTS agents (
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
rarity uuid REFERENCES rarity(id) NOT NULL,
name varchar NOT NULL,
display varchar NOT NULL,
def_index integer NOT NULL,
team integer NOT NULL, -- 0 = CT, 1 = T, 2 = BOTH
model_player varchar NOT NULl
);
"""
conn = psycopg2.connect("dbname=porning user=aindustries")
cur = conn.cursor()
cur.execute("SELECT * FROM rarity")
raw_rarity = cur.fetchall()
rarity = {rarity[1]: rarity[0] for rarity in raw_rarity}
with open("agents.json", "r") as f:
content = json.load(f)
agents = {}
for raw in content:
if raw["id"] in agents:
continue
team = raw["team"]["id"]
if team == "counter-terrorists":
team = 0
elif team == "terrorists":
team = 1
else:
team = 2
agent = {
"name": raw["id"],
"display": raw["name"],
"def_index": raw["def_index"],
"team": team,
"model_player": raw["model_player"],
"rarity": rarity[raw["rarity"]["name"]],
"default": False
}
agents[agent["name"]] = agent
agents["agent-0"] = {
"name": "agent-0",
"display": "Default CT Agent",
"def_index": 0,
"team": 0,
"model_player": "agents/models/ctm_sas/ctm_sas.vmdl",
"rarity": rarity["Stock"],
"default": True
}
agents["agent-1"] = {
"name": "agent-1",
"display": "Default T Agent",
"def_index": 0,
"team": 1,
"model_player": "agents/models/tm_phoenix/tm_phoenix.vmdl",
"rarity": rarity["Stock"],
"default": True
}
for agent in agents.values():
cur.execute("INSERT INTO agents (name, display, def_index, team, model_player, rarity, \"default\") VALUES (%s, %s, %s, %s, %s, %s, %s)", (agent["name"], agent["display"], agent["def_index"], agent["team"], agent["model_player"], agent["rarity"], agent["default"]))
conn.commit()
cur.close()
conn.close()

52
images.py Normal file
View File

@@ -0,0 +1,52 @@
import json, requests, os
os.mkdir("skins")
with open("skins.json", "r") as f:
content = json.load(f)
for skin in content:
url = skin["image"]
weapon = skin["weapon"]["id"]
paint_index = skin["paint_index"]
if "sfui_wpnhud" in weapon:
continue
content = requests.get(url).content
with open(f"skins/{weapon}_{paint_index}.png", "wb") as f:
f.write(content)
with open("base_weapons.json", "r") as f:
content = json.load(f)
for skin in content:
url = skin["image"]
weapon = skin["id"].replace("base_weapon-", "")
if "sfui_wpnhud" in weapon:
continue
content = requests.get(url).content
with open(f"skins/{weapon}_0.png", "wb") as f:
f.write(content)
with open("agents.json", "r") as f:
content = json.load(f)
for skin in content:
url = skin["image"]
url_big = skin["big_image"]
weapon = skin["id"]
content = requests.get(url).content
with open(f"skins/{weapon}_0.png", "wb") as f:
f.write(content)
content_big = requests.get(url_big).content
with open(f"skins/{weapon}_big.png", "wb") as f:
f.write(content_big)

6
import_all.sh Executable file
View File

@@ -0,0 +1,6 @@
source .venv/bin/activate
python weapons.py
python rarity.py
python skins.py
python agents.py

View File

@@ -27,6 +27,26 @@ for raw in content:
rarities[rarity["display"]] = rarity rarities[rarity["display"]] = rarity
with open("agents.json", "r") as f:
content = json.load(f)
for raw in content:
if raw["rarity"]["name"] in rarities:
continue
rarity = {
"display": raw["rarity"]["name"],
"color": raw["rarity"]["color"]
}
rarities[rarity["display"]] = rarity
# Missing rarity for default skins
rarities["Stock"] = {
"display": "Stock",
"color": "#ded6cc"
}
for rarity in rarities.values(): for rarity in rarities.values():
cur.execute("INSERT INTO rarity (display, color) VALUES (%s, %s)", (rarity["display"], rarity["color"])) cur.execute("INSERT INTO rarity (display, color) VALUES (%s, %s)", (rarity["display"], rarity["color"]))

View File

@@ -3,8 +3,8 @@ import psycopg2, json
""" """
CREATE TABLE IF NOT EXISTS skins ( CREATE TABLE IF NOT EXISTS skins (
id uuid DEFAULT gen_random_uuid() PRIMARY KEY, id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
weapon uuid REFERENCES weapons(id), weapon uuid REFERENCES weapons(id) NOT NULL,
rarity uuid REFERENCES rarity(id), rarity uuid REFERENCES rarity(id) NOT NULL,
paint_index integer NOT NULL, paint_index integer NOT NULL,
display varchar NOT NULL, display varchar NOT NULL,
min_float float NOT NULL, min_float float NOT NULL,
@@ -18,7 +18,7 @@ cur = conn.cursor()
cur.execute("SELECT * FROM weapons") cur.execute("SELECT * FROM weapons")
raw_weapons = cur.fetchall() raw_weapons = cur.fetchall()
weapons = {weapon[1]: weapon[0] for weapon in raw_weapons} weapons = {weapon[1]: weapon for weapon in raw_weapons}
cur.execute("SELECT * FROM rarity") cur.execute("SELECT * FROM rarity")
raw_rarity = cur.fetchall() raw_rarity = cur.fetchall()
@@ -34,30 +34,39 @@ for raw in content:
continue continue
skin = { skin = {
"weapon": weapons[raw["weapon"]["id"]], "weapon": weapons[raw["weapon"]["id"]][0],
"rarity": rarity[raw["rarity"]["name"]], "rarity": rarity[raw["rarity"]["name"]],
"paint_index": raw["paint_index"], "paint_index": raw["paint_index"],
"display": raw["pattern"]["name"], "display": raw["pattern"]["name"],
"min_float": raw["min_float"], "min_float": raw["min_float"],
"max_float": raw["max_float"], "max_float": raw["max_float"],
"legacy": raw["legacy_model"] "legacy": raw["legacy_model"],
"default": False
} }
skins.append(skin) skins.append(skin)
for weapon in weapons.keys(): default_weapons = ["weapon_knife_t", "weapon_knife", "t_gloves", "ct_gloves"]
for weapon in weapons.values():
if weapon[4] == "Gloves" and not "Default" in weapon[2]:
continue
default = weapon[1] in default_weapons or ("weapon" in weapon[1] and not "knife" in weapon[1] and not "bayonet" in weapon[1])
skin = { skin = {
"weapon": weapons[weapon], "weapon": weapon[0],
"rarity": rarity["Covert"], "rarity": rarity["Stock"],
"paint_index": 0, "paint_index": 0,
"display": "Default", "display": "",
"min_float": 0, "min_float": 0,
"max_float": 0, "max_float": 0,
"legacy": True "legacy": True,
"default": default
} }
skins.append(skin) skins.append(skin)
for skin in skins: for skin in skins:
cur.execute("INSERT INTO skins (weapon, rarity, paint_index, display, min_float, max_float, legacy) VALUES (%s, %s, %s, %s, %s, %s, %s)", (skin["weapon"], skin["rarity"], skin["paint_index"], skin["display"], skin["min_float"], skin["max_float"], skin["legacy"])) cur.execute("INSERT INTO skins (weapon, rarity, paint_index, display, min_float, max_float, legacy, \"default\") VALUES (%s, %s, %s, %s, %s, %s, %s, %s)", (skin["weapon"], skin["rarity"], skin["paint_index"], skin["display"], skin["min_float"], skin["max_float"], skin["legacy"], skin["default"]))
conn.commit() conn.commit()

View File

@@ -42,6 +42,39 @@ for raw in content:
weapons[weapon["name"]] = weapon weapons[weapon["name"]] = weapon
# Default knives and gloves that are not in the json
weapons["weapon_knife_t"] = {
"name": "weapon_knife_t",
"display": "Knife",
"def_index" : 59,
"category": "Knives",
"team": 1
}
weapons["weapon_knife"] = {
"name": "weapon_knife",
"display": "Knife",
"def_index" : 42,
"category": "Knives",
"team": 0
}
weapons["t_gloves"] = {
"name": "t_gloves",
"display": "Default T Gloves",
"def_index" : 5028,
"category": "Gloves",
"team": 1
}
weapons["ct_gloves"] = {
"name": "ct_gloves",
"display": "Default CT Gloves",
"def_index" : 5029,
"category": "Gloves",
"team": 0
}
for weapon in weapons.values(): for weapon in weapons.values():
cur.execute("INSERT INTO weapons (name, display, def_index, category, team) VALUES (%s, %s, %s, %s, %s)", (weapon["name"], weapon["display"], weapon["def_index"], weapon["category"], weapon["team"])) cur.execute("INSERT INTO weapons (name, display, def_index, category, team) VALUES (%s, %s, %s, %s, %s)", (weapon["name"], weapon["display"], weapon["def_index"], weapon["category"], weapon["team"]))