Skip to content

Instantly share code, notes, and snippets.

@Zemnmez
Created February 11, 2022 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zemnmez/d99d236bb720be0a7afde77acee75d88 to your computer and use it in GitHub Desktop.
Save Zemnmez/d99d236bb720be0a7afde77acee75d88 to your computer and use it in GitHub Desktop.
type CKValue = { toCK(): string }
abstract class NewType<T> {
constructor(public readonly value: T) {}
}
class CKNumber extends NewType<number> {
toCK() { return this.value.toString() }
}
class CKString extends NewType<string> {
toCK() { return `"${this.value.replace('"', '\\"')}"` }
}
class CKList extends NewType<Array<CKValue>> {
toCK(): string {
return `{${
this.value.map(v => v.toCK()).join(" ")
}}`
}
}
class CKRoot extends NewType<
Set<readonly[string,CKValue]>> {
toCK(): string { return `${
[...this.value].map(([k, v]) =>
`${k}=${v.toCK()}`).join("\n")
}`}
}
class CKObject extends CKRoot {
toCK(): string { return `{\n${
super.toCK()
}\n}`}
}
class Vec extends NewType<number[]> {
toToCK() {
return new CKList(
this.value.map(v => new CKNumber(v))
)
}
toCK() {
return this.toToCK().toCK()
}
}
class ColouredEmblem {
constructor(
public readonly color1: string,
public readonly texture: string,
public readonly posX: number,
public readonly posY: number,
public readonly scaleX: number,
public readonly scaleY: number,
public readonly depth:number
) {}
get instance() {
return new CKObject(new Set<readonly[string,CKValue]>([
["position", new Vec([this.posX, this.posY])],
["scale", new Vec([this.scaleX, this.scaleY])],
["depth", new CKNumber(this.depth)]
]))
}
get ckValue() {
return new CKObject(
new Set<readonly[string,CKValue]>([
["color1", new CKString(this.color1)],
["texture", new CKString(this.texture)],
["instance", this.instance ]
])
)
}
toCK() {
return this.ckValue.toCK()
}
}
class Letter {
constructor(
public readonly letter: "a"| "b"|"c"|"d"|"e"|"f"|"g"|"h"|"i"|"j"|"k"|"l"|"m"|"n"|"o"|"p"|"q"|"r"|"s"|"t"|"u"|"v"|"w"|"x"|"y"|"z",
public readonly color: string,
public readonly posX: number,
public readonly posY: number,
public readonly scaleX: number,
public readonly scaleY: number,
public readonly depth:number
) {}
get ckValue() {
return new ColouredEmblem(
this.color,
`ce_letter_${this.letter}.dds`,
this.posX,
this.posY,
this.scaleX,
this.scaleY,
this.depth
)
}
toCK(){ return this.ckValue.toCK() }
}
class CKText {
constructor(
public readonly text: string,
public readonly color: string = "white",
public readonly posX: number = 0,
public readonly posY: number = 0,
public readonly scaleX: number = .12,
public readonly scaleY: number = scaleX,
public readonly depth:number = 1
) {
}
get stepX() { return this.scaleX }
get stepY() { return this.scaleY }
get maxX() { return .8}
get maxY() { return 1 }
get ckValue() {
return new CKRoot(new Set<readonly[string,CKValue]>(
[...this.text].filter(v => "abcdefghijklmnopqrstuvwxyz".split("").indexOf(v) != -1).map((t, i) => {
let xDist = this.stepX * i;
let wraps = Math.floor(xDist / this.maxX);
let X = xDist % this.maxX;
let Y = wraps * this.stepY;
return [
"colored_emblem",
new Letter(t as any, this.color, X + this.posX, Y+ this.posY, this.scaleX, this.scaleY,this.depth)
] as readonly [string, CKValue]
})
))
}
toCK() { return this.ckValue.toCK() }
}
window.write = t => `
coa_title_7266={
custom=yes
pattern="pattern_solid.dds"
color1=red
color2=yellow
color3=red
${new CKText(t, "white", .1, .08).toCK()}
}`
console.log(write("What the fuck did you just fucking say about me, you little bitch? I'll have you know I graduated top of my class in the Navy Seals, and I've been involved in numerous secret raids on Al-Quaeda, and I have over 300 confirmed kills. I am trained in gorilla warfare and I'm the top sniper in the entire US armed forces. You are nothing to me but just another target. I will wipe you the fuck out with precision the likes of which has never been seen before on this Earth, mark my fucking words. You think you can get away with saying that shit to me over the Internet? Think again, fucker. As we speak I am contacting my secret network of spies across the USA and your IP is being traced right now so you better prepare for the storm, maggot. The storm that wipes out the pathetic little thing you call your life. You're fucking dead, kid. I can be anywhere, anytime, and I can kill you in over seven hundred ways, and that's just with my bare hands. Not only am I extensively trained in unarmed combat, but I have access to the entire arsenal of the United States Marine Corps and I will use it to its full extent to wipe your miserable ass off the face of the continent, you little shit. If only you could have known what unholy retribution your little \"clever\" comment was about to bring down upon you, maybe you would have held your fucking tongue. But you couldn't, you didn't, and now you're paying the price, you goddamn idiot. I will shit fury all over you and you will drown in it. You're fucking dead, kiddo."));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment