Free games for graphing calculators: NumWorks, TI-Nspire CX, Casio fx-CG50 and soon TI-84 Plus CE. Balatro, Celeste, Hollow Knight, Minecraft and more.
C calculatorcalculator-gamescasiochesscrossy-roaddrive-madfx-cg50gamesgeometry-dashgraphing-calculatorndlessnumworksnumworks-appsnumworks-calculatornumworks-gamenumworks-gamestetristi-84-plus-ceti-nspire
Celeste: entity attributes default as in the game
Mason Chen0f797af0ffbf
diff --git a/games/celeste/src/ch1.c b/games/celeste/src/ch1.cindex 79741aa7..5696bc57 100644--- a/games/celeste/src/ch1.c+++ b/games/celeste/src/ch1.c@@ -249,7 +249,7 @@ static void new_bonfire(const EData *d) {wiggler_init(&b->wig, 0.2f, 4);b->light = 1;const char *m = EAS(d, bonfire, mode);- bonfire_set_mode(e, !strcmp(m, "lit") ? BF_LIT : !strcmp(m, "smoking") ? BF_SMOKING : BF_UNLIT); /* Added */+ bonfire_set_mode(e, !strcmp(m, "Lit") ? BF_LIT : !strcmp(m, "Smoking") ? BF_SMOKING : BF_UNLIT); /* Added */b->activated = 0;bonfire_set_mode(e, b->mode);}diff --git a/games/celeste/src/ch6.c b/games/celeste/src/ch6.cindex 71d6ff01..e95f6dfd 100644--- a/games/celeste/src/ch6.c+++ b/games/celeste/src/ch6.c@@ -772,8 +772,8 @@ static void new_kevin(const EData *d) {k->giant = w >= 48 && h >= 48 && k->chill;k->can_activate = 1;const char *ax = EAS(d, crushBlock, axes);- if (!strcmp(ax, "horizontal")) k->axes = 1, k->can_h = 1;- else if (!strcmp(ax, "vertical")) k->axes = 2, k->can_v = 1;+ if (!strcmp(ax, "Horizontal")) k->axes = 1, k->can_h = 1;+ else if (!strcmp(ax, "Vertical")) k->axes = 2, k->can_v = 1;else k->axes = 3, k->can_h = k->can_v = 1;k->seed = (uint16_t)rndi(65536);cs_init(&k->face, k->giant ? SB_giant_crushblock_face : SB_crushblock_face);diff --git a/games/celeste/src/data.bin b/games/celeste/src/data.binindex f3e45544..97d8e4cb 100644Binary files a/games/celeste/src/data.bin and b/games/celeste/src/data.bin differdiff --git a/games/celeste/src/entities.c b/games/celeste/src/entities.cindex 75d0512a..9fab7516 100644--- a/games/celeste/src/entities.c+++ b/games/celeste/src/entities.c@@ -1245,7 +1245,7 @@ bool ent_create(const EData *d) {}case ET_bonfire: {const char *mode = EAS(d, bonfire, mode);- Ent *e = new_sprite_ent(d, SB_campfire, !strcmp(mode, "lit") ? A_campfire_burn : !strcmp(mode, "smoking") ? A_campfire_smoking : A_campfire_idle, -5);+ Ent *e = new_sprite_ent(d, SB_campfire, !strcmp(mode, "Lit") ? A_campfire_burn : !strcmp(mode, "Smoking") ? A_campfire_smoking : A_campfire_idle, -5);(void)e;return true;}diff --git a/games/celeste/tools/entities.py b/games/celeste/tools/entities.pyindex 4d7f9569..ac69f814 100644--- a/games/celeste/tools/entities.py+++ b/games/celeste/tools/entities.py@@ -13,6 +13,82 @@ DROP_TRIGGERS = {"musicFadeTrigger", "musicTrigger", "altMusicTrigger", "ambienceParamTrigger", "audioFadeTrigger",}+# The game's own defaults for attributes a map leaves out (its constructors' data.Bool, Int, Float, Char and Attr calls),+# so data.bin holds what the game reads: FallingBlock's climbFall is true unless a map says otherwise.+DEFAULTS = {+ "spring": {"playerCanUse": True},+ "wallSpringLeft": {"playerCanUse": True},+ "wallSpringRight": {"playerCanUse": True},+ "fallingBlock": {"tiletype": "3", "climbFall": True},+ "fakeWall": {"tiletype": "3"},+ "dashBlock": {"tiletype": "3", "permanent": True, "canDash": True},+ "coverupWall": {"tiletype": "3"},+ "exitBlock": {"tileType": "3"},+ "conditionBlock": {"tileType": "3"},+ "jumpThru": {"texture": "default", "surfaceIndex": -1},+ "spikesUp": {"type": "default"},+ "spikesDown": {"type": "default"},+ "spikesLeft": {"type": "default"},+ "spikesRight": {"type": "default"},+ "switchGate": {"sprite": "block"},+ "door": {"type": "wood"},+ "lockBlock": {"sprite": "wood"},+ "templeGate": {"sprite": "default"},+ "dashSwitchH": {"sprite": "default"},+ "dashSwitchV": {"sprite": "default"},+ "moveBlock": {"canSteer": True},+ "gondola": {"active": True},+ "badelineBoost": {"lockCamera": True},+ "finalBoss": {"cameraLockY": True, "cameraPastY": 120.0},+ "fireBall": {"amount": 1, "speed": 1.0},+ "oshiroTrigger": {"state": True},+ "minitextboxTrigger": {"death_count": -1},+}+# Attributes read with data.Char: one character, else the default+CHARS = {("fallingBlock", "tiletype"), ("fakeWall", "tiletype"), ("dashBlock", "tiletype"), ("coverupWall", "tiletype"),+ ("exitBlock", "tileType"), ("conditionBlock", "tileType")}+# Attributes read with data.Enum: the enum's names, its default first. The game reads them in any case (Enum.TryParse+# ignoreCase) and falls back on the default; data.bin holds the name as the enum spells it.+_POSITION = ("NoEffect", "HorizontalCenter", "VerticalCenter", "TopToBottom", "BottomToTop", "LeftToRight", "RightToLeft")+_ENUMS = {+ "bird": {"mode": ("None", "ClimbingTutorial", "DashingTutorial", "DreamJumpTutorial", "SuperWallJumpTutorial",+ "HyperJumpTutorial", "FlyAway", "Sleeping", "MoveToNodes", "WaitForLightningOff")},+ "bonfire": {"mode": ("Unlit", "Lit", "Smoking")},+ "trackSpinner": {"speed": ("Normal", "Slow", "Fast")},+ "clutterDoor": {"type": ("Green", "Red", "Yellow", "Lightning")},+ "colorSwitch": {"type": ("Green", "Red", "Yellow", "Lightning")},+ "moveBlock": {"direction": ("Left", "Right", "Up", "Down")},+ "templeGate": {"type": ("NearestSwitch", "CloseBehindPlayer", "CloseBehindPlayerAlways", "HoldingTheo", "TouchSwitches",+ "CloseBehindPlayerAndTheo")},+ "zipMover": {"theme": ("Normal", "Moon")},+ "swapBlock": {"theme": ("Normal", "Moon")},+ "seekerStatue": {"hatch": ("Distance", "PlayerRightOfX")},+ "conditionBlock": {"condition": ("Key", "Button", "Strawberry")},+ "crushBlock": {"axes": ("Both", "Horizontal", "Vertical")},+ "bigWaterfall": {"layer": ("BG", "FG")},+ "cameraTargetTrigger": {"positionMode": _POSITION},+ "bloomFadeTrigger": {"positionMode": _POSITION},+ "lightFadeTrigger": {"positionMode": _POSITION},+ "cameraAdvanceTargetTrigger": {"positionModeX": _POSITION, "positionModeY": _POSITION},+ "windTrigger": {"pattern": ("None", "Left", "Right", "LeftStrong", "RightStrong", "LeftOnOff", "RightOnOff", "LeftOnOffFast",+ "RightOnOffFast", "Alternating", "LeftGemsOnly", "RightCrazy", "Down", "Up", "Space")},+ "minitextboxTrigger": {"mode": ("OnPlayerEnter", "OnLevelStart", "OnTheoEnter")},+}+++def attr(entity, k):+ """Attribute k of an entity as the game reads it (None: the game reads none, and the map has none)."""+ v = entity.attr.get(k)+ names = _ENUMS.get(entity.name, {}).get(k)+ if names:+ s = str(v) if v is not None else ""+ return next((n for n in names if n.lower() == s.lower()), names[0])+ dflt = DEFAULTS.get(entity.name, {}).get(k)+ if (entity.name, k) in CHARS and (v is None or len(str(v)) != 1):+ return dflt+ return dflt if v is None else v++SPIKE_TYPES = ("default", "outline", "cliffside", "reflection")@@ -135,8 +211,8 @@ def _load_chapter_assets():NPC_ASSETS.update(getattr(mod, "NPC_ASSETS", {}))DROP.update(getattr(mod, "DROP", set()))NEEDS.update(getattr(mod, "NEEDS", {}))- for name, (attr, table) in getattr(mod, "VARIANTS", {}).items(): # {name: (attribute, {value: assets})}- NEEDS[name] = (lambda attr, table: lambda e: table.get(e.get(attr, ""), []))(attr, table)+ for name, (key, table) in getattr(mod, "VARIANTS", {}).items(): # {name: (attribute, {value: assets})}+ NEEDS[name] = (lambda key, table: lambda e: table.get(attr(e, key), []))(key, table)_load_chapter_assets()diff --git a/games/celeste/tools/pack.py b/games/celeste/tools/pack.pyindex a8697f4c..1c41ff5b 100644--- a/games/celeste/tools/pack.py+++ b/games/celeste/tools/pack.py@@ -654,7 +654,7 @@ def write_attrs(w, e):lay, size = SCHEMA.layout(e.name)rec = bytearray(size)for k, kind, off, sz in lay:- v = e.attr.get(k)+ v = E.attr(e, k)if kind == "b":struct.pack_into("<B", rec, off, 1 if v else 0)elif kind == "i":@@ -1582,7 +1582,7 @@ def main():uses = []for e in ents + [t for t in trigs if E.keep_trigger(t.name)]:if e.name == "jumpThru": # its own look, or the area's (AreaData.Jumpthru): not every one- tx = e.get("texture", "default")+ tx = E.attr(e, "texture")tx = tx if tx != "default" else JUMPTHRU[MAP_AREA.get(ch.name, 0)]t_ = TEX("objects/jumpthru/" + tx)uses.append(t_)@@ -1591,10 +1591,11 @@ def main():for a in E.needs(e):uses += asset_textures(a)need += asset_prefetch(a)- if "tiletype" in e.attr:- c = str(e["tiletype"])- if c in fgsets:- need.append(TEX(fgsets[c].path))+ for k in ("tiletype", "tileType"): # blocks' tiles (data.Char)+ if (e.name, k) in E.CHARS:+ c = str(E.attr(e, k))+ if c in fgsets:+ need.append(TEX(fgsets[c].path))for layer in ("fgdecals", "bgdecals"):for d in (r.e.child(layer).children if r.e.child(layer) else []):need += decal_tex(d["texture"])