Compare commits

..

6 Commits

Author SHA1 Message Date
7cb17aeb3a Created script to run all imports 2026-09-03 02:36:48 +02:00
aab93dad02 Agents image download 2026-09-03 02:36:35 +02:00
e7f30ecea4 Added agents 2026-09-03 02:36:21 +02:00
af487ff9f5 Added agents rarities 2026-09-03 02:36:13 +02:00
f6ccf8d807 Changed default rarity and display for base weapons 2026-09-03 02:35:36 +02:00
4ae964c90f Added defaults knives and gloves 2026-09-03 02:34:54 +02:00
7 changed files with 1995 additions and 4 deletions

1829
agents.json Normal file

File diff suppressed because it is too large Load Diff

57
agents.py Normal file
View File

@@ -0,0 +1,57 @@
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"]]
}
agents[agent["name"]] = agent
for agent in agents.values():
cur.execute("INSERT INTO agents (name, display, def_index, team, model_player, rarity) VALUES (%s, %s, %s, %s, %s, %s)", (agent["name"], agent["display"], agent["def_index"], agent["team"], agent["model_player"], agent["rarity"]))
conn.commit()
cur.close()
conn.close()

46
images.py Normal file
View File

@@ -0,0 +1,46 @@
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"]
weapon = skin["id"]
content = requests.get(url).content
with open(f"skins/{weapon}_0.png", "wb") as f:
f.write(content)

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,
@@ -47,9 +47,9 @@ for raw in content:
for weapon in weapons.keys(): for weapon in weapons.keys():
skin = { skin = {
"weapon": weapons[weapon], "weapon": weapons[weapon],
"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

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"]))