// Partita: traduzione in C delle classi originali di Vampire Survivors 1.5.101 // (build Phaser, bundle webpack). Ogni sezione riporta l'id del modulo. // I nomi dei metodi sono quelli originali; le parti che dipendono da sistemi non // ancora tradotti (arcana, eventi, boss, UI del level-up, tileset) sono segnate. #include #include #include #include #include #include #include #include "phaser.h" #include "rlgl.h" #include "audio.h" #define NET_WRAP_INPUT #include "net.h" #include "port_lang.h" // in testa: le reliquie del port mettono i loro testi in itemLang gia' al caricamento del salvataggio // Tutto cio' che la partita alloca passa da gmem e si libera a game_start (cache e risorse raylib escluse) #include "saveimport.h" #include "trophies.h" #define calloc gmem_calloc #define realloc gmem_realloc #define malloc(s) gmem_realloc(NULL, s) #define free gmem_free // Le tabelle dei metodi delle sottoclassi sovrascrivono di proposito i campi della base (macro BASE) #pragma GCC diagnostic ignored "-Woverride-init" #ifdef __clang__ #pragma clang diagnostic ignored "-Winitializer-overrides" #endif Result last_result; static int menu_launching; // la partita parte dal menu: CharSelectionScene ha gia' fatto setupRNJ static Shader fill_shader; static float frand(void) { return (float)det_rand() / ((float)RAND_MAX + 1.0f); } // Math.random in [0,1) static float num(cJSON *o, const char *k, float def) { cJSON *n = cJSON_GetObjectItem(o, k); return cJSON_IsNumber(n) ? (float)n->valuedouble : def; } static int has(cJSON *o, const char *k) { return cJSON_GetObjectItem(o, k) != NULL; } static const char *str(cJSON *o, const char *k) { return cJSON_GetStringValue(cJSON_GetObjectItem(o, k)); } static int RND_between(int min, int max) { return (int)floorf(frand() * (max - min + 1) + min); } // Phaser.Math.Between // ============================================================================ // 0x5103: GameManager (parte statica) // ============================================================================ static float _basePlayerPxSpeed = 82.5f, _baseEnemySpeed = 0.77f * 0.3f, _baseProjectileSpeed = 0xa5, _baseGoldMultiplier = 1, _baseEnemyHealthMultiplier = 1, _baseExperienceMultiplier = 1; static float PlayerPxSpeed, EnemySpeed, ProjectileSpeed, GoldMultiplier = 1, EnemyHealthMultiplier, ExperienceMultiplier; // GoldMultiplier = 1 come l'originale (le monete dal menu) static const float PixelScale = 1; static int IsHalloween; // Core.IsHalloween: la spell Halloween, fino alla fine della partita (Core.CleanUp) // I tasti premuti in questo frame (keydown di Phaser), letti una volta da menu_update/game_update: li usano le combinazioni e i segreti static int KeyQ[32], nKeyQ; static void KeyQ_poll(void) { nKeyQ = 0; for (int k; (k = GetKeyPressed()) && nKeyQ < 32;) KeyQ[nKeyQ++] = k; static int pos; // sviluppo: VS_TYPE digita un tasto per frame dopo 1,5 s (^ _ < > frecce, ! Esc, # Invio, - meno) const char *s = getenv("VS_TYPE"); if (!s || GetTime() < 1.5 || !s[pos] || nKeyQ >= 32) return; int ch = s[pos++]; KeyQ[nKeyQ++] = ch == '^' ? KEY_UP : ch == '_' ? KEY_DOWN : ch == '<' ? KEY_LEFT : ch == '>' ? KEY_RIGHT : ch == '!' ? KEY_ESCAPE : ch == '#' ? KEY_ENTER : ch == '-' ? KEY_MINUS : ch >= 'a' && ch <= 'z' ? ch - 32 : ch; } static int js_keyCode(int k) { // KeyboardEvent.keyCode dal tasto di raylib if ((k >= KEY_A && k <= KEY_Z) || (k >= KEY_ZERO && k <= KEY_NINE)) return k; switch (k) { case KEY_UP: return 38; case KEY_DOWN: return 40; case KEY_LEFT: return 37; case KEY_RIGHT: return 39; case KEY_ESCAPE: return 27; case KEY_ENTER: case KEY_KP_ENTER: return 13; case KEY_MINUS: return 189; case KEY_KP_SUBTRACT: return 109; } return 1000 + k; } // Phaser.Input.Keyboard.KeyCombo (resetOnWrongKey, resetOnMatch) + ProcessKeyCombo; vero quando la combinazione e' completa typedef struct { const int *codes; int n, index; float tLast, maxKeyDelay; } KeyCombo; static int KeyCombo_process(KeyCombo *c, int code, float t) { int keyMatched = 0; if (code == c->codes[c->index] && !(c->index > 0 && c->maxKeyDelay > 0 && t > c->tLast + c->maxKeyDelay)) keyMatched = 1, c->index++, c->tLast = t; if (!keyMatched) { c->index = 0; return 0; } if (c->index < c->n) return 0; c->index = 0; // ResetKeyCombo return 1; } static float now_ms(void) { return (float)(GetTime() * 1000); } // event.timeStamp static int tflag; // Core.tflag: la catena di Smith (spam nel menu, spam, spam, humbug in partita entro 30 s) static float tflagUntil; // ============================================================================ // 0xaa4f: StageModifiers // ============================================================================ typedef struct { float TimeLimit, ClockSpeed, PlayerPxSpeed, EnemySpeed, ProjectileSpeed, GoldMultiplier, EnemyHealthMultiplier, LuckBonus, XPBonus, StartingSpawns, EndCycles; struct { float start, hpPerMinute, speedPerMinute; int has; } TimeMods; } StageModifiers; static void StageModifiers_init(StageModifiers *m) { *m = (StageModifiers){ 0x708, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, { 0, 0, 0, 0 } }; } static float orv(cJSON *o, const char *k, float def) { float v = num(o, k, 0); return v ? v : def; } // a.x ? a.x : def static Color hexc(unsigned c, float a) { return (Color){ (c >> 16) & 255, (c >> 8) & 255, c & 255, (unsigned char)(255 * fmaxf(0, fminf(1, a))) }; } static void StageModifiers_Set(StageModifiers *m, cJSON *o) { if (!o) return; m->TimeLimit = orv(o, "TimeLimit", 0x708); m->ClockSpeed = orv(o, "ClockSpeed", 1); m->PlayerPxSpeed = orv(o, "PlayerPxSpeed", 1); m->EnemySpeed = orv(o, "EnemySpeed", 1); m->ProjectileSpeed = orv(o, "ProjectileSpeed", 1); m->GoldMultiplier = orv(o, "GoldMultiplier", 1); m->EnemyHealthMultiplier = orv(o, "EnemyHealthMultiplier", 1); m->LuckBonus = orv(o, "LuckBonus", 0); m->XPBonus = orv(o, "XPBonus", 1); m->StartingSpawns = orv(o, "StartingSpawns", 0); cJSON *tm = cJSON_GetObjectItem(o, "TimeMods"); if (tm) { m->TimeMods.has = 1; m->TimeMods.start = orv(tm, "start", 0); m->TimeMods.hpPerMinute = orv(tm, "hpPerMinute", 0); m->TimeMods.speedPerMinute = orv(tm, "speedPerMinute", 0); } } static void StageModifiers_Add(StageModifiers *m, cJSON *o) { // hyper e inverse sopra i mods dello stage if (!o) return; m->PlayerPxSpeed += orv(o, "PlayerPxSpeed", 0); m->EnemySpeed += orv(o, "EnemySpeed", 0); m->ProjectileSpeed += orv(o, "ProjectileSpeed", 0); m->GoldMultiplier += orv(o, "GoldMultiplier", 0); m->EnemyHealthMultiplier += orv(o, "EnemyHealthMultiplier", 0); m->LuckBonus += orv(o, "LuckBonus", 0); m->XPBonus += orv(o, "XPBonus", 0); m->StartingSpawns += orv(o, "StartingSpawns", 0); cJSON *tm = cJSON_GetObjectItem(o, "TimeMods"); if (tm) { m->TimeMods.has = 1; m->TimeMods.start = fminf(num(tm, "start", 0), m->TimeMods.start); m->TimeMods.hpPerMinute += orv(tm, "hpPerMinute", 0); m->TimeMods.speedPerMinute += orv(tm, "speedPerMinute", 0); } } // ============================================================================ // Tipi delle classi tradotte // ============================================================================ typedef struct Player Player; typedef struct Enemy Enemy; typedef struct EnemyPool EnemyPool; typedef struct Weapon Weapon; typedef struct Bullet Bullet; typedef struct BulletPool BulletPool; typedef struct MoonExplosionPool MoonExplosionPool; typedef struct Pickup Pickup; struct Player { // 0x869f Sprite s; int IsInFinalStage; // la fase 4 della Machine: la morte porta al GameOverino float radius, hp, xp, maxHp, power, area, speed, cooldown, amount, moveSpeed, growth, duration, luck, shields, armor, greed, regen, shieldInvulTime, revivals, rerolls, skips, banish, curse, charm, frameWalk, walked, slowMultiplier, invulTime, slowTime, shroud, magnet, gfeverMul, exLevels; cJSON *exWeapons, *hiddenWeapons; // armi in piu' all'avvio: normali / nascoste Weapon *onHPRecovery; // onHPRecoveryCallback (Soul Eater): riceve gli HP davvero recuperati Rectangle WorldBoxCollider, ScreenRectangle; // ScreenRectangle: di W_Lightning, qui per comodita' // il riquadro dello schermo attorno al giocatore: bordi per i proiettili che rimbalzano int noHurt; // plsNoHurt (Tatanka): particelle bianche e morte a fantasma int cantRetaliate; // Scorej: !canRetaliate (parte vero) int isMorphed; // Cavallo / Mortaccio dal livello 80 con la loro reliquia // Menya (0x15a3e), MegaMenya (0x2eb8), Syuuto (0xbc52), Onna (0x548e) float MightBonus, MoveBonus, CooldownBonus, CurseBonus, EnemiesTS; int MorphedTimes, finalMorphedTimes, hasSecondAnim, firingIndex, megaDead; const void *lastAnimFrame, *onnaFrames[6]; Animation walk2; Sprite head; // Mortaccio: la testa dello scheletro gigante float armorBonus, armorTime, ElapsedGFBonusTime; // Maruto (0x2470), Luminaire (0xb1f1) int timesRevived, hasBonus; Animation meleeA; // meleeA o rangedA, dipende dal personaggio (Foscari) int hasMeleeA, hasRangedA; int isDead, level, isAnimForced, canFlipX, flipper, HasWalkingAnimation, _invul, IsSlow, receivingDamage, isLastBreathEnabled, hasLastBreath, maxHistory, historyIndex; Vector2 lastFacedDirection, posHistory[0x12d]; // SetMaxHistory: 3 di solito, 300 oltre il bordo di Green Acres float ghostAlpha; int ghostsHidden; // rtGhosts.setVisible(false): W_SoleSolution struct Sine *sineSpeed, *sineDuration, *sineArea, *sineCooldown, *sineMight; // 0x6508: NULL = assente struct { const char *k; float v; } onEveryLevelUp[24]; int n_onEveryLevelUp; const char *characterType, *startingWeapon; TweenRef wiggleTween; Timer _blinkTimeout, regenTimer; Animation walk; cJSON *data; // tabella del personaggio (characters.json) ParticleEmitter *PfxEmitter; // gocce rosse quando viene colpito }; typedef struct { // 0x18540 Sprite s; float radius, percentage; } Magnet; // sottoclassi dei nemici (EnemyPool: new secondo il tipo): i metodi assenti sono quelli di Enemy (0x1166a) typedef struct EnemyVT { void (*OnRecycle)(Enemy *e); void (*Die)(Enemy *e); void (*GetDamaged)(Enemy *e, float amount, int hitVFX, float kb, const char *bulletType); void (*Update)(Enemy *e); void (*DeSpawn)(Enemy *e); void (*Disappear)(Enemy *e); void (*OnPlayerOverlap)(Enemy *e); void (*OnMusicBeat)(Enemy *e); // Astral Stair: i battiti (STARDUST_*, COSMIC_EGG) void (*setOwner)(Enemy *e); // EnemyPool.SpawnAt, dopo la posizione (BRIDGE_*: l'aspetto alternativo a destra del giocatore) } EnemyVT; struct Enemy { // 0x1166a Sprite s; const EnemyVT *vt; int legitKill; // BOSS_XLDEATH (0x5c80): morto davvero solo per Infinite Corridor o Crimson Shroud // PILE (0x76a7), JELLYFISH (0x7c4a), BOSS_XLSTALKER (0x1458d), BULLET_1 (0x533) float sineF, firetime, lifetime, fireDelay; int hasLostTreasure, paniniDone; // paniniDone: done del montante di Panini (mai azzerato, sic) const char *bulletType; TweenRef OnEnterTween, OnFireTimer, OnSineTween, OnLifetimeTween, ScaleTween; void (*onDefeat)(Enemy *e); // BOSS_WEREWOLF2 (0x184e8), BOSS_NOOB (0x115f3): chi lo ha evocato EnemyPool *pool; const char *enemyType; float hp, maxHp, minHp, dataMaxHp, power, knockback, maxKnockback, deathKB, damageKB, xp, speed, scaleMul, defaultSpeed, slow, damageWeakness, medusaElapsed, moreX, moreY, res_Rosary, feverValue, res_Freeze, res_Debuffs, res_Corridor; int HPxLevel, FixedDirection, Medusa, isDead, receivingDamage, IsTimeStopped, isCullable, isTeleportOnCull, isDespawning, conditional_canMove, moveTweenIndex, idleFrameCount, passThroughWalls, hasColliderOverride; float colliderRadius, colliderOffsetX, colliderOffsetY; cJSON *treasure; // AttachTreasure: dati del forziere dello stage int treasureLevel; // treasure.level scritto da SetTreasureLevelFromChance Vector2 _currentDirection; Sprite *target; const Frame *defaultName; unsigned saveTint; Animation die, idle; Timer _blinkTimeout, FreezeTimer, divineBloodlineDamageTimer, shieldTimer; int canBeDamagedByBloodline; // EnemySkill.SelfDestruct: vicino al giocatore lampeggia (alertSprite) e dopo 2 s esplode (Core.MakeExplosion(moreX, moreY)) int SelfDestruct, isSelfDestructionTriggered; float SelfDestDistance; // distanza al quadrato Sprite alertSprite; TweenRef alertTween; Timer SelfDestructTimer; int lives; // SKELANGUE (0x14e3e): risorge finche' ha vite Animation undie; int isRotating, keepMoving; // XLDRAGON (0xaddc), XLMAGIO (0x686) int activated; // BOSS_XLLEDA (0x12236), BRIDGE_BOSS (0x17b7f): 0 finche' dormono TweenRef RotateTween, fadeTrailTween; struct FlagTrail *trail; // XLDRAGON_FLAG (0xe43d) void *x; // i campi propri dei boss (CrabX, DrownerX, WaveX...), creati al primo OnRecycle (il costruttore) Enemy *owner; // BOSS_XLPINCER: il granchio, a cui OnDead void (*OnDead)(Enemy *owner); Sprite *ringSprite; // i boss del finale: l'anello dell'urlo (DeathScream) }; struct EnemyPool { // 0xd1a1 const char *enemyType; Enemy **stored, **spawned; int n_stored, n_spawned, cap, enabled, upperLimit, isUncapped; }; typedef struct BulletVT BulletVT; typedef struct WeaponVT WeaponVT; struct Weapon { // 0xe49a int player; // di chi e' (partita a due) const WeaponVT *vt; const char *bulletType; float interval, repeatInterval, secondaryPower, power, area, speed, amount, duration, critChance, critMul, penetrating, bounces, knockback, hitBoxDelay, freezeChance, lastFiringInterval, stats_inflictedDamage, stats_lifetime, charges, bonusBounces, hitVFX, volume, chance; // chance: W_Pentagram / W_Sire int level, canCrit, hitsWalls, isPowerUp, intervalDependsOnDuration, critIndex, explodeOnExpire, cooldownAffectedByMovement; int limitBreakLevel; // ApplyLimitBreak (accumulatedLimitBreaks serve solo a CopyAccumulatedLimitBreaks di SPELL_STROM, DLC) float critChancesArray[1000]; float healAmount; // W_Sarabande: 0.1 * la cura (TriggerSarabande) int beginningArcana; // Arcana X Beginning gia' applicata const char *explosionType; // RAYEXPLOSION (default), FIREEXPLOSION, COLDEXPLOSION...: la classe di SpawnExplosionAt int secondaryCurse; // SecondaryOvarlapDamageType === CURSE: l'esplosione fa SecondaryCursePPower int skipAddingEvolution; // Pavone: le sue armi nascoste non aggiungono l'evoluzione allo store Sprite *target; // Fire: bersaglio scelto dall'arma (Fire Wand, Hellfire...), passato a SetTarget BulletPool *pool; Collider *wallsColliders[16]; // uno per CollisionLayer; Iron Blue li toglie BulletPool *bloodPools[5]; // W_BloodAstronomia: Garlic, Song, Pentagram, Lancet, Laurel int isStars, hasBullets, hasImage; // W_Cherry SetToStars / W_CherryStars (CHERRY2) BulletPool *drawerPool, *explosionPool; Sprite cow; // W_BoneGiant (BONE2): lo scheletro fantasma e le due braccia giganti BulletPool *armPool; Bullet *frontArm, *backArm; Sprite head, torso, halo; int hasSkeleton, AreArmsAttached, isAttacking, firedTimes; float topDepth; float gemValue; // W_GemCannon: valore e fotogramma della gemma raccolta const Frame *gemFrame; Weapon *astroSrc[5]; // ... e l'arma che li ha fatti partire (overrideWeaponData) int n_wallsColliders; Timer firingTimer, lastShotTimer; cJSON *data; // W_HolyWater (0xe2b7), W_Bora (0x8c61) float targetAngles[12], targetRadii[12], totalTime, mul; int lastAngleIndex, maxAngles, lasRadiusIndex; Vector2 targetPoints[12]; // W_Vampirica (0xd684) int canHeal; float healDelay; Timer healTimer; // W_Laurel (0x11fa3) float maxCharges; int hasThorns; Sprite image, image2; // Laurel/Garlic: image; Soul Eater: image e imageBG // W_Shroud (0xe905): ritorsione col danno assorbito dallo scudo, cerchio a colori invertiti (inverseFilter) float lastReceivedDamage, invRadius; int canPlayInversionVFX; Sprite inverse; TweenRef ringTween, ringTween2; // W_MirageRobe: l'anello (in image) int hasRingTween, hasRingTween2; const float *fireAngles; // W_NightSword (0x1368): spade in sequenza, la sesta di chiusura solo con canFinish int retaliationOnly; float retaliationDelay; Sprite orbs[24]; // W_Bocce (0x113e4): sfera a schermo (image) e otto sfere che orbitano; W_FourSeasons (8), W_FourSeasons2 (24) int nOrbs, canSpin; float orbAngles[25], orbMul[9], bocceTint; // W_Spellstring / W_Spellstream / W_Spellstrike / W_Spellstrom (0x142c3, 0x7d8a, 0xc553, 0xe817) // W_Sword / W_Legionnaire, W_FlashArrow / W_Millionaire, W_ShadowServant, W_Prismatic / W_Luminaire, W_Party int firingCounter, canDoFinisher, canRetaliate, retalNext, snakeKind, firstArcana, colorIndex, frontFiring, fireType; BulletPool *retaliationPool, *finisherPool, *legionnairePool; Timer RetaliationTimer, MeleeAnimEvent, RangedAnimEvent; ParticleEmitter *SmokeEmitter; float CoinsQueue, CoinsTime; TweenRef millTween[2]; Rectangle lumRect; Vector2 *wellSrc, wellPos[2]; // sources: NULL = il giocatore; Spellstrom le da' i due pozzi int sourceIndex, doingSingularity, singularityTimes, skipEmitUpdate; float spellY, stormRadius, angleValue, singularityTime, stormK; Weapon *Weapon_String, *Weapon_Stream, *Weapon_Strike; ParticleManager *stormPfx; ParticleEmitter *stormE1, *stormE2, *circleE; const char *lbKeys[16]; // accumulatedLimitBreaks: le chiavi, per CopyAccumulatedLimitBreaks int nLbKeys; Vector2 seasonPos[5]; // W_FourSeasons: gli angoli dello schermo const Frame *seasonFrame[5]; // la RenderTexture con l'animazione: qui il fotogramma corrente (frameRef) float seasonClock; float recoveredHP, recoveredCalculated, imageScale, innerScale, innerDuration, vfxTime; ParticleManager *vortexPfx; // W_Pentagram (0x17906) / W_Sire (0x1ed3): simbolo in una RenderTexture spezzata da rexShatterImage int canFlash; unsigned badColor, goodColor; float badAlpha, goodAlpha, badRadius, goodRadius, whiteTint; RenderTexture2D rt; ShatterImage *canvas; Sprite outline, center, inner, outer, whiteDot, groundSeal; TweenRef whiteTween, blackTween, sealSpin, sealShow, sealHide; Timer flashTimer; Bullet *activeBullet; MoonExplosionPool *moonExplosionPool; // W_Carnage (0x182a2) int canExplode, exploIndex; Timer ExplodeTimer; BulletPool *TVexplosionPool, *OnGetHitExplosionPool; // W_Silf (0x13a8e) / W_Silf2 (0x127ba) int silf2, silf3, blockFire, enemyIndex, ntargets; int silfCounter; // W_Silf_Counter (1) / W_Silf2_Counter (2): Gemini Weapon *counterWeapon, *counterWeapon2; // Aquarius (Gemini): la gemella nascosta, sale di livello con l'arma const char *const *catBaseFrames; // W_Gatti: RND.pick dei gatti (il contatore ne ha altri) int nCatBaseFrames; Sprite sprite, damageZone, targetZone, damageZone2, targetZone2; // 2: solo W_Silf3 Vector2 targets[24], _currentDirection; float angleTime, delayBasedOnDuration, rayDuration, runSpeed, damageZoneDistance, damageZoneDefaultRadius; // W_Guns (0x140bb) / W_Guns2 (0xb0e5) int hasSecondSet, resetDisabled; Weapon *secondSet; // W_Guns3 (0x1665e) float rayAngle, angleUnit, pxUnit; Sprite rays[32]; int n_rays, hasPermaTween; TweenRef scaleTween; // W_Gatti (0xab10) float RANDOMS[1000], PLUSMINUS[1000], full, chickens; // 1000: W_Grangatti, 500: W_Gatti float goldChance; // W_Grangatti (0xa914) const char *SFXARRAY[120]; int randomIndex, plusMinusIndex, sfxIndex; BulletPool *secondaryPool, *scratchPool, *scufflePool, *redPool; // redPool: W_SummonNight2 // W_Lancet (0x16b3a) / W_Corridor (0x7819) int ticks; Vector2 lancetTargets[12]; float lancetAngles[12]; TweenRef imageTween; const Animation *pierceAnim; BulletPool *corridorPool; // W_Vento (0x11f65) float walkedW, pBonus; int hasWalkedTimer; Timer walkedTimer; ParticleManager *ventoPfx; // W_Cherry (0x3e35) Sprite leafSprite; // anche W_Vento2: la foglia della RenderTexture 'castoro0' // W_Vento2 (0x7051) int canExplodeV2; float explodeDelay; Timer explodeTimerV2; BulletPool *extraPool; int canFinish; // W_Victory (0x1721f) const char *robbaFrames[23]; // W_Larobba (0xdf2e): targetAngles e lastAngleIndex sono quelli di W_HolyWater int lastRobbaIndex; int canFire; // W_SoleSolution (0x4ebb): image = la galassia, image2 = solesBG float galaxyForce; ParticleManager *pfx; ParticleEmitter *pfxEmitter; Vector2 Location; // W_Cart (0xa23f): dove e' stato rotto il distruttibile che lo fa partire int hasLocation; // W_Jubilee (0x185ad) ParticleManager *fwManager; ParticleEmitter *fwEmitters[5]; int canPlaySounds, soundIndex, jubSoundN, jubSoundIdx; Timer soundTimer; // PowerUp (0x5dba): bonus che si sommano al giocatore float pu_power, pu_area, pu_speed, pu_cooldown, pu_amount, pu_maxHp, pu_moveSpeed, pu_growth, pu_magnet, pu_luck, pu_armor, pu_duration, pu_greed, pu_regen, pu_revivals, pu_curse, pu_rerolls, pu_skips, pu_banish, pu_charm; }; struct Bullet { // 0xa14d Sprite s; const BulletVT *vt; BulletPool *pool; Weapon *weapon; int isDead, indexInWeapon, isCullable, isTeleportOnCull, n_hit, cap_hit; float penetrating, bounces, _speed; void **objectsHit; // B_Whip float previousArea; TweenRef tween, tween2; int hasTween, hasTween2; // scie (B_Knife, B_Axe, B_Scythe): un fantasma; B_Vampirica: due Sprite ghost, ghost2; Vector2 posHistory[8]; int maxHistory, historyIndex; // B_Cross, B_HeavenSword: piu' fantasmi, accelerazione in tween sulla velocita' di partenza Sprite ghosts[8]; float angleHistory[8], accel; Vector2 velocity; TweenRef AccelTween, BackwardTween; // B_Diamond (0xd459): la scia di 100 posizioni Vector2 positions[100]; int npos, enemiesHit; unsigned color; float save_vel_x, save_vel_y, trailAlpha; Sprite trail; // B_SilverWind (0xbd7c): le linee della scia, ognuna sfuma per conto suo struct WindLine *lines; int linesHead, linesN, IsInStartingPosition, canUpdateTrail, hasPrevPos; float fnTime, linesClock; Vector2 prevPos; // B_MirageRobe (0x5246) float mirageHits; int hasFadeOut; // B_Spellstring (0x91a5), B_Spellstream (0x15475), B_Spellstrike (0x4990) int updateLoops, expired; float angleLerp, deceleration; Vector2 startingPoint; // B_Sword, B_ShadowServant, B_PrismaticMissile, B_Party float detuneMul, selfGravity, bounceValue, clearObjectTime, angleIncrement; int canClearObjectsHit, hasHitFirstEnemy, isExploding; ParticleEmitter *pfxEmitterB; struct PartyData *party; // B_FourSeasons (0xcc71) / B_FourSeasons2 (0x9a27) Sprite kanji, lightning; ParticleManager *SeasonPfx[5]; ParticleEmitter *SeasonEmit[5]; int season; TweenRef fsTween[6]; float kanjiTint, lightningTint; // B_SummonNight (0x14b69) / B_SummonNight2 (0x87c2) ParticleManager *PfxBack; Sprite fang; TweenRef fangTween, fangTweenOut; int hasFangTween, hasFangTweenOut; float reach; // B_Lightning (0xce4a): RibbonTrail orizzontale di 16 punti (Lightning3.png) e il lampo a terra Vector2 ropePts[32]; Sprite flash, flash2; // B_Loop: graphics e graphics2 int isGrounded; Sprite *target; // AimForRandomEnemyInScreen: il nemico del colpo TweenRef moveTween, despawnTween; int hasMoveTween, hasDespawnTween; // B_Axe Vector2 initialVelocity; float moveAngle, grav, startingAngle, defaultVelocityY; // defaultVelocityY: B_Larobba TweenRef AngleTween, MovementTween, ScaleTween; // B_HolyBook / B_HolyWater float deltaTime, radius, perc, exploRadius, explosionRadius; TweenRef scaleTween, PositionTween; int hasScaleTween, hasPositionTween, isBroken; Timer HitboxTimer, ExpireTimer; ParticleManager *Pfx, *PfxExplosion; ParticleEmitter *PfxEmitter, *PfxEmitter1, *PfxEmitter2; Sprite GroundFx; // b_Bora (0xbbe) TweenRef growTween, scaleGroundTween, fadeOutTween; int hasGrowTween, hasScaleGroundTween, hasFadeOutTween; float globalScale; // B_Pentagram / B_Sire // B_Carnage / B_CarnageExplosion int canExplode, exploIndex; Timer ExplodeTimer; float totalTime; Sprite screenSprite; TweenRef alphaTween, exploTween; // B_Silf / B_Silf2: spline di 3 punti percorsa a velocita' costante, RibbonTrail di 24 punti Vector2 curvePts[3]; float arcLengths[101], duration; int isKilled, trailAdd; const Frame *trailFrame; TweenRef fadeInTween; // fadeOutTween: gia' di B_Bora // B_Gatti / B_Gatti_Scratch Sprite summon; Animation idleAnim; Vector2 aimVec; float defaultSpeed; int isInitialised, cfgIndex; Timer chooseTimer; TweenRef summonTween, entryTween, onExpireAlphaTween, exitTween; int colorCount, repeatCount; // B_Vento2explo int isPlayerFacing; // B_Misspell float *requiem; // B_HolyBook / B_Vespers: requiemRandomOffsets (500 valori tra 0 e 16) int requiemIndex, bounceActivated, isLight; Sprite starSprite, sideSprite, flatSprite, exploSprite; // B_FlareExplosion int victoryFinish; // B_Victory: il sesto colpo, colpo finale (canFinish) // B_Song struct Blitter *blitter, *blitterBG; Timer FadeOutTimer; TweenRef FadeOutTween; // ScaleTween: gia' di B_Axe // B_Trapano Sprite spikeSprite; Vector2 previousVector; int isYeeted, isFading; float durata; TweenRef tween1; Timer explodeTimer; // B_Jubilee ParticleEmitter *jubEmitter; float jubX, jubY, counterVal; TweenRef emitterCounter; // B_Flower Sprite flowerSprite; float bounceAreaMod, maxBounceAreaMod, scaleAfterBounceMod; // B_Cart2 int makeSparks, isFadingOut, enterTweenCompleted; TweenRef disappearTween, enterTween; // B_Cherry Sprite ring, rainbow, rays; float bombDeceleration; ParticleManager *Pfx2; TweenRef SpeedTween; // B_Bone int canBounce, accelOnBounce; float physBounce; Timer BounceTimer; // B_SpaceTime Sprite corridorLight; TweenRef lightTween; // proiettili di Blood Astronomia (0x37ec) float amount, slowPower, groundX, groundY, myRotationAngle, angleRotUnit, radiusMulX, radiusMulY; TweenRef angleTween, imageTween, radiusTween; Sprite *numbers; // B_Blood_Lancet: i 12 numeri dell'orologio (allocati solo li') Sprite windowVfx; // B_Window // B_CherryStar (0x1438f): 7 + 7 stelle, scia di 400 punti, ultimi bersagli Sprite *stars1, *stars2; Vector2 *starTrail, starTarget, lastTargets[3]; int nStarTrail, nTargets, canUpdate, starIndex, bouncedTimes, alreadyRecycled; float starSin, starCos; // B_BoneGiant (0x8343): il braccio si vede con display, il corpo resta invisibile Sprite display; Vector2 anchor; int isAttached, isSpinning; TweenRef attachTween; float *radii; }; struct BulletPool { // 0x4a9d Weapon *weapon; const BulletVT *vt; // new BulletPool(scene, type): NULL = il proiettile dell'arma Bullet **stored; int n_stored, cap_stored, upperLimit, isUncapped; SpriteList group; // il Group stesso (figli = proiettili attivi) }; typedef struct PickupPool PickupPool; typedef struct { // sottoclassi di Pickup: metodi sovrascritti (NULL = quello della base) const char *itemType; void (*ctor)(Pickup *p); void (*OnRecycle)(Pickup *p); void (*DeSpawn)(Pickup *p); void (*GetTaken)(Pickup *p); void (*Update)(Pickup *p); } PickupVT; struct Pickup { // 0x166d5 (+ sottoclassi: 0x50ae Gem, 0x8af Treasure) Sprite s; int player; // verso chi vola (partita a due) float DEFAULT_SPEED, radius, speed, time, value, feverMS; int goToPlayer, isStationary, disableGet, isCullable, isTeleportOnCull, isGem; int quiet; // Silver Wind: volume 0.1 invece di 0.35; come nell'originale resta nel pool const char *itemType, *frameName; Vector2 currentDirection; TweenRef vacuumTween; PickupPool *pool; const PickupVT *vt; // Treasure (0x8af) int hasArcana, CurrentTreasureLevel; cJSON *CurrentTreasureTypes, *CurrentFixedTreasures; Sprite Cursor; Animation cursorIdle, cursorNeutral; Animation idle; // Rosary/PocketWatch/Vacuum/Nft/Gilded: 'idle' a 10 fps // PickupGuarded (0x15ee2) + pickup arma (0xbf1f) const char *weaponType, *enemyType; void (*OnPickupCallback)(Pickup *p); // owner.OnPickupCallback: la classe dello stage che l'ha messo (il formaggio del Dairy Plant) float spawnQuantity, spawnAngle, guardRadius, left, right, top, bottom, colorValue, totalTime, particlesInterval; int hasSpawned, despawnOnUnavailable; Sprite shadow, glow; TweenRef floatTween, shadowTween, glowTween; int hasFloat; struct Enemy *guards[32]; // PickupGuarded.guards int n_guards; // Coffin (0x13742) / CoffinX (0x444) const char *charCFF; int opened, isCoffinX; void (*OnOpen)(void); // bara vuota (0x1072b): la bara giusta del pianoforte Sprite Lid, CharSprite; Sprite CursorIcon; // uovo d'oro (0xf1f6): l'icona accanto alla freccia ParticleManager *pfx; // mercante (0xc903) ed Eggman (0x11e05): maschere o uova che salgono void *ext; // la parte propria della sottoclasse: HealerX (0x639b), TeleX (0x301a) struct Pickup *link; // Teleporter / Moongate: l'altro capo float destinationX, destinationY, triggerDelay; int canTeleport; ParticleEmitter *pfxE; }; typedef struct { // stored[itemType] / spawned[itemType] const char *type; Pickup **stored, **spawned; int n_stored, n_spawned, cap, cap_stored; } PickupSlot; struct PickupPool { // 0xd856 PickupSlot slots[32]; int n_slots; }; typedef struct { // 0x12c8a float x, y, width, height, halfWidth, halfHeight; int index; } ContainmentRect; typedef struct { // 0x11804 const char *stageType; int dataMinute, realMinutes, startingSpawns, minimum, maximum, defaultMaximum, lastMinimum, lastMaximum, stopCheckingMinutes, hasTileset, n_pools; float frequency, EffectiveSpawnFrequency, pause, minimumMultiplier, EnemyHealthMultiplier, EnemySpeedMultiplier, pizzaDelay; cJSON *enemies, *bosses, *data; StageModifiers StageModifiers; Rectangle rectOuter, rectInner; EnemyPool *pools[256], *bossPools[64]; // Green Acres accumula i tipi di cinque stage int n_bossPools, hasAttachedTreasure; cJSON *treasure, *arcanaTreasure; // arcanaTreasure: il forziere dell'arcana del portatore (Randomazzo) const char *arcanaHolder; EnemyPool *arcanaPools[4]; int n_arcanaPools; const char *destructibleType; float destructibleFreq, destructibleChance, destructibleChanceMax; int maxDestructibles; Timer DestructibleTimer; Timer SpawnTimer; int stageEventManager_spawned; struct TilingTileset *tilingTileset; // Init / UpdateAllData (i campi che l'originale copia dai dati con hasOwnProperty) const char *spawnType, *cffName, *BGTextureName; int randomMinutes, dayNight, hasLights, isMerchantBanned, hasClosestDestructibleLogic, hasWallsCheckDestructibleLogic; int hasTrisection; // SelectedRandomEvents: la Trisection dello stage (con Astral Stair l'istanza e' una sola) float bulletAllowance, pizzaIntervalInMilliSeconds; unsigned DayColor, NightColor, InverseDayColor, InverseNightColor; cJSON *pizzaEvents, *poolsMapping, *LootTable; EnemyPool *mappedPools[32]; // poolsMapping[i].pool int n_mappedPools; Vector2 *tiledPositions, *EnemySpanwersLocations, *DestructibleLocations, *CartLocations, *WindowLocations, *PizzaLocations; // (sic) Spanwers int n_tiledPositions, n_EnemySpanwersLocations, n_DestructibleLocations, n_CartLocations, n_WindowLocations, n_PizzaLocations; Rectangle *NoShadowLocations; int n_NoShadowLocations; Timer NoShadowsTimer, PizzaTimer; Sprite WarningSprite, PizzaSprite; const struct FancyBG *fancyBG; // la classe dello stage (Stage.fancyBG), creata se i dati hanno 'background' EnemyPool *BulletPool1; // BULLET_1: i proiettili di tutti i nemici che sparano struct Weapon *WindowWeapon; // fancyBG.WindowWeapon (Cappella): le vetrate rotte sparano con quest'arma } Stage; // Stage.fancyBG: le sottoclassi per stage (FOREST 0x148ea, LIBRARY 0x11270, ...); i metodi assenti valgono NULL typedef struct FancyBG { void (*Create)(void); void (*Update)(float delta); void (*CheckMinute)(int minute); void (*CheckHalfMinute)(void); void (*OnInitCompleted)(void); // dopo BGMan e il resto del Core (Bat Country: lo sfondo) int (*HasMovingBG)(void); // hasMovingBG: la levetta dello sfondo in movimento nelle opzioni della pausa void (*DisableMovingBackground)(void); } FancyBG; static int HasHardBounds; // MainScene.HasHardBounds; RemoveHardBounds = azzerarlo a inizio partita static Rectangle HardBounds; // width e height sono i massimi, non le misure (sic) static void Core_SetHardBounds(float x, float y, float w, float h) { HardBounds = (Rectangle){ x, y, w, h }, HasHardBounds = 1; } static int FB_disableMovingBG; // fancyBG.disableMovingBG static struct { // 0x5103: Core Player *Player; Magnet *Magnet; Stage *Stage; SpriteList Enemies, EnemyGroup, PickupGroup, BulletGroup, playerGroup, MagnetGroup, PickupsWithArrows; Weapon **Weapons, **RemovedWeapons, **HiddenWeapons; // quelli del giocatore corrente (PlayerSlot) int n_RemovedWeapons, n_HiddenWeapons; int n_weapons, SurvivedSeconds, updateTick, updateFreq, MaxGems, IsTimeStopped, canInterrupt, canPause, kills, enterPause; int EnterWeaponSelection, WeaponSelectionEvo; // Candybox: WeaponSelectionType 'normal' / 'evo' int GiveMainArcana, GiveDraftArcana; Weapon *weaponWithShader; // SOLES fra le HiddenWeapons: niente inverseFilter (Crimson Shroud) Collider *pickupCollider; PickupPool gemsPool, pickupPool; Pickup *StagePickups[32]; int n_StagePickups; const char *CharQueue[8], *CurrentFoundChar; int n_CharQueue; const char *FoundWeaponQueue[16], *CurrentFoundItem; int n_FoundWeaponQueue; const char *RelicQueue[16], *CurrentFoundRelic; int n_RelicQueue; int StartShopScene, MerchantInventory, StartHealerScene, StartDirecterScene, JustGotMirror, JustGotTrumpet; // MerchantInventoryType (0x2aa9): 0 DEFAULT, 1 EGGSONLY int AlwaysCoinbag, AlwaysRoast, AlwaysRandomLimitBreak; // scelte "[Always]" e "casuale sempre" del level-up ParticleManager *PfxEmitter_Pickups; struct { int level; cJSON *types, *fixed; } TreasureQueue[16]; // new Treasure(level, prizeTypes, fixedPrizes): forzieri raccolti int n_TreasureQueue, CurrentTreasureLevel; cJSON *CurrentTreasureTypes, *CurrentFixedTreasures; ContainmentRect containmentRect_Exact, containmentRect_Screen, containmentRect_Enemies, containmentRect_Bullets; float currentXPfactor, previousXPfactor, defaultXPfactor; // LevelUpFactory (0xeac3) Timer tickerEvent; Collider *pickupColliderImmaterial; struct { struct EnemyExplosion **stored, **spawned; int nstored, nspawned, capstored, capspawned; } explosionPool; // 0x14e6f struct { struct ShootingStar **stored, **spawned; int nstored, nspawned, capstored, capspawned; } starPool, starPool2; // 0x10924 / 0x7680 (shootingStarsManager / 2) SpriteList Destructibles; struct DestructiblePool *destructiblesPools[8]; int n_destructiblesPools, MaxDestructibles; Timer TimeStopTimer; float RunCoins; // PlayerOptions.RunCoins const char *RunPickups[512]; // PlayerOptions.RunPickups / RunPickups_Coins (riepilogo di fine partita) int n_RunPickups, RunPickups_Coins; } Core; // --- Partita a due: lo stato di ciascun giocatore. Core.Player e le armi puntano al giocatore corrente, cosi' la logica tradotta // dall'originale resta la stessa e gira una volta per giocatore. Con un giocatore solo non cambia mai. typedef struct { Player *player; Magnet *magnet; Weapon *weapons[16], *removed[16], *hidden[16]; int n_weapons, n_removed, n_hidden; Vector2 lastVelocity; } PlayerSlot; static PlayerSlot Slots[2]; static int Players_n = 1, Scene_owner, Pickup_owner; int game_context; void game_context_set(int i) { if (i == game_context) return; PlayerSlot *o = &Slots[game_context], *n = &Slots[i]; o->player = Core.Player, o->magnet = Core.Magnet, o->n_weapons = Core.n_weapons, o->n_removed = Core.n_RemovedWeapons, o->n_hidden = Core.n_HiddenWeapons; game_context = i; Core.Player = n->player, Core.Magnet = n->magnet, Core.n_weapons = n->n_weapons, Core.n_RemovedWeapons = n->n_removed, Core.n_HiddenWeapons = n->n_hidden; Core.Weapons = n->weapons, Core.RemovedWeapons = n->removed, Core.HiddenWeapons = n->hidden; } static void Players_reset(void) { memset(Slots, 0, sizeof(Slots)); game_context = 0, Players_n = 1, Scene_owner = Pickup_owner = 0; Core.Weapons = Slots[0].weapons, Core.RemovedWeapons = Slots[0].removed, Core.HiddenWeapons = Slots[0].hidden; } static int Players_isLocal(void) { return Players_n == 1 || game_context == net_role; } // solo il proprio HUD static int Players_ofSprite(const Sprite *s) { return Players_n > 1 && s->owner == (void *)Slots[1].player ? 1 : 0; } // ============================================================================ // 0x17260: SoundManager (effetti e musica) // ============================================================================ // Chiavi dei suoni e file in sfx/ (load.audio del preload): solo nomi, gli audio vengono dalla copia dell'utente static const struct { const char *key, *file; } SOUND_FILES[] = { { "Treasure1", "sfx_treasure_1.ogg" }, { "Treasure2", "sfx_treasure_2.ogg" }, { "Treasure3", "sfx_treasure_3.ogg" }, { "ThingFound", "sfx_treasure_found.ogg" }, { "BGM_GameOver", "sfx_gameOver.ogg" }, { "BGM_Intro", "sfx_titleIntro.ogg" }, { "LevelUp", "sfx_levelup.ogg" }, { "Treasure1B", "sfx_treasure_1B.ogg" }, { "Treasure2B", "sfx_treasure_2B.ogg" }, { "Treasure3B", "sfx_treasure_3B.ogg" }, { "ThingFoundB", "sfx_treasure_foundB.ogg" }, { "BGM_GameOverB", "sfx_gameOverB.ogg" }, { "BGM_IntroB", "sfx_titleIntroB.ogg" }, { "LevelUpB", "sfx_levelupB.ogg" }, { "BGM_Forest", "bgm_will_beginning.ogg" }, { "BGM_Library", "bgm_elrond_library.ogg" }, { "BGM_Plant", "bgm_elrond_plant.ogg" }, { "BGM_Tower", "bgm_elrond_tower.ogg" }, { "BGM_Chapel", "bgm_elrond_chapel.ogg" }, { "BGM_Forest_B", "bgm_vica_01.ogg" }, { "BGM_Library_B", "bgm_vica_02.ogg" }, { "BGM_Plant_B", "bgm_vica_03.ogg" }, { "BGM_Tower_B", "bgm_vica_04.ogg" }, { "BGM_Chapel_B", "bgm_vica_05.ogg" }, { "BGM_Water_B", "bgm_vica_07.ogg" }, { "BGM_BatCountry", "bgm_vica_08.ogg" }, { "BGM_Bones_B", "bgm_vica_09.ogg" }, { "BGM_BossRush_B", "bgm_vica_10.ogg" }, { "BGM_AstralStair", "bgm_vica_11.ogg" }, { "BGM_Bestiary", "bgm_elrond_dust.ogg" }, { "BGM_GreenAcres", "bgm_elrond_forest.ogg" }, { "BGM_Mana", "bgm_elrond_mana.ogg" }, { "BGM_RedBlue", "bgm_elrond_redblue.ogg" }, { "BGM_Gatti", "bgm_elrond_gatti.ogg" }, { "BGM_Peggi", "bgm_elrond_peggi.ogg" }, { "BGM_Chapet", "bgm_elrond_chapet.ogg" }, { "BGM_Water", "bgm_elrond_water.ogg" }, { "BGM_Vento", "bgm_elrond_vento.ogg" }, { "BGM_Secret", "bgm_elrond_secret.ogg" }, { "BGM_Pizza", "bgm_elrond_pizza.ogg" }, { "BGM_BossRush", "bgm_elrond_fighting.ogg" }, { "BGM_Machine", "bgm_elrond_machine.ogg" }, { "BGM_Bones", "bgm_elrond_bone.ogg" }, { "BGM_Solution", "bgm_elrond_solution.ogg" }, { "TheEndIntro", "bgm_TheEndIntro.ogg" }, { "TheEndMain", "bgm_TheEndMain.ogg" }, { "TheEndIndeed", "bgm_proooot.ogg" }, { "BGM_Spoopy", "bgm_elrond_spoopy.ogg" }, { "BGM_Flame", "bgm_elrond_flame.ogg" }, { "BGM_Bridge", "bgm_elrond_bridge.ogg" }, { "BGM_Foscari_KAZ", "bgm_elrond_foscariK.ogg" }, { "BGM_Magic_KAZ", "bgm_elrond_magicK.ogg" }, { "BGM_War_KAZ", "bgm_elrond_warK.ogg" }, { "BGM_Deception_KAZ", "bgm_elrond_deceptionK.ogg" }, { "BMG_Moonspell", "bgm_moonspell_theme.ogg" }, { "BGM_Silver", "bgm_elrond_miang.ogg" }, { "BGM_FourSeasons", "bgm_elrond_kachara.ogg" }, // manifest dei DLC { "BGM_Night1", "bgm_elrond_night1.ogg" }, { "BGM_Night2", "bgm_elrond_night2.ogg" }, { "BGM_Mirage", "bgm_elrond_mirage.ogg" }, { "BGM_Foscari", "bgm_elrond_foscari.ogg" }, { "BGM_Foscari2", "bgm_elrond_foscari2.ogg" }, { "BGM_Magic", "bgm_elrond_magic.ogg" }, { "BGM_War", "bgm_elrond_war.ogg" }, { "BGM_Deception", "bgm_elrond_deception.ogg" }, { "BGM_Genevieve", "bgm_elrond_genevieve.ogg" }, { "BGM_Luminaire", "bgm_elrond_luminaire.ogg" }, { "BGM_HB", "bgm_elrond_hb.ogg" }, { "ClickIn", "sfx_sounds_pause7_in.ogg" }, { "ClickOut", "sfx_sounds_pause7_out.ogg" }, { "MagicMissile", "sfx_projectile_magic.ogg" }, { "Whip", "sfx_sounds_impact15_2.ogg" }, { "Shot", "sfx_projectile.ogg" }, { "Lightning", "sfx_lightningimpact.ogg" }, { "Lightning2", "sfx_lightningimpact.ogg" }, { "Holywater", "sfx_frostimpact.ogg" }, { "Hit", "sfx_enemyHit.ogg" }, { "LittleHit", "sfx_digit.ogg" }, { "Coin", "sfx_coin_double4.ogg" }, { "Gem", "sfx_gem.ogg" }, { "Roast", "sfx_sounds_powerup2.ogg" }, { "Rosary", "sfx_exp_double1.ogg" }, { "Orologion", "sfx_sounds_impact9.ogg" }, { "Vacuum", "sfx_sounds_powerup18.ogg" }, { "Lucky", "sfx_sounds_powerup9.ogg" }, { "PentagramSFX", "sfx_wpn_cannon3.ogg" }, { "LossSFX", "sxf_loss.ogg" }, { "Explosion", "sfx_exp_odd1.ogg" }, { "Explosion2", "sfx_exp_odd1.ogg" }, { "Alert", "sfx_alarm_loop6.ogg" }, { "LittleHeart", "sfx_littlepickup.ogg" }, { "Fireloop", "sfx_fireloop.ogg" }, { "Whistle", "sfx_whistle.ogg" }, { "Pizza", "sfx_error13.ogg" }, { "Brakes", "sfx_vehicle_breaks.ogg" }, { "Song", "sfx_stream.ogg" }, { "Piano", "sfx_piano.ogg" }, { "CFF2", "cff_shm.ogg" }, { "CFF3", "cff_acc.ogg" }, { "CFF4", "cff_gtr.ogg" }, { "CFFX", "cff_xlf.ogg" }, { "Lid", "sfx_exp_short_hard15.ogg" }, { "Wind", "sfx_wind.ogg" }, { "MoonStarter", "sfx_moon_starter.ogg" }, { "MoonBeat", "sfx_moon_beat.ogg" }, { "MoonFinisher", "sfx_moon_finisher.ogg" }, { "Banish", "sfx_sounds_ban.ogg" }, { "Guns1", "sfx_guns1.ogg" }, { "Guns2", "sfx_guns2.ogg" }, { "Guns3", "sfx_guns3.ogg" }, { "Carrello", "sfx_exp_cluster5.ogg" }, { "ExploGH", "sfx_weapon_singleshot18.ogg" }, { "ExploGH2", "sfx_impact.ogg" }, { "PAN", "sfx_pan.ogg" }, { "CAT1", "Cat1.ogg" }, { "CAT2", "Cat2.ogg" }, { "CAT3", "Cat3.ogg" }, { "CAT5", "Cat5.ogg" }, { "CATE", "CatE.ogg" }, { "CATI", "sfx_sounds_interaction13.ogg" }, { "FireExplosion", "sfx_exp_short_soft9.ogg" }, { "STEP1", "step01.ogg" }, { "STEP2", "step02.ogg" }, { "STEP3", "step03.ogg" }, { "STEP4", "step04.ogg" }, { "Ringing", "sfx_ringing.ogg" }, { "Shroud", "sfx_exp_medium11.ogg" }, { "Corridor", "sfx_exp_cluster8.ogg" }, { "Bell", "belltoll.ogg" }, { "Haha", "haha.ogg" }, { "Clap", "clap.ogg" }, { "Rose", "sfx_rosexpl.ogg" }, { "Window", "sfx_window.ogg" }, { "Deathscream", "sfx_deathscream.ogg" }, { "Groove", "sfx_groove.ogg" }, { "AutoLB", "sfx_autoLB.ogg" }, { "AutoLV", "sfx_autoLevel.ogg" }, { "Flare", "sfx_exp_short_soft6.ogg" }, { "Noise", "sfx_noise.ogg" }, { "Secret", "sfx_secret.ogg" }, { "Victory1", "sfx_victory1.ogg" }, { "Victory2", "sfx_victory2.ogg" }, { "SoleSAnti", "sfx_soleSAnticipation.ogg" }, { "SoleSFirst", "sfx_soleSFirstImpact.ogg" }, { "SoleSSecond", "sfx_soleSSecondImpact.ogg" }, { "Crystal12", "sfx_crystal_12.ogg" }, { "Key1", "sfx_Key1.ogg" }, { "Key2", "sfx_Key2.ogg" }, { "Key3", "sfx_Key3.ogg" }, { "Key4", "sfx_Key4.ogg" }, { "Key5", "sfx_Key5.ogg" }, { "KeyWrong", "sfx_KeyWrong.ogg" }, { "Magic2", "sfx_projectile_magic2.ogg" }, { "ExploSoft", "sfx_explo_soft.ogg" }, { "ExploNight", "sfx_explo_night.ogg" }, { "Clones", "sfx_clones.ogg" }, { "Bubbles", "sfx_bubble.ogg" }, { "Seasons1", "sfx_4seasons.ogg" }, { "Seasons2", "sfx_4mud.ogg" }, { "Seasons3", "sfx_4tai.ogg" }, { "Seasons4", "sfx_4fud.ogg" }, { "Seasons5", "sfx_4hana.ogg" }, { "Seasons6", "sfx_4max.ogg" }, { "Morph", "sfx_morph.ogg" }, { "Bangu", "sfx_bangu.ogg" }, { "Crystal6", "sfx_crystal6.ogg" }, { "Crystal8", "sfx_crystal8.ogg" }, { "SpellString", "sfx_string.wav" }, { "SpellStrike", "sfx_strike.wav" }, { "SpellStrom", "sfx_strom.ogg" }, { "Bumper", "bumper2.ogg" }, { "Magic3", "sfx_magic_chanting.wav" }, { "Attack1", "sfx_attack1.ogg" }, { "Attack2", "sfx_giant.ogg" }, { "Scream", "sfx_scream.ogg" }, { "Bumper2", "sfx_bumper3.ogg" }, { "Pot", "sfx_potBreak.ogg" }, { "WorldEater", "sfx_WorldEater_8.ogg" }, { "Party", "sfx_party.ogg" }, { "Ophion1", "sfx_ophion1.ogg" }, { "Ophion2", "sfx_ophion2.ogg" }, { "Ophion3", "sfx_ophion3.ogg" }, { "Cheers", "sfx_cheers.wav" }, { "Phase0", "bgm_elrond_boss0.ogg" }, { "Phase1", "bgm_elrond_boss1.ogg" }, { "Phase2", "bgm_elrond_boss2.ogg" }, { "Phase3", "bgm_elrond_boss3.ogg" }, { "Phase4", "bgm_elrond_boss4.ogg" }, { "Phase5", "bgm_elrond_boss5.ogg" }, }; #define N_SOUND_FILES (int)(sizeof(SOUND_FILES) / sizeof(*SOUND_FILES)) #define SOUND_ALIASES 8 // istanze contemporanee dello stesso effetto (WebAudio non ha limite: oltre si riusa la piu' vecchia) static struct { Sound base, alias[SOUND_ALIASES]; int loaded, next, instances, loading; float wantVolume, wantPitch; double wantAt; } SoundLib[N_SOUND_FILES > 0 ? N_SOUND_FILES : 1]; static struct { Music music; int idx, playing, loop; float volume, currentVolume, fadeFrom, fadeTo, fadeT, fadeDur; } BGM = { .idx = -1 }; static float SoundsVolume = 1, MusicVolume = 1, SFXVolumeFactor = 1; // PlayerOptions (default: audio attivo) e Core.SFXVolumeFactor static int Sound_index(const char *key) { for (int i = 0; i < N_SOUND_FILES; i++) if (!strcmp(SOUND_FILES[i].key, key)) return i; return -1; } static void Sound_instancesDown(void *ctx) { SoundLib[(intptr_t)ctx].instances--; } // Ogni flusso musicale si apre e si chiude da qui: il thread della musica non deve averlo in lista mentre cambia (audio.c) static void Music_open(Music *m, const char *path) { au_music_remove(m); *m = LoadMusicStream(path); } static void Music_close(Music *m) { au_music_remove(m); UnloadMusicStream(*m); } static void Sound_setBase(int i, Sound s) { SoundLib[i].base = s, SoundLib[i].loaded = 1, SoundLib[i].loading = 0; for (int a = 0; a < SOUND_ALIASES && s.frameCount; a++) SoundLib[i].alias[a] = LoadSoundAlias(s); } static void Sound_start(int i, float volume, float pitch) { au_sound_play(SoundLib[i].alias[SoundLib[i].next++ % SOUND_ALIASES], volume, pitch); } // Primo uso: i file piccoli si caricano in background e l'effetto parte appena e' pronto, se e' ancora in tempo (70 ms sulla Vita, // e un frame ne ha 16); quelli grandi, come le musiche dei forzieri, si caricano subito: arrivano con la scena in pausa e non devono andare persi. #define SOUND_BACKGROUND_MAX_BYTES (64 * 1024) #define SOUND_LATE_S 0.25 static void Sound_pollLoads(void) { int i; Sound loaded; while (au_load_poll(&i, &loaded)) { Sound_setBase(i, loaded); if (SoundLib[i].wantAt > 0 && loaded.frameCount && GetTime() - SoundLib[i].wantAt < SOUND_LATE_S) Sound_start(i, SoundLib[i].wantVolume, SoundLib[i].wantPitch); SoundLib[i].wantAt = 0; } } // SoundManager.PlaySound(key, config, delay, maxInstances): volume <= 0 = config senza volume static void Sound_PlaySound(const char *key, float volume, float rate, float detune, float delay, int maxInstances) { if (SoundsVolume == 0 || !IsAudioDeviceReady()) return; int i = Sound_index(key); if (i < 0) return; if (delay > 0 && maxInstances > 0) { if (SoundLib[i].instances >= maxInstances) return; time_addEvent(delay, 0, 0, Sound_instancesDown, (void *)(intptr_t)i); SoundLib[i].instances++; } float v = (volume > 0 ? volume * 0.5f : 0.1f) * SoundsVolume * SFXVolumeFactor; float pitch = (rate > 0 ? rate : 1) * powf(2, detune / 1200); // WebAudio: playbackRate * 2^(detune/1200) if (!SoundLib[i].loaded) { char rel[128]; snprintf(rel, sizeof(rel), "sfx/%s", SOUND_FILES[i].file); const char *path = vs_path(rel); if (!SoundLib[i].loading && GetFileLength(path) <= SOUND_BACKGROUND_MAX_BYTES && au_load_request(i, path)) SoundLib[i].loading = 1; if (SoundLib[i].loading) { SoundLib[i].wantVolume = v, SoundLib[i].wantPitch = pitch, SoundLib[i].wantAt = GetTime(); return; } Sound_setBase(i, LoadSound(path)); } if (!SoundLib[i].base.frameCount) return; Sound_start(i, v, pitch); } static void Sound_PlaySimple(const char *key, float volume) { Sound_PlaySound(key, volume, 1, 0, 0, 0); } // La PreloadScene carica tutto all'avvio; qui solo gli effetti frequenti, gli altri al primo uso (memoria della Vita) static void Sound_Preload(void) { static const char *keys[] = { "Hit", "Gem", "Whip", "Shot", "MagicMissile", "Holywater", "Coin", "LevelUp", "ClickIn", "LossSFX" }; if (!IsAudioDeviceReady()) return; float v = SoundsVolume; SoundsVolume = 0; // carica senza suonare for (size_t k = 0; k < sizeof(keys) / sizeof(*keys); k++) { int i = Sound_index(keys[k]); if (i < 0 || SoundLib[i].loaded || SoundLib[i].loading) continue; char rel[128]; snprintf(rel, sizeof(rel), "sfx/%s", SOUND_FILES[i].file); Sound_setBase(i, LoadSound(vs_path(rel))); } SoundsVolume = v; } // PlaySound(key, { volume, seek }): il Sound di raylib non ha seek, quindi l'effetto riparte come stream static struct { Music m; int on, idx; } SeekSfx; static void Sound_PlaySeek(const char *key, float volume, float seek) { if (SoundsVolume == 0 || !IsAudioDeviceReady()) return; int i = Sound_index(key); if (i < 0) return; if (SeekSfx.on) Music_close(&SeekSfx.m), SeekSfx.on = 0; char rel[128]; snprintf(rel, sizeof(rel), "sfx/%s", SOUND_FILES[i].file); Music_open(&SeekSfx.m, vs_path(rel)); if (!SeekSfx.m.frameCount) return; SeekSfx.m.looping = 0; au_music_volume(&SeekSfx.m, (volume > 0 ? volume * 0.5f : 0.1f) * SoundsVolume * SFXVolumeFactor); PlayMusicStream(SeekSfx.m); au_music_seek(&SeekSfx.m, seek); au_music_add(&SeekSfx.m); SeekSfx.on = 1, SeekSfx.idx = i; } // PlaySound(key, { loop: true }): un flusso a parte (il vento di Gallo Tower), fermato da StopSound o dalla partita nuova static struct { Music m; int on, idx; } LoopSfx; static void Sound_PlayLoop(const char *key, float volume) { if (SoundsVolume == 0 || !IsAudioDeviceReady()) return; int i = Sound_index(key); if (i < 0) return; if (LoopSfx.on) Music_close(&LoopSfx.m), LoopSfx.on = 0; char rel[128]; snprintf(rel, sizeof(rel), "sfx/%s", SOUND_FILES[i].file); Music_open(&LoopSfx.m, vs_path(rel)); if (!LoopSfx.m.frameCount) return; LoopSfx.m.looping = 1; au_music_volume(&LoopSfx.m, fminf(1, volume * 0.5f * SoundsVolume * SFXVolumeFactor)); PlayMusicStream(LoopSfx.m); au_music_add(&LoopSfx.m); LoopSfx.on = 1, LoopSfx.idx = i; } static void Sound_LoopVolume(float v) { if (LoopSfx.on) au_music_volume(&LoopSfx.m, v); } // sound.volume = v (Sketamari) static void Sound_StopSound(const char *key) { // stopByKey int i = Sound_index(key); if (i >= 0) SoundLib[i].wantAt = 0; // un effetto ancora in caricamento non parte piu' if (i >= 0 && LoopSfx.on && LoopSfx.idx == i) Music_close(&LoopSfx.m), LoopSfx.on = 0; if (i < 0 || !SoundLib[i].loaded) return; for (int a = 0; a < SOUND_ALIASES; a++) au_sound_stop(SoundLib[i].alias[a]); if (SeekSfx.on && SeekSfx.idx == i) Music_close(&SeekSfx.m), SeekSfx.on = 0; } // PlayMusic(key, { volume, loop }): musica in streaming; rate/detune delle mod di stage: Foresta senza static void Sound_PlayMusic(const char *key, float volume, int loop) { if (!IsAudioDeviceReady()) return; int i = Sound_index(key); if (i < 0) return; if (BGM.idx != i) { if (BGM.idx >= 0) Music_close(&BGM.music); char rel[128]; snprintf(rel, sizeof(rel), "sfx/%s", SOUND_FILES[i].file); Music_open(&BGM.music, vs_path(rel)); BGM.idx = i; } if (!BGM.music.frameCount) return; BGM.music.looping = loop; SetMusicPitch(BGM.music, 1); // Moongolow la rallenta BGM.currentVolume = volume; BGM.volume = volume * MusicVolume; BGM.fadeDur = 0; au_music_volume(&BGM.music, BGM.volume); PlayMusicStream(BGM.music); au_music_add(&BGM.music); BGM.playing = 1; } static void Sound_StopMusic(void) { if (BGM.playing) { au_music_stop(&BGM.music); BGM.playing = 0; } } static const char *po_str(const char *k); static void Sound_PlayMusic(const char *key, float volume, int loop); // Sound.SetupAndPlayBGM_Banger: la musica scelta (SelectedBGM) con le mod Hyper/Forsaken di music.json static void Sound_SetupAndPlayBGM_Banger(int loop) { Sound_StopMusic(); const char *key = po_str("SelectedBGM"), *mod = po_str("SelectedBGMMod"); cJSON *m = cJSON_GetObjectItem(data_get("music"), key), *md = NULL; if (m && mod && !strcmp(mod, "Hyper")) md = cJSON_GetObjectItem(m, "hyperMod"); else if (m && mod && !strcmp(mod, "Forsaken")) md = cJSON_GetObjectItem(m, "forsakenMod"); Sound_PlayMusic(key, 0.3f, loop); if (md && BGM.music.frameCount) SetMusicPitch(BGM.music, num(md, "rate", 1) * powf(2, num(md, "detune", 0) / 1200)); // WebAudio: rate * 2^(detune/1200) } // FadeMusic(key, volume, ms): tween lineare del volume (0 ms = subito) static void Sound_FadeMusic(float volume, float ms) { if (!BGM.playing) return; float target = volume * MusicVolume; if (MusicVolume == 0) target = 0, ms = 0; if (ms > 0) { BGM.fadeFrom = BGM.volume, BGM.fadeTo = target, BGM.fadeT = 0, BGM.fadeDur = ms; } else { BGM.volume = target; BGM.fadeDur = 0; au_music_volume(&BGM.music, BGM.volume); } } static void (*Sound_tickHook)(float delta); // DirecterManager: timer e musiche delle fasi a tempo reale static void Sound_Update(float delta) { // la musica va avanti anche con la scena in pausa (level-up, forziere) Sound_pollLoads(); if (Sound_tickHook) Sound_tickHook(delta); if (SeekSfx.on) { au_music_update(&SeekSfx.m); if (!IsMusicStreamPlaying(SeekSfx.m)) Music_close(&SeekSfx.m), SeekSfx.on = 0; } if (LoopSfx.on) au_music_update(&LoopSfx.m); if (!BGM.playing) return; if (BGM.fadeDur > 0) { BGM.fadeT += delta; float k = BGM.fadeT >= BGM.fadeDur ? 1 : BGM.fadeT / BGM.fadeDur; BGM.volume = BGM.fadeFrom + (BGM.fadeTo - BGM.fadeFrom) * k; au_music_volume(&BGM.music, BGM.volume); if (k >= 1) BGM.fadeDur = 0; } au_music_update(&BGM.music); } // ============================================================================ // 0x17895: PlayerOptions. Il salvataggio e' questo oggetto in JSON: qui resta un oggetto cJSON con le chiavi, // l'ordine e i default del costruttore, cosi' ApplyLoadedSave copia solo le chiavi che esistono (hasOwnProperty). // I metodi async (_set/_get, AsyncSave, Save*/Load*) scrivono nello Storage del web: su Steam conta solo SaveSystem. // RunCoins/RunEnemies/RunPickups della partita restano in Core: nel file restano ai default // ============================================================================ cJSON *PlayerOptions; #define LATER __attribute__((unused)) // metodi tradotti che servono a F3.1-F3.5 (negozio, opzioni, recupero) #define VSBUILDVER 15101 // VSVERSION 1.5.101 senza i punti static const char PlayerOptions_ctor[] = "{\"playerID\":\"\",\"playerNickname\":\"\",\"saveDate\":\"\",\"itemInCollection\":0,\"itemInUnlocks\":0,\"itemInSecrets\":0," "\"SelectedCharacter\":\"ANTONIO\",\"SelectedStage\":\"FOREST\",\"SelectedHyper\":false,\"SelectedHurry\":false,\"SelectedMazzo\":true," "\"SelectedLimitBreak\":false,\"SelectedInverse\":false,\"SelectedReapers\":false,\"SelectedGoldenEggs\":true,\"SelectedArcana\":0," "\"SelectedRandomEvents\":false,\"SelectedBGMSave\":false,\"SelectedBGM\":\"BGM_Forest\",\"SelectedBGMMod\":\"Normal\",\"SelectedMaxWeapons\":6," "\"Fullscreen\":false,\"FullScreenView\":false,\"SideHUD\":false,\"TouchMove\":false,\"QualityMode\":false,\"View3D\":false,\"ViewZoom\":1," // opzioni del port: senza la chiave qui il caricamento le scarta "\"Version\":0,\"Coins\":0,\"RunCoins\":0,\"RunEnemies\":0,\"RunPickups\":[],\"RunPickups_Coins\":0,\"LifetimeCoins\":0," "\"TotalCoins\":0,\"BeginnersLuck\":0,\"RunFever\":0,\"RunHunger\":0,\"LifetimeSurvived\":0,\"LifetimeHeal\":0,\"OwO\":0,\"CompletedHurries\":0," "\"ReducePhysics\":true,\"ClassicMusic\":true,\"VisuallyInvertStages\":true,\"HideProgress\":false,\"SoundsEnabled\":true,\"MusicEnabled\":true," "\"SoundsVolume\":0,\"MusicVolume\":0,\"FlashingVFXEnabled\":true,\"ScreenShakeEnabled\":true,\"JoystickVisible\":false," "\"DamageNumbersEnabled\":true,\"StreamSafeEnabled\":true,\"hideXPBar\":false,\"CheatCodeUsed\":false,\"HasKilledTheFinalBoss\":false," "\"HasSeenFinalFireworks\":false,\"Language\":\"\",\"ShowQuitDescription\":true,\"HideCompletedAchievements\":false,\"PlayedRNJ\":0," "\"ShowPickups\":false,\"ShowSmallMapIcons\":true,\"TwitchUsername\":\"\",\"LongestFever\":0,\"HighestFever\":0,\"HasUsedMirror\":false," "\"HasUsedTrumpet\":false,\"BoughtCharacters\":[],\"BoughtPowerups\":[],\"DisabledPowerups\":[],\"CollectedWeapons\":[],\"UnlockedWeapons\":[]," "\"UnlockedCharacters\":[],\"CollectedItems\":[],\"Achievements\":[],\"Secrets\":[],\"UnlockedStages\":[],\"UnlockedHypers\":[]," "\"UnlockedPowerUpRanks\":[],\"UnlockedArcanas\":[],\"UnlockedSkins\":{},\"SelectedSkins\":{},\"KillCount\":{},\"PickupCount\":{}," "\"DestroyedCount\":{},\"StageCompletionLog\":{},\"CharacterStageData\":{},\"CharacterEnemiesKilled\":{},\"CharacterSurvivedMinutes\":{}," "\"MusicSelectionPerStage\":{},\"checksum\":\"\",\"EggData\":{},\"Didit\":false,\"Seals\":10,\"SealedItems\":[],\"SealedWeapons\":[]," "\"MainMenuBG\":\"CLASSIC\",\"SelectedJoystickType\":\"Default\",\"HideAdsButtons\":false}"; static cJSON *po(const char *k) { return cJSON_GetObjectItemCaseSensitive(PlayerOptions, k); } static double po_num(const char *k) { cJSON *n = po(k); return cJSON_IsNumber(n) ? n->valuedouble : cJSON_IsTrue(n); } static int po_is(const char *k) { return po_num(k) != 0; } // un booleano o un numero (SelectedRandomEvents di AsyncLoad e' 0) int vs_quality_mode(void) { return getenv("VS_QUALITY") ? atoi(getenv("VS_QUALITY")) : PlayerOptions && po_is("QualityMode"); } // sviluppo: VS_QUALITY=1 profilo Grafica, 0 Prestazioni static const char *po_str(const char *k) { return cJSON_GetStringValue(po(k)); } static void po_put(const char *k, cJSON *v) { // le chiavi del port (TouchMove, zoom...) non sono nei default: Replace da solo le perdeva if (po(k)) cJSON_ReplaceItemInObjectCaseSensitive(PlayerOptions, k, v); else cJSON_AddItemToObject(PlayerOptions, k, v); } static void po_set(const char *k, double v) { cJSON *n = po(k); if (cJSON_IsNumber(n)) cJSON_SetNumberValue(n, v); else po_put(k, cJSON_CreateNumber(v)); } static void po_add(const char *k, double v) { po_set(k, po_num(k) + v); } LATER static void po_setb(const char *k, int b) { po_put(k, cJSON_CreateBool(b)); } static void po_sets(const char *k, const char *s) { po_put(k, cJSON_CreateString(s)); } static const char *key_of(cJSON *v, char buf[16]) { // o[v] di JS: le arcane sono numeri, le chiavi stringhe if (cJSON_IsString(v)) return v->valuestring; snprintf(buf, 16, "%d", (int)v->valuedouble); return buf; } static int arr_indexOf(cJSON *a, const char *s) { // Array.indexOf con stringhe (o numeri come stringa) int i = 0; char b[16]; cJSON *v; cJSON_ArrayForEach(v, a) { if ((cJSON_IsString(v) || cJSON_IsNumber(v)) && !strcmp(key_of(v, b), s)) return i; i++; } return -1; } static int po_has(const char *k, const char *s) { return arr_indexOf(po(k), s) > -1; } static void po_push(const char *k, const char *s) { cJSON_AddItemToArray(po(k), cJSON_CreateString(s)); } static cJSON *tbl0(const char *table, const char *id) { // X.default[id][0x0] cJSON *e = cJSON_GetObjectItemCaseSensitive(data_get(table), id); return cJSON_IsArray(e) ? cJSON_GetArrayItem(e, 0) : e; } static void obj_set(cJSON *o, const char *k, cJSON *v) { // o[k] = v if (!o) { cJSON_Delete(v); return; } if (cJSON_GetObjectItemCaseSensitive(o, k)) cJSON_ReplaceItemInObjectCaseSensitive(o, k, v); else cJSON_AddItemToObject(o, k, v); } static void obj_copy(cJSON *o, const char *k, cJSON *v) { // o[k] = v (copia); v undefined: la chiave sparisce, come in JSON.stringify if (v) obj_set(o, k, cJSON_Duplicate(v, 1)); else cJSON_DeleteItemFromObjectCaseSensitive(o, k); } static int cmp_key(const void *a, const void *b) { char x[16], y[16]; return strcmp(key_of(*(cJSON *const *)a, x), key_of(*(cJSON *const *)b, y)); } static void arr_sort_uniq(const char *k) { // this.X = this.X.sort().filter((v, i, a) => !i || v != a[i - 1]); sort() confronta come stringhe cJSON *a = po(k), *v, *items[512]; int n = 0; while (n < 512 && (v = cJSON_DetachItemFromArray(a, 0))) items[n++] = v; qsort(items, n, sizeof(*items), cmp_key); for (int i = 0; i < n; i++) { if (i && !cmp_key(&items[i], &items[i - 1])) cJSON_Delete(items[i]); else cJSON_AddItemToArray(a, items[i]); } } static void AchievementManager_RestoreAchievementUnlocks(void); static int DLC_Has(const char *d) { // 0x1679c: data/dlc.json scritto dal tool (DLC.Register). Senza DLC le sue voci mancano dai dati cJSON *v; cJSON_ArrayForEach(v, data_get("dlc")) if (!strcmp(v->valuestring, d)) return 1; return 0; } // Personaggi CUSTOM (beta della versione Unity, giugno 2026; formato di Customello): /CustomCharacters// // character.json (array per livelli, gli stessi campi dei personaggi 1.5), localization.json, sprites/*.png, skins//*.png. // Diventano CUSTOM_ nella tabella characters sopra la base di Antonio. Ignorati (non esistono nella 1.5): // characterController, carte abilita', seguaci, bloodColor, ignoreWalls e gli altri comportamenti nuovi. #include #include static void Custom_loadPngs(const char *folder, const char *sub, const char *prefix_in) { // ogni PNG di / come "" char dir[256], prefix[128]; snprintf(prefix, sizeof(prefix), "%s", prefix_in); // TextFormat ha pochi buffer a giro: il prefisso del chiamante va copiato snprintf(dir, sizeof(dir), "%s", vs_path(TextFormat("CustomCharacters/%s/%s", folder, sub))); DIR *d = opendir(dir); struct dirent *de; while (d && (de = readdir(d))) if (strlen(de->d_name) > 4 && !strcasecmp(de->d_name + strlen(de->d_name) - 4, ".png")) atlas_add_image("custom", TextFormat("%s%s", prefix, de->d_name), TextFormat("%s/%s", dir, de->d_name)); if (d) closedir(d); } static void CustomCharacters_load(void) { static int done; cJSON *chars = data_get("characters"), *base = tbl0("characters", "ANTONIO"); if (done || !chars || !base) return; done = 1; DIR *dir = opendir(vs_path("CustomCharacters")); struct dirent *de; while (dir && (de = readdir(dir))) { if (de->d_name[0] == '.' || strlen(de->d_name) > 40) continue; char folder[48], id[56] = "CUSTOM_"; snprintf(folder, sizeof(folder), "%s", de->d_name); for (int i = 0, n = 7; folder[i] && n < 55; i++) id[n++] = isalnum((unsigned char)folder[i]) ? (char)toupper((unsigned char)folder[i]) : '_', id[n] = 0; cJSON *arr = read_json(TextFormat("CustomCharacters/%s/character.json", folder)), *c0 = cJSON_GetArrayItem(arr, 0), *f; if (!cJSON_IsArray(arr) || !cJSON_IsObject(c0) || cJSON_GetObjectItem(chars, id)) { cJSON_Delete(arr); continue; } cJSON *e = cJSON_Duplicate(base, 1); // i campi che il gioco si aspetta, poi quelli del file cJSON_ArrayForEach(f, c0) obj_set(e, f->string, cJSON_Duplicate(f, 1)); Custom_loadPngs(folder, "sprites", TextFormat("%s/", folder)); obj_set(e, "textureName", cJSON_CreateString("custom")); obj_set(e, "spriteName", cJSON_CreateString(TextFormat("%s/%s", folder, str(c0, "spriteName") ? str(c0, "spriteName") : ""))); cJSON *skins = cJSON_CreateArray(), *sk; int si = 0; cJSON_ArrayForEach(sk, cJSON_GetObjectItem(c0, "skins")) { // spriteFolder: skins// come "//" cJSON *s = cJSON_Duplicate(sk, 1); const char *sf = str(sk, "spriteFolder"); if (sf) Custom_loadPngs(folder, TextFormat("skins/%s", sf), TextFormat("%s/%s/", folder, sf)), Custom_loadPngs(folder, TextFormat("skins/%s/sprites", sf), TextFormat("%s/%s/", folder, sf)); // Customello: skins/red/sprites/ obj_set(s, "id", cJSON_CreateNumber(si++)); obj_set(s, "textureName", cJSON_CreateString("custom")); obj_set(s, "spriteName", cJSON_CreateString(sf ? TextFormat("%s/%s/%s", folder, sf, str(sk, "spriteName")) : TextFormat("%s/%s", folder, str(sk, "spriteName")))); cJSON_AddItemToArray(skins, s); } if (!si) cJSON_AddItemToArray(skins, cJSON_Parse(TextFormat("{\"id\":0,\"name\":\"Default\",\"textureName\":\"custom\",\"spriteName\":\"%s\",\"walkingFrames\":%d,\"unlocked\":true}", str(e, "spriteName"), (int)num(e, "walkingFrames", 1)))); obj_set(e, "skins", skins), obj_set(e, "currentSkinIndex", cJSON_CreateNumber(0)); const char *w = str(e, "startingWeapon"); // armi della versione nuova (BATTILIA...) che la 1.5 non ha: la Frusta if (!w || !tbl0("weapons", w)) obj_set(e, "startingWeapon", cJSON_CreateString("WHIP")); obj_set(e, "hidden", cJSON_CreateFalse()); cJSON *a = cJSON_CreateArray(); // [base, bonus per livello...] cJSON_AddItemToArray(a, e); for (int i = 1; i < cJSON_GetArraySize(arr); i++) cJSON_AddItemToArray(a, cJSON_Duplicate(cJSON_GetArrayItem(arr, i), 1)); cJSON_AddItemToObject(chars, id, a); cJSON *loc = read_json(TextFormat("CustomCharacters/%s/localization.json", folder)), *lg, *cl = lang_table("characterLang"); cJSON_ArrayForEach(lg, loc) { // "it" / "IT" / "pt-br": i codici del gioco (langKeys.json) const char *code = NULL; for (int i = 0; Lang_codeAt(i); i++) if (!strcasecmp(Lang_codeAt(i), lg->string)) code = Lang_codeAt(i); cJSON *tr = code ? cJSON_GetObjectItem(cJSON_GetObjectItem(cl, code), "translations") : NULL; if (tr && !cJSON_GetObjectItem(tr, id)) cJSON_AddItemToObject(tr, id, cJSON_Duplicate(lg, 1)); } cJSON_Delete(loc), cJSON_Delete(arr); TraceLog(LOG_INFO, "CUSTOM: %s (%s), arma %s, sprite %s %s", id, str(e, "charName"), str(e, "startingWeapon"), str(e, "spriteName"), frame_get("custom", str(e, "spriteName")) ? "ok" : "MANCANTE"); } if (dir) closedir(dir); } // Reliquie del port (non sono nell'originale): gli occhiali buffi sbloccano per sempre la Vista 3D, un vinile per stage sblocca // i suoi brani (BGM e sideBBGM) nel Jukebox. Sono voci di items come le altre reliquie: raccolta, CollectedItems e scena "trovata". static float Glasses_fx; // 1 -> 0 dopo aver preso gli occhiali: la realta' si piega (fisheye) mentre arriva la Vista 3D static float Glasses_left; // secondi di Vista 3D regalati dagli occhiali (poi resta l'opzione del menu) static void PortRelic_add(const char *key_in, const char *frame_in, const char *stage) { char key[64], frame[32]; // arrivano da TextFormat, che qui sotto si richiama piu' volte snprintf(key, sizeof(key), "%s", key_in), snprintf(frame, sizeof(frame), "%s", frame_in); cJSON *items = data_get("items"), *e = cJSON_Duplicate(cJSON_GetObjectItem(items, "RELIC_GRIMOIRE"), 1); cJSON *e0 = cJSON_IsArray(e) ? cJSON_GetArrayItem(e, 0) : e, *il = lang_table("itemLang"), *sl = lang_table("stageLang"); const char *kn = stage ? "relic_vinyl_name" : "relic_glasses_name", *kd = stage ? "relic_vinyl_desc" : "relic_glasses_desc"; const char *sn_en = stage ? str(tbl0("stages", stage), "stageName") : NULL; obj_set(e0, "texture", cJSON_CreateString("port")), obj_set(e0, "frameName", cJSON_CreateString(frame)); obj_set(e0, "name", cJSON_CreateString(TextFormat(port_tr_col(kn, 1), sn_en ? sn_en : stage ? stage : ""))); obj_set(e0, "description", cJSON_CreateString(TextFormat(port_tr_col(kd, 1), sn_en ? sn_en : stage ? stage : ""))); obj_set(e0, "achievementTips", cJSON_CreateString("")), obj_set(e0, "tips", cJSON_CreateString("")); cJSON_AddItemToObject(items, key, e); for (int col = 1; col <= 12; col++) { // itemLang: nome e descrizione in ogni lingua, col nome dello stage di quella lingua cJSON *tr = cJSON_GetObjectItem(cJSON_GetObjectItem(il, PORT_LANGS[col - 1]), "translations"); if (!tr || cJSON_GetObjectItem(tr, key)) continue; const char *sn = stage ? cJSON_GetStringValue(cJSON_GetObjectItem(cJSON_GetObjectItem(cJSON_GetObjectItem(cJSON_GetObjectItem(sl, PORT_LANGS[col - 1]), "translations"), stage), "stageName")) : NULL; if (!sn) sn = sn_en ? sn_en : stage ? stage : ""; cJSON *o = cJSON_CreateObject(); cJSON_AddStringToObject(o, "name", TextFormat(port_tr_col(kn, col), sn)); cJSON_AddStringToObject(o, "description", TextFormat(port_tr_col(kd, col), sn)); cJSON_AddItemToObject(tr, key, o); } } static void PortRelics_init(void) { static int done; if (done || !cJSON_GetObjectItem(data_get("items"), "RELIC_GRIMOIRE")) return; done = 1; atlas_add_image("port", "glasses3d.png", vs_asset("relics/glasses3d.png")); for (int i = 0; i < 8; i++) atlas_add_image("port", TextFormat("vinyl%d.png", i), vs_asset(TextFormat("relics/vinyl%d.png", i))); PortRelic_add("RELIC_3DGLASSES", "glasses3d.png", NULL); cJSON *s; int i = 0; cJSON_ArrayForEach(s, data_get("stages")) PortRelic_add(TextFormat("RELIC_VINYL_%s", s->string), TextFormat("vinyl%d.png", i++ % 8), s->string); } static void PlayerOptions_apply(void) { cJSON *t, *v; char b[16]; CustomCharacters_load(); // prima dei personaggi comprati: un CUSTOM comprato resta comprato PortRelics_init(); // prima di CollectedItems: un vinile gia' trovato risulta visto cJSON_ArrayForEach(t, data_get("powerups")) obj_set(cJSON_GetArrayItem(t, 0), "level", cJSON_CreateNumber(0)); cJSON_ArrayForEach(v, po("BoughtPowerups")) if ((t = tbl0("powerups", key_of(v, b)))) obj_set(t, "level", cJSON_CreateNumber(num(t, "level", 0) + 1)); cJSON_ArrayForEach(v, po("DisabledPowerups")) if ((t = tbl0("powerups", key_of(v, b)))) obj_set(t, "active", cJSON_CreateFalse()); cJSON_ArrayForEach(v, po("BoughtCharacters")) if ((t = tbl0("characters", key_of(v, b)))) obj_set(t, "isBought", cJSON_CreateTrue()), obj_set(t, "hidden", cJSON_CreateFalse()); if (!po_has("BoughtCharacters", "ANTONIO")) po_push("BoughtCharacters", "ANTONIO"); cJSON_ArrayForEach(v, po("CollectedWeapons")) if ((t = tbl0("weapons", key_of(v, b)))) obj_set(t, "seen", cJSON_CreateTrue()), obj_set(t, "hidden", cJSON_CreateFalse()); cJSON_ArrayForEach(v, po("CollectedItems")) if ((t = tbl0("items", key_of(v, b)))) obj_set(t, "seen", cJSON_CreateTrue()); cJSON_ArrayForEach(v, po("UnlockedWeapons")) if ((t = tbl0("weapons", key_of(v, b)))) obj_set(t, "isUnlocked", cJSON_CreateTrue()), obj_set(t, "hidden", cJSON_CreateFalse()); cJSON_ArrayForEach(v, po("UnlockedCharacters")) if ((t = tbl0("characters", key_of(v, b)))) obj_set(t, "hidden", cJSON_CreateFalse()); cJSON_ArrayForEach(v, po("UnlockedStages")) if ((t = tbl0("stages", key_of(v, b)))) obj_set(t, "unlocked", cJSON_CreateTrue()), obj_set(t, "hidden", cJSON_CreateFalse()); if (!po_has("UnlockedStages", "FOREST")) po_push("UnlockedStages", "FOREST"); if (DLC_Has("Moonspell") && !po_has("UnlockedStages", "MOONSPELL")) po_push("UnlockedStages", "MOONSPELL"); // loadComplete 0x1559b if (DLC_Has("Foscari") && !po_has("UnlockedStages", "FOSCARI")) po_push("UnlockedStages", "FOSCARI"); arr_sort_uniq("UnlockedStages"); cJSON_ArrayForEach(v, po("UnlockedHypers")) if ((t = tbl0("stages", key_of(v, b)))) obj_set(cJSON_GetObjectItem(t, "hyper"), "unlocked", cJSON_CreateTrue()); arr_sort_uniq("UnlockedHypers"); arr_sort_uniq("UnlockedArcanas"); cJSON_ArrayForEach(v, po("UnlockedArcanas")) if ((t = tbl0("arcana", key_of(v, b)))) obj_set(t, "unlocked", cJSON_CreateTrue()); if (po_has("CollectedItems", "RELIC_RANDOMAZZO") && !po_has("UnlockedArcanas", "6")) { // T06_SARABANDE cJSON_AddItemToArray(po("UnlockedArcanas"), cJSON_CreateNumber(6)); obj_set(tbl0("arcana", "6"), "unlocked", cJSON_CreateTrue()); } cJSON_ArrayForEach(v, po("Achievements")) if ((t = tbl0("achievements", key_of(v, b)))) obj_set(t, "achieved", cJSON_CreateTrue()); cJSON_ArrayForEach(v, po("Secrets")) if ((t = tbl0("secrets", key_of(v, b)))) obj_set(t, "achieved", cJSON_CreateTrue()); cJSON_ArrayForEach(v, po("UnlockedPowerUpRanks")) if ((t = tbl0("powerups", key_of(v, b)))) obj_set(t, "hidden", cJSON_CreateTrue()), obj_set(t, "unlockedRank", cJSON_CreateNumber(0)); cJSON_ArrayForEach(v, po("UnlockedPowerUpRanks")) if ((t = tbl0("powerups", key_of(v, b)))) obj_set(t, "hidden", cJSON_CreateFalse()), obj_set(t, "unlockedRank", cJSON_CreateNumber(num(t, "unlockedRank", 0) + 1)); cJSON_ArrayForEach(v, po("KillCount")) if ((t = tbl0("enemies", v->string))) obj_set(t, "killedAmount", cJSON_Duplicate(v, 1)); cJSON_ArrayForEach(v, po("UnlockedSkins")) { cJSON *s, *skins = cJSON_GetObjectItem(tbl0("characters", v->string), "skins"); cJSON_ArrayForEach(s, skins) if (arr_indexOf(v, key_of(cJSON_GetObjectItem(s, "id"), b)) > -1) obj_set(s, "unlocked", cJSON_CreateTrue()); } cJSON_ArrayForEach(v, po("SelectedSkins")) if ((t = tbl0("characters", v->string)) && cJSON_GetObjectItem(t, "skins")) obj_set(t, "currentSkinIndex", cJSON_Duplicate(v, 1)); // Le chiavi degli enum EnemyType/ItemType/DestructibleType sono quelle delle tabelle cJSON_ArrayForEach(t, data_get("enemies")) if (!cJSON_GetObjectItem(po("KillCount"), t->string)) cJSON_AddNumberToObject(po("KillCount"), t->string, 0); cJSON_ArrayForEach(v, po("PickupCount")) if ((t = tbl0("items", v->string))) obj_set(t, "pickedupAmount", cJSON_Duplicate(v, 1)); cJSON_ArrayForEach(t, data_get("items")) if (!cJSON_GetObjectItem(po("PickupCount"), t->string)) cJSON_AddNumberToObject(po("PickupCount"), t->string, 0); cJSON_ArrayForEach(v, po("DestroyedCount")) if ((t = tbl0("props", v->string))) obj_set(t, "destroyedAmount", cJSON_Duplicate(v, 1)); cJSON_ArrayForEach(t, data_get("props")) if (!cJSON_GetObjectItem(po("DestroyedCount"), t->string)) cJSON_AddNumberToObject(po("DestroyedCount"), t->string, 0); cJSON_ArrayForEach(v, po("StageCompletionLog")) { if (!(t = tbl0("characters", v->string))) continue; const char *K[4] = { "StageCompletionLog", "CharacterSurvivedMinutes", "CharacterEnemiesKilled", "CharacterStageData" }; const char *F[4] = { "completedStages", "survivedMinutes", "enemiesKilled", "stageData" }; for (int i = 0; i < 4; i++) obj_copy(t, F[i], cJSON_GetObjectItem(po(K[i]), v->string)); } AchievementManager_RestoreAchievementUnlocks(); } static void PlayerOptions_Load_options(void); static void SaveSystem_UpdateChecksum(void) { po_sets("checksum", ""); po_set("Version", VSBUILDVER); char *s = cJSON_PrintUnformatted(PlayerOptions), h[65]; sha256_hex(s, h); cJSON_free(s); po_sets("checksum", h); } static int SaveSystem_IsChecksumValid(const char *txt) { const char *m = strstr(txt, "\"checksum\":\""), *e = m ? m + 12 : NULL; // /\"checksum\":\"[a-z0-9]*\"/ while (e && ((*e >= 'a' && *e <= 'z') || (*e >= '0' && *e <= '9'))) e++; if (!e || *e != '"') return TraceLog(LOG_WARNING, "VS: SaveData is corrupt"), 0; // window.alert size_t pre = m + 12 - txt; char *blank = malloc(strlen(txt) + 1), h[65]; memcpy(blank, txt, pre), strcpy(blank + pre, e); sha256_hex(blank, h); free(blank); int ok = (size_t)(e - (m + 12)) == 64 && !strncmp(m + 12, h, 64); if (!ok) TraceLog(LOG_WARNING, "VS: SaveData is corrupt"); return ok; } static void SaveSystem_ApplyLoadedSave(const char *txt) { cJSON *j = cJSON_Parse(txt), *v; cJSON_ArrayForEach(v, j) if (po(v->string)) po_put(v->string, cJSON_Duplicate(v, 1)); cJSON_Delete(j); // Vita: un salvataggio della versione attuale puo' avere selezionato cio' che qui non esiste (DLC, stage nuovi) if (!tbl0("characters", cJSON_GetStringValue(po("SelectedCharacter")))) po_sets("SelectedCharacter", "ANTONIO"); if (!cJSON_GetObjectItem(data_get("stages"), cJSON_GetStringValue(po("SelectedStage")))) po_sets("SelectedStage", "FOREST"); PlayerOptions_apply(); } enum { SAVE_DEFAULT, SAVE_BACKUP, SAVE_STASH }; static const char *SaveSystem_GetSaveName(int t) { return t == SAVE_BACKUP ? "LastRunBackup" : t == SAVE_STASH ? "SaveDataStash" : "SaveData"; } static void SaveSystem_write(int type) { if (net_on && net_role == 1) return; // chi si e' unito gioca col salvataggio dell'ospite: il proprio resta intatto SaveSystem_UpdateChecksum(); char *s = cJSON_PrintUnformatted(PlayerOptions); if (!vs_write_text(SaveSystem_GetSaveName(type), s)) TraceLog(LOG_WARNING, "VS: salvataggio non riuscito"); cJSON_free(s); } void PlayerOptions_Save(void) { SaveSystem_write(SAVE_DEFAULT); } // PlayerOptions.Save -> SaveSystem.Save static void PlayerOptions_SaveRunBackup(void) { SaveSystem_write(SAVE_BACKUP); } // SaveSystem.SaveBackup LATER static void SaveSystem_SaveStash(const char *s) { vs_write_text(SaveSystem_GetSaveName(SAVE_STASH), s); } LATER static char *SaveSystem_LoadStash(void) { return vs_read_text(SaveSystem_GetSaveName(SAVE_STASH)); } static int SaveSystem_HasBackup(void) { return FileExists(vs_path(SaveSystem_GetSaveName(SAVE_BACKUP))); } static int SaveSystem_LoadType(int type) { // Load / LoadBackup: restituisce se il file c'era (anche se corrotto) char *s = vs_read_text(SaveSystem_GetSaveName(type)); if (s && SaveSystem_IsChecksumValid(s)) SaveSystem_ApplyLoadedSave(s); vs_free(s); return s != NULL; } void Trophies_sync(void) { // achievement gia' ottenuti, anche da un salvataggio importato cJSON *a; cJSON_ArrayForEach(a, data_get("achievements")) if (cJSON_IsTrue(cJSON_GetObjectItem(a, "achieved"))) trophies_unlock(a->string); } static void SaveSystem_RestoreBackup(void) { // LoadBackup, Save, window.location.reload SaveSystem_LoadType(SAVE_BACKUP); PlayerOptions_Save(); vs_reload(); } // PlayerOptions.AsyncLoad senza niente nello Storage (Steam senza SaveData): i default di _get, poi apply static void PlayerOptions_AsyncLoad(void) { po_set("SoundsVolume", 0.5), po_set("MusicVolume", 0.5); // SoundsEnabled/MusicEnabled ? 0.5 : 0 po_sets("SelectedBGMMod", "BGM_Forest"); // (sic) JSON.stringify(BGM_Forest) po_set("SelectedRandomEvents", 0); po_set("Coins", ceil(po_num("Coins"))); PlayerOptions_apply(); } static void PlayerOptions_Load_options(void) { // dove il SoundManager legge i volumi SoundsVolume = (float)po_num("SoundsVolume"), MusicVolume = (float)po_num("MusicVolume"); } // PreloadScene.afterCloudInit / afterSaveLoaded static void AchievementManager_CheckForStartupAchievements(void); void SaveSystem_Load(void) { cJSON_Delete(PlayerOptions); PlayerOptions = cJSON_Parse(PlayerOptions_ctor); time_t now = time(NULL); char d[32]; strftime(d, sizeof(d), "%Y-%m-%dT%H:%M:%S.000Z", gmtime(&now)); // new Date() po_sets("saveDate", d); if (!SaveSystem_LoadType(SAVE_DEFAULT)) PlayerOptions_AsyncLoad(); po_sets("TwitchUsername", ""); PlayerOptions_Load_options(); AchievementManager_CheckForStartupAchievements(); // PreloadScene } static void PlayerOptions_CheckSeals(void) { int n = 0; cJSON *v; cJSON_ArrayForEach(v, po("BoughtPowerups")) n += cJSON_IsString(v) && (!strcmp(v->valuestring, "SEAL") || !strcmp(v->valuestring, "SEAL2")); po_set("Seals", n); } static int achieved(const char *a) { return cJSON_IsTrue(cJSON_GetObjectItem(tbl0("achievements", a), "achieved")); } static void PlayerOptions_RestoreUnlockablePowerUps(void) { // static int pandora = achieved("GetTorroneToLevel9") ? 5 : 0, seal = achieved("Banish10Items") ? 10 : 0, seal2 = achieved("Banish20Items") ? 10 : 0, charm = achieved("FindApoplexy") ? 5 : 0; int reroll = achieved("ReachLV100WithMortaccio") + achieved("ReachLV100WithCavallo") + achieved("ReachLV100WithRamba") + achieved("ReachLV100WithOsole") + achieved("ReachLV100WithAmbrojoe"); int skip = achieved("Survive15MinutesInMolise") + achieved("Survive15MinutesInMoongolow") + achieved("Survive30MinutesInGreenAcres") + achieved("Survive30MinutesInBoneZone") + achieved("Survive15MinutesInBossRash"); int banish = achieved("See60Items") + achieved("See70Items") + achieved("See80Items") + achieved("See90Items") + achieved("See100Items"); struct { const char *k; int r; } R[7] = { { "PANDORA", pandora }, { "SEAL", seal }, { "SEAL2", seal2 }, { "REROLL", reroll }, { "SKIP", skip }, { "BANISH", banish }, { "CHARM", charm } }; for (int i = 0; i < 7; i++) if (R[i].r > 0) { cJSON *t = tbl0("powerups", R[i].k); obj_set(t, "hidden", cJSON_CreateFalse()), obj_set(t, "unlockedRank", cJSON_CreateNumber(R[i].r)); } } static void PlayerOptions_RefundAll(void) { cJSON *v, *t; char b[16]; cJSON_ArrayForEach(v, po("BoughtPowerups")) if ((t = tbl0("powerups", key_of(v, b)))) obj_set(t, "level", cJSON_CreateNumber(0)); po_set("Coins", po_num("LifetimeCoins")); const char *E[4] = { "BoughtPowerups", "DisabledPowerups", "SealedItems", "SealedWeapons" }; for (int i = 0; i < 4; i++) po_put(E[i], cJSON_CreateArray()); PlayerOptions_Save(); if (SaveSystem_LoadType(SAVE_DEFAULT)) PlayerOptions_RestoreUnlockablePowerUps(); } static void PlayerOptions_UnlockSkin(const char *ch, int id) { cJSON *u = cJSON_GetObjectItem(po("UnlockedSkins"), ch), *s; char b[16]; snprintf(b, sizeof(b), "%d", id); if (!u) cJSON_AddItemToObject(po("UnlockedSkins"), ch, u = cJSON_CreateArray()); if (arr_indexOf(u, b) < 0) cJSON_AddItemToArray(u, cJSON_CreateNumber(id)); cJSON_ArrayForEach(s, cJSON_GetObjectItem(tbl0("characters", ch), "skins")) if ((int)num(s, "id", -1) == id) { obj_set(s, "unlocked", cJSON_CreateTrue()); break; } } LATER static double PlayerOptions_GetCurrentCoins(void) { return po_num("Coins"); } static void PlayerOptions_AddCoinsFlat(double v) { po_add("Coins", v), po_add("LifetimeCoins", v), po_add("TotalCoins", v); } // SaveCoins: solo Storage del web static void PlayerOptions_AddHeal(double v) { po_add("LifetimeHeal", v); } // Pickup.SetSeenItem (0x166d5) e Core.SetSeenWeapon (0x5103): la collezione (SaveCollection: solo Storage del web) static void Pickup_SetSeenItem(const char *t) { if (po_has("CollectedItems", t)) return; obj_set(tbl0("items", t), "seen", cJSON_CreateTrue()); po_push("CollectedItems", t); } static void Core_SetSeenWeapon(const char *t) { if (!t || po_has("CollectedWeapons", t)) return; cJSON *w = tbl0("weapons", t); obj_set(w, "seen", cJSON_CreateTrue()), obj_set(w, "hidden", cJSON_CreateFalse()); po_push("CollectedWeapons", t); } // 0x9f2f: CharacterSaveData / CharacterSaveManager (stageData del personaggio scelto, una voce per stage) static cJSON *CharacterSaveManager_getCharacterStageData(void) { cJSON *c = tbl0("characters", po_str("SelectedCharacter")), *sd, *e; if (!cJSON_GetObjectItem(c, "stageData")) obj_set(c, "stageData", cJSON_CreateArray()); cJSON *r = cJSON_Parse("{\"complete\":0,\"hyper\":false,\"hurry\":false,\"inverse\":false,\"survivedMinutes\":0,\"startedRun\":0}"); cJSON_AddStringToObject(r, "type", po_str("SelectedStage")); sd = cJSON_GetObjectItem(c, "stageData"); cJSON_ArrayForEach(e, sd) { const char *ty = str(e, "type"); if (ty && !strcmp(ty, po_str("SelectedStage"))) { cJSON *f; cJSON_ArrayForEach(f, e) obj_set(r, f->string, cJSON_Duplicate(f, 1)); break; } } return r; // lo libera il chiamante } static void CharacterSaveManager_setCharacterStageData(cJSON *d) { // d passa all'array o si libera cJSON *c = tbl0("characters", po_str("SelectedCharacter")), *e; if (!cJSON_GetObjectItem(c, "stageData")) obj_set(c, "stageData", cJSON_CreateArray()); cJSON_ArrayForEach(e, cJSON_GetObjectItem(c, "stageData")) { const char *ty = str(e, "type"); if (ty && !strcmp(ty, po_str("SelectedStage"))) { cJSON *f; cJSON_ArrayForEach(f, d) obj_set(e, f->string, cJSON_Duplicate(f, 1)); cJSON_Delete(d); return; } } cJSON_AddItemToArray(cJSON_GetObjectItem(c, "stageData"), d); } // PlayerOptions.SaveGameResults (dalla GameOverScene): le tabelle -> i contatori di carriera static void PlayerOptions_SaveGameResults(void) { cJSON *t; cJSON_ArrayForEach(t, data_get("enemies")) obj_copy(po("KillCount"), t->string, cJSON_GetObjectItem(cJSON_GetArrayItem(t, 0), "killedAmount")); cJSON_ArrayForEach(t, data_get("items")) obj_copy(po("PickupCount"), t->string, cJSON_GetObjectItem(t, "pickedupAmount")); cJSON_ArrayForEach(t, data_get("props")) obj_copy(po("DestroyedCount"), t->string, cJSON_GetObjectItem(t, "destroyedAmount")); cJSON_ArrayForEach(t, data_get("characters")) { cJSON *c = cJSON_GetArrayItem(t, 0); const char *K[5] = { "StageCompletionLog", "CharacterSurvivedMinutes", "CharacterEnemiesKilled", "CharacterStageData", "SelectedSkins" }; const char *F[5] = { "completedStages", "survivedMinutes", "enemiesKilled", "stageData", "currentSkinIndex" }; for (int i = 0; i < 5; i++) obj_copy(po(K[i]), t->string, cJSON_GetObjectItem(c, F[i])); } } // ============================================================================ // HUD: Phaser.GameObjects.Text/Image/Graphics e NineSlice (sottoinsieme) // ============================================================================ #define MAX_SAFE_INTEGER 9007199254740991.0 #define ZInGameUI (MAX_SAFE_INTEGER - 0x3e8) #define ZDamageNumber (MAX_SAFE_INTEGER - 0x2710) static const char *lang1(const char *key, const char *a0); // Text: lo stile dell'HUD non ha fontFamily, quindi Phaser usa 'Courier' (Courier New bold su Windows). // semplificazione: qui ANY.ttf (il sostituto di Courier del gioco) con grassetto sintetico (+1 px); metriche di raylib, non MeasureText di Phaser // HUD_TEXT_SCALE: scostamento voluto da Federico (2026-10-04), testi piu' leggibili sullo schermo della Vita; 1 = dimensioni originali #define HUD_TEXT_SCALE 1.25f typedef struct { Sprite s; char text[32]; float fontSize; } Text; static void Text_draw(Sprite *s) { Text *t = s->owner; if (!s->visible || !*t->text) return; float size = t->fontSize * HUD_TEXT_SCALE; Vector2 m = MeasureTextEx(vs_font, t->text, size, 0); Vector2 p = { roundf(s->x - s->originX * (m.x + 1)), roundf(s->y - s->originY * m.y) }; static const Vector2 O[4] = { { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 } }; // bordo nero al posto del grassetto a +1 px, che scalato sullo schermo si sdoppiava for (int i = 0; i < 4; i++) DrawTextEx(vs_font, t->text, (Vector2){ p.x + O[i].x, p.y + O[i].y }, size, 0, BLACK); DrawTextEx(vs_font, t->text, p, size, 0, WHITE); } static void Text_setText(Text *t, const char *v) { snprintf(t->text, sizeof(t->text), "%s", v); } static void add_text(Text *t, float x, float y, const char *v, float fontSize, float ox, float oy) { // scene.add.text(...).setScrollFactor(0).setOrigin(ox, oy) sprite_init(&t->s, NULL, x, y); sprite_setOrigin(&t->s, ox, oy); t->s.owner = t; t->s.draw = Text_draw; t->s.scrollFactor0 = 1; t->fontSize = fontSize; Text_setText(t, v); children_add(&t->s); } static void add_image(Sprite *s, float x, float y, const char *atlas, const char *frame) { // scene.add.image(...).setScrollFactor(0) sprite_init(s, frame_get(atlas, frame), x, y); s->scrollFactor0 = 1; children_add(s); } static float displayWidth(const Sprite *s) { return s->width * fabsf(s->scaleX); } // NineSlice (phaser3-nineslice): angoli di sourceLayout.width x sourceLayout.height static void nine_wh(const char *frame, int cw, int ch, Rectangle r, Color tint) { const Frame *f = frame_get("UI", frame); if (!f) { DrawRectangleRec(r, (Color){ 40, 40, 80, 230 }); return; } NPatchInfo n = { (Rectangle){ f->x, f->y, f->w, f->h }, cw, ch, cw, ch, NPATCH_NINE_PATCH }; DrawTextureNPatch(*f->tex, n, r, (Vector2){ 0, 0 }, 0, tint); } static void nine(const char *frame, int corner, Rectangle r, Color tint) { nine_wh(frame, corner, corner, r, tint); } // ============================================================================ // 0xbae3: PlayerUI (barra XP in alto, barra della vita sotto il giocatore) // ============================================================================ static struct { Sprite progressBox, progressBar, hpBarBG, hpBar; Vector2 hpBarOffset; float hpBarHeight, hpBarWidth, progressHeight, progressW; Sprite seasonFan, seasonSprite; // Wicked Season: spicchio colorato che si chiude e icona della stagione Vector2 seasonPosition; float seasonValue; unsigned seasonColor; TweenRef seasonTween; } PlayerUI; static void seasonFan_draw(Sprite *s) { // Graphics.slice(x, y, 16, v, PI - v, false) + fillPath, alpha 0.8 if (!s->visible) return; float v = PlayerUI.seasonValue * (180 / PI); DrawCircleSector(PlayerUI.seasonPosition, 0x10, v, 180 - v, 24, hexc(PlayerUI.seasonColor, 0.8f)); sprite_setScale(&PlayerUI.seasonSprite, 1 - PlayerUI.seasonValue / (0.5f * PI) * 0.5f); // onUpdate } static void progressBox_draw(Sprite *s) { // NineSlice ProgressBox: frameB9.png, angoli 6x6, renderer.width x 18 if (s->visible) nine("frameB9.png", 6, (Rectangle){ s->x, s->y, game_width, 0x12 }, WHITE); } static void progressBar_draw(Sprite *s) { // Graphics: fillStyle(0x2266dd), fillRect(4, 4, w, progressHeight) if (s->visible) DrawRectangleRec((Rectangle){ 4, 4, PlayerUI.progressW, PlayerUI.progressHeight }, (Color){ 0x22, 0x66, 0xdd, 255 }); } static void PlayerUI_new(void) { PlayerUI.hpBarOffset = (Vector2){ -0x10, 2 }; PlayerUI.hpBarHeight = 4; PlayerUI.hpBarWidth = 0x20; PlayerUI.progressHeight = 0xa; PlayerUI.progressW = 0; sprite_init(&PlayerUI.progressBox, NULL, 0, 0); PlayerUI.progressBox.draw = progressBox_draw; PlayerUI.progressBox.scrollFactor0 = 1; children_add(&PlayerUI.progressBox); // scene.add.existing sprite_init(&PlayerUI.progressBar, NULL, 0, 0); PlayerUI.progressBar.draw = progressBar_draw; PlayerUI.progressBar.scrollFactor0 = 1; children_add(&PlayerUI.progressBar); float x = 0.5f * game_width + PlayerUI.hpBarOffset.x, y = 0.5f * game_height + PlayerUI.hpBarOffset.y; add_image(&PlayerUI.hpBarBG, x, y, "characters", "blackDot.png"); sprite_setOrigin(&PlayerUI.hpBarBG, 0, 0); PlayerUI.hpBarBG.scaleX = PlayerUI.hpBarWidth, PlayerUI.hpBarBG.scaleY = PlayerUI.hpBarHeight; PlayerUI.hpBarBG.depth = ZInGameUI - 3; add_image(&PlayerUI.hpBar, x, y, "characters", "whiteDot.png"); sprite_setOrigin(&PlayerUI.hpBar, 0, 0); PlayerUI.hpBar.scaleX = PlayerUI.hpBarWidth, PlayerUI.hpBar.scaleY = PlayerUI.hpBarHeight; sprite_setTint(&PlayerUI.hpBar, 0xe00808); PlayerUI.hpBar.depth = ZInGameUI - 3; PlayerUI.progressBox.depth = ZInGameUI - 2; PlayerUI.progressBar.depth = ZInGameUI - 1; PlayerUI.seasonPosition = (Vector2){ PlayerUI.hpBarBG.x + 0x10, PlayerUI.hpBarBG.y + PlayerUI.hpBarHeight + 1 }; sprite_init(&PlayerUI.seasonFan, NULL, 0, 0); PlayerUI.seasonFan.draw = seasonFan_draw, PlayerUI.seasonFan.scrollFactor0 = 1, PlayerUI.seasonFan.visible = 0; PlayerUI.seasonFan.depth = ZInGameUI - 3; PlayerUI.seasonColor = 0xffffff; children_add(&PlayerUI.seasonFan); add_image(&PlayerUI.seasonSprite, PlayerUI.hpBarBG.x + 0x10, PlayerUI.hpBarBG.y + 0xd, "items", "Clover.png"); PlayerUI.seasonSprite.scrollFactor0 = 1, PlayerUI.seasonSprite.depth = ZInGameUI - 2, PlayerUI.seasonSprite.visible = 0; PlayerUI.seasonTween = (TweenRef){ -1, 0 }; } static float WickedSeason_duration(void); static void PlayerUI_OpenSeasonFan(unsigned color, const char *icon) { PlayerUI.seasonSprite.visible = PlayerUI.seasonFan.visible = 1; sprite_setFrame(&PlayerUI.seasonSprite, frame_get("items", icon)); PlayerUI.seasonColor = color; tween_stop(PlayerUI.seasonTween); PlayerUI.seasonValue = 0; // addCounter from 0 to PI / 2 PlayerUI.seasonTween = tweens_add((TweenConfig){ .props = { { &PlayerUI.seasonValue, NULL, 0.5f * PI } }, .nprops = 1, .duration = WickedSeason_duration() }); } static void PlayerUI_Update(void) { if (!Players_isLocal()) return; PlayerUI.hpBar.scaleX = fmaxf(0, Core.Player->hp / Core.Player->maxHp * PlayerUI.hpBarWidth); PlayerUI.hpBar.scaleY = PlayerUI.hpBarHeight; float w = game_width - 8; float v = (Core.Player->xp - Core.previousXPfactor) / (Core.currentXPfactor - Core.previousXPfactor) * w; PlayerUI.progressW = fminf(v, w); } // ============================================================================ // 0x18645: MainUI (tempo, livello, monete, uccisioni, icone di armi e potenziamenti) // ============================================================================ typedef struct { Sprite image; const char *weaponType; int level, isWeapon; } WeaponIconUI; static struct { Text SurvivedSecondsText, PlayerLevelText, KillsText, PlayerCoinsText; Sprite CoinsIcon, KillsIcon, WeaponSlots, BlockedWeaponSlots[5]; WeaponIconUI icons[32]; // memoria delle icone: WeaponIcons/PowerUpIcons puntano qui WeaponIconUI *WeaponIcons[16], *PowerUpIcons[16], *ExtraIcons[16]; int n_icons, n_WeaponIcons, n_PowerUpIcons, n_ExtraIcons; float xIncrease, yOffset; int cols; } MainUI; #define HUDK 1.5f // Vita: l'HUD ingrandito, ancorato ai bordi (il campo di gioco resta quello dell'originale) static void MainUI_new(void) { memset(&MainUI, 0, sizeof(MainUI)); MainUI.xIncrease = 0x10 * HUDK, MainUI.yOffset = 0x12 + 0x10 * (HUDK - 1) * 0, MainUI.cols = 6; MainUI.yOffset = 0x12; add_text(&MainUI.SurvivedSecondsText, 0.5f * game_width, 0x16, "0:00", 20 * HUDK, 0.5f, 0); add_text(&MainUI.PlayerLevelText, game_width - 4, 9, "LV 99", 15, 1, 0.5f); add_image(&MainUI.CoinsIcon, game_width - 4, 0x19 + 6, "UI", "CoinGold.png"); sprite_setOrigin(&MainUI.CoinsIcon, 1, 0.5f); sprite_setScale(&MainUI.CoinsIcon, PixelScale * HUDK); MainUI.CoinsIcon.depth = ZInGameUI - 3; add_image(&MainUI.KillsIcon, game_width - 4, 0x19 + 6 + 0x12 * HUDK, "UI", "SkullToken.png"); // Vita: sotto le monete sprite_setOrigin(&MainUI.KillsIcon, 1, 0.5f); sprite_setScale(&MainUI.KillsIcon, PixelScale * HUDK); MainUI.KillsIcon.depth = ZInGameUI - 3; add_text(&MainUI.KillsText, MainUI.KillsIcon.x - displayWidth(&MainUI.KillsIcon) - 4, MainUI.KillsIcon.y, "9999", 12 * HUDK, 1, 0.5f); MainUI.KillsText.s.depth = ZInGameUI - 3; add_text(&MainUI.PlayerCoinsText, MainUI.CoinsIcon.x - displayWidth(&MainUI.CoinsIcon) - 4, MainUI.CoinsIcon.y, "9999", 12 * HUDK, 1, 0.5f); MainUI.PlayerCoinsText.s.depth = ZInGameUI - 3; add_image(&MainUI.WeaponSlots, 1, 0x12, "UI", "weaponSlots.psd"); sprite_setOrigin(&MainUI.WeaponSlots, 0, 0); sprite_setScale(&MainUI.WeaponSlots, PixelScale * HUDK); MainUI.WeaponSlots.depth = ZInGameUI - 3; for (int i = 1; i < 6; i++) { Sprite *b = &MainUI.BlockedWeaponSlots[5 - i]; // push e poi reverse() add_image(b, 9 * HUDK + MainUI.xIncrease * i, 9 * HUDK + MainUI.yOffset, "UI", "no16.png"); b->alpha = 0.5f; sprite_setScale(b, PixelScale * HUDK); b->depth = ZInGameUI - 2; b->visible = 0; } MainUI.PlayerCoinsText.s.depth = MainUI.CoinsIcon.depth = MainUI.PlayerLevelText.s.depth = MAX_SAFE_INTEGER; MainUI.SurvivedSecondsText.s.depth = MainUI.KillsIcon.depth = MainUI.KillsText.s.depth = MAX_SAFE_INTEGER; // StatsPanel (0xe199): creato e subito nascosto (setVisible(false)); da tradurre con PauseStatsScene } static void MainUI_SetSurvivedSeconds(int s) { // FormatTime char b[16]; snprintf(b, sizeof(b), "%d:%02d", s / 60, s % 60); Text_setText(&MainUI.SurvivedSecondsText, b); } static void MainUI_UpdateCoins(void) { char b[16]; snprintf(b, sizeof(b), "%.0f", Core.RunCoins); // toFixed(0).toLocaleString(): su una stringa non aggiunge separatori Text_setText(&MainUI.PlayerCoinsText, b); } static void MainUI_UpdateKills(void) { char b[16]; snprintf(b, sizeof(b), "%d", Core.kills); Text_setText(&MainUI.KillsText, b); } static void MainUI_UpdatePlayerLevel(void) { char b[16]; snprintf(b, sizeof(b), "%d", Core.Player->level); Text_setText(&MainUI.PlayerLevelText, lang1("ingame_level", b)); } static void MainUI_RearrangeIcons(void) { for (int i = 0; i < MainUI.n_WeaponIcons; i++) { Sprite *im = &MainUI.WeaponIcons[i]->image; im->x = MainUI.xIncrease * i, im->y = MainUI.yOffset; } int l = -1, r = -1; // LEFT e RIGHT in testa ai potenziamenti for (int i = 0; i < MainUI.n_PowerUpIcons; i++) { if (l < 0 && !strcmp(MainUI.PowerUpIcons[i]->weaponType, "LEFT")) l = i; if (r < 0 && !strcmp(MainUI.PowerUpIcons[i]->weaponType, "RIGHT")) r = i; } if (l >= 0 && r >= 0) { WeaponIconUI **a = MainUI.PowerUpIcons, *R = a[r], *L = a[l]; memmove(&a[1], &a[0], r * sizeof(*a)), a[0] = R; // splice(r, 1) + unshift if (l < r) l++; memmove(&a[1], &a[0], l * sizeof(*a)), a[0] = L; } for (int i = 0; i < MainUI.n_PowerUpIcons; i++) { Sprite *im = &MainUI.PowerUpIcons[i]->image; im->x = MainUI.xIncrease * (i % MainUI.cols), im->y = MainUI.yOffset + MainUI.xIncrease + MainUI.xIncrease * (i / MainUI.cols); } for (int i = 0; i < MainUI.n_ExtraIcons; i++) { // dopo i potenziamenti, nella stessa griglia int k = MainUI.n_PowerUpIcons + i; Sprite *im = &MainUI.ExtraIcons[i]->image; im->x = MainUI.xIncrease * (k % MainUI.cols), im->y = MainUI.yOffset + MainUI.xIncrease + MainUI.xIncrease * (k / MainUI.cols); } } static void MainUI_AddExtra(const char *type) { // icone di armi nascoste e arcane: niente slot, solo l'immagine for (int i = 0; i < MainUI.n_ExtraIcons; i++) if (!strcmp(MainUI.ExtraIcons[i]->weaponType, type)) { MainUI.ExtraIcons[i]->level++; MainUI_RearrangeIcons(); return; } if (MainUI.n_icons >= 32 || MainUI.n_ExtraIcons >= 16) return; cJSON *base = cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("weapons"), type), 0); WeaponIconUI *w = &MainUI.icons[MainUI.n_icons++]; w->weaponType = type, w->level = 1, w->isWeapon = 0; int k = MainUI.n_PowerUpIcons + MainUI.n_ExtraIcons; add_image(&w->image, MainUI.xIncrease * (MainUI.n_PowerUpIcons % MainUI.cols), MainUI.yOffset + MainUI.xIncrease + MainUI.xIncrease * (k / MainUI.cols), str(base, "texture"), str(base, "frameName")); // (sic) x dalla sola colonna dei potenziamenti; RearrangeIcons la sistema sprite_setOrigin(&w->image, 0, 0); w->image.depth = ZInGameUI - 2; if (w->image.width) sprite_setScale(&w->image, 0x10 * HUDK / w->image.width); MainUI.ExtraIcons[MainUI.n_ExtraIcons++] = w; MainUI_RearrangeIcons(); } static void MainUI_Add(const char *type) { cJSON *base = cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("weapons"), type), 0); int asPowerUp = cJSON_IsTrue(cJSON_GetObjectItem(base, "isPowerUp")) || MainUI.n_WeaponIcons >= 6; WeaponIconUI **arr = asPowerUp ? MainUI.PowerUpIcons : MainUI.WeaponIcons; int n = asPowerUp ? MainUI.n_PowerUpIcons : MainUI.n_WeaponIcons; for (int i = 0; i < n; i++) if (!strcmp(arr[i]->weaponType, type)) { arr[i]->level++; MainUI_RearrangeIcons(); return; } if (MainUI.n_icons >= 32 || n >= 16) return; WeaponIconUI *w = &MainUI.icons[MainUI.n_icons++]; w->weaponType = type, w->level = 1, w->isWeapon = !asPowerUp; float x = w->isWeapon ? MainUI.xIncrease * MainUI.n_WeaponIcons : MainUI.xIncrease * (MainUI.n_PowerUpIcons % MainUI.cols); float y = w->isWeapon ? MainUI.yOffset : MainUI.yOffset + MainUI.xIncrease + MainUI.xIncrease * (MainUI.n_PowerUpIcons / MainUI.cols); add_image(&w->image, x, y, str(base, "texture"), str(base, "frameName")); sprite_setOrigin(&w->image, 0, 0); w->image.depth = ZInGameUI - 2; if (w->image.width) sprite_setScale(&w->image, 0x10 * HUDK / w->image.width); if (w->isWeapon) MainUI.WeaponIcons[MainUI.n_WeaponIcons++] = w; else MainUI.PowerUpIcons[MainUI.n_PowerUpIcons++] = w; MainUI_RearrangeIcons(); } static void MainUI_AddWeaponIcon(const char *type) { if (Players_isLocal()) MainUI_Add(type); } static void MainUI_ShowWeaponBlocks(int n) { for (int i = 0; i < n && i < 5; i++) MainUI.BlockedWeaponSlots[i].visible = 1; } static void MainUI_Remove(const char *type) { // l'icona sparisce dai potenziamenti o dalle armi, poi RearrangeIcons if (!Players_isLocal()) return; for (int k = 0; k < 2; k++) { WeaponIconUI **a = k == 0 ? MainUI.PowerUpIcons : MainUI.WeaponIcons; int *n = k == 0 ? &MainUI.n_PowerUpIcons : &MainUI.n_WeaponIcons; for (int i = 0; i < *n; i++) { if (strcmp(a[i]->weaponType, type)) continue; children_remove(&a[i]->image); memmove(&a[i], &a[i + 1], (*n - i - 1) * sizeof(*a)); (*n)--; k = 2; break; } } MainUI_RearrangeIcons(); } // AddExtra (arcana), ToggleAll: da tradurre con i sistemi che li chiamano // ============================================================================ // 0xc151: TilingTileset (mappa Tiled ripetuta: 4 copie che seguono il giocatore) // ============================================================================ typedef struct { // classe interna _0x7f280c TilemapLayer *layers[16]; int n; TilemapLayer *ShadowLayer, *ShadowDecalsLayer, *SpawnerLayer; } LayerContainer; static void LayerContainer_setPos(LayerContainer *c, float x, float y) { for (int i = 0; i < c->n; i++) c->layers[i]->x = x, c->layers[i]->y = y; } typedef struct TilingTileset { float _SIZEX, _SIZEY; int mapsAmount, inverted, n_bounds; Tilemap *MainMap; // semplificazione: una sola Tilemap con i LayerData condivisi dalle 4 copie (l'originale ne crea 4 identiche) LayerContainer layerContainers[4]; Rectangle bounds[5], current; Vector2 StartPosition; // linkTeleporters (TELEPORT, per teleportKey) e telepartami (PARTO, per type): coppie A/B struct { char key[32]; Vector2 A, B; int hasA, hasB; } teleporters[16], mongates[16]; int n_teleporters, n_mongates, hasTeleporters, hasMongates; struct Pickup *ListOfTeleporters[32]; int n_ListOfTeleporters; } TilingTileset; static void TilingTileset_update(TilingTileset *t) { if (t->mapsAmount == 1) { t->current = t->bounds[0]; return; } float px = Core.Player->s.x, py = Core.Player->s.y; for (int i = 0; i < t->n_bounds; i++) { Rectangle r = t->bounds[i]; if (px >= r.x && px <= r.x + r.width && py >= r.y && py <= r.y + r.height) { // Rectangle.contains t->current = r; memmove(&t->bounds[i], &t->bounds[i + 1], (t->n_bounds - i - 1) * sizeof(Rectangle)); t->n_bounds--; break; } } int left = px < t->current.x + 0.5f * t->current.width, up = py < t->current.y + 0.5f * t->current.height; Rectangle *b = &t->bounds[0]; b->y = t->current.y, b->x = left ? t->current.x - b->width : t->current.x + t->current.width; b = &t->bounds[1]; b->x = t->current.x, b->y = up ? t->current.y - b->height : t->current.y + t->current.height; b = &t->bounds[2]; b->x = left ? t->current.x - b->width : t->current.x + t->current.width; b->y = up ? t->current.y - b->height : t->current.y + t->current.height; // unshift(current). Giocatore fuori da tutti i rettangoli (solo teletrasporto, VS_POS): nell'originale // l'array cresce di uno a ogni frame; qui la coda oltre i 4 (mai letta) si scarta invece di uscire da bounds[5] if (t->n_bounds > 4) t->n_bounds = 4; memmove(&t->bounds[1], &t->bounds[0], t->n_bounds * sizeof(Rectangle)); t->bounds[0] = t->current; t->n_bounds++; for (int i = 0; i < t->mapsAmount; i++) LayerContainer_setPos(&t->layerContainers[i], t->bounds[i].x, t->bounds[i].y); } // sviluppo (VS_PIANO): dopo un teletrasporto le copie della mappa ripartono attorno al giocatore (camminando lo seguono da sole) static void TilingTileset_recenter(TilingTileset *t) { Rectangle r = { floorf(Core.Player->s.x / t->_SIZEX) * t->_SIZEX, floorf(Core.Player->s.y / t->_SIZEY) * t->_SIZEY, t->_SIZEX, t->_SIZEY }; for (int i = 0; i < 4; i++) t->bounds[i] = r; t->n_bounds = 4; TilingTileset_update(t); } static float tiled_prop(cJSON *o, const char *name, float def) { // properties.find(p => p.name === name) cJSON *p; cJSON_ArrayForEach(p, cJSON_GetObjectItem(o, "properties")) if (!strcmp(str(p, "name"), name)) return num(p, "value", def); return def; } static const char *tiled_props(cJSON *o, const char *name) { cJSON *p; cJSON_ArrayForEach(p, cJSON_GetObjectItem(o, "properties")) if (!strcmp(str(p, "name"), name)) return str(p, "value"); return NULL; } static Pickup *Core_MakeStagePickup(float x, float y, const char *type, const char *weaponType); static float Player_PLuck(Player *p); static void Coffin_setChar(Pickup *p, const char *ch); static void TilingTileset_coffinAt(TilingTileset *t, const char *type, const char *ch) { // l'oggetto CFF di Scripts: posizione e guardie cJSON *o, *cff = NULL; cJSON_ArrayForEach(o, tilemap_getObjectLayerObjects(t->MainMap, "Scripts")) if (str(o, "name") && !strcmp(str(o, "name"), "CFF")) cff = o; if (!cff || !cJSON_GetObjectItem(cff, "properties")) return; float x = num(cff, "x", 0) + t->_SIZEX * tiled_prop(cff, "xMultiplier", 0), y = num(cff, "y", 0) + t->_SIZEY * tiled_prop(cff, "yMultiplier", 0); Pickup *p = Core_MakeStagePickup(x, y, type, NULL); if (!p) return; Coffin_setChar(p, ch); const char *guards = tiled_props(cff, "guards"); if (guards) p->enemyType = guards, p->spawnQuantity = tiled_prop(cff, "spawnQuantity", 0), p->spawnAngle = tiled_prop(cff, "spawnAngle", 0x168) * (PI / 180); } static void TilingTileset_SpawnMerchant(TilingTileset *t) { // l'oggetto MRC di Scripts cJSON *o, *mrc = NULL; cJSON_ArrayForEach(o, tilemap_getObjectLayerObjects(t->MainMap, "Scripts")) if (str(o, "name") && !strcmp(str(o, "name"), "MRC")) mrc = o; if (!mrc) return; Core_MakeStagePickup(num(mrc, "x", 0) + t->_SIZEX * tiled_prop(mrc, "xMultiplier", 0), num(mrc, "y", 0) + t->_SIZEY * tiled_prop(mrc, "yMultiplier", 0), "MERCHANT", NULL); } static void Stage_SpawnMerchant(Stage *st) { // Stage.SpawnMerchant: senza mappa, accanto al giocatore if (st->isMerchantBanned) return; if (st->tilingTileset) TilingTileset_SpawnMerchant(st->tilingTileset); else Core_MakeStagePickup(Core.Player->s.x + 0x40, Core.Player->s.y - 0xbe, "MERCHANT", NULL); } static void TilingTileset_TrySpawnSpecialCoffin(TilingTileset *t) { // Arengijus: dopo le cinque bare degli stage if (po_has("UnlockedCharacters", "ARENGIJUS")) return; static const char *const C[5] = { "PUGNALA", "GIOVANNA", "POPPEA", "CONCETTA", "ASSUNTA" }; for (int i = 0; i < 5; i++) if (!po_has("UnlockedCharacters", C[i])) return; TilingTileset_coffinAt(t, "COFFINX", "ARENGIJUS"); } static void TilingTileset_MakeCoffin(TilingTileset *t, const char *ch) { if (po_has("UnlockedCharacters", ch)) { TilingTileset_TrySpawnSpecialCoffin(t); return; } TilingTileset_coffinAt(t, "COFFIN", ch); } static void TilingTileset_spawnWeaponAt(TilingTileset *t, cJSON *o) { const char *type = str(o, "type"); if (!type || !*type) type = str(o, "class"); float chance = tiled_prop(o, "chance", -1); if (chance >= 0 && frand() > chance * Player_PLuck(Core.Player)) return; // PLuck float x = num(o, "x", 0) + t->_SIZEX * tiled_prop(o, "xMultiplier", 0), y = num(o, "y", 0) + t->_SIZEY * tiled_prop(o, "yMultiplier", 0); Pickup *p = Core_MakeStagePickup(x, y, "WEAPON", type); const char *guards = tiled_props(o, "guards"); if (p && guards) p->enemyType = guards, p->spawnQuantity = tiled_prop(o, "spawnQuantity", 0), p->spawnAngle = tiled_prop(o, "spawnAngle", 0x168) * (PI / 180); } static int Collected(const char *item); static Pickup *Core_MakeGem(float x, float y, float value); static Pickup *Core_MakePickup(float x, float y, const char *type); static const PickupVT *pickup_vt(const char *type); static void TilingTileset_spawnYellowAt(TilingTileset *t, cJSON *o) { // gli anelli e i Metaglio con la reliquia RELIC_YELLOW if (!Collected("RELIC_YELLOW")) return; float x = num(o, "x", 0) + t->_SIZEX * tiled_prop(o, "xMultiplier", 0), y = num(o, "y", 0) + t->_SIZEY * tiled_prop(o, "yMultiplier", 0); // debugPositions = 1 Pickup *p = Core_MakeStagePickup(x, y, "WEAPON", str(o, "type")); const char *guards = tiled_props(o, "guards"); if (p && guards) p->enemyType = guards, p->spawnQuantity = tiled_prop(o, "spawnQuantity", 0), p->spawnAngle = tiled_prop(o, "spawnAngle", 0x168) * (PI / 180); } static void TilingTileset_spawnItemAt(TilingTileset *t, cJSON *o) { const char *type = str(o, "type"); float chance = tiled_prop(o, "chance", -1); if (chance >= 0 && frand() > chance * Player_PLuck(Core.Player)) return; float x = num(o, "x", 0) + t->_SIZEX * tiled_prop(o, "xMultiplier", 0), y = num(o, "y", 0) + t->_SIZEY * tiled_prop(o, "yMultiplier", 0); if (type && !strcmp(type, "GEM")) Core_MakeGem(x, y, tiled_prop(o, "value", 1)); else if (type && pickup_vt(type)) Core_MakePickup(x, y, type); // semplificazione: GOLDFINGER, ROSARYX ancora senza classe, li salta } static void TilingTileset_pair(TilingTileset *t, int tele, const char *key, cJSON *o) { // linkTeleporters / telepartami float x = num(o, "x", 0) + t->_SIZEX * tiled_prop(o, "xMultiplier", 0), y = num(o, "y", 0) + t->_SIZEY * tiled_prop(o, "yMultiplier", 0); int n = tele ? t->n_teleporters : t->n_mongates, i = 0; typeof(t->teleporters[0]) *L = tele ? t->teleporters : t->mongates; while (i < n && strcmp(L[i].key, key)) i++; if (i == n) { if (n >= 16) return; snprintf(L[i].key, sizeof(L[i].key), "%s", key); if (tele) t->n_teleporters++; else t->n_mongates++; } if (!L[i].hasA) L[i].A = (Vector2){ x, y }, L[i].hasA = 1; else if (!L[i].hasB) { L[i].B = (Vector2){ x, y }, L[i].hasB = 1; if (tele) t->hasTeleporters = 1; else t->hasMongates = 1; } } static void Tele_LinkTo(Pickup *p, Pickup *l); static void Moon_LinkTo(Pickup *p, Pickup *l); static void TilingTileset_makePairs(TilingTileset *t) { // mongatami / makeTeleporters for (int i = 0; t->hasMongates && i < t->n_mongates; i++) { if (!t->mongates[i].hasB) continue; // (nell'originale: TypeError su una coppia incompleta) Pickup *a = Core_MakePickup(t->mongates[i].A.x, t->mongates[i].A.y, "MOONGATE"), *b = Core_MakePickup(t->mongates[i].B.x, t->mongates[i].B.y, "MOONGATE"); if (a && b) Moon_LinkTo(a, b), Moon_LinkTo(b, a); } for (int i = 0; t->hasTeleporters && i < t->n_teleporters; i++) { if (!t->teleporters[i].hasB) continue; Pickup *a = Core_MakePickup(t->teleporters[i].A.x, t->teleporters[i].A.y, "TELEPORTER"), *b = Core_MakePickup(t->teleporters[i].B.x, t->teleporters[i].B.y, "TELEPORTER"); if (!a || !b) continue; Tele_LinkTo(a, b), Tele_LinkTo(b, a); if (t->n_ListOfTeleporters < 31) t->ListOfTeleporters[t->n_ListOfTeleporters++] = a, t->ListOfTeleporters[t->n_ListOfTeleporters++] = b; } } static Pickup *Core_MakeRelic(float x, float y, const char *relic); static void TilingTileset_spawnRelicAt(TilingTileset *t, cJSON *o) { // una reliquia non ancora raccolta, con le sue guardie const char *type = str(o, "type"); if (!type || po_has("CollectedItems", type)) return; float x = num(o, "x", 0) + t->_SIZEX * tiled_prop(o, "xMultiplier", 0), y = num(o, "y", 0) + t->_SIZEY * tiled_prop(o, "yMultiplier", 0); Pickup *p = Core_MakeRelic(x, y, type); const char *guards = tiled_props(o, "guards"); if (p && guards) p->enemyType = guards, p->spawnQuantity = tiled_prop(o, "spawnQuantity", 0), p->spawnAngle = tiled_prop(o, "spawnAngle", 0x168) * (PI / 180); } // Reliquie del port nello stage: il vinile nel punto "Item" della mappa piu' lontano dalla partenza (calpestabile per costruzione), // gli occhiali nella Biblioteca nel secondo piu' lontano; senza punti Item, a 900 px dalla partenza static void TilingTileset_spawnPortRelics(TilingTileset *t, const char *stage) { Vector2 best[2] = { { t->StartPosition.x + 900, t->StartPosition.y }, { t->StartPosition.x - 900, t->StartPosition.y } }; float d0 = -1, d1 = -1; cJSON *o; cJSON_ArrayForEach(o, tilemap_getObjectLayerObjects(t->MainMap, "Scripts")) { if (!str(o, "name") || strcmp(str(o, "name"), "Item")) continue; Vector2 q = { num(o, "x", 0), num(o, "y", 0) }; float d = hypotf(q.x - t->StartPosition.x, q.y - t->StartPosition.y); if (d > d0) best[1] = best[0], d1 = d0, best[0] = q, d0 = d; else if (d > d1) best[1] = q, d1 = d; } cJSON *vi = cJSON_GetObjectItem(data_get("items"), TextFormat("RELIC_VINYL_%s", stage)); // la chiave della tabella: Pickup tiene il puntatore if (vi && !po_has("CollectedItems", vi->string)) Core_MakeRelic(best[0].x, best[0].y, vi->string); TraceLog(LOG_INFO, "PORT: %s a %.0f,%.0f (partenza %.0f,%.0f), occhiali %s", vi ? vi->string : "-", best[0].x, best[0].y, t->StartPosition.x, t->StartPosition.y, !strcmp(stage, "LIBRARY") ? TextFormat("a %.0f,%.0f", best[1].x, best[1].y) : "-"); if (!strcmp(stage, "FOREST") && !po_has("CollectedItems", "RELIC_3DGLASSES")) Core_MakeRelic(best[1].x, best[1].y, "RELIC_3DGLASSES"); // primo livello (Federico) } // GetSpecialLocations / GetNoShadowAreaLocations: oggetti di Scripts con quel nome (la memoria e' della partita) static int TilingTileset_GetSpecialLocations(TilingTileset *t, const char *name, Vector2 **out) { cJSON *o, *objs = tilemap_getObjectLayerObjects(t->MainMap, "Scripts"); int n = 0; *out = gmem_calloc(cJSON_GetArraySize(objs) + 1, sizeof(Vector2)); cJSON_ArrayForEach(o, objs) if (str(o, "name") && !strcmp(str(o, "name"), name)) (*out)[n++] = (Vector2){ num(o, "x", 0), num(o, "y", 0) }; return n; } static int TilingTileset_GetNoShadowAreaLocations(TilingTileset *t, const char *name, Rectangle **out) { cJSON *o, *objs = tilemap_getObjectLayerObjects(t->MainMap, "Scripts"); int n = 0; *out = gmem_calloc(cJSON_GetArraySize(objs) + 1, sizeof(Rectangle)); cJSON_ArrayForEach(o, objs) if (str(o, "name") && !strcmp(str(o, "name"), name)) (*out)[n++] = (Rectangle){ num(o, "x", 0), num(o, "y", 0), num(o, "width", 0), num(o, "height", 0) }; return n; } static int objectLayer_points(Tilemap *m, const char *layer, Vector2 **out) { // getObjectLayer(layer).objects.forEach(push({x, y})) cJSON *o, *objs = tilemap_getObjectLayerObjects(m, layer); int n = 0; *out = gmem_calloc(cJSON_GetArraySize(objs) + 1, sizeof(Vector2)); cJSON_ArrayForEach(o, objs) (*out)[n++] = (Vector2){ num(o, "x", 0), num(o, "y", 0) }; return n; } static TilemapLayer *CollisionLayers[16]; // TilingTileset.CollisionLayers: Walls, Obstacle, PlayerWall di ogni copia static int n_CollisionLayers; // inverted && VisuallyInvertStages: data.reverse() di ogni layer (la mappa ruota di 180 gradi) e oggetti specchiati // (x = W - x - width, y = H - y - height, solo se non 0; PlayerStart della Foresta resta dov'e'). L'originale lo fa sulla // cache e la rimette a posto dopo aver creato le mappe, che restano capovolte: qui la mappa capovolta ha la sua voce di cache. // tile.rotation += pi: con i bit di flip H e V scambiati ParseGID da' la stessa tile ruotata di pi (anche con D e i flip). static void TilingTileset_invertJSON(cJSON *j, const char *stageType) { float W = num(j, "width", 0) * num(j, "tilewidth", 0), H = num(j, "height", 0) * num(j, "tileheight", 0); cJSON *l, *o; cJSON_ArrayForEach(l, cJSON_GetObjectItem(j, "layers")) { cJSON *d = cJSON_GetObjectItem(l, "data"); int n = cJSON_GetArraySize(d); if (n > 0) { double *v = malloc(n * sizeof(double)); int i = 0; cJSON_ArrayForEach(o, d) v[i++] = cJSON_GetNumberValue(o); i = n; cJSON_ArrayForEach(o, d) { double g = v[--i]; cJSON_SetNumberValue(o, g ? (double)((unsigned)g ^ 0xC0000000u) : 0); } free(v); } cJSON_ArrayForEach(o, cJSON_GetObjectItem(l, "objects")) { const char *nm = str(o, "name"); if (nm && !strcmp(nm, "PlayerStart") && !strcmp(stageType, "FOREST")) continue; float x = num(o, "x", 0), y = num(o, "y", 0); if (x) obj_set(o, "x", cJSON_CreateNumber(W - x - num(o, "width", 0))); if (y) obj_set(o, "y", cJSON_CreateNumber(H - y - num(o, "height", 0))); } } } // Phaser ParseObjectLayers: x += offsetx + startx, y += offsety + starty per ogni oggetto, dopo l'eventuale capovolta. // Cappella (Scripts -96: bara nel vuoto a destra del pontile), Foresta (Scripts), Latteria (Destructibles) static void TilingTileset_offsetObjects(cJSON *j) { cJSON *l, *o; cJSON_ArrayForEach(l, cJSON_GetObjectItem(j, "layers")) { float dx = num(l, "offsetx", 0) + num(l, "startx", 0), dy = num(l, "offsety", 0) + num(l, "starty", 0); if (!dx && !dy) continue; cJSON_ArrayForEach(o, cJSON_GetObjectItem(l, "objects")) obj_set(o, "x", cJSON_CreateNumber(num(o, "x", 0) + dx)), obj_set(o, "y", cJSON_CreateNumber(num(o, "y", 0) + dy)); } } static TilingTileset *TilingTileset_new(const char *stageType, float sizeX, float sizeY) { TilingTileset *t = calloc(1, sizeof(TilingTileset)); cJSON *sdata = cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("stages"), stageType), 0), *ts = cJSON_GetObjectItem(sdata, "tileset"); t->_SIZEX = sizeX, t->_SIZEY = sizeY; t->inverted = po_is("SelectedInverse") && strcmp(stageType, "STAGEX") && strcmp(stageType, "MACHINE"); int visual = t->inverted && po_is("VisuallyInvertStages"); char jp[96], ip[96]; snprintf(jp, sizeof(jp), "tilesets/%s.json", str(ts, "mapKey")); snprintf(ip, sizeof(ip), "tilesets/%s.png", str(ts, "setKey")); // cache.tilemap, ma di una sola mappa: le mappe 320x320 dei DLC pesano ~70 MiB l'una (cJSON + layer) su 128 di heap, // tenerle tutte faceva finire la memoria al secondo stage grande (issue 14). Rigiocare lo stesso stage non riparsa. static Tilemap *cache; static char cacheKey[32]; static int cacheVisual; if (cache && (strcmp(cacheKey, stageType) || cacheVisual != visual)) tilemap_free(cache), cache = NULL; if (!cache) { cache = make_tilemap(jp, ip, 1, 2); // addTilesetImage(setKey, setKey, 32, 32, 1, 2) if (cache && visual) TilingTileset_invertJSON(cache->json, stageType); if (cache) TilingTileset_offsetObjects(cache->json); snprintf(cacheKey, sizeof(cacheKey), "%s", stageType), cacheVisual = visual; } t->MainMap = cache; if (!t->MainMap) { free(t); return NULL; } // dati senza tilesets/: partita senza mappa tilemap_resetLayers(t->MainMap); // la terrazza della Cappella e spianami tolgono tile: la partita dopo riparte intera t->mapsAmount = cJSON_IsTrue(cJSON_GetObjectItem(ts, "isTiling")) ? 4 : 1; cJSON *o; cJSON_ArrayForEach(o, tilemap_getObjectLayerObjects(t->MainMap, "Scripts")) { const char *n = str(o, "name"); if (n && !strcmp(n, "PlayerStart")) t->StartPosition = (Vector2){ num(o, "x", 0), num(o, "y", 0) }; else if (n && !strcmp(n, "Weapon")) TilingTileset_spawnWeaponAt(t, o); else if (n && !strcmp(n, "Item")) TilingTileset_spawnItemAt(t, o); else if (n && !strcmp(n, "Yellow")) TilingTileset_spawnYellowAt(t, o); else if (n && !strcmp(n, "RELIC")) TilingTileset_spawnRelicAt(t, o); else if (n && !strcmp(n, "PARTO")) TilingTileset_pair(t, 0, str(o, "type") ? str(o, "type") : "", o); else if (n && !strcmp(n, "TELEPORT")) { const char *k = tiled_props(o, "teleportKey"); TilingTileset_pair(t, 1, k ? k : TextFormat("%g", tiled_prop(o, "teleportKey", 0)), o); } // tilep (pianificami) e ARCANACHEST: in nessuna mappa del gioco base; // StoreScript (CFF bara, MRC mercante, Wind, Deco, Piano, center): restano in Scripts, li leggono le classi degli stage } TilingTileset_spawnPortRelics(t, stageType); // occhiali e vinile: dopo PlayerStart for (int i = 0; i < t->mapsAmount; i++) { Tilemap *m = t->MainMap; LayerContainer *c = &t->layerContainers[i]; c->layers[c->n++] = tilemap_createLayer(m, "Floor", -0x7d0); c->layers[c->n++] = tilemap_createLayer(m, "FloorOverlay", -0x7cf); c->layers[c->n++] = tilemap_createLayer(m, "FakeWalls", -0x7ce); TilemapLayer *walls = tilemap_createLayer(m, "Walls", -0x7cd), *playerWall = tilemap_createLayer(m, "PlayerWall", -0x7cd), *obstacle = tilemap_createLayer(m, "Obstacle", -0x7cc); tilemapLayer_setCollisionByProperty(walls, "collides"); tilemapLayer_setCollisionByProperty(playerWall, "collides"); tilemapLayer_setCollisionByProperty(obstacle, "collides"); c->layers[c->n++] = tilemap_createLayer(m, "Decals", -0x7cb); c->layers[c->n++] = tilemap_createLayer(m, "Overlay1", t->inverted ? -0x7ca : 1); TilemapLayer *shadows = tilemap_createLayer(m, "Shadows", 0x7cb); c->ShadowLayer = shadows; c->layers[c->n++] = shadows; c->layers[c->n++] = walls; // layers[6] c->layers[c->n++] = obstacle; // layers[7] c->layers[c->n++] = playerWall; // layers[8] TilemapLayer *sd = tilemap_createLayer(m, "ShadowDecals", 0x7cc); // getLayerIndexByName if (sd) c->ShadowDecalsLayer = sd, c->layers[c->n++] = shadows; // (sic) spinge di nuovo Shadows: ShadowDecals non segue le copie TilemapLayer *sp = tilemap_createLayer(m, "Spawning", 0x2710); if (sp) sp->s.visible = 0, c->SpawnerLayer = sp, c->layers[c->n++] = shadows; // (sic), come sopra physics_addColliderLayer(&Core.playerGroup, walls); physics_addColliderLayer(&Core.playerGroup, obstacle); physics_addColliderLayer(&Core.playerGroup, playerWall); physics_addColliderLayer(&Core.EnemyGroup, walls); physics_addColliderLayer(&Core.EnemyGroup, obstacle); if (n_CollisionLayers + 3 <= 16) CollisionLayers[n_CollisionLayers++] = walls, CollisionLayers[n_CollisionLayers++] = obstacle, CollisionLayers[n_CollisionLayers++] = playerWall; if (t->inverted || num(ts, "tint", 0)) { // maps[i].layers.forEach(tilemapLayer.forEachTile(tile.tint = tileset.tint, o inverse.tint || bianco)) cJSON *inv = cJSON_GetObjectItem(sdata, "inverse"); unsigned tint = !t->inverted ? (unsigned)num(ts, "tint", 0) & 0xffffff : inv ? (unsigned)num(inv, "tint", 0) : 0xffffff; TilemapLayer *all[6 + sizeof(c->layers) / sizeof(c->layers[0])] = { walls, playerWall, obstacle, shadows, c->ShadowDecalsLayer, c->SpawnerLayer }; int na = 6; for (int k = 0; k < c->n; k++) all[na++] = c->layers[k]; for (int k = 0; k < na; k++) if (all[k]) all[k]->tint = tint; } } TilingTileset_makePairs(t); Core.Player->s.x = t->StartPosition.x, Core.Player->s.y = t->StartPosition.y; // Player.setPosition t->n_bounds = 4; for (int i = 0; i < 4; i++) t->bounds[i] = (Rectangle){ t->_SIZEX * i, 0, t->_SIZEX, t->_SIZEY }; TilingTileset_update(t); return t; } static Tile *TilingTileset_getSpawningLayerTile(TilingTileset *t, float x, float y) { // solo le mappe col layer Spawning (MAPPED) return t->layerContainers[0].SpawnerLayer ? tilemapLayer_getTileAtWorldXY(t->layerContainers[0].SpawnerLayer, x, y) : NULL; } // isPointWithinCollisionLayer: Walls (layers[6]) o PlayerWall (layers[8]) della prima copia static int TilingTileset_isPointWithinCollisionLayer(TilingTileset *t, float x, float y) { return tilemapLayer_getTileAtWorldXY(t->layerContainers[0].layers[6], x, y) || tilemapLayer_getTileAtWorldXY(t->layerContainers[0].layers[8], x, y); } // ============================================================================ // 0x12c8a: rettangolo di contenimento centrato sul giocatore // ============================================================================ static void ContainmentRect_init(ContainmentRect *r, float w, float h) { *r = (ContainmentRect){ 0 }; r->index = 1; r->width = game_width * w; r->height = game_height * h; r->halfWidth = 0.5f * r->width; r->halfHeight = 0.5f * r->height; } static int rect_contains(const ContainmentRect *r, float x, float y) { // Phaser.Geom.Rectangle.Contains if (r->width <= 0 || r->height <= 0) return 0; return r->x <= x && r->x + r->width >= x && r->y <= y && r->y + r->height >= y; } static void ContainmentRect_AdjustPosition(ContainmentRect *r) { r->x = Core.Player->s.x - r->halfWidth; r->y = Core.Player->s.y - r->halfHeight; } static int ContainmentRect_Contains(ContainmentRect *r, Sprite *s) { ContainmentRect_AdjustPosition(r); return rect_contains(r, s->x, s->y); } // ============================================================================ // 0x869f: Player // ============================================================================ // 0x6508: onda tra min e max (Linear(1, max, sine) sopra lo zero, Linear(1, min, -sine) sotto), sine -1 -> 1 in yoyo Sine.easeInOut typedef struct Sine { float min, max, duration, sine; } Sine; static float Sine_value(const Sine *s) { return s->sine > 0 ? 1 + (s->max - 1) * s->sine : 1 + (s->min - 1) * -s->sine; } static Sine *Sine_New(float mn, float mx, float duration) { // new Sine senza Start: sine 0, il valore resta 1 Sine *s = gmem_calloc(1, sizeof(Sine)); *s = (Sine){ mn, mx, duration, 0 }; return s; } static Sine *Sine_Start(float mn, float mx, float duration) { Sine *s = gmem_calloc(1, sizeof(Sine)); *s = (Sine){ mn, mx, duration, -1 }; tweens_add((TweenConfig){ .props = { { &s->sine, NULL, 1 } }, .nprops = 1, .duration = duration, .yoyo = 1, .ease = Ease_SineInOut, .repeat = -1 }); return s; } static float sinev(const Sine *s) { return s ? Sine_value(s) : 1; } // Arcanas (0x30b5): la parte che il resto del codice legge static struct { int active[22], n; // ActiveArcanas, in ordine di arrivo (T00 .. T21) int order[22]; float CritMul, xpMultiplier, silentCooldown, silentMight, bloodlineArmorValue, bloodlineMaxHpBonus, bloodlineDamage, divineBloodlineHPBonusUnit; int MaxArcanasPerRun, minTreasureChestLevel, pewpew, HealOnCoins, CoinFever, MadGroove, canGather, hasSilentSanctuary, hasWickedSeason, hasDivineBloodline, hasAstronomia; const char *beginning[16]; int n_beginning; struct { float seasonTime, seasonDuration, growth, luck, curse, greed; int seasonIndex; } wickedSeason; // 0x13661 Weapon *ArcanaWeapons[8], *FireExplosionWeapon, *ColdExplosionWeapon, *SarabandeWeapon, *DivineBloodlineWeapon, *BloodAstronomiaWeapon, *GemCannonWeapon; // armi nascoste delle arcane: Update dal gestore int n_ArcanaWeapons; } Arcanas; static void Arcanas_TriggerFire(float x, float y); static void Arcanas_TriggerCold(float x, float y); static void Arcanas_TriggerSarabande(float v); static void Arcanas_IncreaseBloodlineBonus(void); static void Arcanas_TriggerAstronomia(Weapon *w); static void Arcanas_TriggerGemCannon(float value, const Frame *frame); static int Arcanas_has(int t) { return t >= 0 && t < 22 && Arcanas.active[t]; } // ActiveArcanas.indexOf(t) > -1 static float Player_PCurse(Player *p) { return p->curse * Arcanas.wickedSeason.curse; } static void Foscari_dev(void *ctx); static void Foscari_MakeLevelOne(Player *p), Foscari_LevelUp(Player *p), Foscari_Update(Player *p, float delta), Foscari_OnLastBreath(Player *p), Foscari_AfterFullInit(Player *p), Lum_Revive(Player *p); static float Player_PGrowth(Player *p) { return p->growth * Arcanas.wickedSeason.growth; } static float Player_PLuck(Player *p) { return p->luck * Arcanas.wickedSeason.luck; } static float Player_PGreed(Player *p) { return p->greed * Arcanas.wickedSeason.greed; } static int Player_is(Player *p, const char *t); static float Player_PArmor(Player *p) { return Player_is(p, "PANINI") ? p->armor : fminf(0x32, p->armor + (Player_is(p, "VICTOR") ? p->armorBonus : 0)); } // 0x8ad5: senza tetto static void Player_setIsInvul(Player *p, int v) { if (p->_invul != v) { p->_invul = v; if (v) sprite_setTintFill(&p->s, 0xffffbb); else sprite_clearTint(&p->s); } } static void Player_restoreTint(void *ctx) { Player *p = ctx; sprite_setTint(&p->s, 0xffffff); p->receivingDamage = 0; } static void Player_blinkEnd(void *ctx) { Player *p = ctx; Player_restoreTint(p); emitter_stop(p->PfxEmitter); } static int Player_is(Player *p, const char *t); static void Player_OnGetDamaged_base(Player *p, unsigned tint, float dur, int showPfx); static void Scorej_canRetaliate(void *ctx); static void Weapon_Fire(Weapon *w); static void Player_OnGetDamaged(Player *p, unsigned tint, float dur, int showPfx) { if (Player_is(p, "VICTOR") && !p->receivingDamage) p->armorBonus += 1, p->armorTime = fmaxf(0, p->armorTime - 0x3e8); // 0x2470: AddArmor dopo super if (Player_is(p, "SIGMA")) { // 0xa802: niente lampo di colore; scintille dal petto, senza pavimento nuovo if (p->receivingDamage) return; p->_blinkTimeout = time_addEvent(dur, 0, 0, Player_blinkEnd, p); if (showPfx) { p->PfxEmitter->x = p->s.x, p->PfxEmitter->y = p->s.y - 0x10; emitter_start(p->PfxEmitter); Sound_PlaySound("Hit", 0.4f, 1, 0x3e8 + 0x1f4 * frand(), 0x96, 3); Sound_PlaySound("LossSFX", 0.1f, 1, -0x1f4 * frand() - 0x1f4, 0x1c2, 1); } p->receivingDamage = 1; return; } if (Player_is(p, "SCOREJ") && !p->receivingDamage) { // 0x17fe3: dopo il colpo normale, i Lightning nascosti sparano (una volta al secondo) p->receivingDamage = 0; Player_OnGetDamaged_base(p, tint, dur, showPfx); time_addEvent(0x3e8, 0, 0, Scorej_canRetaliate, p); // _retaliationTimeout: uno per colpo if (!p->cantRetaliate) { p->cantRetaliate = 1; for (int i = 0; i < Core.n_HiddenWeapons; i++) if (!strcmp(Core.HiddenWeapons[i]->bulletType, "LIGHTNING")) Weapon_Fire(Core.HiddenWeapons[i]); } return; } Player_OnGetDamaged_base(p, tint, dur, showPfx); } static void Player_OnGetDamaged_base(Player *p, unsigned tint, float dur, int showPfx) { if (!p->receivingDamage) { sprite_setTintFill(&p->s, tint); p->_blinkTimeout = time_addEvent(dur, 0, 0, Player_blinkEnd, p); // 'Blink' if (showPfx) { // gocce dal punto colpito, pavimento 200 px piu' in basso p->PfxEmitter->boundsY = p->s.y + 0xc8; p->PfxEmitter->x = p->s.x, p->PfxEmitter->y = p->s.y - 8; emitter_start(p->PfxEmitter); Sound_PlaySound("Hit", 0.4f, 1, 0x3e8 + 0x1f4 * frand(), 0x96, 3); Sound_PlaySound("LossSFX", 0.1f, 1, -0x1f4 * frand() - 0x1f4, 0x1c2, 1); } p->receivingDamage = 1; } } static void Player_PlayDeadAnimation(Player *p) { time_removeEvent(p->_blinkTimeout); tween_pause(p->wiggleTween); sprite_setTintFill(&p->s, 0xff0000); if (p->noHurt) { // Tatanka: si rimpicciolisce e il fantasma sale ondeggiando tweens_add((TweenConfig){ .props = { { &p->s.scaleX, &p->s.scaleY, 0 } }, .nprops = 1, .duration = 0x3e8, .ease = Ease_BounceOut }); static Sprite ghost; sprite_init(&ghost, p->s.frame, p->s.x, p->s.y); ghost.originX = p->s.originX, ghost.originY = p->s.originY, ghost.flipX = p->s.flipX; sprite_setScale(&ghost, p->s.scaleX); sprite_setTintFill(&ghost, 0xddddff); children_add(&ghost); tweens_add((TweenConfig){ .props = { { &ghost.scaleX, &ghost.scaleY, 0 }, { &ghost.y, NULL, p->s.y - 0x60 } }, .nprops = 2, .duration = 0x5dc }); tweens_add((TweenConfig){ .props = { { &ghost.x, NULL, p->s.x + 0x18 } }, .nprops = 1, .duration = 0xfa, .ease = Ease_SineInOut, .repeat = 3, .yoyo = 1 }); } else { tweens_add((TweenConfig){ .props = { { &p->s.scaleX, NULL, 2 * PixelScale } }, .nprops = 1, .duration = 0x3e8, .ease = Ease_BounceOut }); tweens_add((TweenConfig){ .props = { { &p->s.scaleY, NULL, 0 } }, .nprops = 1, .duration = 0x3e8 }); } p->PfxEmitter->boundsY = p->s.y - 2; p->PfxEmitter->x = p->s.x, p->PfxEmitter->y = p->s.y - 8; emitter_start(p->PfxEmitter); } static void Player_pfxStop(void *ctx) { emitter_stop(((Player *)ctx)->PfxEmitter); } static void SceneManager_GameOver(void *ctx), SceneManager_AfterDeath(void *ctx); static void Sigma_pfxFollow(void *ctx) { Player *p = ctx; p->PfxEmitter->x = p->s.x, p->PfxEmitter->y = p->s.y - 0x10; } static void Sigma_victory(void *ctx) { (void)ctx; Sound_PlaySound("Victory2", 2, 1, 0, 0, 0); } static void Sigma_OnDeath(Player *p) { // 0xa802: si allarga, poi una colonna di luce time_removeEvent(p->_blinkTimeout); tween_pause(p->wiggleTween); sprite_setTintFill(&p->s, 0xffffbb); tweens_add((TweenConfig){ .props = { { &p->s.scaleX, NULL, 2 } }, .nprops = 1, .duration = 0x2ee, .onUpdate = Sigma_pfxFollow, .ctx = p }); tweens_add((TweenConfig){ .props = { { &p->s.scaleX, NULL, 0 } }, .nprops = 1, .delay = 0x2ee, .duration = 0x64 }); tweens_add((TweenConfig){ .props = { { &p->s.scaleY, NULL, 0.5f } }, .nprops = 1, .duration = 0x2ee }); tweens_add((TweenConfig){ .props = { { &p->s.scaleY, NULL, 8 } }, .nprops = 1, .delay = 0x2ee, .duration = 0x64, .onStart = Sigma_victory }); p->PfxEmitter->x = p->s.x, p->PfxEmitter->y = p->s.y - 0x10; emitter_start(p->PfxEmitter); time_addEvent(0x2ee, 0, 0, Player_pfxStop, p); time_addEvent(0x4e2, 0, 0, SceneManager_AfterDeath, NULL); } static void MegaMenya_victory(void *ctx) { (void)ctx; Sound_PlaySound("Victory2", 2, 1, 0, 0, 0); } static void Player_OnDeath(Player *p) { if (Player_is(p, "SIGMA")) { Sigma_OnDeath(p); return; } if (Player_is(p, "MEGAMENYA")) { // 0x2eb8: si comprime e scoppia in verticale time_removeEvent(p->_blinkTimeout); tween_pause(p->wiggleTween); sprite_setTintFill(&p->s, 0xbbffff); tweens_add((TweenConfig){ .props = { { &p->s.scaleX, NULL, 2 }, { &p->s.scaleY, NULL, 0.5f } }, .nprops = 2, .duration = 0x2ee }); tweens_add((TweenConfig){ .props = { { &p->s.scaleX, NULL, 0 }, { &p->s.scaleY, NULL, 8 } }, .nprops = 2, .duration = 0x64, .delay = 0x2ee }); time_addEvent(0x2ee, 0, 0, MegaMenya_victory, NULL); time_addEvent(0x4e2, 0, 0, SceneManager_AfterDeath, NULL); return; } Player_PlayDeadAnimation(p); time_addEvent(0xfa, 0, 0, Player_pfxStop, p); time_addEvent(0x4e2, 0, 0, SceneManager_AfterDeath, NULL); } static void Player_Die(Player *p) { p->isDead = 1; p->s.body.enable = 0; if (Players_n > 1 && !Slots[Slots[1].player == p ? 0 : 1].player->isDead) { // l'altro continua: si rinasce al prossimo level-up Player_PlayDeadAnimation(p); time_addEvent(0xfa, 0, 0, Player_pfxStop, p); // come in singolo: il sangue si ferma dopo 250 ms return; } Player_OnDeath(p); } static void Player_Revive(Player *p, float k); static void Players_reviveAtLevelUp(void) { // il compagno caduto torna con meta' vita for (int i = 0; i < Players_n; i++) { Player *p = Slots[i].player; if (p->isDead) game_context_set(i), Player_Revive(p, 0.5f); } } // scene.events: 'Player_ReceivedDamage' / 'Player_LostShield' (ascoltati dalle armi di ritorsione) enum { EV_PLAYER_RECEIVEDDAMAGE, EV_PLAYER_LOSTSHIELD }; static struct { Callback fn; void *ctx; int player; } PlayerEvents[2][16]; static int n_PlayerEvents[2]; static void PlayerEvents_add(int ev, Callback fn, void *ctx) { if (n_PlayerEvents[ev] < 16) PlayerEvents[ev][n_PlayerEvents[ev]].fn = fn, PlayerEvents[ev][n_PlayerEvents[ev]].player = game_context, PlayerEvents[ev][n_PlayerEvents[ev]++].ctx = ctx; } static float PlayerEvents_arg; // emit(evento, valore): il danno per 'Player_LostShield' static void PlayerEvents_remove(void *ctx) { // removeListener di tutte le registrazioni di quell'oggetto for (int ev = 0; ev < 2; ev++) for (int i = n_PlayerEvents[ev] - 1; i >= 0; i--) if (PlayerEvents[ev][i].ctx == ctx) memmove(&PlayerEvents[ev][i], &PlayerEvents[ev][i + 1], (--n_PlayerEvents[ev] - i) * sizeof(PlayerEvents[ev][0])); } static void PlayerEvents_emit(int ev) { for (int i = 0; i < n_PlayerEvents[ev]; i++) if (PlayerEvents[ev][i].player == game_context) PlayerEvents[ev][i].fn(PlayerEvents[ev][i].ctx); // le armi di chi ha preso il colpo } static int Player_GetDamaged(Player *p, float amount) { if (Player_is(p, "MEGAMENYA")) Player_setIsInvul(p, 1); // 0x2eb8: IsInvul prima di super if (getenv("VS_GOD")) return 0; // sviluppo: il giocatore non prende danno if (p->receivingDamage) return 0; if (p->_invul) return 0; if (p->hp <= 0) return 0; if (p->shields > 0) { p->shields -= 1; Player_OnGetDamaged(p, 0xffffbb, p->shieldInvulTime, 0); PlayerEvents_arg = amount; PlayerEvents_emit(EV_PLAYER_LOSTSHIELD); return 0; } StageModifiers *sm = &Core.Stage->StageModifiers; if (sm->EndCycles > 0 && (amount *= 1 + 0.25f * sm->EndCycles) > p->maxHp) amount = fmaxf(10, p->maxHp - 1); float shroud = p->shroud - sm->EndCycles; if (shroud > 0) amount = fminf(shroud, amount); if (p->armor > 0 && (amount -= p->armor) < 1) amount = 1; p->hp -= amount; if (p->hp <= 0) { if (p->isLastBreathEnabled && p->hasLastBreath) { p->hp = 0; p->hasLastBreath = 0; Foscari_OnLastBreath(p); } else { p->hp = 0; Player_Die(p); } // Core.GameOver(): vuoto } else { Player_OnGetDamaged(p, 0xff0000, 0x78, 1); PlayerEvents_emit(EV_PLAYER_RECEIVEDDAMAGE); } PlayerUI_Update(); return 1; } static void Core_ShowDamageAt(float x, float y, float amount); static void Core_ShowRecoveryAt(float x, float y, float amount); static void Player_RecoverHp(Player *p, float v, int show, int regenScale) { if (p->isDead) return; if (Player_is(p, "MIANG")) { // 0x13111: la Ripresa moltiplica ogni cura; oltre il massimo sale il massimo v *= 1 + p->regen; if (Arcanas_has(6)) v *= 2, Arcanas_TriggerSarabande(v); if (p->onHPRecovery) p->onHPRecovery->recoveredHP += v; p->hp += v; if (p->hp > p->maxHp) p->hp = p->maxHp, p->maxHp += 0.2f; PlayerUI_Update(); if (v < 0x2328) PlayerOptions_AddHeal(v); if (show) Core_ShowRecoveryAt(Core.Player->s.x, Core.Player->s.y, v); return; } v *= regenScale ? 1 + p->regen : 1; if (Arcanas_has(6)) v *= 2, Arcanas_TriggerSarabande(v); // Sarabande of Healing: cura doppia e anello che ferisce float h = fminf(p->maxHp - p->hp, v); if (p->onHPRecovery) p->onHPRecovery->recoveredHP += h; p->hp += h; if (p->hp > p->maxHp) p->hp = p->maxHp; PlayerUI_Update(); if (v < 0x2328) PlayerOptions_AddHeal(v); if (show) Core_ShowRecoveryAt(Core.Player->s.x, Core.Player->s.y, v); } static void Player_Regenerate(void *ctx) { Player *p = ctx; if (p->regen > 0) Player_RecoverHp(p, p->regen, 0, 0); } static void Player_SetInvulForMilliSeconds(Player *p, float ms) { Player_setIsInvul(p, 1); p->invulTime += ms; } static void Player_AddXP(Player *p, float v) { float gain = v * ExperienceMultiplier * Arcanas.xpMultiplier; p->xp += gain; if (Players_n > 1) Slots[game_context ? 0 : 1].player->xp += gain; // l'esperienza e' di tutti e due } // Le statistiche numeriche che Player possiede (this.hasOwnProperty) e che le tabelle possono toccare static float *Player_field(Player *p, const char *k) { static const struct { const char *k; size_t off; } F[] = { #define P(x) { #x, offsetof(Player, x) } P(radius), P(hp), P(xp), P(maxHp), P(power), P(area), P(speed), P(cooldown), P(amount), P(moveSpeed), P(growth), P(duration), P(luck), P(shields), P(armor), P(greed), P(regen), P(shieldInvulTime), P(revivals), P(rerolls), P(skips), P(banish), P(curse), P(charm), P(shroud), P(exLevels), P(magnet), #undef P }; for (size_t i = 0; i < sizeof(F) / sizeof(F[0]); i++) if (!strcmp(F[i].k, k)) return (float *)((char *)p + F[i].off); return NULL; } static void Magnet_RefreshSize(Magnet *m) { body_setCircle(&m->s.body, m->radius, -m->radius, -m->radius); } // Le sottoclassi del Player (CharacterFactory 0x591a) che contano nel gioco base; MARIA/TATANKA (0x17995) cambiano solo ad Halloween static int Player_is(Player *p, const char *t) { return p->characterType && !strcmp(p->characterType, t); } static void Arcanas_Add(int t); // --- Arengijus (0x3e32): statistiche per livello e onde casuali, pesate dall'alias (nameIndex) --- static const char *const *Weapon_baseList(int *n); static void Arengijus_pickWeapon(cJSON *d) { // RND.pick(getBaseWeapons()) || WHIP, scritto nei dati del personaggio int n; const char *const *b = Weapon_baseList(&n); const char *w = n ? b[(int)floorf(frand() * n)] : "WHIP"; cJSON *sw = cJSON_GetObjectItem(d, "startingWeapon"); if (sw) cJSON_ReplaceItemInObject(d, "startingWeapon", cJSON_CreateString(w)); else cJSON_AddStringToObject(d, "startingWeapon", w); } static void Arengijus_setupRNJ(void) { // CharacterSelection.setupRNJ (alla scelta del personaggio) cJSON *d = cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("characters"), "ARENGIJUS"), 0); if (!d) return; if (po_num("PlayedRNJ") > 0) { static char names[512]; snprintf(names, sizeof(names), "%s", tr("arengijus_aliases")); const char *list[16]; int n = 0; for (char *t = strtok(names, ","); t && n < 16; t = strtok(NULL, ",")) list[n++] = t; if (n) { int k = (int)floorf(frand() * n); cJSON_ReplaceItemInObject(d, "charName", cJSON_CreateString(list[k])); // (sic) con lo spazio dopo la virgola, come split(',') cJSON *ni = cJSON_GetObjectItem(d, "nameIndex"); if (ni) cJSON_SetNumberValue(ni, k); else cJSON_AddNumberToObject(d, "nameIndex", k); } } Arengijus_pickWeapon(d); } static void Arengijus_MakeLevelOne(Player *p) { cJSON *d = cJSON_GetArrayItem(p->data, 0); float a = 1, b = 1, c = 1, dl = 1, e = 1, f = 1, g = 1; // sine min, sine max, speed, luck, curse, armor/amount, maxHp/power cJSON *sw = cJSON_GetObjectItem(d, "startingWeapon"); if (!cJSON_IsString(sw) || !strcmp(sw->valuestring, "VOID")) Arengijus_pickWeapon(d); // (sic) dopo la copia: vale dalla partita dopo switch ((int)num(d, "nameIndex", 0)) { case 1: a = 1.5f, g = 0.5f; break; case 2: b = 1.5f, e = 0.5f; break; case 3: c = 1.5f, a = 0.5f; break; case 4: dl = 1.5f, b = 0.5f; break; case 5: e = 1.5f, dl = 0.5f; break; case 6: f = 1.5f, c = 0.5f; break; case 7: g = 1.5f, f = 0.5f; break; } struct { const char *k; float v; } L[16] = { { "maxHp", 1 * (frand() - 0.025f) * g }, { "regen", 0.01f * (frand() - 0.1f) * g }, { "armor", 0.01f * (frand() - 0.1f) * f }, { "amount", 0.01f * (frand() - 0.1f) * f }, { "revivals", 0.01f * (frand() - 0.1f) * f }, { "magnet", 0.03f * (frand() - 0.1f) * f }, { "speed", 0.01f * (frand() - 0.1f) * c }, { "moveSpeed", 0.01f * (frand() - 0.2f) * c }, { "power", 0.01f * (frand() - 0.1f) * g }, { "cooldown", -0.005f * (frand() - 0.05f) }, { "area", 0.01f * (frand() - 0.1f) * g }, { "duration", 0.01f * (frand() - 0.1f) * g }, { "luck", 0.01f * (frand() - 0.1f) * dl }, { "growth", 0.01f * (frand() - 0.1f) }, { "greed", 0.01f * (frand() - 0.1f) }, { "curse", 0.01f * (frand() - 0.025f) * e } }; p->n_onEveryLevelUp = 0; // onEveryLevelUp = {} for (int i = 0; i < 16; i++) p->onEveryLevelUp[p->n_onEveryLevelUp].k = L[i].k, p->onEveryLevelUp[p->n_onEveryLevelUp++].v = L[i].v; // new Sine(...) senza Start: valgono 1 (sic); occupano pero' il posto delle onde di Chaos, Painting e Illusions Sine **S[5] = { &p->sineMight, &p->sineSpeed, &p->sineDuration, &p->sineArea, &p->sineCooldown }; for (int i = 0; i < 5; i++) { float mn = 2 * (0.1f + frand()) * a, mx = 2 * (0.1f + frand()) * b; *S[i] = Sine_New(mn, mx, 0xea60 * (0.1f + frand())); } po_add("PlayedRNJ", 1); } static void make_anim(Animation *a, const char *atlas, const char *prefix, int start, int end, int pad, float fps, int repeat); // PlayerOptions.CollectedItems.indexOf(item) > -1 (sviluppo: VS_RELICS="RELIC_ROSALIA,RELIC_MALACHITE") static int Collected(const char *item) { const char *e = getenv("VS_RELICS"); return po_has("CollectedItems", item) || (e && strstr(e, item)); } // MorphVFX (0xa6c): lampo, disco, stella e schermo scuro della trasformazione typedef struct { Sprite spark, ring, dark, burst; Animation enter; float x, y; int made; TweenRef ringTween, darkTween, sparkTween; } MorphVFX; static MorphVFX morphVfx; static void MorphVFX_Make(int darkOrigin0) { // darkOrigin0: la copia dentro Mortaccio ha setOrigin(0) (sic) MorphVFX *m = &morphVfx; if (m->made) return; m->made = 1, m->x = 0.5f * game_width, m->y = 0.5f * game_height; m->ringTween = m->darkTween = m->sparkTween = (TweenRef){ -1, 0 }; sprite_init(&m->spark, frame_get("vfx", "blurredSharpStar.png"), m->x, m->y), m->spark.alpha = 0, sprite_setScale(&m->spark, 0), m->spark.blendAdd = 1, m->spark.depth = game_height; sprite_init(&m->ring, frame_get("vfx", "disc.png"), m->x, m->y), m->ring.alpha = 0, sprite_setScale(&m->ring, 0), m->ring.blendAdd = 1, m->ring.depth = game_height; sprite_init(&m->dark, frame_get("vfx", "blackDot.png"), m->x, m->y), m->dark.alpha = 0, m->dark.scaleX = game_width, m->dark.scaleY = game_height; if (darkOrigin0) sprite_setOrigin(&m->dark, 0, 0); m->dark.depth = game_height - 1, m->dark.scrollFactor0 = 1; sprite_init(&m->burst, frame_get("vfx", "Burst1.png"), 0.5f * game_width, 0.5f * game_height), m->burst.alpha = 0, sprite_setScale(&m->burst, 0xa), m->burst.blendAdd = 1; m->burst.depth = game_height, m->burst.scrollFactor0 = 1, m->burst.tint = 0xff00; // semplificazione: setTint a 4 angoli (verde, blu, giallo, rosso): qui il primo children_add(&m->spark), children_add(&m->ring), children_add(&m->dark), children_add(&m->burst); make_anim(&m->enter, "vfx", "Burst", 1, 6, 0, 0x1e, 0); } static void MorphVFX_follow(void *ctx) { (void)ctx; MorphVFX *m = &morphVfx; m->spark.x = m->ring.x = m->x, m->spark.y = m->ring.y = m->y - 0x14; } static void MorphVFX_done(void *ctx) { (void)ctx; morphVfx.ring.alpha = morphVfx.spark.alpha = 0; } static void MorphVFX_PlaySparkle(void) { MorphVFX *m = &morphVfx; anims_play(&m->burst, &m->enter, 0), m->burst.alpha = 1; m->x = Core.Player->s.x, m->y = Core.Player->s.y; m->ring.x = m->spark.x = m->x, m->ring.y = m->spark.y = m->y; tween_stop(m->ringTween), sprite_setScale(&m->ring, 0), m->ring.alpha = 1; m->ringTween = tweens_add((TweenConfig){ .props = { { &m->ring.scaleX, &m->ring.scaleY, 0xa }, { &m->ring.alpha, NULL, 0.1f } }, .nprops = 2, .duration = 0xc8 }); tween_stop(m->darkTween), m->dark.alpha = 0; m->darkTween = tweens_add((TweenConfig){ .props = { { &m->dark.alpha, NULL, 0.65f } }, .nprops = 1, .duration = 0x64, .yoyo = 1 }); tween_stop(m->sparkTween), sprite_setScale(&m->spark, 0), m->spark.alpha = 1, m->spark.angle = 0; m->sparkTween = tweens_add((TweenConfig){ .props = { { &m->spark.scaleX, &m->spark.scaleY, 0xa }, { &m->spark.alpha, NULL, 0.5f }, { &m->spark.angle, NULL, 0xb4 } }, .nprops = 3, .duration = 0xc8, .onUpdate = MorphVFX_follow, .onComplete = MorphVFX_done, .ctx = m }); } static void Player_SetMaxHistory(Player *p, int n) { p->maxHistory = n, p->historyIndex = 0; for (int i = 0; i <= n; i++) p->posHistory[i] = (Vector2){ Core.Player->s.x, Core.Player->s.y }; } // --- Cavallo (0x452f): dal livello 80, con la reliquia Rosalia, diventa la mucca Yatta e prende Cherry Stars --- static Weapon *Core_AddWeapon(const char *type, int removeFromStore); static void W_Cherry_SetToStars(Weapon *w); static void Cavallo_Morph(Player *p) { if (p->isMorphed) return; MorphVFX_Make(0), MorphVFX_PlaySparkle(); p->isMorphed = 1; Sound_PlaySound("Morph", 1, 0.5f, 0, 0x7d0, 1); Weapon *c = Core_AddWeapon("CHERRY2", 1); // OnStop = MorphedOnStop: vedi Player_OnStop if (c) W_Cherry_SetToStars(c), c->chance = 1; body_setOffset(&p->s.body, 0x1e, 0x3e); anims_stop(&p->s); sprite_setFrame(&p->s, frame_get("characters", "yattaCowi01.png")); make_anim(&p->walk2, "characters", "yattaCowi0", 1, 4, 0, 8, -1); anims_play(&p->s, &p->walk2, 0); Player_SetMaxHistory(p, 1); p->amount += 1, p->armor += 2, p->maxHp += 0x64, p->luck += 0.25f, p->hp = p->maxHp; } // --- Mortaccio (0x182a4): dal livello 80, con la reliquia Malachite, diventa lo scheletro gigante e prende Anima of Mortaccio --- static void Mortaccio_Morph(Player *p) { static Animation headIdle; if (p->isMorphed) return; Core_AddWeapon("BONE2", 1); // GiantBoneWeapon; boneWeapon (Weapons.find BONE) non e' mai usato body_setOffset(&p->s.body, 0x10, 0x20); Sound_PlaySound("Morph", 1, 0.5f, 0, 0x7d0, 1); MorphVFX_PlaySparkle(); sprite_init(&p->head, frame_get("characters", "Gash_head_i01.png"), 0, 0), children_add(&p->head); // MakeBigSkeleton sprite_setOrigin(&p->head, 0, 0); if (!headIdle.n) make_anim(&headIdle, "characters", "Gash_head_i", 1, 5, 2, 0x18, -1); anims_play(&p->head, &headIdle, 0); p->isMorphed = 1; anims_stop(&p->s); sprite_setFrame(&p->s, frame_get("characters", "Gash_body_i01.png")); make_anim(&p->walk2, "characters", "Gash_body_i0", 1, 1, 0, 1, -1); anims_play(&p->s, &p->walk2, 0); Player_SetMaxHistory(p, 1); p->amount += 1, p->armor += 2, p->maxHp += 0x64, p->hp = p->maxHp; } // MARIA/TATANKA (0x17995): skin di Halloween solo con IsHalloween (Spell segreta); TATANKA nel Core: onCaneOverlapsEnemy scarta i nemici isStatic (nessuno nella Foresta) // --- DLC Moonspell: Menya, Syuuto, Onna, MegaMenya ------------------------------------------------------------------ static void Core_RosaryDamageEx(int vfx); static Weapon *Core_AddHiddenWeapon(const char *type); static void Core_RemoveHiddenWeapon(const char *type); static Weapon *Core_GetHiddenWeapon(const char *type); static void W_NightSword_SetAsRetaliatoryOnly(Weapon *w); static void Weapon_LevelUpNow(Weapon *w); static void Player_MakeWalk2(Player *p, const char *character) { // generateFrameNames coi dati del personaggio morfato + anims.create('walk2') cJSON *d = tbl0("characters", character); if (p->hasSecondAnim || !d) return; char prefix[64]; snprintf(prefix, sizeof(prefix), "%s", str(d, "spriteName")); char *e = strstr(prefix, "01.png"); if (e) *e = 0; sprite_setFrame(&p->s, frame_get(str(d, "textureName"), str(d, "spriteName"))); make_anim(&p->walk2, str(d, "textureName"), prefix, 1, (int)num(d, "walkingFrames", 0), 2, num(d, "walkFrameRate", 0) ? num(d, "walkFrameRate", 0) : 8, -1); p->hasSecondAnim = 1; } static void Menya_CalculateTreshold(Player *p) { static const int T[8] = { 0x1f4, 0x3e8, 0x7d0, 0xbb8, 0x1388, 0x1b58, 0x2710, 0x3a98 }; if (p->MorphedTimes >= 8) p->EnemiesTS = p->finalMorphedTimes * 0x2710, p->finalMorphedTimes++; else p->EnemiesTS = T[p->MorphedTimes]; } static void Menya_Unmorph(void *ctx) { Player *p = ctx; p->cooldown -= p->CooldownBonus, p->moveSpeed -= p->MoveBonus, p->power -= p->MightBonus, p->curse -= p->CurseBonus; anims_play(&p->s, &p->walk, 0); p->isMorphed = 0; Core_RemoveHiddenWeapon("BOCCE"); } static void Menya_Morph(Player *p) { if (p->isMorphed) return; Sound_PlaySound("Morph", 1, 0.5f, 0, 0x7d0, 1); Sound_PlaySound("Rosary", 1.5f, 1, 0, 0x7d0, 1); MorphVFX_PlaySparkle(); Core_RosaryDamageEx(0); Core_AddHiddenWeapon("BOCCE"); p->isMorphed = 1; p->MorphedTimes++; Menya_CalculateTreshold(p); Player_MakeWalk2(p, "MEGAMENYA"); anims_play(&p->s, &p->walk2, 0); p->CooldownBonus = -0.2f, p->MoveBonus = fmaxf(0, 2 - p->moveSpeed), p->MightBonus = 2, p->CurseBonus = 0.5f; p->cooldown += p->CooldownBonus, p->moveSpeed += p->MoveBonus, p->power += p->MightBonus, p->curse += p->CurseBonus; Player_SetInvulForMilliSeconds(p, 0x7530); p->s.tintFill = 0, p->s.tint = 0xffffff; // restoreTint time_addEvent(0x7530, 0, 0, Menya_Unmorph, p); } static void Syuuto_Morph(Player *p) { if (p->isMorphed) return; Sound_PlaySound("Morph", 1, 0.5f, 0, 0x7d0, 1); Sound_PlaySound("Bangu", 1, 1, 0, 0x7d0, 1); p->isMorphed = 1; MorphVFX_PlaySparkle(); int i; for (i = 0; i < p->n_onEveryLevelUp; i++) if (!strcmp(p->onEveryLevelUp[i].k, "power")) break; if (i < p->n_onEveryLevelUp) p->onEveryLevelUp[i].v += 0.01f; else if (p->n_onEveryLevelUp < 24) p->onEveryLevelUp[p->n_onEveryLevelUp].k = "power", p->onEveryLevelUp[p->n_onEveryLevelUp++].v = 0.01f; Player_MakeWalk2(p, "MEGASYUUTO"); anims_play(&p->s, &p->walk2, 0); p->armor += 2, p->area += 0.3f, p->speed += 0.3f, p->moveSpeed += 0.4f, p->maxHp += 0x64; Player_SetInvulForMilliSeconds(p, 0x64); } static void Character_LevelHiddenWeapon(Player *p, const char *type) { // un livello dell'arma nascosta ogni dieci del personaggio, fino all'ottavo Weapon *w = Core_GetHiddenWeapon(type); if (w && w->level < (int)floorf(p->level / 10.0f) && w->level < 8) Weapon_LevelUpNow(w); } static struct { Sprite spark, ring; float x, y; TweenRef ringTween, sparkTween; } OnnaVfx; static void Onna_follow(void *ctx) { Player *p = ctx; OnnaVfx.spark.x = OnnaVfx.ring.x = p->s.x, OnnaVfx.spark.y = OnnaVfx.ring.y = p->s.y - 0x14; } static void Onna_done(void *ctx) { (void)ctx; OnnaVfx.ring.alpha = OnnaVfx.spark.alpha = 0; } static void Onna_MakeLevelOne(Player *p) { for (int i = 0; i < 6; i++) p->onnaFrames[i] = frame_get("moonspellChars", TextFormat("onna_%02d.png", 3 * (i + 1))); sprite_init(&OnnaVfx.spark, frame_get("vfx", "blurredSharpStar.png"), p->s.x, p->s.y), OnnaVfx.spark.alpha = 0, sprite_setScale(&OnnaVfx.spark, 0), OnnaVfx.spark.blendAdd = 1, OnnaVfx.spark.depth = -1; sprite_init(&OnnaVfx.ring, frame_get("vfx", "sPFX_ring_64.png"), p->s.x, p->s.y), OnnaVfx.ring.alpha = 0, sprite_setScale(&OnnaVfx.ring, 0), OnnaVfx.ring.blendAdd = 1, OnnaVfx.ring.depth = -1; children_add(&OnnaVfx.spark), children_add(&OnnaVfx.ring); OnnaVfx.ringTween = OnnaVfx.sparkTween = (TweenRef){ -1, 0 }; } static void Onna_FireWeapons(Player *p) { // le armi sparano solo sui passi dell'animazione, una alla volta Weapon *list[16]; int n = 0; for (int i = 0; i < Core.n_weapons; i++) if (!Core.Weapons[i]->isPowerUp) list[n++] = Core.Weapons[i]; for (int i = 0; i < n; i++) time_removeEvent(list[i]->firingTimer); // RemoveFiringTimer if (++p->firingIndex >= n) p->firingIndex = 0; if (n) Weapon_Fire(list[p->firingIndex]); tween_stop(OnnaVfx.ringTween); sprite_setScale(&OnnaVfx.ring, 0), OnnaVfx.ring.alpha = 1; OnnaVfx.ringTween = tweens_add((TweenConfig){ .props = { { &OnnaVfx.ring.scaleX, &OnnaVfx.ring.scaleY, 1.5f }, { &OnnaVfx.ring.alpha, NULL, 0.1f } }, .nprops = 2, .duration = 0xfa, .ease = Ease_SineInOut }); tween_stop(OnnaVfx.sparkTween); sprite_setScale(&OnnaVfx.spark, 0), OnnaVfx.spark.alpha = 1, OnnaVfx.spark.angle = 0; OnnaVfx.sparkTween = tweens_add((TweenConfig){ .props = { { &OnnaVfx.spark.scaleX, &OnnaVfx.spark.scaleY, 2 }, { &OnnaVfx.spark.alpha, NULL, 0.5f }, { &OnnaVfx.spark.angle, NULL, 0xb4 } }, .nprops = 3, .duration = 0xfa, .ease = Ease_SineInOut, .onUpdate = Onna_follow, .onComplete = Onna_done, .ctx = p }); } static void Onna_LevelUp(Player *p) { // la camminata, e quindi il fuoco, accelera con la velocita' float m = p->moveSpeed, fps = m >= 1.6f ? 9 : m >= 1.5f ? 8 : m >= 1.4f ? 7 : m >= 1.3f ? 6 : m >= 1.2f ? 5 : 4; p->walk.frameRate = fps, p->walk.msPerFrame = 1000 / fps; anims_play(&p->s, &p->walk, 0); } static void Character_Update(Player *p) { // Update dopo super delle classi del DLC if (Player_is(p, "MENYA")) { if (Core.kills > p->EnemiesTS || (getenv("VS_MORPH") && !p->MorphedTimes)) Menya_Morph(p); // RunEnemies; VS_MORPH: sviluppo } else if (Player_is(p, "ONNA")) { const void *f = p->s.frame; // ANIMATION_UPDATE if (f != p->lastAnimFrame) { p->lastAnimFrame = f; for (int i = 0; i < 6; i++) if (f == p->onnaFrames[i]) Onna_FireWeapons(p); } } else if (Player_is(p, "MEGAMENYA") && !p->megaDead && Core.SurvivedSeconds >= Core.Stage->StageModifiers.TimeLimit) { p->megaDead = 1; // l'originale la richiama a ogni fotogramma oltre il limite: qui una volta, il risultato e' lo stesso Player_OnDeath(p); } } static void Player_MakeLevelOne_char(Player *p) { if (IsHalloween && (Player_is(p, "MARIA") || Player_is(p, "TATANKA"))) { // 0x17995: camminata 'h' + nome dello sprite della skin cJSON *base = cJSON_GetArrayItem(p->data, 0), *skin = base, *sk; cJSON_ArrayForEach(sk, cJSON_GetObjectItem(base, "skins")) if (num(sk, "id", -1) == num(base, "currentSkinIndex", 0)) { skin = sk; break; } if (num(skin, "walkingFrames", 0)) { sprite_setFrame(&p->s, frame_get(str(skin, "textureName"), str(skin, "spriteName"))); p->HasWalkingAnimation = 1; char prefix[96]; snprintf(prefix, sizeof(prefix), "h%s", str(skin, "spriteName")); char *q = strstr(prefix, "01.png"); if (q) *q = 0; p->walk.n = anims_generateFrameNames(str(skin, "textureName"), prefix, 1, (int)num(skin, "walkingFrames", 0), 2, p->walk.frames, ANIM_MAX_FRAMES); p->walk.frameRate = has(skin, "walkFrameRate") ? num(skin, "walkFrameRate", 8) : 8; p->walk.msPerFrame = 1000.0f / p->walk.frameRate; p->walk.repeat = -1; anims_play(&p->s, &p->walk, 0); anims_pause(&p->s); } } Foscari_MakeLevelOne(p); if (Player_is(p, "ARENGIJUS")) Arengijus_MakeLevelOne(p); if (Player_is(p, "CAVALLO")) { p->isMorphed = 0, morphVfx.made = 0; if (Collected("RELIC_ROSALIA")) MorphVFX_Make(0); } if (Player_is(p, "MORTACCIO")) p->isMorphed = 0, morphVfx.made = 0, MorphVFX_Make(1); if (Player_is(p, "MENYA")) { p->MorphedTimes = 0, p->finalMorphedTimes = 2, p->isMorphed = 0, p->hasSecondAnim = 0; p->MoveBonus = p->MightBonus = p->CooldownBonus = p->CurseBonus = 0; Menya_CalculateTreshold(p); morphVfx.made = 0, MorphVFX_Make(1); } if (Player_is(p, "SYUUTO")) { p->isMorphed = 0, p->hasSecondAnim = 0; morphVfx.made = 0, MorphVFX_Make(1); morphVfx.dark.depth = game_height - 2, morphVfx.burst.depth = game_height - 1; morphVfx.burst.blendAdd = 0, morphVfx.burst.tint = 0x2a002a; // semplificazione: quattro angoli (0x220000, 0x880000, 0x22, 0x88) reso col colore medio } if (Player_is(p, "ONNA")) Onna_MakeLevelOne(p); p->megaDead = 0; if (Player_is(p, "PANTALONE")) p->gfeverMul = 1.5f; // 0x2968 if (Player_is(p, "SIGMA")) { // 0xa802: scintille chiare in tutte le direzioni ParticleEmitter *e = p->PfxEmitter; e->c.angle = ERND(0, 0x168), e->c.gravityY = 0, e->c.tint = 0xffffbb, e->c.collideBottom = 0; } if (Player_is(p, "AVATAR")) { // 0x17d7d: scintille di fuoco in tutte le direzioni, Heart of Fire da subito e un'arcana in piu' ParticleEmitter *e = p->PfxEmitter; e->c.angle = ERND(0, 0x168), e->c.gravityY = 0, e->c.tint = 0xffffbb, e->c.tintEnd = 0xff0000, e->c.hasTintEnd = 1, e->c.collideBottom = 0; Arcanas_Add(19); // ActiveArcanas.push(T19) + TriggerArcana(T19) Arcanas.MaxArcanasPerRun += 1; if (!po_has("UnlockedWeapons", "MISSPELL")) po_push("UnlockedWeapons", "MISSPELL"); } } static Sine *Player_sine(cJSON *d, const char *k) { // ActivateSine*Bonus: new Sine con min/max/duration dei dati + Start cJSON *o = cJSON_GetObjectItem(d, k); return o ? Sine_Start(num(o, "min", 0), num(o, "max", 0), num(o, "duration", 0)) : NULL; } static void Player_MakeLevelOne(Player *p) { p->level = 0; p->shieldInvulTime = 0xf0; p->gfeverMul = 1; cJSON *d = cJSON_GetArrayItem(p->data, p->level); for (cJSON *it = d ? d->child : NULL; it; it = it->next) { if (!strcmp(it->string, "level") && cJSON_IsNumber(it)) { p->level = it->valueint; continue; } if (!strcmp(it->string, "startingWeapon")) { p->startingWeapon = cJSON_IsString(it) ? it->valuestring : NULL; continue; } // 0 = VOID: nessuna arma if (!strcmp(it->string, "exWeapons")) { p->exWeapons = it; continue; } if (!strcmp(it->string, "hiddenWeapons")) { p->hiddenWeapons = it; continue; } float *f = Player_field(p, it->string); if (f && cJSON_IsNumber(it)) *f = (float)it->valuedouble; } p->hp = p->maxHp; float magnet = num(d, "magnet", 0); if (magnet > 0) { Core.Magnet->radius += Core.Magnet->radius * magnet; Magnet_RefreshSize(Core.Magnet); Core.Magnet->percentage += magnet; } cJSON *bo = cJSON_GetObjectItem(d, "bodyOffset"); if (bo) body_setOffset(&p->s.body, num(bo, "x", 0), num(bo, "y", 0)); // ordine dell'originale: speed, cooldown, area, duration, might (Graziella ha tutti e cinque) if (has(d, "sineSpeed")) p->sineSpeed = Player_sine(d, "sineSpeed"); if (has(d, "sineCooldown")) p->sineCooldown = Player_sine(d, "sineCooldown"); if (has(d, "sineArea")) p->sineArea = Player_sine(d, "sineArea"); if (has(d, "sineDuration")) p->sineDuration = Player_sine(d, "sineDuration"); if (has(d, "sineMight")) p->sineMight = Player_sine(d, "sineMight"); if (cJSON_IsTrue(cJSON_GetObjectItem(d, "noHurt"))) p->noHurt = 1, p->PfxEmitter->c.tint = 0xffffff; // plsNoHurt p->n_onEveryLevelUp = 0; // onEveryLevelUp = {} + i valori del personaggio cJSON *ev = cJSON_GetObjectItem(d, "onEveryLevelUp"), *e; cJSON_ArrayForEach(e, ev) if (cJSON_IsNumber(e) && p->n_onEveryLevelUp < 24) p->onEveryLevelUp[p->n_onEveryLevelUp].k = e->string, p->onEveryLevelUp[p->n_onEveryLevelUp++].v = (float)e->valuedouble; Player_MakeLevelOne_char(p); } static Weapon *Core_GetHiddenWeapon(const char *type); static int Weapon_LevelUp(Weapon *w); static int Arcana_unlockedCount(void); static int RandomazzoEnabled(void); static Weapon *Core_AddHiddenWeapon(const char *type); // --- Scorej (0x17fe3): i Lightning nascosti crescono di numero e di livello; rispondono ai colpi --- static int Scorej_lightnings(Weapon **out) { int n = 0; for (int i = 0; i < Core.n_HiddenWeapons; i++) if (!strcmp(Core.HiddenWeapons[i]->bulletType, "LIGHTNING")) out[n++] = Core.HiddenWeapons[i]; return n; } static struct { Sprite s; float tx, ty, delay; } ScorejRings[12]; // semplificazione: 12 immagini riusate in giro (l'originale ne crea di nuove) static int ScorejRing_next; static void ScorejRing_hide(void *ctx) { ((Sprite *)ctx)->visible = 0; } static void ScorejRing_show(void *ctx) { ((Sprite *)ctx)->visible = 1; } static void ScorejRing_back(void *ctx) { // onComplete: torna al centro, si allarga e sparisce for (int k = 0; k < 12; k++) if (&ScorejRings[k].s == ctx) { Sprite *r = ctx; static TweenProp pr[12][4]; pr[k][0] = (TweenProp){ .t = &r->scaleX, .t2 = &r->scaleY, .end = 2 }, pr[k][1] = (TweenProp){ .t = &r->x, .end = 0.5f * game_width }; pr[k][2] = (TweenProp){ .t = &r->y, .end = 0.5f * game_height }, pr[k][3] = (TweenProp){ .t = &r->alpha, .end = 0 }; tweens_add((TweenConfig){ .many = pr[k], .nmany = 4, .duration = 0x1f4, .ease = Ease_SineInOut, .delay = ScorejRings[k].delay, .onComplete = ScorejRing_hide, .ctx = r }); } } static void Scorej_ShowRings(int n) { float u = 2 * PI / n; for (int i = 0; i < n; i++) { Sprite *r = &ScorejRings[ScorejRing_next].s; ScorejRings[ScorejRing_next].delay = 0x3e8 + 0x64 * i; ScorejRing_next = (ScorejRing_next + 1) % 12; if (!r->frame) children_add(r); sprite_init(r, frame_get("items", "LighningRing.png"), 0.5f * game_width, 0.5f * game_height); r->visible = 0, r->scrollFactor0 = 1, r->depth = 0x7d0; tweens_add((TweenConfig){ .props = { { &r->x, NULL, 0.5f * game_width + 0x3c * cosf(0.5f + u * i) }, { &r->y, NULL, 0.5f * game_height + 0x3c * sinf(0.5f + u * i) } }, .nprops = 2, .duration = 0x1f4, .ease = Ease_SineInOut, .delay = 0x64 * i, .onStart = ScorejRing_show, .onComplete = ScorejRing_back, .ctx = r }); } } static void Scorej_LevelUp(Player *p) { Weapon *L[16]; int n = Scorej_lightnings(L), every12 = p->level % 0xc == 0, every8 = p->level % 8 == 0, grew = 0; if (every8) { if (n < 1 + (int)floorf(p->level / 8.0f) && n < 6) Core_AddHiddenWeapon("LIGHTNING"); else every8 = 0; } if (every12) { int to = 1 + (int)floorf(p->level / 12.0f); for (int i = 0; i < n; i++) { // (sic) l'elenco di prima: il Lightning appena aggiunto resta fuori L[i]->skipAddingEvolution = 1; if (L[i]->level < to && L[i]->level < 8) Weapon_LevelUp(L[i]), grew = 1; } } if (every8 || grew) Scorej_ShowRings(Scorej_lightnings(L)); } static void Scorej_canRetaliate(void *ctx) { ((Player *)ctx)->cantRetaliate = 0; } static void Pavone_LevelUp(Player *p) { // 0x14f3e: le due armi nascoste salgono di uno ogni 5 livelli, fino all'8 int n = (int)floorf(p->level / 5.0f); const char *t[2] = { "SILF2", "SILF" }; for (int k = 0; k < 2; k++) { Weapon *w = Core_GetHiddenWeapon(t[k]); if (!w) continue; if (w->level < n && w->level < 8) Weapon_LevelUp(w); w->skipAddingEvolution = 1; } } static void Player_LevelUp(Player *p) { p->level++; cJSON *found = NULL, *it; cJSON_ArrayForEach(it, p->data) if ((int)num(it, "level", -1) == p->level) { found = it; break; } if (found) for (cJSON *k = found->child; k; k = k->next) { if (!strcmp(k->string, "level")) continue; float *f = Player_field(p, k->string); if (f && cJSON_IsNumber(k)) *f += (float)k->valuedouble; } for (int i = 0; i < p->n_onEveryLevelUp; i++) { // onEveryLevelUp: arcane (e personaggi) float *f = Player_field(p, p->onEveryLevelUp[i].k); if (f) *f += p->onEveryLevelUp[i].v; } Foscari_LevelUp(p); if (Player_is(p, "PAVONE")) Pavone_LevelUp(p); if (Player_is(p, "SCOREJ")) Scorej_LevelUp(p); if (Player_is(p, "CAVALLO") && p->level >= 0x50 && Collected("RELIC_ROSALIA")) Cavallo_Morph(p); // SealedItems: nessuna if (Player_is(p, "MORTACCIO") && p->level >= 0x50 && Collected("RELIC_MALACHITE")) Mortaccio_Morph(p); if (Player_is(p, "MEGAMENYA")) Character_LevelHiddenWeapon(p, "BOCCE"); if (Player_is(p, "SYUUTO")) Character_LevelHiddenWeapon(p, "NIGHTSWORD"); if (Player_is(p, "ONNA")) Onna_LevelUp(p); if (Player_is(p, "SIGMA") && Arcana_unlockedCount() > Arcanas.n && RandomazzoEnabled() && (p->level == 2 || p->level == 3 || p->level == 0x4d || p->level == 0x6c)) Core.GiveMainArcana = 1; // 0xa802: una nuova arcana ai livelli 2, 3, 77, 108 (UnlockedArcanas > ActiveArcanas, SelectedMazzo) } static void Player_OnStop(Player *p) { tween_pause(p->wiggleTween); p->s.angle = 0; if (Player_is(p, "GENEVIEVE") || Player_is(p, "MEGAGENEVIEVE") || Player_is(p, "LUMINAIRE")) return; // OnStop senza pausa dell'animazione if (Player_is(p, "AVATAR") || Player_is(p, "PEPPINO") || Player_is(p, "SIGMA") || Player_is(p, "SCOREJ") || Player_is(p, "MENYA") || Player_is(p, "MEGAMENYA") || (p->isMorphed && Player_is(p, "CAVALLO"))) return; // Cavallo morfato: MorphedOnStop (Mortaccio no) // 0x17d7d / 0x16af1: l'animazione continua da fermo (Peppino: neve solo con la skin December) anims_pause(&p->s); } static Player *Player_new(const char *characterType) { Player *p = calloc(1, sizeof(Player)); sprite_init(&p->s, frame_get("characters", "Antonio_01.png"), 0, 0); p->s.owner = p; p->radius = 9; p->PfxEmitter = particles_createEmitter(particles_add(), (EmitterConfig){ // scene.add.particles('vfx').createEmitter .frames = { frame_get("vfx", "WhiteDot.png") }, .nframes = 1, .quantity = 0xa, .lifespan = EOP(0x7d0), .alpha = ERANGE(1, 0), .angle = ERND(0xe1, 0x13b), .speed = ERND(0x4b, 0x7d), .scale = ERANGE(2 * PixelScale, 0), .gravityY = 0x12c, .tint = 0xff0000, .bounce = 0.1f, .boundsH = 1, .collideBottom = 1, .on = 0, .flowEveryFrame = 1 }); p->PfxEmitter->boundsY = -2; p->lastFacedDirection = (Vector2){ 1, 0 }; p->hp = 100; p->level = 1; p->maxHp = 100; p->power = p->area = p->speed = p->cooldown = p->moveSpeed = p->growth = p->duration = p->luck = p->greed = p->curse = 1; p->shieldInvulTime = 0xf0; p->canFlipX = 1; p->flipper = 1; p->maxHistory = 3; p->ghostAlpha = 0.65f; p->hasLastBreath = 1; p->slowMultiplier = 1; p->gfeverMul = 1; p->startingWeapon = "WHIP"; p->characterType = characterType; children_add(&p->s); // scene.add.existing physics_existing(&p->s); sprite_setOrigin(&p->s, 0.5f, 1); body_setCircle(&p->s.body, p->radius, p->s.body.offset.x, p->s.body.offset.y); body_setOffset(&p->s.body, 6, 16); p->s.body.immovable = 1; sprite_setScale(&p->s, PixelScale); p->s.angle = -5; p->wiggleTween = tweens_add((TweenConfig){ .props = { { &p->s.angle, NULL, 5 } }, .nprops = 1, .duration = 0xfa, .loop = -1, .yoyo = 1, .persist = 1 }); tween_pause(p->wiggleTween); for (int i = 0; i <= p->maxHistory; i++) p->posHistory[i] = (Vector2){ 0, 0 }; cJSON *chars = data_get("characters"); if (!cJSON_GetObjectItem(chars, p->characterType)) p->characterType = "ANTONIO"; p->data = cJSON_GetObjectItem(chars, p->characterType); p->characterType = p->data->string; // la chiave del JSON: il chiamante puo' passare last_result.character, che poi viene riscritto da qui cJSON *base = cJSON_GetArrayItem(p->data, 0), *skin = base, *skins = cJSON_GetObjectItem(base, "skins"), *sk; if (skins) cJSON_ArrayForEach(sk, skins) if (num(sk, "id", -1) == num(base, "currentSkinIndex", 0)) { skin = sk; break; } if (num(skin, "walkingFrames", 0)) { sprite_setFrame(&p->s, frame_get(str(skin, "textureName"), str(skin, "spriteName"))); p->HasWalkingAnimation = 1; char prefix[96]; snprintf(prefix, sizeof(prefix), "%s", str(skin, "spriteName")); char *q = strstr(prefix, "01.png"); if (q) *q = 0; p->walk.n = anims_generateFrameNames(str(skin, "textureName"), prefix, 1, (int)num(skin, "walkingFrames", 0), 2, p->walk.frames, ANIM_MAX_FRAMES); p->walk.frameRate = has(skin, "walkFrameRate") ? num(skin, "walkFrameRate", 8) : 8; p->walk.msPerFrame = 1000.0f / p->walk.frameRate; p->walk.repeat = -1; anims_play(&p->s, &p->walk, 0); anims_pause(&p->s); } p->regenTimer = time_addEvent(0x3e8, 0, -1, Player_Regenerate, p); return p; } static void Player_Update(Player *p, float delta) { if (p->isDead) return; p->invulTime -= delta; if (p->invulTime <= 0) p->invulTime = 0; p->slowTime -= delta; if (p->slowTime <= 0) p->slowTime = 0; Player_setIsInvul(p, p->invulTime > 0); p->IsSlow = p->slowTime > 0; p->slowMultiplier = p->IsSlow ? 0.5f : 1; p->s.depth = 0; if (p->canFlipX) { if (p->s.body.velocity.x < 0) p->s.flipX = p->flipper == 1; if (p->s.body.velocity.x > 0) p->s.flipX = p->flipper != 1; } if (p->s.body.velocity.x == 0 && p->s.body.velocity.y == 0) { if (!p->isAnimForced) Player_OnStop(p); } else if (p->HasWalkingAnimation) { anims_resume(&p->s); } else if (tween_isPaused(p->wiggleTween)) { tween_play(p->wiggleTween); } if (p->historyIndex < p->maxHistory) p->historyIndex++; else p->historyIndex = 0; p->posHistory[p->historyIndex] = p->s.body.position; // rtGhosts (scie): disegnate in Player_draw p->WorldBoxCollider = (Rectangle){ p->s.x - 0.5f * game_width, p->s.y - 0.5f * game_height, game_width, game_height }; if (p->isMorphed) p->s.angle = 0; // Cavallo / Mortaccio: Update dopo super if (p->isMorphed && Player_is(p, "MORTACCIO")) { // la testa dello scheletro float x0 = p->s.x - 0x1f * p->s.scaleX, y0 = p->s.y - 0x31 * p->s.scaleY; p->head.flipX = p->s.flipX; p->head.x = x0 + (p->s.flipX ? -0x1a : 0x34) * p->s.scaleX, p->head.y = y0 - 0x15 * p->s.scaleY; p->head.depth = p->s.depth + 1; } Character_Update(p); Foscari_Update(p, delta); } // I "fantasmi" del giocatore: rtGhosts.draw(this, ..., alpha 0.1 - 0.1 * i) con alpha globale ghostAlpha static void Player_draw(Sprite *s); // ============================================================================ // 0x18540: Magnet // ============================================================================ static Magnet *Magnet_new(void) { Magnet *m = calloc(1, sizeof(Magnet)); sprite_init(&m->s, frame_get("vfx", "WhiteDot.png"), 0, 0); m->s.owner = m; m->radius = 0x1e; m->percentage = 1; m->s.visible = 0; physics_existing(&m->s); sprite_setScale(&m->s, Core.Player->s.scaleX); body_setCircle(&m->s.body, m->radius, -m->radius, -m->radius); return m; } static void Magnet_Update(Magnet *m) { m->s.x = Core.Player->s.x; m->s.y = Core.Player->s.y - 0xc; } // ============================================================================ // 0xd856 + 0x166d5 + 0x50ae: Pickup, Gem e il loro pool // ============================================================================ static void Pickup_DeSpawn(Pickup *p); static void RunPickups_push(const char *t) { if (Core.n_RunPickups < 512) Core.RunPickups[Core.n_RunPickups++] = t; } static void json_inc(cJSON *o, const char *k) { // o[k] += 1 sui dati in memoria if (!o) return; cJSON *n = cJSON_GetObjectItem(o, k); if (n) cJSON_SetNumberValue(n, n->valuedouble + 1); else cJSON_AddItemToObject(o, k, cJSON_CreateNumber(1)); } static void make_anim(Animation *a, const char *atlas, const char *prefix, int start, int end, int pad, float fps, int repeat) { a->n = anims_generateFrameNames(atlas, prefix, start, end, pad, a->frames, ANIM_MAX_FRAMES); a->frameRate = fps; a->msPerFrame = 1000.0f / fps; a->repeat = repeat; } // --- 0x50ae: Gem --------------------------------------------------------------- static const char *Gem_frameFor(float value) { // Gem.SetValue int v = (int)value; if (v == 1 || v == 2) return "GemBlue.png"; if (v >= 3 && v <= 9) return "GemGreen.png"; return "GemRed.png"; } static void Gem_SetValue(Pickup *p, float v) { p->value = v; p->frameName = Gem_frameFor(p->value); sprite_setFrame(&p->s, frame_get("items", p->frameName)); p->s.alpha = 1; } static void Gem_ctor(Pickup *p) { p->isGem = 1; p->frameName = "GemBlue.png"; Gem_SetValue(p, 0); sprite_setScale(&p->s, PixelScale); tweens_add((TweenConfig){ .props = { { &p->time, NULL, 1 } }, .nprops = 1, .duration = 0x1f4 }); } static void Gem_GetTaken(Pickup *p); static void Gem_Update(Pickup *p); // --- 0x8af: Treasure ------------------------------------------------------------ static void Treasure_ResetCursor(Pickup *p) { sprite_setFrame(&p->s, frame_get("items", "BoxOpen.png")); anims_play(&p->Cursor, &p->cursorIdle, 0); sprite_setTint(&p->Cursor, 0xffffff); } static void Treasure_SetArcana(Pickup *p, int has) { // il forziere dell'arcana: BoxArcana e cursore viola if (!has) return; p->hasArcana = 1; sprite_setFrame(&p->s, frame_get("items", "BoxArcana.png")); sprite_setTint(&p->Cursor, 0x5f37c8); anims_play(&p->Cursor, &p->cursorNeutral, 0); } static void Treasure_ctor(Pickup *p) { p->radius = 0x14; p->hasArcana = 0; sprite_setScale(&p->s, PixelScale); sprite_init(&p->Cursor, frame_get("UI", "arrow_01.png"), p->s.x, p->s.y); p->Cursor.depth = 0x270f; sprite_setScale(&p->Cursor, 2); p->Cursor.alpha = 0.75f; p->Cursor.blendAdd = 1; children_add(&p->Cursor); make_anim(&p->cursorIdle, "UI", "arrow_", 1, 8, 2, 0x10, -1); make_anim(&p->cursorNeutral, "UI", "arrowNeutral_", 1, 8, 2, 0x10, -1); anims_play(&p->Cursor, &p->cursorIdle, 0); body_setCircle(&p->s.body, 0x10, -8, -8); } static void Pickup_OnRecycle(Pickup *p); static void Treasure_OnRecycle(Pickup *p) { Pickup_OnRecycle(p); p->goToPlayer = 1; p->isStationary = 1; p->Cursor.visible = 1; if (!list_contains(&Core.PickupsWithArrows, &p->s)) list_add(&Core.PickupsWithArrows, &p->s); // Stage.minTreasureX/Y: assenti nella Foresta p->hasArcana = 0; Treasure_ResetCursor(p); } static void Treasure_DeSpawn(Pickup *p) { Pickup_DeSpawn(p); p->Cursor.visible = 0; } static float Pickup_AngleFromTargetRadians(Pickup *p) { Vector2 b = Core.Player->s.body.position; return atan2f(p->s.y - b.y, p->s.x - b.x); } static Vector2 Pickup_safeXY(Pickup *p, float x, float y) { TilingTileset *t = Core.Stage->tilingTileset; if (t && TilingTileset_isPointWithinCollisionLayer(t, x, y)) { float dx = Core.Player->s.x - x, dy = Core.Player->s.y - y, l = sqrtf(dx * dx + dy * dy); if (l > 0) dx /= l, dy /= l; p->currentDirection = (Vector2){ dx, dy }; return (Vector2){ x + 4 * dx, y + 4 * dy }; } return (Vector2){ x, y }; } static void Pickup_GoToPlayer(Pickup *p); static void Treasure_Update(Pickup *p) { if (p->goToPlayer && !p->isStationary) Pickup_GoToPlayer(p); // super.Update p->s.depth = 9 + p->s.y - Core.Player->s.y; Sprite *c = &p->Cursor; if (fabsf(p->s.x - Core.Player->s.x) < 0.5f * game_width && fabsf(p->s.y - Core.Player->s.y) < 0.5f * game_height) { c->x = p->s.x, c->y = p->s.y - 0x18; c->angle = 0x5a; c->alpha = 1; c->blendAdd = 0; } else { float a = Pickup_AngleFromTargetRadians(p); c->angle = a * RAD2DEG; c->x = Core.Player->s.x + 0.45f * cosf(a) * game_width; c->y = Core.Player->s.y + 0.45f * sinf(a) * game_height; c->alpha = 0.75f; c->blendAdd = 1; } Vector2 s = Pickup_safeXY(p, p->s.x, p->s.y); p->s.x = s.x, p->s.y = s.y; if (p->hasArcana && Arcanas.n >= Arcanas.MaxArcanasPerRun) p->hasArcana = 0, Treasure_ResetCursor(p); // arcane al completo } static void Pickup_GetTaken(Pickup *p); static void Treasure_GetTaken(Pickup *p) { if (p->disableGet) return; p->Cursor.visible = 0; Pickup_SetSeenItem(p->itemType); RunPickups_push("TREASURE"); const char *stat = p->CurrentTreasureLevel == 3 ? "STATS_TREASURE_3" : p->CurrentTreasureLevel == 2 ? "STATS_TREASURE_2" : p->CurrentTreasureLevel == 1 ? "STATS_TREASURE_1" : NULL; if (stat) { json_inc(cJSON_GetObjectItem(data_get("items"), stat), "pickedupAmount"); RunPickups_push(stat); } if (Core.n_TreasureQueue < 16) Core.TreasureQueue[Core.n_TreasureQueue++] = (typeof(Core.TreasureQueue[0])){ p->CurrentTreasureLevel, p->CurrentTreasureTypes, p->CurrentFixedTreasures }; Pickup_GetTaken(p); } // --- Pickup del LootManager ------------------------------------------------------ static float PlayerOptions_AddCoins(float v); static void Core_RosaryDamage(void); static void Core_TimeStop(void); static void Core_TurnOnVacuum(void); static void Core_TurnOnVacuumForGold(void); static void Player_RecoverHp(Player *p, float v, int show, int regenScale); static void Player_SetInvulForMilliSeconds(Player *p, float ms); static void Item_Update(Pickup *p) { // Update di tutti gli oggetti a terra: base + depth 9 + y - Player.y if (p->goToPlayer && !p->isStationary) Pickup_GoToPlayer(p); p->s.depth = 9 + p->s.y - Core.Player->s.y; } static void GoldFever_OnCoinPickup(Pickup *p); static void W_Mill_OnCoinPickup(float value); static void Foscari_OnCoinPickup(float value); static void GoldFever_Start(float ms); static void Coin_GetTaken(Pickup *p) { // 0xdee7 Coin, 0xf789 CoinBag1, 0xb693 CoinBagMax if (p->disableGet) return; if (!strcmp(p->itemType, "COIN")) Core.RunPickups_Coins++; else RunPickups_push(p->itemType); GoldFever_OnCoinPickup(p); W_Mill_OnCoinPickup(p->value); // CoinPickedup Foscari_OnCoinPickup(p->value); PlayerOptions_AddCoins(p->value); MainUI_UpdateCoins(); if (!strcmp(p->itemType, "COIN")) Sound_PlaySound("Coin", 0.5f, 1, 0, 1, 1); else Sound_PlaySimple("Coin", !strcmp(p->itemType, "COINBAGMAX") ? 0.65f : 0.5f); if (strcmp(p->itemType, "COIN")) Pickup_SetSeenItem(p->itemType); // solo i sacchetti (0xf789, 0xb693) Pickup_GetTaken(p); } static void Roast_GetTaken(Pickup *p) { // 0x50b2: pollo arrosto if (p->disableGet) return; Player_RecoverHp(Core.Player, p->value, 1, 1); RunPickups_push(p->itemType); Player_SetInvulForMilliSeconds(Core.Player, 0x12c); Pickup_SetSeenItem(p->itemType); Pickup_GetTaken(p); Sound_PlaySound("Roast", 0.6f, 1, 0, 0x1f4, 5); } static void CoinBag2_GetTaken(Pickup *p) { // 0x14b01: sacchetto grande (premio del level-up a scelte finite) if (p->disableGet) return; PlayerOptions_AddCoins(p->value); RunPickups_push(p->itemType); MainUI_UpdateCoins(); Sound_PlaySimple("Coin", 0.5f); Pickup_SetSeenItem(p->itemType); Pickup_GetTaken(p); } static void Always_ctor(Pickup *p) { // 0x603b / 0x139d8: itemType COINBAG2 / ROAST (lo slot del pool resta quello della classe) p->itemType = !strcmp(p->vt->itemType, "ALWAYS_ROAST") ? "ROAST" : "COINBAG2"; cJSON *it = cJSON_GetObjectItem(data_get("items"), p->itemType); p->frameName = str(it, "frameName"); sprite_setFrame(&p->s, frame_get("items", p->frameName)); } static void AlwaysCoinbag_GetTaken(Pickup *p) { // 0x603b PlayerOptions_AddCoins(p->value); RunPickups_push("COINBAG2"); Core.AlwaysCoinbag = 1; MainUI_UpdateCoins(); Sound_PlaySimple("Coin", 0.5f); Pickup_SetSeenItem(p->itemType); Pickup_GetTaken(p); } static void AlwaysRoast_GetTaken(Pickup *p) { // 0x139d8 Core.AlwaysRoast = 1; if (Core.Player->hp < Core.Player->maxHp) { Player_RecoverHp(Core.Player, p->value, 1, 1); RunPickups_push("ROAST"); } else { PlayerOptions_AddCoins(0x19); RunPickups_push("COINBAG2"); MainUI_UpdateCoins(); Sound_PlaySimple("Coin", 0.5f); } Pickup_GetTaken(p); Sound_PlaySimple("Roast", 0.6f); } static void GizmoManager_DisplayIconOverhead(const char *frame, const char *value, unsigned tint); static void GizmoManager_DisplayQuickTreasureChestAnimation(void); static void Clover_GetTaken(Pickup *p) { // 0x17e96: quadrifoglio if (p->disableGet) return; Core.Player->luck += p->value; RunPickups_push(p->itemType); Pickup_SetSeenItem(p->itemType); GizmoManager_DisplayIconOverhead("Clover.png", "+10", 0xffff00); Pickup_GetTaken(p); Sound_PlaySound("Groove", 0.7f, 1, 0x7d0, 0x96, 3); } static void Idle_ctor(Pickup *p) { // generateFrameNames('items', prefix, 1..3) a 10 fps, in loop const char *prefix = !strcmp(p->itemType, "ROSARY") ? "Rosary" : !strcmp(p->itemType, "OROLOGION") ? "PocketWatch" : !strcmp(p->itemType, "VACUUM") ? "Vacuum" : !strcmp(p->itemType, "NFT") ? "Nft" : "Gilded"; make_anim(&p->idle, "items", prefix, 1, !strcmp(p->itemType, "NFT") ? 4 : 3, 0, 0xa, -1); } static void Idle_OnRecycle(Pickup *p) { Pickup_OnRecycle(p); anims_play(&p->s, &p->idle, 0); } static void Rosary_GetTaken(Pickup *p) { if (p->disableGet) return; Core_RosaryDamage(); RunPickups_push(p->itemType); Pickup_SetSeenItem(p->itemType); Pickup_GetTaken(p); } // 0x608c static void Orologion_GetTaken(Pickup *p) { if (p->disableGet) return; Core_TimeStop(); RunPickups_push(p->itemType); Pickup_SetSeenItem(p->itemType); Pickup_GetTaken(p); } // 0x11e6e static void Vacuum_GetTaken(Pickup *p) { if (p->disableGet) return; Core_TurnOnVacuum(); RunPickups_push(p->itemType); Pickup_SetSeenItem(p->itemType); Pickup_GetTaken(p); Sound_PlaySimple("Vacuum", 0.6f); } // 0x1386 static Weapon *Core_AddHiddenWeapon(const char *type); static void Nft_GetTaken(Pickup *p) { // 0x165ca: Nduja Fritta if (p->disableGet) return; Weapon *w = NULL; for (int i = 0; i < Core.n_HiddenWeapons; i++) if (!strcmp(Core.HiddenWeapons[i]->bulletType, "NDUJA")) w = Core.HiddenWeapons[i]; if (w) { w->totalTime = fmaxf(1, w->totalTime - 0x2710); for (int i = 0; i < Core.n_HiddenWeapons; i++) if (!strcmp(Core.HiddenWeapons[i]->bulletType, "NDUJA_COUNTER")) Core.HiddenWeapons[i]->totalTime = w->totalTime; } else Core_AddHiddenWeapon("NDUJA"); RunPickups_push(p->itemType); Pickup_SetSeenItem(p->itemType); Pickup_GetTaken(p); } static void Gilded_GetTaken(Pickup *p) { // 0x17e91: Gold Fever (compare dal livello 30) if (p->disableGet) return; GoldFever_Start(0x2710); // Core.TriggerGoldFever(10000) Core_TurnOnVacuumForGold(); RunPickups_push(p->itemType); Pickup_SetSeenItem(p->itemType); Pickup_GetTaken(p); } // --- 0x15ee2 PickupGuarded + 0xbf1f pickup arma: fluttua, bagliore arcobaleno, ombra; le guardie appaiono da vicino -------- static void PickupGuarded_UpdateBounds(Pickup *p) { p->left = p->s.x - p->guardRadius, p->right = p->s.x + p->guardRadius, p->top = p->s.y - p->guardRadius, p->bottom = p->s.y + p->guardRadius; } static EnemyPool *StageEvent_pool(Stage *st, const char *type); static Enemy *EnemyPool_SpawnAt(EnemyPool *p, float x, float y); static void PickupGuarded_TriggerSpawn(Pickup *p) { if (p->hasSpawned) return; p->hasSpawned = 1; if (!p->enemyType || !p->spawnQuantity) return; EnemyPool *pool = StageEvent_pool(Core.Stage, p->enemyType); if (!pool) return; float a = 0; for (int i = 0; i < p->spawnQuantity; i++) { float x = p->s.x + 0x30 * cosf(a) * 3, y = p->s.y + 0x30 * sinf(a) * 3; a += p->spawnAngle / (p->spawnQuantity - 1); Enemy *e = EnemyPool_SpawnAt(pool, x, y); if (e) e->isCullable = 0; if (e && p->n_guards < 32) p->guards[p->n_guards++] = e; } } static void WeaponPickup_float(Pickup *p) { // floatTween: y - 8 in yoyo, Sine.easeInOut if (p->hasFloat) tween_stop(p->floatTween), tween_remove(p->floatTween); p->floatTween = tweens_add((TweenConfig){ .props = { { &p->s.y, NULL, p->s.y - 8 } }, .nprops = 1, .duration = 0x3e8, .ease = Ease_SineInOut, .loop = -1, .yoyo = 1 }); p->hasFloat = 1; } static void WeaponPickup_ctor(Pickup *p) { p->weaponType = "VOID"; p->particlesInterval = 0xc8, p->totalTime = 0x64; p->despawnOnUnavailable = 1; sprite_setScale(&p->s, PixelScale); p->isStationary = 1; p->spawnQuantity = 0xc, p->guardRadius = 0xc8, p->spawnAngle = PI; sprite_init(&p->shadow, frame_get("items", "ShadowSpot.png"), 0, 0); sprite_init(&p->glow, frame_get("vfx", "round.png"), 0, 0); // Cursor e CursorIcon: visibili solo con PlayerOptions.ShowPickups, spento di default } static void WeaponPickup_OnRecycle(Pickup *p) { Pickup_OnRecycle(p); p->guardRadius = 0.5f * 0x1c8; // PickupGuarded.OnRecycle: GAMEPLAY_PIXEL_HEIGHT / 2 PickupGuarded_UpdateBounds(p); p->hasSpawned = 0; if (!list_contains(&Core.PickupsWithArrows, &p->s)) list_add(&Core.PickupsWithArrows, &p->s); p->colorValue = 0; WeaponPickup_float(p); p->shadowTween = tweens_add((TweenConfig){ .props = { { &p->shadow.scaleX, &p->shadow.scaleY, 0.75f } }, .nprops = 1, .duration = 0x3e8, .ease = Ease_SineInOut, .loop = -1, .yoyo = 1 }); children_add(&p->shadow); p->shadow.x = p->s.x, p->shadow.y = p->s.y; sprite_setScale(&p->shadow, 1); p->shadow.alpha = 0.5f; children_add(&p->glow); p->glow.x = p->s.x, p->glow.y = p->s.y; p->glow.blendAdd = 1; p->glow.alpha = 0.5f; p->glowTween = tweens_add((TweenConfig){ .props = { { &p->glow.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x1f4, .loop = -1, .yoyo = 1 }); } static void WeaponPickup_DeSpawn(Pickup *p) { Pickup_DeSpawn(p); tween_remove(p->floatTween), tween_remove(p->shadowTween), tween_remove(p->glowTween); p->hasFloat = 0; children_remove(&p->shadow); children_remove(&p->glow); } static void WeaponPickup_SetWeaponType(Pickup *p, const char *t) { cJSON *b = cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("weapons"), t), 0); p->frameName = str(b, "frameName"); sprite_setFrame(&p->s, frame_get(str(b, "texture"), p->frameName)); p->weaponType = t; } static int LevelUpFactory_InStore(const char *t); static void WeaponPickup_Update(Pickup *p) { if (p->goToPlayer && !p->isStationary) Pickup_GoToPlayer(p); // Pickup.Update if (!p->hasSpawned && !(Core.Player->s.y > p->bottom || Core.Player->s.y < p->top || Core.Player->s.x > p->right || Core.Player->s.x < p->left)) PickupGuarded_TriggerSpawn(p); p->glow.x = p->s.x, p->glow.y = p->s.y; float h = game_height; p->s.depth = h, p->shadow.depth = h - 1, p->glow.depth = h; p->totalTime += 0x64 / 6.0f; // semplificazione: Update(delta) riceve ~16.7 ms per frame; qui lo scandisce Core_Update ogni frame if (p->totalTime > p->particlesInterval) { p->totalTime = 0; manager_emitParticleAt(Core.PfxEmitter_Pickups, p->s.x, p->s.y); } p->colorValue += 0.1f; p->glow.tint = (unsigned)(0xff * fabsf(sinf(p->colorValue))) << 16 | (unsigned)(0xff * fabsf(cosf(0.5f * p->colorValue))) << 8 | (unsigned)(0xc8 + 0x37 * fabsf(cosf(p->colorValue))); if (p->despawnOnUnavailable && !LevelUpFactory_InStore(p->weaponType)) { WeaponPickup_DeSpawn(p); return; } // owner.OnPickupCallback: vuoto Vector2 sxy = Pickup_safeXY(p, p->s.x, p->s.y); if (sxy.x != p->s.x || sxy.y != p->s.y) { p->s.x = sxy.x, p->s.y = sxy.y; WeaponPickup_float(p); p->shadow.x = p->s.x, p->shadow.y = p->s.y; } } static void WeaponPickup_GetTaken(Pickup *p) { if (p->disableGet) return; // triggerOnGet: solo per le maschere GOLD/SILVER/LEFT/RIGHT if (Core.n_FoundWeaponQueue < 16) Core.FoundWeaponQueue[Core.n_FoundWeaponQueue++] = p->weaponType; Pickup_GetTaken(p); } // --- 0x4d2b: la reliquia a terra (PickupGuarded), con la freccia verde verso di lei quando e' fuori schermo --------- static void Relic_ctor(Pickup *p) { WeaponPickup_ctor(p); // stessi particlesInterval, totalTime, scala, isStationary, ombra e alone p->weaponType = NULL, p->despawnOnUnavailable = 0; sprite_init(&p->Cursor, frame_get("UI", "arrow_01.png"), p->s.x, p->s.y); p->Cursor.depth = 0x270f; sprite_setScale(&p->Cursor, 2); p->Cursor.alpha = 1; sprite_setTint(&p->Cursor, 0xff00); children_add(&p->Cursor); make_anim(&p->cursorIdle, "UI", "arrow_", 1, 8, 2, 0x10, -1); anims_play(&p->Cursor, &p->cursorIdle, 0); } static void Relic_OnRecycle(Pickup *p) { WeaponPickup_OnRecycle(p); p->Cursor.visible = 1; } static void Relic_DeSpawn(Pickup *p) { WeaponPickup_DeSpawn(p); p->Cursor.visible = 0; } static void Relic_SetItemType(Pickup *p, const char *t) { cJSON *it = cJSON_GetObjectItem(data_get("items"), t); sprite_setFrame(&p->s, frame_get(str(it, "texture"), str(it, "frameName"))); p->itemType = t; // il pool la ritrova dal tipo della classe (vt->itemType) } static void Relic_Update(Pickup *p) { if (p->goToPlayer && !p->isStationary) Pickup_GoToPlayer(p); // PickupGuarded.Update if (!p->hasSpawned && !(Core.Player->s.y > p->bottom || Core.Player->s.y < p->top || Core.Player->s.x > p->right || Core.Player->s.x < p->left)) PickupGuarded_TriggerSpawn(p); p->shadow.x = p->s.x, p->shadow.y = p->s.y; p->glow.x = p->s.x, p->glow.y = p->s.y; float h = game_height; p->s.depth = h, p->shadow.depth = h - 1, p->glow.depth = h; p->totalTime += 0x64 / 6.0f; // Update(delta): un frame a 60 FPS, come WeaponPickup_Update if (p->totalTime > p->particlesInterval) { p->totalTime = 0; manager_emitParticleAt(Core.PfxEmitter_Pickups, p->s.x, p->s.y); } p->colorValue += 0.1f; p->glow.tint = (unsigned)(0xff * fabsf(sinf(p->colorValue))) << 16 | (unsigned)(0xff * fabsf(cosf(0.5f * p->colorValue))) << 8 | (unsigned)(0xc8 + 0x37 * fabsf(cosf(p->colorValue))); if (fabsf(p->s.x - Core.Player->s.x) < 0.5f * game_width && fabsf(p->s.y - Core.Player->s.y) < 0.5f * game_height) p->Cursor.visible = 0; else { float a = Pickup_AngleFromTargetRadians(p); p->Cursor.angle = a * RAD2DEG; p->Cursor.x = Core.Player->s.x + 0.45f * cosf(a) * game_width; p->Cursor.y = Core.Player->s.y + 0.45f * sinf(a) * game_height; p->Cursor.visible = 1; } } static void Relic_GetTaken(Pickup *p) { if (p->disableGet) return; p->Cursor.visible = 0; Core.CurrentFoundRelic = p->itemType; if (!strcmp(p->itemType, "RELIC_3DGLASSES")) Glasses_fx = 1, Glasses_left = 30; // la realta' si piega per 30 s; poi Vista 3D dal menu if (Core.n_RelicQueue < 16) Core.RelicQueue[Core.n_RelicQueue++] = p->itemType; Pickup_SetSeenItem(p->itemType); Pickup_GetTaken(p); } // --- 0xf623: EggManager, le uova d'oro di ogni personaggio in PlayerOptions.EggData --------------------------------- static const struct { const char *name; double value; } EggAttr[19] = { { "maxHp", 1 }, { "armor", 0.1 }, { "regen", 0.1 }, { "moveSpeed", 0.01 }, { "power", 0.01 }, { "cooldown", -0.005 }, { "area", 0.01 }, { "speed", 0.01 }, { "duration", 0.01 }, { "amount", 0.1 }, { "luck", 0.01 }, { "growth", 0.01 }, { "greed", 0.01 }, { "curse", 0.01 }, { "magnet", 0.3 }, { "revivals", 0.1 }, { "rerolls", 0.1 }, { "skips", 0.2 }, { "banish", 0.2 } }; static cJSON *Egg_char(int make) { // EggData[SelectedCharacter], creato vuoto se serve cJSON *d = po("EggData"), *c = cJSON_GetObjectItem(d, po_str("SelectedCharacter")); if (!c && make) cJSON_AddItemToObject(d, po_str("SelectedCharacter"), c = cJSON_CreateObject()); return c; } static void json_addnum(cJSON *o, const char *k, double v) { // o[k] === undefined && (o[k] = 0), o[k] += v cJSON *n = cJSON_GetObjectItem(o, k); if (!n) cJSON_AddItemToObject(o, k, cJSON_CreateNumber(v)); else cJSON_SetNumberValue(n, n->valuedouble + v); } static int EggManager_AddGoldenEgg(void) { // restituisce l'indice dell'attributo pescato cJSON *c = Egg_char(1); int a = RND_between(0, 18); // PickRandomAttribute json_addnum(c, EggAttr[a].name, EggAttr[a].value); json_addnum(c, "total", 1); json_addnum(po("EggData"), "total", 1); if (!po_has("CollectedItems", "RELIC_GOLDENEGG")) { obj_set(cJSON_GetObjectItem(data_get("items"), "RELIC_GOLDENEGG"), "seen", cJSON_CreateTrue()); po_push("CollectedItems", "RELIC_GOLDENEGG"); } return a; } static void EggManager_ApplyBonuses(void) { cJSON *c = Egg_char(0); if (!c) return; Player *p = Core.Player; p->power += num(c, "power", 0), p->area += num(c, "area", 0), p->speed += num(c, "speed", 0), p->cooldown += num(c, "cooldown", 0); p->duration += num(c, "duration", 0), p->moveSpeed += num(c, "moveSpeed", 0), p->growth += num(c, "growth", 0), p->luck += num(c, "luck", 0); p->maxHp += num(c, "maxHp", 0), p->regen += num(c, "regen", 0), p->greed += num(c, "greed", 0), p->curse += num(c, "curse", 0); Core.Magnet->radius += num(c, "magnet", 0); p->amount += floor(num(c, "amount", 0)), p->armor += floor(num(c, "armor", 0)), p->rerolls += floor(num(c, "rerolls", 0)); p->skips += floor(num(c, "skips", 0)), p->banish += floor(num(c, "banish", 0)), p->revivals += floor(num(c, "revivals", 0)); } static int EggAttr_find(const char *name) { for (int i = 0; i < 19; i++) if (!strcmp(EggAttr[i].name, name)) return i; return -1; } static void Egg_dropTotals(cJSON *c, int n) { // total del personaggio (mai sotto zero) e totale generale cJSON *t = cJSON_GetObjectItem(c, "total"), *g = cJSON_GetObjectItem(po("EggData"), "total"); if (t && t->valuedouble > 0) cJSON_SetNumberValue(t, fmax(0, t->valuedouble - n)); if (g) cJSON_SetNumberValue(g, g->valuedouble - n); } static void EggManager_RemoveAllSpecificEggs(const char *name) { cJSON *c = Egg_char(0); int a = EggAttr_find(name), n = 0; if (!c || a < 0) return; cJSON *v = cJSON_GetObjectItem(c, name); if (v && v->valuedouble != 0) { double x = v->valuedouble; if (strcmp(name, "cooldown")) { while (x > 0) x -= EggAttr[a].value, n++; if (x < 0) x = 0; } else { while (x < 0) x += EggAttr[a].value, n++; if (x > 0) x = 0; } cJSON_SetNumberValue(v, x); } if (n) Egg_dropTotals(c, n); } static int EggManager_RemoveRandomEgg(void) { // (sic) restituisce sempre l'attributo pescato, tolto o no: vero se il personaggio ha uova cJSON *c = Egg_char(0); if (!c) return 0; int a = RND_between(0, 18); cJSON *v = cJSON_GetObjectItem(c, EggAttr[a].name); if (v && v->valuedouble != 0) { double x = v->valuedouble - EggAttr[a].value; if (strcmp(EggAttr[a].name, "cooldown") && x < 0) x = 0; cJSON_SetNumberValue(v, x); Egg_dropTotals(c, 1); } return 1; } static int EggManager_RemoveBonuses(void) { // l'inverso di ApplyBonuses (per Astral Stair senza le sue reliquie); restituisce total cJSON *c = Egg_char(0); if (!c) return 0; Player *p = Core.Player; p->power -= num(c, "power", 0), p->area -= num(c, "area", 0), p->speed -= num(c, "speed", 0), p->cooldown -= num(c, "cooldown", 0); p->duration -= num(c, "duration", 0), p->moveSpeed -= num(c, "moveSpeed", 0), p->growth -= num(c, "growth", 0), p->luck -= num(c, "luck", 0); p->maxHp -= num(c, "maxHp", 0), p->regen -= num(c, "regen", 0), p->greed -= num(c, "greed", 0), p->curse -= num(c, "curse", 0); Core.Magnet->radius -= num(c, "magnet", 0); p->amount -= floor(num(c, "amount", 0)), p->armor -= floor(num(c, "armor", 0)), p->rerolls -= floor(num(c, "rerolls", 0)); p->skips -= floor(num(c, "skips", 0)), p->banish -= floor(num(c, "banish", 0)), p->revivals -= floor(num(c, "revivals", 0)); return (int)num(c, "total", 0); } static void EggManager_RemoveAllEggs(void) { cJSON *c = Egg_char(0); if (!c) return; cJSON *z = cJSON_CreateObject(); cJSON_AddNumberToObject(z, "total", 0); cJSON_ReplaceItemInObject(po("EggData"), po_str("SelectedCharacter"), z); } static const char *EggManager_lookUpFrame(int a) { static const char *const F[19] = { "HeartBlack.png", "ArmorIron.png", "HeartRuby.png", "Wing.png", "Leaf.png", "Book2.png", "Candelabra.png", "Gauntlet.png", "EmblemEye.png", "Ring.png", "Clover.png", "Crown.png", "Mask.png", "Curse.png", "OrbGlow.png", "Tiramisu.png", "Dice.png", "Skip.png", "Banish.png" }; return F[a]; } // ShowResultAt: l'icona dell'attributo e "+valore" (scala 2, tinta a caso, ombra) che salgono di 20 px e svaniscono in 2 s typedef struct { Sprite icon, txt; char text[24]; } EggResult; static void EggResult_drawText(Sprite *s) { EggResult *r = s->owner; if (s->alpha <= 0) return; float cx = s->scrollFactor0 ? 0 : camera_scrollX, cy = s->scrollFactor0 ? 0 : camera_scrollY, size = 16 * s->scaleX; Vector2 m = MeasureTextEx(vs_font, r->text, size, 0), p = { roundf(s->x - cx), roundf(s->y - cy - 0.5f * m.y) }; DrawTextEx(vs_font, r->text, (Vector2){ p.x + 2, p.y + 2 }, size, 0, Fade(BLACK, s->alpha)); // setShadow(2, 2, '#000') DrawTextEx(vs_font, r->text, p, size, 0, Fade(GetColor(s->tint << 8 | 0xff), s->alpha)); } static void EggResult_done(void *ctx) { EggResult *r = ctx; children_remove(&r->icon), children_remove(&r->txt); free(r); } static void EggManager_ShowResultAt(float tx, float ty, int a, float ox, float oy, int tint) { EggResult *r = calloc(1, sizeof(EggResult)); float x = tx + ox + frand() * ox, y = ty + oy + frand() * oy; sprite_init(&r->icon, frame_get("items", EggManager_lookUpFrame(a)), x, y); sprite_setScale(&r->icon, 2), r->icon.depth = 0xc1c; children_add(&r->icon); snprintf(r->text, sizeof(r->text), "%s%g", EggAttr[a].value > 0 ? "+" : "", EggAttr[a].value); static const unsigned T[3] = { 0xffff00, 0xff00, 0xffff }; sprite_init(&r->txt, NULL, x + 0x20, y); r->txt.owner = r, r->txt.draw = EggResult_drawText, r->txt.scaleX = r->txt.scaleY = 2, r->txt.depth = 0xc1c; r->txt.tint = tint >= 0 ? (unsigned)tint : T[RND_between(0, 2)]; children_add(&r->txt); tweens_add((TweenConfig){ .props = { { &r->icon.alpha, NULL, 0 }, { &r->icon.y, NULL, y - 0x14 } }, .nprops = 2, .duration = 0x7d0 }); tweens_add((TweenConfig){ .props = { { &r->txt.alpha, NULL, 0 }, { &r->txt.y, NULL, y - 0x14 } }, .nprops = 2, .duration = 0x7d0, .onComplete = EggResult_done, .ctx = r }); } // --- 0xc903 mercante (Pantalone) e 0x11e05 Eggman: toccati aprono il negozio, con le maschere o le uova che salgono --- static void Merchant_init(Pickup *p, int egg) { sprite_setScale(&p->s, PixelScale); body_setCircle(&p->s.body, 0x10, p->s.body.offset.x, p->s.body.offset.y); p->pfx = particles_add(); EmitterConfig c = { .lifespan = EOP(0x3e8), .rotate = egg ? ERND(-0x3c, 0x3c) : ERND(-0x14, 0x14), .angle = egg ? ERND(0xc8, 0x154) : ERND(0x104, 0x118), .speed = egg ? ERND(0x32, 0x46) : ERND(0x14, 0x32), .quantity = egg ? 4 : 1, .scale = ERANGE(1, 0.75f), .alpha = ERANGE(1, 0), .frequency = 0x1f4, .on = 1 }; static const char *const M[5] = { "mask1.png", "mask2.png", "mask3.png", "mask4.png", "mask5.png" }; for (int i = 0; i < (egg ? 2 : 5); i++) c.frames[i] = egg ? frame_get("items", "goldenegg.png") : frame_get("vfx", M[i]); c.nframes = egg ? 2 : 5; p->pfxE = particles_createEmitter(p->pfx, c); } static void Merchant_ctor(Pickup *p) { Merchant_init(p, 0); } static void Eggman_ctor(Pickup *p) { Merchant_init(p, 1); } static void Merchant_OnRecycle(Pickup *p) { Pickup_OnRecycle(p); p->goToPlayer = 1, p->isStationary = 1; sprite_setFrame(&p->s, frame_get("items", p->vt->ctor == Eggman_ctor ? "Eggman.png" : "Pantalone.png")); } static void Merchant_Update(Pickup *p) { if (p->goToPlayer && !p->isStationary) Pickup_GoToPlayer(p); // super.Update p->s.depth = 9 + p->s.y - Core.Player->s.y, p->pfx->s.depth = p->s.depth - 1; Vector2 s = Pickup_safeXY(p, p->s.x, p->s.y); p->s.x = s.x, p->s.y = s.y, p->pfxE->x = p->s.x, p->pfxE->y = p->s.y; // particles.x/y: l'emettitore segue il mercante } static void Merchant_GetTaken(Pickup *p) { if (p->disableGet) return; emitter_stop(p->pfxE); // (sic) mai riacceso: un mercante riciclato non fa piu' maschere Core.MerchantInventory = p->vt->ctor == Eggman_ctor; Core.StartShopScene = 1; Pickup_GetTaken(p); } // --- 0x639b: il guaritore di Moongolow, sette occhi neri in orbita che respirano ------------------------------------ typedef struct { Sprite eye[7]; float r[7], a[7]; } HealerX; static void Healer_ctor(Pickup *p) { HealerX *h = calloc(1, sizeof(HealerX)); p->ext = h; sprite_setScale(&p->s, 4); body_setCircle(&p->s.body, 0x10, p->s.body.offset.x, p->s.body.offset.y); static const float A[7] = { 0, 0.23f, 0.41f, 0.61f, 0.71f, 0.79f, 0.83f }, S[7] = { 2, 1.75f, 1.5f, 1.25f, 1, 0.75f, 0.5f }, S2[7] = { 0.5f, 0.75f, 1, 1.25f, 1.5f, 1.75f, 2 }; static const float D[7] = { 0x3f1, 0x4c1, 0x5d1, 0x653, 0x745, 0x833, 0x925 }; for (int i = 0; i < 7; i++) { h->r[i] = 0x6c, h->a[i] = 2 * PI * A[i]; sprite_init(&h->eye[i], frame_get("vfx", "eyeanim_0.png"), p->s.x, p->s.y); sprite_setScale(&h->eye[i], S[i]), sprite_setTintFill(&h->eye[i], 0); children_add(&h->eye[i]); tweens_add((TweenConfig){ .props = { { &h->r[i], NULL, 0x36 } }, .nprops = 1, .duration = D[i], .yoyo = 1, .repeat = -1 }); tweens_add((TweenConfig){ .props = { { &h->eye[i].scaleX, &h->eye[i].scaleY, S2[i] } }, .nprops = 1, .duration = D[i], .yoyo = 1, .repeat = -1 }); } } static void Healer_OnRecycle(Pickup *p) { Pickup_OnRecycle(p); p->goToPlayer = 1, p->isStationary = 1; sprite_setFrame(&p->s, frame_get("items", "Healer.png")); } static void Healer_Update(Pickup *p) { HealerX *h = p->ext; if (p->goToPlayer && !p->isStationary) Pickup_GoToPlayer(p); // super.Update p->s.depth = 9 + p->s.y - Core.Player->s.y; for (int i = 0; i < 7; i++) h->eye[i].depth = p->s.depth + 2; Vector2 s = Pickup_safeXY(p, p->s.x, p->s.y); p->s.x = s.x, p->s.y = s.y; for (int i = 0; i < 7; i++) h->a[i] += PI / 0xb4 * (0x64 / 6.0f); // angleUnit * delta (un frame a 60 FPS) static const int RX[7] = { 0, 2, 4, 6, 1, 3, 5 }, RY[7] = { 1, 3, 5, 0, 2, 4, 6 }; // eye1: radius1/radius2, eye2: radius3/radius4, ... for (int i = 0; i < 7; i++) h->eye[i].x = p->s.x + cosf(h->a[i]) * h->r[RX[i]], h->eye[i].y = p->s.y + sinf(h->a[i]) * h->r[RY[i]]; } static void Healer_GetTaken(Pickup *p) { if (p->disableGet) return; HealerX *h = p->ext; for (int i = 0; i < 7; i++) h->eye[i].visible = 0; // (sic) non tornano piu' visibili Core.StartHealerScene = 1; Pickup_GetTaken(p); } // --- 0x301a Teleporter (le porte di Astral Stair) e 0x8504 Moongate (le lune di Gallo Tower), a coppie ------------- static void Guarded_OnRecycle(Pickup *p) { // PickupGuarded.OnRecycle Pickup_OnRecycle(p); p->guardRadius = 0.5f * 0x1c8; PickupGuarded_UpdateBounds(p); p->hasSpawned = 0, p->n_guards = 0; if (!list_contains(&Core.PickupsWithArrows, &p->s)) list_add(&Core.PickupsWithArrows, &p->s); } static void Guarded_Update(Pickup *p) { // PickupGuarded.Update if (p->goToPlayer && !p->isStationary) Pickup_GoToPlayer(p); if (!p->hasSpawned && !(Core.Player->s.y > p->bottom || Core.Player->s.y < p->top || Core.Player->s.x > p->right || Core.Player->s.x < p->left)) PickupGuarded_TriggerSpawn(p); } static void Enemy_Disappear(Enemy *e); typedef struct { Sprite door, beam, whiteFader; Animation open; } TeleX; static void Teleporter_ctor(Pickup *p) { TeleX *x = calloc(1, sizeof(TeleX)); p->ext = x; p->triggerDelay = 0x1e, p->isStationary = 1; sprite_init(&x->door, frame_get("background_Astral", "door01.png"), p->s.x, p->s.y); sprite_setOrigin(&x->door, 0.5f, 1), x->door.depth = -0x7cb; children_add(&x->door); make_anim(&x->open, "background_Astral", "door", 1, 0x10, 2, 0x40, 0); sprite_init(&x->beam, frame_get("vfx", "Beam.png"), 0, 0); // MakeDoorVFX x->beam.scaleX = 0, x->beam.scaleY = 1, sprite_setTint(&x->beam, 0xfafafa), x->beam.blendAdd = 1, x->beam.depth = 0x7cc; children_add(&x->beam); sprite_init(&x->whiteFader, frame_get("vfx", "WhiteDot.png"), 0, 0); sprite_setTint(&x->whiteFader, 0xfafafa), sprite_setOrigin(&x->whiteFader, 0, 0), x->whiteFader.scrollFactor0 = 1, x->whiteFader.alpha = 0, x->whiteFader.depth = 0x7cc; x->whiteFader.scaleX = game_width / fmaxf(1, x->whiteFader.width), x->whiteFader.scaleY = game_height / fmaxf(1, x->whiteFader.height); children_add(&x->whiteFader); if (po_is("SelectedInverse") && po_is("VisuallyInvertStages")) x->door.scaleY = -1; // door.setScale(1, -1) p->canTeleport = 1; } static void Teleporter_OnRecycle(Pickup *p) { Guarded_OnRecycle(p); p->colorValue = 0; body_setCircle(&p->s.body, 0xc, -6, 6); p->s.visible = 0; } static void Teleporter_DeSpawn(Pickup *p) { (void)p; } static void Teleporter_Update(Pickup *p) { TeleX *x = p->ext; Guarded_Update(p); p->s.depth = -0x7cb, p->triggerDelay = 0x2710; x->door.x = p->s.x, x->door.y = p->s.y; } static void Tele_enable(void *ctx) { Pickup *p = ctx; p->canTeleport = 1, p->s.body.enable = 1; } static void Teleporter_Disable(Pickup *p) { p->s.body.enable = 0; time_addEvent(p->triggerDelay, 0, 0, Tele_enable, p); } static void Tele_yoyo(void *ctx) { // a schermo bianco: il raggio sparisce, la porta si chiude e il giocatore passa Pickup *p = ctx; TeleX *x = p->ext; x->beam.scaleX = x->beam.scaleY = 0; anims_stop(&x->door), sprite_setFrame(&x->door, frame_get("background_Astral", "door01.png")); Core.Player->s.x = p->destinationX, Core.Player->s.y = p->destinationY; // DoTeleport for (int i = 0; i < Core.Enemies.n; i++) { Enemy *e = Core.Enemies.items[i]->owner; if (!e->res_Rosary) Enemy_Disappear(e); } } static void Tele_finished(void *ctx) { // OnTeleportFinished (void)ctx; for (int i = 0; i < Core.Enemies.n; i++) { Enemy *e = Core.Enemies.items[i]->owner; if (!e->IsTimeStopped) e->speed = e->defaultSpeed; } } static void Teleporter_GetTaken(Pickup *p) { if (p->disableGet || !p->canTeleport) return; TeleX *x = p->ext; p->canTeleport = 0; Teleporter_Disable(p), Teleporter_Disable(p->link); anims_play(&x->door, &x->open, 0); // StartTeleport -> OpenDoorAnimation x->beam.x = x->door.x, x->beam.y = x->door.y; tweens_add((TweenConfig){ .props = { { &x->beam.scaleX, NULL, 3 }, { &x->beam.scaleY, NULL, 0x14 } }, .nprops = 2, .duration = 0xc8 }); tweens_add((TweenConfig){ .props = { { &x->whiteFader.alpha, NULL, 1 } }, .nprops = 1, .duration = 0x12c, .yoyo = 1, .onYoyo = Tele_yoyo, .onComplete = Tele_finished, .ctx = p }); for (int i = 0; i < Core.Enemies.n; i++) ((Enemy *)Core.Enemies.items[i]->owner)->speed = 0; json_inc(cJSON_GetObjectItem(data_get("items"), p->vt->itemType), "pickedupAmount"); } static void Tele_LinkTo(Pickup *p, Pickup *l) { p->link = l, p->destinationX = l->s.x, p->destinationY = l->s.y + 0x30; if (po_is("SelectedInverse") && po_is("VisuallyInvertStages")) p->destinationY = l->s.y - 0x30; } static void Moongate_ctor(Pickup *p) { p->weaponType = "VOID", p->particlesInterval = 0xc8, p->totalTime = 0x64, p->triggerDelay = 0x1e, p->isStationary = 1; sprite_setScale(&p->s, PixelScale); sprite_init(&p->glow, frame_get("vfx", "round.png"), p->s.x, p->s.y); p->pfx = particles_add(); static const char *const R[5] = { "_runes_02.png", "_runes_03.png", "_runes_04.png", "_runes_05.png", "_runes_06.png" }; EmitterConfig c = { .lifespan = EOP(0x7d0), .rotate = ERND(0, 0x168), .angle = ERND(0xf0, 0x12c), .speed = ERND(0xa, 0x32), .quantity = 1, .scale = ERANGE(0.3f, 0.5f), .alpha = ERANGE(1, 0), .frequency = 0x1f4, .tints = { 0xaaffff }, .ntints = 1, .blendAdd = 1, .on = 1 }; for (int i = 0; i < 5; i++) c.frames[i] = frame_get("vfx", R[i]); c.nframes = 5; p->pfxE = particles_createEmitter(p->pfx, c); } static void Moongate_OnRecycle(Pickup *p) { Guarded_OnRecycle(p); p->colorValue = 0; body_setCircle(&p->s.body, 0x18, -0xc, 0xc); p->pfx->s.depth = p->s.depth; children_add(&p->glow); p->glow.x = p->s.x, p->glow.y = p->s.y, p->glow.blendAdd = 1, p->glow.alpha = 0.5f; tween_remove(p->glowTween); p->glowTween = tweens_add((TweenConfig){ .props = { { &p->glow.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x1f4, .loop = -1, .yoyo = 1 }); p->s.visible = 0; p->pfxE->x = p->s.x, p->pfxE->y = p->s.y; } static void Moongate_Update(Pickup *p) { Guarded_Update(p); p->s.depth = 9 + p->s.y - Core.Player->s.y, p->pfx->s.depth = p->s.depth; p->glow.x = p->s.x, p->glow.y = p->s.y - 0x30, p->glow.depth = p->s.y - Core.Player->s.y; p->colorValue += 0.1f; p->glow.tint = (unsigned)(0xff * fabsf(sinf(p->colorValue))) << 16 | (unsigned)(0xff * fabsf(cosf(0.5f * p->colorValue))) << 8 | (unsigned)(0xc8 + 0x37 * fabsf(cosf(p->colorValue))); p->triggerDelay = 0x4e20, p->canTeleport = 1; // (sic) torna sempre vero: conta solo il corpo spento } static void Moon_enable(void *ctx) { Pickup *p = ctx; p->canTeleport = 1, p->s.body.enable = 1, p->glow.visible = 1, emitter_start(p->pfxE); } static void Moongate_Disable(Pickup *p) { p->s.body.enable = 0, p->glow.visible = 0; emitter_stop(p->pfxE); time_addEvent(p->triggerDelay, 0, 0, Moon_enable, p); } static void Moongate_GetTaken(Pickup *p) { if (p->disableGet || !p->canTeleport) return; p->canTeleport = 0; Moongate_Disable(p), Moongate_Disable(p->link); Core.Player->s.x = p->destinationX, Core.Player->s.y = p->destinationY; } static void Moon_LinkTo(Pickup *p, Pickup *l) { p->link = l, p->destinationX = l->s.x, p->destinationY = l->s.y; } // --- 0xf1f6: l'uovo d'oro a terra (Mietitore, maschere) --------------------------------------------------------- static void Core_RemoveStagePickup(Pickup *p) { // StagePickups.splice(indexOf(this), 1) for (int i = 0; i < Core.n_StagePickups; i++) if (Core.StagePickups[i] == p) { memmove(&Core.StagePickups[i], &Core.StagePickups[i + 1], (--Core.n_StagePickups - i) * sizeof(Pickup *)); break; } } static void GoldenEgg_ctor(Pickup *p) { sprite_setScale(&p->s, PixelScale); sprite_init(&p->Cursor, frame_get("UI", "arrow_01.png"), p->s.x, p->s.y); p->Cursor.depth = 0x270e, p->Cursor.alpha = 0.75f, p->Cursor.blendAdd = 1; sprite_setScale(&p->Cursor, 2); children_add(&p->Cursor); sprite_init(&p->CursorIcon, frame_get("items", "goldenegg.png"), p->s.x, p->s.y); p->CursorIcon.depth = 0x270f; children_add(&p->CursorIcon); make_anim(&p->cursorIdle, "UI", "arrow_", 1, 8, 2, 0x10, -1); anims_play(&p->Cursor, &p->cursorIdle, 0); p->Cursor.visible = p->CursorIcon.visible = 0; } static void GoldenEgg_Update(Pickup *p) { if (p->goToPlayer && !p->isStationary) Pickup_GoToPlayer(p); // super.Update p->s.depth = 9 + p->s.y - Core.Player->s.y; if ((fabsf(p->s.x - Core.Player->s.x) < 0.5f * game_width && fabsf(p->s.y - Core.Player->s.y) < 0.5f * game_height) || !po_is("ShowPickups")) p->Cursor.visible = p->CursorIcon.visible = 0; else { float a = Pickup_AngleFromTargetRadians(p); p->Cursor.angle = a * RAD2DEG; p->Cursor.x = Core.Player->s.x + 0.45f * cosf(a) * game_width; p->Cursor.y = Core.Player->s.y + 0.45f * sinf(a) * game_height; p->Cursor.alpha = 0.75f, p->Cursor.blendAdd = 1, p->Cursor.visible = 1; p->CursorIcon.x = p->Cursor.x, p->CursorIcon.y = p->Cursor.y, p->CursorIcon.visible = 1; } Vector2 s = Pickup_safeXY(p, p->s.x, p->s.y); p->s.x = s.x, p->s.y = s.y; } static void GoldenEgg_DeSpawn(Pickup *p) { Pickup_DeSpawn(p); p->Cursor.visible = p->CursorIcon.visible = 0; Core_RemoveStagePickup(p); } static void Sigma_eggGone(void *ctx) { children_remove(ctx); free(ctx); } static void GoldenEgg_GetTaken(Pickup *p) { if (p->disableGet) return; if (!strcmp(po_str("SelectedCharacter"), "SIGMA")) { // Sigma non tiene le uova: vola via in alto a sinistra Sprite *e = calloc(1, sizeof(Sprite)); sprite_init(e, frame_get("items", "goldenegg.png"), 0.5f * game_width, 0.5f * game_height); e->scrollFactor0 = 1, e->depth = 1; children_add(e); tweens_add((TweenConfig){ .props = { { &e->x, NULL, -0x64 }, { &e->y, NULL, -0x64 }, { &e->angle, NULL, 0x2d0 } }, .nprops = 3, .duration = 0x1f4 }); tweens_add((TweenConfig){ .props = { { &e->scaleX, &e->scaleY, 1.4f } }, .nprops = 1, .duration = 0x1f4, .onComplete = Sigma_eggGone, .ctx = e }); Core_RemoveStagePickup(p); GoldenEgg_DeSpawn(p); return; } int a = EggManager_AddGoldenEgg(); EggManager_ShowResultAt(Core.Player->s.x, Core.Player->s.y, a, -0x10, -0x10, -1); RunPickups_push(p->itemType); Pickup_SetSeenItem(p->itemType); Pickup_GetTaken(p); Sound_PlaySound("Roast", 0.5f, 1, 0xc8, 0, 0), Sound_PlaySound("Roast", 0.5f, 1, 0x190, 0, 0), Sound_PlaySound("Roast", 0.5f, 1, 0x258, 0, 0); Core_RemoveStagePickup(p); } static void LittleHeart_GetTaken(Pickup *p) { // 0x16fe9: cuoricino, 1 HP if (p->disableGet) return; Player_RecoverHp(Core.Player, 1, 1, 1); Pickup_SetSeenItem(p->itemType); Pickup_GetTaken(p); Sound_PlaySound("LittleHeart", p->quiet ? 0.1f : 0.35f, 1.2f, 0xc8 * (frand() - 0.5f), 0x32, 3); } static int AchievementManager_UnlockSecret(const char *k); static void Pickup_SetSeenItem(const char *t); // --- 0x13742 Coffin e 0x444 CoffinX: la bara del personaggio da sbloccare, aperta quando le guardie sono morte -------- static void Coffin_ctor(Pickup *p) { p->charCFF = "VOID", p->totalTime = 0x64, p->particlesInterval = 0xc8, p->isStationary = 1; sprite_setScale(&p->s, PixelScale); sprite_init(&p->Lid, frame_get("items", "CoffinLid.png"), 0, 0); sprite_init(&p->CharSprite, NULL, 0, 0); sprite_setScale(&p->CharSprite, 0); // Cursor e CursorIcon: visibili solo con PlayerOptions.ShowPickups, spento di default } static void Coffin_OnRecycle(Pickup *p) { Pickup_OnRecycle(p); p->guardRadius = 0.5f * 0x1c8; // PickupGuarded.OnRecycle PickupGuarded_UpdateBounds(p); p->hasSpawned = 0, p->n_guards = 0, p->opened = 0; body_setCircle(&p->s.body, 0x10, 0, 8); sprite_setFrame(&p->s, frame_get("items", "Coffin.png")); p->Lid.x = p->s.x, p->Lid.y = p->s.y, p->Lid.visible = 1, p->Lid.angle = 0, p->Lid.scaleX = p->Lid.scaleY = 1; p->CharSprite.x = p->s.x, p->CharSprite.y = p->s.y, p->CharSprite.visible = 1, p->CharSprite.scaleX = p->CharSprite.scaleY = 0; sprite_setTintFill(&p->CharSprite, 0); children_add(&p->Lid); children_add(&p->CharSprite); } static void Coffin_DeSpawn(Pickup *p) { Pickup_DeSpawn(p); } static int Coffin_guardsAlive(Pickup *p) { for (int i = 0; i < p->n_guards; i++) if (!p->guards[i]->isDead) return 1; return 0; } static void Coffin_Update(Pickup *p) { if (!p->hasSpawned && !(Core.Player->s.y > p->bottom || Core.Player->s.y < p->top || Core.Player->s.x > p->right || Core.Player->s.x < p->left)) PickupGuarded_TriggerSpawn(p); // PickupGuarded.Update p->s.depth = 9 + p->s.y - Core.Player->s.y, p->Lid.depth = 0xa + p->s.y - Core.Player->s.y, p->CharSprite.depth = p->Lid.depth; // vicino (o senza ShowPickups): scintille quando le guardie sono morte if (Coffin_guardsAlive(p)) return; p->totalTime += 0x64 / 6.0f; // Update(delta): un frame if (p->totalTime > p->particlesInterval) { p->totalTime = 0; manager_emitParticleAt(Core.PfxEmitter_Pickups, p->s.x, p->s.y); } } static void Coffin_setChar(Pickup *p, const char *ch) { p->charCFF = ch; cJSON *c = tbl0("characters", ch); if (c) sprite_setFrame(&p->CharSprite, frame_get("characters", p->isCoffinX ? "random_00.png" : str(c, "spriteName"))); } static void Coffin_TriggerCharScene(void *ctx) { Pickup *p = ctx; p->Lid.visible = 0; if (p->isCoffinX) { Sound_PlaySound("ThingFound", 1, 0.5f, -0x3e8, 0, 0); Pickup_GetTaken(p); return; } if (Core.n_CharQueue < 8) Core.CharQueue[Core.n_CharQueue++] = p->charCFF; Pickup_SetSeenItem(p->itemType); Pickup_GetTaken(p); } static void Coffin_hideChar(void *ctx) { ((Pickup *)ctx)->CharSprite.visible = 0; } static void Coffin_GetTaken(Pickup *p) { if (p->disableGet || p->opened || Coffin_guardsAlive(p)) return; p->opened = 1; if (p->isCoffinX) AchievementManager_UnlockSecret("UnderTheCoffin"); else { Sound_FadeMusic(0.1f, 0x64); } Sound_PlaySound("Lid", 2, 1, 0, 0x96, 2); if (!p->isCoffinX) Sound_PlaySound("ThingFound", 1.4f, 1, -0x7d0, 0, 0); tweens_add((TweenConfig){ .props = { { &p->CharSprite.scaleX, NULL, 2 }, { &p->CharSprite.scaleY, NULL, 4 } }, .nprops = 2, .duration = 0x64 }); tweens_add((TweenConfig){ .props = { { &p->CharSprite.y, NULL, p->s.y - game_height } }, .nprops = 1, .duration = 0x190, .onComplete = Coffin_hideChar, .ctx = p }); tweens_add((TweenConfig){ .props = { { &p->Lid.scaleX, NULL, -1 } }, .nprops = 1, .duration = 0x1f4 }); // (piu' di TWEEN_DATA proprieta': due tween) tweens_add((TweenConfig){ .props = { { &p->Lid.y, NULL, p->s.y - 0.75f * game_height }, { &p->Lid.x, NULL, p->s.x - 0.75f * game_width }, { &p->Lid.angle, NULL, 0x168 } }, .nprops = 3, .duration = 0x1f4, .onComplete = Coffin_TriggerCharScene, .ctx = p }); } static void CoffinX_ctor(Pickup *p) { Coffin_ctor(p); p->isCoffinX = 1; } // --- COFFIN_EMPTY (0x1072b): le nove bare del pianoforte; quasi tutte vuote ("Empty"), una con Avatar (OnOpen) ----------------- // itemType resta COFFIN_EMPTY (l'originale passa COFFIN al costruttore): qui il pool dei pickup e' per itemType static void text_at(const char *s, float x, float y, float size, float ox, float oy, Color c); static void EmptyText_draw(Sprite *s) { // scene.add.text(x, y, 'Empty', { align: center }): 16 px, origine 0.5 if (!s->visible || s->alpha <= 0 || s->scaleX <= 0) return; text_at("Empty", roundf(s->x - camera_scrollX), roundf(s->y - camera_scrollY), 16 * s->scaleX, 0.5f, 0.5f, Fade(WHITE, s->alpha)); } static void EmptyText_gone(void *ctx) { children_remove(ctx); } static void EmptyText_fade(void *ctx) { Sprite *t = ctx; tweens_add((TweenConfig){ .props = { { &t->alpha, NULL, 0 } }, .nprops = 1, .duration = 0x3e8, .onComplete = EmptyText_gone, .ctx = t }); } static void EmptyText_rise(void *ctx) { Sprite *t = ctx; tweens_add((TweenConfig){ .props = { { &t->y, NULL, t->y - 0x10 } }, .nprops = 1, .duration = 0x7d0, .onComplete = EmptyText_fade, .ctx = t }); } static void CoffinEmpty_lidDone(void *ctx) { Pickup *p = ctx; p->Lid.visible = 0; Pickup_GetTaken(p); } static void CoffinEmpty_GetTaken(Pickup *p) { if (p->disableGet || p->opened) return; if (p->charCFF && strcmp(p->charCFF, "VOID")) { tweens_add((TweenConfig){ .props = { { &p->CharSprite.scaleX, NULL, 2 }, { &p->CharSprite.scaleY, NULL, 4 } }, .nprops = 2, .duration = 0x64 }); tweens_add((TweenConfig){ .props = { { &p->CharSprite.y, NULL, p->s.y - game_height } }, .nprops = 1, .duration = 0x190, .onComplete = Coffin_hideChar, .ctx = p }); } else { Sprite *t = gmem_calloc(1, sizeof(Sprite)); sprite_init(t, NULL, p->s.x, p->s.y); t->draw = EmptyText_draw, t->scaleX = t->scaleY = 0, t->depth = 0xbba; children_add(t); tweens_add((TweenConfig){ .props = { { &t->scaleX, &t->scaleY, 1 } }, .nprops = 1, .duration = 0xc8, .onComplete = EmptyText_rise, .ctx = t }); } if (p->OnOpen) p->OnOpen(); p->opened = 1; Sound_PlaySound("Lid", 2, 1, 0, 0x96, 2); tweens_add((TweenConfig){ .props = { { &p->Lid.scaleX, NULL, -1 } }, .nprops = 1, .duration = 0x1f4 }); // un tween solo nell'originale (4 proprieta') tweens_add((TweenConfig){ .props = { { &p->Lid.y, NULL, p->s.y - 0.75f * game_height }, { &p->Lid.x, NULL, p->s.x - 0.75f * game_width }, { &p->Lid.angle, NULL, 0x168 } }, .nprops = 3, .duration = 0x1f4, .onComplete = CoffinEmpty_lidDone, .ctx = p }); } static void Core_RosaryDamage(void); static int AchievementManager_UnlockSecret(const char *k); static void Cosmo_ctor(Pickup *p) { // 0x936d: Cosmo Pavone, sul balcone della Cappella (itemType COSMO_PAVONE) static Animation idle; if (!idle.n) make_anim(&idle, "characters", "Cosmic_0", 1, 4, 0, 0x10, -1); p->idle = idle; anims_play(&p->s, &p->idle, 0); } static void Cosmo_Update(Pickup *p) { p->goToPlayer = 1, p->isStationary = 1; Item_Update(p); } static void Cosmo_GetTaken(Pickup *p) { Core_RosaryDamage(); if (!po_has("UnlockedCharacters", "PAVONE")) AchievementManager_UnlockSecret("PureHeart"); Pickup_GetTaken(p); } static Texture2D img_texture(const char *key); // --- 0xb5aa: il Directer da raccogliere nella Machine (v_i01-04), sette maschere in orbita, mani, stelle dentro la sagoma --- typedef struct { Sprite eye[7], hand[2]; float r[7], a[7]; Animation idle, handIdle; float t; } DirecterX; static void DirecterPickup_drawStars(Sprite *s); static void Directer_ctor(Pickup *p) { DirecterX *h = calloc(1, sizeof(DirecterX)); p->ext = h; sprite_setScale(&p->s, 5); // setScale(PixelScale) poi setScale(5) body_setCircle(&p->s.body, 0x10, p->s.body.offset.x, p->s.body.offset.y); static const float A[7] = { 0, 0.23f, 0.41f, 0.61f, 0.71f, 0.79f, 0.83f }, S[7] = { 2, 1.75f, 1.5f, 1.25f, 1, 0.75f, 0.5f }, S2[7] = { 0.5f, 0.75f, 1, 1.25f, 1.5f, 1.75f, 2 }; static const float D[7] = { 0x3f1, 0x4c1, 0x5d1, 0x653, 0x745, 0x833, 0x925 }; static const char *const M[7] = { "mask_sun_0.png", "mask_moon_0.png", "mask_city_0.png", "mask_seawind_0.png", "mask_volcano_0.png", "mask_stone_0.png", "nomask_0.png" }; for (int i = 0; i < 7; i++) { h->r[i] = 0x40, h->a[i] = 2 * PI * A[i]; sprite_init(&h->eye[i], frame_get("enemiesM", M[i]), p->s.x, p->s.y); sprite_setScale(&h->eye[i], S[i]); children_add(&h->eye[i]); tweens_add((TweenConfig){ .props = { { &h->r[i], NULL, 0x20 } }, .nprops = 1, .duration = D[i], .yoyo = 1, .repeat = -1 }); // radiusN -> 32 tweens_add((TweenConfig){ .props = { { &h->eye[i].scaleX, &h->eye[i].scaleY, S2[i] } }, .nprops = 1, .duration = D[i], .yoyo = 1, .repeat = -1 }); } make_anim(&h->handIdle, "enemiesM", "hand_", 1, 4, 2, 8, -1); for (int k = 0; k < 2; k++) { // LeftHand (origine 1, 0.5) e RightHand (0, 0.5, specchiata), capovolte; alpha 0.4 e scala 0.9 in yoyo sprite_init(&h->hand[k], frame_get("enemiesM", "hand_01.png"), p->s.x, p->s.y); sprite_setOrigin(&h->hand[k], k ? 0 : 1, 0.5f), h->hand[k].flipY = 1, h->hand[k].flipX = k; anims_play(&h->hand[k], &h->handIdle, 0); children_add(&h->hand[k]); tweens_add((TweenConfig){ .props = { { &h->hand[k].alpha, NULL, 0.4f }, { &h->hand[k].scaleX, &h->hand[k].scaleY, 0.9f } }, .nprops = 2, .duration = 0x3e8, .yoyo = 1, .repeat = -1 }); } make_anim(&h->idle, "enemiesM", "v_i", 1, 4, 2, 0xc, -1); } static void Directer_OnRecycle(Pickup *p) { Pickup_OnRecycle(p); p->goToPlayer = 1, p->isStationary = 1; DirecterX *h = p->ext; sprite_setFrame(&p->s, frame_get("enemiesM", "v_i01.png")); anims_play(&p->s, &h->idle, 0); p->s.draw = DirecterPickup_drawStars; } static void Directer_Update(Pickup *p) { DirecterX *h = p->ext; if (p->goToPlayer && !p->isStationary) Pickup_GoToPlayer(p); // super.Update p->s.depth = 9 + p->s.y - Core.Player->s.y; // isBehind: mai for (int i = 0; i < 7; i++) h->eye[i].depth = 0x49 + h->eye[i].y - Core.Player->s.y; for (int k = 0; k < 2; k++) h->hand[k].x = p->s.x + (k ? 0x30 : -0x30), h->hand[k].y = p->s.y, h->hand[k].depth = p->s.depth + 2; sprite_animsUpdate(&h->hand[0], 1000 / 60.0f), sprite_animsUpdate(&h->hand[1], 1000 / 60.0f); Vector2 s = Pickup_safeXY(p, p->s.x, p->s.y); p->s.x = s.x, p->s.y = s.y; for (int i = 0; i < 7; i++) h->a[i] += PI / 0x168 * (1000 / 60.0f); // angleUnit * delta // eye i: x = 108 cos(angle i), y = -64 + sin(angle i+1) * radius (2, 4, 6, 1, 3, 5, 7) static const int RY[7] = { 1, 3, 5, 0, 2, 4, 6 }; for (int i = 0; i < 7; i++) h->eye[i].x = p->s.x + 0x6c * cosf(h->a[i]), h->eye[i].y = -0x40 + p->s.y + sinf(h->a[(i + 1) % 7]) * h->r[RY[i]]; h->t += 1000 / 60.0f; } static void Directer_GetTaken(Pickup *p) { if (p->disableGet || Core.StartDirecterScene) return; Core.StartDirecterScene = 1, p->disableGet = 1; // (sic) il pickup resta dov'e' } // Il Directer e le stelle: stars1/stars2 (hStars1, hStars2, alpha 1 -> 0.6 in yoyo, sfalsate di 500 ms) con la bitmap mask del Directer. // Uno shader prende l'alpha dal fotogramma e il colore dalle stelle in coordinate dello schermo (sono setScrollFactor(0)). static struct { Shader sh; int locStars, locRes, locAlpha, tried; } DStars; static void DStars_draw(Sprite *s, float t) { // pickup e nemico: il fotogramma, poi le due stelle dentro la sua sagoma void (*dr)(Sprite *) = s->draw; s->draw = NULL; scene_render_one(s, (Shader){ 0 }); // il Directer s->draw = dr; if (!DStars.tried) { DStars.tried = 1; static const char *FS = #ifdef __vita__ "#version 100\nprecision highp float;\nvarying vec2 fragTexCoord;\nvarying vec4 fragColor;\nuniform sampler2D texture0;\nuniform sampler2D stars;\nuniform vec2 res;\nuniform float salpha;\n" "void main() { float a = texture2D(texture0, fragTexCoord).a; vec4 st = texture2D(stars, gl_FragCoord.xy / res); gl_FragColor = vec4(st.rgb, st.a * a * salpha); }\n"; #else "#version 330\nin vec2 fragTexCoord;\nin vec4 fragColor;\nuniform sampler2D texture0;\nuniform sampler2D stars;\nuniform vec2 res;\nuniform float salpha;\nout vec4 finalColor;\n" "void main() { float a = texture(texture0, fragTexCoord).a; vec4 st = texture(stars, gl_FragCoord.xy / res); finalColor = vec4(st.rgb, st.a * a * salpha); }\n"; #endif DStars.sh = LoadShaderFromMemory(NULL, FS); DStars.locStars = GetShaderLocation(DStars.sh, "stars"), DStars.locRes = GetShaderLocation(DStars.sh, "res"), DStars.locAlpha = GetShaderLocation(DStars.sh, "salpha"); } if (!DStars.sh.id || DStars.locStars < 0) return; for (int k = 0; k < 2; k++) { Texture2D st = img_texture(k ? "hStars2" : "hStars1"); float ph = fmodf(fmaxf(0, t - (k ? 0 : 0x1f4)), 2 * 0x3e8) / 0x3e8, al = 1 - 0.4f * (ph < 1 ? ph : 2 - ph); float res[2] = { (float)st.width, (float)st.height }; rlDrawRenderBatchActive(); BeginShaderMode(DStars.sh); SetShaderValueTexture(DStars.sh, DStars.locStars, st); SetShaderValue(DStars.sh, DStars.locRes, res, SHADER_UNIFORM_VEC2); SetShaderValue(DStars.sh, DStars.locAlpha, &al, SHADER_UNIFORM_FLOAT); Sprite c = *s; c.draw = NULL; scene_render_one(&c, (Shader){ 0 }); rlDrawRenderBatchActive(); EndShaderMode(); } } static void DirecterPickup_drawStars(Sprite *s) { DStars_draw(s, ((DirecterX *)((Pickup *)s->owner)->ext)->t); } static const PickupVT pickupTypes[] = { { "GEM", Gem_ctor, NULL, NULL, Gem_GetTaken, Gem_Update }, { "TREASURE", Treasure_ctor, Treasure_OnRecycle, Treasure_DeSpawn, Treasure_GetTaken, Treasure_Update }, { "COIN", NULL, NULL, NULL, Coin_GetTaken, Item_Update }, { "COINBAG1", NULL, NULL, NULL, Coin_GetTaken, Item_Update }, { "COINBAGMAX", NULL, NULL, NULL, Coin_GetTaken, Item_Update }, { "ROAST", NULL, NULL, NULL, Roast_GetTaken, Item_Update }, { "COINBAG2", NULL, NULL, NULL, CoinBag2_GetTaken, Item_Update }, { "ALWAYS_COINBAG2", Always_ctor, NULL, NULL, AlwaysCoinbag_GetTaken, NULL }, { "ALWAYS_ROAST", Always_ctor, NULL, NULL, AlwaysRoast_GetTaken, NULL }, { "COSMO_PAVONE", Cosmo_ctor, NULL, NULL, Cosmo_GetTaken, Cosmo_Update }, { "CLOVER", NULL, NULL, NULL, Clover_GetTaken, Item_Update }, { "ROSARY", Idle_ctor, Idle_OnRecycle, NULL, Rosary_GetTaken, Item_Update }, { "OROLOGION", Idle_ctor, Idle_OnRecycle, NULL, Orologion_GetTaken, Item_Update }, { "VACUUM", Idle_ctor, Idle_OnRecycle, NULL, Vacuum_GetTaken, Item_Update }, { "NFT", Idle_ctor, Idle_OnRecycle, NULL, Nft_GetTaken, Item_Update }, { "GILDED", Idle_ctor, Idle_OnRecycle, NULL, Gilded_GetTaken, Item_Update }, { "LITTLEHEART", NULL, NULL, NULL, LittleHeart_GetTaken, Item_Update }, { "WEAPON", WeaponPickup_ctor, WeaponPickup_OnRecycle, WeaponPickup_DeSpawn, WeaponPickup_GetTaken, WeaponPickup_Update }, { "COFFIN", Coffin_ctor, Coffin_OnRecycle, Coffin_DeSpawn, Coffin_GetTaken, Coffin_Update }, { "COFFINX", CoffinX_ctor, Coffin_OnRecycle, Coffin_DeSpawn, Coffin_GetTaken, Coffin_Update }, { "COFFIN_EMPTY", Coffin_ctor, Coffin_OnRecycle, Coffin_DeSpawn, CoffinEmpty_GetTaken, Coffin_Update }, { "RELIC", Relic_ctor, Relic_OnRecycle, Relic_DeSpawn, Relic_GetTaken, Relic_Update }, { "RELIC_GOLDENEGG", GoldenEgg_ctor, NULL, GoldenEgg_DeSpawn, GoldenEgg_GetTaken, GoldenEgg_Update }, { "MERCHANT", Merchant_ctor, Merchant_OnRecycle, NULL, Merchant_GetTaken, Merchant_Update }, { "EGGMAN", Eggman_ctor, Merchant_OnRecycle, NULL, Merchant_GetTaken, Merchant_Update }, { "HEALER", Healer_ctor, Healer_OnRecycle, NULL, Healer_GetTaken, Healer_Update }, { "DIRECTER", Directer_ctor, Directer_OnRecycle, NULL, Directer_GetTaken, Directer_Update }, { "TELEPORTER", Teleporter_ctor, Teleporter_OnRecycle, Teleporter_DeSpawn, Teleporter_GetTaken, Teleporter_Update }, { "MOONGATE", Moongate_ctor, Moongate_OnRecycle, Teleporter_DeSpawn, Moongate_GetTaken, Moongate_Update }, }; static const PickupVT *pickup_vt(const char *type) { for (size_t i = 0; i < sizeof(pickupTypes) / sizeof(*pickupTypes); i++) if (!strcmp(pickupTypes[i].itemType, type)) return &pickupTypes[i]; return NULL; } // --- 0x166d5: Pickup -------------------------------------------------------------- static void Pickup_OnRecycle(Pickup *p) { p->s.active = 1; p->s.visible = 1; sprite_setFrame(&p->s, frame_get("items", p->frameName)); p->s.body.enable = 1; p->goToPlayer = 0; p->speed = p->DEFAULT_SPEED; cJSON *it = cJSON_GetObjectItem(data_get("items"), p->itemType); p->value = num(it, "value", 0); p->feverMS = num(it, "feverMS", 0); } static Pickup *Pickup_new(PickupPool *pool, const char *type) { // PickupPool.Make: new (pool, 0, 0) const PickupVT *vt = pickup_vt(type); if (!vt) return NULL; Pickup *p = calloc(1, sizeof(Pickup)); sprite_init(&p->s, NULL, 0, 0); p->s.owner = p; p->pool = pool; p->vt = vt; p->DEFAULT_SPEED = 0xfa; p->radius = 0xa; p->speed = p->DEFAULT_SPEED; p->isCullable = 1; p->itemType = vt->itemType; cJSON *it = cJSON_GetObjectItem(data_get("items"), p->itemType); p->frameName = str(it, "frameName"); p->value = num(it, "value", 0); p->feverMS = num(it, "feverMS", 0); sprite_setFrame(&p->s, frame_get("items", p->frameName)); children_add(&p->s); physics_existing(&p->s); sprite_setScale(&p->s, PixelScale); body_setCircle(&p->s.body, p->radius, p->s.body.offset.x, p->s.body.offset.y); p->vacuumTween = tweens_add((TweenConfig){ .props = { { &p->time, NULL, 1 } }, .nprops = 1, .duration = 0x1f4, .persist = 1 }); tween_pause(p->vacuumTween); if (vt->ctor) vt->ctor(p); return p; } static void Pickup_Recycle(Pickup *p) { if (p->vt->OnRecycle) p->vt->OnRecycle(p); else Pickup_OnRecycle(p); } static void PickupPool_push(Pickup ***arr, int *n, int *cap, Pickup *p) { if (*n == *cap) { *cap = *cap ? *cap * 2 : 64; *arr = realloc(*arr, *cap * sizeof(Pickup *)); } (*arr)[(*n)++] = p; } static PickupSlot *PickupPool_slot(PickupPool *pool, const char *type) { for (int i = 0; i < pool->n_slots; i++) if (!strcmp(pool->slots[i].type, type)) return &pool->slots[i]; if (pool->n_slots >= 32) return NULL; PickupSlot *s = &pool->slots[pool->n_slots++]; *s = (PickupSlot){ .type = type }; return s; } static Pickup *PickupPool_SpawnAt(PickupPool *pool, float x, float y, const char *type) { PickupSlot *sl = PickupPool_slot(pool, type); if (!sl) return NULL; Pickup *p = sl->n_stored ? sl->stored[--sl->n_stored] : NULL; // Spawn if (!p) { // Make + Init(-1000, -1000) p = Pickup_new(pool, type); if (!p) return NULL; p->s.x = -1000; p->s.y = -1000; Pickup_Recycle(p); } PickupPool_push(&sl->spawned, &sl->n_spawned, &sl->cap, p); list_add(&Core.PickupGroup, &p->s); children_add(&p->s); p->s.x = x; p->s.y = y; Pickup_Recycle(p); return p; } static void PickupPool_Return(PickupPool *pool, Pickup *p) { PickupSlot *sl = PickupPool_slot(pool, p->vt->itemType); // la reliquia cambia itemType (SetItemType): lo slot resta quello della classe children_remove(&p->s); for (int i = 0; i < sl->n_spawned; i++) if (sl->spawned[i] == p) { memmove(&sl->spawned[i], &sl->spawned[i + 1], (sl->n_spawned - i - 1) * sizeof(Pickup *)); sl->n_spawned--; break; } list_remove(&Core.PickupGroup, &p->s); list_remove(&Core.PickupsWithArrows, &p->s); PickupPool_push(&sl->stored, &sl->n_stored, &sl->cap_stored, p); } static void Pickup_DeSpawn(Pickup *p) { p->s.active = 0; p->s.visible = 0; p->s.body.enable = 0; sprite_setVelocity(&p->s, 0, 0); anims_stop(&p->s); PickupPool_Return(p->pool, p); } static void Pickup_DoDeSpawn(Pickup *p) { if (p->vt->DeSpawn) p->vt->DeSpawn(p); else Pickup_DeSpawn(p); } static void Pickup_GetTaken(Pickup *p) { if (p->disableGet) return; Pickup_DoDeSpawn(p); json_inc(cJSON_GetObjectItem(data_get("items"), p->itemType), "pickedupAmount"); // semplificazione: solo in memoria, il salvataggio delle statistiche viene con PlayerOptions if (p->OnPickupCallback) p->OnPickupCallback(p); } static void Pickup_DoGetTaken(Pickup *p) { if (p->vt->GetTaken) p->vt->GetTaken(p); else Pickup_GetTaken(p); } static void Gem_GetTaken(Pickup *p) { if (p->disableGet) return; if (Arcanas.pewpew) { // Game Killer: la gemma non da' esperienza, la spara il cannone Sound_PlaySound("Gem", 0.1f, 1, 0, 1, 1); Arcanas_TriggerGemCannon(p->value * Player_PGrowth(Core.Player), p->s.frame); Pickup_GetTaken(p); return; } Player_AddXP(Core.Player, p->value * Player_PGrowth(Core.Player)); Sound_PlaySound("Gem", 0.1f, 1, 0, 1, 1); PlayerUI_Update(); // CheckForLevelUp: vuoto Pickup_GetTaken(p); } static void Pickup_GoToPlayer(Pickup *p) { p->currentDirection.x = Core.Player->s.x - p->s.x; p->currentDirection.y = Core.Player->s.y - 8 - p->s.y; float l = sqrtf(p->currentDirection.x * p->currentDirection.x + p->currentDirection.y * p->currentDirection.y); if (l > 0) { p->currentDirection.x /= l; p->currentDirection.y /= l; } sprite_setVelocity(&p->s, p->speed * p->currentDirection.x * p->time, p->speed * p->currentDirection.y * p->time); p->speed++; } static void Pickup_Update(Pickup *p) { if (p->vt->Update) { p->vt->Update(p); return; } if (p->goToPlayer && !p->isStationary) Pickup_GoToPlayer(p); } static void Gem_Update(Pickup *p) { if (p->goToPlayer && !p->isStationary) Pickup_GoToPlayer(p); p->s.depth = p->s.y - Core.Player->s.y - game_height; } static int Pickup_Vacuum(Pickup *p) { if (p->goToPlayer) return 0; tween_restart(p->vacuumTween); p->time = -1; p->goToPlayer = 1; return 1; } static Pickup *Core_furthest(Sprite *from, Pickup **arr, int n) { float best = -1; Pickup *r = NULL; for (int i = 0; i < n; i++) { float dx = arr[i]->s.x - from->x, dy = arr[i]->s.y - from->y, d = dx * dx + dy * dy; if (d > best) { best = d; r = arr[i]; } } return r; } // Core.MakePickup (ramo GEM) + Core.MakeGem static Pickup *Core_MakeGem(float x, float y, float value) { PickupSlot *gp = PickupPool_slot(&Core.gemsPool, "GEM"); Pickup *g; if (gp->n_spawned > Core.MaxGems) { float acc = 0; int onScreen = 0, guard = 0; while (gp->n_spawned > Core.MaxGems) { Pickup *f = Core_furthest(&Core.Player->s, gp->spawned, gp->n_spawned); if (f) { if (ContainmentRect_Contains(&Core.containmentRect_Screen, &f->s)) { onScreen = 1; break; } acc += f->value; Pickup_DoDeSpawn(f); } if (++guard > Core.MaxGems) break; } Pickup *f = Core_furthest(&Core.Player->s, gp->spawned, gp->n_spawned); if (f) Gem_SetValue(f, acc + f->value); if (onScreen) { f->value += value; return NULL; } g = PickupPool_SpawnAt(&Core.gemsPool, x, y, "GEM"); } else { g = PickupPool_SpawnAt(&Core.gemsPool, x, y, "GEM"); } if (g) Gem_SetValue(g, value); return g; } // Core.MakePickup (ramo pickupPool): x/y NULL = GetPositionOutOfSight, non ancora usato static Pickup *Core_MakePickup(float x, float y, const char *type) { return PickupPool_SpawnAt(&Core.pickupPool, x, y, type); } static Pickup *Core_MakeStagePickup(float x, float y, const char *type, const char *weaponType) { // MakePickup(x, y, type, weaponType) Pickup *p = Core_MakePickup(x, y, type); if (!p) return NULL; if (weaponType) WeaponPickup_SetWeaponType(p, weaponType); if (Core.n_StagePickups < 32) Core.StagePickups[Core.n_StagePickups++] = p; return p; } // MakeStagePickup(x, y, RELIC, VOID, 1, relic): un itemType che non e' fra gli oggetti diventa una moneta static Pickup *Core_MakeRelic(float x, float y, const char *relic) { int known = cJSON_GetObjectItem(data_get("items"), relic) != NULL; Pickup *p = Core_MakeStagePickup(x, y, known ? "RELIC" : "COIN", NULL); if (p && known) Relic_SetItemType(p, relic); return p; } // Core.MakeTreasure static Pickup *Core_MakeTreasure(float x, float y, cJSON *treasure, int level) { Pickup *t = Core_MakePickup(x, y, "TREASURE"); if (!t) return NULL; t->CurrentTreasureLevel = level; t->CurrentTreasureTypes = cJSON_GetObjectItem(treasure, "prizeTypes"); t->CurrentFixedTreasures = cJSON_GetObjectItem(treasure, "fixedPrizes"); // [null x5] se assenti: si legge NULL Treasure_SetArcana(t, cJSON_IsTrue(cJSON_GetObjectItem(treasure, "hasArcana"))); return t; } // ============================================================================ // 0x1166a: Enemy + 0xd1a1: EnemyPool // ============================================================================ static float TweenAngles[10]; static int n_TweenAngles; static void Enemy_restoreTint(void *ctx) { Enemy *e = ctx; if (e->IsTimeStopped) sprite_setTint(&e->s, 0xff); else sprite_setTint(&e->s, e->saveTint); e->receivingDamage = 0; } static void EnemyPool_Recycle(EnemyPool *pool, Enemy *e); static void base_EnemyDeSpawn(Enemy *e); static void Enemy_DeSpawn(Enemy *e) { if (e->vt && e->vt->DeSpawn) e->vt->DeSpawn(e); else base_EnemyDeSpawn(e); } static void base_EnemyDeSpawn(Enemy *e) { e->isDespawning = 1; e->isDead = 1; e->s.body.enable = 0; e->s.visible = 0; EnemyPool_Recycle(e->pool, e); e->isCullable = 1; time_removeEvent(e->SelfDestructTimer); if (e->SelfDestruct) { children_remove(&e->alertSprite); e->alertSprite.visible = 0, e->alertSprite.alpha = 0; tween_stop(e->alertTween), e->alertTween = (TweenRef){ -1, 0 }; } } static void Enemy_OnDeathAnimationComplete(void *ctx) { Enemy_DeSpawn(ctx); } static const EnemyVT *enemy_vt(const char *type); static void base_EnemyOnRecycle(Enemy *e); static void Enemy_OnRecycle(Enemy *e) { if (e->vt && e->vt->OnRecycle) e->vt->OnRecycle(e); else base_EnemyOnRecycle(e); } static void base_EnemyOnRecycle(Enemy *e) { e->conditional_canMove = 1; e->damageWeakness = 1; if (e->idleFrameCount) anims_play(&e->s, &e->idle, (int)ceilf(frand() * (0.5f * e->idleFrameCount))); if (e->SelfDestruct) { // SelfDestructTimer && ...: col solo SelfDestruct cambia solo che un timer mai partito non c'e' da distruggere time_removeEvent(e->SelfDestructTimer); e->alertSprite.visible = 0, e->alertSprite.alpha = 1, e->isSelfDestructionTriggered = 0; } e->canBeDamagedByBloodline = 1; e->damageKB = 1; e->target = &Core.Player->s; e->maxHp = e->dataMaxHp * EnemyHealthMultiplier * Player_PCurse(Core.Player) * Core.Stage->EnemyHealthMultiplier; if (e->HPxLevel) e->maxHp = e->dataMaxHp * Core.Player->level * EnemyHealthMultiplier * Core.Stage->EnemyHealthMultiplier; if (e->FixedDirection || e->Medusa) e->_currentDirection = (Vector2){ 0, 0 }; e->hp = e->maxHp; e->isDead = 0; e->s.visible = 1; e->s.body.enable = 1; e->IsTimeStopped = 0; e->speed = e->defaultSpeed; sprite_setFrame(&e->s, e->defaultName); Enemy_restoreTint(e); sprite_setOrigin(&e->s, 0.5f, 0.5f); sprite_setScale(&e->s, 1); float r = 0.4f * e->s.width, o = 0.5f * r; body_setCircle(&e->s.body, r, o, o); if (e->hasColliderOverride) { r = e->s.width * e->colliderRadius; o = 0.5f * r; body_setCircle(&e->s.body, r, o, o); body_setOffset(&e->s.body, o + e->colliderOffsetX, o + e->colliderOffsetY); } sprite_setOrigin(&e->s, 0.5f, 1); sprite_setScale(&e->s, PixelScale * e->scaleMul); e->slow = 1; e->isDespawning = 0; } // I primi nemici della partita da un blocco solo: un'ondata non alloca e azzera centinaia di KB in un frame (nessuno libera un nemico singolo) #define ENEMY_BLOCK 400 static Enemy *EnemyBlock; static int EnemyBlock_used; static Enemy *Enemy_new(EnemyPool *pool, const char *type) { // constructor Enemy *e = EnemyBlock_used < ENEMY_BLOCK && EnemyBlock ? &EnemyBlock[EnemyBlock_used++] : calloc(1, sizeof(Enemy)); sprite_init(&e->s, NULL, 0, 0); e->s.owner = e; e->vt = enemy_vt(type); e->OnEnterTween = e->OnFireTimer = e->OnSineTween = e->OnLifetimeTween = e->ScaleTween = (TweenRef){ -1, 0 }; e->hp = e->maxHp = e->dataMaxHp = 3; e->minHp = 0.1f; e->power = 0xa; e->knockback = 1; e->maxKnockback = 3; e->deathKB = 0xa; e->damageKB = 1; e->xp = 1; e->speed = e->defaultSpeed = 0x64; e->scaleMul = 1; e->isCullable = 1; e->slow = 1; e->damageWeakness = 1; e->conditional_canMove = 1; e->SelfDestDistance = 0x9c40; e->alertTween = e->RotateTween = e->fadeTrailTween = (TweenRef){ -1, 0 }, e->SelfDestructTimer = (Timer){ -1, 0 }; e->enemyType = type; e->pool = pool; if (n_TweenAngles == 0) { // static MovementTweens / TweenAngles for (int i = 0; i < 10; i++) { TweenAngles[i] = -5; tweens_add((TweenConfig){ .props = { { &TweenAngles[i], NULL, 5 } }, .nprops = 1, .delay = 0x2d * i, .duration = 0x1f4, .loop = -1, .yoyo = 1 }); } n_TweenAngles = 10; } return e; } // I dati di un tipo di nemico, letti una volta sola: l'ondata del minuto 23 crea 286 nemici in un frame, e rileggere ogni volta // enemies.json (25 voci + i nomi dei fotogrammi) costava decine di millisecondi sulla Vita. Idea di DrakonPL. // Dura una partita: gli atlanti possono cambiare fra uno stage e l'altro. typedef struct { const Frame *frame; Animation die, idle; } EnemyLook; // una per ogni frameNames: RND.pick typedef struct EnemyData { const char *type; struct EnemyData *next; int hasMaxSpeed, hasColliderOverride, idleFrameCount, passThroughWalls, HPxLevel, FixedDirection, Medusa, SelfDestruct, nLooks; float speed, maxSpeed, maxHp, power, knockback, maxKnockback, deathKB, res_Rosary, feverValue, res_Freeze, res_Corridor, res_Debuffs, xp, moreX, moreY, alpha, scale; float colliderRadius, colliderOffsetX, colliderOffsetY; unsigned saveTint; EnemyLook *looks; } EnemyData; #define ENEMY_DATA_BUCKETS 256 static EnemyData *EnemyData_table[ENEMY_DATA_BUCKETS]; static void EnemyData_look(EnemyLook *l, const char *tex, const char *name, int end, int idleFrames) { l->frame = frame_get(tex, name); char prefix[96]; snprintf(prefix, sizeof(prefix), "%s", name ? name : ""); char *q = strstr(prefix, "0.png"); if (q) *q = 0; l->die.n = anims_generateFrameNames(tex, prefix, 0, end, 0, l->die.frames, ANIM_MAX_FRAMES); l->die.frameRate = 0x18; l->die.msPerFrame = 1000.0f / l->die.frameRate; l->die.repeat = 0; if (idleFrames) { char ip[100]; snprintf(ip, sizeof(ip), "%si", prefix); l->idle.n = anims_generateFrameNames(tex, ip, 1, idleFrames, 2, l->idle.frames, ANIM_MAX_FRAMES); l->idle.frameRate = 8; l->idle.msPerFrame = 1000.0f / 8; l->idle.repeat = -1; } } static const EnemyData *EnemyData_of(const char *type) { unsigned h = 5381; for (const char *c = type; *c; c++) h = h * 33 + (unsigned char)*c; EnemyData **slot = &EnemyData_table[h % ENEMY_DATA_BUCKETS]; for (EnemyData *t = *slot; t; t = t->next) if (!strcmp(t->type, type)) return t; EnemyData *t = calloc(1, sizeof(EnemyData)); t->type = type, t->next = *slot, *slot = t; cJSON *d = cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("enemies"), type), 0); t->hasMaxSpeed = has(d, "maxSpeed"); t->speed = num(d, "speed", 0), t->maxSpeed = num(d, "maxSpeed", 0), t->maxHp = num(d, "maxHp", 0), t->power = num(d, "power", 0); t->knockback = num(d, "knockback", 0), t->maxKnockback = num(d, "maxKnockback", 0), t->deathKB = num(d, "deathKB", 0); t->res_Rosary = num(d, "res_Rosary", 0), t->feverValue = orv(d, "feverValue", 1), t->res_Freeze = num(d, "res_Freeze", 0); t->res_Corridor = num(d, "res_Corridor", 0), t->res_Debuffs = num(d, "res_Debuffs", 0), t->xp = num(d, "xp", 0); t->moreX = num(d, "moreX", 0), t->moreY = num(d, "moreY", 0), t->alpha = orv(d, "alpha", 1), t->scale = orv(d, "scale", 1); cJSON *co = cJSON_GetObjectItem(d, "colliderOverride"); if (co) t->hasColliderOverride = 1, t->colliderRadius = num(co, "radius", 0), t->colliderOffsetX = num(co, "offsetX", 0), t->colliderOffsetY = num(co, "offsetY", 0); t->idleFrameCount = (int)num(d, "idleFrameCount", 0); t->passThroughWalls = cJSON_IsTrue(cJSON_GetObjectItem(d, "passThroughWalls")); t->saveTint = has(d, "tint") ? (unsigned)num(d, "tint", 0xffffff) : 0xffffff; cJSON *sk; cJSON_ArrayForEach(sk, cJSON_GetObjectItem(d, "skills")) { // enum EnemySkill (0x7584): numeri nei dati; le altre abilita': nemici non ancora usati int s = (int)cJSON_GetNumberValue(sk); if (s == 0) t->HPxLevel = 1; if (s == 1) t->FixedDirection = 1; if (s == 2) t->SelfDestruct = 1; if (s == 3) t->Medusa = 1; } cJSON *names = cJSON_GetObjectItem(d, "frameNames"); t->nLooks = cJSON_GetArraySize(names); t->looks = calloc(t->nLooks ? t->nLooks : 1, sizeof(EnemyLook)); for (int k = 0; k < t->nLooks; k++) EnemyData_look(&t->looks[k], str(d, "textureName"), cJSON_GetStringValue(cJSON_GetArrayItem(names, k)), (int)num(d, "end", 0), t->idleFrameCount); return t; } static void Enemy_Init(Enemy *e, float x, float y) { const EnemyData *t = EnemyData_of(e->enemyType); float sp = t->hasMaxSpeed ? frand() * (t->maxSpeed - t->speed) + t->speed : t->speed; e->dataMaxHp = e->maxHp = t->maxHp; e->power = t->power, e->knockback = t->knockback, e->maxKnockback = t->maxKnockback, e->deathKB = t->deathKB; e->res_Rosary = t->res_Rosary, e->feverValue = t->feverValue, e->res_Freeze = t->res_Freeze, e->res_Corridor = t->res_Corridor, e->res_Debuffs = t->res_Debuffs; e->xp = t->xp; e->speed = e->defaultSpeed = sp; e->moreX = t->moreX, e->moreY = t->moreY; e->s.alpha = t->alpha; e->scaleMul = t->scale; if (t->hasColliderOverride) e->hasColliderOverride = 1, e->colliderRadius = t->colliderRadius, e->colliderOffsetX = t->colliderOffsetX, e->colliderOffsetY = t->colliderOffsetY; e->idleFrameCount = t->idleFrameCount; e->passThroughWalls = t->passThroughWalls; e->saveTint = t->saveTint; if (t->HPxLevel) e->HPxLevel = 1; if (t->FixedDirection) e->FixedDirection = 1; if (t->Medusa) e->Medusa = 1, e->medusaElapsed = 2 * frand(); if (t->SelfDestruct) { e->SelfDestruct = 1; sprite_init(&e->alertSprite, frame_get("vfx", "sPFX_ring_64.png"), 0, 0); e->alertSprite.visible = 0, e->alertSprite.blendAdd = 1; sprite_setOrigin(&e->alertSprite, 0.5f, 0.75f), sprite_setTint(&e->alertSprite, 0xff0000); } const EnemyLook *l = &t->looks[t->nLooks ? (int)floorf(frand() * t->nLooks) : (frand(), 0)]; // RND.pick sprite_setFrame(&e->s, l->frame); e->die = l->die; if (e->idleFrameCount) e->idle = l->idle; e->s.onAnimationComplete = Enemy_OnDeathAnimationComplete; e->defaultName = e->s.frame; e->s.x = x; e->s.y = y; physics_existing(&e->s); Enemy_OnRecycle(e); e->moveTweenIndex = (int)floorf(frand() * n_TweenAngles); } // HitVFXType (0x136b9) e la tabella dei suoi effetti (0xd195) enum { HIT_NONE, HIT_DEFAULT, HIT_TIMEFREEZE, HIT_FIRE, HIT_DARK, HIT_LIGHT, HIT_PUSH, HIT_PRISM, HIT_RED, HIT_BLUE, HIT_BEAM, HIT_EVIL, HIT_WIND }; static const struct { int isTintFill; unsigned targetTint; const char *hitFrameName, *impactFrameName; float duration; } HitVFXData[] = { [HIT_NONE] = { 0, 0xffffff, "", "", 0x78 }, [HIT_PUSH] = { 1, 0xddffdd, "NoDraw.png", "NoDraw.png", 0x3c }, [HIT_DEFAULT] = { 1, 0xffffff, "HitStar2.png", "Shockwave3.png", 0x78 }, [HIT_TIMEFREEZE] = { 1, 0xff, "feedback-4.png", "Shockwave3.png", 0x1e }, [HIT_FIRE] = { 1, 0xff0000, "Hit1.png", "HitBoom2.png", 0x1e }, [HIT_EVIL] = { 1, 0x110022, "HitMoon2.png", "HitBlack1.png", 0x1e }, [HIT_DARK] = { 1, 0x220044, "HitMoon2.png", "HitBlack1.png", 0x1e }, [HIT_LIGHT] = { 1, 0x44ffff, "HitStar2.png", "HitStarWhite1.png", 0x1e }, [HIT_PRISM] = { 1, 0xffffff, "s_pfx_rainbow_32.png", "s_pfx_rainbow_64.png", 0x3c }, [HIT_RED] = { 1, 0xffeeee, "HitCross1.png", "HitCrossImpact1.png", 0x3c }, [HIT_BLUE] = { 1, 0xeeeeff, "HitCross2.png", "HitCrossImpact2.png", 0x3c }, [HIT_BEAM] = { 1, 0xffffff, "HitStarWhite2.png", "HitCrossImpact3.png", 0x3c }, [HIT_WIND] = { 1, 0xff00, "HitStarWhite2.png", "HitCrossImpact3.png", 0x3c }, }; static void Enemy_OnGetDamaged(Enemy *e, int hitVFX) { int has = hitVFX != HIT_NONE; // FlashingVFXEnabled if (has) { if (HitVFXData[hitVFX].isTintFill) sprite_setTintFill(&e->s, HitVFXData[hitVFX].targetTint); else sprite_setTint(&e->s, HitVFXData[hitVFX].targetTint); } e->_blinkTimeout = time_addEvent(e->isDead ? 0x3c : has ? HitVFXData[hitVFX].duration : 0x78, 0, 0, Enemy_restoreTint, e); e->receivingDamage = 1; } static int GoldFever_isActive(void); static void GoldFever_OnEnemyDeath(Enemy *e); static void base_EnemyDie(Enemy *e); static void Enemy_Die(Enemy *e) { if (e->vt && e->vt->Die) e->vt->Die(e); else base_EnemyDie(e); } static void base_EnemyDie(Enemy *e) { if (e->isDead) return; if (e->SelfDestruct) e->alertSprite.visible = 0, tween_stop(e->alertTween), e->alertTween = (TweenRef){ -1, 0 }; e->isDead = 1; float kb = -e->deathKB, v = EnemySpeed * e->speed * kb * e->slow; sprite_setVelocity(&e->s, v * e->_currentDirection.x, v * e->_currentDirection.y); anims_play(&e->s, &e->die, 0); time_removeEvent(e->_blinkTimeout); int value = (int)floorf((frand() + 0.5f) * e->xp); if (value > 0) Core_MakeGem(e->s.x, e->s.y - 0xc, value); if (e->treasure) { Core_MakeTreasure(e->s.x, e->s.y, e->treasure, e->treasureLevel); e->treasure = NULL; } if (GoldFever_isActive()) GoldFever_OnEnemyDeath(e); json_inc(tbl0("enemies", e->enemyType), "killedAmount"); Core.kills++; // PlayerOptions.RunEnemies += 1 MainUI_UpdateKills(); } static void Core_ShowHitVFXAt(float x, float y, int type); static void base_EnemyGetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *bulletType); static void Enemy_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *bulletType) { if (e->vt && e->vt->GetDamaged) e->vt->GetDamaged(e, amount, hitVFX, kb, bulletType); else base_EnemyGetDamaged(e, amount, hitVFX, kb, bulletType); } static void base_EnemyGetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *bulletType) { (void)bulletType; // il tipo serve solo alle sottoclassi if (e->damageWeakness > 1) amount *= e->damageWeakness; if (amount > 0) Core_ShowDamageAt(e->s.x, e->s.y, amount); // PlayerOptions.DamageNumbersEnabled (di default si') e->hp -= amount; if (e->hp <= 0) Enemy_Die(e); else e->damageKB = kb; Sound_PlaySound("Hit", 0.5f, 1, 0x1f4 * (frand() - 0.5f), 0x96, 3); if (hitVFX != HIT_NONE) Core_ShowHitVFXAt(e->s.x, e->s.y, hitVFX); Enemy_OnGetDamaged(e, hitVFX); } // --- BOSS_XLDEATH / BOSS_XLDEATH2, il Mietitore (0x5c80) --------------------------------------------------------- // Resiste a tutto tranne Infinite Corridor e Crimson Shroud (+1% della vita massima); ucciso cosi', ferma il tempo e chiama la Mano Bianca. static void WhiteHand_Summon(void); static void Enemy_Disappear(Enemy *e); static void E_Reaper_OnRecycle(Enemy *e) { base_EnemyOnRecycle(e); e->legitKill = 0; } static void E_Reaper_Die(Enemy *e) { if (e->isDead) return; base_EnemyDie(e); if (!e->legitKill) return; cJSON *mods = cJSON_GetObjectItem(cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("stages"), Core.Stage->stageType), 0), "mods"); // SelectedStage float tl = num(mods, "TimeLimit", 0x708); if (Core.SurvivedSeconds < 0x3c + tl) Core.SurvivedSeconds = (int)(0x3c + tl); time_removeEvent(Core.tickerEvent); WhiteHand_Summon(); for (int i = 0; i < Core.Enemies.n; i++) Enemy_Disappear(Core.Enemies.items[i]->owner); for (int i = 0; i < 5; i++) // 5 uova d'oro in cerchio, raggio 60 Core_MakeStagePickup(e->s.x + sinf(2 * PI / 5 * i) * 0x3c, e->s.y + cosf(2 * PI / 5 * i) * 0x3c, "RELIC_GOLDENEGG", NULL); } static void E_Reaper_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *bulletType) { if (bulletType && !strcmp(bulletType, "CORRIDOR")) e->legitKill = 1; else if (bulletType && !strcmp(bulletType, "SHROUD")) e->legitKill = 1, amount += 0.01f * e->maxHp; base_EnemyGetDamaged(e, amount, hitVFX, kb, bulletType); } static const EnemyVT E_Reaper = { E_Reaper_OnRecycle, E_Reaper_Die, E_Reaper_GetDamaged }; // X ? X.restart() : X = scene.tweens.add(...): il tween resta (persist) e riparte a ogni riciclo dell'oggetto static void tween_restartOrAdd(TweenRef *r, TweenConfig c) { if (tween_get(*r)) tween_restart(*r); else c.persist = 1, *r = tweens_add(c); } static void base_EnemyUpdate(Enemy *e); static void base_EnemyOnPlayerOverlap(Enemy *e); static int Stage_SetTreasureLevelFromChance(cJSON *t, int *level); static cJSON *enemy_data(Enemy *e) { return cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("enemies"), e->enemyType), 0); } static void Stage_FireEnemyBulletAt(float x, float y); // --- PILE1..3 (0x76a7) e BOSS_PILE3 (0x7d8f): entrano di slancio, si fermano e sparano ---------------------------- static void E_Pile_fire(void *ctx) { Enemy *e = ctx; if (!e->IsTimeStopped && !e->isDead) Stage_FireEnemyBulletAt(e->s.x, e->s.y); } // bulletType ignorato (sic) static void E_BossPile_fire(void *ctx) { Enemy *e = ctx; if (!e->isDead) Stage_FireEnemyBulletAt(e->s.x, e->s.y); } // BULLET_3 chiesto, BULLET_1 sparato static void E_Pile_recycle(Enemy *e, Callback fire) { base_EnemyOnRecycle(e); e->speed = EnemySpeed > _baseEnemySpeed ? 0x7d0 - 0x7d0 * (EnemySpeed - _baseEnemySpeed) : 0x7d0; sprite_setScale(&e->s, 0), e->firetime = 0; cJSON *d = enemy_data(e); e->fireDelay = num(d, "fireDelay", 0) ? num(d, "fireDelay", 0) : 0x7d0; // BOSS_PILE3: 1000 nel costruttore, poi sovrascritto qui (sic) e->bulletType = str(d, "bulletType") ? str(d, "bulletType") : "BULLET_1"; tween_restartOrAdd(&e->OnEnterTween, (TweenConfig){ .props = { { &e->s.scaleX, &e->s.scaleY, e->scaleMul }, { &e->speed, NULL, 0 } }, .nprops = 2, .duration = 0x12c }); tween_restartOrAdd(&e->OnFireTimer, (TweenConfig){ .props = { { &e->firetime, NULL, 1 } }, .nprops = 1, .duration = e->fireDelay, .repeat = -1, .onRepeat = fire, .ctx = e }); } static void E_Pile_OnRecycle(Enemy *e) { E_Pile_recycle(e, E_Pile_fire); } static void E_BossPile_OnRecycle(Enemy *e) { E_Pile_recycle(e, E_BossPile_fire); } static void E_Pile_Die(Enemy *e) { base_EnemyDie(e); tween_stop(e->OnFireTimer); } static void E_Pile_DeSpawn(Enemy *e) { base_EnemyDeSpawn(e); tween_stop(e->OnFireTimer); } static const EnemyVT E_Pile = { .OnRecycle = E_Pile_OnRecycle, .Die = E_Pile_Die, .DeSpawn = E_Pile_DeSpawn }; static const EnemyVT E_BossPile = { .OnRecycle = E_BossPile_OnRecycle, .Die = E_Pile_Die, .DeSpawn = E_Pile_DeSpawn }; // --- BULLET_1 (0x533): il proiettile dei nemici, un nemico che vive 5,5 s e muore toccando il giocatore ------------ static void E_Bullet_Disappear(Enemy *e); static void E_Bullet_lifeDone(void *ctx) { E_Bullet_Disappear(ctx); } static void E_Bullet_OnRecycle(Enemy *e) { base_EnemyOnRecycle(e); sprite_setScale(&e->s, 0), e->isDespawning = 0, e->lifetime = 1; cJSON *d = enemy_data(e); e->power = num(d, "power", 0); sprite_setTint(&e->s, has(d, "tint") ? (unsigned)num(d, "tint", 0) : 0xffffff); tween_restartOrAdd(&e->OnEnterTween, (TweenConfig){ .props = { { &e->s.scaleX, &e->s.scaleY, 1 } }, .nprops = 1, .duration = 0x64 }); tween_restartOrAdd(&e->OnLifetimeTween, (TweenConfig){ .props = { { &e->lifetime, NULL, 0 } }, .nprops = 1, .duration = 0x64, .delay = 0x157c, .onComplete = E_Bullet_lifeDone, .ctx = e }); } static void E_Bullet_DeSpawn(Enemy *e) { if (e->isDespawning) return; e->isDespawning = 1; // ScaleTween/OnEnterTween/OnLifetimeTween.stop senza parentesi (sic): non si fermano base_EnemyDeSpawn(e); } static void E_Bullet_deathDone(void *ctx) { E_Bullet_DeSpawn(ctx); } static void E_Bullet_DeathTween(Enemy *e) { tween_stop(e->OnLifetimeTween); if (tween_get(e->ScaleTween)) tween_stop(e->ScaleTween), tween_restart(e->ScaleTween); else e->ScaleTween = tweens_add((TweenConfig){ .props = { { &e->s.scaleX, &e->s.scaleY, 0 } }, .nprops = 1, .duration = 0x64, .onComplete = E_Bullet_deathDone, .ctx = e, .persist = 1 }); } static void E_Bullet_OnPlayerOverlap(Enemy *e) { base_EnemyOnPlayerOverlap(e); if (!e->isDead) e->isDead = 1, E_Bullet_DeathTween(e); // OnLifetimeTween.stop senza parentesi (sic) } static void E_Bullet_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *bulletType) { (void)hitVFX, (void)bulletType; e->hp -= amount; if (e->hp <= 0) Enemy_Die(e); else e->damageKB = kb; } static void E_Bullet_Disappear(Enemy *e) { if (!e->isDead) e->isDead = 1, E_Bullet_DeathTween(e); } // niente gemma ne' uccisione static const EnemyVT E_Bullet = { .OnRecycle = E_Bullet_OnRecycle, .Die = E_Bullet_Disappear, .GetDamaged = E_Bullet_GetDamaged, .DeSpawn = E_Bullet_DeSpawn, .Disappear = E_Bullet_Disappear, .OnPlayerOverlap = E_Bullet_OnPlayerOverlap }; // --- JELLYFISH (0x7c4a): avanza e arretra, la velocita' oscilla tra +1 e -1 ------------------------------------------- static void E_Jelly_OnRecycle(Enemy *e) { base_EnemyOnRecycle(e); e->defaultSpeed = num(enemy_data(e), "speed", 0), e->sineF = 1; sprite_setScale(&e->s, 0); if (tween_get(e->OnEnterTween)) { tween_restart(e->OnEnterTween); if (tween_get(e->OnSineTween)) tween_restart(e->OnSineTween); } else { e->OnEnterTween = tweens_add((TweenConfig){ .props = { { &e->s.scaleX, &e->s.scaleY, e->scaleMul } }, .nprops = 1, .duration = 0x3e8, .persist = 1 }); tween_restartOrAdd(&e->OnSineTween, (TweenConfig){ .props = { { &e->sineF, NULL, -1 } }, .nprops = 1, .delay = 0x64, .duration = 0xfa0, .repeat = -1, .yoyo = 1, .ease = Ease_SineInOut }); } } static void E_Jelly_DeSpawn(Enemy *e) { base_EnemyDeSpawn(e); tween_stop(e->OnEnterTween); } static void E_Jelly_Update(Enemy *e) { e->speed = e->defaultSpeed * e->sineF; base_EnemyUpdate(e); } static const EnemyVT E_Jelly = { .OnRecycle = E_Jelly_OnRecycle, .DeSpawn = E_Jelly_DeSpawn, .Update = E_Jelly_Update }; // Gli inseguitori che hanno perso il forziere, con Exdash sbloccato e Panini no: Exdash in basso a destra, Invio + giu' (sic, 'up' e' DOWN) e Panini si sblocca static Sprite PaniniSpr; static Enemy *PaniniOwner; static void Panini_uppercut(Enemy *e) { if (!e->hasLostTreasure || e->paniniDone || po_has("UnlockedCharacters", "PANINI") || !po_has("UnlockedCharacters", "EXDASH")) return; if (!PaniniSpr.frame) { sprite_init(&PaniniSpr, frame_get("characters", "uExdash_01.png"), game_width, game_height); sprite_setScale(&PaniniSpr, 4), PaniniSpr.angle = -0x2d, PaniniSpr.scrollFactor0 = 1, PaniniSpr.depth = 0xce4, PaniniSpr.alpha = 0.8f; } if (!PaniniSpr.visible || PaniniOwner != e) children_remove(&PaniniSpr), children_add(&PaniniSpr); PaniniSpr.visible = 1, PaniniOwner = e; Sound_PlaySound("PAN", 1, 1, 0, 0x4e20, 1); if (!(IsKeyDown(KEY_ENTER) && IsKeyDown(KEY_DOWN))) return; e->paniniDone = 1; po_push("UnlockedCharacters", "PANINI"); cJSON *d = tbl0("characters", "PANINI"); obj_set(d, "hidden", cJSON_CreateFalse()), obj_set(d, "isBought", cJSON_CreateTrue()); po_push("BoughtCharacters", "PANINI"); PlayerOptions_Save(); Sound_PlaySimple("ClickIn", 0), Sound_PlaySound("ThingFound", 1, 0.5f, -0x3e8, 0, 0); } static void Panini_update(void) { if (PaniniOwner && !PaniniOwner->s.active) PaniniSpr.visible = 0, PaniniOwner = NULL; } // DeSpawn: spritte nascosto // --- BOSS_XLSTALKER (0x1458d): invulnerabile; Rosary/Sire/Corridor/Shroud/Victory (o un carrello) lo cacciano, e lascia un forziere --- static void E_Stalker_OnRecycle(Enemy *e) { base_EnemyOnRecycle(e); sprite_setTint(&e->s, 0xccccff); e->defaultSpeed = num(enemy_data(e), "speed", 0), e->sineF = 1, e->isCullable = 0, e->isTeleportOnCull = 1, e->s.alpha = 0.8f, e->hasLostTreasure = 0; tween_restartOrAdd(&e->OnSineTween, (TweenConfig){ .props = { { &e->sineF, NULL, 0.1f }, { &e->s.alpha, NULL, 0.6f } }, .nprops = 2, .duration = 0x7d0, .repeat = -1, .yoyo = 1, .ease = Ease_SineInOut }); } static void E_Stalker_MulSpeed(Enemy *e, float m) { e->defaultSpeed = num(enemy_data(e), "speed", 0) * m; } static void E_Stalker_Disappear(Enemy *e) { // se ne va all'indietro, sempre piu' veloce tween_stop(e->OnSineTween); e->sineF = -2, e->isCullable = 1, e->isTeleportOnCull = 0; tweens_add((TweenConfig){ .props = { { &e->sineF, NULL, -0xa } }, .nprops = 1, .duration = 0x7d0 }); } static void E_Stalker_Update(Enemy *e) { e->speed = e->defaultSpeed * e->sineF; base_EnemyUpdate(e); Panini_uppercut(e); } // new TreasureClass(chances, tipi) (sic): il primo argomento e' il livello, quindi level = l'array e chances = []; il tiro non riesce mai // (tranne BeginnersLuck) e il livello resta "non numerico": qui 0, che la TreasureScene tratta come l'originale (un premio) static cJSON *Stalker_treasure(void) { static cJSON *t; if (!t) { static const char *const P[5] = { "EVOLUTION", "EXISTING_ANY", "EXISTING_ANY", "EVOLUTION", "EVOLUTION" }; t = cJSON_CreateObject(); cJSON_AddItemToObject(t, "prizeTypes", cJSON_CreateStringArray(P, 5)); } return t; } static void E_Stalker_LoseTreasure(Enemy *e) { E_Stalker_Disappear(e); e->hasLostTreasure = 1; int lv = 0; Stage_SetTreasureLevelFromChance(Stalker_treasure(), &lv); Core_MakeTreasure(e->s.x, e->s.y, Stalker_treasure(), lv); // [6, 66, 100] o, per il carrello, [3, 10, 100]: mai letti (vedi sopra) } static void E_Stalker_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *t) { (void)amount, (void)hitVFX, (void)kb; if (e->hasLostTreasure || !t) return; if (!strcmp(t, "PENTAGRAM")) E_Stalker_Disappear(e); else if (!strcmp(t, "ROSARY") || !strcmp(t, "SIRE") || !strcmp(t, "CORRIDOR") || !strcmp(t, "SHROUD") || !strcmp(t, "VICTORY") || !strcmp(t, "CART")) E_Stalker_LoseTreasure(e); } static const EnemyVT E_Stalker = { .OnRecycle = E_Stalker_OnRecycle, .GetDamaged = E_Stalker_GetDamaged, .Update = E_Stalker_Update, .Disappear = E_Stalker_Disappear }; // --- BOSS_WEREWOLF2 (0x184e8): alla morte avvisa chi lo ha evocato --------------------------------------------------------- static void E_Werewolf2_Die(Enemy *e) { base_EnemyDie(e); if (e->onDefeat) e->onDefeat(e); } static const EnemyVT E_Werewolf2 = { .Die = E_Werewolf2_Die }; // I personaggi trovati in partita (Neo, Graziella, Peppino, Boros, Veranda): hidden = false (e isBought = false, tranne Peppino e Boros); // se non era sbloccato: BoughtCharacters (Neo, Graziella, Peppino), UnlockedCharacters, Save. Vero se e' nuovo (allora suona ThingFound) static int Char_found(const char *ch, int bought, int keepBought) { cJSON *d = tbl0("characters", ch); obj_set(d, "hidden", cJSON_CreateFalse()); if (!keepBought) obj_set(d, "isBought", cJSON_CreateFalse()); if (po_has("UnlockedCharacters", ch)) return 0; if (bought) po_push("BoughtCharacters", ch); po_push("UnlockedCharacters", ch); PlayerOptions_Save(); return 1; } // --- BOSS_NOOB (0x115f3): il conte del segreto della Foresta; pulsa, spara e alla morte avvisa la Foresta ----------------------- static void E_Noob_fire(void *ctx) { Enemy *e = ctx; if (!e->IsTimeStopped && !e->isDead) Stage_FireEnemyBulletAt(e->s.x, e->s.y); } static void E_Noob_OnRecycle(Enemy *e) { base_EnemyOnRecycle(e); cJSON *d = enemy_data(e); e->defaultSpeed = num(d, "speed", 0), e->sineF = 1, e->isCullable = 0, e->isTeleportOnCull = 0, e->s.alpha = 0.9f; // activated = 0: mai letto tween_restartOrAdd(&e->OnSineTween, (TweenConfig){ .props = { { &e->sineF, NULL, 0.1f }, { &e->s.alpha, NULL, 0.8f } }, .nprops = 2, .duration = 0x7d0, .repeat = -1, .yoyo = 1, .ease = Ease_SineInOut }); e->firetime = 0; e->fireDelay = num(d, "fireDelay", 0) ? num(d, "fireDelay", 0) : 0x7d0; e->bulletType = str(d, "bulletType") ? str(d, "bulletType") : "BULLET_Z"; // ignorato da FireEnemyBulletAt tween_restartOrAdd(&e->OnFireTimer, (TweenConfig){ .props = { { &e->firetime, NULL, 1 } }, .nprops = 1, .duration = e->fireDelay, .repeat = -1, .onRepeat = E_Noob_fire, .ctx = e }); } static void E_Noob_Disappear(Enemy *e) { // come lo Stalker; sineF qui non muove nulla (niente Update sulla velocita') tween_stop(e->OnSineTween); e->sineF = -2, e->isCullable = 1, e->isTeleportOnCull = 0; tweens_add((TweenConfig){ .props = { { &e->sineF, NULL, -0xa } }, .nprops = 1, .duration = 0x7d0 }); } static void E_Noob_Die(Enemy *e) { base_EnemyDie(e); tween_stop(e->OnFireTimer); if (e->onDefeat) e->onDefeat(e); } static void E_Noob_DeSpawn(Enemy *e) { base_EnemyDeSpawn(e); tween_stop(e->OnFireTimer); } static const EnemyVT E_Noob = { .OnRecycle = E_Noob_OnRecycle, .Die = E_Noob_Die, .DeSpawn = E_Noob_DeSpawn, .Disappear = E_Noob_Disappear }; // --- SKULLINO / SKULOROSSO (0xcf45): velocita' dei dati + fino al 30% a caso ---------------------------------------------- static void E_Skullino_OnRecycle(Enemy *e) { base_EnemyOnRecycle(e); e->speed = num(enemy_data(e), "speed", 0); e->speed += frand() * e->speed * 0.3f; } static const EnemyVT E_Skullino = { .OnRecycle = E_Skullino_OnRecycle }; // --- HARPYV (0xe8a9): direzione fissa, ma la x ondeggia col seno (niente Medusa ne' SelfDestruct) --------------------------- static void E_HarpyV_Update(Enemy *e) { if (e->isDead) return; e->s.depth = e->s.y - Core.Player->s.y; if (e->IsTimeStopped) return; if (!e->FixedDirection || (e->FixedDirection && e->_currentDirection.x == 0 && e->_currentDirection.y == 0)) { e->_currentDirection.x = e->target->x - e->s.x; e->_currentDirection.y = e->target->y - e->s.y; float l = sqrtf(e->_currentDirection.x * e->_currentDirection.x + e->_currentDirection.y * e->_currentDirection.y); if (l > 0) { e->_currentDirection.x /= l; e->_currentDirection.y /= l; } } e->medusaElapsed += 0.05f, e->_currentDirection.x = sinf(e->medusaElapsed); float k = e->receivingDamage ? -e->knockback * e->damageKB : 1; e->s.flipX = e->_currentDirection.x > 0; float v = EnemySpeed * e->speed * k * e->slow; sprite_setVelocity(&e->s, v * e->_currentDirection.x, v * e->_currentDirection.y); e->s.angle = TweenAngles[e->moveTweenIndex]; } static const EnemyVT E_HarpyV = { .Update = E_HarpyV_Update }; // --- POLTER_DEST (0x111ca): entra rimpicciolendo e si ferma; esplode a 100 px dal giocatore (SelfDestruct nei dati) ------------- static void E_PolterDest_OnRecycle(Enemy *e) { base_EnemyOnRecycle(e); tween_restartOrAdd(&e->OnEnterTween, (TweenConfig){ .props = { { &e->s.scaleX, &e->s.scaleY, e->scaleMul }, { &e->speed, NULL, 0 } }, .nprops = 2, .duration = 0x12c }); e->SelfDestDistance = 0x2710; } static void E_PolterDest_Update(Enemy *e) { base_EnemyUpdate(e); e->s.angle = 0; } static const EnemyVT E_PolterDest = { .OnRecycle = E_PolterDest_OnRecycle, .Update = E_PolterDest_Update }; // --- SKELANGUE (0x14e3e): risorge (la morte al contrario) finche' ha vite; Pentagram, Rosary, Sire e Heaven Sword lo finiscono ------- static void E_Skel_OnDeathAnimationComplete(void *ctx); static void E_Skel_OnUndieComplete(void *ctx) { Enemy *e = ctx; anims_play(&e->s, &e->idle, 0); e->hp = e->maxHp, e->isDead = 0, e->s.body.enable = 1; e->s.onAnimationComplete = E_Skel_OnDeathAnimationComplete; } static void E_Skel_OnDeathAnimationComplete(void *ctx) { Enemy *e = ctx; if (--e->lives <= 0) { Enemy_DeSpawn(e); return; } e->isDead = 1, e->s.body.enable = 0; anims_play(&e->s, &e->undie, 0); e->s.onAnimationComplete = E_Skel_OnUndieComplete; } static void E_Skel_OnRecycle(Enemy *e) { if (!e->undie.n) { // costruttore: 'undie' = i fotogrammi di 'die' al contrario, 24 fps e->undie = e->die; for (int i = 0; i < e->die.n; i++) e->undie.frames[i] = e->die.frames[e->die.n - 1 - i]; e->lives = 3; } base_EnemyOnRecycle(e); cJSON *d = enemy_data(e); if (num(d, "lives", 0)) e->lives = (int)num(d, "lives", 0); e->s.onAnimationComplete = E_Skel_OnDeathAnimationComplete; } static void E_Skel_Disappear(Enemy *e) { e->lives = 0, e->isDead = 1; anims_play(&e->s, &e->die, 0); } static void E_Skel_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *t) { if (t && (!strcmp(t, "PENTAGRAM") || !strcmp(t, "ROSARY") || !strcmp(t, "SIRE") || !strcmp(t, "HEAVENSWORD"))) e->lives = 0; if (!e->isDead) base_EnemyGetDamaged(e, amount, hitVFX, kb, t); } static const EnemyVT E_Skel = { .OnRecycle = E_Skel_OnRecycle, .GetDamaged = E_Skel_GetDamaged, .Disappear = E_Skel_Disappear }; // --- XLDRAGON1/2, BOSS_XLDRAGON1/2, XLSWORDIAN_AGGRO/_V (0xaddc): colpiti, fanno una giravolta e accelerano (fino al doppio) ---- static void E_Dragon_rotated(void *ctx) { Enemy *e = ctx; e->isRotating = 0; if (!e->FixedDirection || (e->FixedDirection && e->_currentDirection.x == 0 && e->_currentDirection.y == 0)) { e->_currentDirection.x = e->target->x - e->s.x; e->_currentDirection.y = e->target->y - e->s.y; float l = sqrtf(e->_currentDirection.x * e->_currentDirection.x + e->_currentDirection.y * e->_currentDirection.y); if (l > 0) { e->_currentDirection.x /= l; e->_currentDirection.y /= l; } } } static void E_Dragon_OnRecycle(Enemy *e) { base_EnemyOnRecycle(e); e->isRotating = 0, e->keepMoving = 1; sprite_setOrigin(&e->s, 0.5f, 0.5f); e->speed = num(enemy_data(e), "speed", 0); if (!tween_get(e->RotateTween)) e->RotateTween = tweens_add((TweenConfig){ .props = { { &e->s.angle, NULL, -0x168 } }, .nprops = 1, .duration = 0x12c, .ease = Ease_SineOut, .onComplete = E_Dragon_rotated, .ctx = e, .persist = 1 }); tween_stop(e->RotateTween); } static void E_Dragon_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *t) { if (!e->isRotating) { // startRotate e->isRotating = 1; e->speed += 0x28; float max = 2 * num(enemy_data(e), "speed", 0); if (e->speed > max) e->speed = max; tween_restart(e->RotateTween); } base_EnemyGetDamaged(e, amount, hitVFX, kb, t); } static void E_Dragon_Update(Enemy *e) { // niente Medusa ne' SelfDestruct; l'angolo lo tiene il tween mentre gira if (e->isDead) return; e->s.depth = e->s.y - Core.Player->s.y; if (e->IsTimeStopped) return; if (!e->isRotating) { if (!e->FixedDirection || (e->FixedDirection && e->_currentDirection.x == 0 && e->_currentDirection.y == 0)) { e->_currentDirection.x = e->target->x - e->s.x; e->_currentDirection.y = e->target->y - e->s.y; float l = sqrtf(e->_currentDirection.x * e->_currentDirection.x + e->_currentDirection.y * e->_currentDirection.y); if (l > 0) { e->_currentDirection.x /= l; e->_currentDirection.y /= l; } } e->s.angle = TweenAngles[e->moveTweenIndex]; } float k = e->receivingDamage ? -e->knockback * e->damageKB : 1; e->s.flipX = e->_currentDirection.x > 0; float v = e->keepMoving * EnemySpeed * e->speed * k * e->slow; sprite_setVelocity(&e->s, v * e->_currentDirection.x, v * e->_currentDirection.y); } static const EnemyVT E_Dragon = { .OnRecycle = E_Dragon_OnRecycle, .GetDamaged = E_Dragon_GetDamaged, .Update = E_Dragon_Update }; // --- XLDRAGON1_FLAG / XLDRAGON2_FLAG (0xe43d): il drago-stendardo, una Rope (RibbonTrail 0x7c1) di 120 punti che segue la testa ------- static void Rope_drawH(const Vector2 *pts, int n, const Frame *f, float scale, float alpha, int add, int flipY); static int Rope_cull; // solo per corde a punti fitti: un tratto lungo con gli estremi fuori puo' attraversare lo schermo typedef struct FlagTrail { Sprite s; // la Rope nella lista di disegno (x = y = 0: i punti sono in coordinate del mondo) Vector2 points[0x78], positions[0x78]; int npos; const Frame *frame; } FlagTrail; static void FlagTrail_draw(Sprite *s) { FlagTrail *t = (FlagTrail *)s; if (!s->visible) return; Rope_cull = !scene_view3d; // centinaia di draghi da 120 punti: fuori schermo non si calcola ne' si disegna nulla Rope_drawH(t->points, 0x78, t->frame, 1, s->alpha, 0, s->flipY); Rope_cull = 0; } static void FlagTrail_resetPoints(FlagTrail *t, float x, float y) { for (int i = 0; i < 0x78; i++) t->points[i] = (Vector2){ x, y }; } static void E_Flag_OnRecycle(Enemy *e) { if (!e->trail) { // costruttore: la scia (aggiunta alla scena) e il drago stesso invisibile; OnRecycle lo rimette visibile (sic) cJSON *d = enemy_data(e); e->trail = calloc(1, sizeof(FlagTrail)); sprite_init(&e->trail->s, NULL, 0, 0); e->trail->s.draw = FlagTrail_draw; e->trail->frame = frame_get(str(d, "textureName"), str(d, "flagName")); children_add(&e->trail->s); e->s.visible = 0; e->fadeTrailTween = (TweenRef){ -1, 0 }; } base_EnemyOnRecycle(e); e->trail->npos = 0; // clearPositions FlagTrail_resetPoints(e->trail, e->s.x, e->s.y); // la posizione vecchia (Spawn chiama OnRecycle prima di spostare): la riallinea il primo Update e->trail->s.alpha = 1; e->medusaElapsed += frand() * PI * 2; float sp = num(enemy_data(e), "speed", 0); e->speed = frand() * sp * 0.2f + sp; sprite_setFrame(&e->s, e->defaultName); } static void E_Flag_fadeTrail(Enemy *e) { tween_stop(e->fadeTrailTween); e->fadeTrailTween = tweens_add((TweenConfig){ .props = { { &e->trail->s.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x12c }); } static void E_Flag_Disappear(Enemy *e) { e->isDead = 1; anims_play(&e->s, &e->die, 0); E_Flag_fadeTrail(e); } static void E_Flag_Die(Enemy *e) { base_EnemyDie(e); E_Flag_fadeTrail(e); } static void E_Flag_DeSpawn(Enemy *e) { anims_stop(&e->s); tween_stop(e->fadeTrailTween); e->trail->s.alpha = 0; base_EnemyDeSpawn(e); } static float Enemies_delta; // semplificazione: il delta di Core.Update per i pochi Update(delta) dei nemici, invece di cambiare la firma di tutti static void E_Flag_Update(Enemy *e) { float delta = Enemies_delta > 0 ? Enemies_delta : 16.666f; // il primo fotogramma di raylib ha dt 0, quello di Phaser mai: niente divisione per zero if (e->isDead) return; e->s.depth = game_height; // renderer.height if (e->IsTimeStopped) return; if (!e->FixedDirection || (e->FixedDirection && e->_currentDirection.x == 0 && e->_currentDirection.y == 0)) { e->_currentDirection.x = e->target->x - e->s.x; e->_currentDirection.y = e->target->y - e->s.y; float l = sqrtf(e->_currentDirection.x * e->_currentDirection.x + e->_currentDirection.y * e->_currentDirection.y); if (l > 0) { e->_currentDirection.x /= l; e->_currentDirection.y /= l; } } e->medusaElapsed += e->speed / (0x271 * delta); // (sic): piu' corto il fotogramma, piu' ampio il passo e->_currentDirection.y = cosf(e->medusaElapsed); float k = e->receivingDamage ? -e->knockback * e->damageKB : 1; e->s.flipX = e->_currentDirection.x > 0; float v = EnemySpeed * e->speed * k * e->slow * (16.666f / delta); sprite_setVelocity(&e->s, v * e->_currentDirection.x, v * e->_currentDirection.y); e->s.angle = TweenAngles[e->moveTweenIndex]; FlagTrail *t = e->trail; if (t->npos == 0) FlagTrail_resetPoints(t, e->s.x, e->s.y); // reset memmove(&t->positions[1], &t->positions[0], (0x78 - 1) * sizeof(Vector2)); // trailUpdate: unshift, al massimo 120 t->positions[0] = (Vector2){ e->s.x, e->s.y }; if (t->npos < 0x78) t->npos++; memcpy(t->points, t->positions, t->npos * sizeof(Vector2)); t->s.depth = e->s.depth - 1; t->s.flipY = e->s.flipX; } static const EnemyVT E_Flag = { .OnRecycle = E_Flag_OnRecycle, .Die = E_Flag_Die, .Update = E_Flag_Update, .DeSpawn = E_Flag_DeSpawn, .Disappear = E_Flag_Disappear }; // --- XLMAGIO (0x686): resta a distanza dal giocatore (avanza o arretra) e spara ------------------------------------------ static void E_Magio_fire(void *ctx) { Enemy *e = ctx; if (!e->IsTimeStopped && !e->isDead) Stage_FireEnemyBulletAt(e->s.x, e->s.y); } // BULLET_1 static void E_Magio_OnRecycle(Enemy *e) { base_EnemyOnRecycle(e); sprite_setScale(&e->s, 0), e->firetime = 0, e->keepMoving = 1; cJSON *d = enemy_data(e); e->fireDelay = num(d, "fireDelay", 0) ? num(d, "fireDelay", 0) : 0x7d0; e->bulletType = str(d, "bulletType") ? str(d, "bulletType") : "BULLET_2"; // ignorato: Fire spara BULLET_1 tween_restartOrAdd(&e->OnEnterTween, (TweenConfig){ .props = { { &e->s.scaleX, &e->s.scaleY, e->scaleMul } }, .nprops = 1, .duration = 0x12c }); tween_restartOrAdd(&e->OnFireTimer, (TweenConfig){ .props = { { &e->firetime, NULL, 1 } }, .nprops = 1, .duration = e->fireDelay, .repeat = -1, .onRepeat = E_Magio_fire, .ctx = e }); } static void E_Magio_Update(Enemy *e) { if (e->isDead) return; e->s.depth = e->s.y - Core.Player->s.y; if (e->IsTimeStopped) return; if (!e->FixedDirection || (e->FixedDirection && e->_currentDirection.x == 0 && e->_currentDirection.y == 0)) { e->_currentDirection.x = e->target->x - e->s.x; e->_currentDirection.y = e->target->y - e->s.y; float l = sqrtf(e->_currentDirection.x * e->_currentDirection.x + e->_currentDirection.y * e->_currentDirection.y); if (l > 0) { e->_currentDirection.x /= l; e->_currentDirection.y /= l; } } if (e->Medusa) { e->medusaElapsed += 0.05f; e->_currentDirection.y = cosf(e->medusaElapsed); } float dx = Core.Player->s.x - e->s.x, dy = Core.Player->s.y - e->s.y, d2 = dx * dx + dy * dy, dist = 0xc350; if (d2 < dist - 0x3e8) e->keepMoving = -1; else if (d2 > dist + 0x3e8) e->keepMoving = 1; float k = e->receivingDamage ? -e->knockback * e->damageKB : 1; e->s.flipX = e->_currentDirection.x > 0; float v = e->keepMoving * EnemySpeed * e->speed * k * e->slow; sprite_setVelocity(&e->s, v * e->_currentDirection.x, v * e->_currentDirection.y); e->s.angle = TweenAngles[e->moveTweenIndex]; } static const EnemyVT E_Magio = { .OnRecycle = E_Magio_OnRecycle, .Die = E_Pile_Die, .Update = E_Magio_Update, .DeSpawn = E_Pile_DeSpawn }; static const FancyBG FB_Bat, FB_Astral; static const EnemyVT E_XLTrickster, E_Infernas; // il pianoforte della Biblioteca static const EnemyVT E_DMask, E_DSkull, E_DCluster, E_Directer; static const EnemyVT E_Crab, E_Pincer, E_Drowner, E_WaveW, E_Gallo, E_Leda, E_BridgeBoss, E_Bridge, E_FAngel, E_Trina, E_Molisano, E_Anfora, E_Sketa, E_Snake, E_SnakeRed, E_Crabbino, E_MoonEye, E_EyeSpin, E_MoonAnfora, E_MoonTrina, E_Mask, E_Maddener, E_StalkerN, E_Trickster, E_DrownerN, E_EnderRash, E_Ender, E_Scythe, E_Diamond, E_AxeBat, E_DiamondAxe, E_ScalingBat, E_Stardust, E_StardustAlias, E_Eyes, E_Egg; // piu' avanti, dopo il Blitter static void GA_batDefeated(void); static void E_XXLBat_Die(Enemy *e) { base_EnemyDie(e); if (Core.Stage->fancyBG) GA_batDefeated(); } // 0x182a5: fancyBG.xxlBatsDefeated += 1, se lo stage lo ha static const EnemyVT E_XXLBat = { .Die = E_XXLBat_Die }; static const EnemyVT E_Gasha, E_EvilSpirit, E_Orochi, E_OroHead; static const EnemyVT E_Snak, E_SnakShield, E_Salmon2, E_Flowerfed, E_Cake, E_Patrol, E_MushHP, E_Crate, E_Pot, E_Agaea, E_Jeneviv; static EnemyVT E_Blinder; static void E_Blinder_OnRecycle(Enemy *e); static const EnemyVT *enemy_vt(const char *type) { // EnemyPool: la classe del tipo (le altre arrivano con gli stage) if (!strncmp(type, "FS_", 3) || !strcmp(type, "BOSS_XLBLINDER")) { if (!strcmp(type, "BOSS_XLBLINDER")) { E_Blinder = E_Stalker, E_Blinder.OnRecycle = E_Blinder_OnRecycle; return &E_Blinder; } if (!strcmp(type, "FS_SALMON2")) return &E_Salmon2; if (!strcmp(type, "FS_SNAK1") || !strcmp(type, "FS_SNAK2") || !strcmp(type, "FS_SNAK3") || !strcmp(type, "FS_SNAK4") || !strcmp(type, "FS_SNAK_SWARM") || !strcmp(type, "FS_SNAKBOMB")) return &E_Snak; if (!strcmp(type, "FS_SNAKSHIELD")) return &E_SnakShield; if (!strcmp(type, "FS_SHOOTER1") || !strcmp(type, "FS_SHOOTER2")) return &E_Pile; if (!strcmp(type, "FS_BOSS_AGAEA")) return &E_Agaea; if (!strcmp(type, "FS_CAKE")) return &E_Cake; if (!strcmp(type, "FS_MUSH_PATROL") || !strcmp(type, "FS_BLINDER_PATROL")) return &E_Patrol; if (!strcmp(type, "FS_BROWN") || !strcmp(type, "FS_HTROW") || !strcmp(type, "FS_LAMB") || !strcmp(type, "FS_GEF")) return &E_Flowerfed; if (!strcmp(type, "FS_MUSH_HP")) return &E_MushHP; if (!strcmp(type, "FS_CRATE_HP")) return &E_Crate; if (!strcmp(type, "FS_POT_HP") || !strcmp(type, "FS_ANFORA_HP")) return &E_Pot; if (!strcmp(type, "FS_BOSS_JENEVIV")) return &E_Jeneviv; return NULL; } if (!strcmp(type, "MS_GOSHADOKURO")) return &E_Gasha; if (!strcmp(type, "MS_EVILSPIRIT")) return &E_EvilSpirit; if (!strcmp(type, "MS_OROCHIMARIO")) return &E_Orochi; if (!strcmp(type, "MS_OROCHIHEAD")) return &E_OroHead; if (!strcmp(type, "XXLBAT")) return &E_XXLBat; if (!strncmp(type, "D_MASK_", 7)) return &E_DMask; // la Machine (0x15196, 0xa2b, 0x5b89, 0x185e5) if (!strcmp(type, "D_SKULL") || !strcmp(type, "D_EYE")) return &E_DSkull; if (!strcmp(type, "D_CLUSTER_COINS") || !strcmp(type, "D_CLUSTER_GEMS")) return &E_DCluster; if (!strcmp(type, "DIRECTER")) return &E_Directer; if (!strcmp(type, "BULLET_EGG") || !strcmp(type, "BULLET_EYE")) return &E_Scythe; // stessa classe della falce (0x529e) if (!strcmp(type, "BOSS_XLDEATH") || !strcmp(type, "BOSS_XLDEATH2")) return &E_Reaper; if (!strcmp(type, "PILE1") || !strcmp(type, "PILE2") || !strcmp(type, "PILE3") || !strcmp(type, "PILE4") || !strcmp(type, "PILE4_SCALED") || !strcmp(type, "FS_SHOOTER1")) return &E_Pile; if (!strcmp(type, "BOSS_PILE3")) return &E_BossPile; if (!strcmp(type, "BULLET_1")) return &E_Bullet; if (!strcmp(type, "JELLYFISH") || !strcmp(type, "STARDUST_RELLYFISH")) return &E_Jelly; if (!strcmp(type, "BOSS_XLSTALKER")) return &E_Stalker; if (!strcmp(type, "BOSS_WEREWOLF2")) return &E_Werewolf2; if (!strcmp(type, "BOSS_NOOB")) return &E_Noob; if (!strcmp(type, "SKULLINO") || !strcmp(type, "SKULOROSSO")) return &E_Skullino; if (!strcmp(type, "HARPYV")) return &E_HarpyV; if (!strcmp(type, "POLTER_DEST") || !strcmp(type, "POLTER_GEM_STATIC")) return &E_PolterDest; if (!strcmp(type, "SKELANGUE")) return &E_Skel; if (!strcmp(type, "XLDRAGON1") || !strcmp(type, "XLDRAGON2") || !strcmp(type, "BOSS_XLDRAGON1") || !strcmp(type, "BOSS_XLDRAGON2") || !strcmp(type, "XLSWORDIAN_AGGRO") || !strcmp(type, "XLSWORDIAN_V")) return &E_Dragon; if (!strcmp(type, "XLDRAGON1_FLAG") || !strcmp(type, "XLDRAGON2_FLAG") || !strcmp(type, "XLDRAGON3_FLAG")) return &E_Flag; if (!strcmp(type, "XLMAGIO")) return &E_Magio; if (!strcmp(type, "BOSS_XLCRAB") || !strcmp(type, "BOSS_XLCRAB_RASH")) return &E_Crab; if (!strcmp(type, "BOSS_MADDENER_NORMAL")) return &E_Maddener; if (!strcmp(type, "BOSS_STALKER_NORMAL")) return &E_StalkerN; if (!strcmp(type, "BOSS_TRICKSTER_NORMAL")) return &E_Trickster; if (!strcmp(type, "BOSS_XLTRICKSTER")) return &E_XLTrickster; if (!strcmp(type, "BOSS_SHARD_INFERNAS")) return &E_Infernas; if (!strcmp(type, "BOSS_DROWNER_NORMAL") || !strcmp(type, "BOSS_DROWNER_RASH")) return &E_DrownerN; if (!strcmp(type, "BOSS_ENDER_RASH")) return &E_EnderRash; if (!strcmp(type, "BOSS_ENDER")) return &E_Ender; if (!strcmp(type, "BULLET_SCYTHE")) return &E_Scythe; if (!strcmp(type, "EX_DIAMOND")) return &E_Diamond; if (!strcmp(type, "EX_AXE_BAT3")) return &E_AxeBat; if (!strcmp(type, "EX_DIAMOND_AXE")) return &E_DiamondAxe; if (!strncmp(type, "EX_SCALING_", 11)) return &E_ScalingBat; if (!strcmp(type, "STARDUST_ELEMENTAL") || !strcmp(type, "STARDUST_GHOUL") || !strcmp(type, "STARDUST_GOLEM") || !strcmp(type, "STARDUST_MUMMY") || !strcmp(type, "STARDUST_SKULL")) return &E_Stardust; if (!strcmp(type, "STARDUST_CLOAK") || !strcmp(type, "STARDUST_GHOST")) return &E_StardustAlias; if (!strcmp(type, "STARDUST_EYES") || !strcmp(type, "UNDEADEYES") || !strcmp(type, "STARDUST_HEAD") || !strcmp(type, "UNDEADHEAD") || !strcmp(type, "STARDUST_MUD")) return &E_Eyes; if (!strcmp(type, "COSMIC_EGG")) return &E_Egg; if (!strcmp(type, "BOSS_XLPINCER")) return &E_Pincer; if (!strcmp(type, "BOSS_XLDROWNER")) return &E_Drowner; if (!strcmp(type, "BULLET_W")) return &E_WaveW; if (!strcmp(type, "BOSS_GALLO")) return &E_Gallo; if (!strcmp(type, "FANGEL1") || !strcmp(type, "FANGEL2") || !strcmp(type, "FANGEL3") || !strcmp(type, "TRAINEE_Y") || !strcmp(type, "MOON_BAT") || !strcmp(type, "MOON_BAT_PROJECTILE") || !strcmp(type, "MOON_SHADE")) return &E_FAngel; if (!strcmp(type, "TRINACRIA") || !strcmp(type, "BOSS_TRINACRIA")) return &E_Trina; if (!strcmp(type, "MOLISANO_ANFORA")) return &E_Anfora; if (!strcmp(type, "SKETAMARI")) return &E_Sketa; if (!strcmp(type, "MOON_SNEK") || !strcmp(type, "MOON_SNEK_GREEN")) return &E_Snake; if (!strcmp(type, "MOON_SNEK_RED")) return &E_SnakeRed; if (!strcmp(type, "MOON_CRABBINO") || !strcmp(type, "MOON_BOSS_CRABBINO")) return &E_Crabbino; if (!strcmp(type, "MOON_EYE1") || !strcmp(type, "MOON_EYE2") || !strcmp(type, "MOON_EYE3")) return &E_MoonEye; if (!strcmp(type, "MOON_EYE1S") || !strcmp(type, "MOON_EYE2S") || !strcmp(type, "MOON_EYE3S")) return &E_EyeSpin; if (!strcmp(type, "MOON_ANFORA")) return &E_MoonAnfora; if (!strcmp(type, "MOON_TRINACRIA") || !strcmp(type, "MOON_TRINACRIA_X")) return &E_MoonTrina; if (!strncmp(type, "MOON_MASK", 9) || !strncmp(type, "MASK_", 5)) return &E_Mask; if (!strcmp(type, "MOON_JELLYFISH")) return &E_HarpyV; if (!strncmp(type, "MOLISANO_", 9)) return &E_Molisano; if (!strcmp(type, "BOSS_XLLEDA")) return &E_Leda; if (!strcmp(type, "BRIDGE_BOSS")) return &E_BridgeBoss; if (!strcmp(type, "BRIDGE_ARMOR") || !strcmp(type, "BRIDGE_MINION") || !strcmp(type, "BRIDGE_TETRA") || !strcmp(type, "BRIDGE_TRAINEE")) return &E_Bridge; return NULL; } static void Core_MakeExplosion(float x, float y, float damage, float radius); static void Enemy_OnSelfDestruct(void *ctx) { Enemy *e = ctx; if (e->isDead) return; e->alertSprite.visible = 0; tween_stop(e->alertTween), e->alertTween = (TweenRef){ -1, 0 }; Core_MakeExplosion(e->s.x, e->s.y, e->moreX, e->moreY); Enemy_Disappear(e); } static void Enemy_alertRepeat(void *ctx) { // l'allarme accelera del 10% a ogni giro Enemy *e = ctx; Tween *t = tween_get(e->alertTween); if (t) t->timeScale *= 1.1f; Sound_PlaySound("Alert", 0.2f, 1, 0, 0xfa, 3); } static void Enemy_CheckSelfDestruct(Enemy *e) { // Update / ConditionalUpdate: il ramo SelfDestruct e->alertSprite.x = e->s.x, e->alertSprite.y = e->s.y; // copyPosition if (e->isSelfDestructionTriggered) return; float dx = Core.Player->s.x - e->s.x, dy = Core.Player->s.y - e->s.y; if (dx * dx + dy * dy >= e->SelfDestDistance) return; e->isSelfDestructionTriggered = 1; children_add(&e->alertSprite); e->alertSprite.visible = 1, e->alertSprite.alpha = 1, sprite_setScale(&e->alertSprite, 1); tween_stop(e->alertTween); e->alertTween = tweens_add((TweenConfig){ .props = { { &e->alertSprite.alpha, NULL, 0 }, { &e->alertSprite.scaleX, &e->alertSprite.scaleY, 0.9f } }, .nprops = 2, .yoyo = 1, .duration = 0xc8, .repeat = -1, .onRepeat = Enemy_alertRepeat, .ctx = e }); e->SelfDestructTimer = time_addEvent(0x7d0, 0, 0, Enemy_OnSelfDestruct, e); } static void base_EnemyUpdate(Enemy *e); static int Enemy_beatMode; // Abyss Foscari (0xba51): Update = ConditionalUpdate sul battito static void Enemy_Update(Enemy *e) { if (Enemy_beatMode && !e->conditional_canMove) { // ConditionalUpdate col battito fermo: niente passi if (!e->isDead) { e->s.depth = e->s.y - Core.Player->s.y; if (e->SelfDestruct && !e->IsTimeStopped) Enemy_CheckSelfDestruct(e); } return; } if (e->vt && e->vt->Update) e->vt->Update(e); else base_EnemyUpdate(e); } static void base_EnemyUpdate(Enemy *e) { if (e->isDead) return; e->s.depth = e->s.y - Core.Player->s.y; if (e->IsTimeStopped) return; if (!e->FixedDirection || (e->FixedDirection && e->_currentDirection.x == 0 && e->_currentDirection.y == 0)) { e->_currentDirection.x = e->target->x - e->s.x; e->_currentDirection.y = e->target->y - e->s.y; float l = sqrtf(e->_currentDirection.x * e->_currentDirection.x + e->_currentDirection.y * e->_currentDirection.y); if (l > 0) { e->_currentDirection.x /= l; e->_currentDirection.y /= l; } } if (e->Medusa) { e->medusaElapsed += 0.05f; e->_currentDirection.y = cosf(e->medusaElapsed); } if (e->SelfDestruct) Enemy_CheckSelfDestruct(e); float k = e->receivingDamage ? -e->knockback * e->damageKB : 1; e->s.flipX = e->_currentDirection.x > 0; float v = EnemySpeed * e->speed * k * e->slow; sprite_setVelocity(&e->s, v * e->_currentDirection.x, v * e->_currentDirection.y); e->s.angle = TweenAngles[e->moveTweenIndex]; } static void Enemy_ResumeFromFreeze(void *ctx) { Enemy *e = ctx; e->IsTimeStopped = 0; e->speed = e->defaultSpeed; Enemy_restoreTint(e); if (e->idleFrameCount) anims_resume(&e->s); } static int Enemy_Freeze(void *o, float duration, float chance) { // Enemy.Freeze (0x1166a) Enemy *e = o; if (e->res_Freeze > chance || e->IsTimeStopped) return 0; time_removeEvent(e->FreezeTimer); // FreezeTimer.destroy() e->FreezeTimer = time_addEvent(duration, 0, 0, Enemy_ResumeFromFreeze, e); e->IsTimeStopped = 1; e->speed = 0; sprite_setVelocity(&e->s, 0, 0); sprite_setTint(&e->s, 0xff); if (e->idleFrameCount) anims_pause(&e->s); return 1; } static void Enemy_TimeStop(Enemy *e) { time_removeEvent(e->FreezeTimer); e->IsTimeStopped = 1; e->speed = 0; sprite_setVelocity(&e->s, 0, 0); sprite_setTint(&e->s, 0xff); if (e->idleFrameCount) anims_pause(&e->s); } static EnemyPool *EnemyPool_new(const char *type) { EnemyData_of(type); // l'atlante del tipo si carica alla nascita del pool, non al primo nemico a partita in corso EnemyPool *p = calloc(1, sizeof(EnemyPool)); p->enemyType = type; p->enabled = 1; p->upperLimit = 0x12c; return p; } static void arr_push(Enemy ***a, int *n, int cap, Enemy *e) { (void)cap; *a = realloc(*a, (*n + 1) * sizeof(Enemy *)); (*a)[(*n)++] = e; } static Enemy *EnemyPool_Spawn(EnemyPool *p) { Enemy *e = p->n_stored ? p->stored[--p->n_stored] : NULL; if (!e) { e = Enemy_new(p, p->enemyType); Enemy_Init(e, -1000, -1000); } children_add(&e->s); Enemy_OnRecycle(e); arr_push(&p->spawned, &p->n_spawned, 0, e); list_add(&Core.Enemies, &e->s); if (!e->passThroughWalls) list_add(&Core.EnemyGroup, &e->s); return e; } static Enemy *EnemyPool_SpawnAt(EnemyPool *p, float x, float y) { if (p->n_spawned >= p->upperLimit && p->isUncapped) { int i = 0; while (p->spawned[i]->isDespawning && i < p->upperLimit) i++; if (p->spawned[i]) Enemy_DeSpawn(p->spawned[i]); } Enemy *e = EnemyPool_Spawn(p); e->s.x = x; e->s.y = y; if (e->vt && e->vt->setOwner) e->vt->setOwner(e); if (Core.IsTimeStopped) Enemy_TimeStop(e); return e; } static void EnemyPool_Recycle(EnemyPool *p, Enemy *e) { children_remove(&e->s); for (int i = 0; i < p->n_spawned; i++) if (p->spawned[i] == e) { memmove(&p->spawned[i], &p->spawned[i + 1], (p->n_spawned - i - 1) * sizeof(Enemy *)); p->n_spawned--; break; } list_remove(&Core.Enemies, &e->s); list_remove(&Core.EnemyGroup, &e->s); arr_push(&p->stored, &p->n_stored, 0, e); } // ============================================================================ // 0x4a9d: BulletPool + 0xa14d: Bullet + 0xe49a: Weapon, e le armi base: // 0x7e1d/0xb66f Whip, 0xf82d/0x663d MagicMissile, 0x9225/0x1f5a Knife, // 0x136b1/0xd0f4 Axe, 0x1d36/0x61be HolyBook, 0x1220c/0xe2b7 HolyWater, // 0x7784/0x11fa3 Laurel, 0x5dba PowerUp // ============================================================================ struct BulletVT { const char *tex, *frame; void (*ctor)(Bullet *b); // dopo il costruttore di Bullet void (*Init)(Bullet *b, float x, float y); void (*OnRecycle)(Bullet *b); void (*OnHasHitAnObject)(Bullet *b, void *o, int oIsDead); // o: Enemy o Destructible (si legge solo isDead) void (*Update)(Bullet *b, float delta); void (*DeSpawn)(Bullet *b); void (*SetTarget)(Bullet *b, Vector2 target); // FireOneBullet: SetTarget(target) / SetNullTarget() void (*SetNullTarget)(Bullet *b); void (*OnHasHitWall)(Bullet *b, Tile *t); // NULL: DeSpawn }; struct WeaponVT { const BulletVT *bullet; float (*PArea)(Weapon *w); float (*PAmount)(Weapon *w); float (*PPower)(Weapon *w); float (*PBounces)(Weapon *w); float (*PInterval)(Weapon *w); void (*ctor)(Weapon *w); void (*Fire)(Weapon *w); void (*OnStart)(Weapon *w); void (*Update)(Weapon *w, float delta); int (*LevelUp)(Weapon *w); void (*MakeLevelOne)(Weapon *w); void (*ResetFiringTimer)(Weapon *w); void (*onBulletOverlapsEnemy)(Weapon *w, Bullet *b, Enemy *e); Bullet *(*FireOneBullet)(Weapon *w, float x, float y, int index); // NULL: quello della base void (*OnWeaponAdded)(Weapon *w); // NULL: niente (Core.AddWeapon, dopo l'icona) void (*CheckArcanas)(Weapon *w); // MakeLevelOne e Arcanas.CheckOnAllWeapons float (*SecondaryPPower)(Weapon *w); // NULL: quello della base (secondaryPower) }; // --- Weapon: proprieta' calcolate ------------------------------------------ static float Weapon_PArea(Weapon *w) { return w->vt->PArea(w); } static float Weapon_PAmount(Weapon *w) { return w->vt->PAmount(w); } static float Weapon_PPower(Weapon *w) { return w->vt->PPower(w); } static float base_PArea(Weapon *w) { return fminf(10, Core.Player->area * sinev(Core.Player->sineArea)) * w->area; } static float base_PAmount(Weapon *w) { return fminf(10, Core.Player->amount) + w->amount; } static float base_PPower(Weapon *w) { return fminf(10, (Arcanas.silentMight + Core.Player->power) * sinev(Core.Player->sineMight)) * w->power + Arcanas.bloodlineDamage; } static float base_PBounces(Weapon *w) { return w->bounces; } // Bloodline: Cross, Garlic, HolyBook, HolyWater, Lightning aggiungono l'armatura; Song, Vento, Victory di nuovo bloodlineDamage // (super.PPower lo somma gia': conta due volte, sic) static float armor_PPower(Weapon *w) { return base_PPower(w) + Arcanas.bloodlineArmorValue; } static float blood2_PPower(Weapon *w) { return base_PPower(w) + Arcanas.bloodlineDamage; } static float bonus_PBounces(Weapon *w) { return w->bonusBounces + w->bounces; } // bonusBounces: NaN senza arcana, qui 0 (NaN > 0 e' falso) static float Weapon_PSpeed(Weapon *w) { return fminf(5, Core.Player->speed) * w->speed * sinev(Core.Player->sineSpeed); } static float base_PInterval(Weapon *w) { return fmaxf(0.1f, (Arcanas.silentCooldown + Core.Player->cooldown) * sinev(Core.Player->sineCooldown)) * w->interval; } static float Weapon_PInterval(Weapon *w) { return w->vt->PInterval(w); } static float Weapon_PDuration(Weapon *w) { return fminf(5, Core.Player->duration * sinev(Core.Player->sineDuration)) * w->duration; } static float Bullet_TrueSpeed(Bullet *b) { return Weapon_PSpeed(b->weapon) * ProjectileSpeed * b->_speed; } // --- BulletPool (0x4a9d) ---------------------------------------------------- static void BulletPool_Return(BulletPool *pool, Bullet *b) { children_remove(&b->s); list_remove(&pool->group, &b->s); list_remove(&Core.BulletGroup, &b->s); if (pool->n_stored == pool->cap_stored) { pool->cap_stored = pool->cap_stored ? pool->cap_stored * 2 : 16; pool->stored = realloc(pool->stored, pool->cap_stored * sizeof(Bullet *)); } pool->stored[pool->n_stored++] = b; } // --- Bullet (0xa14d) -------------------------------------------------------- static void Bullet_DeSpawn(Bullet *b) { if (b->vt->DeSpawn) { b->vt->DeSpawn(b); return; } b->s.active = 0; b->s.body.enable = 0; BulletPool_Return(b->pool, b); } static void base_DeSpawn(Bullet *b) { b->s.active = 0; b->s.body.enable = 0; BulletPool_Return(b->pool, b); } static void Bullet_OnRecycle(Bullet *b) { b->isDead = 0; b->n_hit = 0; b->s.active = 1; b->s.body.enable = 1; b->penetrating = b->weapon->penetrating; b->bounces = b->weapon->vt->PBounces(b->weapon); } // Rimbalzo sul WorldBoxCollider attivato da weapon.PBounces (Pearls): Cross, HeavenSword, Scythe, Hellfire. // L'ascoltatore 'worldbounds' resta per sempre (bounceActivated): ai riusi successivi i bordi tornano accesi. static void Bullet_activateBounce(Bullet *b, void (*Bounce)(void *)) { if (b->weapon->vt->PBounces(b->weapon) && !b->bounceActivated) { b->bounceActivated = 1; b->s.body.customBounds = &Core.Player->WorldBoxCollider; b->s.body.onWorldBounds = Bounce, b->s.body.onWorldBoundsCtx = b; } if (b->bounceActivated) b->s.body.collideWorldBounds = 1, b->s.body.hasWorldBounce = 1, b->s.body.worldBounce = (Vector2){ 1, 1 }; } static int Bullet_Bounce(Bullet *b) { // bounces > 0 ? (bounces--, objectsHit = []) : setCollideWorldBounds(false) if (b->bounces > 0) { b->bounces--, b->n_hit = 0; return 1; } b->s.body.collideWorldBounds = 0; return 0; } static void B_velocity_Bounce(void *ctx) { Bullet *b = ctx; if (Bullet_Bounce(b)) b->velocity.x *= -1, b->velocity.y *= -1; } // Cross, HeavenSword static void B_Scythe_Bounce(void *ctx) { Bullet *b = ctx; if (Bullet_Bounce(b)) b->s.body.velocity.x *= -2, b->s.body.velocity.y *= -2; } static void B_Hellfire_Bounce(void *ctx) { Bullet *b = ctx; if (Bullet_Bounce(b)) b->s.body.velocity.x *= -1.5f, b->s.body.velocity.y *= -1.5f, b->s.angle += 0xb4; // setAngle: il wrap non cambia il disegno } static void Bullet_Init(Bullet *b, float x, float y) { b->s.x = x; b->s.y = y; physics_existing(&b->s); b->vt->OnRecycle(b); } static int Bullet_HasAlreadyHitObject(Bullet *b, void *o, int oIsDead) { for (int i = 0; i < b->n_hit; i++) if (b->objectsHit[i] == o) return 1; if (b->n_hit == b->cap_hit) { b->cap_hit = b->cap_hit ? b->cap_hit * 2 : 16; b->objectsHit = realloc(b->objectsHit, b->cap_hit * sizeof(void *)); } b->objectsHit[b->n_hit++] = o; if (b->vt->OnHasHitAnObject) b->vt->OnHasHitAnObject(b, o, oIsDead); return 0; } static float Bullet_AngleFromVelocityRadians(Vector2 v) { return atan2f(v.y - 0, v.x - 1); } // Vector2.RIGHT sottratto come l'originale static void Bullet_ApplyInitialVelocity(Bullet *b, Sprite *target) { Vector2 d = { target->body.position.x - Core.Player->s.x, target->body.position.y - Core.Player->s.y }; float l = sqrtf(d.x * d.x + d.y * d.y); if (l > 0) { d.x /= l; d.y /= l; } sprite_setVelocity(&b->s, Bullet_TrueSpeed(b) * d.x, Bullet_TrueSpeed(b) * d.y); b->s.angle = Bullet_AngleFromVelocityRadians(b->s.body.velocity) * (180 / PI); } static void Bullet_ApplyPlayerFacingVelocity(Bullet *b) { Vector2 *d = &Core.Player->lastFacedDirection; // normalize() modifica il vettore del giocatore float l = sqrtf(d->x * d->x + d->y * d->y); if (l > 0) { d->x /= l; d->y /= l; } if (d->x == 0 && d->y == 0) d->x = 1; sprite_setVelocity(&b->s, Bullet_TrueSpeed(b) * d->x, Bullet_TrueSpeed(b) * d->y); b->s.angle = Bullet_AngleFromVelocityRadians(b->s.body.velocity) * (180 / PI); } static void Bullet_ApplyInversePlayerFacingVelocity(Bullet *b) { Vector2 *d = &Core.Player->lastFacedDirection; // normalize() modifica il vettore del giocatore float l = sqrtf(d->x * d->x + d->y * d->y); if (l > 0) { d->x /= l; d->y /= l; } if (d->x == 0 && d->y == 0) d->x = 1; sprite_setVelocity(&b->s, Bullet_TrueSpeed(b) * -d->x, Bullet_TrueSpeed(b) * -d->y); b->s.angle = Bullet_AngleFromVelocityRadians(b->s.body.velocity) * (180 / PI); } static int Bullet_AimForNearestEnemy(Bullet *b) { Sprite *t = physics_closest(&Core.Player->s, &Core.Enemies); if (t) { Bullet_ApplyInitialVelocity(b, t); return 1; } Bullet_ApplyPlayerFacingVelocity(b); return 0; } static Sprite *Bullet_AimForRandomEnemy(Bullet *b) { Sprite *t = Core.Enemies.n ? Core.Enemies.items[(int)floorf(frand() * Core.Enemies.n)] : NULL; // RND.pick if (t) { Bullet_ApplyInitialVelocity(b, t); return t; } Bullet_ApplyPlayerFacingVelocity(b); return NULL; } static Bullet *Bullet_new(BulletPool *pool, Weapon *w, int index) { const BulletVT *vt = pool->vt ? pool->vt : w->vt->bullet; Bullet *b = calloc(1, sizeof(Bullet)); sprite_init(&b->s, frame_get(vt->tex, vt->frame), 0, 0); b->s.owner = b; b->vt = vt; b->isCullable = 1; b->_speed = 1; b->pool = pool; b->weapon = w; b->indexInWeapon = index; if (vt->ctor) vt->ctor(b); return b; } static Bullet *BulletPool_SpawnAt(BulletPool *pool, float x, float y, Weapon *w, int index) { if (pool->group.n >= pool->upperLimit) { if (!pool->isUncapped) return NULL; Bullet *first = pool->group.n ? pool->group.items[0]->owner : NULL; if (first) Bullet_DeSpawn(first); } Bullet *b = pool->n_stored ? pool->stored[--pool->n_stored] : NULL; // Spawn if (!b) { b = Bullet_new(pool, w, index); (b->vt->Init ? b->vt->Init : Bullet_Init)(b, -1000, -1000); } list_add(&pool->group, &b->s); list_add(&Core.BulletGroup, &b->s); b->s.x = x; b->s.y = y; b->indexInWeapon = index; children_add(&b->s); b->vt->OnRecycle(b); return b; } // Fantasmi (scie) di Knife e Axe: immagini con tinta, alpha e scala proprie static void ghost_init(Bullet *b, float sx, float sy, float alpha) { sprite_init(&b->ghost, b->s.frame, 0, 0); b->ghost.scaleX = sx; b->ghost.scaleY = sy; b->ghost.visible = 0; b->ghost.tint = 0xff; b->ghost.alpha = alpha; children_add(&b->ghost); // scene.add.image } static int getHistoryIndex(Bullet *b, int i) { return b->historyIndex + i >= b->maxHistory ? b->historyIndex + i - b->maxHistory : b->historyIndex + i; } // --- B_Whip (0x7e1d) ---------------------------------------------------------- static void B_Whip_tween2_done(void *ctx) { Bullet_DeSpawn(ctx); } static void B_Whip_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); b->s.alpha = 1; if (b->hasTween) { if (b->previousArea != Weapon_PArea(b->weapon)) { tween_stop(b->tween); tween_remove(b->tween); sprite_setScale(&b->s, 0); b->tween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, PixelScale * Weapon_PArea(b->weapon) } }, .nprops = 1, .duration = 0x64, .persist = 1 }); } tween_restart(b->tween); } if (b->hasTween2) tween_stop(b->tween2); b->tween2 = tweens_add((TweenConfig){ .props = { { &b->s.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x64, .delay = 0x64, .onComplete = B_Whip_tween2_done, .ctx = b }); b->hasTween2 = 1; int flip = Core.Player->s.flipX ? b->indexInWeapon % 2 != 1 : b->indexInWeapon % 2 == 1; b->s.x += flip ? -0x40 : 0x40; b->s.y -= 0x10; b->s.y -= 0x10 * b->indexInWeapon; b->s.flipY = b->indexInWeapon % 2 == 1; b->s.flipX = flip; Sound_PlaySound("Whip", 1.7f, 2, -0x64 * b->indexInWeapon, 0, 0); } static void B_Whip_Init(Bullet *b, float x, float y) { Bullet_Init(b, x, y); sprite_setScale(&b->s, 0); b->previousArea = Weapon_PArea(b->weapon); b->tween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, PixelScale * Weapon_PArea(b->weapon) } }, .nprops = 1, .duration = 0x64, .persist = 1 }); b->hasTween = 1; } static const BulletVT B_Whip = { "vfx", "slash.png", NULL, B_Whip_Init, B_Whip_OnRecycle, NULL, NULL, NULL }; // --- B_MagicMissile (0xf82d) -------------------------------------------------- static void B_MagicMissile_ctor(Bullet *b) { b->Pfx = particles_add(); b->PfxEmitter = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "PfxHoly1.png"), frame_get("vfx", "PfxHoly2.png") }, .nframes = 2, .speed = ERND(0xf, 0x1e), .quantity = 1, .lifespan = EOP(0x12c), .alpha = ERANGE(1, 0), .on = 0 }); } static void B_MagicMissile_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); body_setCircle(&b->s.body, 8, b->s.body.offset.x, b->s.body.offset.y); sprite_setScale(&b->s, PixelScale * Weapon_PArea(b->weapon)); b->s.x += (frand() - 0.5f) * b->indexInWeapon * 0xa; b->s.y += (frand() - 0.5f) * b->indexInWeapon * 0xa; Bullet_AimForNearestEnemy(b); Sound_PlaySound("MagicMissile", b->weapon->volume ? b->weapon->volume : 0.15f, 1, -0x64 * b->indexInWeapon, 0xc8, 0xc); } static void Bullet_TryFreeze(Bullet *b, void *o); static void B_MagicMissile_OnHasHitAnObject(Bullet *b, void *o, int isDead) { // anche Knife, Fireball (Jewels: solo MagicMissile e HolyWand lo accendono) if (isDead) return; if (b->bounces > 0) { b->bounces--; Bullet_AimForRandomEnemy(b); b->n_hit = 0; return; } b->penetrating--; if (b->penetrating <= 0) Bullet_DeSpawn(b); if (Arcanas_has(14) && b->weapon->freezeChance > 0) Bullet_TryFreeze(b, o); } static void B_MagicMissile_Update(Bullet *b, float delta) { (void)delta; emitter_emitParticleAt(b->PfxEmitter, b->s.x, b->s.y, 0); } static const BulletVT B_MagicMissile = { "vfx", "ProjectileHoly1.png", B_MagicMissile_ctor, NULL, B_MagicMissile_OnRecycle, B_MagicMissile_OnHasHitAnObject, B_MagicMissile_Update, NULL }; // --- B_Knife (0x9225) --------------------------------------------------------- static void B_Knife_ctor(Bullet *b) { b->maxHistory = 1; sprite_setScale(&b->s, PixelScale * Weapon_PArea(b->weapon)); b->s.angle = -0x5a; b->_speed = 2; b->posHistory[0] = (Vector2){ 0, 0 }; ghost_init(b, 1.5f * PixelScale, 0.75f * PixelScale, 0.5f); } static void B_Knife_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); body_setCircle(&b->s.body, 8, b->s.body.offset.x, b->s.body.offset.y); b->_speed = 2; Weapon *w = b->weapon; float c = w->critChancesArray[w->critIndex++ % 1000]; b->bounces = c >= 0.5f ? w->vt->PBounces(w) : 0; sprite_setScale(&b->s, PixelScale * Weapon_PArea(w)); b->ghost.scaleX = 2 * b->s.scaleX; b->ghost.scaleY = 0.75f * b->s.scaleX; b->ghost.visible = 1; b->ghost.angle = b->s.angle; b->ghost.x = b->s.x; b->ghost.y = b->s.y; for (int i = 0; i < b->maxHistory; i++) b->posHistory[i] = (Vector2){ b->s.x, b->s.y }; b->s.y -= 0xc; b->s.x += (frand() - 0.5f) * (b->indexInWeapon == 0 ? 0 : 0x28) * Weapon_PArea(w); b->s.y += (frand() - 0.5f) * (b->indexInWeapon == 0 ? 0 : 0x28) * Weapon_PArea(w); Bullet_ApplyPlayerFacingVelocity(b); Sound_PlaySound("Shot", w->volume ? w->volume : 0.4f, 1, -0x64 * b->indexInWeapon, 0xc8, 0xa); } static void B_Knife_DeSpawn(Bullet *b) { b->ghost.visible = 0; base_DeSpawn(b); } static void B_Knife_Update(Bullet *b, float delta) { (void)delta; if (b->historyIndex < b->maxHistory - 1) b->historyIndex++; else b->historyIndex = 0; Vector2 h = b->posHistory[getHistoryIndex(b, 0)]; b->ghost.angle = b->s.angle; b->ghost.x = h.x; b->ghost.y = h.y; b->posHistory[b->historyIndex] = (Vector2){ b->s.x, b->s.y }; } static const BulletVT B_Knife = { "vfx", "ProjectileKnife3.png", B_Knife_ctor, NULL, B_Knife_OnRecycle, B_MagicMissile_OnHasHitAnObject, B_Knife_Update, B_Knife_DeSpawn }; // --- B_Axe (0x136b1) ---------------------------------------------------------- static void B_Axe_ctor(Bullet *b) { b->maxHistory = 1; b->grav = 0.625f; sprite_setScale(&b->s, PixelScale * Weapon_PArea(b->weapon)); b->AngleTween = tweens_add((TweenConfig){ .props = { { &b->s.angle, NULL, 0x168 } }, .nprops = 1, .duration = 0x3e8, .repeat = -1 }); b->MovementTween = tweens_add((TweenConfig){ .props = { { &b->moveAngle, NULL, PI } }, .nprops = 1, .duration = 0x3e8 }); ghost_init(b, PixelScale, PixelScale, 0.75f); } static void B_Axe_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); body_setCircle(&b->s.body, 0xc, b->s.body.offset.x, b->s.body.offset.y); b->_speed = 2; b->isCullable = 0; sprite_setScale(&b->s, PixelScale * Weapon_PArea(b->weapon)); int dir = Core.Player->lastFacedDirection.x * 1 + Core.Player->lastFacedDirection.y * 0 < 0 ? -1 : 1; // dot(RIGHT) float a = 0x2d * dir / Weapon_PAmount(b->weapon) * b->indexInWeapon - 0x5a; b->startingAngle = a; b->s.body.velocity = velocityFromRotation(a * (PI / 180), Bullet_TrueSpeed(b)); b->initialVelocity.x = b->s.body.velocity.x; b->initialVelocity.y = fmaxf(-0x258, b->s.body.velocity.y); for (int i = 0; i < b->maxHistory; i++) b->posHistory[i] = (Vector2){ b->s.x, b->s.y }; b->moveAngle = a * (PI / 180); b->MovementTween = tweens_add((TweenConfig){ .props = { { &b->moveAngle, NULL, (a + 0xb4 * dir) * (PI / 180) } }, .nprops = 1, .duration = 0x5dc }); Sound_PlaySound("Shot", 0.45f, 1, -0x64 * b->indexInWeapon, 0xc8, 0xa); } static void B_Axe_DeSpawn(Bullet *b) { tween_stop(b->MovementTween); tween_stop(b->ScaleTween); b->ghost.visible = 0; base_DeSpawn(b); } static void B_Axe_OnHasHitAnObject(Bullet *b, void *o, int isDead) { (void)o; if (isDead) return; if (b->bounces > 0) { b->bounces--; b->s.body.velocity = velocityFromRotation(b->startingAngle * (PI / 180), Bullet_TrueSpeed(b)); b->initialVelocity.x *= -1; b->initialVelocity.y = fmaxf(-0x258, b->s.body.velocity.y); b->n_hit = 0; return; } b->penetrating--; if (b->penetrating <= 0) Bullet_DeSpawn(b); } static void B_Axe_Update(Bullet *b, float delta) { b->initialVelocity.y += delta * b->grav; if (b->historyIndex < b->maxHistory - 1) b->historyIndex++; else b->historyIndex = 0; Vector2 h = b->posHistory[getHistoryIndex(b, 0)]; b->ghost.angle = b->s.angle; b->ghost.x = h.x; b->ghost.y = h.y; b->ghost.scaleX = b->ghost.scaleY = b->s.scaleX; b->ghost.visible = 1; sprite_setVelocity(&b->s, b->initialVelocity.x, b->initialVelocity.y); b->posHistory[b->historyIndex] = (Vector2){ b->s.x, b->s.y }; if (b->s.y > Core.Player->s.y + game_height) { b->isCullable = 1; Bullet_DeSpawn(b); } } static const BulletVT B_Axe = { "vfx", "ProjectileAxe1.png", B_Axe_ctor, NULL, B_Axe_OnRecycle, B_Axe_OnHasHitAnObject, B_Axe_Update, B_Axe_DeSpawn }; static void Bullet_explodeMany(Bullet *b); static Bullet *Weapon_SpawnExplosionAt(Weapon *w, float x, float y, int index); static BulletPool *BulletPool_new(Weapon *w, const BulletVT *vt); // --- B_HolyBook (0x1d36) ------------------------------------------------------ static void B_HolyBook_pfxStart(void *ctx) { emitter_start(((Bullet *)ctx)->PfxEmitter); } static void B_HolyBook_clearHits(void *ctx) { ((Bullet *)ctx)->n_hit = 0; } static void B_HolyBook_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void B_HolyBook_expire(void *ctx) { Bullet *b = ctx; time_removeEvent(b->HitboxTimer); time_removeEvent(b->ExpireTimer); emitter_stop(b->PfxEmitter); if (b->hasScaleTween) tween_stop(b->scaleTween); b->scaleTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, 0 } }, .nprops = 1, .duration = 0x1f4, .onComplete = B_HolyBook_despawn, .ctx = b }); b->hasScaleTween = 1; } static void B_HolyBook_ctor(Bullet *b) { b->radius = 0x32; b->perc = 1.0f / 16; sprite_setScale(&b->s, PixelScale * (1 + 0.1f * Weapon_PArea(b->weapon))); b->Pfx = particles_add(); b->PfxEmitter = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "Page.png") }, .nframes = 1, .speed = EOP(0x32), .quantity = 1, .lifespan = EOP(0x12c), .alpha = ERANGE(0.7f, 0), .on = 1, .follow = &b->s, .frequency = 0xc8 }); // requiemRandomOffsets: servono solo con l'arcana Twilight Requiem } static void B_HolyBook_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); body_setCircle(&b->s.body, 8, b->s.body.offset.x, b->s.body.offset.y); sprite_setScale(&b->s, 0); if (b->hasScaleTween) tween_stop(b->scaleTween); b->scaleTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, PixelScale * (1 + 0.3f * Weapon_PArea(b->weapon)) } }, .nprops = 1, .duration = 0x1f4, .onComplete = B_HolyBook_pfxStart, .ctx = b }); b->hasScaleTween = 1; b->deltaTime = 2 * PI / Weapon_PAmount(b->weapon) * b->indexInWeapon; time_removeEvent(b->HitboxTimer); time_removeEvent(b->ExpireTimer); b->HitboxTimer = time_addEvent(b->weapon->hitBoxDelay, 1, 0, B_HolyBook_clearHits, b); b->ExpireTimer = time_addEvent(Weapon_PDuration(b->weapon), 0, 0, B_HolyBook_expire, b); } static void B_HolyBook_DeSpawn(Bullet *b) { base_DeSpawn(b); if (b->hasScaleTween) tween_stop(b->scaleTween); time_removeEvent(b->HitboxTimer); time_removeEvent(b->ExpireTimer); emitter_stop(b->PfxEmitter); if (b->weapon->explodeOnExpire) Bullet_explodeMany(b); } static void B_HolyBook_Update(Bullet *b, float delta) { b->deltaTime += 0.035f * Weapon_PSpeed(b->weapon) * delta * b->perc; b->s.x = Core.Player->s.x; b->s.y = Core.Player->s.y; float r = fminf(4.5f, Weapon_PArea(b->weapon)); b->s.x += cosf(b->deltaTime) * r * b->radius; b->s.y += sinf(b->deltaTime) * r * b->radius; } static const BulletVT B_HolyBook = { "vfx", "HolyBook.png", B_HolyBook_ctor, NULL, B_HolyBook_OnRecycle, NULL, B_HolyBook_Update, B_HolyBook_DeSpawn }; // --- B_HolyWater (0x1220c) ---------------------------------------------------- static void GroundFx_draw(Sprite *s) { // scene.add.circle(16, colore in tint), blend ADD BeginBlendMode(BLEND_ADDITIVE); DrawCircle((int)roundf(s->x - camera_scrollX), (int)roundf(s->y - camera_scrollY), 16 * s->scaleX, (Color){ (s->tint >> 16) & 0xff, (s->tint >> 8) & 0xff, s->tint & 0xff, (unsigned char)(255 * s->alpha) }); EndBlendMode(); } static float Weapon_GetAngle(Weapon *w) { int i = (w->lastAngleIndex + 1) % w->maxAngles; w->lastAngleIndex = i; return w->targetAngles[i]; } static float Weapon_GetRadius(Weapon *w) { int i = (w->lasRadiusIndex + 1) % w->maxAngles; w->lasRadiusIndex = i; return w->targetRadii[i]; } static void B_HolyWater_Break(void *ctx); static void B_HolyWater_expire(void *ctx) { Bullet *b = ctx; b->GroundFx.visible = 0; time_removeEvent(b->HitboxTimer); time_removeEvent(b->ExpireTimer); Bullet_DeSpawn(b); } static void B_HolyWater_ctor(Bullet *b) { b->radius = 0x10; b->exploRadius = 8; b->_speed = 2; b->explosionRadius = b->exploRadius; sprite_init(&b->GroundFx, NULL, 0, 0); b->GroundFx.alpha = 0.2f; b->GroundFx.tint = 0xff; b->GroundFx.visible = 0; b->GroundFx.draw = GroundFx_draw; children_add(&b->GroundFx); b->Pfx = particles_add(); const Frame *fl[2] = { frame_get("vfx", "ProjectileFlameHoly.png"), frame_get("vfx", "ProjectileFlameBlue.png") }; b->PfxEmitter1 = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { fl[0], fl[1] }, .nframes = 2, .speed = ERND(1, 1), .quantity = 1, .rotate = ERND(0x5a, 0x5a), .lifespan = EOP(0x258), .alpha = ERANGE(1, 0), .scale = ERANGE(PixelScale / 4, PixelScale), .hasZone = 1, .zoneRadius = b->exploRadius }); b->PfxEmitter2 = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { fl[0], fl[1] }, .nframes = 2, .speed = ERND(1, 1), .quantity = 1, .rotate = ERND(0x5a, 0x5a), .lifespan = EOP(0x258), .alpha = ERANGE(0.2f, 0), .scale = ERANGE(PixelScale / 4, PixelScale / 2), .blendAdd = 1, .hasZone = 1, .zoneRadius = b->exploRadius }); b->PfxExplosion = particles_add(); particles_createEmitter(b->PfxExplosion, (EmitterConfig){ .frames = { frame_get("vfx", "HitCloud2.png") }, .nframes = 1, .quantity = 1, .rotate = ERND(0, 0x168), .lifespan = EOP(0x96), .alpha = ERANGE(1, 0.5f), .scale = ERANGE(PixelScale / 4, 2 * PixelScale) }); particles_createEmitter(b->PfxExplosion, (EmitterConfig){ .frames = { frame_get("vfx", "HitCloud1.png") }, .nframes = 1, .quantity = 3, .rotate = ERND(0, 0x168), .lifespan = EOP(0x96), .alpha = ERANGE(1, 0.5f), .scale = ERANGE(PixelScale / 4, PixelScale) }); b->AngleTween = tweens_add((TweenConfig){ .props = { { &b->s.angle, NULL, 0x168 } }, .nprops = 1, .duration = 0x258, .repeat = -1 }); } static void B_HolyWater_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); Weapon *w = b->weapon; b->_speed = 2; body_setCircle(&b->s.body, b->radius, -0.5f * b->radius, -0.5f * b->radius); sprite_setScale(&b->s, PixelScale); b->s.visible = 1; b->isBroken = 0; b->s.body.enable = 0; b->isCullable = 0; time_removeEvent(b->HitboxTimer); time_removeEvent(b->ExpireTimer); b->explosionRadius = b->exploRadius * Weapon_PArea(w) * 3; b->PfxEmitter1->c.zoneRadius = b->PfxEmitter2->c.zoneRadius = b->explosionRadius; b->PfxEmitter1->c.quantity = b->PfxEmitter2->c.quantity = 1 + (int)floorf(w->level / 3.0f); Vector2 t = { Core.Player->s.x, Core.Player->s.y }; b->s.x = t.x + (frand() - 0.5f) * game_width * 0.5f; b->s.y = t.y - 0.6f * game_height; float ang = Weapon_GetAngle(w), rad = Weapon_GetRadius(w); t.x += cosf(ang) * rad; t.y += sinf(ang) * rad; if (Weapon_PAmount(w) < 4 && b->indexInWeapon == 0) { Sprite *c = physics_closest(&Core.Player->s, &Core.Enemies); if (c) t = (Vector2){ c->x, c->y }; } b->s.depth = b->s.y - Core.Player->s.y + game_height; if (b->hasPositionTween) tween_remove(b->PositionTween); b->PositionTween = tweens_add((TweenConfig){ .props = { { &b->s.x, NULL, t.x }, { &b->s.y, NULL, t.y } }, .nprops = 2, .duration = 0x2ee, .onComplete = B_HolyWater_Break, .ctx = b }); b->hasPositionTween = 1; } static void B_HolyWater_Break(void *ctx) { Bullet *b = ctx; if (b->isBroken) return; b->isBroken = 1; b->s.visible = 0; sprite_setVelocity(&b->s, 0, 0); b->n_hit = 0; b->s.body.enable = 1; b->GroundFx.x = b->s.x; b->GroundFx.y = b->s.y; b->GroundFx.visible = 1; sprite_setScale(&b->GroundFx, PixelScale * Weapon_PArea(b->weapon)); sprite_setScale(&b->s, PixelScale * Weapon_PArea(b->weapon)); b->HitboxTimer = time_addEvent(b->weapon->hitBoxDelay, 1, 0, B_HolyBook_clearHits, b); b->ExpireTimer = time_addEvent(Weapon_PDuration(b->weapon), 0, 0, B_HolyWater_expire, b); manager_emitParticleAt(b->PfxExplosion, b->s.x, b->s.y); b->Pfx->s.depth = b->s.y - Core.Player->s.y - 0.5f * game_height; b->GroundFx.depth = b->s.y - Core.Player->s.y - 0.5f * game_height; Sound_PlaySound("Holywater", 0.35f, 2, -0xc8 - -0x32 * b->indexInWeapon, 0xc8, 0xc); } static void B_HolyWater_Update(Bullet *b, float delta) { (void)delta; if (b->isBroken) manager_emitParticleAt(b->Pfx, b->s.x, b->s.y); } static void B_HolyWater_DeSpawn(Bullet *b) { b->isCullable = 1; time_removeEvent(b->HitboxTimer); time_removeEvent(b->ExpireTimer); b->GroundFx.visible = 0; base_DeSpawn(b); } static const BulletVT B_HolyWater = { "items", "HolyWater.png", B_HolyWater_ctor, NULL, B_HolyWater_OnRecycle, NULL, B_HolyWater_Update, B_HolyWater_DeSpawn }; // --- B_Vampirica (0xe4a6): la frusta con due fantasmi, rosso e viola additivo ------------ static TweenRef B_Vampirica_scaleTween(Bullet *b) { // targets [this, ghost1, ghost2] float v = PixelScale * Weapon_PArea(b->weapon); return tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, v }, { &b->ghost.scaleX, &b->ghost.scaleY, v }, { &b->ghost2.scaleX, &b->ghost2.scaleY, v } }, .nprops = 3, .duration = 0x64, .persist = 1 }); } static void B_Vampirica_ctor(Bullet *b) { sprite_init(&b->ghost, frame_get("vfx", "slash.png"), b->s.x, b->s.y); sprite_setScale(&b->ghost, 0); sprite_init(&b->ghost2, frame_get("vfx", "slash.png"), b->s.x, b->s.y); sprite_setScale(&b->ghost2, 0); b->ghost2.blendAdd = 1; children_add(&b->ghost); children_add(&b->ghost2); sprite_setTint(&b->s, 0x110011); sprite_setTint(&b->ghost2, 0x660066); sprite_setTint(&b->ghost, 0xff0000); } static void B_Vampirica_Init(Bullet *b, float x, float y) { Bullet_Init(b, x, y); sprite_setScale(&b->s, 0); b->previousArea = Weapon_PArea(b->weapon); b->tween = B_Vampirica_scaleTween(b); b->hasTween = 1; } static void B_Vampirica_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); b->s.alpha = b->ghost.alpha = b->ghost2.alpha = 1; if (b->hasTween) { if (b->previousArea != Weapon_PArea(b->weapon)) { tween_stop(b->tween); tween_remove(b->tween); sprite_setScale(&b->s, 0); b->tween = B_Vampirica_scaleTween(b); } tween_restart(b->tween); } if (b->hasTween2) tween_stop(b->tween2); b->tween2 = tweens_add((TweenConfig){ .props = { { &b->s.alpha, NULL, 0 }, { &b->ghost.alpha, NULL, 0 }, { &b->ghost2.alpha, NULL, 0 } }, .nprops = 3, .duration = 0xc8, .delay = 0x64, .onComplete = B_Whip_tween2_done, .ctx = b }); b->hasTween2 = 1; int flip = Core.Player->s.flipX ? b->indexInWeapon % 2 != 1 : b->indexInWeapon % 2 == 1; b->s.x += flip ? -0x40 : 0x40; b->s.y -= 0x10; b->s.y -= 0x10 * b->indexInWeapon; int fy = b->indexInWeapon % 2 == 1; b->s.flipY = b->ghost.flipY = b->ghost2.flipY = fy; b->s.flipX = b->ghost.flipX = b->ghost2.flipX = flip; b->ghost.x = b->s.x + 4, b->ghost2.x = b->s.x - 4; b->ghost.y = b->s.y + 2, b->ghost2.y = b->s.y - 2; Sound_PlaySound("Whip", 1.7f, 2, -0x64 * b->indexInWeapon, 0, 0); } static const BulletVT B_Vampirica = { "vfx", "slash.png", B_Vampirica_ctor, B_Vampirica_Init, B_Vampirica_OnRecycle, NULL, NULL, NULL }; // --- B_Scythe (0x1179c): falce che gira, a raggiera, con un fantasma nero ---------------- static void B_Scythe_ctor(Bullet *b) { b->maxHistory = 1; b->posHistory[0] = (Vector2){ b->s.x, b->s.y }; b->AngleTween = tweens_add((TweenConfig){ .props = { { &b->s.angle, NULL, 0x168 } }, .nprops = 1, .duration = 0x1f4, .repeat = -1 }); ghost_init(b, PixelScale, PixelScale, 0.75f); b->ghost.tint = 0; } static void B_Scythe_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); body_setCircle(&b->s.body, 0x10, b->s.body.offset.x, b->s.body.offset.y); sprite_setScale(&b->s, PixelScale * Weapon_PArea(b->weapon)); float a = 0x168 / Weapon_PAmount(b->weapon) * b->indexInWeapon - 0x5a; b->s.body.velocity = velocityFromRotation(a * (PI / 180), Bullet_TrueSpeed(b)); for (int i = 0; i < b->maxHistory; i++) b->posHistory[i] = (Vector2){ b->s.x, b->s.y }; Sound_PlaySound("Shot", 0.4f, 1, -0x64 * b->indexInWeapon, 0xc8, 0xa); Bullet_activateBounce(b, B_Scythe_Bounce); } static void B_Scythe_Update(Bullet *b, float delta) { (void)delta; if (b->historyIndex < b->maxHistory - 1) b->historyIndex++; else b->historyIndex = 0; Vector2 h = b->posHistory[getHistoryIndex(b, 0)]; b->ghost.angle = b->s.angle; b->ghost.x = h.x; b->ghost.y = h.y; b->ghost.scaleX = b->ghost.scaleY = b->s.scaleX; b->ghost.visible = 1; b->posHistory[b->historyIndex] = (Vector2){ b->s.x, b->s.y }; } static const BulletVT B_Scythe = { "vfx", "ProjectileScythe.png", B_Scythe_ctor, NULL, B_Scythe_OnRecycle, NULL, B_Scythe_Update, B_Knife_DeSpawn }; // --- B_Vespers (0x54d4): HolyBook con Page2, scia piu' fitta e l'animazione 'idle' ---------- static Animation VespersIdle; // anims.create('idle'): g o r g o n z o l a, 2 fps, repeat -1 static void B_Vespers_ctor(Bullet *b) { b->radius = 0x32; b->perc = 1.0f / 16; sprite_setScale(&b->s, PixelScale * (1 + 0.1f * Weapon_PArea(b->weapon))); static const char *letters[] = { "g.png", "o.png", "r.png", "g.png", "o.png", "n.png", "z.png", "o.png", "l.png", "a.png" }; VespersIdle.n = 0; for (int i = 0; i < 10; i++) VespersIdle.frames[VespersIdle.n++] = frame_get("vfx", letters[i]); VespersIdle.frameRate = 2, VespersIdle.msPerFrame = 1000.0f / 2, VespersIdle.repeat = -1; b->Pfx = particles_add(); b->PfxEmitter = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "Page2.png") }, .nframes = 1, .speed = EOP(0x32), .quantity = 2, .lifespan = EOP(0x12c), .alpha = ERANGE(1, 0), .on = 1, .follow = &b->s, .frequency = 0x64 }); // requiemRandomOffsets: servono solo con l'arcana Twilight Requiem } static void B_Vespers_OnRecycle(Bullet *b) { // OnRecycle di HolyBook (stessi tween e timer) + anims.play('idle') B_HolyBook_OnRecycle(b); anims_play(&b->s, &VespersIdle, 0); } static const BulletVT B_Vespers = { "vfx", "Page2.png", B_Vespers_ctor, NULL, B_Vespers_OnRecycle, NULL, B_HolyBook_Update, B_HolyBook_DeSpawn }; // --- b_Bora (0xbbe): acqua che si rompe, poi insegue il giocatore e cresce ---------------- static Vector2 W_Bora_GetTargetPoint(Weapon *w) { int i = (w->lasRadiusIndex + 1) % w->maxAngles; w->lasRadiusIndex = i; return w->targetPoints[i]; } static void B_Bora_Break(void *ctx); static void B_Bora_ctor(Bullet *b) { b->radius = 0x10; b->exploRadius = 8; b->_speed = 2; b->explosionRadius = b->exploRadius; sprite_init(&b->GroundFx, NULL, 0, 0); b->GroundFx.alpha = 0.2f; // groundFxAlpha b->GroundFx.tint = 0x88ff; b->GroundFx.visible = 0; b->GroundFx.draw = GroundFx_draw; children_add(&b->GroundFx); b->Pfx = particles_add(); const Frame *fl[2] = { frame_get("vfx", "ProjectileFlameHoly2.png"), frame_get("vfx", "ProjectileFlameBlue2.png") }; b->PfxEmitter1 = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { fl[0], fl[1] }, .nframes = 2, .speed = ERND(1, 1), .quantity = 1, .rotate = ERND(0x5a, 0x5a), .lifespan = EOP(0x258), .alpha = ERANGE(1, 0), .scale = ERANGE(PixelScale / 4, PixelScale), .hasZone = 1, .zoneRadius = b->exploRadius }); b->PfxEmitter2 = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { fl[0], fl[1] }, .nframes = 2, .speed = ERND(1, 1), .quantity = 1, .rotate = ERND(0x5a, 0x5a), .lifespan = EOP(0x258), .alpha = ERANGE(0.2f, 0), .scale = ERANGE(PixelScale / 4, PixelScale / 2), .blendAdd = 1, .hasZone = 1, .zoneRadius = b->exploRadius }); b->PfxExplosion = particles_add(); particles_createEmitter(b->PfxExplosion, (EmitterConfig){ .frames = { frame_get("vfx", "HitCloud2.png") }, .nframes = 1, .quantity = 1, .rotate = ERND(0, 0x168), .lifespan = EOP(0x96), .alpha = ERANGE(1, 0.5f), .scale = ERANGE(PixelScale / 4, 2 * PixelScale) }); particles_createEmitter(b->PfxExplosion, (EmitterConfig){ .frames = { frame_get("vfx", "HitCloud1.png") }, .nframes = 1, .quantity = 3, .rotate = ERND(0, 0x168), .lifespan = EOP(0x96), .alpha = ERANGE(1, 0.5f), .scale = ERANGE(PixelScale / 4, PixelScale) }); b->AngleTween = tweens_add((TweenConfig){ .props = { { &b->s.angle, NULL, 0x168 } }, .nprops = 1, .duration = 0x258, .repeat = -1 }); } static void B_Bora_OnRecycle(Bullet *b) { b->s.visible = 0; Bullet_OnRecycle(b); Weapon *w = b->weapon; b->_speed = 2; body_setCircle(&b->s.body, b->radius, -0.5f * b->radius, -0.5f * b->radius); if (b->hasGrowTween) tween_stop(b->growTween); sprite_setScale(&b->s, PixelScale); b->s.visible = 1; b->isBroken = 0; b->s.body.enable = 0; b->isCullable = 0; time_removeEvent(b->HitboxTimer); time_removeEvent(b->ExpireTimer); b->explosionRadius = b->exploRadius * Weapon_PArea(w) * 3; // explosionCircle b->PfxEmitter1->c.zoneRadius = b->PfxEmitter2->c.zoneRadius = b->explosionRadius; b->PfxEmitter1->c.quantity = b->PfxEmitter2->c.quantity = 1 + (int)floorf(w->level / 3.0f); Vector2 t = { Core.Player->s.x, Core.Player->s.y }; b->s.x = t.x + (frand() - 0.5f) * game_width * 0.5f; b->s.y = t.y - 0.6f * game_height; Vector2 pt = W_Bora_GetTargetPoint(w); t.x += pt.x; t.y += pt.y; if (Weapon_PAmount(w) < 4 && b->indexInWeapon == 0) { Sprite *c = physics_closest(&Core.Player->s, &Core.Enemies); if (c) t = (Vector2){ c->x, c->y }; } b->s.depth = b->s.y - Core.Player->s.y + game_height; if (b->hasPositionTween) tween_remove(b->PositionTween); b->PositionTween = tweens_add((TweenConfig){ .props = { { &b->s.x, NULL, t.x }, { &b->s.y, NULL, t.y } }, .nprops = 2, .duration = 0x12c, .onComplete = B_Bora_Break, .ctx = b }); b->hasPositionTween = 1; } static void B_Bora_grow(void *ctx) { // onComplete di scaleGroundTweeen Bullet *b = ctx; float ms = Core.Player->moveSpeed > 1 ? Core.Player->moveSpeed : 1; float sc = fminf(0xc, ms * PixelScale * Weapon_PArea(b->weapon) * Weapon_PSpeed(b->weapon)); if (b->hasGrowTween) tween_stop(b->growTween); b->growTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, sc }, { &b->GroundFx.scaleX, &b->GroundFx.scaleY, sc } }, .nprops = 2, .duration = Weapon_PDuration(b->weapon) - 0xc8 }); b->hasGrowTween = 1; } static void B_Bora_expire(void *ctx) { Bullet *b = ctx; b->GroundFx.visible = 0; time_removeEvent(b->HitboxTimer); time_removeEvent(b->ExpireTimer); Bullet_DeSpawn(b); } static void B_Bora_Break(void *ctx) { Bullet *b = ctx; if (b->isBroken) return; Weapon *w = b->weapon; b->isBroken = 1; b->s.visible = 0; sprite_setVelocity(&b->s, 0, 0); b->n_hit = 0; b->s.body.enable = 1; b->GroundFx.x = b->s.x; b->GroundFx.y = b->s.y; b->GroundFx.visible = 1; sprite_setScale(&b->GroundFx, 0); b->GroundFx.alpha = 0.2f; if (b->hasScaleGroundTween) tween_stop(b->scaleGroundTween); b->scaleGroundTween = tweens_add((TweenConfig){ .props = { { &b->GroundFx.scaleX, &b->GroundFx.scaleY, PixelScale * Weapon_PArea(w) } }, .nprops = 1, .duration = 0xc8, .onComplete = B_Bora_grow, .ctx = b }); b->hasScaleGroundTween = 1; sprite_setScale(&b->s, PixelScale * Weapon_PArea(w)); b->HitboxTimer = time_addEvent(w->hitBoxDelay, 1, 0, B_HolyBook_clearHits, b); if (b->hasFadeOutTween) tween_stop(b->fadeOutTween); b->fadeOutTween = tweens_add((TweenConfig){ .props = { { &b->GroundFx.alpha, NULL, 0 } }, .nprops = 1, .delay = 0.8f * Weapon_PDuration(w), .duration = 0.2f * Weapon_PDuration(w) }); b->hasFadeOutTween = 1; b->ExpireTimer = time_addEvent(Weapon_PDuration(w), 0, 0, B_Bora_expire, b); manager_emitParticleAt(b->PfxExplosion, b->s.x, b->s.y); b->Pfx->s.depth = b->s.y - Core.Player->s.y - 0.5f * game_height; b->GroundFx.depth = b->s.y - Core.Player->s.y - 0.5f * game_height; Sound_PlaySound("Holywater", 0.35f, 2, -0xc8 - -0x32 * b->indexInWeapon, 0xc8, 0xc); } static void B_Bora_Update(Bullet *b, float delta) { (void)delta; if (!b->isBroken) return; manager_emitParticleAt(b->Pfx, b->s.x, b->s.y); Vector2 d = { Core.Player->s.x - b->s.x, Core.Player->s.y - b->s.y }; float l = sqrtf(d.x * d.x + d.y * d.y); if (l > 0) d.x /= l, d.y /= l; float ms = Core.Player->moveSpeed > 1 ? Core.Player->moveSpeed : 1; sprite_setVelocity(&b->s, 0xf * ms * Weapon_PSpeed(b->weapon) * d.x, 0xf * ms * Weapon_PSpeed(b->weapon) * d.y); b->GroundFx.x = b->s.x; b->GroundFx.y = b->s.y; } static void B_Bora_DeSpawn(Bullet *b) { b->isCullable = 1; time_removeEvent(b->HitboxTimer); time_removeEvent(b->ExpireTimer); base_DeSpawn(b); } static const BulletVT B_Bora = { "items", "Water2.png", B_Bora_ctor, NULL, B_Bora_OnRecycle, NULL, B_Bora_Update, B_Bora_DeSpawn }; // --- B_Cross (0x16aac): la croce che torna indietro, tre fantasmi gialli --------------------- static void ghosts_init(Bullet *b, const char *frame, int n, int blendAdd) { // scene.add.image x n, poi ghosts.reverse() for (int i = 0; i < n; i++) { Sprite *g = &b->ghosts[n - 1 - i]; sprite_init(g, frame_get("vfx", frame), 0, 0); sprite_setScale(g, PixelScale); g->visible = 0; g->blendAdd = blendAdd; children_add(g); b->posHistory[i] = (Vector2){ b->s.x, b->s.y }; b->angleHistory[i] = b->s.angle; } } static void ghosts_hide(Bullet *b) { for (int i = 0; i < b->maxHistory; i++) b->ghosts[i].visible = 0; } static void ghosts_follow(Bullet *b) { // i fantasmi prendono la posizione storica e l'angolo attuale for (int i = 0; i < b->maxHistory; i++) { Vector2 h = b->posHistory[getHistoryIndex(b, i)]; Sprite *g = &b->ghosts[i]; g->angle = b->s.angle, g->x = h.x, g->y = h.y; g->scaleX = g->scaleY = b->s.scaleX; g->visible = 1; } } static void B_Cross_ctor(Bullet *b) { b->maxHistory = 3; b->accel = 1; b->AngleTween = tweens_add((TweenConfig){ .props = { { &b->s.angle, NULL, 0x168 } }, .nprops = 1, .duration = 0x1f4, .repeat = -1 }); b->AccelTween = tweens_add((TweenConfig){ .props = { { &b->accel, NULL, -2 } }, .nprops = 1, .duration = 0x3e8, .persist = 1 }); ghosts_init(b, "ProjectileCross2.png", 3, 0); for (int i = 0; i < 3; i++) b->ghosts[2 - i].tint = 0xffff66, b->ghosts[2 - i].alpha = 0.75f - 0.15f * i; } static void B_Cross_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); Weapon *w = b->weapon; body_setCircle(&b->s.body, 0xc, b->s.body.offset.x, b->s.body.offset.y); sprite_setScale(&b->s, PixelScale * Weapon_PArea(w)); b->accel = 1.5f + 0.1f * b->indexInWeapon; tween_restart(b->AccelTween); for (int i = 0; i < b->maxHistory; i++) b->posHistory[i] = (Vector2){ b->s.x, b->s.y }; b->s.x += (frand() - 0.5f) * b->indexInWeapon * 0x14 * Weapon_PArea(w); b->s.y += (frand() - 0.5f) * b->indexInWeapon * 0x14 * Weapon_PArea(w); Bullet_AimForNearestEnemy(b); b->velocity = b->s.body.velocity; Sound_PlaySound("Shot", 0.45f, 1, -0x64 * b->indexInWeapon, 0xc8, 0xa); b->s.depth = b->s.y - Core.Player->s.y + 2 * game_height; Bullet_activateBounce(b, B_velocity_Bounce); } static void B_Cross_Update(Bullet *b, float delta) { (void)delta; if (b->historyIndex < b->maxHistory - 1) b->historyIndex++; else b->historyIndex = 0; ghosts_follow(b); b->posHistory[b->historyIndex] = (Vector2){ b->s.x, b->s.y }; b->s.body.velocity = (Vector2){ b->velocity.x * b->accel, b->velocity.y * b->accel }; } static void B_ghosts_DeSpawn(Bullet *b) { base_DeSpawn(b); ghosts_hide(b); } static const BulletVT B_Cross = { "vfx", "ProjectileCross2.png", B_Cross_ctor, NULL, B_Cross_OnRecycle, NULL, B_Cross_Update, B_ghosts_DeSpawn }; // --- B_HeavenSword (0x8801): spada che rallenta, gira e torna indietro, otto fantasmi additivi --------- static void B_HeavenSword_cullable(void *ctx) { ((Bullet *)ctx)->isCullable = 1; } static void B_HeavenSword_GoBackwards(void *ctx) { Bullet *b = ctx; b->AngleTween = tweens_add((TweenConfig){ .props = { { &b->s.angle, NULL, b->s.angle + 0x168 } }, .nprops = 1, .duration = 0x3e8, .repeat = -1 }); b->BackwardTween = tweens_add((TweenConfig){ .props = { { &b->accel, NULL, -2 } }, .nprops = 1, .duration = 0x1f4 }); time_addEvent(0x2ee, 0, 0, B_HeavenSword_cullable, b); b->n_hit = 0; } static void B_HeavenSword_ctor(Bullet *b) { static const unsigned T[8] = { 0x20c0, 0x2020c0, 0x4020c0, 0x6020c0, 0x8020c0, 0xa020c0, 0xc020c0, 0xe020c0 }; b->maxHistory = 8; b->accel = 1; b->AngleTween = tweens_add((TweenConfig){ .props = { { &b->s.angle, NULL, 0x168 } }, .nprops = 1, .duration = 0x1f4, .repeat = -1 }); tween_pause(b->AngleTween); b->AccelTween = tweens_add((TweenConfig){ .props = { { &b->accel, NULL, 0 } }, .nprops = 1, .duration = 0x1f4, .onComplete = B_HeavenSword_GoBackwards, .ctx = b, .persist = 1 }); b->BackwardTween = tweens_add((TweenConfig){ .props = { { &b->accel, NULL, -2 } }, .nprops = 1, .duration = 0x1f4 }); // creato anche qui, come l'originale ghosts_init(b, "SwordBW.png", 8, 1); for (int i = 0; i < 8; i++) b->ghosts[7 - i].tint = T[i]; } static void B_HeavenSword_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); Weapon *w = b->weapon; body_setCircle(&b->s.body, 0xc, b->s.body.offset.x, b->s.body.offset.y); tween_pause(b->AngleTween); b->isCullable = 0; sprite_setScale(&b->s, PixelScale * Weapon_PArea(w)); b->accel = 2; tween_restart(b->AccelTween); for (int i = 0; i < b->maxHistory; i++) b->posHistory[i] = (Vector2){ b->s.x, b->s.y }, b->angleHistory[i] = b->s.angle; b->s.x += (frand() - 0.5f) * b->indexInWeapon * 0x14 * Weapon_PArea(w); b->s.y += (frand() - 0.5f) * b->indexInWeapon * 0x14 * Weapon_PArea(w); Bullet_AimForNearestEnemy(b); b->velocity = b->s.body.velocity; Sound_PlaySound("Shot", 0.5f, 1, -0x64 * b->indexInWeapon, 0xc8, 0xa); b->s.depth = b->s.y - Core.Player->s.y + 2 * game_height; Bullet_activateBounce(b, B_velocity_Bounce); } static void B_HeavenSword_Update(Bullet *b, float delta) { (void)delta; b->s.body.velocity = (Vector2){ b->velocity.x * b->accel, b->velocity.y * b->accel }; if (b->historyIndex < b->maxHistory - 1) b->historyIndex++; else b->historyIndex = 0; ghosts_follow(b); b->posHistory[b->historyIndex] = (Vector2){ b->s.x, b->s.y }; b->angleHistory[b->historyIndex] = b->s.angle; } static const BulletVT B_HeavenSword = { "vfx", "Sword.png", B_HeavenSword_ctor, NULL, B_HeavenSword_OnRecycle, NULL, B_HeavenSword_Update, B_ghosts_DeSpawn }; // --- B_Fireball (0xc80e) / B_Hellfire (0x4ae7): palle di fuoco verso un nemico a caso, a ventaglio ---------- static float Bullet_AngleFromTarget(Vector2 t) { // AngleFromTargetRadians: dal corpo del giocatore al bersaglio Vector2 b = Core.Player->s.body.position; return atan2f(t.y - b.y, t.x - b.x); } static Vector2 Bullet_NullTargetPoint(void) { // SetNullTarget: la direzione normalizzata usata come se fosse un punto del mondo Vector2 *d = &Core.Player->lastFacedDirection; if (d->x == 0 && d->y == 0) d->x = 1; float l = sqrtf(d->x * d->x + d->y * d->y); if (l > 0) d->x /= l, d->y /= l; // normalize() modifica il vettore del giocatore return *d; } static void Bullet_SetTargetFan(Bullet *b, Vector2 t, const float *fan, int n) { float a = Bullet_AngleFromTarget(t) + fan[b->indexInWeapon % n] * (PI / 180); b->s.body.velocity = velocityFromRotation(a, Bullet_TrueSpeed(b)); b->s.angle = atan2f(b->s.body.velocity.y - 0, b->s.body.velocity.x - 1) * (180 / PI); // Vector2.RIGHT sottratto } static const float FireballFan[19] = { 0, 5, -5, 10, -10, 15, -15, 20, -20, 25, -25, 30, -30, 35, -35, 40, -40, 45, -45 }; static const float HellfireFan[9] = { 0, 10, -10, 20, -20, 30, -30, 40, -40 }; static void B_Fireball_SetTarget(Bullet *b, Vector2 t) { Bullet_SetTargetFan(b, t, FireballFan, 19); } static void B_Fireball_SetNullTarget(Bullet *b) { B_Fireball_SetTarget(b, Bullet_NullTargetPoint()); } static void B_Hellfire_SetTarget(Bullet *b, Vector2 t) { Bullet_SetTargetFan(b, t, HellfireFan, 9); } static void B_Hellfire_SetNullTarget(Bullet *b) { B_Hellfire_SetTarget(b, Bullet_NullTargetPoint()); } static void B_Fire_scaleIn(Bullet *b) { // ScaleTween: 0 -> PixelScale * PArea in 200 ms if (b->hasScaleTween) tween_stop(b->scaleTween), tween_remove(b->scaleTween); sprite_setScale(&b->s, 0); b->scaleTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, PixelScale * Weapon_PArea(b->weapon) } }, .nprops = 1, .duration = 0xc8 }); b->hasScaleTween = 1; } static void B_Fireball_ctor(Bullet *b) { sprite_setScale(&b->s, 0); b->_speed = 0.8f; b->Pfx = particles_add(); particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "HitBoom1.png"), frame_get("vfx", "HitBoom2.png") }, .nframes = 2, .rotate = ERND(0, 0x168), .quantity = 1, .lifespan = EOP(0x12c), .scale = ERANGE(0.5f, 0), .on = 0 }); } static void B_Fireball_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); body_setCircle(&b->s.body, 0xc, b->s.body.offset.x, b->s.body.offset.y); b->_speed = 0.8f; b->s.y -= 0x10; B_Fire_scaleIn(b); } static void B_Fireball_OnHasHitAnObject(Bullet *b, void *o, int isDead) { (void)o; if (isDead) return; if (Arcanas_has(19)) Weapon_SpawnExplosionAt(b->weapon, b->s.x, b->s.y, 1); // Heart of Fire if (b->bounces > 0) { b->bounces--; Bullet_AimForRandomEnemy(b); b->n_hit = 0; return; } b->penetrating--; if (b->penetrating <= 0) Bullet_DeSpawn(b); } static void B_Fire_Update(Bullet *b, float delta) { (void)delta; manager_emitParticleAt(b->Pfx, b->s.x, b->s.y); } static const BulletVT B_Fireball = { "vfx", "ProjectileFireball2.png", B_Fireball_ctor, NULL, B_Fireball_OnRecycle, B_Fireball_OnHasHitAnObject, B_Fire_Update, NULL, B_Fireball_SetTarget, B_Fireball_SetNullTarget }; static void B_Hellfire_ctor(Bullet *b) { sprite_setScale(&b->s, 0); b->Pfx = particles_add(); particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "ProjectileFireball.png"), frame_get("vfx", "HitBoom2.png") }, .nframes = 2, .rotate = ERND(0, 0x168), .quantity = 1, .lifespan = EOP(0x12c), .scale = ERANGE(1.25f, 0), .on = 0 }); } static void B_Hellfire_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); body_setCircle(&b->s.body, 0x10, b->s.body.offset.x, b->s.body.offset.y); b->s.depth = b->s.y - Core.Player->s.y + game_height; b->Pfx->s.depth = b->s.depth - 1; B_Fire_scaleIn(b); Bullet_activateBounce(b, B_Hellfire_Bounce); } static const BulletVT B_Hellfire = { "vfx", "ProjectileHellfireLarge.png", B_Hellfire_ctor, NULL, B_Hellfire_OnRecycle, NULL, // attraversa i nemici B_Fire_Update, NULL, B_Hellfire_SetTarget, B_Hellfire_SetNullTarget }; // --- B_Garlic (0x6fd9) / B_Vortex (0x593): un cerchio invisibile sul giocatore che dura un intervallo ------------- static void B_Garlic_expire(void *ctx) { Bullet *b = ctx; time_removeEvent(b->ExpireTimer); Bullet_DeSpawn(b); } static void B_Garlic_ctor(Bullet *b) { b->radius = 0x10; b->s.x = Core.Player->s.x, b->s.y = Core.Player->s.y; } static void B_Garlic_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); body_setCircle(&b->s.body, b->radius, b->s.body.offset.x, b->s.body.offset.y); sprite_setScale(&b->s, 2 * PixelScale * Weapon_PArea(b->weapon)); b->s.visible = 0; time_removeEvent(b->ExpireTimer); b->ExpireTimer = time_addEvent(Weapon_PInterval(b->weapon), 0, 0, B_Garlic_expire, b); // 'G Expire' } static void B_Garlic_Update(Bullet *b, float delta) { (void)delta; b->s.x = Core.Player->s.x, b->s.y = Core.Player->s.y; sprite_setScale(&b->s, 2 * PixelScale * Weapon_PArea(b->weapon)); } static void B_Garlic_OnHasHitAnObject(Bullet *b, void *o, int isDead) { // indebolisce: piu' rinculo, meno resistenza al gelo (void)b; if (isDead || !(((Sprite *)o)->groups & Core.Enemies.bit)) return; // Destructible: in JS i campi sono undefined e non cambia nulla; qui si scriverebbe nella sua struct Enemy *e = o; if (e->res_Debuffs >= 1) return; if (e->knockback < e->maxKnockback) e->knockback += 0.3f; if (e->res_Freeze > 0) e->res_Freeze -= 0.1f; } static const BulletVT B_Garlic = { "vfx", "Rings3.png", B_Garlic_ctor, NULL, B_Garlic_OnRecycle, B_Garlic_OnHasHitAnObject, B_Garlic_Update, NULL }; // --- B_Diamond (0xd459): il diamante che rimbalza sui bordi dello schermo e sui muri, con la scia ---------- static void Diamond_trailDraw(Sprite *s) { // Graphics: ogni passata usa l'ultimo lineStyle (colore e alpha) per tutti i segmenti Bullet *b = s->owner; if (b->npos < 2 || b->trailAlpha <= 0) return; float w = 2 * PixelScale * Weapon_PArea(b->weapon), ox = b->trail.x - camera_scrollX, oy = b->trail.y - camera_scrollY; BeginBlendMode(BLEND_ADDITIVE); float a = fminf(1, 1.0f / ((b->npos - 1) / 20.0f)) * b->trailAlpha; for (int i = 1; i < b->npos; i++) DrawLineEx((Vector2){ ox + b->positions[i - 1].x, oy + b->positions[i - 1].y }, (Vector2){ ox + b->positions[i].x, oy + b->positions[i].y }, w, hexc(b->color, a)); int last = 0; for (int i = 1; i < 0x32 && i < b->npos; i++) last = i; if (last) { a = fminf(1, 0.8f / (last / 20.0f)) * b->trailAlpha; for (int i = 1; i <= last; i++) DrawLineEx((Vector2){ ox + b->positions[i - 1].x, oy + b->positions[i - 1].y }, (Vector2){ ox + b->positions[i].x, oy + b->positions[i].y }, 0.5f * w, hexc(0xffffff, a)); } EndBlendMode(); } static void B_Diamond_Bounce(void *ctx) { ((Bullet *)ctx)->n_hit = 0; } // 'worldbounds' static void B_Diamond_ctor(Bullet *b) { b->color = 0xff0000; sprite_init(&b->trail, NULL, 0, 0); b->trail.owner = b; b->trail.draw = Diamond_trailDraw; children_add(&b->trail); } static void B_Diamond_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void B_Diamond_FadeOut(void *ctx) { // ExpireTimer: alpha di scia e diamante a 0 in 100 ms Bullet *b = ctx; time_removeEvent(b->ExpireTimer); if (b->weapon->explodeOnExpire) Weapon_SpawnExplosionAt(b->weapon, b->s.x, b->s.y, 0); tweens_add((TweenConfig){ .props = { { &b->trailAlpha, NULL, 0 }, { &b->s.alpha, NULL, 0 } }, .nprops = 2, .duration = 0x64, .onComplete = B_Diamond_despawn, .ctx = b }); } static void B_Diamond_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); b->enemiesHit = 0; body_setCircle(&b->s.body, 8, b->s.body.offset.x, b->s.body.offset.y); b->_speed = 1.1f; sprite_setScale(&b->s, PixelScale * Weapon_PArea(b->weapon)); time_removeEvent(b->ExpireTimer); b->s.body.collideWorldBounds = 1, b->s.body.hasWorldBounce = 1, b->s.body.worldBounce = (Vector2){ 1, 1 }; b->s.body.customBounds = &Core.Player->WorldBoxCollider; b->s.body.onWorldBounds = B_Diamond_Bounce, b->s.body.onWorldBoundsCtx = b; b->trail.x = b->s.x - Core.Player->s.x, b->trail.y = b->s.y - Core.Player->s.y; b->color = (unsigned)(0xffffff * frand()); b->trailAlpha = 1, b->s.alpha = 1; b->npos = 0; // clearPositions b->ExpireTimer = time_addEvent(Weapon_PDuration(b->weapon), 0, 0, B_Diamond_FadeOut, b); // 'DI Expire' Sound_PlaySound("MagicMissile", 0.15f, 1, -0x64 * b->indexInWeapon, 0xc8, 0xa); } static void B_Diamond_OnHasHitWall(Bullet *b, Tile *t) { b->save_vel_x *= t && (t->faceRight || t->faceLeft) ? -1 : 1; b->save_vel_y *= t && (t->faceTop || t->faceBottom) ? -1 : 1; sprite_setVelocity(&b->s, b->save_vel_x, b->save_vel_y); b->n_hit = 0; } static const float DiamondFan[9] = { 0, 10, -10, 20, -20, 30, -30, 40, -40 }; static void B_Diamond_SetTarget(Bullet *b, Vector2 t) { Bullet_SetTargetFan(b, t, DiamondFan, 9); } static void B_Diamond_SetNullTarget(Bullet *b) { B_Diamond_SetTarget(b, Bullet_NullTargetPoint()); } static void B_Diamond_trailUpdate(Bullet *b) { // attivo: positions.unshift, al massimo 100 memmove(&b->positions[1], &b->positions[0], 99 * sizeof(Vector2)); b->positions[0] = (Vector2){ b->s.x, b->s.y }; if (b->npos < 100) b->npos++; } static void B_Diamond_Update(Bullet *b, float delta) { b->trail.depth = b->s.y - Core.Player->s.y + 0.5f * game_height; int n = (int)ceilf(delta / 0x10); for (int i = 0; i < n; i++) B_Diamond_trailUpdate(b); b->save_vel_x = b->s.body.velocity.x == 0 ? b->save_vel_x : b->s.body.velocity.x; b->save_vel_y = b->s.body.velocity.y == 0 ? b->save_vel_y : b->s.body.velocity.y; } static void B_Diamond_OnHasHitAnObject(Bullet *b, void *o, int isDead) { if (isDead) return; if (Arcanas_has(14)) Bullet_TryFreeze(b, o); b->enemiesHit++; } static void B_Diamond_DeSpawn(Bullet *b) { b->s.body.collideWorldBounds = 0; base_DeSpawn(b); } // la scia resta, ad alpha 0 static const BulletVT B_Diamond = { "items", "Diamond2.png", B_Diamond_ctor, NULL, B_Diamond_OnRecycle, B_Diamond_OnHasHitAnObject, B_Diamond_Update, B_Diamond_DeSpawn, B_Diamond_SetTarget, B_Diamond_SetNullTarget, B_Diamond_OnHasHitWall }; // --- B_SilverWind (0xbd7c) / B_SilverWind2 (0x123a1): la foglia che traccia un'orbita attorno al giocatore -------- #define WIND_FADE 0x2ee #define WIND_LINES 600 // il pool dell'originale cresce a richiesta; 4 linee a fotogramma per 750 ms ne usano circa 180 struct WindLine { Vector2 a, b; unsigned color; float alpha, born; }; static Animation WindSpin; // anims.create('spin'): leaf0000..leaf0019, 30 fps static const BulletVT B_SilverWind2; static void Wind_trailDraw(Sprite *s) { Bullet *b = s->owner; if (!b->linesN || b->trailAlpha <= 0) return; float ox = b->trail.x - camera_scrollX, oy = b->trail.y - camera_scrollY; BeginBlendMode(BLEND_ADDITIVE); for (int i = 0; i < b->linesN; i++) { const struct WindLine *l = &b->lines[(b->linesHead - 1 - i + 2 * WIND_LINES) % WIND_LINES]; float k = 1 - (b->linesClock - l->born) / WIND_FADE; if (k <= 0) { b->linesN = i; break; } // dalla piu' nuova: le successive sono piu' vecchie DrawLineEx((Vector2){ ox + l->a.x, oy + l->a.y }, (Vector2){ ox + l->b.x, oy + l->b.y }, 1, hexc(l->color, l->alpha * k * b->trailAlpha)); } EndBlendMode(); } static void Wind_setLine(Bullet *b, Vector2 from, Vector2 to, unsigned color, float alpha) { b->lines[b->linesHead] = (struct WindLine){ from, to, color, alpha, b->linesClock }; b->linesHead = (b->linesHead + 1) % WIND_LINES; if (b->linesN < WIND_LINES) b->linesN++; } static void B_SilverWind_ctor(Bullet *b) { int evo = b->vt == &B_SilverWind2; if (!WindSpin.n) { for (int i = 0; i < 0x14; i++) WindSpin.frames[WindSpin.n++] = frame_get("vfx", TextFormat("leaf%04d.png", i)); WindSpin.frameRate = 0x1e, WindSpin.msPerFrame = 1000.0f / 0x1e, WindSpin.repeat = -1; } b->s.blendAdd = 1; b->lines = malloc(WIND_LINES * sizeof(*b->lines)); sprite_init(&b->trail, NULL, 0, 0); b->trail.owner = b; b->trail.draw = Wind_trailDraw; children_add(&b->trail); b->Pfx = particles_add(); EmitterConfig c = { .speed = ERND(0xf, 0x1e), .quantity = 1, .lifespan = EOP(0x3e8), .alpha = ERANGE(1, 0), .on = 0 }; c.frames[c.nframes++] = frame_get("vfx", "PfxHoly1.png"); c.frames[c.nframes++] = frame_get("vfx", "PfxHoly2.png"); if (evo) c.frames[c.nframes++] = frame_get("vfx", "PfxGreen.png"); b->PfxEmitter = particles_createEmitter(b->Pfx, c); } static void B_SilverWind_clearHits(void *ctx) { ((Bullet *)ctx)->n_hit = 0; } // 'HW Hitbox' static void B_SilverWind_OnRecycle(Bullet *b) { static const unsigned colors[] = { 0xeeeeee, 0xffff, 0xff }, colors2[] = { 0x88ff88, 0xff00, 0xffff00, 0xff88 }; int evo = b->vt == &B_SilverWind2; Bullet_OnRecycle(b); b->hasPrevPos = 0; body_setCircle(&b->s.body, 4, b->s.body.offset.x, b->s.body.offset.y); b->isCullable = 0; b->_speed = 1.1f; sprite_setScale(&b->s, PixelScale * Weapon_PArea(b->weapon)); time_removeEvent(b->ExpireTimer); b->IsInStartingPosition = 1; b->trail.x = b->s.x - Core.Player->s.x, b->trail.y = b->s.y - Core.Player->s.y; b->color = evo ? colors2[b->indexInWeapon % 4] : colors[b->indexInWeapon % 3]; b->s.tint = evo ? b->color : 0xffffff; // l'originale, senza evoluzione: tints[indice] oltre la fine = setTint(undefined) = bianco b->linesN = 0; // clearPositions (positions non si usa) + recycle delle linee anims_play(&b->s, &WindSpin, 0); float area = Weapon_PArea(b->weapon); if (b->hasTween) tween_stop(b->tween); b->trailAlpha = 1, b->s.alpha = 0; b->tween = tweens_add((TweenConfig){ .props = { { &b->s.alpha, NULL, area >= 2 ? 1 / area : 1 } }, .nprops = 1, .duration = 0xc8 }); b->hasTween = 1; time_removeEvent(b->HitboxTimer); b->HitboxTimer = time_addEvent(b->weapon->hitBoxDelay, 1, 0, B_SilverWind_clearHits, b); b->ExpireTimer = time_addEvent(Weapon_PDuration(b->weapon), 0, 0, B_Diamond_FadeOut, b); // stessa FadeOut del diamante b->canUpdateTrail = 0; Sound_PlaySound("Magic2", 0.15f, 1, -0x64 * b->indexInWeapon, 0x64, 0xa); } static void B_SilverWind_DeSpawn(Bullet *b) { base_DeSpawn(b); time_removeEvent(b->ExpireTimer); b->IsInStartingPosition = 0; anims_stop(&b->s); b->linesN = 0; } static void B_SilverWind_Update(Bullet *b, float delta) { manager_emitParticleAt(b->Pfx, b->s.x, b->s.y); b->linesClock += delta; if (b->canUpdateTrail) { int n = (int)ceilf(delta / 0x10); Vector2 cur = { b->s.x, b->s.y }; for (int i = 0; i < n; i++) { // trailUpdate if (!b->hasPrevPos) b->prevPos = cur, b->hasPrevPos = 1; Wind_setLine(b, b->prevPos, cur, b->color, 0.5f); Wind_setLine(b, b->prevPos, cur, 0xffffff, 0.25f); b->prevPos = cur; } } if (b->IsInStartingPosition) { Weapon *w = b->weapon; b->fnTime += delta * Weapon_PSpeed(w); // mai azzerato (sic): ogni giro riparte da dove era float t = 0.001f * b->fnTime, t2 = 3.375f * t, area = Weapon_PArea(w), rx = game_width * fminf(0.125f * area, 0.4f), rx2 = rx / 1.75f, ry = 5 * fminf(6, area) * 7; b->s.x = Core.Player->s.x + rx * sinf(t) + rx2 * sinf(t2); b->s.y = Core.Player->s.y + ry * cosf(t) + 4 * cosf(t2); } b->canUpdateTrail = 1; } static const BulletVT B_SilverWind = { "vfx", "leaf0001.png", B_SilverWind_ctor, NULL, B_SilverWind_OnRecycle, NULL, B_SilverWind_Update, B_SilverWind_DeSpawn, B_Diamond_SetTarget, B_Diamond_SetNullTarget }; static void B_SilverWind2_OnHasHitAnObject(Bullet *b, void *o, int isDead) { (void)b; if (isDead || !(((Sprite *)o)->groups & Core.Enemies.bit)) return; // Destructible: in JS i campi sono undefined Enemy *e = o; if (e->res_Debuffs >= 2) return; if (e->damageWeakness < 0x64) e->damageWeakness += 0.02f; // maxDamageWeakness } static const BulletVT B_SilverWind2 = { "vfx", "leaf0001.png", B_SilverWind_ctor, NULL, B_SilverWind_OnRecycle, B_SilverWind2_OnHasHitAnObject, B_SilverWind_Update, B_SilverWind_DeSpawn, B_Diamond_SetTarget, B_Diamond_SetNullTarget }; // --- B_MirageRobe (0x5246) / B_MirageRobe2 (0x1404): la copia del giocatore che congela chi la tocca --------------- static void B_Mirage_despawn(void *ctx) { Bullet *b = ctx; if (b->s.active) Bullet_DeSpawn(b); } // la copia puo' essere gia' sparita per penetrating static void B_Mirage_FadeOut(Bullet *b) { if (!b->s.active) return; b->s.body.enable = 0; if (b->hasFadeOut) tween_stop(b->fadeOutTween); b->fadeOutTween = tweens_add((TweenConfig){ .props = { { &b->s.alpha, NULL, 0 } }, .nprops = 1, .duration = 0xc8, .onComplete = B_Mirage_despawn, .ctx = b }); b->hasFadeOut = 1; } static void B_Mirage_expire(void *ctx) { Bullet *b = ctx; time_removeEvent(b->ExpireTimer); B_Mirage_FadeOut(b); } static void B_MirageRobe_ctor(Bullet *b) { sprite_setScale(&b->s, 1); b->s.originX = 0.5f, b->s.originY = 1; b->s.tint = 0x7070ff; // semplificazione: setTint a quattro angoli (0xe0e0ff, 0xff, 0xe0e0ff, 0xff) reso col colore medio } static void B_MirageRobe_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); body_setCircle(&b->s.body, 0x10, b->s.body.offset.x, b->s.body.offset.y); if (b->hasFadeOut) tween_stop(b->fadeOutTween); sprite_setScale(&b->s, fminf(Weapon_PArea(b->weapon), 1)); b->s.frame = Core.Player->s.frame; // setTexture sul fotogramma del giocatore b->s.flipX = Core.Player->s.flipX; b->s.alpha = 0.65f; time_removeEvent(b->ExpireTimer); b->ExpireTimer = time_addEvent(Weapon_PDuration(b->weapon), 0, 0, B_Mirage_expire, b); // 'Mirage Expire' b->mirageHits = b->weapon->amount; } static void B_MirageRobe_OnHasHitAnObject(Bullet *b, void *o, int isDead) { if (isDead) return; if (--b->mirageHits <= 0) B_Mirage_FadeOut(b); if (((Sprite *)o)->groups & Core.Enemies.bit) Enemy_Freeze(o, Weapon_PDuration(b->weapon), 1); // _0x.Freeze &&: i Destructible non ce l'hanno if (Arcanas_has(12)) Arcanas_TriggerCold(((Sprite *)o)->x, ((Sprite *)o)->y); // Out of Time } static const BulletVT B_MirageRobe = { "vfx", "Rings3.png", B_MirageRobe_ctor, NULL, B_MirageRobe_OnRecycle, B_MirageRobe_OnHasHitAnObject }; static void B_MirageRobe2_ctor(Bullet *b) { static const unsigned T[4] = { 0x4444a1, 0x7070ff, 0xef70ff, 0xb470ff }; // i quattro angoli di tints reso col colore medio B_MirageRobe_ctor(b); b->_speed = 0.3f; anims_play(&b->s, &Core.Player->walk, 0); // anims.create('walk') coi dati del personaggio scelto: e' l'animazione del giocatore b->s.tint = T[b->indexInWeapon % 4]; } static void B_MirageRobe2_OnRecycle(Bullet *b) { B_MirageRobe_OnRecycle(b); for (int i = 0; i < Core.Enemies.n; i++) { // i nemici inseguono la copia, e continuano anche quando e' sparita (sic) Enemy *e = (Enemy *)Core.Enemies.items[i]; if (e->target == &Core.Player->s) e->target = &b->s; } Vector2 *d = &Core.Player->lastFacedDirection; // ApplyPlayerFacingVelocity(false) col TrueSpeed di questa classe float l = sqrtf(d->x * d->x + d->y * d->y), v = Weapon_PSpeed(b->weapon) * PlayerPxSpeed * Core.Player->moveSpeed * b->_speed; if (l > 0) d->x /= l, d->y /= l; if (d->x == 0 && d->y == 0) d->x = 1; sprite_setVelocity(&b->s, v * d->x, v * d->y); } static void B_MirageRobe2_OnHasHitAnObject(Bullet *b, void *o, int isDead) { (void)o; if (!isDead && --b->penetrating <= 0) Bullet_DeSpawn(b); } static const BulletVT B_MirageRobe2 = { "vfx", "Rings3.png", B_MirageRobe2_ctor, NULL, B_MirageRobe2_OnRecycle, B_MirageRobe2_OnHasHitAnObject }; // --- B_Bubble (0x359f) / B_Bubble2 (0x10235): la bolla che va verso il nemico piu' vicino e si ferma dove capita ----- static const BulletVT B_Bubble2; static void Bullet_SetForNearestEnemy(Bullet *b, Vector2 *out) { Sprite *t = physics_closest(&Core.Player->s, &Core.Enemies); Vector2 d; if (t) { d = (Vector2){ t->body.position.x - Core.Player->s.x, t->body.position.y - Core.Player->s.y }; float l = sqrtf(d.x * d.x + d.y * d.y); if (l > 0) d.x /= l, d.y /= l; } else { Vector2 *f = &Core.Player->lastFacedDirection; float l = sqrtf(f->x * f->x + f->y * f->y); if (l > 0) f->x /= l, f->y /= l; if (f->x == 0 && f->y == 0) f->x = 1; d = *f; } *out = (Vector2){ Bullet_TrueSpeed(b) * d.x, Bullet_TrueSpeed(b) * d.y }; } static void B_Bubble_clearHits(void *ctx) { ((Bullet *)ctx)->n_hit = 0; } static void B_Bubble_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void B_Bubble_FadeOut(void *ctx) { Bullet *b = ctx; if (b->hasFadeOut) tween_stop(b->fadeOutTween); b->fadeOutTween = tweens_add((TweenConfig){ .props = { { &b->s.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x1f4, .onComplete = B_Bubble_despawn, .ctx = b }); b->hasFadeOut = 1; } static void B_Bubble_ctor(Bullet *b) { b->s.visible = 0, b->SpeedTween = (TweenRef){ -1, 0 }; } static void B_Bubble_OnRecycle(Bullet *b) { static const char *const F[] = { "HitBlue1.png", "HitBlue2.png", "HitCloud1.png", "bubble.png", "bubble.png", "bubble.png" }, *const F2[] = { "HitWhite1.png", "HitWhite2.png", "HitCloud1.png", "bubble.png", "bubble.png", "bubble.png" }; int evo = b->vt == &B_Bubble2; Bullet_OnRecycle(b); if (b->hasFadeOut) tween_stop(b->fadeOutTween); body_setCircle(&b->s.body, 0xa, 1, 1); b->s.body.enable = 1; b->n_hit = 0; b->s.visible = 1; sprite_setScale(&b->s, 0); b->isCullable = 1; b->save_vel_x = b->save_vel_y = 1; b->s.frame = frame_get("vfx", (evo ? F2 : F)[(int)floorf(frand() * 6)]); // SetColor, chiamato da FireOneBullet if (evo) { time_removeEvent(b->HitboxTimer); b->HitboxTimer = time_addEvent(b->weapon->hitBoxDelay, 1, 0, B_Bubble_clearHits, b); b->s.tint = ((unsigned)(0x80 + 0x80 * frand()) << 16) | ((unsigned)(0x80 + 0x80 * frand()) << 8) | (unsigned)(0x80 + 0x80 * frand()); // semplificazione: 20 colori a caso per proiettile, qui uno a ogni riuso b->s.depth = -game_height; } Bullet_SetForNearestEnemy(b, &b->aimVec); float sp = Weapon_PSpeed(b->weapon), dur = Weapon_PDuration(b->weapon); sprite_setVelocity(&b->s, b->aimVec.x * sp, b->aimVec.y * sp); if (!evo) Sound_PlaySound("Bubbles", 0.4f, 1, 0x32 * b->indexInWeapon, 0x64, 0xc); tween_stop(b->SpeedTween); b->bombDeceleration = 1; b->SpeedTween = tweens_add((TweenConfig){ .props = { { &b->bombDeceleration, NULL, 0 } }, .nprops = 1, .delay = 0.25f * dur, .duration = 0.75f * dur, .onComplete = B_Bubble_FadeOut, .ctx = b }); if (b->hasTween) tween_stop(b->tween); b->s.alpha = 0.65f; float area = Weapon_PArea(b->weapon); b->tween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, area } }, .nprops = 1, .duration = 0xfa }); b->hasTween = 1; if (evo) { b->s.body.collideWorldBounds = 1, b->s.body.hasWorldBounce = 1, b->s.body.worldBounce = (Vector2){ 0.9f, 0.9f }; b->s.body.customBounds = &Core.Player->WorldBoxCollider; } } static void B_Bubble_Update(Bullet *b, float delta) { (void)delta; sprite_setVelocity(&b->s, b->aimVec.x * b->save_vel_x, b->aimVec.y * b->save_vel_y); if (b->vt != &B_Bubble2) b->s.depth = -game_height; } static void B_Bubble_DeSpawn(Bullet *b) { tween_stop(b->SpeedTween); if (b->hasTween) tween_stop(b->tween); if (b->hasFadeOut) tween_stop(b->fadeOutTween); sprite_setScale(&b->s, 0); b->s.visible = 0; b->s.body.enable = 0; if (b->vt == &B_Bubble2) time_removeEvent(b->HitboxTimer); base_DeSpawn(b); } static void B_Bubble_OnHasHitWall(Bullet *b, Tile *t) { (void)t; b->save_vel_x = b->save_vel_y = 0; } // decelerate static const BulletVT B_Bubble = { "vfx", "circle8.png", B_Bubble_ctor, NULL, B_Bubble_OnRecycle, NULL, B_Bubble_Update, B_Bubble_DeSpawn, NULL, NULL, B_Bubble_OnHasHitWall }; static const BulletVT B_Bubble2 = { "vfx", "circle8.png", B_Bubble_ctor, NULL, B_Bubble_OnRecycle, NULL, B_Bubble_Update, B_Bubble_DeSpawn, NULL, NULL, B_Bubble_OnHasHitWall }; // --- B_SummonNight (0x14b69): zanna dall'alto / B_SummonNight2 (0x87c2): zanna dal basso, a meta' fra quelle rosse -------- static const BulletVT B_SummonNight2; static void B_Night_ctor(Bullet *b) { static const unsigned TINT[3] = { 0xff0000, 0xff00ff, 0xff }; int up = b->vt == &B_SummonNight2; sprite_init(&b->fang, frame_get("vfx", up ? "fangNight2.png" : "fangNight.png"), b->s.x, b->s.y); b->fang.originX = 0.5f, b->fang.originY = up ? 1 : 0; sprite_setScale(&b->fang, 0); b->fang.alpha = 0, b->fang.depth = game_height; children_add(&b->fang); EmitterConfig frag = { .speed = ERND(0x64, 0x12c), .angle = up ? ERND(0xd2, 0x14a) : ERND(0x1e, 0x96), .gravityY = up ? -0x190 : 0x190, .rotate = ERANGE(0, 0x168), .quantity = 0x10, .lifespan = ERND(0xfa, 0x2ee), .alpha = ERANGE(0.8f, 0.6f), .scale = ERANGE(4, 0), .tints = { 0, 0, 0x44 }, .ntints = 3, .on = 0 }; for (int i = 0; i < 4; i++) frag.frames[frag.nframes++] = frame_get("vfx", TextFormat("glass%04d.png", i)); b->PfxExplosion = particles_add(); particles_createEmitter(b->PfxExplosion, frag); b->Pfx = particles_add(); b->PfxEmitter1 = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "bulletNightA.png") }, .nframes = 1, .speed = ERND(0xf, 0x1e), .quantity = 1, .lifespan = EOP(0x12c), .alpha = ERANGE(1, 0), .tints = { TINT[0], TINT[1], TINT[2] }, .ntints = 3, .hasZoneRect = 1, .on = 0 }); b->PfxBack = particles_add(); b->PfxEmitter2 = particles_createEmitter(b->PfxBack, (EmitterConfig){ .frames = { frame_get("vfx", "bulletNightB.png") }, .nframes = 1, .speed = ERND(0xf, 0x1e), .quantity = 2, .lifespan = EOP(0x12c), .scale = ERANGE(1, 0), .tints = { TINT[0], TINT[1], TINT[2] }, .ntints = 3, .hasZoneRect = 1, .on = 0 }); b->PfxExplosion->s.depth = game_height + 2, b->Pfx->s.depth = game_height + 1, b->PfxBack->s.depth = -game_height; b->ScaleTween = (TweenRef){ -1, 0 }; } static void B_Night_clearHits(void *ctx) { ((Bullet *)ctx)->n_hit = 0; } static void B_Night_expire(void *ctx) { Bullet_DeSpawn(ctx); } static void B_Night_frontBack(void *ctx) { Bullet *b = ctx; b->Pfx->s.depth = 1 - game_height; } static void B_Night_fangOut(void *ctx) { Bullet *b = ctx; if (b->hasFangTweenOut) tween_stop(b->fangTweenOut); b->fangTweenOut = tweens_add((TweenConfig){ .props = { { &b->fang.scaleX, &b->fang.scaleY, 0 } }, .nprops = 1, .delay = 0xc8, .duration = 0xc8, .ease = Ease_SineInOut, .onComplete = B_Night_frontBack, .ctx = b }); b->hasFangTweenOut = 1; } static void B_Night_OnRecycle(Bullet *b) { Weapon *w = b->weapon; int up = b->vt == &B_SummonNight2; Bullet_OnRecycle(b); b->s.visible = 0; b->s.originX = 0.5f, b->s.originY = up ? 1 : 0; sprite_setScale(&b->s, 0); b->s.body.enable = 1; b->isCullable = 0; manager_emitParticleAt(b->PfxExplosion, b->s.x, b->s.y + (up ? 0x18 : -0x18)); time_removeEvent(b->HitboxTimer), time_removeEvent(b->ExpireTimer); b->HitboxTimer = time_addEvent(w->hitBoxDelay, 1, 0, B_Night_clearHits, b); b->ExpireTimer = time_addEvent(Weapon_PDuration(w), 1, 0, B_Night_expire, b); float area = Weapon_PArea(w), sx = 0x10 * area; b->reach = 0.5f; if (area - 1.2f > 0) b->reach += fminf(0.5f, area - 1.2f); b->reach *= 0x1c8; // GAMEPLAY_PIXEL_HEIGHT tween_stop(b->ScaleTween); b->ScaleTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, NULL, sx }, { &b->s.scaleY, NULL, b->reach } }, .nprops = 2, .duration = 0x1f4 }); b->Pfx->s.depth = game_height + 1; if (b->hasFangTweenOut) tween_stop(b->fangTweenOut); if (b->hasFangTween) tween_stop(b->fangTween); b->fang.x = b->s.x, b->fang.y = b->s.y + (up ? 0x80 : -0x80), b->fang.alpha = 0; // onStart sprite_setScale(&b->fang, 0); b->fangTween = tweens_add((TweenConfig){ .props = { { &b->fang.alpha, NULL, 0.65f }, { &b->fang.scaleX, NULL, area }, { &b->fang.scaleY, NULL, b->reach / 0x43 } }, .nprops = 3, .duration = 0xc8, .ease = Ease_SineInOut, .onComplete = B_Night_fangOut, .ctx = b }); tweens_add((TweenConfig){ .props = { { &b->fang.y, NULL, b->s.y } }, .nprops = 1, .duration = 0xc8, .ease = Ease_SineInOut }); // un TweenConfig ha tre proprieta' b->hasFangTween = 1; float half = 0.5f * sx; b->PfxEmitter1->c.zoneRect = b->PfxEmitter2->c.zoneRect = (Rectangle){ -0.5f * half, 0, half, b->reach }; } static void B_Night_DeSpawn(Bullet *b) { b->isCullable = 1; b->s.body.enable = 0; time_removeEvent(b->HitboxTimer), time_removeEvent(b->ExpireTimer); base_DeSpawn(b); } static void B_Night_Update(Bullet *b, float delta) { (void)delta; int up = b->vt == &B_SummonNight2; b->PfxEmitter1->c.zoneRect.height = b->PfxEmitter2->c.zoneRect.height = b->s.scaleY; // explosionRect if (up) b->PfxEmitter1->c.zoneRect.y = b->PfxEmitter2->c.zoneRect.y = -b->s.scaleY; manager_emitParticleAt(b->Pfx, b->s.x, b->s.y); manager_emitParticleAt(b->PfxBack, b->s.x, b->s.y); } static const BulletVT B_SummonNight = { "vfx", "WhiteDot.png", B_Night_ctor, NULL, B_Night_OnRecycle, NULL, B_Night_Update, B_Night_DeSpawn }; static const BulletVT B_SummonNight2 = { "vfx", "WhiteDot.png", B_Night_ctor, NULL, B_Night_OnRecycle, NULL, B_Night_Update, B_Night_DeSpawn }; // --- B_NightSword (0x2497): il fendente sul bersaglio; la sesta spada (canFinish) e' doppia e sparge particelle --------- static const float NightFireX[6] = { -0x10, 0x10, 0, 0x10, -0x10, 0 }; static void B_NightSword_ctor(Bullet *b) { b->Pfx = particles_add(); b->PfxEmitter = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "WhiteDot.png") }, .nframes = 1, .quantity = 0xa, .lifespan = EOP(0x1f4), .alpha = ERANGE(1, 0), .angle = ERND(0xe1, 0x13b), .blendAdd = 1, .speed = ERND(0x4b, 0x7d), .scale = ERANGE(2 * PixelScale, 0), .gravityY = -0x258, .tint = 0xff0000, .tintEnd = 0xff00ff, .hasTintEnd = 1, .hasZoneRect = 1, .zoneRect = { -0x10, -0x80, 0x20, 0x100 }, .flowEveryFrame = 1, .on = 0 }); } static void B_NightSword_Init(Bullet *b, float x, float y) { Bullet_Init(b, x, y); sprite_setScale(&b->s, 0); b->s.blendAdd = 1; b->s.depth = 0xf0; } static void B_NightSword_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); emitter_stop(b->PfxEmitter); } static void B_NightSword_DeSpawn(Bullet *b) { base_DeSpawn(b); emitter_stop(b->PfxEmitter); } static void B_NightSword_SetNullTarget(Bullet *b) { Bullet_DeSpawn(b); } static void B_NightSword_pfxStop(void *ctx) { emitter_stop(((Bullet *)ctx)->PfxEmitter); } static void B_NightSword_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void B_NightSword_SetTarget(Bullet *b, Vector2 t) { Weapon *w = b->weapon; int i = b->indexInWeapon % 6, fin = w->canFinish && i == 5; if (i < 5) Sound_PlaySound("Crystal6", 0.4f * w->volume, 1, 0xc8 * i, 0x64, 5); else if (fin) Sound_PlaySound("Crystal8", w->volume, 1, 0x4b0, 0x12c, 1); b->s.x = t.x + NightFireX[i], b->s.y = t.y; b->s.frame = frame_get("vfx", fin ? "nightSwordCrit.png" : "nightSword.png"); b->s.alpha = fin ? 0.5f : 0.75f; b->s.originX = 0.5f, b->s.originY = fin ? 1 : 0.5f; b->s.angle = w->fireAngles[i]; b->s.depth = game_height; if (b->hasTween) tween_stop(b->tween); b->s.scaleX = 0.5f * (fin ? 2 : 1), b->s.scaleY = Weapon_PArea(w) * (fin ? 2 : 1); // onStart if (fin) b->PfxEmitter->x = b->s.x, b->PfxEmitter->y = b->s.y, emitter_start(b->PfxEmitter); b->tween = tweens_add((TweenConfig){ .props = { { &b->s.scaleY, NULL, 0 }, { &b->s.scaleX, NULL, 0.5f } }, .nprops = 2, .duration = fin ? 0x96 : 0x64, .onComplete = fin ? B_NightSword_pfxStop : NULL, .ctx = b }); b->hasTween = 1; if (b->hasTween2) tween_stop(b->tween2); b->tween2 = tweens_add((TweenConfig){ .props = { { &b->s.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x64, .delay = 0x64, .onComplete = B_NightSword_despawn, .ctx = b }); b->hasTween2 = 1; } static const BulletVT B_NightSword = { "vfx", "nightSword.png", B_NightSword_ctor, B_NightSword_Init, B_NightSword_OnRecycle, NULL, NULL, B_NightSword_DeSpawn, B_NightSword_SetTarget, B_NightSword_SetNullTarget }; // --- B_Bocce (0xd9ed): l'area invisibile attorno al giocatore ------------------------------------------------------ static void B_Bocce_expire(void *ctx) { Bullet *b = ctx; time_removeEvent(b->ExpireTimer); Bullet_DeSpawn(b); } static void B_Bocce_ctor(Bullet *b) { b->s.x = Core.Player->s.x, b->s.y = Core.Player->s.y; } static void B_Bocce_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); body_setCircle(&b->s.body, 0x10, b->s.body.offset.x, b->s.body.offset.y); sprite_setScale(&b->s, 2 * PixelScale * Weapon_PArea(b->weapon)); b->s.visible = 0; time_removeEvent(b->ExpireTimer); b->ExpireTimer = time_addEvent(Weapon_PInterval(b->weapon), 0, 0, B_Bocce_expire, b); } static void B_Bocce_Update(Bullet *b, float delta) { (void)delta; b->s.x = Core.Player->s.x, b->s.y = Core.Player->s.y; sprite_setScale(&b->s, 2 * PixelScale * Weapon_PArea(b->weapon)); } static const BulletVT B_Bocce = { "vfx", "Rings3.png", B_Bocce_ctor, NULL, B_Bocce_OnRecycle, NULL, B_Bocce_Update }; // --- B_FourSeasons (0xcc71) / B_FourSeasons2 (0x9a27): lo scoppio della stagione (o dell'elemento) negli angoli dello schermo ----- // fwEmitter e particles dell'originale non emettono mai: omessi static const BulletVT B_FourSeasons2; static void FS_sprite(Sprite *s, const char *frame, int add, float depth) { sprite_init(s, frame_get("vfx", frame), 0, 0); s->visible = 0, s->blendAdd = add, s->alpha = add ? 0.65f : 1, s->depth = depth; children_add(s); } static void B_FS_ctor(Bullet *b) { static const unsigned T1[4][4] = { { 0xff8888, 0xff88ff, 0xff88ff, 0xffff88 }, { 0x88ff88, 0xff00, 0x88ff00, 0x88ff44 }, { 0xff0088, 0xff8800, 0xffcc00, 0xffff00 }, { 0xffffff, 0x88ff, 0xccccff, 0x8888ff } }; static const unsigned T2[5][4] = { { 0x884400, 0x442200, 0x551100, 0xcc8800 }, { 0xffff44, 0xff00, 0x88ff00, 0x88ff44 }, { 0xff0000, 0xff8800, 0xffcc00, 0xffff00 }, { 0xffffff, 0x4488ff, 0xccccff, 0x8888ff }, { 0x2222, 0xffffff, 0x8888, 0xcccc } }; int evo = b->vt == &B_FourSeasons2, n = evo ? 5 : 4; Weapon *w = b->weapon; FS_sprite(&b->ring, "sPFX_ring_64.png", 1, game_height + 1); FS_sprite(&b->rainbow, evo ? "s_pfx_rainbow_64u.png" : "s_pfx_rainbow_64.png", 1, game_height + 1); FS_sprite(&b->rays, "fuzzA.png", 1, game_height + 1); FS_sprite(&b->kanji, "k_spring.png", 0, game_height + 1); if (evo) FS_sprite(&b->lightning, "Lightning3.png", 0, game_height); for (int i = 0; i < n; i++) { EmitterConfig c = { .lifespan = EOP(evo ? 0x3e8 : 0x4b0), .rotate = ERND(0, 0x168), .alpha = evo ? (EmitterOp){ 1, 0, 2, Ease_ExpoIn } : (EmitterOp){ 0, 1, 2, Ease_ExpoOut }, .angle = { 0, 0x168, 1 }, .angleSteps = 0x1f, .speed = ERND(0x32, 0x64), .quantity = 0x50, .scale = evo ? ERANGE(2, 1) : ERANGE(2, 0.1f), .frequency = 0x50, .ntints = 4, .hasZone = 1, .zoneRadius = 0x20, .on = 0 }; for (int k = 0; k < 4; k++) c.tints[k] = evo ? T2[i][k] : T1[i][k]; if (!evo && i == 0) { // MakeEmitter_Frames: i fiori for (int k = 1; k <= 10; k++) c.frames[c.nframes++] = frame_get("vfx", TextFormat("flo_%02d.png", k)); c.rotate = (EmitterOp){ 0, 0x2d0, 2, Ease_SineInOut }; } else c.frameRef = &w->seasonFrame[evo ? i : i == 3 ? 1 : 0]; // Animated: foglia, foglia, neve / terra, vento, fuoco, acqua, vuoto b->SeasonPfx[i] = particles_add(); b->SeasonPfx[i]->s.depth = game_height; b->SeasonEmit[i] = particles_createEmitter(b->SeasonPfx[i], c); b->SeasonPfx[i]->hasWell = 1; // createGravityWell({ power, epsilon, gravity: 200 }) b->SeasonPfx[i]->wellPower = (evo ? 0.5f : 1) * 0xc8, b->SeasonPfx[i]->wellEpsilon = evo ? 0x28 * 0x28 : 0x14 * 0x14; } for (int i = 0; i < 6; i++) b->fsTween[i] = (TweenRef){ -1, 0 }; } static void B_FS_expire(void *ctx) { Bullet *b = ctx; time_removeEvent(b->ExpireTimer); Bullet_DeSpawn(b); } static void B_FS_follow(void *ctx) { Bullet *b = ctx; b->ring.x = b->rainbow.x = b->rays.x = b->kanji.x = b->lightning.x = b->s.x; b->ring.y = b->rainbow.y = b->rays.y = b->kanji.y = b->lightning.y = b->s.y; } static void B_FS_ringOff(void *ctx) { ((Bullet *)ctx)->ring.visible = 0; } static void B_FS_rainbowOff(void *ctx) { ((Bullet *)ctx)->rainbow.visible = 0; } static void B_FS_raysOff(void *ctx) { ((Bullet *)ctx)->rays.visible = 0; } static void B_FS_kanjiOut(void *ctx) { Bullet *b = ctx; tween_stop(b->fsTween[4]); b->kanjiTint = 0xffffff; b->fsTween[4] = tweens_add((TweenConfig){ .props = { { &b->kanji.scaleX, &b->kanji.scaleY, 4 }, { &b->kanji.alpha, NULL, 0 }, { &b->kanjiTint, NULL, 0 } }, .nprops = 3, .duration = 0xc8 }); } static void B_FS_lightningOut(void *ctx) { Bullet *b = ctx; b->lightningTint = 0xffffff; tweens_add((TweenConfig){ .props = { { &b->lightning.alpha, NULL, 0 }, { &b->lightningTint, NULL, 0 } }, .nprops = 2, .duration = 0x64 }); } static void B_FS_OnRecycle(Bullet *b) { static const char *const K1[4] = { "k_spring.png", "k_summer.png", "k_autumn.png", "k_winter.png" }, *const K2[5] = { "k_earth.png", "k_wind.png", "k_fire.png", "k_water.png", "k_void.png" }; static const char *const SND[5] = { "Seasons2", "Seasons3", "Seasons4", "Seasons5", "Seasons6" }; int evo = b->vt == &B_FourSeasons2; float a = Weapon_PArea(b->weapon); Bullet_OnRecycle(b); body_setCircle(&b->s.body, 0x10, b->s.body.offset.x, b->s.body.offset.y); b->s.body.enable = 1; b->s.visible = 0; b->season = b->indexInWeapon % (evo ? 5 : 4); b->kanji.frame = frame_get("vfx", (evo ? K2 : K1)[b->season]); ParticleEmitter *e = b->SeasonEmit[b->season]; if (!evo) e->c.quantity = (int)(0x10 * a); b->s.alpha = 1; sprite_setScale(&b->s, a); e->c.speed = ERND(5 * a, 0xa * a); e->c.zoneRadius = fmaxf(0x20, 0x10 * a); b->isCullable = 0; time_removeEvent(b->ExpireTimer); b->ExpireTimer = time_addEvent(0x1f4, 0, 0, B_FS_expire, b); // TryDetonate emitter_emitParticleAt(e, b->s.x, b->s.y, 0); Sound_PlaySound(SND[b->season], 0.5f, 1, 0, b->season == 1 || b->season == 4 ? 0x1770 : 0x1f4, 1); B_FS_follow(b); for (int i = 0; i < 6; i++) tween_stop(b->fsTween[i]); b->ring.visible = 1, sprite_setScale(&b->ring, 0); b->fsTween[0] = tweens_add((TweenConfig){ .props = { { &b->ring.scaleX, &b->ring.scaleY, a } }, .nprops = 1, .duration = 0xc8, .onUpdate = B_FS_follow, .onComplete = B_FS_ringOff, .ctx = b }); b->rainbow.visible = 1, sprite_setScale(&b->rainbow, 0), b->rainbow.angle = 0; b->fsTween[1] = tweens_add((TweenConfig){ .props = { { &b->rainbow.scaleX, &b->rainbow.scaleY, a }, { &b->rainbow.angle, NULL, 0x168 } }, .nprops = 2, .duration = 0xfa, .onUpdate = B_FS_follow, .onComplete = B_FS_rainbowOff, .ctx = b }); b->rays.visible = 1, sprite_setScale(&b->rays, 0), b->rays.angle = 0; b->fsTween[2] = tweens_add((TweenConfig){ .props = { { &b->rays.scaleX, &b->rays.scaleY, 1.2f * a } }, .nprops = 1, .duration = 0x3c, .onUpdate = B_FS_follow, .onComplete = B_FS_raysOff, .ctx = b }); b->kanji.visible = 1, sprite_setScale(&b->kanji, 0), b->kanji.alpha = 1, b->kanji.tint = 0xffffff, b->kanjiTint = 0xffffff; b->fsTween[3] = tweens_add((TweenConfig){ .props = { { &b->kanji.scaleX, &b->kanji.scaleY, 2 } }, .nprops = 1, .duration = 0xc8, .onUpdate = B_FS_follow, .onComplete = B_FS_kanjiOut, .ctx = b }); if (evo && b->season == 4) { b->lightning.visible = 1, sprite_setScale(&b->lightning, 0), b->lightning.alpha = 1, b->lightning.tint = 0xffffff, b->lightningTint = 0xffffff; b->fsTween[5] = tweens_add((TweenConfig){ .props = { { &b->lightning.scaleX, &b->lightning.scaleY, game_width / 480.0f } }, .nprops = 1, .duration = 0x64, .onUpdate = B_FS_follow, .onComplete = B_FS_lightningOut, .ctx = b }); } } static void B_FS_Update(Bullet *b, float delta) { (void)delta; int evo = b->vt == &B_FourSeasons2; Weapon *w = b->weapon; b->s.x = w->seasonPos[b->indexInWeapon].x, b->s.y = w->seasonPos[b->indexInWeapon].y; b->s.depth = -game_height; b->kanji.tint = (unsigned)b->kanjiTint; // il tween interpola il numero intero if (evo) b->lightning.tint = (unsigned)b->lightningTint; for (int i = 0; i < (evo ? 5 : 4); i++) { b->SeasonPfx[i]->wellX = evo ? b->s.x : Core.Player->s.x; b->SeasonPfx[i]->wellY = evo ? b->s.y : Core.Player->s.y; } } static void B_FS_DeSpawn(Bullet *b) { b->isCullable = 1; base_DeSpawn(b); } static const BulletVT B_FourSeasons = { "vfx", "blurBlack2.png", B_FS_ctor, NULL, B_FS_OnRecycle, NULL, B_FS_Update, B_FS_DeSpawn }; static const BulletVT B_FourSeasons2 = { "vfx", "blurBlack2.png", B_FS_ctor, NULL, B_FS_OnRecycle, NULL, B_FS_Update, B_FS_DeSpawn }; // --- B_Spellstring (0x91a5): il filo dal mago al bersaglio ------------------------------------------------------------- static void B_String_trailDraw(Sprite *s) { Bullet *b = s->owner; if (s->visible) Rope_drawH(b->ropePts, 0xa, b->trailFrame, 1, s->alpha, 1, 0); } static void B_String_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void B_String_FadeOut(Bullet *b) { tween_stop(b->fadeOutTween); b->fadeOutTween = tweens_add((TweenConfig){ .props = { { &b->trail.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x64, .onComplete = B_String_despawn, .ctx = b }); } static void B_String_ctor(Bullet *b) { b->Pfx = particles_add(); particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "PfxHoly1.png"), frame_get("vfx", "PfxHoly2.png") }, .nframes = 2, .speed = EOP(0), .quantity = 1, .lifespan = EOP(0x12c), .alpha = ERANGE(1, 0), .on = 0 }); b->trailFrame = frame_get("vfx", frand() >= 0.5f ? "spellstring1.png" : "spellstring2.png"); sprite_init(&b->trail, NULL, b->s.x, b->s.y); b->trail.owner = b, b->trail.draw = B_String_trailDraw; children_add(&b->trail); b->fadeOutTween = b->tween = (TweenRef){ -1, 0 }; } static void B_String_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); b->expired = 0, b->updateLoops = 0; b->s.body.enable = 0; b->trail.visible = 1; b->startingPoint = (Vector2){ b->s.x, b->s.y }; Sound_PlaySound("SpellString", 0.1f, 1, -0x64 * b->indexInWeapon, 0xc8, 4); b->trail.alpha = 1; tween_stop(b->tween); float target = -b->angleLerp; // il valore finale si calcola prima di onStart (sic) b->angleLerp = 2 * (frand() - 0.5f); b->tween = tweens_add((TweenConfig){ .props = { { &b->angleLerp, NULL, target } }, .nprops = 1, .duration = 0x78 }); } static void B_String_SetTarget(Bullet *b, Vector2 t) { (void)t; b->target = b->weapon->target; } static void B_String_Update(Bullet *b, float delta) { (void)delta; b->updateLoops++; if (!b->expired && b->updateLoops > 1) b->expired = 1, B_String_FadeOut(b); b->trail.depth = b->s.y - Core.Player->s.y + 0.5f * game_height; if (!b->target) return; Vector2 t = { b->target->x, b->target->y }, st = b->startingPoint; float a = 0.5f * b->angleLerp, sn = sinf(a), cs = cosf(a), rx = t.x - st.x, ry = t.y - st.y; Vector2 c = { rx * cs - ry * sn + st.x, rx * sn + ry * cs + st.y }; for (int i = 0; i < 0xa; i++) { // QuadraticBezier.getPoints(9) float k = i / 9.0f, u = 1 - k; b->ropePts[i] = (Vector2){ u * u * t.x + 2 * u * k * c.x + k * k * st.x, u * u * t.y + 2 * u * k * c.y + k * k * st.y }; if (i < 9) manager_emitParticleAt(b->Pfx, b->ropePts[i].x, b->ropePts[i].y); } } static void B_String_DeSpawn(Bullet *b) { tween_stop(b->tween); b->trail.visible = 0; base_DeSpawn(b); } static const BulletVT B_Spellstring = { "vfx", "ProjectileHoly1.png", B_String_ctor, NULL, B_String_OnRecycle, NULL, B_String_Update, B_String_DeSpawn, B_String_SetTarget }; // --- B_Spellstream (0x15475): il cerchio che avanza, cresce e rallenta -------------------------------------------------- static void B_Stream_ctor(Bullet *b) { b->Pfx = particles_add(); b->PfxEmitter1 = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "2Spell1.png"), frame_get("vfx", "2Spell2.png") }, .nframes = 2, .speed = EOP(0), .quantity = 1, .lifespan = ERND(0x12c, 0x2bc), .alpha = ERANGE(1, 0), .scale = ERND(1, 2), .hasZone = 1, .zoneRadius = 0x10, .on = 0 }); b->PfxEmitter2 = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "2Spell3.png"), frame_get("vfx", "2Spell4.png") }, .nframes = 2, .speed = EOP(0), .quantity = 1, .lifespan = ERND(0x64, 0xc8), .alpha = ERANGE(1, 0), .scale = { 0, 2, 2, Ease_QuintOut }, .hasZone = 1, .zoneRadius = 0x10, .on = 0 }); b->ScaleTween = b->SpeedTween = (TweenRef){ -1, 0 }; b->ExpireTimer = (Timer){ -1, 0 }; } static void B_Stream_expire(void *ctx) { Bullet_DeSpawn(ctx); } static void B_Stream_OnRecycle(Bullet *b) { Weapon *w = b->weapon; Bullet_OnRecycle(b); b->isCullable = 0; b->s.visible = 0; sprite_setScale(&b->s, 1); body_setCircle(&b->s.body, 1, -0.5f, -0.5f); b->s.body.enable = 1; b->deceleration = 2; b->s.x += 8 * w->critChancesArray[w->critIndex++ % 1000], b->s.y -= 0xc; // GetChanceFromArray Bullet_SetForNearestEnemy(b, &b->aimVec); sprite_setVelocity(&b->s, b->aimVec.x, b->aimVec.y); int shortLife = Weapon_PDuration(w) < 0x2ee; tween_stop(b->ScaleTween); b->ScaleTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, 0x10 * (1 + Weapon_PArea(w)) } }, .nprops = 1, .duration = 0x2ee, .onComplete = shortLife ? B_Stream_expire : NULL, .ctx = b }); time_removeEvent(b->ExpireTimer); if (!shortLife) b->ExpireTimer = time_addEvent(Weapon_PDuration(w), 0, 0, B_Stream_expire, b); // durationTween tween_stop(b->SpeedTween); b->SpeedTween = tweens_add((TweenConfig){ .props = { { &b->deceleration, NULL, -0.75f } }, .nprops = 1, .duration = 0x2ee, .ease = Ease_SineInOut }); Sound_PlaySound("Song", 0.4f, 1, 0, 0x96, 1); } static void B_Stream_Update(Bullet *b, float delta) { (void)delta; float sc = b->s.scaleX, n = fminf(0xa0, 0.25f * sc); b->PfxEmitter1->c.zoneRadius = b->PfxEmitter2->c.zoneRadius = sc; emitter_emitParticleAt(b->PfxEmitter1, b->s.x, b->s.y, (int)ceilf(n)); emitter_emitParticleAt(b->PfxEmitter2, b->s.x, b->s.y, (int)ceilf(0.5f * n)); sprite_setVelocity(&b->s, b->aimVec.x * b->deceleration, b->aimVec.y * b->deceleration); } static void B_Stream_DeSpawn(Bullet *b) { time_removeEvent(b->ExpireTimer); tween_stop(b->SpeedTween), tween_stop(b->ScaleTween); base_DeSpawn(b); } static const BulletVT B_Spellstream = { "vfx", "WhiteDot.png", B_Stream_ctor, NULL, B_Stream_OnRecycle, NULL, B_Stream_Update, B_Stream_DeSpawn }; // --- B_Spellstrike (0x4990): il fulmine sul bersaglio --------------------------------------------------------------------- static void B_Strike_ctor(Bullet *b) { b->Pfx = particles_add(); b->PfxEmitter1 = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "2Spell1.png"), frame_get("vfx", "2Spell2.png") }, .nframes = 2, .speed = ERND(0x32, 0x96), .quantity = 1, .lifespan = ERND(0x12c, 0x2bc), .alpha = ERANGE(1, 0), .scale = ERND(1, 2), .hasZone = 1, .zoneRadius = 0x10, .on = 0 }); b->PfxEmitter2 = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "2Spell3.png"), frame_get("vfx", "2Spell4.png") }, .nframes = 2, .speed = EOP(0), .quantity = 1, .lifespan = ERND(0x96, 0x12c), .alpha = ERANGE(1, 0), .scale = { 0, 2, 2, Ease_QuintOut }, .hasZone = 1, .zoneRadius = 0x10, .on = 0 }); b->ScaleTween = b->SpeedTween = (TweenRef){ -1, 0 }; } static void B_Strike_done(void *ctx) { Bullet *b = ctx; b->s.visible = 0; Bullet_DeSpawn(b); } static void B_Strike_emit(void *ctx) { Bullet *b = ctx; b->PfxEmitter1->c.zoneRadius = b->PfxEmitter2->c.zoneRadius = b->radius; emitter_emitParticleAt(b->PfxEmitter1, b->s.x, b->s.y, 4); emitter_emitParticleAt(b->PfxEmitter2, b->s.x, b->s.y, 2); } static void B_Strike_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); b->s.body.enable = 0; b->s.flipX = b->s.x > Core.Player->s.x; tween_stop(b->ScaleTween); sprite_setScale(&b->s, 0), b->s.visible = 1; b->ScaleTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, 2 } }, .nprops = 1, .duration = 0x50, .ease = Ease_BounceOut, .onComplete = B_Strike_done, .ctx = b }); tween_stop(b->SpeedTween); b->radius = 0x20; b->SpeedTween = tweens_add((TweenConfig){ .props = { { &b->radius, NULL, 0x40 } }, .nprops = 1, .duration = 0x50, .onUpdate = B_Strike_emit, .ctx = b }); Sound_PlaySound("SpellStrike", b->weapon->volume ? b->weapon->volume : 0.15f, 1, -0x64 * b->indexInWeapon, 0xc8, 4); } static void B_Strike_Update(Bullet *b, float delta) { (void)delta; b->Pfx->s.depth = b->s.depth - 1; } static const BulletVT B_Spellstrike = { "vfx", "2Strike1.png", B_Strike_ctor, NULL, B_Strike_OnRecycle, NULL, B_Strike_Update }; // --- B_Spellstrom (0x4124): due sfere nere che seguono i pozzi, senza scadenza ----------------------------------------------- static void B_Strom_ctor(Bullet *b) { sprite_setTint(&b->s, 0), b->s.alpha = 0.65f, b->isCullable = 0; } static void B_Strom_clearHits(void *ctx) { ((Bullet *)ctx)->n_hit = 0; } static void B_Strom_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); if (b->alreadyRecycled) return; b->s.visible = 1, b->alreadyRecycled = 1; sprite_setScale(&b->s, 1); body_setCircle(&b->s.body, 0x40, 0, 0); time_removeEvent(b->HitboxTimer); b->HitboxTimer = time_addEvent(b->weapon->hitBoxDelay, 1, 0, B_Strom_clearHits, b); b->s.depth = -game_height - 1; } static void B_Strom_Update(Bullet *b, float delta) { (void)delta; b->s.x = b->weapon->wellPos[b->indexInWeapon].x, b->s.y = b->weapon->wellPos[b->indexInWeapon].y; } static void B_Strom_DeSpawn(Bullet *b) { base_DeSpawn(b); b->s.visible = 0; } static const BulletVT B_Spellstrom = { "vfx", "blur128.png", B_Strom_ctor, NULL, B_Strom_OnRecycle, NULL, B_Strom_Update, B_Strom_DeSpawn }; // --- RibbonTrail orizzontale (0x7c1 su una Rope horizontal = true): vertici a mezza altezza del fotogramma ------------ static void Rope_drawH(const Vector2 *pts, int n, const Frame *f, float scale, float alpha, int add, int flipY) { // n <= 128 if (!f || alpha <= 0) return; Texture2D tex = *f->tex; float half = 0.5f * f->h, u0 = (float)f->x / tex.width, u1 = (float)(f->x + f->w) / tex.width, v0 = (float)f->y / tex.height, v1 = (float)(f->y + f->h) / tex.height; if (flipY) { float t = v0; v0 = v1; v1 = t; } Vector2 a[128], c[128]; int ok[128]; Vector2 last = pts[0]; for (int i = 0; i < n; i++) { Vector2 p = pts[i], nx = i < n - 1 ? pts[i + 1] : p; if (Rope_cull) { float sx = scale * p.x - camera_scrollX, sy = scale * p.y - camera_scrollY, m = 0x40 + half; if (sx < -m || sx > game_width + m || sy < -m || sy > game_height + m) { ok[i] = 0, last = p; continue; } } float px = nx.y - last.y, py = -(nx.x - last.x), l = sqrtf(px * px + py * py); ok[i] = l > 0; // lunghezza 0: vertici NaN, WebGL non li disegna if (ok[i]) px = px / l * half, py = py / l * half; a[i] = (Vector2){ scale * (p.x + px) - camera_scrollX, scale * (p.y + py) - camera_scrollY }; c[i] = (Vector2){ scale * (p.x - px) - camera_scrollX, scale * (p.y - py) - camera_scrollY }; last = p; } if (add) BeginBlendMode(BLEND_ADDITIVE); rlDisableBackfaceCulling(); rlSetTexture(tex.id); rlBegin(RL_QUADS); rlColor4ub(255, 255, 255, (unsigned char)(255 * fminf(1, alpha))); for (int i = 0; i < n - 1; i++) { if (!ok[i] || !ok[i + 1]) continue; float ua = u0 + i * (u1 - u0) / (n - 1), ub = u0 + (i + 1) * (u1 - u0) / (n - 1); rlTexCoord2f(ua, v0), rlVertex2f(a[i].x, a[i].y); rlTexCoord2f(ua, v1), rlVertex2f(c[i].x, c[i].y); rlTexCoord2f(ub, v1), rlVertex2f(c[i + 1].x, c[i + 1].y); rlTexCoord2f(ub, v0), rlVertex2f(a[i + 1].x, a[i + 1].y); } rlEnd(); rlSetTexture(0); rlEnableBackfaceCulling(); if (add) EndBlendMode(); } static void Lightning_trailDraw(Sprite *s) { Bullet *b = s->owner; if (s->visible) Rope_drawH(b->ropePts, 16, frame_get("vfx", "Lightning3.png"), 1, 1, 0, 0); } static void Lightning_flashDraw(Sprite *s) { // graphics.fillStyle(colore, 0.15).fillCircle(0, 0, 8), ADD if (!s->visible || s->scaleX <= 0) return; BeginBlendMode(BLEND_ADDITIVE); DrawCircle((int)roundf(s->x - camera_scrollX), (int)roundf(s->y - camera_scrollY), 8 * s->scaleX, hexc(s->tint, s->alpha)); // alpha del fillStyle EndBlendMode(); } static void Lightning_trailUpdate(Bullet *b) { // RibbonTrail.trailUpdate: positions.unshift(follower), max 16, poi nei punti memmove(&b->positions[1], &b->positions[0], 15 * sizeof(Vector2)); b->positions[0] = (Vector2){ b->s.x, b->s.y }; if (b->npos < 16) b->npos++; for (int i = 0; i < b->npos; i++) b->ropePts[i] = b->positions[i]; } // AimForRandomEnemyInScreen: physics.overlapRect sui corpi, quelli con owner (i nemici) non morti, RND.pick static Sprite *Bullet_AimForRandomEnemyInScreen(Rectangle r) { static Sprite *found[1024]; int n = 0; for (int i = 0; i < Core.Enemies.n && n < 1024; i++) { Sprite *e = Core.Enemies.items[i]; Body *bd = &e->body; if (!e->hasBody || !bd->enable || ((Enemy *)e->owner)->isDead) continue; if (bd->position.x + bd->width < r.x || bd->position.x > r.x + r.width || bd->position.y + bd->height < r.y || bd->position.y > r.y + r.height) continue; found[n++] = e; } return n ? found[(int)floorf(frand() * n)] : NULL; } static void B_Lightning_ctor(Bullet *b) { static const unsigned C[4] = { 0xffff, 0xff, 0x88ff, 0xffffff }; sprite_init(&b->trail, NULL, 0, 0); b->trail.owner = b; b->trail.draw = Lightning_trailDraw; b->trail.depth = ZInGameUI; // Number.MAX_SAFE_INTEGER - 1000 b->trail.visible = 0; children_add(&b->trail); b->s.visible = 0; b->isCullable = 0; b->_speed = 0; sprite_init(&b->flash, NULL, 0, 0); b->flash.draw = Lightning_flashDraw; b->flash.tint = C[b->indexInWeapon % 4]; b->flash.alpha = 0.15f; b->flash.blendAdd = 1; b->flash.visible = 0; children_add(&b->flash); } static void B_Lightning_end(void *ctx) { Bullet *b = ctx; b->trail.visible = 0; b->flash.visible = 0; Bullet_DeSpawn(b); } typedef struct { Bullet *b; Vector2 t; } LightningHit; static void B_Lightning_hit(void *ctx) { // moveTween onComplete: il lampo a terra Bullet *b = ctx; b->n_hit = 0; b->s.body.enable = 1; b->flash.x = b->s.x, b->flash.y = b->s.y; // setPosition(x, y) del bersaglio: dove il tween ha portato il fulmine b->flash.visible = 1; sprite_setScale(&b->flash, 0); b->flash.depth = b->s.y - Core.Player->s.y - 0.5f * game_height; Sound_PlaySound("Lightning", 0.6f, 2, -0x64 * b->indexInWeapon, 0xc8, 4); b->despawnTween = tweens_add((TweenConfig){ .props = { { &b->flash.scaleX, &b->flash.scaleY, Weapon_PArea(b->weapon) } }, .nprops = 1, .duration = 0x3c, .onComplete = B_Lightning_end, .ctx = b }); b->hasDespawnTween = 1; } static void B_Lightning_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); body_setCircle(&b->s.body, 0x10, b->s.body.offset.x, b->s.body.offset.y); if (b->hasMoveTween) tween_stop(b->moveTween); if (b->hasDespawnTween) tween_stop(b->despawnTween); b->s.visible = 0; b->trail.visible = 0; frand(); // RND.pick([0, 1, 2]) senza uso Rectangle *r = &Core.Player->ScreenRectangle; r->x = Core.Player->s.x - 0.5f * game_width, r->y = Core.Player->s.y - 0.5f * game_height, r->width = game_width, r->height = game_height; b->npos = 0; // trail.clearPositions b->s.body.enable = 0; sprite_setScale(&b->s, 0.5f * PixelScale * Weapon_PArea(b->weapon)); Sprite *t = Bullet_AimForRandomEnemyInScreen(*r); if (!t) { Bullet_DeSpawn(b); return; } b->s.x = t->x; b->s.y = Core.Player->s.y - 0.6f * game_height; for (int i = 0; i < 16; i++) b->ropePts[i] = (Vector2){ b->s.x, b->s.y }; // resetPoints b->trail.visible = 1; b->moveTween = tweens_add((TweenConfig){ .props = { { &b->s.y, NULL, t->y } }, .nprops = 1, .duration = 0x46, .onComplete = B_Lightning_hit, .ctx = b }); b->hasMoveTween = 1; } static void B_Lightning_Update(Bullet *b, float delta) { (void)delta; Lightning_trailUpdate(b); } static const BulletVT B_Lightning = { "vfx", "HitRed2.png", B_Lightning_ctor, NULL, B_Lightning_OnRecycle, NULL, B_Lightning_Update, NULL }; // --- B_Loop (0x13075, Thunder Loop): il fulmine arriva di lato, scarica a terra, colpisce una seconda volta e risale ------------ static void B_Loop_ctor(Bullet *b) { static const unsigned C[4] = { 0xffff00, 0xff8800, 0xffff88, 0xff8888 }; b->explosionRadius = 0x10; sprite_init(&b->trail, NULL, 0, 0); b->trail.owner = b; b->trail.draw = Lightning_trailDraw; b->trail.depth = ZInGameUI; b->trail.visible = 0; children_add(&b->trail); b->s.visible = 0; b->isCullable = 0; b->_speed = 0; Sprite *g[2] = { &b->flash, &b->flash2 }; for (int i = 0; i < 2; i++) { sprite_init(g[i], NULL, 0, 0); g[i]->draw = Lightning_flashDraw; g[i]->tint = i ? 0xffffff : C[b->indexInWeapon % 4]; g[i]->alpha = 0.075f; g[i]->visible = 0; children_add(g[i]); } b->Pfx = particles_add(); b->PfxEmitter1 = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "PfxYellow.png"), frame_get("vfx", "PfxRed.png"), frame_get("vfx", "PfxLine.png") }, .nframes = 3, .speed = ERND(1, 1), .quantity = 1, .rotate = ERND(0x5a, 0x5a), .lifespan = EOP(0x258), .alpha = ERANGE(1, 0), .scale = ERANGE(PixelScale / 2, PixelScale), .hasZone = 1, .zoneRadius = 0x10, .on = 0 }); } static void B_Loop_end(void *ctx) { Bullet *b = ctx; b->trail.visible = b->flash.visible = b->flash2.visible = 0; Bullet_DeSpawn(b); } static void B_Loop_up(void *ctx) { // secondMoveTween onComplete Bullet *b = ctx; b->despawnTween = tweens_add((TweenConfig){ .props = { { &b->flash.scaleX, &b->flash.scaleY, 0 }, { &b->flash2.scaleX, &b->flash2.scaleY, 0 } }, .nprops = 2, .duration = 0x3c, .onComplete = B_Loop_end, .ctx = b }); b->hasDespawnTween = 1; } static void B_Loop_second(void *ctx) { // finalScaleGroundTween onStart: il secondo colpo Bullet *b = ctx; b->n_hit = 0; Sound_PlaySound("Lightning2", 0.5f, 1, -0x64 * b->indexInWeapon, 0xc8, 8); b->s.body.enable = 1; } static void B_Loop_secondDone(void *ctx) { Bullet *b = ctx; b->s.body.enable = 0; b->moveTween = tweens_add((TweenConfig){ .props = { { &b->s.y, NULL, b->s.y - 1.5f * game_height } }, .nprops = 1, .duration = 0x5a, .onComplete = B_Loop_up, .ctx = b }); } static void B_Loop_ungrounded(void *ctx) { ((Bullet *)ctx)->isGrounded = 0; } static void B_Loop_grounded(void *ctx) { // hitGroundTween onComplete Bullet *b = ctx; b->s.body.enable = 0; b->isGrounded = 1; tweens_add((TweenConfig){ .props = { { &b->flash2.scaleX, &b->flash2.scaleY, 0 } }, .nprops = 1, .duration = 0x5dc, .onComplete = B_Loop_ungrounded, .ctx = b }); // chargeTween time_addEvent(0x514, 0, 0, B_Loop_second, b); // onStart del tween con delay 1300 tweens_add((TweenConfig){ .props = { { &b->flash.scaleX, &b->flash.scaleY, 0 } }, .nprops = 1, .delay = 0x514, .duration = 0x3c, .onComplete = B_Loop_secondDone, .ctx = b }); } static void B_Loop_hit(void *ctx) { // moveTween onComplete: primo colpo dove sta il bersaglio adesso Bullet *b = ctx; b->n_hit = 0; b->s.body.enable = 1; Sprite *t = b->target; if (t) { Sprite *g[2] = { &b->flash, &b->flash2 }; for (int i = 0; i < 2; i++) { g[i]->x = t->x, g[i]->y = t->y; g[i]->visible = 1; sprite_setScale(g[i], 0); g[i]->depth = b->s.y - Core.Player->s.y - 0.5f * game_height; } } Sound_PlaySound("Lightning", 0.5f, 1, 0xc8 * b->indexInWeapon, 0xc8, 8); tweens_add((TweenConfig){ .props = { { &b->flash.scaleX, &b->flash.scaleY, PixelScale * Weapon_PArea(b->weapon) }, { &b->flash2.scaleX, &b->flash2.scaleY, PixelScale * Weapon_PArea(b->weapon) } }, .nprops = 2, .duration = 0x3c, .onComplete = B_Loop_grounded, .ctx = b }); // hitGroundTween } static void B_Loop_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); body_setCircle(&b->s.body, 0x10, b->s.body.offset.x, b->s.body.offset.y); b->PfxEmitter1->c.zoneRadius = 0x10 * PixelScale * 0.5f * Weapon_PArea(b->weapon); // explosionCircle if (b->hasMoveTween) tween_stop(b->moveTween); if (b->hasDespawnTween) tween_stop(b->despawnTween); b->s.visible = 0; b->trail.visible = 0; Rectangle *r = &Core.Player->ScreenRectangle; r->x = Core.Player->s.x - 0.5f * game_width, r->y = Core.Player->s.y - 0.5f * game_height, r->width = game_width, r->height = game_height; b->npos = 0; b->s.body.enable = 0; sprite_setScale(&b->s, 0.5f * PixelScale * Weapon_PArea(b->weapon)); Sprite *t = Bullet_AimForRandomEnemyInScreen(*r); b->target = t; if (!t) { Bullet_DeSpawn(b); return; } b->s.x = Core.Player->s.x + 0.5f * game_width * (frand() >= 0.5f ? 1 : -1); b->s.y = Core.Player->s.y - 0.6f * game_height; for (int i = 0; i < 16; i++) b->ropePts[i] = (Vector2){ b->s.x, b->s.y }; b->trail.visible = 1; b->moveTween = tweens_add((TweenConfig){ .props = { { &b->s.x, NULL, t->x }, { &b->s.y, NULL, t->y } }, .nprops = 2, .duration = 0x46, .onComplete = B_Loop_hit, .ctx = b }); b->hasMoveTween = 1; } static void B_Loop_Update(Bullet *b, float delta) { (void)delta; Lightning_trailUpdate(b); if (b->isGrounded) manager_emitParticleAt(b->Pfx, b->s.x, b->s.y); } static const BulletVT B_Loop = { "vfx", "HitRed2.png", B_Loop_ctor, NULL, B_Loop_OnRecycle, NULL, B_Loop_Update, NULL }; // --- B_Misspell (0x22c5): NDUJA, vampate invisibili con un cerchio additivo a terra e due scie di particelle ---------- // Stessa classe, con due varianti: B_Misspell_True (0x17469, Flames of Misspell) e B_Misspell_True2 (0x15b0b, Ashes of Muspell) static void Circle1_draw(Sprite *s) { // scene.add.circle(0, 0, 1, colore): raggio 1 * scala, colore nel tint BeginBlendMode(BLEND_ADDITIVE); DrawCircle((int)roundf(s->x - camera_scrollX), (int)roundf(s->y - camera_scrollY), s->scaleX, hexc(s->tint, s->alpha)); EndBlendMode(); } static void Circle1Normal_draw(Sprite *s) { // B_Misspell_True2: cerchio scuro in miscela NORMAL DrawCircle((int)roundf(s->x - camera_scrollX), (int)roundf(s->y - camera_scrollY), s->scaleX, hexc(s->tint, s->alpha)); } static void B_Misspell_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void Misspell_ctor(Bullet *b, int ashes) { static const unsigned C[2][3] = { { 0xff0000, 0xff6600, 0xff4400 }, { 0, 0x222222, 0x442222 } }; b->radius = 0x10; b->isPlayerFacing = 1; sprite_init(&b->GroundFx, NULL, 0, 0); b->GroundFx.tint = C[ashes][(int)floorf(frand() * 3)]; // RND.pick b->GroundFx.alpha = 0.2f; b->GroundFx.draw = ashes ? Circle1Normal_draw : Circle1_draw; children_add(&b->GroundFx); b->s.visible = 0; b->Pfx = particles_add(); particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "PfxRed.png"), frame_get("vfx", ashes ? "PfxGrayInverted.png" : "PfxYellow.png") }, .nframes = 2, .speed = ERND(0xf, 0x1e), .quantity = 1, .lifespan = EOP(0x64), .alpha = ERANGE(1, 0), .scale = ERANGE(1, 0), .on = 0 }); particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", ashes ? "Flame3.png" : "Flame2.png"), frame_get("vfx", ashes ? "PfxGray.png" : "PfxYellow.png") }, .nframes = 2, .speed = ERND(0xf, 0x1e), .rotate = ERND(0, 0x168), .angle = { 0, 0xb4, 1 }, .angleSteps = 0x10, .quantity = 1, .lifespan = EOP(0x64), .alpha = ERANGE(1, 0), .scale = ERANGE(0, 2), .on = 0 }); } static void B_Misspell_ctor(Bullet *b) { Misspell_ctor(b, 0); } static void B_MisspellAshes_ctor(Bullet *b) { Misspell_ctor(b, 1); } // v: 0 NDUJA (tween di 400 ms), 1 Flames of Misspell, 2 Ashes of Muspell (PDuration; indietro se !isPlayerFacing, suono solo in avanti) static void Misspell_OnRecycle(Bullet *b, int v) { Bullet_OnRecycle(b); body_setCircle(&b->s.body, 1, b->s.body.offset.x, b->s.body.offset.y); sprite_setScale(&b->s, PixelScale * Weapon_PArea(b->weapon)); sprite_setTintFill(&b->s, 0xff0000); b->s.y -= 0x18; if (v == 1 || b->isPlayerFacing) Bullet_ApplyPlayerFacingVelocity(b); // NDUJA: isPlayerFacing; NDUJA_COUNTER all'indietro else Bullet_ApplyInversePlayerFacingVelocity(b); b->s.body.velocity.x += 0x64 * sinf(b->indexInWeapon); b->s.body.velocity.y += 0x64 * cosf(b->indexInWeapon); if (v < 2 || b->isPlayerFacing) Sound_PlaySound("Fireloop", 1, 2, -0x64 * b->indexInWeapon, 0xc8, 1); b->GroundFx.alpha = 1; sprite_setScale(&b->GroundFx, 0); b->s.alpha = 1; sprite_setScale(&b->s, 0); if (b->hasScaleTween) tween_stop(b->scaleTween); float sc = b->radius * Weapon_PArea(b->weapon), d = v ? Weapon_PDuration(b->weapon) : 0x190; TweenProp pr[4] = { { &b->GroundFx.alpha, NULL, 0 }, { &b->GroundFx.scaleX, &b->GroundFx.scaleY, sc }, { &b->s.alpha, NULL, 0 }, { &b->s.scaleX, &b->s.scaleY, sc } }; b->scaleTween = tweens_add((TweenConfig){ .many = pr, .nmany = 4, .duration = d, .onComplete = B_Misspell_despawn, .ctx = b }); b->hasScaleTween = 1; } static void B_Misspell_OnRecycle(Bullet *b) { Misspell_OnRecycle(b, 0); } static void B_MisspellTrue_OnRecycle(Bullet *b) { Misspell_OnRecycle(b, 1); } static void B_MisspellTrue2_OnRecycle(Bullet *b) { Misspell_OnRecycle(b, 2); } static void B_Misspell_Update(Bullet *b, float delta) { (void)delta; b->GroundFx.x = b->s.x, b->GroundFx.y = b->s.y; // copyPosition manager_emitParticleAt(b->Pfx, b->s.x, b->s.y); } static const BulletVT B_Misspell = { "vfx", "WhiteDot.png", B_Misspell_ctor, NULL, B_Misspell_OnRecycle, NULL, B_Misspell_Update, NULL }; static void B_MisspellCounter_ctor(Bullet *b) { B_Misspell_ctor(b); b->isPlayerFacing = 0; } static const BulletVT B_MisspellCounter = { "vfx", "WhiteDot.png", B_MisspellCounter_ctor, NULL, B_Misspell_OnRecycle, NULL, B_Misspell_Update, NULL }; static const BulletVT B_MisspellTrue = { "vfx", "WhiteDot.png", B_Misspell_ctor, NULL, B_MisspellTrue_OnRecycle, NULL, B_Misspell_Update, NULL }; static const BulletVT B_MisspellTrue2 = { "vfx", "WhiteDot.png", B_MisspellAshes_ctor, NULL, B_MisspellTrue2_OnRecycle, NULL, B_Misspell_Update, NULL }; // --- Weapon (0xe49a) ---------------------------------------------------------- static void Weapon_Fire(Weapon *w) { w->vt->Fire(w); } static void Weapon_ResetFiringTimer(Weapon *w) { if (!w->resetDisabled) w->vt->ResetFiringTimer(w); } // resetDisabled: ResetFiringTimer = function () {} static void Weapon_FireCb(void *ctx) { // i timer di sparo girano anche se Update e' saltato: in coop il caduto non spara Weapon *w = ctx; if (Players_n > 1 && Slots[w->player].player && Slots[w->player].player->isDead) return; Weapon_Fire(w); } static void base_ResetFiringTimer(Weapon *w) { time_removeEvent(w->firingTimer); // firingTimer.destroy() float delay = w->intervalDependsOnDuration ? w->duration + Weapon_PInterval(w) : Weapon_PInterval(w); w->firingTimer = time_addEvent(delay, 1, 0, Weapon_FireCb, w); } static void noop_ResetFiringTimer(Weapon *w) { time_removeEvent(w->firingTimer); } static Bullet *base_FireOneBullet(Weapon *w, float x, float y, int index); static Bullet *Weapon_FireOneBullet(Weapon *w, float x, float y, int index) { return w->vt->FireOneBullet ? w->vt->FireOneBullet(w, x, y, index) : base_FireOneBullet(w, x, y, index); } static Bullet *base_FireOneBullet(Weapon *w, float x, float y, int index) { Bullet *b = BulletPool_SpawnAt(w->pool, x, y, w, index); if (!b) return NULL; if (w->target && b->vt->SetTarget) b->vt->SetTarget(b, (Vector2){ w->target->x, w->target->y }); else if (!w->target && b->vt->SetNullTarget) b->vt->SetNullTarget(b); // il Bullet base: target = null return b; } typedef struct { Weapon *w; int index; } ShotCtx; static void Weapon_DelayedShot(void *ctx) { ShotCtx *c = ctx; Weapon_FireOneBullet(c->w, Core.Player->s.x, Core.Player->s.y, c->index); } static void base_Fire(Weapon *w) { Weapon_FireOneBullet(w, Core.Player->s.x, Core.Player->s.y, 0); static ShotCtx shots[256]; static int shot_i; if (Weapon_PAmount(w) > 1) for (int i = 1; i < Weapon_PAmount(w); i++) { if (w->repeatInterval * i > 0) { ShotCtx *c = &shots[shot_i++ & 255]; *c = (ShotCtx){ w, i }; w->lastShotTimer = time_addEvent(w->repeatInterval * i, 0, 0, Weapon_DelayedShot, c); } else { Weapon_FireOneBullet(w, Core.Player->s.x, Core.Player->s.y, i); } } if (w->lastFiringInterval != Weapon_PInterval(w)) { w->lastFiringInterval = Weapon_PInterval(w); Weapon_ResetFiringTimer(w); } } // Le proprieta' che Weapon possiede (hasOwnProperty) e che le tabelle impostano o sommano static float *Weapon_field(Weapon *w, const char *k) { static const struct { const char *k; size_t off; } F[] = { #define W(x) { #x, offsetof(Weapon, x) } W(interval), W(repeatInterval), W(secondaryPower), W(power), W(area), W(speed), W(amount), W(duration), W(critChance), W(critMul), W(penetrating), W(bounces), W(knockback), W(hitBoxDelay), W(freezeChance), W(charges), W(hitVFX), W(volume), W(chance), #undef W }; for (size_t i = 0; i < sizeof(F) / sizeof(F[0]); i++) if (!strcmp(F[i].k, k)) return (float *)((char *)w + F[i].off); return NULL; } static void Weapon_MakeChanceArray(Weapon *w) { for (int i = 0; i < 1000; i++) w->critChancesArray[i] = (1.0f / 1000) * i; for (int i = 999; i > 0; i--) { // Phaser.Utils.Array.Shuffle int j = (int)floorf(frand() * (i + 1)); float t = w->critChancesArray[i]; w->critChancesArray[i] = w->critChancesArray[j]; w->critChancesArray[j] = t; } } static void Core_RemoveWeapon(const char *type); static void LevelUpFactory_AddLateWeapon(const char *type); static void base_MakeLevelOne(Weapon *w) { w->level = 0; Weapon_MakeChanceArray(w); w->canCrit = 0; cJSON *d = cJSON_GetArrayItem(w->data, w->level); for (cJSON *it = d ? d->child : NULL; it; it = it->next) { if (!strcmp(it->string, "level") && cJSON_IsNumber(it)) { w->level = it->valueint; continue; } if (!strcmp(it->string, "hitsWalls")) { w->hitsWalls = cJSON_IsTrue(it); continue; } if (!strcmp(it->string, "isPowerUp")) { w->isPowerUp = cJSON_IsTrue(it); continue; } if (!strcmp(it->string, "intervalDependsOnDuration")) { w->intervalDependsOnDuration = cJSON_IsTrue(it); continue; } float *f = Weapon_field(w, it->string); if (f && cJSON_IsNumber(it)) *f = (float)it->valuedouble; } if (has(d, "poolLimit")) w->pool->upperLimit = (int)num(d, "poolLimit", 50); cJSON *from = cJSON_GetObjectItem(d, "evolvesFrom"), *f; if (cJSON_IsArray(from)) cJSON_ArrayForEach(f, from) Core_RemoveWeapon(f->valuestring); // evolvesFrom stringa: ha .length, e l'originale cicla sui suoi caratteri senza togliere nulla // bgm, unexcludeSelf: nessuna delle armi tradotte li ha if (w->vt->CheckArcanas) w->vt->CheckArcanas(w); w->lastFiringInterval = Weapon_PInterval(w); if (Player_is(Core.Player, "SYUUTO") && !strcmp(w->bulletType, "SUMMONNIGHT2")) Syuuto_Morph(Core.Player); // OnWeaponMadeLevelOne } static void base_onBulletOverlapsEnemy(Weapon *w, Bullet *b, Enemy *e) { if (e->isDead || Bullet_HasAlreadyHitObject(b, e, e->isDead)) return; Enemy_GetDamaged(e, Weapon_PPower(w), (int)w->hitVFX, w->knockback, w->bulletType); w->stats_inflictedDamage += Weapon_PPower(w); } static void Weapon_onBulletOverlapsEnemy(void *ctx, Sprite *bs, Sprite *es) { Weapon *w = ctx; w->vt->onBulletOverlapsEnemy(w, bs->owner, es->owner); } static void Destructible_GetDamagedFwd(void *d, float amount); static int Destructible_isDead(void *d); static const char *Destructible_hitBy; static void Weapon_onBulletOverlapsDestuctible(void *ctx, Sprite *bs, Sprite *ds) { // (sic) nome originale Weapon *w = ctx; Bullet *b = bs->owner; Destructible_hitBy = w->bulletType; // i sigilli di Foscari guardano l'arma if (!Bullet_HasAlreadyHitObject(b, ds->owner, Destructible_isDead(ds->owner))) Destructible_GetDamagedFwd(ds->owner, Weapon_PPower(w)); Destructible_hitBy = NULL; } static void Weapon_onBulletOverlapsWall(void *ctx, Sprite *bs, Sprite *tile) { // Bullet.OnHasHitWall: DeSpawn (Fire Wand: in piu' solo con l'arcana Hellfire) (void)ctx, (void)tile; Bullet *b = bs->owner; if (!b->s.active) return; if (b->vt->OnHasHitWall) b->vt->OnHasHitWall(b, (Tile *)(void *)tile); else Bullet_DeSpawn(b); // piu' tile nello stesso passo: l'originale chiamerebbe DeSpawn di nuovo } static void base_OnStart(Weapon *w) { Weapon_ResetFiringTimer(w); physics_addOverlap(&w->pool->group, &Core.Enemies, Weapon_onBulletOverlapsEnemy, w); physics_addOverlap(&w->pool->group, &Core.Destructibles, Weapon_onBulletOverlapsDestuctible, w); if (w->hitsWalls && Core.Stage && Core.Stage->hasTileset) // wallsColliders for (int i = 0; i < n_CollisionLayers; i++) w->wallsColliders[w->n_wallsColliders++] = physics_addColliderLayerCb(&w->pool->group, CollisionLayers[i], Weapon_onBulletOverlapsWall, w); } static int base_LevelUp(Weapon *w) { cJSON *d = cJSON_GetArrayItem(w->data, w->level); if (!d) return 0; for (cJSON *it = d->child; it; it = it->next) { float *f = Weapon_field(w, it->string); if (f && cJSON_IsNumber(it)) *f += (float)it->valuedouble; } Weapon_ResetFiringTimer(w); w->level++; if (!w->isPowerUp) Weapon_Fire(w); if (has(d, "addEvolvedWeapon") && !w->skipAddingEvolution) LevelUpFactory_AddLateWeapon(str(d, "addEvolvedWeapon")); return 1; } static void base_Update(Weapon *w, float delta) { w->stats_lifetime += delta; } static void base_CheckArcanas(Weapon *w) { // Weapon.CheckArcanas (0xe49a): Beginning, +3 colpi alle armi del personaggio e alle loro evoluzioni if (w->beginningArcana) return; for (int i = 0; i < Arcanas.n_beginning; i++) if (!strcmp(Arcanas.beginning[i], w->bulletType)) { w->beginningArcana = 1, w->amount += 3; return; } } // --- W_HolyWater (0xe2b7) ----------------------------------------------------- static void shuffle(float *a, int n) { for (int i = n - 1; i > 0; i--) { int j = (int)floorf(frand() * (i + 1)); float t = a[i]; a[i] = a[j]; a[j] = t; } } static void W_HolyWater_ctor(Weapon *w) { w->maxAngles = 0xc; w->mul = 1000.0f / 6; float m = fminf(game_width, game_height); for (int i = 0; i < w->maxAngles; i++) { w->targetAngles[i] = 2 * PI * i / w->maxAngles; w->targetRadii[i] = 0.25f * m + 0.1f * m * ((float)i / w->maxAngles); } shuffle(w->targetRadii, w->maxAngles); } static int W_HolyWater_LevelUp(Weapon *w) { shuffle(w->targetRadii, w->maxAngles); return base_LevelUp(w); } static void W_HolyWater_Update(Weapon *w, float delta) { base_Update(w, delta); w->totalTime += delta; if (w->cooldownAffectedByMovement) w->totalTime += Core.Player->frameWalk * (delta / w->mul); if (w->totalTime >= Weapon_PInterval(w)) { w->totalTime -= Weapon_PInterval(w); Weapon_Fire(w); } } // --- W_Laurel (0x11fa3) ------------------------------------------------------- static Weapon *laurel_of[2]; #define laurel laurel_of[game_context] // laurel: ascolta l'evento Player_LostShield static void W_Laurel_CheckColor(Weapon *w) { w->image.visible = 1; switch ((int)Core.Player->shields) { default: case 0: w->image.visible = 0; break; case 1: w->image.tint = 0x8888ff; break; case 2: w->image.tint = 0x88ff88; break; case 3: w->image.tint = 0xffff00; break; } } static void W_Laurel_onLostShield(void *ctx) { W_Laurel_CheckColor(ctx); } static void W_Laurel_ctor(Weapon *w) { w->maxCharges = 3; sprite_init(&w->image, frame_get("vfx", "Shockwave2.png"), Core.Player->s.x, Core.Player->s.y); w->image.alpha = 0.3f; sprite_setScale(&w->image, 1.25f * PixelScale); w->image.visible = 0; children_add(&w->image); tweens_add((TweenConfig){ .props = { { &w->image.alpha, NULL, 0.6f } }, .nprops = 1, .loop = 1, .yoyo = 1, .duration = 0x7d0, .repeat = -1 }); tweens_add((TweenConfig){ .props = { { &w->image.angle, NULL, 0x168 } }, .nprops = 1, .loop = 1, .duration = 0x2ee0, .repeat = -1 }); laurel = w; PlayerEvents_add(EV_PLAYER_LOSTSHIELD, W_Laurel_onLostShield, w); // colorEvent } static float W_Laurel_PAmount(Weapon *w) { (void)w; return 1; } static void W_Laurel_Fire(Weapon *w) { Player *p = Core.Player; if (p->shields < w->charges && p->shields < w->maxCharges) p->shields += 1; W_Laurel_CheckColor(w); if (Arcanas.hasAstronomia) Arcanas_TriggerAstronomia(w); // hasThorns (Shroud): non usato dall'Alloro base if (w->lastFiringInterval != Weapon_PInterval(w)) { w->lastFiringInterval = Weapon_PInterval(w); Weapon_ResetFiringTimer(w); } } static void W_Laurel_OnStart(Weapon *w) { base_OnStart(w); time_addEvent(1, 0, 0, Weapon_FireCb, w); } static void W_Laurel_Update(Weapon *w, float delta) { base_Update(w, delta); w->image.x = Core.Player->s.x; w->image.y = Core.Player->s.y - 0x10; w->image.depth = Core.Player->s.depth - 0.5f * game_height; } static int W_Laurel_LevelUp(Weapon *w) { base_LevelUp(w); cJSON *d = cJSON_GetArrayItem(w->data, w->level - 1); if (!d) return 0; if (num(d, "shieldInvulTime", 0)) Core.Player->shieldInvulTime += num(d, "shieldInvulTime", 0); return 1; } // --- PowerUp (0x5dba) --------------------------------------------------------- static float *PowerUp_field(Weapon *w, const char *k) { static const struct { const char *k; size_t off; } F[] = { #define U(x) { #x, offsetof(Weapon, pu_##x) } U(power), U(area), U(speed), U(cooldown), U(amount), U(maxHp), U(moveSpeed), U(growth), U(magnet), U(luck), U(armor), U(duration), U(greed), U(regen), U(revivals), U(curse), U(rerolls), U(skips), U(banish), U(charm), #undef U }; for (size_t i = 0; i < sizeof(F) / sizeof(F[0]); i++) if (!strcmp(F[i].k, k)) return (float *)((char *)w + F[i].off); return NULL; } static void PowerUp_resetBonuses(Weapon *w) { w->pu_power = w->pu_area = w->pu_speed = w->pu_cooldown = w->pu_amount = w->pu_maxHp = w->pu_moveSpeed = w->pu_growth = w->pu_magnet = w->pu_luck = w->pu_armor = w->pu_duration = w->pu_greed = w->pu_regen = w->pu_revivals = w->pu_curse = w->pu_rerolls = w->pu_skips = w->pu_banish = w->pu_charm = 0; } static void PowerUp_Apply(Weapon *w) { Player *p = Core.Player; p->power += w->pu_power; p->area += w->pu_area; p->speed += w->pu_speed; p->cooldown += w->pu_cooldown; p->amount += w->pu_amount; p->moveSpeed += w->pu_moveSpeed; p->growth += w->pu_growth; p->luck += w->pu_luck; p->armor += w->pu_armor; p->duration += w->pu_duration; p->greed += w->pu_greed; p->regen += w->pu_regen; p->maxHp += p->maxHp * w->pu_maxHp; p->revivals += w->pu_revivals; p->curse += w->pu_curse; p->rerolls += w->pu_rerolls; p->skips += w->pu_skips; p->banish += w->pu_banish; p->charm += w->pu_charm; if (w->pu_magnet > 0) { Core.Magnet->radius += Core.Magnet->radius * w->pu_magnet; Magnet_RefreshSize(Core.Magnet); Core.Magnet->percentage += w->pu_magnet; } } // Le chiavi della tabella finiscono sui campi del PowerUp (che possiede power, armor...) e non su quelli dell'arma static void PowerUp_copy(Weapon *w, cJSON *d, int add) { for (cJSON *it = d ? d->child : NULL; it; it = it->next) { if (!strcmp(it->string, "level")) { if (!add && cJSON_IsNumber(it)) w->level = it->valueint; continue; } if (!strcmp(it->string, "isPowerUp")) { w->isPowerUp = cJSON_IsTrue(it); continue; } float *f = PowerUp_field(w, it->string); if (f && cJSON_IsNumber(it)) *f = add ? *f + (float)it->valuedouble : (float)it->valuedouble; } } static void PowerUp_MakeLevelOne(Weapon *w) { PowerUp_resetBonuses(w); w->level = 0; Weapon_MakeChanceArray(w); w->canCrit = 0; PowerUp_copy(w, cJSON_GetArrayItem(w->data, 0), 0); w->lastFiringInterval = Weapon_PInterval(w); if (Core.Player) PowerUp_Apply(w); } static int PowerUp_LevelUp(Weapon *w) { PowerUp_resetBonuses(w); cJSON *d = cJSON_GetArrayItem(w->data, w->level); if (!d) return 0; PowerUp_copy(w, d, 1); w->level++; PowerUp_Apply(w); return 1; } // --- Tabelle dei metodi ------------------------------------------------------- #define BASE .PArea = base_PArea, .PAmount = base_PAmount, .PPower = base_PPower, .PBounces = base_PBounces, .PInterval = base_PInterval, .Fire = base_Fire, \ .OnStart = base_OnStart, .Update = base_Update, .LevelUp = base_LevelUp, .MakeLevelOne = base_MakeLevelOne, \ .ResetFiringTimer = base_ResetFiringTimer, .onBulletOverlapsEnemy = base_onBulletOverlapsEnemy, .CheckArcanas = base_CheckArcanas static float W_Axe_PArea(Weapon *w) { return fminf(10, 1.3f * Core.Player->area) * w->area; } static void Weapon_StandardCritical(Weapon *w, Bullet *b, Enemy *e); // --- B_FlareExplosion (0x8355): l'esplosione RAYEXPLOSION (Twilight Requiem), un lampo orizzontale largo 256 * area --------- static void B_Flare_ctor(Bullet *b) { static const char *const dark[] = { "VESPERS", "SILF2", "MANNAGGIA", "BONE", "TRAPANO" }; // darkWeapons: esplosione scura b->isLight = 1; for (int i = 0; i < 5; i++) if (!strcmp(b->weapon->bulletType, dark[i])) b->isLight = 0; const char *imgs[4] = { "FlareStar1.png", "FlareSide1.png", "FlareFlat1.png", "s_pfx_rainbow_64w.png" }; Sprite *sp[4] = { &b->starSprite, &b->sideSprite, &b->flatSprite, &b->exploSprite }; for (int i = 0; i < 4; i++) { sprite_init(sp[i], frame_get("vfx", imgs[i]), b->s.x, b->s.y); sp[i]->visible = 0, sp[i]->blendAdd = 1; sprite_setScale(sp[i], 0.5f); children_add(sp[i]); } sprite_setOrigin(&b->sideSprite, 1, 0.5f); sprite_setScale(&b->exploSprite, 1), b->exploSprite.alpha = 0.25f, b->exploSprite.angle = 0x5a; b->Pfx = particles_add(); b->PfxEmitter = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "WhiteDot.png") }, .nframes = 1, .quantity = 0xa, .lifespan = EOP(0xfa), .alpha = ERANGE(0.7f, 0), .angle = { 0, 0x168, 1 }, .angleSteps = 2, .speed = ERND(0xc8, 0x190), .scale = ERANGE(1, 0), .tint = b->isLight ? 0xffffff : 0x220022, .flowEveryFrame = 1, .on = 0 }); b->s.visible = 0; b->scaleTween = b->fadeOutTween = (TweenRef){ -1, 0 }; } static void B_Flare_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void B_Flare_fadeOut(void *ctx) { Bullet *b = ctx; b->s.body.enable = 0; emitter_stop(b->PfxEmitter); b->fadeOutTween = tweens_add((TweenConfig){ .props = { { &b->s.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x12c, .onComplete = B_Flare_despawn, .ctx = b }); } static void B_Flare_exploHide(void *ctx) { ((Bullet *)ctx)->exploSprite.visible = 0; } static const char *pickOf(const char *const *a, int n) { return a[(int)floorf(frand() * n)]; } static void B_Flare_OnRecycle(Bullet *b) { static const char *const sides[5] = { "FlareSide1.png", "FlareSide2.png", "FlareCircle1.png", "FlareCircle2.png", "FlareCircle3.png" }, *const stars[6] = { "FlareStar1.png", "FlareStar2.png", "FlareStar3.png", "FlareStar4.png", "FlareStar5.png", "FlareStar6.png" }, *const flats[5] = { "FlareFlat1.png", "FlareFlat2.png", "FlareFlat3.png", "FlareFlat4.png", "FlareFlat5.png" }; Weapon *w = b->weapon; float a = Weapon_PArea(w), x = b->s.x, y = b->s.y; Bullet_OnRecycle(b); b->s.body.enable = 1; body_setSize(&b->s.body, 1, 0x20); b->s.visible = 0, b->s.alpha = 1; sprite_setFrame(&b->starSprite, frame_get("vfx", pickOf(stars, 6))); sprite_setFrame(&b->sideSprite, frame_get("vfx", pickOf(sides, 5))); sprite_setFrame(&b->flatSprite, frame_get("vfx", pickOf(flats, 5))); Sprite *sp[4] = { &b->starSprite, &b->sideSprite, &b->flatSprite, &b->exploSprite }; for (int i = 0; i < 4; i++) sp[i]->x = x, sp[i]->y = y; sprite_setScale(&b->starSprite, 0.5f * a), sprite_setScale(&b->sideSprite, 0.5f * a), sprite_setScale(&b->flatSprite, 0.5f * a); b->PfxEmitter->x = x, b->PfxEmitter->y = y; b->PfxEmitter->c.speed = ERND(0xc8 * a, 0x190 * a); emitter_start(b->PfxEmitter); // Explode float big = 0x100 * a; tween_stop(b->scaleTween); b->s.scaleX = b->s.scaleY = 1; // onStart: setScale(1, 1) b->scaleTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, NULL, big } }, .nprops = 1, .duration = 0x96, .onComplete = B_Flare_fadeOut, .ctx = b }); b->flatSprite.alpha = 0, b->flatSprite.visible = 1; // FlashingVFXEnabled: lampo piatto, scintilla laterale, stella tweens_add((TweenConfig){ .props = { { &b->flatSprite.alpha, NULL, 1 }, { &b->flatSprite.scaleX, &b->flatSprite.scaleY, 0.7f * a } }, .nprops = 2, .duration = 0x96, .yoyo = 1 }); b->sideSprite.alpha = 0, b->sideSprite.visible = 1; tweens_add((TweenConfig){ .props = { { &b->sideSprite.alpha, NULL, 1 }, { &b->sideSprite.x, NULL, x + 0x20 * a } }, .nprops = 2, .duration = 0x96, .yoyo = 1 }); b->starSprite.alpha = 0, b->starSprite.angle = 0, b->starSprite.visible = 1; tweens_add((TweenConfig){ .props = { { &b->starSprite.alpha, NULL, 1 }, { &b->starSprite.angle, NULL, 0x168 }, { &b->starSprite.x, NULL, x - 0x10 * a } }, .nprops = 3, .duration = 0x96, .yoyo = 1 }); b->exploSprite.scaleX = 1, b->exploSprite.scaleY = 0, b->exploSprite.visible = 1; tweens_add((TweenConfig){ .props = { { &b->exploSprite.scaleY, NULL, big / 0x34 }, { &b->exploSprite.scaleX, NULL, 1 } }, .nprops = 2, .duration = 0x96, .onComplete = B_Flare_exploHide, .ctx = b }); Sound_PlaySound("Flare", 0.8f, 1, -0x64 * b->indexInWeapon, 0xc8, 1); } static void B_Flare_DeSpawn(Bullet *b) { base_DeSpawn(b); tween_stop(b->fadeOutTween); } static const BulletVT B_FlareExplosion = { "vfx", "WhiteDot.png", B_Flare_ctor, NULL, B_Flare_OnRecycle, NULL, NULL, B_Flare_DeSpawn }; // Weapon.SpawnExplosionAt (0xe49a): il pool secondario nasce al primo uso, con la classe di explosionType static float base_SecondaryPPower(Weapon *w) { return fminf(10, (Arcanas.silentMight + Core.Player->power) * sinev(Core.Player->sineMight)) * w->secondaryPower + Arcanas.bloodlineDamage; } static float Weapon_SecondaryPPower(Weapon *w) { return w->vt->SecondaryPPower ? w->vt->SecondaryPPower(w) : base_SecondaryPPower(w); } static float power_noBloodline(Weapon *w) { return fminf(10, (Arcanas.silentMight + Core.Player->power) * sinev(Core.Player->sineMight)) * w->power; } // HolyBook, Vespers, Bone static void Weapon_onSecondaryBulletOverlapsEnemy(void *ctx, Sprite *bs, Sprite *es) { // ...Curse: SecondaryCursePPower (secondaryPower * PCurse) Weapon *w = ctx; Enemy *e = es->owner; if (e->isDead || Bullet_HasAlreadyHitObject(bs->owner, e, e->isDead)) return; float p = w->secondaryCurse ? fminf(10, (Arcanas.silentMight + Core.Player->power) * sinev(Core.Player->sineMight)) * w->secondaryPower * Player_PCurse(Core.Player) + Arcanas.bloodlineDamage : Weapon_SecondaryPPower(w); Enemy_GetDamaged(e, p, (int)w->hitVFX, w->knockback, w->bulletType); w->stats_inflictedDamage += p; } static const BulletVT B_FireExplosion, B_ColdExplosion; static void Weapon_onBulletOverlapsDestuctible(void *ctx, Sprite *bs, Sprite *ds); static const BulletVT B_Millionaire; static Bullet *Weapon_SpawnExplosionAt(Weapon *w, float x, float y, int index) { if (!w->secondaryPool) { const BulletVT *vt = !strcmp(w->explosionType, "FIREEXPLOSION") ? &B_FireExplosion : !strcmp(w->explosionType, "COLDEXPLOSION") ? &B_ColdExplosion : !strcmp(w->explosionType, "SEC_MILLIONAIRE") ? &B_Millionaire : &B_FlareExplosion; w->secondaryPool = BulletPool_new(w, vt); physics_addOverlap(&w->secondaryPool->group, &Core.Enemies, Weapon_onSecondaryBulletOverlapsEnemy, w); physics_addOverlap(&w->secondaryPool->group, &Core.Destructibles, Weapon_onBulletOverlapsDestuctible, w); } return BulletPool_SpawnAt(w->secondaryPool, x, y, w, index); } static int Weapon_CheckFreeze(Weapon *w) { return w->critChancesArray[w->critIndex++ % 1000] < w->freezeChance * Player_PLuck(Core.Player); } static int Enemy_Freeze(void *o, float duration, float chance); static void Bullet_TryFreeze(Bullet *b, void *o) { // Bullet.TryFreeze: solo i nemici hanno Freeze if (!Weapon_CheckFreeze(b->weapon) || !(((Sprite *)o)->groups & Core.Enemies.bit)) return; if (Enemy_Freeze(o, Weapon_PDuration(b->weapon), b->weapon->freezeChance) && Arcanas_has(12)) Arcanas_TriggerCold(((Sprite *)o)->x, ((Sprite *)o)->y); } static void Bullet_explodeMany(Bullet *b) { // HolyBook / Vespers: SecondaryPAmount esplosioni sfalsate (offset solo positivi, sic) Weapon *w = b->weapon; int n = (int)Weapon_PAmount(w); if (!b->requiem) { // requiemRandomOffsets: 500 valori fatti nel costruttore b->requiem = gmem_calloc(0x1f4, sizeof(float)); for (int i = 0; i < 0x1f4; i++) b->requiem[i] = 0.5f * frand() * 0x20; } for (int i = 0; i < n; i++) { float ox = b->requiem[b->requiemIndex++ % 0x1f4], oy = b->requiem[b->requiemIndex++ % 0x1f4]; Weapon_SpawnExplosionAt(w, b->s.x + ox * Weapon_PArea(w), b->s.y + oy * Weapon_PArea(w), i); } } // --- CheckArcanas delle armi (A4): i flag che le arcane accendono; le armi delle arcane (fuoco, freddo, Gemini...) in A4.2 #define ARC_T(t) Arcanas_has(t) static void IronBlue_noWalls(Weapon *w) { // removeCollider(wallsColliders): i muri non fermano piu' i colpi w->penetrating = 0xffff, w->hitsWalls = 0; for (int i = 0; i < w->n_wallsColliders; i++) if (w->wallsColliders[i]) w->wallsColliders[i]->active = 0; } static void CA_tragic(Weapon *w) { if (ARC_T(3)) w->cooldownAffectedByMovement = 1; base_CheckArcanas(w); } static void CA_twilight(Weapon *w) { if (ARC_T(2)) w->explodeOnExpire = 1; base_CheckArcanas(w); } static void CA_slash(Weapon *w) { if (ARC_T(16)) w->canCrit = 1; base_CheckArcanas(w); } static void CA_tragicTwilight(Weapon *w) { if (ARC_T(3)) w->cooldownAffectedByMovement = 1; if (ARC_T(2)) w->explodeOnExpire = 1; base_CheckArcanas(w); } static void CA_jewels(Weapon *w) { if (ARC_T(14)) w->freezeChance = 0.25f; base_CheckArcanas(w); } static void CA_twilightJewels(Weapon *w) { if (ARC_T(2)) w->explodeOnExpire = 1; if (ARC_T(14)) w->freezeChance = 0.25f; base_CheckArcanas(w); } static void CA_cross(Weapon *w) { if (ARC_T(11)) w->bonusBounces = 2; base_CheckArcanas(w); } // anche HeavenSword #define FIREW Arcanas.FireExplosionWeapon // Aquarius (Gemini): LevelUp delle armi con counterWeapon tira su anche la gemella (Guns, Guns2, Silf, Gatti, Grangatti, Guns3, Silf3) static int Weapon_LevelUp(Weapon *w) { int r = w->vt->LevelUp(w); if (w->counterWeapon) Weapon_LevelUp(w->counterWeapon); if (w->counterWeapon2) Weapon_LevelUp(w->counterWeapon2); return r; } static Weapon *Core_GetHiddenWeapon(const char *type) { for (int i = 0; i < Core.n_HiddenWeapons; i++) if (!strcmp(Core.HiddenWeapons[i]->bulletType, type)) return Core.HiddenWeapons[i]; return NULL; } static void Weapon_LevelUpNow(Weapon *w) { w->vt->LevelUp(w); } static Weapon *Aquarius_Add(const char *type, int toLevel) { // AddHiddenWeapon + LevelUp fino al livello (l'originale non si ferma: qui si', a fine dati) Weapon *c = Core_AddHiddenWeapon(type); while (c && c->level < toLevel && Weapon_LevelUp(c)) {} return c; } static void CA_hellfire(Weapon *w) { if (ARC_T(19) && FIREW) FIREW->power = 0.5f * w->power; if (ARC_T(11)) w->bonusBounces = 1; base_CheckArcanas(w); } static void CA_fireball(Weapon *w) { if (ARC_T(19) && FIREW) FIREW->power = 0.5f * w->power; if (ARC_T(11)) w->bonusBounces = 3; base_CheckArcanas(w); } static void CA_fireAtLeast(Weapon *w) { if (ARC_T(19) && FIREW && FIREW->power < 0.5f * w->power) FIREW->power = 0.5f * w->power; } // Trapano2, Guns static void CA_trapano2(Weapon *w) { CA_fireAtLeast(w); base_CheckArcanas(w); } static void CA_magicMissile(Weapon *w) { if (ARC_T(11)) w->bonusBounces = 3; if (ARC_T(14)) w->freezeChance = 0.25f; base_CheckArcanas(w); } static void CA_holyWand(Weapon *w) { if (ARC_T(11)) w->bonusBounces = 3, w->penetrating = 0xffff; if (ARC_T(14)) w->freezeChance = 0.25f; base_CheckArcanas(w); } static void CA_knife(Weapon *w) { if (ARC_T(7)) IronBlue_noWalls(w), w->bonusBounces = 3; if (ARC_T(16)) w->canCrit = 1; base_CheckArcanas(w); } static void CA_axe(Weapon *w) { if (ARC_T(7)) w->penetrating = 0xffff, w->bonusBounces = 3; if (ARC_T(16)) w->canCrit = 1; base_CheckArcanas(w); } static void CA_scythe(Weapon *w) { if (ARC_T(7)) w->penetrating = 0xffff, w->bonusBounces = 1; if (ARC_T(16)) w->canCrit = 1; base_CheckArcanas(w); } static void CA_guns(Weapon *w) { if (ARC_T(7)) IronBlue_noWalls(w), w->bonusBounces = 1; CA_fireAtLeast(w); if (ARC_T(1)) { // (sic) con la gemella gia' presente si esce senza super.CheckArcanas if (Core_GetHiddenWeapon("GUNS_COUNTER")) return; w->counterWeapon = Aquarius_Add("GUNS_COUNTER", w->level); } base_CheckArcanas(w); } static void CA_gunsCounter(Weapon *w) { if (ARC_T(7)) IronBlue_noWalls(w), w->bonusBounces = 1; CA_fireAtLeast(w); } // niente super static void CA_guns2Counter(Weapon *w) { if (ARC_T(7)) IronBlue_noWalls(w), w->bonusBounces = 1; if (ARC_T(14)) w->freezeChance = 0.25f; } static void CA_guns2(Weapon *w) { if (ARC_T(7)) IronBlue_noWalls(w), w->bonusBounces = 1; if (ARC_T(14)) w->freezeChance = 0.25f; if (ARC_T(1)) { if (Core_GetHiddenWeapon("GUNS2_COUNTER")) return; w->counterWeapon = Aquarius_Add("GUNS2_COUNTER", w->level); } base_CheckArcanas(w); } static void CA_silf(Weapon *w) { // Silf e Silf2 (Silf2 eredita: Twilight compreso) if (ARC_T(2)) w->explodeOnExpire = 1; if (ARC_T(1)) { const char *t = w->silf2 ? "SILF2_COUNTER" : "SILF_COUNTER"; if (Core_GetHiddenWeapon(t)) return; Weapon *c = Core_AddHiddenWeapon(t); if (c) c->totalTime = w->totalTime, c->angleTime = w->angleTime; w->counterWeapon = c; while (c && c->level < w->level && Weapon_LevelUp(c)) {} } base_CheckArcanas(w); } static void CA_silfCounter(Weapon *w) { if (ARC_T(14)) w->freezeChance = 0.25f; } static void CA_none(Weapon *w) { (void)w; } // W_Silf2_Counter, W_Gatti_Counter: CheckArcanas vuoto static void CA_silf3(Weapon *w) { if (ARC_T(1)) { const char *t[2] = { "SILF_COUNTER", "SILF2_COUNTER" }; Weapon **cw[2] = { &w->counterWeapon, &w->counterWeapon2 }; for (int k = 0; k < 2; k++) { if (Core_GetHiddenWeapon(t[k])) continue; Weapon *c = Core_AddHiddenWeapon(t[k]); if (c) c->totalTime = w->totalTime, c->angleTime = w->angleTime + PI; // (sic) Math.PI millisecondi *cw[k] = c; while (c && c->level < w->level && Weapon_LevelUp(c)) {} } } base_CheckArcanas(w); } static void W_Guns3_counterReset(void *ctx) { Weapon_ResetFiringTimer(ctx); } static void CA_guns3(Weapon *w) { if (ARC_T(1)) { if (!Core_GetHiddenWeapon("GUNS_COUNTER")) w->counterWeapon = Aquarius_Add("GUNS_COUNTER", 8); if (!Core_GetHiddenWeapon("GUNS2_COUNTER")) { Weapon *c = w->counterWeapon2 = Aquarius_Add("GUNS2_COUNTER", 8); if (c) time_addEvent(0.5f * c->repeatInterval, 0, 0, W_Guns3_counterReset, c); } } base_CheckArcanas(w); } static void CA_gatti(Weapon *w) { if (ARC_T(1)) { if (Core_GetHiddenWeapon("GATTI_COUNTER")) return; w->counterWeapon = Aquarius_Add("GATTI_COUNTER", w->level); } base_CheckArcanas(w); } static const char *const CATS6[6] = { "cat_i0", "cat3_i0", "cat2_i0", "cat4_i0", "cat6_i0", "cat5_i0" }; static void CA_grangatti(Weapon *w) { if (ARC_T(1)) { Weapon *c = Core_GetHiddenWeapon("GATTI_COUNTER"); if (c) { c->catBaseFrames = CATS6, c->nCatBaseFrames = 6; return; } c = Core_AddHiddenWeapon("GATTI_COUNTER"); if (c) c->catBaseFrames = CATS6, c->nCatBaseFrames = 6; w->counterWeapon = c; while (c && c->level < 8 && Weapon_LevelUp(c)) {} } base_CheckArcanas(w); } static void CA_nduja(Weapon *w) { if (ARC_T(1)) { if (Core_GetHiddenWeapon("NDUJA_COUNTER")) return; w->counterWeapon = Aquarius_Add("NDUJA_COUNTER", w->level); } base_CheckArcanas(w); } static void CA_triace(Weapon *w) { if (ARC_T(14)) w->freezeChance = 0.25f; if (strcmp(w->bulletType, "TRIASSO1") && ARC_T(2)) w->explodeOnExpire = 1; if (strcmp(w->bulletType, "TRIASSO1") && strcmp(w->bulletType, "TRIASSO2") && ARC_T(19) && FIREW) FIREW->power = fmaxf(0.5f * w->power, FIREW->power); base_CheckArcanas(w); } static void CA_inverseBeginning(Weapon *w) { // Carrello, Bone, Cherry, Flower, La Robba: (sic) +1 colpo alle armi FUORI dalla lista di Beginning base_CheckArcanas(w); if (!w->beginningArcana && Arcanas.n_beginning > 0) { int in = 0; for (int i = 0; i < Arcanas.n_beginning; i++) in |= !strcmp(Arcanas.beginning[i], w->bulletType); if (!in) w->beginningArcana = 1, w->amount += 1; } if (ARC_T(2)) w->explodeOnExpire = 1; } static void CA_cart2(Weapon *w) { if (ARC_T(3)) w->cooldownAffectedByMovement = 1; w->bonusBounces = (ARC_T(11) ? 3 : 0) + (ARC_T(7) ? 3 : 0); CA_inverseBeginning(w); } static void W_canCrit_onBulletOverlapsEnemy(Weapon *w, Bullet *b, Enemy *e) { // this.canCrit ? StandardCritical : super.onBulletOverlapsEnemy if (w->canCrit) Weapon_StandardCritical(w, b, e); else base_onBulletOverlapsEnemy(w, b, e); } static const WeaponVT W_Whip = { BASE, .bullet = &B_Whip, .CheckArcanas = CA_slash, .onBulletOverlapsEnemy = W_canCrit_onBulletOverlapsEnemy }; static const WeaponVT W_MagicMissile = { BASE, .CheckArcanas = CA_magicMissile, .bullet = &B_MagicMissile, .PBounces = bonus_PBounces }; static const WeaponVT W_Knife = { BASE, .CheckArcanas = CA_knife, .onBulletOverlapsEnemy = W_canCrit_onBulletOverlapsEnemy, .bullet = &B_Knife, .PBounces = bonus_PBounces }; static const WeaponVT W_Axe = { BASE, .CheckArcanas = CA_axe, .onBulletOverlapsEnemy = W_canCrit_onBulletOverlapsEnemy, .bullet = &B_Axe, .PBounces = bonus_PBounces, .PArea = W_Axe_PArea }; static const WeaponVT W_HolyBook = { BASE, .PPower = armor_PPower, .SecondaryPPower = power_noBloodline, .CheckArcanas = CA_twilight, .bullet = &B_HolyBook }; static const WeaponVT W_HolyWater = { BASE, .PPower = armor_PPower, .CheckArcanas = CA_tragic, .bullet = &B_HolyWater, .ctor = W_HolyWater_ctor, .LevelUp = W_HolyWater_LevelUp, .Update = W_HolyWater_Update, .ResetFiringTimer = noop_ResetFiringTimer }; static const WeaponVT W_Laurel = { BASE, .bullet = &B_Whip, .ctor = W_Laurel_ctor, .PAmount = W_Laurel_PAmount, .Fire = W_Laurel_Fire, .OnStart = W_Laurel_OnStart, .Update = W_Laurel_Update, .LevelUp = W_Laurel_LevelUp }; // W_HolyWand (0xf87): MagicMissile con PBounces; il suo B_HolyWand (0xf422) estende B_MagicMissile senza cambiare nulla static const WeaponVT W_HolyWand = { BASE, .CheckArcanas = CA_holyWand, .bullet = &B_MagicMissile, .PBounces = bonus_PBounces }; // THOUSAND: stessa classe di KNIFE (0x1f5a) e stesso bullet (0x9225) // W_Scythe (0xd99a): PArea con 1.2 invece dell'1.3 dell'ascia static float W_Scythe_PArea(Weapon *w) { return fminf(10, 1.2f * Core.Player->area) * w->area; } static const WeaponVT W_Scythe = { BASE, .CheckArcanas = CA_scythe, .onBulletOverlapsEnemy = W_canCrit_onBulletOverlapsEnemy, .bullet = &B_Scythe, .PBounces = bonus_PBounces, .PArea = W_Scythe_PArea }; // canCrit (StandardCritical) solo con l'arcana Mad Groove // W_Vespers (0x14936): SecondaryPPower/explodeOnExpire servono solo con l'arcana Twilight Requiem static const WeaponVT W_Vespers = { BASE, .SecondaryPPower = power_noBloodline, .CheckArcanas = CA_twilight, .bullet = &B_Vespers }; // W_Vampirica (0xd684): un critico cura 8 HP, al massimo una volta ogni healDelay static void W_Vampirica_ctor(Weapon *w) { w->canHeal = 1; w->healDelay = 0x3e8; } static void W_Vampirica_heal(void *ctx) { ((Weapon *)ctx)->canHeal = 1; } static void W_Vampirica_onBulletOverlapsEnemy(Weapon *w, Bullet *b, Enemy *e) { if (e->isDead) return; float crit = frand() < w->critChance * Player_PLuck(Core.Player) ? w->critMul * Arcanas.CritMul : 1; // PLuck if (crit > 1 && w->canHeal) { w->canHeal = 0; Player_RecoverHp(Core.Player, 8, 1, 0); w->healTimer = time_addEvent(w->healDelay, 0, 0, W_Vampirica_heal, w); } if (!Bullet_HasAlreadyHitObject(b, e, e->isDead)) { float p = Weapon_PPower(w) * crit; Enemy_GetDamaged(e, p, (int)w->hitVFX, w->knockback, w->bulletType); w->stats_inflictedDamage += p; } } static const WeaponVT W_Vampirica = { BASE, .CheckArcanas = CA_slash, .bullet = &B_Vampirica, .ctor = W_Vampirica_ctor, .onBulletOverlapsEnemy = W_Vampirica_onBulletOverlapsEnemy }; // W_Bora (0x8c61): spara da Update come HolyWater; i bersagli sono i 12 punti di un'ellisse static void W_Bora_ctor(Weapon *w) { w->maxAngles = 0xc; w->mul = 1000.0f / 3; float r = 0.5f * 0x1c8; // GAMEPLAY_PIXEL_HEIGHT for (int i = 0; i < 0xc; i++) { // new Ellipse(0, 0, GAMEPLAY_PIXEL_HEIGHT, GAMEPLAY_PIXEL_WIDTH).getPoints(12) float a = 2 * PI * ((float)i / 0xc); w->targetPoints[i] = (Vector2){ 0.5f * 0x1c8 * cosf(a), 0.5f * 0x156 * sinf(a) }; } for (int i = 0; i < w->maxAngles; i++) w->targetAngles[i] = 2 * PI * i / w->maxAngles, w->targetRadii[i] = r; shuffle(w->targetRadii, w->maxAngles); } static const WeaponVT W_Bora = { BASE, .CheckArcanas = CA_tragic, .bullet = &B_Bora, .ctor = W_Bora_ctor, .LevelUp = W_HolyWater_LevelUp, .Update = W_HolyWater_Update, .ResetFiringTimer = noop_ResetFiringTimer }; // cooldownAffectedByMovement: solo con l'arcana Tragic Princess // W_Cross (0x10856): PPower + bloodlineArmorValue, PBounces con bonusBounces (Pearls) static const WeaponVT W_Cross = { BASE, .PPower = armor_PPower, .CheckArcanas = CA_cross, .bullet = &B_Cross, .PBounces = bonus_PBounces }; // W_HeavenSword (0x29d2): critico senza StandardCritical static void W_crit_onBulletOverlapsEnemy(Weapon *w, Bullet *b, Enemy *e) { if (e->isDead) return; float crit = frand() < w->critChance * Player_PLuck(Core.Player) ? w->critMul * Arcanas.CritMul : 1; if (!Bullet_HasAlreadyHitObject(b, e, e->isDead)) { float p = Weapon_PPower(w) * crit; Enemy_GetDamaged(e, p, (int)w->hitVFX, w->knockback, w->bulletType); w->stats_inflictedDamage += p; } } static const WeaponVT W_HeavenSword = { BASE, .CheckArcanas = CA_cross, .bullet = &B_HeavenSword, .PBounces = bonus_PBounces, .onBulletOverlapsEnemy = W_crit_onBulletOverlapsEnemy }; // W_Fireball (0xa894) / W_Hellfire (0x1e1f): Fire sceglie un nemico a caso (RND.pick: lista vuota = nessun bersaglio) static void W_Fireball_Fire(Weapon *w) { w->target = Core.Enemies.n ? Core.Enemies.items[(int)floorf(frand() * Core.Enemies.n)] : NULL; Sound_PlaySound("MagicMissile", 0.2f, 1, 0, 0xc8, 0xa); base_Fire(w); } static void W_Hellfire_Fire(Weapon *w) { // EnemyGroup.children.entries w->target = Core.EnemyGroup.n ? Core.EnemyGroup.items[(int)floorf(frand() * Core.EnemyGroup.n)] : NULL; Sound_PlaySound("MagicMissile", 0.2f, 1, 0, 0xc8, 0xa); base_Fire(w); } static const WeaponVT W_Fireball = { BASE, .CheckArcanas = CA_fireball, .bullet = &B_Fireball, .PBounces = bonus_PBounces, .Fire = W_Fireball_Fire }; static const WeaponVT W_Hellfire = { BASE, .CheckArcanas = CA_hellfire, .bullet = &B_Hellfire, .PBounces = bonus_PBounces, .Fire = W_Hellfire_Fire }; // W_Garlic (0x4a36): spara da Update ogni PInterval; un anello additivo che pulsa e gira attorno al giocatore static float one_PAmount(Weapon *w) { (void)w; return 1; } static void W_Garlic_ctor(Weapon *w) { w->mul = 1000.0f / 6; sprite_init(&w->image, frame_get("vfx", "Rings3.png"), Core.Player->s.x, Core.Player->s.y); w->image.blendAdd = 1; w->image.alpha = 0.1f; sprite_setScale(&w->image, 2 * PixelScale * fminf(10, Core.Player->area) * 1); // PArea prima di MakeLevelOne: area = 1 children_add(&w->image); // semplificazione: loopDelay 100 ms del primo tween non tradotto (yoyo continuo) tweens_add((TweenConfig){ .props = { { &w->image.alpha, NULL, 0.3f } }, .nprops = 1, .loop = 1, .yoyo = 1, .duration = 0x3e8, .repeat = -1 }); tweens_add((TweenConfig){ .props = { { &w->image.angle, NULL, 0x168 } }, .nprops = 1, .loop = 1, .duration = 0x1770, .repeat = -1 }); } static void W_Garlic_Fire(Weapon *w) { sprite_setScale(&w->image, 2 * PixelScale * Weapon_PArea(w)); if (Arcanas.hasAstronomia) Arcanas_TriggerAstronomia(w); base_Fire(w); } static void W_Garlic_Update(Weapon *w, float delta) { base_Update(w, delta); w->image.x = Core.Player->s.x, w->image.y = Core.Player->s.y; w->image.depth = Core.Player->s.depth - 0.5f * game_height; sprite_setScale(&w->image, 2 * PixelScale * Weapon_PArea(w)); w->totalTime += delta; if (w->cooldownAffectedByMovement) w->totalTime += Core.Player->frameWalk * (delta / w->mul); if (w->totalTime >= Weapon_PInterval(w)) { w->totalTime -= Weapon_PInterval(w); Weapon_Fire(w); } } static const WeaponVT W_Garlic = { BASE, .PPower = armor_PPower, .CheckArcanas = CA_tragic, .bullet = &B_Garlic, .ctor = W_Garlic_ctor, .PAmount = one_PAmount, .Fire = W_Garlic_Fire, .Update = W_Garlic_Update, .ResetFiringTimer = noop_ResetFiringTimer }; // W_Vortex (0x101f3, Soul Eater): un buco nero che si richiude, potenza dagli HP recuperati, cuoricini dai nemici uccisi static void W_Vortex_ctor(Weapon *w) { w->imageScale = 36.0f / 256; w->mul = 1000.0f / 6; float sc = 2 * PixelScale * fminf(10, Core.Player->area) * 1 * w->imageScale; sprite_init(&w->image2, frame_get("vfx", "circle.png"), Core.Player->s.x, Core.Player->s.y); // imageBG w->image2.alpha = 0.6f, w->image2.tint = 0; sprite_setScale(&w->image2, sc); children_add(&w->image2); sprite_init(&w->image, frame_get("vfx", "circle.png"), Core.Player->s.x, Core.Player->s.y); w->image.alpha = 0.1f, w->image.tint = 0; sprite_setScale(&w->image, sc); children_add(&w->image); tweens_add((TweenConfig){ .props = { { &w->image.alpha, NULL, 0.6f } }, .nprops = 1, .loop = 1, .yoyo = 1, .duration = 0x3e8, .repeat = -1 }); Core.Player->onHPRecovery = w; w->vortexPfx = particles_add(); particles_createEmitter(w->vortexPfx, (EmitterConfig){ .frames = { frame_get("vfx", "PfxColor2.png") }, .nframes = 1, .frameCycle = 1, .lifespan = EOP(0x1f4), .speed = EOP(0), .scale = ERANGE(1, 0), .alpha = EOP(0.2f), .blendAdd = 1, .rotate = ERANGE(0, 0x168), .hasZone = 1, .zoneRadius = 0x3c, .on = 0 }); // semplificazione: rotate con ease Bounce.easeOut, qui lineare (punti di 3 px) w->vortexPfx->hasWell = 1; // createGravityWell({ power: 0.51, epsilon: 20, gravity: 50 }) w->vortexPfx->wellPower = 0.51f * 0x32, w->vortexPfx->wellEpsilon = 0x14 * 0x14; w->innerDuration = 0x1770; } static float W_Vortex_PPower(Weapon *w) { return base_PPower(w) + w->recoveredCalculated; } static void W_Vortex_Fire(Weapon *w) { w->recoveredCalculated = fminf(6, w->recoveredHP / 0x258); if (Arcanas.hasAstronomia) Arcanas_TriggerAstronomia(w); base_Fire(w); } static void W_Vortex_Update(Weapon *w, float delta) { base_Update(w, delta); w->totalTime += delta; Sprite *im = &w->image, *bg = &w->image2; // VortexUpdate im->x = bg->x = Core.Player->s.x, im->y = bg->y = Core.Player->s.y; im->depth = bg->depth = Core.Player->s.depth - 0.5f * game_height; emitter_emitParticleAt(w->vortexPfx->emitters[0], im->x, im->y, 0); w->vortexPfx->wellX = im->x, w->vortexPfx->wellY = im->y; sprite_setScale(bg, 2 * PixelScale * Weapon_PArea(w) * w->imageScale); w->vfxTime += delta; if (w->vfxTime > w->innerDuration) w->vfxTime = 0; w->innerScale = Weapon_PArea(w) * ((w->innerDuration - w->vfxTime) / w->innerDuration); sprite_setScale(im, 2 * PixelScale * w->innerScale * w->imageScale); w->vortexPfx->emitters[0]->c.zoneRadius = 0x10 * Weapon_PArea(w) * 2; // shape1.radius if (w->cooldownAffectedByMovement) w->totalTime += Core.Player->frameWalk * (delta / w->mul); if (w->totalTime >= Weapon_PInterval(w)) { w->totalTime -= Weapon_PInterval(w); Weapon_Fire(w); } } static void W_Vortex_onBulletOverlapsEnemy(Weapon *w, Bullet *b, Enemy *e) { if (e->isDead || Bullet_HasAlreadyHitObject(b, e, e->isDead)) return; Enemy_GetDamaged(e, Weapon_PPower(w), (int)w->hitVFX, w->knockback, w->bulletType); w->stats_inflictedDamage += Weapon_PPower(w); if (!e->isDead) return; float r = frand(); if (Weapon_PPower(w) / 7 * 0.15f > r) { float o = 0xa * (r - 0.5f); Pickup *h = Core_MakePickup(e->s.x + o, e->s.y - o, "LITTLEHEART"); if (h) h->goToPlayer = 1, h->time = 1; } } static const WeaponVT W_Vortex = { BASE, .CheckArcanas = CA_tragic, .bullet = &B_Garlic, .ctor = W_Vortex_ctor, .PAmount = one_PAmount, .PPower = W_Vortex_PPower, .Fire = W_Vortex_Fire, .Update = W_Vortex_Update, .ResetFiringTimer = noop_ResetFiringTimer, .onBulletOverlapsEnemy = W_Vortex_onBulletOverlapsEnemy }; // B_Vortex (0x593) e B_Garlic (0x6fd9) sono identici a parte il nome // W_Diamond (0xc916, Runetracer): bersaglio a caso; danno come la base (onBulletOverlapsEnemy ridefinito identico) static void W_Diamond_Fire(Weapon *w) { w->target = Core.Enemies.n ? Core.Enemies.items[(int)floorf(frand() * Core.Enemies.n)] : NULL; base_Fire(w); } static const WeaponVT W_Diamond = { BASE, .CheckArcanas = CA_twilightJewels, .bullet = &B_Diamond, .Fire = W_Diamond_Fire }; // W_SilverWind (0xf6a6) / W_SilverWind2 (0xc271): i nemici uccisi possono lasciare un cuore static void W_SilverWind_onBulletOverlapsEnemy(Weapon *w, Bullet *b, Enemy *e) { if (e->isDead || Bullet_HasAlreadyHitObject(b, e, e->isDead)) return; Enemy_GetDamaged(e, Weapon_PPower(w), (int)w->hitVFX, w->knockback, w->bulletType); w->stats_inflictedDamage += Weapon_PPower(w); if (!e->isDead) return; float c = w->critChancesArray[w->critIndex % 1000]; w->critIndex++; if (c <= w->chance * Player_PLuck(Core.Player)) { Pickup *h = Core_MakePickup(e->s.x, e->s.y, "LITTLEHEART"); if (h) h->goToPlayer = 1, h->time = 1, h->quiet = 1; } } static const WeaponVT W_SilverWind = { BASE, .PPower = armor_PPower, .CheckArcanas = CA_twilight, .bullet = &B_SilverWind, .onBulletOverlapsEnemy = W_SilverWind_onBulletOverlapsEnemy }; static const WeaponVT W_SilverWind2 = { BASE, .PPower = armor_PPower, .CheckArcanas = CA_twilight, .bullet = &B_SilverWind2, .onBulletOverlapsEnemy = W_SilverWind_onBulletOverlapsEnemy }; // W_MirageRobe (0x1753d) / W_MirageRobe2 (0xed6, senza collider fra le copie) static void W_MirageRobe_ctor(Weapon *w) { w->explosionType = "COLDEXPLOSION"; sprite_init(&w->image, frame_get("vfx", "sPFX_ring_64.png"), 0, 0); w->image.originX = 0.5f, w->image.originY = 1; w->image.tint = 0x7070ff; // semplificazione: quattro angoli (0xff, 0xff, 0xe0e0ff, 0xe0e0ff) reso col colore medio w->image.alpha = 0, w->image.depth = -1; children_add(&w->image); } static void W_Mirage_ringFollow(void *ctx) { Weapon *w = ctx; w->image.x = Core.Player->s.x, w->image.y = Core.Player->s.y; } static void W_Mirage_ringOut(void *ctx) { Weapon *w = ctx; if (w->hasRingTween2) tween_stop(w->ringTween2); w->image.alpha = 0.5f; w->ringTween2 = tweens_add((TweenConfig){ .props = { { &w->image.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x64 }); w->hasRingTween2 = 1; } static void W_MirageRobe_Fire(Weapon *w) { base_Fire(w); Sound_PlaySound("Clones", 0.3f, 1, 0x3e8 * (frand() - 0.25f), 0x64, 8); if (w->hasRingTween2) tween_stop(w->ringTween2); if (w->hasRingTween) tween_stop(w->ringTween); W_Mirage_ringFollow(w); sprite_setScale(&w->image, 0); w->image.alpha = 1; w->ringTween = tweens_add((TweenConfig){ .props = { { &w->image.alpha, NULL, 0.5f }, { &w->image.scaleX, &w->image.scaleY, 1.25f * fminf(Weapon_PArea(w), 1) } }, .nprops = 2, .duration = 0x96, .onUpdate = W_Mirage_ringFollow, .onComplete = W_Mirage_ringOut, .ctx = w }); w->hasRingTween = 1; } static void W_MirageRobe_OnStart(Weapon *w) { base_OnStart(w); physics_addCollider(&w->pool->group, &w->pool->group, NULL, NULL); } static void W_MirageRobe_onBulletOverlapsEnemy(Weapon *w, Bullet *b, Enemy *e) { if (e->isDead || Bullet_HasAlreadyHitObject(b, e, e->isDead)) return; Enemy_GetDamaged(e, Weapon_PPower(w), (int)w->hitVFX, w->knockback, w->bulletType); w->stats_inflictedDamage += Weapon_PPower(w); if (w->chance <= 0) return; float c = w->critChancesArray[w->critIndex % 1000]; w->critIndex++; if (c < w->chance * Player_PLuck(Core.Player)) Weapon_SpawnExplosionAt(w, b->s.x, b->s.y, 0); } static const WeaponVT W_MirageRobe = { BASE, .bullet = &B_MirageRobe, .ctor = W_MirageRobe_ctor, .Fire = W_MirageRobe_Fire, .OnStart = W_MirageRobe_OnStart, .onBulletOverlapsEnemy = W_MirageRobe_onBulletOverlapsEnemy, .SecondaryPPower = Weapon_PPower }; static const WeaponVT W_MirageRobe2 = { BASE, .bullet = &B_MirageRobe2, .ctor = W_MirageRobe_ctor, .Fire = W_MirageRobe_Fire, .onBulletOverlapsEnemy = W_MirageRobe_onBulletOverlapsEnemy, .SecondaryPPower = Weapon_PPower }; // W_Bubble (0x16828) / W_Bubble2 (0x1015a): collider fra le bolle; solo la prima si ferma fuori dal raggio del magnete static void W_Bubble_OnStart(Weapon *w) { base_OnStart(w); physics_addCollider(&w->pool->group, &w->pool->group, NULL, NULL); } static void W_Bubble_Update(Weapon *w, float delta) { base_Update(w, delta); Magnet *m = Core.Magnet; for (int i = 0; i < w->pool->group.n; i++) { // OverlapCirc Bullet *b = w->pool->group.items[i]->owner; float dx = m->s.x - b->s.body.position.x, dy = m->s.y - b->s.body.position.y; if (sqrtf(dx * dx + dy * dy) > m->radius + b->s.body.radius) b->save_vel_x = b->save_vel_y = 0; } } static const WeaponVT W_Bubble = { BASE, .bullet = &B_Bubble, .OnStart = W_Bubble_OnStart, .Update = W_Bubble_Update }; static const WeaponVT W_Bubble2 = { BASE, .bullet = &B_Bubble2, .OnStart = W_Bubble_OnStart }; // W_SummonNight (0xbecb) / W_SummonNight2 (0x6c73): colonne equidistanti sulla larghezza dello schermo, nel punto in cui si trovava il giocatore allo sparo typedef struct { Weapon *w; float x, y; int index, red; } NightShot; static void W_Night_shot(void *ctx) { NightShot *s = ctx; BulletPool_SpawnAt(s->red ? s->w->redPool : s->w->pool, s->x, s->y, s->w, s->index); } static void W_Night_schedule(Weapon *w, float x, float y, int i, int red) { static NightShot shots[64]; // come i ShotCtx: un anello basta per i colpi ritardati in volo static int n; NightShot one = { w, x, y, i, red }; if (w->repeatInterval * i > 0) { NightShot *s = &shots[n++ & 63]; *s = one; w->lastShotTimer = time_addEvent(w->repeatInterval * i, 0, 0, W_Night_shot, s); } else W_Night_shot(&one); } static void W_SummonNight_Fire(Weapon *w) { Sound_PlaySound("ExploNight", 0.9f, 1, 0, 0x64, 8); int n = (int)Weapon_PAmount(w); float step = game_width / (1.0f + Weapon_PAmount(w)), x = Core.Player->s.x - 0.5f * game_width, y = Core.Player->s.y - 0.5f * game_height; for (int i = 0; i < n; i++) W_Night_schedule(w, x + step * (1 + i), y, i, 0); if (w->lastFiringInterval != Weapon_PInterval(w)) w->lastFiringInterval = Weapon_PInterval(w), Weapon_ResetFiringTimer(w); } static const WeaponVT W_SummonNight = { BASE, .bullet = &B_SummonNight, .Fire = W_SummonNight_Fire }; static void W_SummonNight2_ctor(Weapon *w) { w->skipAddingEvolution = 1; } static void W_Night2_bgm(void *ctx) { (void)ctx; po_sets("SelectedBGM", "BGM_Night2"); Sound_SetupAndPlayBGM_Banger(1); } static void W_SummonNight2_OnStart(Weapon *w) { base_OnStart(w); w->redPool = BulletPool_new(w, &B_SummonNight); physics_addOverlap(&w->redPool->group, &Core.Enemies, Weapon_onBulletOverlapsEnemy, w); physics_addOverlap(&w->redPool->group, &Core.Destructibles, Weapon_onBulletOverlapsDestuctible, w); if (BGM.idx == Sound_index("BGM_Night1")) { // la musica di Syuuto cambia con l'evoluzione Sound_FadeMusic(0, 0x64); time_addEvent(0x64, 0, 0, W_Night2_bgm, NULL); } } static void W_SummonNight2_Fire(Weapon *w) { int n = (int)Weapon_PAmount(w); float step = game_width / (1.0f + Weapon_PAmount(w)), x = Core.Player->s.x - 0.5f * game_width, y = Core.Player->s.y - 0.5f * game_height, y2 = Core.Player->s.y + 0.5f * game_height; Sound_PlaySound("ExploNight", 0.9f, 1, 0x12c, 0x64, 8); for (int i = 0; i < n; i++) W_Night_schedule(w, x + step * (1 + i), y, i, 1); for (int i = 0; i < n - 1; i++) W_Night_schedule(w, x + 0.5f * step + step * (1 + i), y2, i, 0); if (w->lastFiringInterval != Weapon_PInterval(w)) w->lastFiringInterval = Weapon_PInterval(w), Weapon_ResetFiringTimer(w); } static const WeaponVT W_SummonNight2 = { BASE, .bullet = &B_SummonNight2, .ctor = W_SummonNight2_ctor, .OnStart = W_SummonNight2_OnStart, .Fire = W_SummonNight2_Fire }; // W_Lightning (0x26b9): spara da Update ogni PInterval (come Garlic); ScreenRectangle del giocatore static void W_UpdateFire(Weapon *w, float delta) { // super.Update + totalTime, frameWalk, Fire base_Update(w, delta); if (!w->mul) w->mul = 1000.0f / 6; w->totalTime += delta; if (w->cooldownAffectedByMovement) w->totalTime += Core.Player->frameWalk * (delta / w->mul); if (w->totalTime >= Weapon_PInterval(w)) { w->totalTime -= Weapon_PInterval(w); Weapon_Fire(w); } } static const WeaponVT W_Lightning = { BASE, .PPower = armor_PPower, .CheckArcanas = CA_tragicTwilight, .bullet = &B_Lightning, .Update = W_UpdateFire, .ResetFiringTimer = noop_ResetFiringTimer }; static const WeaponVT W_Loop = { BASE, .CheckArcanas = CA_tragicTwilight, .bullet = &B_Loop, .Update = W_UpdateFire, .ResetFiringTimer = noop_ResetFiringTimer }; // W_Loop (0xcea) // W_Misspell (0x17685): l'arma nascosta NDUJA, si toglie da sola dopo 10 s * Player.duration static void Weapon_CleanUp(Weapon *w); static void W_Misspell_Update(Weapon *w, float delta) { base_Update(w, delta); w->totalTime += delta; if (w->totalTime > 0x2710 * Core.Player->duration) { for (int i = 0; i < Core.n_HiddenWeapons; i++) if (Core.HiddenWeapons[i] == w) { memmove(&Core.HiddenWeapons[i], &Core.HiddenWeapons[i + 1], (Core.n_HiddenWeapons - i - 1) * sizeof(Weapon *)); Core.n_HiddenWeapons--; break; } Weapon_CleanUp(w); time_removeEvent(w->firingTimer); } } static const WeaponVT W_Misspell = { BASE, .CheckArcanas = CA_nduja, .bullet = &B_Misspell, .Update = W_Misspell_Update }; // Gemini: W_Misspell_Counter (0x6e83) per NDUJA_COUNTER, stesso orologio di 10 s; B_Misspell_Counter (0xce02) spara all'indietro static const BulletVT B_MisspellCounter; static const WeaponVT W_Misspell_Counter = { BASE, .bullet = &B_MisspellCounter, .Update = W_Misspell_Update }; // --- Flames of Misspell: W_Misspell_True (0x4dd0), il Weapon base; Ashes of Muspell: W_Misspell_True2 (0x8c99) --- static const WeaponVT W_MisspellTrue = { BASE, .bullet = &B_MisspellTrue }; // explosionType FIREEXPLOSION: solo con le arcane static float W_MisspellTrue2_PPower(Weapon *w) { return fminf(10, (Arcanas.silentMight + Core.Player->power) * sinev(Core.Player->sineMight)) * (w->power + 0.1f * floorf(Core.kills / 5000.0f)) + Arcanas.bloodlineDamage; } // RunEnemies static Bullet *W_MisspellTrue2_FireOneBullet(Weapon *w, float x, float y, int index) { // (sic) isPlayerFacing si scrive dopo lo SpawnAt: l'OnRecycle appena fatto ha letto il valore dell'uso precedente Bullet *b = base_FireOneBullet(w, x, y, index); if (b) b->isPlayerFacing = 1; b = base_FireOneBullet(w, x, y, index); if (b) b->isPlayerFacing = 0; return b; } static const WeaponVT W_MisspellTrue2 = { BASE, .bullet = &B_MisspellTrue2, .PPower = W_MisspellTrue2_PPower, .FireOneBullet = W_MisspellTrue2_FireOneBullet }; // --- Pentagram (0x17906 / B 0x31f8) e Gorgeous Moon (0x1ed3 / B 0xc1d1) ---------------------------------------- // Il simbolo si disegna in una RenderTexture grande come lo schermo, che una rexShatterImage spezza in triangoli. static void Enemy_Disappear(Enemy *e); static void Destructible_DeSpawnFwd(void *d); #define TWEEN_NONE ((TweenRef){ -1, 0 }) // RenderTexture.draw di Graphics e Image: tutti al centro dello schermo (setPosition(0.5 * width, 0.5 * height)) static void PG_rtClear(Weapon *w) { BeginTextureMode(w->rt); ClearBackground(BLANK); EndTextureMode(); } static void PG_rtCircle(Weapon *w, unsigned color, float alpha, float radius, float scale) { // fillCircle(0, 0, r), ADD su una RT vuota BeginTextureMode(w->rt); rlSetBlendFactorsSeparate(0x0302, 0x0303, 1, 0x0303, 0x8006, 0x8006); BeginBlendMode(BLEND_CUSTOM_SEPARATE); DrawCircleV((Vector2){ 0.5f * game_width, 0.5f * game_height }, radius * scale, hexc(color, alpha)); EndBlendMode(); EndTextureMode(); } static void PG_rtImage(Weapon *w, const Sprite *im) { // setTintFill(0xffffff, 0xffff00, 0xffff00, 0xffffff): gradiente sui 4 angoli const Frame *f = im->frame; if (!f) return; float sc = im->scaleX, lx = -f->sw * 0.5f + f->ox, ly = -f->sh * 0.5f + f->oy; float x0 = 0.5f * game_width + lx * sc, y0 = 0.5f * game_height + ly * sc, x1 = x0 + f->w * sc, y1 = y0 + f->h * sc; float tw = f->tex->width, th = f->tex->height, u0 = f->x / tw, v0 = f->y / th, u1 = (f->x + f->w) / tw, v1 = (f->y + f->h) / th; BeginTextureMode(w->rt); rlSetBlendFactorsSeparate(0x0302, 0x0303, 1, 0x0303, 0x8006, 0x8006); BeginBlendMode(BLEND_CUSTOM_SEPARATE); if (fill_shader.id) BeginShaderMode(fill_shader); rlSetTexture(f->tex->id); rlBegin(RL_QUADS); rlColor4ub(255, 255, 255, 255), rlTexCoord2f(u0, v0), rlVertex2f(x0, y0); // topLeft rlColor4ub(255, 255, 0, 255), rlTexCoord2f(u0, v1), rlVertex2f(x0, y1); // bottomLeft rlColor4ub(255, 255, 255, 255), rlTexCoord2f(u1, v1), rlVertex2f(x1, y1); // bottomRight rlColor4ub(255, 255, 0, 255), rlTexCoord2f(u1, v0), rlVertex2f(x1, y0); // topRight rlEnd(); rlSetTexture(0); if (fill_shader.id) EndShaderMode(); EndBlendMode(); EndTextureMode(); } // whiteDot: tint e' un numero che il blackTween interpola (0xffffff -> 0); il renderer lo tronca a intero static float PG_getTint(void *o) { return ((Weapon *)o)->whiteTint; } static void PG_setTint(void *o, float v) { Weapon *w = o; w->whiteTint = v; w->whiteDot.tint = (unsigned)(int)v & 0xffffff; } static void PG_resetWhiteDot(Weapon *w) { w->whiteDot.alpha = 0; PG_setTint(w, 0xffffff); } // setAlpha(0).setTint(0xffffff) static void PG_canFlash(void *ctx) { ((Weapon *)ctx)->canFlash = 1; } static void PG_flash(Weapon *w, float flashDelay) { // FlashingVFXEnabled: sempre vero qui if (!w->canFlash) return; w->whiteTween = tweens_add((TweenConfig){ .props = { { &w->whiteDot.alpha, NULL, 0.5f } }, .nprops = 1, .duration = 0x64, .yoyo = 1 }); w->blackTween = tweens_add((TweenConfig){ .props = { { .end = 0, .get = PG_getTint, .set = PG_setTint, .o = w } }, .nprops = 1, .duration = 0x32, .yoyo = 1 }); w->canFlash = 0; w->flashTimer = time_addEvent(flashDelay, 0, 0, PG_canFlash, w); } static void PG_stopWhiteTweens(Weapon *w) { // whiteTween && (stop(), null) tween_stop(w->whiteTween), w->whiteTween = TWEEN_NONE; tween_stop(w->blackTween), w->blackTween = TWEEN_NONE; } static void PG_image(Sprite *s, const char *frame) { sprite_init(s, frame_get("vfx", frame), 0.5f * game_width, 0.5f * game_height); } static void PG_ctor_common(Weapon *w) { w->canFlash = 1; w->chance = 0.1f; w->whiteTween = w->blackTween = w->sealSpin = w->sealShow = w->sealHide = TWEEN_NONE; w->flashTimer = (Timer){ -1, 0 }; w->rt = LoadRenderTexture(game_width, game_height); // make.renderTexture + saveTexture SetTextureFilter(w->rt.texture, TEXTURE_FILTER_POINT); PG_rtClear(w); w->canvas = shatterImage_add(0, 0, &w->rt.texture, game_width, game_height); // scene.add.rexShatterImage w->canvas->s.depth = ZDamageNumber + 6; } static void PG_whiteDot(Weapon *w) { // scene.add.sprite(0, 0, 'vfx', 'WhiteDot.png'): schermo intero, sopra quasi tutto sprite_init(&w->whiteDot, frame_get("vfx", "WhiteDot.png"), 0, 0); w->whiteDot.scrollFactor0 = 1; w->whiteDot.scaleX = game_width, w->whiteDot.scaleY = game_height; w->whiteDot.alpha = 0; sprite_setOrigin(&w->whiteDot, 0, 0); w->whiteDot.depth = 0x1388; w->whiteTint = 0xffffff; children_add(&w->whiteDot); } static float PG_PInterval(Weapon *w) { return fmaxf(base_PInterval(w), 0x3a98); } // minimo 15 s static void W_Pentagram_ctor(Weapon *w) { PG_ctor_common(w); w->badColor = 0x550044, w->badAlpha = 0.5f, w->badRadius = 7; // graphics_Bad w->goodColor = 0xee, w->goodAlpha = 0.35f, w->goodRadius = 7; // graphics_Good PG_image(&w->outline, "outer0.png"); PG_image(&w->center, "center.png"); PG_image(&w->inner, "inner1.png"); PG_image(&w->outer, "outer1.png"); PG_whiteDot(w); } static void W_Pentagram_Fire(Weapon *w) { Weapon_FireOneBullet(w, Core.Player->s.x, Core.Player->s.y, 0); PG_resetWhiteDot(w); PG_stopWhiteTweens(w); PG_flash(w, 0x1f4); if (w->lastFiringInterval != Weapon_PInterval(w)) { w->lastFiringInterval = Weapon_PInterval(w); Weapon_ResetFiringTimer(w); } if (Arcanas.hasAstronomia) Arcanas_TriggerAstronomia(w); } static int W_Pentagram_LevelUp(Weapon *w) { int r = base_LevelUp(w); PG_resetWhiteDot(w); if (r) switch (w->level) { case 3: sprite_setFrame(&w->outer, frame_get("vfx", "outer2.png")); break; case 4: sprite_setFrame(&w->inner, frame_get("vfx", "inner2.png")); break; case 6: sprite_setFrame(&w->outer, frame_get("vfx", "outer3.png")); break; case 7: sprite_setFrame(&w->inner, frame_get("vfx", "inner3.png")); break; } return r; } static void W_Pentagram_MakeLevelOne(Weapon *w) { base_MakeLevelOne(w); time_addEvent(Core.n_weapons == 0 ? 0x3e8 : 0x64, 0, 0, Weapon_FireCb, w); // Core.Weapons.length: l'arma non e' ancora in lista } // --- B_Pentagram (0x31f8) --- static void B_PG_ctor(Bullet *b) { // trueWeapon = weapon; i quattro simboli prendono qui il gradiente (PG_rtImage) b->s.x = Core.Player->s.x, b->s.y = Core.Player->s.y; // copyPosition b->s.visible = 0; b->globalScale = 0.8f * fminf(game_width, game_height); } static void B_PG_Init(Bullet *b, float x, float y) { b->s.x = x, b->s.y = y; physics_existing(&b->s); } // senza OnRecycle static void B_PG_Update(Bullet *b, float delta) { (void)delta; b->weapon->canvas->s.x = Core.Player->s.x, b->weapon->canvas->s.y = Core.Player->s.y; } static void B_Pentagram_EraseEnemies(Bullet *b, int bad) { for (int i = 0; i < Core.Enemies.n; i++) { Enemy *e = Core.Enemies.items[i]->owner; if (e->res_Rosary || !ContainmentRect_Contains(&Core.containmentRect_Screen, &e->s)) continue; if (bad) Enemy_Disappear(e); else Enemy_GetDamaged(e, fmaxf(0x42, e->maxHp), HIT_NONE, 0, "PENTAGRAM"); b->weapon->stats_inflictedDamage += e->maxHp; } } static void B_Pentagram_EraseItems(Bullet *b) { (void)b; for (int i = Core.PickupGroup.n - 1; i > 0; i--) { // (sic) > 0: il primo resta if (i >= Core.PickupGroup.n) continue; Pickup *p = Core.PickupGroup.items[i]->owner; if (ContainmentRect_Contains(&Core.containmentRect_Screen, &p->s)) Pickup_DeSpawn(p); // res_Rosary: i pickup non ce l'hanno } for (int i = Core.Destructibles.n - 1; i >= 0; i--) { if (i >= Core.Destructibles.n) continue; Sprite *d = Core.Destructibles.items[i]; if (ContainmentRect_Contains(&Core.containmentRect_Screen, d)) Destructible_DeSpawnFwd(d->owner); } } static void B_Pentagram_eraseBad(void *ctx) { B_Pentagram_EraseEnemies(ctx, 1); B_Pentagram_EraseItems(ctx); } static void B_Pentagram_eraseGood(void *ctx) { B_Pentagram_EraseEnemies(ctx, 0); } static void B_PG_done(void *ctx) { Bullet *b = ctx; b->weapon->canvas->hasTask = 0; Bullet_DeSpawn(b); } // stopUpdate, DeSpawn static void B_Sire_yoyo(void *ctx) { // onYoyo: una volta per ogni TweenData, come l'originale Bullet *b = ctx; Core_TurnOnVacuum(); b->weapon->canvas->s.scaleX = -1; } static void B_Sire_done(void *ctx) { Bullet *b = ctx; ShatterImage *c = b->weapon->canvas; c->hasTask = 0; Bullet_DeSpawn(b); tweens_add((TweenConfig){ .props = { { &c->s.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x1f4, .ease = Ease_SineInOut }); } // Shatter: un tween sulle facce (targets: canvas.faces), valori di arrivo calcolati per ogni faccia static void B_PG_Shatter(Bullet *b, int sire) { ShatterImage *c = b->weapon->canvas; if (c->hasTask) tween_stop(c->task), c->hasTask = 0; shatterImage_shatter(c); if (sire) c->s.alpha = 1, c->s.scaleX = 1; int nf = c->nfaces; TweenProp *pr = malloc((4 * nf + 1) * sizeof(TweenProp)); for (int i = 0; i < nf; i++) pr[i] = face_prop(&c->faces[i], 0, 0); // alpha for (int i = 0; i < nf; i++) pr[nf + i] = face_prop(&c->faces[i], 1, (sire ? 0x168 : 0xb4) * frand() - 0x5a); // angle for (int i = 0; i < nf; i++) pr[2 * nf + i] = face_prop(&c->faces[i], 2, (sire ? 1.5f : 1.2f) * (frand() - 0.5f)); // x for (int i = 0; i < nf; i++) pr[3 * nf + i] = face_prop(&c->faces[i], 3, 1.2f * (frand() - 0.5f)); // y c->task = tweens_add((TweenConfig){ .many = pr, .nmany = 4 * nf, .duration = 0x3e8, .delay = 0x96, .yoyo = sire, .ease = sire ? Ease_SineInOut : NULL, .onYoyo = sire ? B_Sire_yoyo : NULL, .onComplete = sire ? B_Sire_done : B_PG_done, .ctx = b }); c->hasTask = 1; // startUpdate: qui le facce si proiettano a ogni disegno free(pr); } static void B_Pentagram_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); b->s.body.enable = 0; Weapon *w = b->weapon; float gs = b->globalScale; PG_rtClear(w); sprite_setScale(&w->outline, gs / 0x80), sprite_setScale(&w->inner, gs / 0x80); sprite_setScale(&w->outer, gs / 0x80), sprite_setScale(&w->center, gs / 0x80); float gScale = gs / 0x10; // graphics_Bad / graphics_Good int bad = frand() * (1 / Player_PLuck(Core.Player)) > w->chance; // PLuck time_addEvent(0x64, 0, 0, bad ? B_Pentagram_eraseBad : B_Pentagram_eraseGood, b); if (bad) PG_rtCircle(w, w->badColor, w->badAlpha, w->badRadius, gScale); else PG_rtCircle(w, w->goodColor, w->goodAlpha, w->goodRadius, gScale); PG_rtImage(w, &w->outline); PG_rtImage(w, &w->outer); PG_rtImage(w, &w->inner); PG_rtImage(w, &w->center); w->canvas->s.x = Core.Player->s.x, w->canvas->s.y = Core.Player->s.y; B_PG_Shatter(b, 0); Sound_PlaySound("PentagramSFX", 0.9f, 2, 0, 0, 0); } static const BulletVT B_Pentagram = { "vfx", "Rings3.png", B_PG_ctor, B_PG_Init, B_Pentagram_OnRecycle, NULL, B_PG_Update, NULL }; static const WeaponVT W_Pentagram = { BASE, .bullet = &B_Pentagram, .ctor = W_Pentagram_ctor, .PInterval = PG_PInterval, .Fire = W_Pentagram_Fire, .LevelUp = W_Pentagram_LevelUp, .MakeLevelOne = W_Pentagram_MakeLevelOne }; // --- MoonExplosion (0xd2aa) e il suo pool (0xc9ac) --- typedef struct MoonExplosion { Sprite s; // invisibile (WhiteDot) float radius, damage; int hasHit; ParticleManager *particlesManager; ParticleEmitter *pfxEmitter, *pfxEmitter2; Sprite GroundFx, ringSPrite; // GroundFx: scene.add.circle, raggio in scaleX TweenRef despawnTimer; MoonExplosionPool *pool; } MoonExplosion; struct MoonExplosionPool { MoonExplosion **stored, **spawned; int nstored, nspawned, capstored, capspawned, blood; }; // blood: 0x7cb4 / 0x61b2 (Astronomia) static void MoonGroundFx_draw(Sprite *s) { if (!s->visible) return; BeginBlendMode(BLEND_ADDITIVE); DrawCircle((int)roundf(s->x - camera_scrollX), (int)roundf(s->y - camera_scrollY), s->scaleX, hexc(s->tint, s->alpha)); EndBlendMode(); } static void MoonExplosion_DeSpawn(MoonExplosion *e) { e->s.active = 0; emitter_stop(e->pfxEmitter); emitter_stop(e->pfxEmitter2); MoonExplosionPool *p = e->pool; // Return children_remove(&e->s); for (int i = 0; i < p->nspawned; i++) if (p->spawned[i] == e) { memmove(&p->spawned[i], &p->spawned[i + 1], (p->nspawned - i - 1) * sizeof(*p->spawned)); p->nspawned--; break; } if (p->nstored == p->capstored) p->stored = realloc(p->stored, (p->capstored = p->capstored ? p->capstored * 2 : 16) * sizeof(*p->stored)); p->stored[p->nstored++] = e; tween_stop(e->despawnTimer), e->despawnTimer = TWEEN_NONE; e->GroundFx.visible = 0; } static void MoonExplosion_despawnCb(void *ctx) { MoonExplosion_DeSpawn(ctx); } static void MoonExplosion_Explode(MoonExplosion *e) { e->hasHit = 0; // circleArea: non usata da nessuno e->particlesManager->wellX = e->s.x, e->particlesManager->wellY = e->s.y - 0x14; e->pfxEmitter->x = e->s.x, e->pfxEmitter->y = e->s.y; emitter_start(e->pfxEmitter); e->pfxEmitter2->x = e->s.x, e->pfxEmitter2->y = e->s.y; emitter_start(e->pfxEmitter2); e->GroundFx.x = e->s.x, e->GroundFx.y = e->s.y, e->GroundFx.visible = 1, e->GroundFx.scaleX = 1; // FlashingVFXEnabled tween_stop(e->despawnTimer), e->despawnTimer = TWEEN_NONE; e->despawnTimer = tweens_add((TweenConfig){ .props = { { &e->GroundFx.scaleX, NULL, e->radius } }, .nprops = 1, .duration = 0x78, .onComplete = MoonExplosion_despawnCb, .ctx = e }); Sound_PlaySound("Explosion", 0.5f, 1, 0x1f4 * (frand() - 0.5f), 0x96, 3); } static void MoonExplosion_ringDone(void *ctx) { MoonExplosion *e = ctx; e->ringSPrite.visible = 0; MoonExplosion_Explode(e); } static void MoonExplosion_OnRecycle(MoonExplosion *e) { e->s.active = 1; sprite_setScale(&e->s, e->radius); e->ringSPrite.x = e->s.x, e->ringSPrite.y = e->s.y; e->ringSPrite.visible = 1; sprite_setScale(&e->ringSPrite, 4); tweens_add((TweenConfig){ .props = { { &e->ringSPrite.scaleX, &e->ringSPrite.scaleY, 0 } }, .nprops = 1, .duration = 0x78, .onComplete = MoonExplosion_ringDone, .ctx = e }); } static MoonExplosion *MoonExplosion_new(MoonExplosionPool *pool) { // Make: new MoonExplosion(pool, -100000, -100000) static const unsigned TINTS[4] = { 0xff8888, 0xff88ff, 0xff88ff, 0xffff88 }, BLOOD[3] = { 0xff0000, 0xff8800, 0x880000 }; MoonExplosion *e = calloc(1, sizeof(MoonExplosion)); sprite_init(&e->s, frame_get("vfx", "WhiteDot.png"), -0x186a0, -0x186a0); e->s.owner = e; e->radius = e->damage = 1; e->pool = pool; e->s.visible = 0; e->despawnTimer = TWEEN_NONE; e->particlesManager = particles_add(); e->pfxEmitter2 = particles_createEmitter(e->particlesManager, (EmitterConfig){ .frames = { frame_get("vfx", "HitCloud1.png"), frame_get("vfx", "HitCloud2.png") }, .nframes = 2, .lifespan = EOP(0x3e8), .rotate = ERND(0, 0x168), .angle = { 0, 0xb4, 1 }, .angleSteps = 0x10, .speed = ERND(0x64, 0xc8), .quantity = 4, .scale = ERANGE(1, 0), .frequency = 4, .alpha = ERANGE(0.5f, 0), .on = 0, .tints = { TINTS[0], TINTS[1], TINTS[2], TINTS[3] }, .ntints = 4 }); if (pool->blood) for (int i = 0; i < 3; i++) e->pfxEmitter2->c.tints[i] = BLOOD[i]; if (pool->blood) e->pfxEmitter2->c.ntints = 3; e->pfxEmitter = particles_createEmitter(e->particlesManager, (EmitterConfig){ .frames = { frame_get("vfx", "PfxLine2.png") }, .nframes = 1, .lifespan = EOP(0x3e8), .rotate = EOP(0), .angle = { 0, 0x168, 1 }, .angleSteps = 0x10, .speed = ERND(0x50, 0x64), .quantity = 1, .scale = ERANGE(1, 0), .scaleY = ERANGE(5, 0), .hasScaleY = 1, .alpha = ERANGE(0.5f, 0), .frequency = 1, .blendAdd = 1, .on = 0 }); if (pool->blood) e->pfxEmitter->c.tint = 0xdd0000; e->particlesManager->hasWell = 1; // createGravityWell({ power: 1, epsilon: 50, gravity: 20 }) e->particlesManager->wellPower = 1 * 0x14, e->particlesManager->wellEpsilon = 0x32 * 0x32; e->particlesManager->wellX = e->s.x, e->particlesManager->wellY = e->s.y - 0x14; sprite_init(&e->GroundFx, NULL, 0, 0); // scene.add.circle(0, 0, 1, 0x88ccff) e->GroundFx.draw = MoonGroundFx_draw; e->GroundFx.tint = 0x88ccff, e->GroundFx.alpha = 0.4f, e->GroundFx.visible = 0, e->GroundFx.scaleX = 1; children_add(&e->GroundFx); sprite_init(&e->ringSPrite, frame_get("vfx", "sPFX_ring_64.png"), 0, 0); e->ringSPrite.visible = 0, e->ringSPrite.blendAdd = 1; if (pool->blood) e->ringSPrite.tint = 0xdd0000; children_add(&e->ringSPrite); return e; } static MoonExplosion *MoonExplosionPool_SpawnAt(MoonExplosionPool *p, float x, float y, float damage, float radius) { MoonExplosion *e = p->nstored ? p->stored[--p->nstored] : NULL; // Spawn if (!e) { e = MoonExplosion_new(p); e->s.x = -0x3e8, e->s.y = -0x3e8; // Init(): setPosition + OnRecycle (il primo anello parte da qui) MoonExplosion_OnRecycle(e); } if (p->nspawned == p->capspawned) p->spawned = realloc(p->spawned, (p->capspawned = p->capspawned ? p->capspawned * 2 : 16) * sizeof(*p->spawned)); p->spawned[p->nspawned++] = e; e->s.x = x, e->s.y = y; e->damage = damage, e->radius = radius; double d = y + 1 - Core.Player->s.y; // setDepthPlease e->s.depth = e->GroundFx.depth = e->particlesManager->s.depth = d; children_add(&e->s); MoonExplosion_OnRecycle(e); // un'esplosione appena creata ha due anelli: Explode parte due volte, come l'originale return e; } // --- Esplosione dei nemici (0x16642) e il suo pool nel Core (0x14e6f): Core.MakeExplosion(x, y, danno, raggio) ------------------- // SelfDestruct dei nemici (POLTER, SHADERED...): fumo, cerchio rosso che si allarga in 120 ms, un colpo al giocatore se e' dentro typedef struct EnemyExplosion { float x, y, radius, damage; int hasHit; ParticleManager *particlesManager; ParticleEmitter *pfxEmitter, *pfxEmitter2; Sprite GroundFx; // scene.add.circle(0, 0, 1, 0xff0000): raggio in scaleX TweenRef despawnTimer; } EnemyExplosion; static void EnemyExplosion_DeSpawn(EnemyExplosion *e) { emitter_stop(e->pfxEmitter), emitter_stop(e->pfxEmitter2); typeof(Core.explosionPool) *p = &Core.explosionPool; // Return for (int i = 0; i < p->nspawned; i++) if (p->spawned[i] == e) { memmove(&p->spawned[i], &p->spawned[i + 1], (p->nspawned - i - 1) * sizeof(*p->spawned)); p->nspawned--; break; } if (p->nstored == p->capstored) p->stored = realloc(p->stored, (p->capstored = p->capstored ? p->capstored * 2 : 16) * sizeof(*p->stored)); p->stored[p->nstored++] = e; tween_stop(e->despawnTimer), e->despawnTimer = TWEEN_NONE; e->GroundFx.visible = 0; } static void EnemyExplosion_despawnCb(void *ctx) { EnemyExplosion_DeSpawn(ctx); } static void EnemyExplosion_OnRecycle(EnemyExplosion *e) { e->hasHit = 0; e->particlesManager->wellX = e->x, e->particlesManager->wellY = e->y - 0x14; e->pfxEmitter->x = e->pfxEmitter2->x = e->x, e->pfxEmitter->y = e->pfxEmitter2->y = e->y; emitter_start(e->pfxEmitter), emitter_start(e->pfxEmitter2); e->GroundFx.x = e->x, e->GroundFx.y = e->y, e->GroundFx.visible = 1, e->GroundFx.scaleX = 1; // FlashingVFXEnabled tween_stop(e->despawnTimer); e->despawnTimer = tweens_add((TweenConfig){ .props = { { &e->GroundFx.scaleX, NULL, e->radius } }, .nprops = 1, .duration = 0x78, .onComplete = EnemyExplosion_despawnCb, .ctx = e }); Sound_PlaySound("Explosion", 0.5f, 1, 0x1f4 * (frand() - 0.5f), 0x96, 3); } static EnemyExplosion *EnemyExplosion_new(void) { EnemyExplosion *e = calloc(1, sizeof(EnemyExplosion)); e->radius = e->damage = 1, e->despawnTimer = TWEEN_NONE; e->particlesManager = particles_add(); e->pfxEmitter2 = particles_createEmitter(e->particlesManager, (EmitterConfig){ .frames = { frame_get("vfx", "Smoke1.png"), frame_get("vfx", "Smoke2.png") }, .nframes = 2, .lifespan = EOP(0x3e8), .rotate = ERND(0, 0x168), .angle = { 0, 0xb4, 1 }, .angleSteps = 0x10, .speed = ERND(0x64, 0xc8), .quantity = 4, .scale = ERANGE(1, 0), .frequency = 4, .alpha = ERANGE(0.5f, 0), .on = 0 }); e->pfxEmitter = particles_createEmitter(e->particlesManager, (EmitterConfig){ .frames = { frame_get("vfx", "HitSmoke1.png"), frame_get("vfx", "HitSmoke2.png") }, .nframes = 2, .lifespan = EOP(0x3e8), .rotate = ERND(0, 0x168), .angle = { 0, 0x168, 1 }, .angleSteps = 0x10, .speed = ERND(0x32, 0x50), .quantity = 4, .scale = ERANGE(1, 0), .frequency = 2, .blendAdd = 1, .on = 0 }); e->particlesManager->hasWell = 1; // createGravityWell({ power: 1, epsilon: 50, gravity: 20 }) e->particlesManager->wellPower = 1 * 0x14, e->particlesManager->wellEpsilon = 0x32 * 0x32; sprite_init(&e->GroundFx, NULL, 0, 0); e->GroundFx.draw = MoonGroundFx_draw; e->GroundFx.tint = 0xff0000, e->GroundFx.alpha = 0.4f, e->GroundFx.visible = 0, e->GroundFx.scaleX = 1; children_add(&e->GroundFx); return e; } static void Core_MakeExplosion(float x, float y, float damage, float radius) { // explosionPool.SpawnAt typeof(Core.explosionPool) *p = &Core.explosionPool; EnemyExplosion *e = p->nstored ? p->stored[--p->nstored] : NULL; // Spawn if (!e) { e = EnemyExplosion_new(); e->x = e->y = -0x3e8; // Init(): setPosition + OnRecycle (fumo e suono anche qui, come l'originale) EnemyExplosion_OnRecycle(e); } if (p->nspawned == p->capspawned) p->spawned = realloc(p->spawned, (p->capspawned = p->capspawned ? p->capspawned * 2 : 16) * sizeof(*p->spawned)); p->spawned[p->nspawned++] = e; e->x = x, e->y = y, e->damage = damage, e->radius = radius; e->GroundFx.depth = e->particlesManager->s.depth = y + 1 - Core.Player->s.y; // setDepthPlease EnemyExplosion_OnRecycle(e); } static void EnemyExplosion_Update(EnemyExplosion *e) { // circleArea.contains: un solo colpo float dx = Core.Player->s.x - e->x, dy = Core.Player->s.y - e->y; if (!e->hasHit && e->radius > 0 && dx * dx + dy * dy <= e->radius * e->radius) e->hasHit = 1, Player_GetDamaged(Core.Player, e->damage); } // --- W_Sire (0x1ed3, Gorgeous Moon) --- static void W_Sire_ctor(Weapon *w) { PG_ctor_common(w); w->moonExplosionPool = calloc(1, sizeof(MoonExplosionPool)); w->badColor = 0x88ccff, w->badAlpha = 0.5f, w->badRadius = 8; sprite_init(&w->groundSeal, frame_get("vfx", "moon3.png"), 0.5f * game_width, 0.5f * game_height); sprite_setScale(&w->groundSeal, 0.5f); w->groundSeal.alpha = 0, w->groundSeal.blendAdd = 1, w->groundSeal.scrollFactor0 = 1; children_add(&w->groundSeal); PG_image(&w->inner, "moon2.png"); PG_image(&w->outer, "moon.png"); PG_whiteDot(w); } static void W_Sire_resetSealTweens(Weapon *w) { tween_stop(w->sealSpin), w->sealSpin = TWEEN_NONE; tween_stop(w->sealShow), w->sealShow = TWEEN_NONE; tween_stop(w->sealHide), w->sealHide = TWEEN_NONE; } static void W_Sire_ShowSeal(Weapon *w) { W_Sire_resetSealTweens(w); sprite_setScale(&w->groundSeal, 0); w->groundSeal.alpha = 0; w->sealShow = tweens_add((TweenConfig){ .props = { { &w->groundSeal.scaleX, &w->groundSeal.scaleY, 0.5f }, { &w->groundSeal.alpha, NULL, 0.2f } }, .nprops = 2, .duration = 0xbb8, .ease = Ease_SineInOut }); } static void W_Sire_SpinSeal(Weapon *w, float duration, float scale, float alpha, Bullet *b) { if (b != w->activeBullet) return; w->groundSeal.visible = 1; w->sealSpin = tweens_add((TweenConfig){ .props = { { &w->groundSeal.scaleX, &w->groundSeal.scaleY, scale }, { &w->groundSeal.alpha, NULL, alpha } }, .nprops = 2, .yoyo = 1, .duration = duration, .ease = Ease_SineInOut }); } static void W_Sire_HideSeal(Weapon *w, Bullet *b) { if (b != w->activeBullet) return; w->sealHide = tweens_add((TweenConfig){ .props = { { &w->groundSeal.scaleX, &w->groundSeal.scaleY, 0 }, { &w->groundSeal.alpha, NULL, 0 } }, .nprops = 2, .duration = 0x12c }); } static void W_Sire_Fire(Weapon *w) { w->activeBullet = Weapon_FireOneBullet(w, Core.Player->s.x, Core.Player->s.y, 0); if (!w->activeBullet) return; PG_resetWhiteDot(w); W_Sire_ShowSeal(w); PG_stopWhiteTweens(w); w->groundSeal.x = 0.5f * game_width, w->groundSeal.y = 0.5f * game_height; if (w->lastFiringInterval != Weapon_PInterval(w)) { w->lastFiringInterval = Weapon_PInterval(w); Weapon_ResetFiringTimer(w); } if (Arcanas.hasAstronomia) Arcanas_TriggerAstronomia(w); } static int W_Sire_LevelUp(Weapon *w) { int r = base_LevelUp(w); PG_resetWhiteDot(w); return r; } static void W_Sire_MakeLevelOne(Weapon *w) { base_MakeLevelOne(w); time_addEvent(0x64, 0, 0, Weapon_FireCb, w); } static void W_Sire_Update(Weapon *w, float delta) { base_Update(w, delta); w->groundSeal.depth = -game_height; } // --- B_Sire (0xc1d1) --- static const char *const SIRE_FRAMES[3] = { "Gem6.png", "Gem7.png", "Gem10.png" }; static const float SIRE_OFFSETS[4] = { -8, 8, -0x10, 0x10 }; static void B_Sire_MoonDamage(Bullet *b, Enemy *e, int i) { if (!e || e->res_Rosary) return; Enemy_GetDamaged(e, fmaxf(0x42, e->maxHp), HIT_NONE, 0, "SIRE"); Pickup *g = Core_MakeGem(e->s.x + SIRE_OFFSETS[i % 4], e->s.y + 0x10, b->weapon->amount); if (g) sprite_setFrame(&g->s, frame_get("items", SIRE_FRAMES[i % 3])); b->weapon->stats_inflictedDamage += e->maxHp; } typedef struct { Bullet *b; int i; float detune, duration; } SireBeat; static void B_Sire_EraseRandomEnemy(void *ctx) { SireBeat *c = ctx; Enemy *best = NULL; // physics.closest(Player, Enemies.filter(e => !e.isDead)) float bd = 1e30f; for (int k = 0; k < Core.Enemies.n; k++) { Enemy *e = Core.Enemies.items[k]->owner; if (e->isDead) continue; float dx = Core.Player->s.x - e->s.body.center.x, dy = Core.Player->s.y - e->s.body.center.y, d = dx * dx + dy * dy; if (d < bd) bd = d, best = e; } if (best) MoonExplosionPool_SpawnAt(c->b->weapon->moonExplosionPool, best->s.x, best->s.y, 0, 0xa); Sound_PlaySound("MoonBeat", 0.5f, 1, c->detune, 0, 0); B_Sire_MoonDamage(c->b, best, c->i); W_Sire_SpinSeal(c->b->weapon, c->duration / 3, 0.6f, 0.6f, c->b); // FlashingVFXEnabled } static void B_Sire_EraseEnemies(void *ctx) { Bullet *b = ctx; for (int i = 0; i < Core.Enemies.n; i++) { Enemy *e = Core.Enemies.items[i]->owner; if (e->res_Rosary || !ContainmentRect_Contains(&Core.containmentRect_Screen, &e->s)) continue; Enemy_GetDamaged(e, fmaxf(0x42, e->maxHp), HIT_NONE, 0, "SIRE"); Pickup *g = Core_MakeGem(e->s.x + SIRE_OFFSETS[i % 4], e->s.y + 0x10, 1); if (g) sprite_setFrame(&g->s, frame_get("items", SIRE_FRAMES[i % 3])); b->weapon->stats_inflictedDamage += e->maxHp; } } static void B_Sire_DrawSymbol(void *ctx) { Bullet *b = ctx; Weapon *w = b->weapon; PG_flash(w, 0x3e8); // FlashScreen W_Sire_HideSeal(w, b); PG_rtClear(w); sprite_setScale(&w->inner, b->globalScale / 0x100); sprite_setScale(&w->outer, b->globalScale / 0x100); time_addEvent(0x64, 0, 0, B_Sire_EraseEnemies, b); PG_rtCircle(w, w->badColor, w->badAlpha, w->badRadius, b->globalScale / 0x10); PG_rtImage(w, &w->outer); PG_rtImage(w, &w->inner); w->canvas->s.x = Core.Player->s.x, w->canvas->s.y = Core.Player->s.y; B_PG_Shatter(b, 1); Sound_PlaySound("PentagramSFX", 0.9f, 2, 0, 0, 0); Sound_PlaySound("MoonFinisher", 1.3f, 1, 0, 0, 0); } static void B_Sire_OnRecycle(Bullet *b) { static SireBeat beats[64]; static int nb; static const float det[4] = { 0, -0x1f4, -0xc8, -0x1f4 }; Bullet_OnRecycle(b); b->s.body.enable = 0; b->isCullable = 0; Sound_PlaySound("MoonStarter", 1.3f, 1, 0, 0, 0); float t = 0xbb8; static const struct { int n; float step; } runs[3] = { { 8, 0x2ee }, { 4, 0x177 }, { 8, 0xc8 } }; for (int r = 0; r < 3; r++) for (int i = 0; i < runs[r].n; i++) { SireBeat *c = &beats[nb++ & 63]; *c = (SireBeat){ b, i, det[i % 4], runs[r].step }; time_addEvent(t, 0, 0, B_Sire_EraseRandomEnemy, c); t += runs[r].step; } time_addEvent(t, 0, 0, B_Sire_DrawSymbol, b); } static const BulletVT B_Sire = { "vfx", "Rings3.png", B_PG_ctor, B_PG_Init, B_Sire_OnRecycle, NULL, B_PG_Update, NULL }; static const WeaponVT W_Sire = { BASE, .bullet = &B_Sire, .ctor = W_Sire_ctor, .PInterval = PG_PInterval, .Fire = W_Sire_Fire, .LevelUp = W_Sire_LevelUp, .MakeLevelOne = W_Sire_MakeLevelOne, .Update = W_Sire_Update }; // --- NO FUTURE: W_Carnage (0x182a2), B_Carnage (0x4389), B_CarnageExplosion (0x74af) ----------------------------- // Runetracer evoluto: esplode quando rimbalza e quando il giocatore viene colpito (ritorsione) static Animation CarnageScreenAnim; // anims.create('screen'): Screeno_0..29 a 60 fps static void B_CarnageExplosion_ctor(Bullet *b) { b->Pfx = particles_add(); b->PfxEmitter = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "PfxPink.png"), frame_get("vfx", "PfxPurple.png") }, .nframes = 2, .lifespan = EOP(0x1f4), .rotate = ERND(0, 0x168), .speed = ERND(0xc8, 0xdc), .quantity = 0x64, .scale = ERANGE(4, 0), .frequency = 4, .blendAdd = 1, .on = 0 }); b->PfxEmitter2 = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "PfxLine2.png") }, .nframes = 1, .lifespan = EOP(0x1f4), .rotate = EOP(0), .angle = { 0, 0x168, 1 }, .angleSteps = 0x10, .speed = ERND(0x50, 0x64), .quantity = 1, .scale = ERANGE(1, 0), .scaleY = ERANGE(4, 0), .hasScaleY = 1, .alpha = ERANGE(0.5f, 0), .frequency = 1, .tint = 0xff88ff, .blendAdd = 1, .on = 0 }); b->Pfx->hasWell = 1; // createGravityWell({ power: 1, epsilon: 20, gravity: 200 }) b->Pfx->wellPower = 1 * 0xc8, b->Pfx->wellEpsilon = 0x14 * 0x14; b->Pfx->wellX = b->s.x, b->Pfx->wellY = b->s.y - 0x14; sprite_init(&b->screenSprite, frame_get("vfx", "Screen.png"), 0, 0); b->screenSprite.visible = 0, b->screenSprite.alpha = 0.5f; children_add(&b->screenSprite); if (!CarnageScreenAnim.n) make_anim(&CarnageScreenAnim, "vfx", "Screeno_", 0, 0x1d, 0, 0x3c, 0); sprite_setTint(&b->s, 0xddff); b->alphaTween = b->exploTween = TWEEN_NONE; } static void B_CarnageExplosion_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void B_CarnageExplosion_bodyOff(void *ctx) { ((Bullet *)ctx)->s.body.enable = 0; } static void B_CarnageExplosion_Explode(Bullet *b) { b->s.scaleX = b->s.scaleY = 0; b->s.alpha = 1; b->screenSprite.x = b->s.x, b->screenSprite.y = b->s.y; b->screenSprite.visible = 1; b->screenSprite.alpha = 0; anims_play(&b->screenSprite, &CarnageScreenAnim, 0); tween_stop(b->alphaTween); b->alphaTween = tweens_add((TweenConfig){ .props = { { &b->screenSprite.alpha, NULL, 0.5f } }, .nprops = 1, .yoyo = 1, .duration = 0x78, .onComplete = B_CarnageExplosion_despawn, .ctx = b }); tween_stop(b->exploTween); b->exploTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, 5 * Weapon_PArea(b->weapon) }, { &b->s.alpha, NULL, 0 } }, .nprops = 2, .duration = 0x78, .onComplete = B_CarnageExplosion_bodyOff, .ctx = b }); emitter_emitParticleAt(b->PfxEmitter, b->s.x, b->s.y, 0); emitter_emitParticleAt(b->PfxEmitter2, b->s.x, b->s.y, 0); } static void B_CarnageExplosion_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); b->s.scaleX = b->s.scaleY = 1; body_setCircle(&b->s.body, 0xa, b->s.body.offset.x, b->s.body.offset.y); b->s.body.enable = 1; sprite_setScale(&b->screenSprite, Weapon_PArea(b->weapon)); B_CarnageExplosion_Explode(b); } static void B_CarnageExplosion_Update(Bullet *b, float delta) { // il pozzo gira attorno al giocatore (sin dei millisecondi) b->totalTime += delta; b->Pfx->wellX = Core.Player->s.x + 0xfa * sinf(b->totalTime); b->Pfx->wellY = Core.Player->s.y + 0xfa * cosf(b->totalTime); } static const BulletVT B_CarnageExplosion = { "vfx", "round2.png", B_CarnageExplosion_ctor, NULL, B_CarnageExplosion_OnRecycle, NULL, B_CarnageExplosion_Update, NULL }; static void B_Carnage_canExplode(void *ctx) { ((Bullet *)ctx)->canExplode = 1; } static void B_Carnage_Explode(Bullet *b) { if (!b->canExplode) return; b->canExplode = 0; time_removeEvent(b->ExplodeTimer); b->ExplodeTimer = time_addEvent(0xc8, 0, 0, B_Carnage_canExplode, b); BulletPool_SpawnAt(b->weapon->TVexplosionPool, b->s.x, b->s.y, b->weapon, 0); b->exploIndex++; Sound_PlaySound("ExploGH2", 0.2f, 1, b->exploIndex % 2 == 0 ? 0x3e8 : -0x3e8, 0xc8, 4); Sound_PlaySound("ExploGH2", 0.2f, 1, b->exploIndex % 2 == 0 ? -0x384 : 0x384, 0xc8, 4); } static void B_Carnage_Bounce(void *ctx) { Bullet *b = ctx; b->n_hit = 0; B_Carnage_Explode(b); } // 'worldbounds' static void B_Carnage_ctor(Bullet *b) { b->color = 0xff0000; b->s.visible = 0; sprite_init(&b->trail, NULL, 0, 0); b->trail.owner = b; b->trail.draw = Diamond_trailDraw; // stessa scia di Runetracer (maxPositions 50) children_add(&b->trail); b->ExplodeTimer = (Timer){ -1, 0 }; } static void B_Carnage_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); body_setCircle(&b->s.body, 8, b->s.body.offset.x, b->s.body.offset.y); b->_speed = 1.1f; sprite_setTint(&b->s, 0xffff); b->canExplode = 1; time_removeEvent(b->ExpireTimer); b->exploIndex = 0; b->s.body.collideWorldBounds = 1, b->s.body.hasWorldBounce = 1, b->s.body.worldBounce = (Vector2){ 1, 1 }; b->s.body.customBounds = &Core.Player->WorldBoxCollider; b->s.body.onWorldBounds = B_Carnage_Bounce, b->s.body.onWorldBoundsCtx = b; b->trail.x = b->s.x - Core.Player->s.x, b->trail.y = b->s.y - Core.Player->s.y; b->color = 0xddff; b->trailAlpha = 1, b->s.alpha = 1; b->npos = 0; b->ExpireTimer = time_addEvent(Weapon_PDuration(b->weapon), 0, 0, B_Diamond_FadeOut, b); // FadeOut identico Sound_PlaySound("MagicMissile", 0.15f, 1, -0x64 * b->indexInWeapon, 0xc8, 0xa); } static void B_Carnage_OnHasHitWall(Bullet *b, Tile *t) { b->save_vel_x *= t && (t->faceRight || t->faceLeft) ? -1 : 1; b->save_vel_y *= t && (t->faceTop || t->faceBottom) ? -1 : 1; sprite_setVelocity(&b->s, b->save_vel_x, b->save_vel_y); b->n_hit = 0; B_Carnage_Explode(b); } static const float CarnageFan[10] = { 10, -10, 20, -20, 30, -30, 40, -40, 50, -50 }; static void B_Carnage_SetTarget(Bullet *b, Vector2 t) { Bullet_SetTargetFan(b, t, CarnageFan, 10); } static void B_Carnage_SetNullTarget(Bullet *b) { B_Carnage_SetTarget(b, Bullet_NullTargetPoint()); } static void B_Carnage_Update(Bullet *b, float delta) { b->trail.depth = b->s.y - Core.Player->s.y + 0.5f * game_height; int n = (int)ceilf(delta / 0x10); for (int i = 0; i < n; i++) { // trailUpdate: maxPositions 50 memmove(&b->positions[1], &b->positions[0], 49 * sizeof(Vector2)); b->positions[0] = (Vector2){ b->s.x, b->s.y }; if (b->npos < 50) b->npos++; } b->save_vel_x = b->s.body.velocity.x == 0 ? b->save_vel_x : b->s.body.velocity.x; b->save_vel_y = b->s.body.velocity.y == 0 ? b->save_vel_y : b->s.body.velocity.y; } static const BulletVT B_Carnage = { "vfx", "round.png", B_Carnage_ctor, NULL, B_Carnage_OnRecycle, NULL, B_Carnage_Update, NULL, B_Carnage_SetTarget, B_Carnage_SetNullTarget, B_Carnage_OnHasHitWall }; // OnHasHitAnObject: solo arcana Jewels static void W_Carnage_canExplode(void *ctx) { ((Weapon *)ctx)->canExplode = 1; } static void W_Carnage_ExplodeOnPlayer(void *ctx) { Weapon *w = ctx; if (!w->canExplode) return; w->canExplode = 0; time_removeEvent(w->ExplodeTimer); w->ExplodeTimer = time_addEvent(0x1f4, 0, 0, W_Carnage_canExplode, w); BulletPool_SpawnAt(w->OnGetHitExplosionPool, Core.Player->s.x, Core.Player->s.y, w, 0); w->exploIndex++; Sound_PlaySound("ExploGH", 0.5f, 1, w->exploIndex % 2 == 0 ? 0x3e8 : -0x3e8, 0xc8, 0xa); Sound_PlaySound("ExploGH2", 0.5f, 1, w->exploIndex % 2 == 0 ? 0x3e8 : -0x3e8, 0xc8, 0xa); Sound_PlaySound("ExploGH2", 0.5f, 1, w->exploIndex % 2 == 0 ? 0x384 : -0x384, 0xc8, 0xa); } static void W_Carnage_ctor(Weapon *w) { w->canExplode = 1; w->explodeOnExpire = 0; // explosionType = RAYEXPLOSION: usato solo con explodeOnExpire w->ExplodeTimer = (Timer){ -1, 0 }; PlayerEvents_add(EV_PLAYER_RECEIVEDDAMAGE, W_Carnage_ExplodeOnPlayer, w); PlayerEvents_add(EV_PLAYER_LOSTSHIELD, W_Carnage_ExplodeOnPlayer, w); } static void W_Carnage_Fire(Weapon *w) { w->target = Core.Enemies.n ? Core.Enemies.items[(int)floorf(frand() * Core.Enemies.n)] : NULL; base_Fire(w); } static void Weapon_onBulletOverlapsEnemy_Retaliation(void *ctx, Sprite *bs, Sprite *es) { // Weapon (0xe49a) Weapon *w = ctx; Bullet *b = bs->owner; Enemy *e = es->owner; if (e->isDead || Bullet_HasAlreadyHitObject(b, e, e->isDead)) return; float m = Player_PArmor(Core.Player) > 0 ? 1 + 0.1f * Player_PArmor(Core.Player) : 1, p = Weapon_PPower(w) * m; Enemy_GetDamaged(e, p, (int)w->hitVFX, w->knockback, w->bulletType); w->stats_inflictedDamage += p; if (Arcanas.hasDivineBloodline && e->isDead) Arcanas_IncreaseBloodlineBonus(); } static void Weapon_onBulletOverlapsEnemy_NightSword(void *ctx, Sprite *bs, Sprite *es); static BulletPool *BulletPool_new(Weapon *w, const BulletVT *vt) { // new BulletPool(scene, type) BulletPool *p = calloc(1, sizeof(BulletPool)); p->weapon = w; p->vt = vt; p->upperLimit = 0x32; return p; } // W_NightSword (0x1368) / W_NightSword2 (0xbe1f): sul colpo subito, sei fendenti sul giocatore; l'evoluzione si ferisce sparando static const float NightAngles[6] = { 0x14, -0x14, -0x46, 0x1e, -0x1e, 0x46 }, NightAngles2[6] = { 0x14, -0x14, -0x46, 0x1e, -0x1e, 0 }; static float W_NightSword_PPower(Weapon *w) { return base_PPower(w) + Arcanas.bloodlineDamage; } // (sic) il sangue due volte static void W_NightSword_canExplode(void *ctx) { ((Weapon *)ctx)->canExplode = 1; } static Bullet *W_NightSword_SpawnExplosionAt(Weapon *w, float x, float y, int index) { if (!w->secondaryPool) { w->secondaryPool = BulletPool_new(w, &B_NightSword); physics_addOverlap(&w->secondaryPool->group, &Core.Enemies, Weapon_onBulletOverlapsEnemy_NightSword, w); physics_addOverlap(&w->secondaryPool->group, &Core.Destructibles, Weapon_onBulletOverlapsDestuctible, w); } Bullet *b = BulletPool_SpawnAt(w->secondaryPool, x, y, w, index); if (b) b->vt->SetTarget(b, (Vector2){ Core.Player->s.x, Core.Player->s.y }); return b; } static void W_NightSword_delayedExplosion(void *ctx) { ShotCtx *c = ctx; W_NightSword_SpawnExplosionAt(c->w, Core.Player->s.x, Core.Player->s.y, c->index); } static void W_NightSword_ExplodeOnPlayer(void *ctx) { static ShotCtx shots[64]; static int n; Weapon *w = ctx; if (!w->canExplode) return; w->canExplode = 0; time_removeEvent(w->ExplodeTimer); w->ExplodeTimer = time_addEvent(fmaxf(Weapon_PInterval(w), w->retaliationDelay), 0, 0, W_NightSword_canExplode, w); W_NightSword_SpawnExplosionAt(w, Core.Player->s.x, Core.Player->s.y, 0); for (int i = 1; i < 6; i++) { ShotCtx *c = &shots[n++ & 63]; *c = (ShotCtx){ w, i }; time_addEvent(w->repeatInterval * i, 0, 0, W_NightSword_delayedExplosion, c); } } static void W_NightSword_ctor(Weapon *w) { w->fireAngles = NightAngles; w->canFinish = 0, w->retaliationDelay = 0x258, w->volume = 1, w->canExplode = 1, w->canCrit = 0; w->ExplodeTimer = (Timer){ -1, 0 }; PlayerEvents_add(EV_PLAYER_RECEIVEDDAMAGE, W_NightSword_ExplodeOnPlayer, w); PlayerEvents_add(EV_PLAYER_LOSTSHIELD, W_NightSword_ExplodeOnPlayer, w); } static void W_NightSword2_ctor(Weapon *w) { W_NightSword_ctor(w); w->fireAngles = NightAngles2, w->canFinish = 1, w->volume = 0.5f; } static void W_NightSword_ResetFiringTimer(Weapon *w) { if (w->retaliationOnly) time_removeEvent(w->firingTimer); else base_ResetFiringTimer(w); } // SetAsRetaliatoryOnly static void W_NightSword_SetAsRetaliatoryOnly(Weapon *w) { time_removeEvent(w->firingTimer); w->retaliationDelay = 0x3e8, w->retaliationOnly = 1; } static void W_NightSword_Fire(Weapon *w) { static Sprite *list[512]; // closest: i successivi record di vicinanza, nell'ordine dei nemici int n = 0; float best = HUGE_VALF; for (int i = 0; i < Core.Enemies.n && n < 512; i++) { Enemy *e = (Enemy *)Core.Enemies.items[i]; if (e->isDead) continue; float dx = Core.Player->s.x - e->s.x, dy = Core.Player->s.y - e->s.y, d = sqrtf(dx * dx + dy * dy); if (d < best) best = d, list[n++] = &e->s; } w->target = n > 1 ? list[n - 1 - (int)floorf(frand() * n * 0.5f)] : n ? list[0] : NULL; base_Fire(w); } static void W_NightSword2_Fire(Weapon *w) { W_NightSword_Fire(w); float d = fmaxf(1, Core.Player->hp / Core.Player->maxHp * 8); Player_GetDamaged(Core.Player, Player_PArmor(Core.Player) + d); } static void W_NightSword_heart(Weapon *w, Enemy *e) { float r = frand(); if (w->chance * Player_PLuck(Core.Player) <= r) return; float o = 0xa * (r - 0.5f); Pickup *h = Core_MakePickup(e->s.x + o, e->s.y - o, "LITTLEHEART"); if (h) h->goToPlayer = 1, h->time = 1; } static void W_NightSword_onBulletOverlapsEnemy(Weapon *w, Bullet *b, Enemy *e) { if (e->isDead || Bullet_HasAlreadyHitObject(b, e, e->isDead)) return; Enemy_GetDamaged(e, Weapon_PPower(w), (int)w->hitVFX, w->knockback, w->bulletType); w->stats_inflictedDamage += Weapon_PPower(w); if (e->isDead) W_NightSword_heart(w, e); } static void Weapon_onBulletOverlapsEnemy_NightSword(void *ctx, Sprite *bs, Sprite *es) { Weapon *w = ctx; Enemy *e = es->owner; int wasDead = e->isDead; Weapon_onBulletOverlapsEnemy_Retaliation(ctx, bs, es); if (!wasDead && e->isDead) W_NightSword_heart(w, e); } static const WeaponVT W_NightSword = { BASE, .bullet = &B_NightSword, .ctor = W_NightSword_ctor, .PPower = W_NightSword_PPower, .Fire = W_NightSword_Fire, .ResetFiringTimer = W_NightSword_ResetFiringTimer, .onBulletOverlapsEnemy = W_NightSword_onBulletOverlapsEnemy }; static const WeaponVT W_NightSword2 = { BASE, .bullet = &B_NightSword, .ctor = W_NightSword2_ctor, .PPower = W_NightSword_PPower, .Fire = W_NightSword2_Fire, .ResetFiringTimer = W_NightSword_ResetFiringTimer, .onBulletOverlapsEnemy = W_NightSword_onBulletOverlapsEnemy }; // W_Bocce (0x113e4): il danno cresce con la distanza fra Fortuna e Maledizione static float W_Bocce_PPower(Weapon *w) { float k = 1 + fminf(0xa, fabsf(Player_PLuck(Core.Player) - Player_PCurse(Core.Player))); return fminf(10, (Arcanas.silentMight + Core.Player->power) * sinev(Core.Player->sineMight)) * w->power * k + Arcanas.bloodlineDamage; } static void W_Bocce_ctor(Weapon *w) { sprite_init(&w->image, frame_get("vfx", "bubbleSphere.png"), 0.5f * game_width, 0.5f * game_height); w->image.alpha = 0.1f, w->image.scrollFactor0 = 1; sprite_setScale(&w->image, 2 * Weapon_PArea(w)); children_add(&w->image); w->bocceTint = 0xffffff, w->nOrbs = 8; tweens_add((TweenConfig){ .props = { { &w->image.alpha, NULL, 0.3f } }, .nprops = 1, .yoyo = 1, .duration = 0x3e8, .repeat = -1 }); tweens_add((TweenConfig){ .props = { { &w->bocceTint, NULL, 0x880000 } }, .nprops = 1, .yoyo = 1, .duration = 0x1770, .repeat = -1 }); for (int i = 0; i < 8; i++) { sprite_init(&w->orbs[i], frame_get("vfx", "bulletFourSeasons.png"), 0, 0); children_add(&w->orbs[i]); } for (int i = 0; i < 9; i++) w->orbAngles[i] = 2 * PI * (i / 9.0f), w->orbMul[i] = 0.8f + 0.2f * frand(); } static void W_Bocce_Fire(Weapon *w) { w->image.x = 0.5f * game_width, w->image.y = 0.5f * game_height; sprite_setScale(&w->image, 2 * Weapon_PArea(w)); base_Fire(w); } static void W_Bocce_Update(Weapon *w, float delta) { base_Update(w, delta); w->image.tint = (unsigned)w->bocceTint; // il tween interpola il numero intero, non i canali w->image.depth = Core.Player->s.depth - 0.5f * game_height; sprite_setScale(&w->image, 2 * PixelScale * Weapon_PArea(w)); w->image.x = 0.5f * game_width, w->image.y = 0.5f * game_height; for (int i = 0; i < 9; i++) w->orbAngles[i] += PI / 0x168 * w->orbMul[i] * delta; float area = Weapon_PArea(w), r = 0x20 * area, px = Core.Player->s.x, py = Core.Player->s.y; for (int i = 0; i < 8; i++) { float a = w->orbAngles[i], b = w->orbAngles[i + 1]; w->orbs[i].x = px + (i < 2 || i >= 6 ? cosf(a) : sinf(a)) * r; w->orbs[i].y = py + (i < 2 || (i >= 4 && i < 6) ? sinf(b) : cosf(b)) * r; sprite_setScale(&w->orbs[i], area); } } static const WeaponVT W_Bocce = { BASE, .bullet = &B_Bocce, .ctor = W_Bocce_ctor, .PPower = W_Bocce_PPower, .PAmount = one_PAmount, .Fire = W_Bocce_Fire, .Update = W_Bocce_Update }; // W_FourSeasons (0xa2d9) / W_FourSeasons2 (0x16755): quattro angoli che si stringono col livello / quattro angoli fissi piu' il centro static const WeaponVT W_FourSeasons2; static float W_FS_PPower(Weapon *w) { float p = (w->power + 0.001f * Weapon_PDuration(w)) * Weapon_PAmount(w); return fminf(10, (Arcanas.silentMight + Core.Player->power) * sinev(Core.Player->sineMight)) * p + Arcanas.bloodlineDamage; } static void W_FS_positions(Weapon *w) { static const int OFF[9] = { 0xc0, 0xc0, 0xb0, 0xa0, 0x90, 0x80, 0x70, 0x60, 0x40 }; float o = w->vt == &W_FourSeasons2 ? 0x40 : OFF[w->level < 8 ? w->level : 8], hw = 0.5f * game_width, hh = 0.5f * game_height, px = Core.Player->s.x, py = Core.Player->s.y; w->seasonPos[0] = (Vector2){ px - hw + o, py - hh + o }; w->seasonPos[1] = (Vector2){ px + hw - o, py - hh + o }; w->seasonPos[2] = (Vector2){ px - hw + o, py + hh - o }; w->seasonPos[3] = (Vector2){ px + hw - o, py + hh - o }; w->seasonPos[4] = (Vector2){ px, py }; } static void W_FS_ctor(Weapon *w) { w->nOrbs = w->vt == &W_FourSeasons2 ? 0x18 : 8; for (int i = 0; i < w->nOrbs; i++) { sprite_init(&w->orbs[i], frame_get("vfx", "bulletFourSeasons.png"), 0, 0); w->orbs[i].scrollFactor0 = w->vt == &W_FourSeasons2; children_add(&w->orbs[i]); } w->explodeOnExpire = 0; w->seasonFrame[0] = frame_get("vfx", "leaf0000.png"); } static void W_FS_animate(Weapon *w, float delta) { // i fotogrammi delle RenderTexture, a 30 fps static const struct { const char *fmt; int n; } A1[2] = { { "leaf%04d.png", 0x14 }, { "snowb%04d.png", 7 } }, A2[5] = { { "rock%04d.png", 0x30 }, { "spinThick%04d.png", 0x2c }, { "fiamma%04d.png", 0x19 }, { "icicle%04d.png", 0x18 }, { "lightning%04d.png", 4 } }; int evo = w->vt == &W_FourSeasons2; w->seasonClock += delta; int f = (int)(w->seasonClock * 0x1e / 1000); for (int i = 0; i < (evo ? 5 : 2); i++) { const char *fmt = evo ? A2[i].fmt : A1[i].fmt; w->seasonFrame[i] = frame_get("vfx", TextFormat(fmt, f % (evo ? A2[i].n : A1[i].n))); } } static void W_FS_spinOn(void *ctx) { ((Weapon *)ctx)->canSpin = 1; } static void W_FS_MakeLevelOne(Weapon *w) { base_MakeLevelOne(w); W_FS_animate(w, 0); w->canSpin = 0; for (int i = 0; i < 9; i++) w->orbAngles[i] = 2 * PI * 0.11f * i; W_FS_positions(w); for (int i = 0; i < 8; i++) { Sprite *o = &w->orbs[i]; o->visible = 1, o->x = Core.Player->s.x, o->y = Core.Player->s.y; tweens_add((TweenConfig){ .props = { { &o->x, NULL, w->seasonPos[i % 4].x }, { &o->y, NULL, w->seasonPos[i % 4].y } }, .nprops = 2, .duration = 0x1f4, .onComplete = W_FS_spinOn, .ctx = w }); } } static void W_FS2_MakeLevelOne(Weapon *w) { base_MakeLevelOne(w); W_FS_animate(w, 0); for (int i = 0; i < 0x18; i++) w->orbAngles[i] = 2 * PI * (i / (float)0x18); } static void W_FS_Update(Weapon *w, float delta) { base_Update(w, delta); W_FS_positions(w); W_FS_animate(w, delta); if (!w->canSpin) return; for (int i = 0; i < 9; i++) w->orbAngles[i] += PI / 0x168 * delta; for (int i = 0; i < 8; i++) { w->orbs[i].x = w->seasonPos[i % 4].x + cosf(w->orbAngles[i]) * 0x20; w->orbs[i].y = w->seasonPos[i % 4].y + cosf(w->orbAngles[i + 1]) * 0x20; } } static void W_FS2_Update(Weapon *w, float delta) { base_Update(w, delta); W_FS_positions(w); W_FS_animate(w, delta); float r = 0.65f * game_height, cx = 0.5f * game_width, cy = 0.5f * game_height; for (int i = 0; i < 0x18; i++) { w->orbAngles[i] += PI / 0x2710 * delta; w->orbs[i].x = cx + cosf(w->orbAngles[i]) * r; w->orbs[i].y = cy + sinf(w->orbAngles[i]) * r; } } static void W_FS_shot(void *ctx) { ShotCtx *c = ctx; BulletPool_SpawnAt(c->w->pool, c->w->seasonPos[c->index].x, c->w->seasonPos[c->index].y, c->w, c->index); } static void W_FS_Fire(Weapon *w) { static ShotCtx shots[64]; static int n; Sound_PlaySound("Seasons1", 1, 1, 0, 0x7d0, 1); for (int i = 0; i < (w->vt == &W_FourSeasons2 ? 5 : 4); i++) { ShotCtx *c = &shots[n++ & 63]; *c = (ShotCtx){ w, i }; if (w->repeatInterval * i > 0) w->lastShotTimer = time_addEvent(w->repeatInterval * i, 0, 0, W_FS_shot, c); else W_FS_shot(c); } if (w->lastFiringInterval != Weapon_PInterval(w)) w->lastFiringInterval = Weapon_PInterval(w), Weapon_ResetFiringTimer(w); } static const WeaponVT W_FourSeasons = { BASE, .bullet = &B_FourSeasons, .ctor = W_FS_ctor, .PPower = W_FS_PPower, .MakeLevelOne = W_FS_MakeLevelOne, .Update = W_FS_Update, .Fire = W_FS_Fire }; static const WeaponVT W_FourSeasons2 = { BASE, .bullet = &B_FourSeasons2, .ctor = W_FS_ctor, .PPower = W_FS_PPower, .MakeLevelOne = W_FS2_MakeLevelOne, .Update = W_FS2_Update, .Fire = W_FS_Fire }; // --- Foscari: gli incantesimi (0x142c3, 0x7d8a, 0xc553) e la loro unione (0xe817) --------------------------------------------- static Sprite *Weapon_closestAlive(float range) { // dal giocatore; range: Number.MAX_VALUE se assente Sprite *best = NULL; float bd = range, px = Core.Player->s.x, py = Core.Player->s.y; for (int i = 0; i < Core.Enemies.n; i++) { Enemy *e = Core.Enemies.items[i]->owner; if (e->isDead) continue; float dx = px - e->s.body.center.x, dy = py - e->s.body.center.y, d = sqrtf(dx * dx + dy * dy); if (d < bd) best = &e->s, bd = d; } return best; } static void Weapon_DirectDamage(Weapon *w, Sprite *t) { Enemy *e = t->owner; if (e->isDead) return; Enemy_GetDamaged(e, Weapon_PPower(w), (int)w->hitVFX, w->knockback, w->bulletType); w->stats_inflictedDamage += Weapon_PPower(w); } static float Might_P(float p) { return fminf(10, (Arcanas.silentMight + Core.Player->power) * sinev(Core.Player->sineMight)) * p + Arcanas.bloodlineDamage; } static Vector2 W_Spell_GetSource(Weapon *w) { if (!w->wellSrc) return (Vector2){ Core.Player->s.x, Core.Player->s.y }; w->sourceIndex = (w->sourceIndex + 1) % 2; return w->wellSrc[w->sourceIndex]; } static float W_String_PPower(Weapon *w) { return Might_P(w->power * (1.25f * Weapon_PSpeed(w))); } static void W_String_later(void *ctx) { Weapon *w = ctx; Sprite *t = Weapon_closestAlive(fminf(0.4f * game_width, 0.4f * game_height)); if (!t) return; Vector2 s = W_Spell_GetSource(w); w->target = t; Weapon_FireOneBullet(w, s.x + 8 * w->critChancesArray[w->critIndex++ % 1000], w->spellY, 0); Weapon_DirectDamage(w, t); } static void W_String_Fire(Weapon *w) { Sprite *t = Weapon_closestAlive(fminf(0.4f * game_width, 0.4f * game_height)); Vector2 s = W_Spell_GetSource(w); float x = s.x + 8 * w->critChancesArray[w->critIndex++ % 1000]; w->spellY = s.y - 0x18; if (t) w->target = t, Weapon_FireOneBullet(w, x, w->spellY, 0), Weapon_DirectDamage(w, t); for (int i = 1; i < Weapon_PAmount(w); i++) w->lastShotTimer = time_addEvent(w->repeatInterval * i, 0, 0, W_String_later, w); if (w->lastFiringInterval != Weapon_PInterval(w)) w->lastFiringInterval = Weapon_PInterval(w), Weapon_ResetFiringTimer(w); } static float W_Stream_PPower(Weapon *w) { return Might_P(w->power * (1.25f * Weapon_PArea(w))); } static void W_Stream_Fire(Weapon *w) { Sprite *t = Weapon_closestAlive(HUGE_VALF); if (t) { Vector2 s = W_Spell_GetSource(w); w->target = t; Weapon_FireOneBullet(w, s.x, s.y, 0); } if (w->lastFiringInterval != Weapon_PInterval(w)) w->lastFiringInterval = Weapon_PInterval(w), Weapon_ResetFiringTimer(w); } static float W_Strike_PPower(Weapon *w) { return Might_P(w->power * (1.25f * Core.Player->power)); } static void W_Strike_later(void *ctx) { Weapon *w = ctx; Sprite *t = Weapon_closestAlive(HUGE_VALF); if (t) w->target = t, Weapon_FireOneBullet(w, t->x, t->y, 0), Weapon_DirectDamage(w, t); } static void W_Strike_Fire(Weapon *w) { W_Strike_later(w); for (int i = 1; i < Weapon_PAmount(w); i++) w->lastShotTimer = time_addEvent(w->repeatInterval * i, 0, 0, W_Strike_later, w); if (w->lastFiringInterval != Weapon_PInterval(w)) w->lastFiringInterval = Weapon_PInterval(w), Weapon_ResetFiringTimer(w); } static const WeaponVT W_Spellstring = { BASE, .bullet = &B_Spellstring, .PPower = W_String_PPower, .Fire = W_String_Fire }; static const WeaponVT W_Spellstream = { BASE, .bullet = &B_Spellstream, .PPower = W_Stream_PPower, .Fire = W_Stream_Fire }; static const WeaponVT W_Spellstrike = { BASE, .bullet = &B_Spellstrike, .PPower = W_Strike_PPower, .Fire = W_Strike_Fire }; static void Weapon_CopyAccumulatedLimitBreaks(Weapon *from, Weapon *to) { for (int i = 0; i < from->nLbKeys; i++) { float *s = Weapon_field(from, from->lbKeys[i]), *d = Weapon_field(to, from->lbKeys[i]); if (s && d) *d += *s; // (sic) tutto il valore dell'arma di partenza, non l'accumulato if (to->nLbKeys < 16) to->lbKeys[to->nLbKeys++] = from->lbKeys[i]; } if (from->nLbKeys) to->limitBreakLevel += from->limitBreakLevel; } static void Weapon_ScreenShake_start(void *c) { (void)c; camera_followOffsetX = -3; } static void Weapon_ScreenShake_done(void *c) { (void)c; camera_followOffsetX = 0; } static void Weapon_ScreenShake(int repeat) { if (!po_is("ScreenShakeEnabled")) return; camera_followOffsetX = -3; tweens_add((TweenConfig){ .props = { { &camera_followOffsetX, NULL, 3 } }, .nprops = 1, .duration = 0x18, .yoyo = 1, .repeat = repeat, .onComplete = Weapon_ScreenShake_done }); } static Weapon *Weapon_new(const char *bulletType); static void Weapon_Init(Weapon *w); static Weapon *W_Strom_sub(Weapon *w, const char *type) { // WeaponFactory.GetWeapon, portata a livello 6; resta fuori dalle liste: l'aggiorna Spellstrom Weapon *s = Weapon_new(type); if (!s) return NULL; Weapon_Init(s); s->skipAddingEvolution = 1; while (s->level < 6 && s->vt->LevelUp(s)) {} (void)w; return s; } static void W_Strom_ctor(Weapon *w) { static Vector2 ring[0x78]; for (int i = 0; i < 0x78; i++) ring[i] = (Vector2){ 0xc8 * cosf(2 * PI * i / 0x78), 0xc8 * sinf(2 * PI * i / 0x78) }; // la zona 'edge' si calcola una volta: raggio 200 fisso (sic) w->stormPfx = particles_add(); w->stormE1 = particles_createEmitter(w->stormPfx, (EmitterConfig){ .frames = { frame_get("vfx", "2Spell1.png"), frame_get("vfx", "2Spell2.png") }, .nframes = 2, .speed = EOP(0), .quantity = 1, .lifespan = ERND(0xbb8, 0x1b58), .alpha = ERANGE(1, 0), .scale = ERND(1, 2), .blendAdd = 1, .hasZone = 1, .zoneRadius = 0x10, .on = 0 }); w->stormE2 = particles_createEmitter(w->stormPfx, (EmitterConfig){ .frames = { frame_get("vfx", "2Spell3.png"), frame_get("vfx", "2Spell4.png") }, .nframes = 2, .speed = EOP(0), .quantity = 1, .lifespan = ERND(0x3e8, 0x7d0), .alpha = ERANGE(1, 0), .scale = { 0, 2, 2, Ease_QuintOut }, .hasZone = 1, .zoneRadius = 0x10, .on = 0 }); w->stormPfx->hasWell = w->stormPfx->hasWell2 = 1; w->stormPfx->wellPower = 1 * 0x190, w->stormPfx->wellEpsilon = 0xc8 * 0xc8; // createGravityWell({ power: 1, epsilon: 200, gravity: 400 }) ParticleManager *m = particles_add(); m->scrollFactor0 = 1; w->circleE = particles_createEmitter(m, (EmitterConfig){ .frames = { frame_get("vfx", "2Spell1.png"), frame_get("vfx", "2Spell2.png"), frame_get("vfx", "2Spell3.png") }, .nframes = 3, .quantity = 1, .alpha = ERANGE(1, 0), .lifespan = EOP(0x5dc), .blendAdd = 1, .edge = ring, .nEdge = 0x78, .flowEveryFrame = 1, .on = 1 }); w->circleE->x = 0.5f * game_width, w->circleE->y = 0.5f * game_height; } static void W_Strom_OnStart(Weapon *w) { base_OnStart(w); if ((w->Weapon_String = W_Strom_sub(w, "SPELL_STRING"))) w->Weapon_String->wellSrc = w->wellPos, w->Weapon_String->power += 1; if ((w->Weapon_Stream = W_Strom_sub(w, "SPELL_STREAM"))) w->Weapon_Stream->speed += 1, w->Weapon_Stream->duration += 0x1f4, w->Weapon_Stream->area += 0.5f; if ((w->Weapon_Strike = W_Strom_sub(w, "SPELL_STRIKE"))) w->Weapon_Strike->amount += 2; for (int i = 0; i < Core.n_RemovedWeapons; i++) { Weapon *r = Core.RemovedWeapons[i]; if (!strcmp(r->bulletType, "SPELL_STRING") && w->Weapon_String) Weapon_CopyAccumulatedLimitBreaks(r, w->Weapon_String); if (!strcmp(r->bulletType, "SPELL_STREAM") && w->Weapon_Stream) Weapon_CopyAccumulatedLimitBreaks(r, w->Weapon_Stream); if (!strcmp(r->bulletType, "SPELL_STRIKE") && w->Weapon_Strike) Weapon_CopyAccumulatedLimitBreaks(r, w->Weapon_Strike); } Sound_PlaySound("SpellStrom", 2, 1, 0, 0x190, 1); Weapon_ScreenShake(0xc); } // Performance: un terzo delle particelle (~1000 vive invece di ~3000, sulla Vita ~10 ms di disegno). Grafica: come l'originale static int Strom_n(int n) { return vs_quality_mode() ? n : (n + 2) / 3; } static void W_Strom_ExplodeUpdate(void *ctx) { Weapon *w = ctx; Rectangle r = { -0.5f * game_width * w->stormK, -5, game_width * w->stormK, 0xa }; w->stormE1->c.zoneRect = w->stormE2->c.zoneRect = r; emitter_emitParticleAt(w->stormE1, Core.Player->s.x, Core.Player->s.y, Strom_n(0xa0)); emitter_emitParticleAt(w->stormE2, Core.Player->s.x, Core.Player->s.y, Strom_n(0xa0)); } static void W_Strom_ExplodeDone(void *ctx) { ((Weapon *)ctx)->skipEmitUpdate = 0; } static void W_Strom_ExplodeSingularity(void *ctx) { Weapon *w = ctx; w->skipEmitUpdate = 1; w->stormE1->c.hasZone = w->stormE2->c.hasZone = 0; w->stormE1->c.hasZoneRect = w->stormE2->c.hasZoneRect = 1; w->stormE1->c.blendAdd = w->stormE2->c.blendAdd = 1; w->stormK = 0; tweens_add((TweenConfig){ .props = { { &w->stormK, NULL, 1 } }, .nprops = 1, .duration = 0xc8, .onUpdate = W_Strom_ExplodeUpdate, .onComplete = W_Strom_ExplodeDone, .ctx = w }); } static void W_Strom_restoreStart(void *ctx) { Weapon *w = ctx; Weapon_ScreenShake(0xc); Sound_PlaySound("SpellStrike", 1, 0.5f, 0, 0xc8, 4); Sound_PlaySound("SpellStrike", 1, 0.4f, 0, 0xc8, 4); w->singularityTimes++; } static void W_Strom_restoreUpdate(void *ctx) { Weapon *w = ctx; w->stormPfx->s.depth = game_height; emitter_emitParticleAt(w->stormE1, Core.Player->s.x, Core.Player->s.y, Strom_n(0x50)); emitter_emitParticleAt(w->stormE2, Core.Player->s.x, Core.Player->s.y, Strom_n(0x50)); } static void W_Strom_restoreDone(void *ctx) { Weapon *w = ctx; float p = Might_P((w->power + 0.001f * Weapon_PDuration(w) + Weapon_PSpeed(w) + Weapon_PArea(w)) * Weapon_PAmount(w) + 0.5f * w->singularityTimes); // SingularityPower for (int i = 0; i < Core.Enemies.n; i++) { // DamageAllEnemies Enemy *e = Core.Enemies.items[i]->owner; if (ContainmentRect_Contains(&Core.containmentRect_Exact, &e->s)) Enemy_GetDamaged(e, p, HIT_NONE, 0, w->bulletType), w->stats_inflictedDamage += p; } w->doingSingularity = 0; } static void W_Strom_Update(Weapon *w, float delta) { base_Update(w, delta); if (!w->hasBullets) { // InitBullets BulletPool_SpawnAt(w->pool, w->wellPos[0].x, w->wellPos[0].y, w, 0); BulletPool_SpawnAt(w->pool, w->wellPos[1].y, w->wellPos[1].y, w, 1); w->hasBullets = 1; } w->singularityTime += delta; if (w->singularityTime > 0x4e20 + 0x4e20 * fmaxf(0.1f, Arcanas.silentCooldown + Core.Player->cooldown)) { // SingularityDelay w->doingSingularity = 1; Weapon_ScreenShake(0xc); Sound_PlaySound("SpellStrom", 1, 1, 0, 0x190, 3), Sound_PlaySound("SpellStrom", 1, 0.6f, 0, 0x190, 3), Sound_PlaySound("SpellStrom", 1, 0.2f, 0, 0x190, 3); tweens_add((TweenConfig){ .props = { { &w->stormRadius, NULL, 1 } }, .nprops = 1, .duration = 0x1388, .onComplete = W_Strom_ExplodeSingularity, .ctx = w }); tweens_add((TweenConfig){ .props = { { &w->stormRadius, NULL, fminf(0.4f * game_width, 0.4f * game_height) } }, .nprops = 1, .duration = 0xc8, .delay = 0x1388, .onStart = W_Strom_restoreStart, .onUpdate = W_Strom_restoreUpdate, .onComplete = W_Strom_restoreDone, .ctx = w }); w->singularityTime = 0; } if (w->Weapon_String) w->Weapon_String->vt->Update(w->Weapon_String, delta); if (w->Weapon_Stream) w->Weapon_Stream->vt->Update(w->Weapon_Stream, delta); if (w->Weapon_Strike) w->Weapon_Strike->vt->Update(w->Weapon_Strike, delta); if (!w->doingSingularity) { w->stormRadius = fminf(0.4f * game_width, 0.4f * game_height); w->stormE1->c.zoneRadius = w->stormE2->c.zoneRadius = 0.8f * w->stormRadius; w->stormPfx->s.depth = -game_height; } w->angleValue += 0.001f * delta; float cx = cosf(w->angleValue) * w->stormRadius, cy = sinf(w->angleValue) * w->stormRadius, px = Core.Player->s.x, py = Core.Player->s.y; w->wellPos[0] = (Vector2){ px + cx, py + cy }, w->wellPos[1] = (Vector2){ px - cx, py - cy }; w->stormPfx->wellX = w->wellPos[0].x, w->stormPfx->wellY = w->wellPos[0].y, w->stormPfx->well2X = w->wellPos[1].x, w->stormPfx->well2Y = w->wellPos[1].y; if (!w->skipEmitUpdate) { w->stormE1->c.blendAdd = w->stormE2->c.blendAdd = 0; w->stormE1->c.hasZone = w->stormE2->c.hasZone = 1; w->stormE1->c.hasZoneRect = w->stormE2->c.hasZoneRect = 0; emitter_emitParticleAt(w->stormE1, px, py, Strom_n(8)); emitter_emitParticleAt(w->stormE2, px, py, Strom_n(8)); } } static void noop_Fire(Weapon *w) { (void)w; } static const WeaponVT W_Spellstrom = { BASE, .bullet = &B_Spellstrom, .ctor = W_Strom_ctor, .OnStart = W_Strom_OnStart, .Update = W_Strom_Update, .Fire = noop_Fire }; static void W_Carnage_OnStart(Weapon *w) { base_OnStart(w); w->TVexplosionPool = BulletPool_new(w, &B_CarnageExplosion); w->OnGetHitExplosionPool = BulletPool_new(w, &B_CarnageExplosion); physics_addOverlap(&w->TVexplosionPool->group, &Core.Enemies, Weapon_onBulletOverlapsEnemy, w); physics_addOverlap(&w->TVexplosionPool->group, &Core.Destructibles, Weapon_onBulletOverlapsDestuctible, w); physics_addOverlap(&w->OnGetHitExplosionPool->group, &Core.Enemies, Weapon_onBulletOverlapsEnemy_Retaliation, w); physics_addOverlap(&w->OnGetHitExplosionPool->group, &Core.Destructibles, Weapon_onBulletOverlapsDestuctible, w); } static const WeaponVT W_Carnage = { BASE, .CheckArcanas = CA_jewels, .bullet = &B_Carnage, .ctor = W_Carnage_ctor, .Fire = W_Carnage_Fire, .OnStart = W_Carnage_OnStart }; // CheckArcanas (Jewels): arcana // --- Peachone / Ebony Wings: W_Silf (0x13a8e), W_Silf2 (0x127ba), B_Silf (0x544e), B_Silf2 (0x11c17) ------------- // Un uccello segue il giocatore; i colpi cadono su 12 punti a caso di una zona che gira attorno a lui. static Vector2 Spline_getPoint(const Vector2 *p, int n, float t); static void Silf_zoneDraw(Sprite *s) { // scene.add.circle con solo lo stroke: raggio in scaleX, lineWidth in scaleY if (!s->visible || s->alpha <= 0) return; Vector2 c = { s->x - camera_scrollX, s->y - camera_scrollY }; DrawRing(c, s->scaleX - 0.5f * s->scaleY, s->scaleX + 0.5f * s->scaleY, 0, 360, 48, hexc(s->tint, s->alpha)); } static void Silf_zone(Sprite *s, float radius, float lineWidth, unsigned color) { sprite_init(s, NULL, 0, 0); s->draw = Silf_zoneDraw; s->scaleX = radius, s->scaleY = lineWidth, s->tint = color; children_add(s); } static void W_Silf_ctor_common(Weapon *w, int silf2) { static Animation idle[2]; w->silf2 = silf2; w->ntargets = 12; w->damageZoneDistance = 0x1c8 * 0.5f; // IS_PORTRAIT ? GAMEPLAY_PIXEL_WIDTH : GAMEPLAY_PIXEL_HEIGHT w->damageZoneDefaultRadius = 0.25f * w->damageZoneDistance; w->damageZoneDistance -= w->damageZoneDefaultRadius; w->delayBasedOnDuration = 1; w->rayDuration = 0x1f4; w->runSpeed = PlayerPxSpeed / 1.178571428571429f; Silf_zone(&w->damageZone, w->damageZoneDefaultRadius, 2, 0xffff00); w->damageZone.visible = 0; Silf_zone(&w->targetZone, w->damageZoneDefaultRadius, 1, silf2 ? 0xff88ff : 0x8888ff); w->targetZone.alpha = 0.5f; sprite_init(&w->sprite, frame_get("vfx", silf2 ? "ProjectileBird4.png" : "ProjectileBird2.png"), Core.Player->s.x, Core.Player->s.y); children_add(&w->sprite); physics_existing(&w->sprite); if (!idle[silf2].n) make_anim(&idle[silf2], "vfx", "ProjectileBird", silf2 ? 4 : 1, silf2 ? 5 : 2, 0, 6, -1); anims_play(&w->sprite, &idle[silf2], 0); w->sprite.depth = MAX_SAFE_INTEGER - 0x3e7; } static void W_Silf_ctor(Weapon *w) { W_Silf_ctor_common(w, 0); } static void W_Silf2_ctor(Weapon *w) { W_Silf_ctor_common(w, 1); } static void W_Silf_Fire(Weapon *w) { if (w->blockFire) return; w->repeatInterval = w->interval / Weapon_PAmount(w); w->damageZone.scaleX = w->damageZoneDefaultRadius; float r = w->damageZone.scaleX; // this.circle for (int i = 0; i < 12; i++) { // Geom.Circle.Random float t = 2 * PI * frand(), u = frand() + frand(), k = u > 1 ? 2 - u : u; w->targets[i] = (Vector2){ k * cosf(t) * r + w->damageZone.x, k * sinf(t) * r + w->damageZone.y }; } base_Fire(w); } static void W_Silf_Update(Weapon *w, float delta) { base_Update(w, delta); w->totalTime += delta; w->angleTime += delta; float ox = w->silfCounter ? ((Core.Player->s.flipX != (w->silfCounter == 2)) ? 0x24 : -0x24) : ((Core.Player->s.flipX != w->silf2) ? 0x18 : -0x18); // OffsetX (Silf2 al contrario) float oy = w->silfCounter ? 0x18 : 0; // OffsetY Sprite *s = &w->sprite; float dx = Core.Player->s.x + ox - s->x, dy = Core.Player->s.y - s->y; if (dx * dx + dy * dy > 0x1388) { Vector2 *d = &w->_currentDirection; d->x = Core.Player->s.x + ox - s->x, d->y = Core.Player->s.y - 0x18 - s->y + oy; float l = sqrtf(d->x * d->x + d->y * d->y); if (l > 0) d->x /= l, d->y /= l; s->flipX = d->x < 0; sprite_setVelocity(s, w->runSpeed * d->x * Core.Player->moveSpeed, w->runSpeed * d->y * Core.Player->moveSpeed); } else { sprite_setVelocity(s, 0x23 * w->_currentDirection.x, 0x23 * w->_currentDirection.y); } float sg = (w->silf2 || w->silfCounter == 2) ? -1 : 1, a = 0.001f * (w->angleTime - w->rayDuration) * Weapon_PSpeed(w); w->targetZone.x = Core.Player->s.x + cosf(sg * a) * w->damageZoneDistance, w->targetZone.y = Core.Player->s.y + sinf(sg * a) * w->damageZoneDistance; a = 0.001f * w->angleTime * Weapon_PSpeed(w); w->damageZone.x = Core.Player->s.x + cosf(sg * a) * w->damageZoneDistance, w->damageZone.y = Core.Player->s.y + sinf(sg * a) * w->damageZoneDistance; if (w->totalTime >= Weapon_PDuration(w)) { w->totalTime = -Weapon_PDuration(w) * w->delayBasedOnDuration * Core.Player->cooldown; w->blockFire = 1; w->targetZone.alpha = 0.1f; if (w->totalTime >= Weapon_PDuration(w)) w->totalTime = 0, w->blockFire = 0, w->targetZone.alpha = 0.5f; } else if (w->totalTime > 0) { w->blockFire = 0; w->targetZone.alpha = 0.5f; } } // LevelUp / ApplyLimitBreak: counterWeapon solo con l'arcana Aquarius static const BulletVT B_Silf, B_Silf2; static const WeaponVT W_Silf = { BASE, .CheckArcanas = CA_silf, .bullet = &B_Silf, .ctor = W_Silf_ctor, .Fire = W_Silf_Fire, .Update = W_Silf_Update }; static const WeaponVT W_Silf2 = { BASE, .CheckArcanas = CA_silf, .bullet = &B_Silf2, .ctor = W_Silf2_ctor, .Fire = W_Silf_Fire, .Update = W_Silf_Update }; // Gemini: W_Silf_Counter (0x17c85) / W_Silf2_Counter (0x82eb), entrambi figli di Silf: zone e sprite nascono col costruttore di Silf, // poi distanza 150, raggio di fuoco 50, OffsetX 36 e OffsetY 24; il secondo gira al contrario static void W_SilfCounter_common(Weapon *w, int k) { static Animation idle[2]; W_Silf_ctor_common(w, 0); w->silfCounter = k; w->damageZoneDistance = 0x96, w->damageZoneDefaultRadius = 0x32; if (!idle[k - 1].n) make_anim(&idle[k - 1], "vfx", "ProjectileBird_C", k == 1 ? 1 : 4, k == 1 ? 2 : 5, 0, 6, -1); anims_play(&w->sprite, &idle[k - 1], 0); } static void W_SilfCounter_ctor(Weapon *w) { W_SilfCounter_common(w, 1); } static void W_Silf2Counter_ctor(Weapon *w) { W_SilfCounter_common(w, 2); } static const BulletVT B_Silf_Counter, B_Silf2_Counter; static const WeaponVT W_Silf_Counter = { BASE, .CheckArcanas = CA_silfCounter, .bullet = &B_Silf_Counter, .ctor = W_SilfCounter_ctor, .Fire = W_Silf_Fire, .Update = W_Silf_Update }; static const WeaponVT W_Silf2_Counter = { BASE, .CheckArcanas = CA_none, .bullet = &B_Silf2_Counter, .ctor = W_Silf2Counter_ctor, .Fire = W_Silf_Fire, .Update = W_Silf_Update }; // Curve.getPointAt: lunghezza d'arco su 100 divisioni (getLengths + getUtoTmapping) static void Silf_curveLengths(Bullet *b) { Vector2 last = Spline_getPoint(b->curvePts, 3, 0); float sum = 0; b->arcLengths[0] = 0; for (int p = 1; p <= 100; p++) { Vector2 c = Spline_getPoint(b->curvePts, 3, p / 100.0f); sum += sqrtf((c.x - last.x) * (c.x - last.x) + (c.y - last.y) * (c.y - last.y)); b->arcLengths[p] = sum; last = c; } } static Vector2 Silf_getPointAt(Bullet *b, float u) { const float *L = b->arcLengths; float target = u * L[100]; int low = 0, high = 100, i = 0; while (low <= high) { i = (int)floorf(low + (high - low) / 2.0f); float c = L[i] - target; if (c < 0) low = i + 1; else if (c > 0) high = i - 1; else { high = i; break; } } i = high; float t = L[i] == target ? i / 100.0f : (i + (target - L[i]) / (L[i + 1] - L[i])) / 100.0f; return Spline_getPoint(b->curvePts, 3, t); } static void Silf_trailDraw(Sprite *s) { // RibbonTrail di 24 punti, Rope orizzontale Bullet *b = s->owner; if (s->visible) Rope_drawH(b->ropePts, 0x18, b->trailFrame, 1, s->alpha, b->trailAdd, 0); } static void B_Silf_ctor_common(Bullet *b, int silf2) { b->isKilled = 1; b->trailAlpha = silf2 ? 1 : 0.4f; b->s.alpha = silf2 ? 1 : 0.5f; // startingAlpha b->_speed = 0; b->duration = b->weapon->rayDuration; b->fadeInTween = b->fadeOutTween = b->scaleTween = TWEEN_NONE; b->explodeTimer = (Timer){ -1, 0 }; sprite_init(&b->trail, NULL, 0, 0); // MakeTrail: Silf la crea al primo OnRecycle, Silf2 nel costruttore b->trail.owner = b; b->trail.draw = Silf_trailDraw; b->trail.depth = MAX_SAFE_INTEGER - 0x3eb; b->trail.visible = 0; b->trailAdd = !silf2; b->trailFrame = frame_get("vfx", silf2 ? "Gradient4_4px.png" : "Gradient3_4px.png"); children_add(&b->trail); } static void B_Silf_ctor(Bullet *b) { B_Silf_ctor_common(b, 0); } static void B_Silf2_ctor(Bullet *b) { B_Silf_ctor_common(b, 1); } static void B_Silf_DeSpawn(Bullet *b) { if (b->weapon->explodeOnExpire) Weapon_SpawnExplosionAt(b->weapon, b->s.x, b->s.y, 0); b->isKilled = 1; b->trail.visible = 0, b->trail.alpha = 0; b->s.body.enable = 0; sprite_setScale(&b->s, 0); b->s.visible = 0; base_DeSpawn(b); } static void B_Silf_despawnCb(void *ctx) { Bullet_DeSpawn(ctx); } static void B_Silf_explode(void *ctx) { // explodeTimer 'SILF explode' Bullet *b = ctx; b->s.body.enable = 1; b->fadeOutTween = tweens_add((TweenConfig){ .props = { { &b->trail.alpha, NULL, 0 } }, .nprops = 1, .duration = 0xc8, .onComplete = B_Silf_despawnCb, .ctx = b }); b->scaleTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, 1 * PixelScale * Weapon_PArea(b->weapon) }, { &b->s.alpha, NULL, 0 } }, .nprops = 2, .duration = 0x78 }); } static void B_Silf_OnRecycle(Bullet *b) { Weapon *w = b->weapon; int silf2 = w->silf2; Bullet_OnRecycle(b); body_setCircle(&b->s.body, 0x10, b->s.body.offset.x, b->s.body.offset.y); b->s.body.enable = 0; b->totalTime = 0; b->isCullable = 0; tween_stop(b->fadeInTween), tween_stop(b->fadeOutTween); // despawnTween: mai creato b->s.visible = 0; b->trail.visible = 0, b->trail.alpha = 0; b->npos = 0; // clearPositions for (int i = 0; i < 0x18; i++) b->ropePts[i] = (Vector2){ b->s.x, b->s.y }; // reset: punti sul follower sprite_setScale(&b->s, 0.5f); Vector2 t = w->targets[w->enemyIndex % w->ntargets]; w->enemyIndex++; if (w->silf3) { // B_Silf3: niente SetBeamTextureFromArea } else if (w->silfCounter == 1) { // B_Silf_Counter: solo le scie larghe, rovesciate float a = Weapon_PArea(w); if (a >= 2) b->trailFrame = frame_get("vfx", "Gradient3_8pxReverse.png"); else if (a >= 1.5f) b->trailFrame = frame_get("vfx", "Gradient3_6pxReverse.png"); } else if (w->silfCounter == 2) { // B_Silf2_Counter float a = Weapon_PArea(w); sprite_setFrame(&b->s, frame_get("vfx", "HitBlack1.png")); b->trailFrame = frame_get("vfx", a >= 2 ? "Gradient4_8pxReverse.png" : a >= 1.5f ? "Gradient4_6pxReverse.png" : "Gradient4_4pxReverse.png"); } else if (!silf2) { // SetBeamTextureFromArea sprite_setFrame(&b->s, frame_get("vfx", "HitWhite1.png")); float a = Weapon_PArea(w); b->trailFrame = frame_get("vfx", a >= 2 ? "Gradient3_8px.png" : a >= 1.5f ? "Gradient3_6px.png" : "Gradient3_4px.png"); } else if (!(Weapon_PArea(w) >= 2) && Weapon_PArea(w) >= 1.5f) { // (sic) PArea >= 2 || ...: oltre 2 resta la 4px b->trailFrame = frame_get("vfx", "Gradient4_6px.png"); } // targets ha sempre 12 punti: il ramo DeSpawn dell'originale non scatta mai Sound_PlaySound("MagicMissile", 0.15f, 1, -0x64 * b->indexInWeapon, 0xc8, 0xc); b->isKilled = 0; b->target = NULL; // SetTarget: this.target = punto float sg = w->enemyIndex % 2 == 0 ? 1 : -1, ang = (10 * (PI / 180)) * sg + frand() * (20 * (PI / 180)) * sg; b->s.x = w->sprite.x, b->s.y = w->sprite.y; float px = b->s.x - t.x, py = b->s.y - t.y, sn = sinf(ang), cs = cosf(ang); // rotate_point attorno al bersaglio b->curvePts[0] = (Vector2){ b->s.x, b->s.y }; b->curvePts[1] = (Vector2){ px * cs - py * sn + t.x, px * sn + py * cs + t.y }; b->curvePts[2] = t; if (w->silf3) b->curvePts[1] = (Vector2){ Core.Player->s.x + 0x32 * (frand() - 0.5f), Core.Player->s.y - 0x96 }; // B_Silf3: l'arco passa sopra il giocatore Silf_curveLengths(b); Vector2 p = Silf_getPointAt(b, 0); b->s.x = p.x, b->s.y = p.y; for (int i = 0; i < 0x18; i++) b->ropePts[i] = p; // resetPoints b->trail.visible = 1; b->s.visible = 1; b->s.alpha = 1; tween_stop(b->fadeInTween), tween_remove(b->fadeInTween); tween_stop(b->fadeOutTween), tween_remove(b->fadeOutTween); tween_stop(b->scaleTween), tween_remove(b->scaleTween); b->fadeInTween = tweens_add((TweenConfig){ .props = { { &b->trail.alpha, NULL, b->trailAlpha } }, .nprops = 1, .duration = 0xc8 }); b->explodeTimer = time_addEvent(b->duration, 0, 0, B_Silf_explode, b); // FlashingVFXEnabled } static void B_Silf_Update(Bullet *b, float delta) { if (b->isKilled) return; b->totalTime += delta; if (b->totalTime > b->duration) b->totalTime = b->duration; Vector2 p = Silf_getPointAt(b, b->totalTime / b->duration); b->s.x = p.x, b->s.y = p.y; memmove(&b->positions[1], &b->positions[0], 0x17 * sizeof(Vector2)); // RibbonTrail.trailUpdate (active) b->positions[0] = p; if (b->npos < 0x18) b->npos++; for (int i = 0; i < b->npos; i++) b->ropePts[i] = b->positions[i]; } static void B_Silf3_ctor(Bullet *b) { // 0x500f: scia a prisma in miscela normale char nm[24]; B_Silf_ctor_common(b, 0); b->trailAlpha = 0.4f; b->s.alpha = 0.75f; b->trailAdd = 0; snprintf(nm, sizeof(nm), "Prism%d_8px.png", 1 + b->indexInWeapon % 9); b->trailFrame = frame_get("vfx", nm); } static const BulletVT B_Silf3 = { "vfx", "HitWhite1.png", B_Silf3_ctor, NULL, B_Silf_OnRecycle, NULL, B_Silf_Update, B_Silf_DeSpawn }; static const BulletVT B_Silf = { "vfx", "HitWhite1.png", B_Silf_ctor, NULL, B_Silf_OnRecycle, NULL, B_Silf_Update, B_Silf_DeSpawn }; static const BulletVT B_Silf2 = { "vfx", "HitBlack1.png", B_Silf2_ctor, NULL, B_Silf_OnRecycle, NULL, B_Silf_Update, B_Silf_DeSpawn }; static void B_SilfCounter_ctor(Bullet *b) { // 0x17d9a: scia additiva rovesciata, alpha 0.5 B_Silf_ctor_common(b, 0); b->trailAlpha = 0.4f, b->s.alpha = 0.5f, b->trailAdd = 1; b->trailFrame = frame_get("vfx", "Gradient3_4pxReverse.png"); } static void B_Silf2Counter_ctor(Bullet *b) { // 0x12357: scia normale rovesciata, alpha 1 B_Silf_ctor_common(b, 0); b->trailAlpha = 0.4f, b->s.alpha = 1, b->trailAdd = 0; b->trailFrame = frame_get("vfx", "Gradient4_4pxReverse.png"); } static void B_SilfCounter_OnHasHitAnObject(Bullet *b, void *o, int isDead) { if (!isDead && Arcanas_has(14)) Bullet_TryFreeze(b, o); } static const BulletVT B_Silf_Counter = { "vfx", "HitWhite1.png", B_SilfCounter_ctor, NULL, B_Silf_OnRecycle, B_SilfCounter_OnHasHitAnObject, B_Silf_Update, B_Silf_DeSpawn }; static const BulletVT B_Silf2_Counter = { "vfx", "HitWhite1.png", B_Silf2Counter_ctor, NULL, B_Silf_OnRecycle, NULL, B_Silf_Update, B_Silf_DeSpawn }; // --- Phiera Der Tuphello / Eight The Sparrow: W_Guns (0x140bb), W_Guns2 (0xb0e5), B_Guns (0x15e86), B_Guns2 (0x21ce) -- // Quattro colpi a 30, -30, 210, -210 gradi. Con tutte e due le armi, GUNS prende GUNS2 come secondo set e la fa sparare a meta' repeatInterval. static Weapon *Core_GetWeapon(const char *type); static void Guns_OnRecycle(Bullet *b, const float *firingAngles) { Bullet_OnRecycle(b); sprite_setScale(&b->s, 1); body_setCircle(&b->s.body, 8, b->s.body.offset.x, b->s.body.offset.y); sprite_setScale(&b->s, 0.5f * Weapon_PArea(b->weapon)); b->s.y -= 0xc; b->s.body.velocity = velocityFromRotation(firingAngles[b->indexInWeapon % 4] * (PI / 180), Bullet_TrueSpeed(b)); Sound_PlaySound("Guns1", 0.2f, 1, 0x64 * b->indexInWeapon, 0xc8, 0xc); } static const float GUNS_ANGLES[4] = { 0x1e, -0x1e, 0xd2, -0xd2 }, GUNS_COUNTER_ANGLES[4] = { 0x2d, -0x2d, 0xe1, -0xe1 }; static void B_Guns_OnRecycle(Bullet *b) { Guns_OnRecycle(b, GUNS_ANGLES); } static void B_GunsCounter_OnRecycle(Bullet *b) { Guns_OnRecycle(b, GUNS_COUNTER_ANGLES); } // B_Guns_Counter / B_Guns2_Counter static void Guns_OnHasHitAnObject(Bullet *b, void *o, int isDead, int guns2) { // B_Guns: Heart of Fire all'impatto; B_Guns2: gelo Jewels if (!isDead) { if (!guns2 && Arcanas_has(19)) Weapon_SpawnExplosionAt(b->weapon, b->s.x, b->s.y, 1); if (b->bounces > 0) { b->bounces--; b->s.body.velocity.x *= -1, b->s.body.velocity.y *= -1; b->n_hit = 0; // objectsHit = [] return; // B_Guns2: niente gelo sul rimbalzo } if (--b->penetrating <= 0) Bullet_DeSpawn(b); } if (guns2 && Arcanas_has(14)) Bullet_TryFreeze(b, o); // B_Guns2: anche col nemico gia' morto, come l'originale } static void B_Guns_OnHasHitAnObject(Bullet *b, void *o, int isDead) { Guns_OnHasHitAnObject(b, o, isDead, 0); } static void B_Guns2_OnHasHitAnObject(Bullet *b, void *o, int isDead) { Guns_OnHasHitAnObject(b, o, isDead, 1); } static const BulletVT B_Guns = { "vfx", "BulletRed.png", NULL, NULL, B_Guns_OnRecycle, B_Guns_OnHasHitAnObject, NULL, NULL }; static const BulletVT B_Guns2 = { "vfx", "BulletBlue.png", NULL, NULL, B_Guns_OnRecycle, B_Guns2_OnHasHitAnObject, NULL, NULL }; static const BulletVT B_Guns_Counter = { "vfx", "BulletRed.png", NULL, NULL, B_GunsCounter_OnRecycle, B_Guns_OnHasHitAnObject, NULL, NULL }; static const BulletVT B_Guns2_Counter = { "vfx", "BulletBlue.png", NULL, NULL, B_GunsCounter_OnRecycle, B_Guns2_OnHasHitAnObject, NULL, NULL }; static Bullet *W_Guns_FireOneBullet(Weapon *w, float x, float y, int index) { // l'indice del colpo non conta: 0..3 (void)index; Bullet *b = NULL; for (int i = 0; i < 4; i++) b = BulletPool_SpawnAt(w->pool, x, y, w, i); // SetTarget: target sempre vuoto per queste armi return b; } static void W_Guns_secondFire(void *ctx) { Weapon_Fire(ctx); } static void W_Guns_Fire(Weapon *w) { base_Fire(w); if (!w->hasSecondSet) { Weapon *g2 = Core_GetWeapon("GUNS2"); // Core.Weapons.find(secondSetType) if (g2) { w->hasSecondSet = 1; w->secondSet = g2; Weapon_CleanUp(g2); g2->resetDisabled = 1; } } if (w->secondSet) time_addEvent(0.5f * w->repeatInterval, 0, 0, W_Guns_secondFire, w->secondSet); } static void W_GunsCounter_Fire(Weapon *w) { // W_Guns_Counter: il secondo set e' GUNS2_COUNTER fra le armi nascoste base_Fire(w); if (!w->hasSecondSet) { Weapon *g2 = Core_GetHiddenWeapon("GUNS2_COUNTER"); if (g2) { w->hasSecondSet = 1; w->secondSet = g2; Weapon_CleanUp(g2); g2->resetDisabled = 1; } } if (w->secondSet) time_addEvent(0.5f * w->repeatInterval, 0, 0, W_Guns_secondFire, w->secondSet); } // critChancesArray(1000): critico solo con le arcane static const WeaponVT W_Guns = { BASE, .CheckArcanas = CA_guns, .bullet = &B_Guns, .PBounces = bonus_PBounces, .Fire = W_Guns_Fire, .FireOneBullet = W_Guns_FireOneBullet }; static const WeaponVT W_Guns2 = { BASE, .CheckArcanas = CA_guns2, .bullet = &B_Guns2, .PBounces = bonus_PBounces, .FireOneBullet = W_Guns_FireOneBullet }; // Gemini: W_Guns_Counter (0x7551) / W_Guns2_Counter (0xd675), colpi a 45 gradi (0x3901 / 0x1822a) static const WeaponVT W_Guns_Counter = { BASE, .CheckArcanas = CA_gunsCounter, .bullet = &B_Guns_Counter, .PBounces = bonus_PBounces, .Fire = W_GunsCounter_Fire, .FireOneBullet = W_Guns_FireOneBullet }; static const WeaponVT W_Guns2_Counter = { BASE, .CheckArcanas = CA_guns2Counter, .bullet = &B_Guns2_Counter, .PBounces = bonus_PBounces, .FireOneBullet = W_Guns_FireOneBullet }; // --- Phieraggi: W_Guns3 (0x1665e), B_Guns3 (0x8e78) ----------------------------------------------------------- // Raggi RaggiBeam che girano attorno al giocatore; lungo ognuno una raffica di 9 colpi invisibili che curva col giro. static void B_Guns3_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); sprite_setScale(&b->s, 1); body_setCircle(&b->s.body, 0xa, b->s.body.offset.x, b->s.body.offset.y); b->s.visible = 0; sprite_setScale(&b->s, Weapon_PArea(b->weapon)); } static void B_Guns3_OnHasHitAnObject(Bullet *b, void *o, int isDead) { (void)o; if (!isDead && --b->penetrating <= 0) Bullet_DeSpawn(b); } static const BulletVT B_Guns3 = { "vfx", "HitRed1.png", NULL, NULL, B_Guns3_OnRecycle, B_Guns3_OnHasHitAnObject, NULL, NULL }; static float W_Guns3_PAmount(Weapon *w) { return fminf(10, Core.Player->amount) + w->amount + fminf(10, Core.Player->revivals); } static float W_Guns3_PPower(Weapon *w) { return fminf(10, Core.Player->power) * (w->power + 0.1f * fminf(10, Core.Player->revivals)); } static float W_Guns3_PSpeed(Weapon *w) { return fminf(5, Core.Player->speed + 1.5f * (Core.Player->speed - 1)) * w->speed * sinev(Core.Player->sineSpeed); } // Chaos static void W_Guns3_ctor(Weapon *w) { w->angleUnit = (0.5f / 0x10) * (PI / 180); w->pxUnit = 0.5f * sqrtf((float)game_width * game_width + (float)game_height * game_height) / 0xc; } static void W_Guns3_FireOneBullet(Weapon *w, float x, float y, int index, float angle) { Bullet *b = BulletPool_SpawnAt(w->pool, x, y, w, index); if (b) b->s.body.velocity = velocityFromRotation(angle, 0xa * ProjectileSpeed); // SetTarget } typedef struct { Weapon *w; float dx, dy, angle, delay; int index; } Guns3Shot; static void W_Guns3_DelayedShot(void *ctx) { Guns3Shot *c = ctx; W_Guns3_FireOneBullet(c->w, Core.Player->s.x + c->dx, Core.Player->s.y + c->dy, c->index, c->angle + 1.66f * c->w->angleUnit * c->delay); } static TweenRef W_Guns3_raysTween(Weapon *w, float sx, float alpha, Callback onStart, Callback onComplete) { TweenProp pr[3 * 32]; for (int i = 0; i < w->n_rays; i++) { pr[3 * i] = (TweenProp){ &w->rays[i].scaleX, NULL, sx }; pr[3 * i + 1] = (TweenProp){ &w->rays[i].scaleY, NULL, 6.5f }; pr[3 * i + 2] = (TweenProp){ &w->rays[i].alpha, NULL, alpha }; } return tweens_add((TweenConfig){ .many = pr, .nmany = 3 * w->n_rays, .duration = 4 * w->repeatInterval, .yoyo = 1, .ease = Ease_SineInOut, .onStart = onStart, .onComplete = onComplete, .ctx = w }); } static void W_Guns3_PermaTween(void *ctx); static void W_Guns3_permaStart(void *ctx) { Weapon *w = ctx; for (int i = 0; i < w->n_rays; i++) w->rays[i].alpha = 1, w->rays[i].scaleX = 0.5f * Weapon_PArea(w), w->rays[i].scaleY = 6.5f; } static void W_Guns3_PermaTween(void *ctx) { Weapon *w = ctx; w->hasPermaTween = 1; W_Guns3_raysTween(w, 0.4f * Weapon_PArea(w), 0.8f, W_Guns3_permaStart, W_Guns3_PermaTween); } static void W_Guns3_Fire(Weapon *w) { static Guns3Shot shots[1024]; static int shot_i; w->angleUnit = (0.5f / 0x20 * W_Guns3_PSpeed(w)) * (PI / 180); int n = (int)ceilf(Weapon_PAmount(w)); if (n > 32) n = 32; // semplificazione: tetto a 32 raggi (PAmount arriva a ~30 al massimo) for (; w->n_rays < n; w->n_rays++) { Sprite *r = &w->rays[w->n_rays]; sprite_init(r, frame_get("vfx", "RaggiBeam.png"), 0, 0); r->visible = 0, r->originX = 0.5f, r->originY = 0, r->alpha = 0.25f; children_add(r); } float step = (360.0f / Weapon_PAmount(w)) * (PI / 180); for (int i = 0; i < n; i++) { float a = w->rayAngle + step * i, dx = cosf(a) * w->pxUnit, dy = sinf(a) * w->pxUnit; Sprite *r = &w->rays[i]; r->visible = 1, r->x = Core.Player->s.x + dx, r->y = Core.Player->s.y + dy; r->scaleX = 0.1f, r->scaleY = 1; W_Guns3_FireOneBullet(w, dx, dy, 0, a); // come l'originale: il primo colpo nasce in (dx, dy), senza la posizione del giocatore for (int k = 1; k <= 8; k++) { Guns3Shot *c = &shots[shot_i++ & 1023]; *c = (Guns3Shot){ w, dx, dy, a, w->repeatInterval * k, k }; w->lastShotTimer = time_addEvent(c->delay, 0, 0, W_Guns3_DelayedShot, c); } } if (Weapon_PInterval(w) > 8 * w->repeatInterval) { Sound_PlaySound("Guns2", 0.5f, 1, -0x64, 0xc8, 0xa); tween_stop(w->scaleTween); w->scaleTween = W_Guns3_raysTween(w, 0.5f * Weapon_PArea(w), 0.9f, NULL, NULL); } else { Sound_PlaySound("Guns3", 0.3f, 1, -0x64, 0x64, 1); if (!w->hasPermaTween) Sound_PlaySound("Guns2", 0.5f, 1, -0x64, 0xc8, 0xa), W_Guns3_PermaTween(w); } if (w->lastFiringInterval != Weapon_PInterval(w)) { w->lastFiringInterval = Weapon_PInterval(w); Weapon_ResetFiringTimer(w); } } static void W_Guns3_Update(Weapon *w, float delta) { base_Update(w, delta); w->rayAngle += w->angleUnit * delta; float step = (360.0f / Weapon_PAmount(w)) * (PI / 180); for (int i = 0; i < w->n_rays; i++) { float a = w->rayAngle + step * i; Sprite *r = &w->rays[i]; r->visible = 1; r->x = Core.Player->s.x + cosf(a) * w->pxUnit, r->y = Core.Player->s.y + sinf(a) * w->pxUnit; r->angle = a * (180 / PI) - 0x5a; r->depth = -game_height; } } // critChancesArray(1000), LevelUp / ApplyLimitBreak dei counterWeapon: solo con l'arcana Aquarius static const WeaponVT W_Guns3 = { BASE, .CheckArcanas = CA_guns3, .bullet = &B_Guns3, .PAmount = W_Guns3_PAmount, .PPower = W_Guns3_PPower, .ctor = W_Guns3_ctor, .Fire = W_Guns3_Fire, .Update = W_Guns3_Update }; // --- Gatti Amari: W_Gatti (0xab10), B_Gatti (0xbd84), B_Gatti_Scratch (0xfb8b), B_Gatti_Scuffle (0x155f9), B_FireExplosion (0x123bc) --- // Gatti capricciosi: compaiono attorno al giocatore, graffiano (a volte lui), fanno zuffa tra loro e giocano coi pickup. static float W_Gatti_GetRandom(Weapon *w) { return w->RANDOMS[w->randomIndex++ % 0x1f4]; } static float W_Gatti_GetPlusMinus(Weapon *w) { return w->PLUSMINUS[w->plusMinusIndex++ % 0x1f4]; } static const char *W_Gatti_GetSfx(Weapon *w) { return w->SFXARRAY[w->sfxIndex++ % 0x78]; } static void Bullet_pushHit(Bullet *b, void *o) { // objectsHit.push senza OnHasHitAnObject if (b->n_hit == b->cap_hit) { b->cap_hit = b->cap_hit ? b->cap_hit * 2 : 16; b->objectsHit = realloc(b->objectsHit, b->cap_hit * sizeof(void *)); } b->objectsHit[b->n_hit++] = o; } // B_Gatti_Scratch: un graffio (slash..slash4) che si allarga in 120 ms e svanisce in 100 static void B_Scratch_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void B_Scratch_OnRecycle(Bullet *b) { static const struct { const char *frame; float ox, oy; } configs[4] = { { "slash.png", 0, 0.5f }, { "slash2.png", 0, 1 }, { "slash3.png", 0, 0 }, { "slash4.png", 0, 0.5f } }; Weapon *w = b->weapon; Bullet_OnRecycle(b); tween_stop(b->exitTween), tween_stop(b->entryTween); sprite_setScale(&b->s, 1); body_setCircle(&b->s.body, 0x40, -0x20, -0x20); sprite_setScale(&b->s, 0); b->s.alpha = 1; int k = b->cfgIndex++ % 4; b->s.flipX = 0.5f >= w->critChancesArray[w->critIndex++ % 1000]; sprite_setFrame(&b->s, frame_get("vfx", configs[k].frame)); sprite_setOrigin(&b->s, configs[k].ox, configs[k].oy); b->s.angle = (2 * PI * w->critChancesArray[w->critIndex++ % 1000]) * (180 / PI); b->s.x += 0x18 * W_Gatti_GetPlusMinus(w); b->s.y += 0x18 * W_Gatti_GetPlusMinus(w); b->entryTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, 0.5f * Weapon_PArea(w) } }, .nprops = 1, .duration = 0x78 }); b->exitTween = tweens_add((TweenConfig){ .props = { { &b->s.alpha, NULL, 0 } }, .nprops = 1, .delay = 0x78, .duration = 0x64, .onComplete = B_Scratch_despawn, .ctx = b }); } static void B_Scratch_ctor(Bullet *b) { b->exitTween = b->entryTween = TWEEN_NONE; } static const BulletVT B_Gatti_Scratch = { "vfx", "Cat.png", B_Scratch_ctor, NULL, B_Scratch_OnRecycle, NULL, NULL, NULL }; // B_Gatti_Scuffle: nuvola di fumo invisibile che genera un graffio ogni 30 ms per tutta la durata static void B_Scuffle_ctor(Bullet *b) { b->exploRadius = 0x40; b->Pfx = particles_add(); b->PfxEmitter1 = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "Smoke1.png"), frame_get("vfx", "Smoke2.png") }, .nframes = 2, .speed = ERND(1, 0xa), .quantity = 2, .rotate = ERND(0, 0x168), .lifespan = EOP(0x1f4), .alpha = ERANGE(1, 0), .scale = ERANGE(2, 1), .hasZone = 1, .zoneRadius = b->exploRadius, .on = 0 }); b->PfxEmitter2 = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "Smoke1.png"), frame_get("vfx", "Smoke2.png"), frame_get("vfx", "HitStarRed1.png"), frame_get("vfx", "HitStarRed2.png"), frame_get("vfx", "Hit2.png"), frame_get("vfx", "Cat.png") }, .nframes = 6, .speed = ERND(1, 0xa), .quantity = 1, .rotate = ERND(0, 0x168), .lifespan = EOP(0xfa), .alpha = ERANGE(1, 0), .scale = ERANGE(0, 2), .hasZone = 1, .zoneRadius = b->exploRadius, .on = 0 }); b->HitboxTimer = b->ExpireTimer = (Timer){ -1, 0 }; } static void B_Scuffle_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void B_Scuffle_hitbox(void *ctx) { Bullet *b = ctx; b->n_hit = 0; // objectsHit = [] BulletPool_SpawnAt(b->weapon->scratchPool, b->s.x, b->s.y, b->weapon, 0); } static void B_Scuffle_OnRecycle(Bullet *b) { Weapon *w = b->weapon; float a = Weapon_PArea(w); Bullet_OnRecycle(b); b->s.body.enable = 1; sprite_setScale(&b->s, 1); body_setCircle(&b->s.body, 0x20, -0x10, -0x10); b->s.visible = 0; sprite_setScale(&b->s, a); time_removeEvent(b->HitboxTimer), time_removeEvent(b->ExpireTimer); b->PfxEmitter1->c.zoneRadius = b->PfxEmitter2->c.zoneRadius = b->exploRadius * a; // explosionCircle b->PfxEmitter1->c.quantity = b->PfxEmitter2->c.quantity = 1 + (int)floorf(a); b->PfxEmitter1->c.scale = ERANGE(1 * a, 1); b->PfxEmitter2->c.scale = ERANGE(0, 1 * a); b->ExpireTimer = time_addEvent(Weapon_PDuration(w), 0, 0, B_Scuffle_despawn, b); b->HitboxTimer = time_addEvent(0x1e, 0, -1, B_Scuffle_hitbox, b); } static void B_Scuffle_Update(Bullet *b, float delta) { (void)delta; manager_emitParticleAt(b->Pfx, b->s.x, b->s.y); } static void B_Scuffle_DeSpawn(Bullet *b) { b->isCullable = 1; time_removeEvent(b->HitboxTimer), time_removeEvent(b->ExpireTimer); base_DeSpawn(b); } static const BulletVT B_Gatti_Scuffle = { "vfx", "Cat.png", B_Scuffle_ctor, NULL, B_Scuffle_OnRecycle, NULL, B_Scuffle_Update, B_Scuffle_DeSpawn }; // B_FireExplosion: esplosione rossa (NFT preso da un gatto); OnRecycle non passa dal Bullet base static void B_FireExplosion_ctor(Bullet *b) { b->radius = 0x20, b->exploRadius = 0x10; b->s.visible = 0; b->Pfx = particles_add(); b->PfxEmitter2 = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "Smoke1.png"), frame_get("vfx", "Smoke2.png") }, .nframes = 2, .lifespan = EOP(0x1f4), .rotate = ERND(0, 0x168), .angle = { 0, 0xb4, 1 }, .angleSteps = 0x10, .speed = ERND(0x64, 0xc8), .quantity = 1, .scale = ERANGE(1, 0), .frequency = 1, .alpha = ERANGE(0.5f, 0), .hasZone = 1, .zoneRadius = b->exploRadius, .on = 0 }); b->PfxEmitter = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "HitSmoke1.png"), frame_get("vfx", "HitSmoke2.png") }, .nframes = 2, .lifespan = EOP(0x1f4), .rotate = ERND(0, 0x168), .angle = { 0, 0x168, 1 }, .angleSteps = 0x10, .speed = ERND(0x32, 0x50), .quantity = 1, .scale = ERANGE(1, 0), .frequency = 1, .blendAdd = 1, .hasZone = 1, .zoneRadius = b->exploRadius, .on = 0 }); b->Pfx->hasWell = 1; // createGravityWell({ power: 1, epsilon: 50, gravity: 20 }) b->Pfx->wellPower = 1 * 0x14, b->Pfx->wellEpsilon = 0x32 * 0x32; sprite_init(&b->GroundFx, NULL, 0, 0); // scene.add.circle(0, 0, 1, 0xff0000), ADD b->GroundFx.draw = MoonGroundFx_draw; b->GroundFx.tint = 0xff0000, b->GroundFx.alpha = 0.4f, b->GroundFx.visible = 0, b->GroundFx.scaleX = 1; children_add(&b->GroundFx); b->despawnTween = TWEEN_NONE; } static void B_FireExplosion_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void B_FireExplosion_OnRecycle(Bullet *b) { float a = Weapon_PArea(b->weapon); sprite_setScale(&b->s, b->radius * a); body_setCircle(&b->s.body, 1, -0.5f, -0.5f); sprite_setScale(&b->s, 1); b->n_hit = 0; b->PfxEmitter->c.scale = b->PfxEmitter2->c.scale = ERANGE(0.5f * a, 0); b->PfxEmitter->c.zoneRadius = b->PfxEmitter2->c.zoneRadius = b->exploRadius * a; b->Pfx->wellX = b->s.x, b->Pfx->wellY = b->s.y + 0x14; b->PfxEmitter->x = b->s.x, b->PfxEmitter->y = b->s.y; emitter_start(b->PfxEmitter); b->PfxEmitter2->x = b->s.x, b->PfxEmitter2->y = b->s.y; emitter_start(b->PfxEmitter2); b->GroundFx.x = b->s.x, b->GroundFx.y = b->s.y; b->GroundFx.scaleX = 1, b->GroundFx.alpha = 0.2f, b->GroundFx.visible = 1; // FlashingVFXEnabled tween_stop(b->despawnTween); // targets [GroundFx, this]: scale e alpha; onStart: setActive(true), body.enable = true b->s.active = 1, b->s.body.enable = 1; float sc = b->radius * a; b->despawnTween = tweens_add((TweenConfig){ .props = { { &b->GroundFx.scaleX, &b->GroundFx.scaleY, sc }, { &b->GroundFx.alpha, NULL, 0 }, { &b->s.scaleX, &b->s.scaleY, sc } }, .nprops = 3, .duration = 0x78, .onComplete = B_FireExplosion_despawn, .ctx = b }); tweens_add((TweenConfig){ .props = { { &b->s.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x78 }); Sound_PlaySound("FireExplosion", 0.5f, 1, 0x1f4 * (frand() - 0.5f), 0x96, 3); } static void B_FireExplosion_DeSpawn(Bullet *b) { b->s.body.enable = 0; b->s.active = 0; emitter_stop(b->PfxEmitter), emitter_stop(b->PfxEmitter2); BulletPool_Return(b->pool, b); tween_stop(b->despawnTween), b->despawnTween = TWEEN_NONE; b->GroundFx.visible = 0; } static const BulletVT B_FireExplosion = { "vfx", "WhiteDot.png", B_FireExplosion_ctor, NULL, B_FireExplosion_OnRecycle, NULL, NULL, B_FireExplosion_DeSpawn }; // --- Heart of Fire / Out of Bounds: W_FireExplosion (0xc2b9), W_ColdExplosion (0xf81a), B_ColdExplosion (0x5bf4) ---------- // B_ColdExplosion = B_FireExplosion con particelle di ghiaccio e cerchio blu. // semplificazione: il DeSpawn del freddo nell'originale lascia il corpo acceso nel pool; qui lo spegne come il fuoco (nessun effetto: e' inattivo) static void B_ColdExplosion_ctor(Bullet *b) { B_FireExplosion_ctor(b); b->PfxEmitter2->c.frames[0] = b->PfxEmitter->c.frames[0] = frame_get("vfx", "feedback-5.png"); b->PfxEmitter2->c.frames[1] = b->PfxEmitter->c.frames[1] = frame_get("vfx", "feedback-4.png"); b->GroundFx.tint = 0xff; } static const BulletVT B_ColdExplosion = { "vfx", "WhiteDot.png", B_ColdExplosion_ctor, NULL, B_FireExplosion_OnRecycle, NULL, NULL, B_FireExplosion_DeSpawn }; static void W_Explosion_canExplode(void *ctx) { ((Weapon *)ctx)->canExplode = 1; } static void W_FireExplosion_ExplodeOnPlayer(void *ctx) { // ExplodeAt(Player): una ogni 500 ms Weapon *w = ctx; if (!w->canExplode) return; w->canExplode = 0; time_removeEvent(w->ExplodeTimer); w->ExplodeTimer = time_addEvent(0x1f4, 0, 0, W_Explosion_canExplode, w); BulletPool_SpawnAt(w->pool, Core.Player->s.x, Core.Player->s.y, w, 0); } static void W_FireExplosion_ctor(Weapon *w) { w->canExplode = 1, w->ExplodeTimer = (Timer){ -1, 0 }; PlayerEvents_add(EV_PLAYER_RECEIVEDDAMAGE, W_FireExplosion_ExplodeOnPlayer, w); PlayerEvents_add(EV_PLAYER_LOSTSHIELD, W_FireExplosion_ExplodeOnPlayer, w); } static void W_retaliation_onBulletOverlapsEnemy(Weapon *w, Bullet *b, Enemy *e) { Weapon_onBulletOverlapsEnemy_Retaliation(w, &b->s, &e->s); } static float W_ColdExplosion_PPower(Weapon *w) { return fminf(10, Core.Player->power * sinev(Core.Player->sineMight)) * w->power; } // senza silent ne' bloodline static const WeaponVT W_FireExplosion = { BASE, .bullet = &B_FireExplosion, .ctor = W_FireExplosion_ctor, .ResetFiringTimer = noop_ResetFiringTimer, .onBulletOverlapsEnemy = W_retaliation_onBulletOverlapsEnemy }; // ExplodeOnPlayer del freddo: doesRetaliate e' sempre falso e i listener non vengono mai aggiunti static const WeaponVT W_ColdExplosion = { BASE, .PPower = W_ColdExplosion_PPower, .bullet = &B_ColdExplosion, .ResetFiringTimer = noop_ResetFiringTimer }; // --- Sarabande of Healing: W_Sarabande (0x67bf), B_Sarabande (0x15b74); Divine Bloodline: W_DivineBloodline (0x385e) ----------- static void B_Sarabande_ctor(Bullet *b) { b->radius = 0x10; b->s.x = Core.Player->s.x, b->s.y = Core.Player->s.y; } static void B_Sarabande_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void B_Sarabande_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); body_setCircle(&b->s.body, b->radius, b->s.body.offset.x, b->s.body.offset.y); sprite_setScale(&b->s, 0); b->s.alpha = 0.2f, b->s.visible = 1, b->s.blendAdd = 1; time_removeEvent(b->ExpireTimer); tween_stop(b->scaleTween); b->scaleTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, 2 * PixelScale * Weapon_PArea(b->weapon) }, { &b->s.alpha, NULL, 0 } }, .nprops = 2, .duration = 0x12c, .onComplete = B_Sarabande_despawn, .ctx = b }); } static void B_Sarabande_Update(Bullet *b, float delta) { (void)delta; b->s.x = Core.Player->s.x, b->s.y = Core.Player->s.y; } static const BulletVT B_Sarabande = { "vfx", "Rings4.png", B_Sarabande_ctor, NULL, B_Sarabande_OnRecycle, NULL, B_Sarabande_Update, NULL }; static float W_Sarabande_PPower(Weapon *w) { return w->healAmount; } static const WeaponVT W_Sarabande = { BASE, .PPower = W_Sarabande_PPower, .PAmount = one_PAmount, .bullet = &B_Sarabande, .ResetFiringTimer = noop_ResetFiringTimer }; static const WeaponVT W_DivineBloodline = { BASE, .bullet = &B_Sarabande, .ResetFiringTimer = noop_ResetFiringTimer }; // non spara: tiene le statistiche static void Arcanas_TriggerSarabande(float v) { Arcanas.SarabandeWeapon->healAmount = 0.1f * v; Weapon_Fire(Arcanas.SarabandeWeapon); } static void Arcanas_IncreaseBloodlineBonus(void) { Arcanas.bloodlineMaxHpBonus += Arcanas.divineBloodlineHPBonusUnit, Core.Player->maxHp += Arcanas.divineBloodlineHPBonusUnit; } // --- Blood Astronomia: W_BloodAstronomia (0x37ec), B_BloodAstronomia (0x390f), B_Blood_Garlic (0xcdf1), B_Blood_Planet (0x609a), // B_Blood_Pentagram (0x66dd), B_Blood_Laurel (0x13134), B_Blood_Lancet (0x16764) --------------------------------------------- // Ogni volta che Garlic/Vortex, Song/Mannaggia, Pentagram/Sire, Laurel o Lancet sparano, l'arma lancia la sua versione di sangue // con i dati dell'arma di partenza (overrideWeaponData). Esplosioni: MoonExplosion rossa (pool 0x7cb4). enum { ASTRO_GARLIC, ASTRO_SONG, ASTRO_PENTAGRAM, ASTRO_LANCET, ASTRO_LAUREL }; #define ASTRO_DEPTH (0.5f * -game_height) static float astro_amount(Weapon *src) { return fminf(10, Core.Player->amount) + src->amount; } static void astro_despawnCb(void *ctx) { Bullet_DeSpawn(ctx); } static void astro_stop(TweenRef *t) { tween_stop(*t), *t = TWEEN_NONE; } static void astro_explosion(Bullet *b, float x, float y, int maxSim) { // PentagramSFX + moonExplosionPool.SpawnAt(x, y, 0, 10) Sound_PlaySound("PentagramSFX", 0.4f, 1.5f, 0, 0xc8, maxSim); MoonExplosionPool_SpawnAt(b->weapon->moonExplosionPool, x, y, 0, 0xa); } static void astro_FadeOutTo0(Bullet *b, float ms) { // alphaTween: alpha 0 -> DeSpawn astro_stop(&b->alphaTween); b->alphaTween = tweens_add((TweenConfig){ .props = { { &b->s.alpha, NULL, 0 } }, .nprops = 1, .duration = ms, .onComplete = astro_despawnCb, .ctx = b }); } static void astro_expire(Bullet *b, float ms, Callback cb) { time_removeEvent(b->ExpireTimer); b->ExpireTimer = time_addEvent(ms, 0, 0, cb, b); } // B_BloodAstronomia: cerchio invisibile grande quanto il Magnete, vive un intervallo static void B_BloodAstro_expire(void *ctx) { Bullet *b = ctx; time_removeEvent(b->ExpireTimer); Bullet_DeSpawn(b); } static void B_BloodAstro_ctor(Bullet *b) { b->radius = 1; b->s.x = Core.Magnet->s.x, b->s.y = Core.Magnet->s.y; } static void B_BloodAstro_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); b->radius = Core.Magnet->radius; body_setCircle(&b->s.body, b->radius, -b->radius, -b->radius); b->s.visible = 0; astro_expire(b, Weapon_PInterval(b->weapon), B_BloodAstro_expire); } static void B_BloodAstro_Update(Bullet *b, float delta) { (void)delta; b->s.x = Core.Magnet->s.x, b->s.y = Core.Magnet->s.y; } static const BulletVT B_BloodAstronomia = { "vfx", "WhiteDot.png", B_BloodAstro_ctor, NULL, B_BloodAstro_OnRecycle, NULL, B_BloodAstro_Update, NULL }; // B_Blood_Garlic static void B_BloodGarlic_FadeOut(void *ctx) { Bullet *b = ctx; time_removeEvent(b->ExpireTimer); astro_FadeOutTo0(b, 0x1f4); } static void B_BloodGarlic_ctor(Bullet *b) { b->radius = 1; } static void B_BloodGarlic_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); b->s.visible = 0, b->s.alpha = 0.1f; } static void B_BloodGarlic_override(Bullet *b, Weapon *src) { body_setCircle(&b->s.body, 0x10, b->s.body.offset.x, b->s.body.offset.y); b->s.visible = 1; sprite_setScale(&b->s, fmaxf(Core.Magnet->radius / 0x20, Weapon_PArea(src))); astro_expire(b, Weapon_PDuration(src), B_BloodGarlic_FadeOut); astro_stop(&b->alphaTween); b->s.alpha = 0.1f; // onStart; semplificazione: loopDelay 100 ms non tradotto (come Garlic) b->alphaTween = tweens_add((TweenConfig){ .props = { { &b->s.alpha, NULL, 0.3f } }, .nprops = 1, .loop = 1, .yoyo = 1, .duration = 0x3e8, .repeat = -1 }); astro_stop(&b->angleTween); b->s.angle = 0; b->angleTween = tweens_add((TweenConfig){ .props = { { &b->s.angle, NULL, 0x168 } }, .nprops = 1, .loop = 1, .duration = 0x1770, .repeat = -1 }); b->s.depth = ASTRO_DEPTH; } static const BulletVT B_Blood_Garlic = { "vfx", "Rings6.png", B_BloodGarlic_ctor, NULL, B_BloodGarlic_OnRecycle, NULL, NULL, NULL }; // B_Blood_Planet (Song): nove pianeti animati che girano attorno al punto di partenza static Animation planetAnims[9]; static const float PLANET_DURATIONS[10] = { 0x95f, 0x989, 0x745, 0x3f1, 0x4c1, 0x925, 0x9a3, 0x833, 0x5d1, 0x653 }, PLANET_RADII[9] = { 0x10, 0x18, 0x18, 0x18, 0x20, 0x20, 0x20, 0x8, 0 }; // bodyRadii[8] e' undefined: setCircle non fa nulla static void B_BloodPlanet_FadeOutCb(void *ctx); static void B_BloodPlanet_ctor(Bullet *b) { b->radius = 1; if (!planetAnims[0].n) for (int i = 0; i < 9; i++) { char pre[8]; snprintf(pre, sizeof(pre), "p0%d_", i + 1); make_anim(&planetAnims[i], "vfx", pre, 1, 0x10, 2, 0x10, -1); } b->radiusMulX = b->radiusMulY = 1; } static void B_BloodPlanet_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); b->s.visible = 0; } static void B_BloodPlanet_scaleStart(void *ctx) { Bullet *b = ctx; b->radiusMulY = 1; sprite_setScale(&b->s, 1); } static void B_BloodPlanet_override(Bullet *b, Weapon *src) { int i = b->indexInWeapon % 9; anims_play(&b->s, &planetAnims[i], 0); sprite_setScale(&b->s, 1); body_setCircle(&b->s.body, PLANET_RADII[i], b->s.body.offset.x, b->s.body.offset.y); sprite_setScale(&b->s, 0); b->s.visible = 1; float d = PLANET_DURATIONS[i]; b->radius = 0, b->radiusMulX = b->radiusMulY = 1; sprite_setScale(&b->s, 1); // this.scale = 1 astro_stop(&b->scaleTween); B_BloodPlanet_scaleStart(b); b->scaleTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, NULL, 0.25f }, { &b->s.scaleY, NULL, 0.25f }, { &b->radiusMulY, NULL, 0.1f } }, .nprops = 3, .duration = d, .yoyo = 1, .repeat = -1, .onStart = B_BloodPlanet_scaleStart, .ctx = b }); astro_expire(b, Weapon_PInterval(src) + Weapon_PDuration(src), B_BloodPlanet_FadeOutCb); b->s.alpha = 0.1f; tweens_add((TweenConfig){ .props = { { &b->s.alpha, NULL, 0.6f }, { &b->radius, NULL, Core.Magnet->radius } }, .nprops = 2, .duration = 0xc8 }); b->groundX = b->s.x, b->groundY = b->s.y; b->myRotationAngle = 2 * PI / 9 * i; b->angleRotUnit = PI / (8 * Core.Magnet->radius); b->amount = astro_amount(src); } static void B_BloodPlanet_FadeOut(Bullet *b) { astro_stop(&b->scaleTween), astro_stop(&b->alphaTween); b->alphaTween = tweens_add((TweenConfig){ .props = { { &b->s.alpha, NULL, 0 }, { &b->s.scaleX, NULL, 0 }, { &b->s.scaleY, NULL, 0 } }, .nprops = 3, .duration = 0xc8, .onComplete = astro_despawnCb, .ctx = b }); } static void B_BloodPlanet_FadeOutCb(void *ctx) { Bullet *b = ctx; time_removeEvent(b->ExpireTimer); B_BloodPlanet_FadeOut(b); } static void B_BloodPlanet_explode(Bullet *b) { astro_explosion(b, b->s.x, b->s.y, 3); if (--b->amount <= 0) b->s.body.enable = 0, B_BloodPlanet_FadeOut(b); } static void B_BloodPlanet_DeSpawn(Bullet *b) { astro_stop(&b->scaleTween), astro_stop(&b->alphaTween); base_DeSpawn(b); b->s.visible = 0; time_removeEvent(b->ExpireTimer); } static void B_BloodPlanet_Update(Bullet *b, float delta) { b->myRotationAngle += b->angleRotUnit * delta; b->s.x = b->groundX + cosf(b->myRotationAngle) * (b->radiusMulX * b->radius); b->s.y = b->groundY + sinf(b->myRotationAngle) * (b->radiusMulY * b->radius); } static const BulletVT B_Blood_Planet = { "vfx", "p01_01.png", B_BloodPlanet_ctor, NULL, B_BloodPlanet_OnRecycle, NULL, B_BloodPlanet_Update, B_BloodPlanet_DeSpawn }; // B_Blood_Pentagram / B_Blood_Laurel / B_Blood_Lancet: stessa uscita (alpha a 0 in 500 ms) e stesso DeSpawn static void B_BloodRing_DeSpawn(Bullet *b) { base_DeSpawn(b); b->s.visible = 0; time_removeEvent(b->ExpireTimer); astro_stop(&b->alphaTween); } static void B_BloodPentagram_FadeOut(void *ctx) { Bullet *b = ctx; time_removeEvent(b->ExpireTimer); astro_FadeOutTo0(b, 0x1f4); } static void B_BloodPentagram_ctor(Bullet *b) { b->s.visible = 0; } static void B_BloodPentagram_override(Bullet *b, Weapon *src) { b->s.body.enable = 1, b->s.visible = 1; body_setCircle(&b->s.body, 0x10, b->s.body.offset.x, b->s.body.offset.y); b->isCullable = 0, b->s.alpha = 1; b->amount = astro_amount(src); astro_expire(b, Weapon_PInterval(src) + Weapon_PDuration(src), B_BloodPentagram_FadeOut); b->s.depth = ASTRO_DEPTH; } static void B_BloodPentagram_explode(Bullet *b) { astro_explosion(b, b->s.x, b->s.y, 6); if (--b->amount <= 0) b->s.body.enable = 0, astro_FadeOutTo0(b, 0x1f4); } static const BulletVT B_Blood_Pentagram = { "vfx", "Rings5.png", B_BloodPentagram_ctor, NULL, Bullet_OnRecycle, NULL, NULL, B_BloodRing_DeSpawn }; static void B_BloodLaurel_FadeOut(Bullet *b) { astro_stop(&b->scaleTween), astro_stop(&b->imageTween); astro_FadeOutTo0(b, 0x1f4); } static void B_BloodLaurel_FadeOutCb(void *ctx) { Bullet *b = ctx; time_removeEvent(b->ExpireTimer); B_BloodLaurel_FadeOut(b); } static void B_BloodLaurel_ctor(Bullet *b) { b->s.visible = 0, b->s.tint = 0xff0000; } static void B_BloodLaurel_override(Bullet *b, Weapon *src) { b->s.body.enable = 1, b->s.visible = 1; body_setCircle(&b->s.body, 0x40, b->s.body.offset.x, b->s.body.offset.y); b->isCullable = 0, b->s.alpha = 0.2f; b->amount = astro_amount(src), b->amount *= b->amount; sprite_setScale(&b->s, 0); astro_expire(b, Weapon_PInterval(src) + Weapon_PDuration(src), B_BloodLaurel_FadeOutCb); astro_stop(&b->imageTween); b->imageTween = tweens_add((TweenConfig){ .props = { { &b->s.alpha, NULL, 0.5f } }, .nprops = 1, .loop = 1, .yoyo = 1, .duration = 0x3e8, .repeat = -1 }); astro_stop(&b->scaleTween); b->scaleTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, fmaxf(1, Core.Magnet->radius / 0x40) } }, .nprops = 1, .duration = 0x12c }); b->s.depth = ASTRO_DEPTH; } static void B_BloodLaurel_explode(Bullet *b, float x, float y) { astro_explosion(b, x, y, 3); if (--b->amount <= 0) b->s.body.enable = 0, B_BloodLaurel_FadeOut(b); } static const BulletVT B_Blood_Laurel = { "vfx", "bloodMin.png", B_BloodLaurel_ctor, NULL, Bullet_OnRecycle, NULL, NULL, B_BloodRing_DeSpawn }; // B_Blood_Lancet: un orologio di 12 numeri che rallenta i nemici static void B_BloodLancet_FadeOut(Bullet *b) { astro_stop(&b->scaleTween), astro_stop(&b->imageTween), astro_stop(&b->alphaTween); static TweenProp props[12]; for (int i = 0; i < 12; i++) props[i] = (TweenProp){ .t = &b->numbers[i].alpha, .end = 0 }; b->alphaTween = tweens_add((TweenConfig){ .many = props, .nmany = 12, .duration = 0x1f4, .onComplete = astro_despawnCb, .ctx = b }); astro_stop(&b->radiusTween); // semplificazione: il secondo tween (radius -> 0, onComplete DeSpawn) non tradotto: radius non e' usato e DeSpawn partirebbe due volte } static void B_BloodLancet_FadeOutCb(void *ctx) { Bullet *b = ctx; time_removeEvent(b->ExpireTimer); B_BloodLancet_FadeOut(b); } static void B_BloodLancet_ctor(Bullet *b) { b->s.visible = 0, b->s.tint = 0xff0000; b->numbers = calloc(12, sizeof(Sprite)), b->radii = calloc(12, sizeof(float)); for (int i = 0; i < 12; i++) { char f[8]; snprintf(f, sizeof(f), "%02d.png", i + 1); sprite_init(&b->numbers[i], frame_get("items", f), b->s.x, b->s.y); b->numbers[i].tint = 0xff0000, b->numbers[i].alpha = 0, b->numbers[i].depth = ASTRO_DEPTH; children_add(&b->numbers[i]); } } static void B_BloodLancet_override(Bullet *b, Weapon *src) { b->s.body.enable = 1, b->s.visible = 1; body_setCircle(&b->s.body, 0x40, b->s.body.offset.x, b->s.body.offset.y); b->isCullable = 0, b->s.alpha = 0.5f; b->amount = astro_amount(src), b->amount *= b->amount; sprite_setScale(&b->s, 0); b->slowPower = src->amount; astro_expire(b, Weapon_PDuration(src), B_BloodLancet_FadeOutCb); astro_stop(&b->imageTween); b->s.angle = 0; // onStart for (int i = 0; i < 12; i++) b->numbers[i].alpha = 0.5f; // stagger(20, { start: 1000 }): un tween per numero; il riferimento tiene l'ultimo (semplificazione: gli altri si fermano col loro sprite nascosto) for (int i = 0; i < 12; i++) b->imageTween = tweens_add((TweenConfig){ .props = { { &b->numbers[i].alpha, NULL, 0.8f } }, .nprops = 1, .loop = 1, .yoyo = 1, .duration = 0x3e8 + 0x14 * i, .repeat = -1 }); astro_stop(&b->angleTween); b->angleTween = tweens_add((TweenConfig){ .props = { { &b->s.angle, NULL, 0x168 } }, .nprops = 1, .loop = 1, .duration = 0xfa0, .repeat = -1 }); float sc = fmaxf(1, Core.Magnet->radius / 0x40); astro_stop(&b->scaleTween); b->scaleTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, sc } }, .nprops = 1, .duration = 0x12c }); astro_stop(&b->radiusTween); for (int i = 0; i < 12; i++) b->radii[i] = 0xa; for (int i = 0; i < 12; i++) b->radiusTween = tweens_add((TweenConfig){ .props = { { &b->radii[i], NULL, Core.Magnet->radius - 0xc } }, .nprops = 1, .duration = 0x3e8 * sc + 0x32 * i, .ease = Ease_SineInOut, .yoyo = 1, .repeat = -1 }); b->s.depth = ASTRO_DEPTH; } // explode (amount--): nessuno lo chiama, onLancetOverlapsEnemy non esplode; l'orologio dura PDuration static void B_BloodLancet_Update(Bullet *b, float delta) { (void)delta; float u = 2 * PI / 12, a = b->s.angle * (PI / 180); for (int i = 0; i < 12; i++) b->numbers[i].x = b->s.x + cosf(u * i + a) * b->radii[i], b->numbers[i].y = b->s.y + sinf(u * i + a) * b->radii[i]; } static void B_BloodLancet_OnHasHitAnObject(Bullet *b, void *o, int isDead) { if (isDead || !(((Sprite *)o)->groups & Core.Enemies.bit)) return; Enemy *e = ((Sprite *)o)->owner; if (e->res_Debuffs >= 1) return; if (e->slow > 0.2f) e->slow -= 0.01f * b->slowPower; } static const BulletVT B_Blood_Lancet = { "vfx", "outer0.png", B_BloodLancet_ctor, NULL, Bullet_OnRecycle, B_BloodLancet_OnHasHitAnObject, B_BloodLancet_Update, B_BloodRing_DeSpawn }; // W_BloodAstronomia static float W_Astro_PPower(Weapon *w) { return w->power * Core.Player->amount; } static float W_Astro_PArea(Weapon *w) { (void)w; return Core.Magnet->radius; } static void W_Astro_ctor(Weapon *w) { sprite_init(&w->image, frame_get("vfx", "Rings3.png"), Core.Magnet->s.x, Core.Magnet->s.y); w->image.blendAdd = 1, w->image.alpha = 0.6f, w->image.tint = 0xff0000; sprite_setScale(&w->image, Core.Magnet->radius / 0x10); children_add(&w->image); tweens_add((TweenConfig){ .props = { { &w->image.alpha, NULL, 0.3f } }, .nprops = 1, .loop = 1, .yoyo = 1, .duration = 0x3e8, .repeat = -1 }); tweens_add((TweenConfig){ .props = { { &w->image.angle, NULL, -0x168 } }, .nprops = 1, .loop = 1, .duration = 0x1770, .repeat = -1 }); } static void W_Astro_Fire(Weapon *w) { sprite_setScale(&w->image, Weapon_PArea(w) / 0x10); base_Fire(w); } static void W_Astro_Update(Weapon *w, float delta) { base_Update(w, delta); w->image.x = Core.Magnet->s.x, w->image.y = Core.Magnet->s.y; } static void W_Astro_hit(Weapon *w, Enemy *e, float p, float kb) { Enemy_GetDamaged(e, p, (int)w->hitVFX, kb, w->bulletType); w->stats_inflictedDamage += p; } static void W_Astro_onGarlic(void *ctx, Sprite *bs, Sprite *es) { Weapon *w = ctx; Enemy *e = es->owner; if (!e->isDead && !Bullet_HasAlreadyHitObject(bs->owner, e, e->isDead)) W_Astro_hit(w, e, Weapon_PPower(w->astroSrc[ASTRO_GARLIC]), w->knockback); } static void W_Astro_onSong(void *ctx, Sprite *bs, Sprite *es) { Weapon *w = ctx; Enemy *e = es->owner; if (e->isDead) return; if (!Bullet_HasAlreadyHitObject(bs->owner, e, e->isDead)) W_Astro_hit(w, e, Weapon_PPower(w->astroSrc[ASTRO_SONG]), w->knockback); B_BloodPlanet_explode(bs->owner); // explode(x, y): i pianeti ignorano gli argomenti } static void W_Astro_onPentagram(void *ctx, Sprite *bs, Sprite *es) { Weapon *w = ctx; Enemy *e = es->owner; if (e->isDead || Bullet_HasAlreadyHitObject(bs->owner, e, e->isDead)) return; if (!e->res_Rosary) W_Astro_hit(w, e, fmaxf(0x42, e->maxHp - e->hp), 0); B_BloodPentagram_explode(bs->owner); } static void W_Astro_onLaurel(void *ctx, Sprite *bs, Sprite *es) { // niente HasAlreadyHitObject: colpisce a ogni passo finche' ha cariche Weapon *w = ctx; Enemy *e = es->owner; if (e->isDead) return; Weapon *l = w->astroSrc[ASTRO_LAUREL]; W_Astro_hit(w, e, Weapon_PPower(l) * (fminf(10, Core.Player->amount) + l->amount), 0xa); B_BloodLaurel_explode(bs->owner, e->s.x, e->s.y); } static void W_Astro_onLancet(void *ctx, Sprite *bs, Sprite *es) { Weapon *w = ctx; Enemy *e = es->owner; if (!e->isDead && !Bullet_HasAlreadyHitObject(bs->owner, e, e->isDead)) W_Astro_hit(w, e, Weapon_PPower(w->astroSrc[ASTRO_LANCET]) + 0.5f, w->knockback); } static void W_Astro_OnStart(Weapon *w) { static const BulletVT *const vts[5] = { &B_Blood_Garlic, &B_Blood_Planet, &B_Blood_Pentagram, &B_Blood_Lancet, &B_Blood_Laurel }; static void (*const cbs[5])(void *, Sprite *, Sprite *) = { W_Astro_onGarlic, W_Astro_onSong, W_Astro_onPentagram, W_Astro_onLancet, W_Astro_onLaurel }; Weapon_ResetFiringTimer(w); for (int i = 0; i < 5; i++) w->bloodPools[i] = BulletPool_new(w, vts[i]); w->moonExplosionPool = calloc(1, sizeof(MoonExplosionPool)), w->moonExplosionPool->blood = 1; physics_addOverlap(&w->pool->group, &Core.Enemies, Weapon_onBulletOverlapsEnemy, w); physics_addOverlap(&w->pool->group, &Core.Destructibles, Weapon_onBulletOverlapsDestuctible, w); for (int i = 0; i < 5; i++) physics_addOverlap(&w->bloodPools[i]->group, &Core.Enemies, cbs[i], w); } static const WeaponVT W_BloodAstronomia = { BASE, .PPower = W_Astro_PPower, .PAmount = one_PAmount, .PArea = W_Astro_PArea, .bullet = &B_BloodAstronomia, .ctor = W_Astro_ctor, .Fire = W_Astro_Fire, .Update = W_Astro_Update, .OnStart = W_Astro_OnStart }; static Bullet *astro_spawn(Weapon *w, int k, float x, float y, int i) { Bullet *b = BulletPool_SpawnAt(w->bloodPools[k], x, y, w, i); if (!b) return NULL; switch (k) { // overrideWeaponData case ASTRO_GARLIC: B_BloodGarlic_override(b, w->astroSrc[k]); break; case ASTRO_SONG: B_BloodPlanet_override(b, w->astroSrc[k]); break; case ASTRO_PENTAGRAM: B_BloodPentagram_override(b, w->astroSrc[k]); break; case ASTRO_LANCET: B_BloodLancet_override(b, w->astroSrc[k]); break; case ASTRO_LAUREL: B_BloodLaurel_override(b, w->astroSrc[k]); break; } return b; } static void W_Astro_FirePentagramLater(void *ctx) { Weapon *w = ctx; int n = (int)(fminf(10, Core.Player->amount) + 3 * w->astroSrc[ASTRO_PENTAGRAM]->amount); float u = 2 * PI / n, r = fminf(0.45f * game_height, 0.75f * Core.Magnet->radius), x = Core.Player->s.x, y = Core.Player->s.y; for (int i = 0; i < n; i++) astro_spawn(w, ASTRO_PENTAGRAM, x + cosf(u * i) * r, y + sinf(u * i) * r, i); } static void Arcanas_TriggerAstronomia(Weapon *src) { Weapon *w = Arcanas.BloodAstronomiaWeapon; const char *t = src->bulletType; float x = Core.Player->s.x, y = Core.Player->s.y; if (!strcmp(t, "VORTEX") || !strcmp(t, "GARLIC")) { // FireGarlic w->astroSrc[ASTRO_GARLIC] = src; int n = (int)astro_amount(src); float r = 8 * fmaxf(Core.Magnet->radius / 0x20, Weapon_PArea(src)), u = 2 * PI / n; for (int i = 0; i < n; i++) astro_spawn(w, ASTRO_GARLIC, x + cosf(u * i) * r, y + sinf(u * i) * r, i); } else if (!strcmp(t, "MANNAGGIA") || !strcmp(t, "SONG")) { // FireSong w->astroSrc[ASTRO_SONG] = src; int n = (int)(fminf(10, Core.Player->amount) + 3 * src->amount); for (int i = 0; i < n; i++) astro_spawn(w, ASTRO_SONG, x, y, i); } else if (!strcmp(t, "SIRE") || !strcmp(t, "PENTAGRAM")) { // FirePentagram: dopo 200 ms w->astroSrc[ASTRO_PENTAGRAM] = src; time_addEvent(0xc8, 0, 0, W_Astro_FirePentagramLater, w); } else if (!strcmp(t, "LAUREL")) { // FireLaurel w->astroSrc[ASTRO_LAUREL] = src; astro_spawn(w, ASTRO_LAUREL, Core.Magnet->s.x, Core.Magnet->s.y, 0); } else if (!strcmp(t, "LANCET")) { // FireLancet w->astroSrc[ASTRO_LANCET] = src; astro_spawn(w, ASTRO_LANCET, Core.Magnet->s.x, Core.Magnet->s.y, 0); } } // --- Game Killer: W_GemCannon (0x184c1), B_GemCannon (0x12103), B_Window (0x620b) ----------------------------------------- // Ogni gemma raccolta parte verso un nemico a caso; dove colpisce si apre una "finestra" verticale che ferisce tutto cio' che tocca. static void B_GemCannon_ctor(Bullet *b) { b->Pfx = particles_add(); b->PfxEmitter = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "PfxColor1.png"), frame_get("vfx", "PfxColor2.png") }, .nframes = 2, .speed = ERND(0xf, 0x1e), .quantity = 1, .lifespan = EOP(0x12c), .alpha = ERANGE(1, 0), .on = 0 }); } static void B_GemCannon_OnHasHitAnObject(Bullet *b, void *o, int isDead) { (void)o; if (!isDead && --b->penetrating <= 0) Bullet_DeSpawn(b); } static void B_GemCannon_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); body_setCircle(&b->s.body, 8, b->s.body.offset.x, b->s.body.offset.y); sprite_setScale(&b->s, 1); b->s.x += (frand() - 0.5f) * b->indexInWeapon * 0xa; b->s.y += (frand() - 0.5f) * b->indexInWeapon * 0xa; Bullet_AimForRandomEnemy(b); b->s.angle -= 0x5a; Sound_PlaySound("MagicMissile", b->weapon->volume ? b->weapon->volume : 0.15f, 1, -0x64 * b->indexInWeapon, 0xc8, 0xc); if (b->weapon->gemFrame) sprite_setFrame(&b->s, b->weapon->gemFrame); } static void B_GemCannon_Update(Bullet *b, float delta) { (void)delta; emitter_emitParticleAt(b->PfxEmitter, b->s.x, b->s.y, 0); } static const BulletVT B_GemCannon = { "items", "GemBlue.png", B_GemCannon_ctor, NULL, B_GemCannon_OnRecycle, B_GemCannon_OnHasHitAnObject, B_GemCannon_Update, NULL }; static Animation windowStrike; static void B_Window_ctor(Bullet *b) { static const unsigned TINTS[6] = { 0xefe70d, 0xefc3ca, 0xe57714, 0xafcb09, 0x9fc4e0, 0x9e58fd }; b->s.scaleX = 0x60, b->s.scaleY = 0; if (!windowStrike.n) make_anim(&windowStrike, "vfx", "window_", 0, 0x1d, 0, 0x18, 0); sprite_init(&b->windowVfx, frame_get("vfx", "window_0.png"), b->s.x, b->s.y); b->windowVfx.visible = 0, b->windowVfx.depth = 0x2329; children_add(&b->windowVfx); sprite_init(&b->exploSprite, frame_get("vfx", "s_pfx_rainbow_64.png"), b->s.x, b->s.y); b->exploSprite.visible = 0, b->exploSprite.blendAdd = 1; children_add(&b->exploSprite); b->Pfx = particles_add(); EmitterConfig c = { .frames = { frame_get("vfx", "PfxLine2.png") }, .nframes = 1, .lifespan = EOP(0x1f4), .rotate = EOP(0), .angle = { 0, 0x168, 1 }, .angleSteps = 0x10, .speed = ERND(0x50, 0x64), .scale = ERANGE(4, 0), .scaleY = ERANGE(4, 0xc), .hasScaleY = 1, .alpha = ERANGE(0.75f, 0), .quantity = 1, .frequency = 1, .ntints = 6, .on = 0 }; for (int i = 0; i < 6; i++) c.tints[i] = TINTS[i]; b->PfxEmitter = particles_createEmitter(b->Pfx, c); c.speed = ERND(0xa0, 0xc8), c.scale = ERANGE(4, 6), c.blendAdd = 1; b->PfxEmitter2 = particles_createEmitter(b->Pfx, c); b->Pfx->hasWell = 1; // createGravityWell({ power: 1, epsilon: 50, gravity: 20 }) b->Pfx->wellPower = 1 * 0x14, b->Pfx->wellEpsilon = 0x32 * 0x32; b->Pfx->s.depth = 0x2328; } static void B_Window_done(void *ctx) { Bullet *b = ctx; emitter_stop(b->PfxEmitter), emitter_stop(b->PfxEmitter2); Bullet_DeSpawn(b); } static void B_Window_exploHide(void *ctx) { ((Bullet *)ctx)->exploSprite.visible = 0; } static void B_Window_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); b->windowVfx.visible = 0; float a = Weapon_PArea(b->weapon), d = 0x3e8 * (frand() - 0.5f); b->s.scaleX = 0x60 * a, b->s.scaleY = 0, b->s.alpha = 0; for (int i = 0; i < 3; i++) Sound_PlaySound("Window", 0.5f, 1, d - 0x190 * i, 0x96, 6); b->windowVfx.x = b->s.x, b->windowVfx.y = b->s.y, b->windowVfx.visible = 1; anims_play(&b->windowVfx, &windowStrike, 0); b->Pfx->wellX = b->s.x, b->Pfx->wellY = b->s.y - 0x14; b->PfxEmitter->x = b->PfxEmitter2->x = b->s.x, b->PfxEmitter->y = b->PfxEmitter2->y = b->s.y; b->PfxEmitter->c.scaleY = b->PfxEmitter2->c.scaleY = ERANGE(4, 0xc * a); emitter_start(b->PfxEmitter), emitter_start(b->PfxEmitter2); tween_stop(b->scaleTween); b->scaleTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleY, NULL, 0.5f * game_height * a } }, .nprops = 1, .duration = 0x78, .onComplete = B_Window_done, .ctx = b }); b->exploSprite.x = b->s.x, b->exploSprite.y = b->s.y; // FlashingVFXEnabled sprite_setScale(&b->exploSprite, 0), b->exploSprite.visible = 1, b->exploSprite.depth = 0x2328; tween_stop(b->exploTween); b->exploTween = tweens_add((TweenConfig){ .props = { { &b->exploSprite.scaleX, NULL, 0x60 * a / 0x40 }, { &b->exploSprite.scaleY, NULL, 0.5f * game_height * a / 0x40 } }, .nprops = 2, .duration = 0xfa, .onComplete = B_Window_exploHide, .ctx = b }); tween_stop(b->tween2); sprite_setScale(&b->windowVfx, 1); // onStart b->tween2 = tweens_add((TweenConfig){ .props = { { &b->windowVfx.scaleX, &b->windowVfx.scaleY, 1.5f } }, .nprops = 1, .duration = 0x12c }); } static const BulletVT B_Window = { "vfx", "blackDot.png", B_Window_ctor, NULL, B_Window_OnRecycle, NULL, NULL, NULL }; static float W_GemCannon_PPower(Weapon *w) { return w->gemValue; } static void W_GemCannon_ctor(Weapon *w) { w->gemValue = 1, w->gemFrame = frame_get("items", "GemBlue.png"); } static void W_GemCannon_onBulletOverlapsEnemy(Weapon *w, Bullet *b, Enemy *e) { if (e->isDead || Bullet_HasAlreadyHitObject(b, e, e->isDead)) return; Enemy_GetDamaged(e, Weapon_PPower(w), (int)w->hitVFX, w->knockback, w->bulletType); w->stats_inflictedDamage += Weapon_PPower(w); BulletPool_SpawnAt(w->secondaryPool, e->s.x, e->s.y, w, 0); } static void W_GemCannon_onExplosionOverlapsEnemy(void *ctx, Sprite *bs, Sprite *es) { Weapon *w = ctx; Enemy *e = es->owner; if (e->isDead || Bullet_HasAlreadyHitObject(bs->owner, e, e->isDead)) return; Enemy_GetDamaged(e, Weapon_PPower(w), (int)w->hitVFX, w->knockback, w->bulletType); w->stats_inflictedDamage += Weapon_PPower(w); } static void W_GemCannon_OnStart(Weapon *w) { base_OnStart(w); w->secondaryPool = BulletPool_new(w, &B_Window); physics_addOverlap(&w->secondaryPool->group, &Core.Enemies, W_GemCannon_onExplosionOverlapsEnemy, w); physics_addOverlap(&w->secondaryPool->group, &Core.Destructibles, Weapon_onBulletOverlapsDestuctible, w); } static const WeaponVT W_GemCannon = { BASE, .PPower = W_GemCannon_PPower, .PAmount = one_PAmount, .bullet = &B_GemCannon, .ctor = W_GemCannon_ctor, .ResetFiringTimer = noop_ResetFiringTimer, .onBulletOverlapsEnemy = W_GemCannon_onBulletOverlapsEnemy, .OnStart = W_GemCannon_OnStart }; // W_Window (0xbc47): l'arma delle vetrate della Cappella, un colpo alla volta e mai da sola static const WeaponVT W_WindowW = { BASE, .PAmount = one_PAmount, .bullet = &B_Window, .ResetFiringTimer = noop_ResetFiringTimer }; static void Arcanas_TriggerGemCannon(float value, const Frame *frame) { Weapon *w = Arcanas.GemCannonWeapon; w->gemValue = value, w->gemFrame = frame; Weapon_Fire(w); } static void Arcanas_TriggerFire(float x, float y) { Weapon *w = Arcanas.FireExplosionWeapon; BulletPool_SpawnAt(w->pool, x, y, w, 0); } static void Arcanas_TriggerCold(float x, float y) { Weapon *w = Arcanas.ColdExplosionWeapon; BulletPool_SpawnAt(w->pool, x, y, w, 0); } // B_Gatti: il gatto static void B_Gatti_ctor(Bullet *b) { b->defaultSpeed = b->_speed; sprite_init(&b->summon, frame_get("vfx", "summon.png"), 0, 0); b->summon.visible = 0; children_add(&b->summon); b->summonTween = b->entryTween = b->onExpireAlphaTween = TWEEN_NONE; b->chooseTimer = b->ExpireTimer = (Timer){ -1, 0 }; // PfxEmitter (PfxHoly): creato ma mai emesso dall'originale, non tradotto } static void B_Gatti_TargetPlayer(Bullet *b) { float dx = Core.Player->s.x - b->s.x, dy = Core.Player->s.y - b->s.y, l = sqrtf(dx * dx + dy * dy); if (l > 0) dx /= l, dy /= l; b->aimVec = (Vector2){ Bullet_TrueSpeed(b) * dx, Bullet_TrueSpeed(b) * dy }; } static void B_Gatti_ChooseTarget(void *ctx) { Bullet *b = ctx; Weapon *w = b->weapon; Vector2 t; Sprite *best = NULL; float bd = 1e30f; for (int i = 0; i < Core.PickupGroup.n; i++) { // filter(ROAST || NFT) + physics.closest(this, ...) Pickup *p = Core.PickupGroup.items[i]->owner; if (strcmp(p->itemType, "ROAST") && strcmp(p->itemType, "NFT")) continue; float dx = b->s.x - p->s.body.center.x, dy = b->s.y - p->s.body.center.y, d = dx * dx + dy * dy; if (d < bd) bd = d, best = &p->s; } if (!best) { float r = w->critChancesArray[w->critIndex++ % 1000]; if (r < 0.2f) { B_Gatti_TargetPlayer(b); return; } float px = Core.Player->s.x, py = Core.Player->s.y; t = r < 0.25f ? (Vector2){ px + 0xc8, py } : r < 0.5f ? (Vector2){ px - 0xc8, py } : r < 0.75f ? (Vector2){ px, py + 0xc8 } : (Vector2){ px, py - 0xc8 }; } else { t = (Vector2){ best->x, best->y }; } float dx = b->s.x - t.x, dy = b->s.y - t.y, l = sqrtf(dx * dx + dy * dy); // (sic) this - bersaglio: il gatto se ne allontana if (l > 0) dx /= l, dy /= l; b->aimVec = (Vector2){ Bullet_TrueSpeed(b) * dx, Bullet_TrueSpeed(b) * dy }; } static void B_Gatti_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void B_Gatti_onExpire(void *ctx) { Bullet *b = ctx; b->onExpireAlphaTween = tweens_add((TweenConfig){ .props = { { &b->s.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x12c, .onComplete = B_Gatti_despawn, .ctx = b }); } static void B_Gatti_OnRecycle(Bullet *b) { static const char *const catBaseFrames[3] = { "cat_i0", "cat3_i0", "cat2_i0" }; Weapon *w = b->weapon; Bullet_OnRecycle(b); if (!b->isInitialised) { const char *const *cf = w->catBaseFrames ? w->catBaseFrames : catBaseFrames; // trueWeapon.catBaseFrames int nc = w->catBaseFrames ? w->nCatBaseFrames : 3; make_anim(&b->idleAnim, "vfx", cf[(int)floorf(frand() * nc)], 1, 4, 0, 8, -1); // RND.pick anims_play(&b->s, &b->idleAnim, 0); b->isInitialised = 1; } tween_stop(b->summonTween), tween_stop(b->entryTween), tween_stop(b->onExpireAlphaTween); b->s.visible = 1; b->isCullable = 0; b->idleAnim.frameRate = 0xc * Weapon_PSpeed(w), b->idleAnim.msPerFrame = 1000 / b->idleAnim.frameRate; // play({ key, frameRate }) anims_play(&b->s, &b->idleAnim, 0); sprite_setScale(&b->s, 1); body_setCircle(&b->s.body, 8, b->s.body.offset.x, b->s.body.offset.y); sprite_setScale(&b->s, Weapon_PArea(w)); b->s.alpha = 1; sprite_setScale(&b->summon, 0); b->summon.visible = 1, b->summon.alpha = 1; b->s.tint = 0xffffff; b->_speed = b->defaultSpeed; b->summonTween = tweens_add((TweenConfig){ .props = { { &b->summon.scaleX, &b->summon.scaleY, Weapon_PArea(w) }, { &b->summon.alpha, NULL, 0 } }, .nprops = 2, .duration = 0x3e8 }); sprite_setScale(&b->s, 0); // entryTween onStart: scaleX = scaleY = 0 b->entryTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, Weapon_PArea(w) } }, .nprops = 1, .duration = 0x12c }); float a = 2 * PI * frand(); b->s.x += cosf(a) * game_width * 0.45f, b->s.y += sinf(a) * game_height * 0.45f; b->summon.x = b->s.x, b->summon.y = b->s.y + 0x18; b->save_vel_x = b->save_vel_y = 1; B_Gatti_TargetPlayer(b); time_removeEvent(b->chooseTimer); // l'originale lo ferma solo qui: dopo il DeSpawn continua a girare b->chooseTimer = time_addEvent(0x5dc / Weapon_PSpeed(w), 0, -1, B_Gatti_ChooseTarget, b); time_removeEvent(b->ExpireTimer); b->ExpireTimer = time_addEvent(Weapon_PDuration(w), 0, 0, B_Gatti_onExpire, b); Sound_PlaySound("MagicMissile", 0.2f, 1, 0x3e8, 0xc8, 0xc); } static void B_Gatti_OnHasHitWall(Bullet *b, Tile *t) { b->save_vel_x *= t && (t->faceRight || t->faceLeft) ? -1 : 1; b->save_vel_y *= t && (t->faceTop || t->faceBottom) ? -1 : 1; } static void B_Gatti_Update(Bullet *b, float delta) { (void)delta; sprite_setVelocity(&b->s, b->aimVec.x * b->save_vel_x, b->aimVec.y * b->save_vel_y); b->s.flipX = b->s.body.velocity.x < 0; b->summon.x = b->s.x, b->summon.y = b->s.y + 0x18; } static void B_Gatti_DeSpawn(Bullet *b) { b->s.visible = 0; base_DeSpawn(b); } static const BulletVT B_Gatti = { "vfx", "Cat.png", B_Gatti_ctor, NULL, B_Gatti_OnRecycle, NULL, B_Gatti_Update, B_Gatti_DeSpawn, NULL, NULL, B_Gatti_OnHasHitWall }; // W_Gatti static void W_Gatti_ctor(Weapon *w) { static const char *const cats[4] = { "CAT1", "CAT2", "CAT3", "CAT5" }; w->full = 1, w->chickens = 0; for (int i = 0; i < 0x1f4; i++) w->RANDOMS[i] = i / 500.0f; shuffle(w->RANDOMS, 0x1f4); // RND.shuffle for (int i = 0; i < 0x1f4; i++) w->PLUSMINUS[i] = (i - 0xfa) / 500.0f; shuffle(w->PLUSMINUS, 0x1f4); for (int i = 0; i < 0x78; i++) w->SFXARRAY[i] = cats[(int)floorf(frand() * 4)]; } static int W_Gatti_tryChance(Weapon *w) { return w->chance * Player_PLuck(Core.Player) < W_Gatti_GetRandom(w); } // PLuck; vero = il colpo NON riesce static void W_Gatti_onCatOverlapsEnemy(void *ctx, Sprite *bs, Sprite *es) { Weapon *w = ctx; Bullet *b = bs->owner; Enemy *e = es->owner; if (e->isDead || Bullet_HasAlreadyHitObject(b, e, e->isDead)) return; if (W_Gatti_tryChance(w)) { Bullet_pushHit(b, e); return; } BulletPool_SpawnAt(w->scratchPool, b->s.x, b->s.y, w, 0); Sound_PlaySound(W_Gatti_GetSfx(w), 0.2f, 1, 0x190 * W_Gatti_GetPlusMinus(w), 0xc8, 2); Enemy_GetDamaged(e, Weapon_PPower(w), (int)w->hitVFX, w->knockback, w->bulletType); w->stats_inflictedDamage += Weapon_PPower(w); } static void W_Gatti_onCatOverlapsPlayer(void *ctx, Sprite *bs, Sprite *ps) { Weapon *w = ctx; Bullet *b = bs->owner; (void)ps; if (Core.Player->isDead || Bullet_HasAlreadyHitObject(b, Core.Player, Core.Player->isDead)) return; if (W_Gatti_tryChance(w)) { // (sic) il graffio che non riesce sui nemici qui colpisce il giocatore BulletPool_SpawnAt(w->scratchPool, b->s.x, b->s.y, w, 0); Sound_PlaySound(W_Gatti_GetSfx(w), 0.2f, 1, 0, 0xc8, 2); w->stats_inflictedDamage += Weapon_PPower(w); Player_GetDamaged(Core.Player, 2 * Weapon_PPower(w)); return; } Bullet_pushHit(b, Core.Player); } static void W_Gatti_OnBulletOverlapsBullet(void *ctx, Sprite *as, Sprite *bs) { Weapon *w = ctx; Bullet *a = as->owner, *b = bs->owner; if (Bullet_HasAlreadyHitObject(a, b, 0)) return; Bullet_pushHit(b, a), Bullet_pushHit(a, b); if (w->chance * Player_PLuck(Core.Player) > W_Gatti_GetRandom(w)) { Sound_PlaySound("CAT3", 0.8f, 1, 0x190 * W_Gatti_GetRandom(w), 0xc8, 2); Sound_PlaySound("CATE", 1, 1, 0x190 * W_Gatti_GetRandom(w), 0xc8, 2); BulletPool_SpawnAt(w->scufflePool, b->s.x, b->s.y, w, 0); Bullet_DeSpawn(a); Bullet_DeSpawn(b); } } static void W_Gatti_OnBulletOverlapsPickup(void *ctx, Sprite *cs, Sprite *ps) { Weapon *w = ctx; Bullet *c = cs->owner; Pickup *p = ps->owner; const char *t = p->itemType; if (!strcmp(t, "ROAST")) { Sound_PlaySound(W_Gatti_GetSfx(w), 0.2f, 2, 0x3e8, 0xc8, 2); Sound_PlaySound("Roast", 0.6f, 1.7f, 0x1f4, 0, 0); w->chickens++; w->chance *= 1.1f; w->full = 1 - fminf(0.95f, w->chickens / 108.0f); w->power += 0.1f * w->full; Pickup_DeSpawn(p); } if (!strcmp(t, "NFT")) { Sound_PlaySound(W_Gatti_GetSfx(w), 0.2f, 2, 1, 0xc8, 2); BulletPool_SpawnAt(w->secondaryPool, p->s.x, p->s.y, w, 0); Bullet_DeSpawn(c); Pickup_DeSpawn(p); } if (!strcmp(t, "CLOVER") || !strcmp(t, "GILDED")) { Sound_PlaySound(W_Gatti_GetSfx(w), 0.2f, 2, 0x3e8, 0xc8, 2); c->_speed *= 2; Pickup_DeSpawn(p); } if (!strcmp(t, "ROSARY") || !strcmp(t, "VACUUM")) { if (W_Gatti_tryChance(w)) { Sound_PlaySound(W_Gatti_GetSfx(w), 0.2f, 2, -0x3e8, 0xc8, 2); Pickup_DeSpawn(p); } else Pickup_DoGetTaken(p); } if (!strcmp(t, "OROLOGION")) { if (W_Gatti_tryChance(w)) { Sound_PlaySound(W_Gatti_GetSfx(w), 0.2f, 2, -0x3e8, 0xc8, 2); sprite_setTint(&c->s, 0xff); Sound_PlaySound("Orologion", 1.5f, 4, 0, 0, 0); c->_speed = 0; Pickup_DeSpawn(p); } else { Pickup_DoGetTaken(p); } } } static void W_Gatti_OnBulletOverlapsEnemyNoKB(void *ctx, Sprite *bs, Sprite *es) { // GetDamaged(..., false): senza respinta Weapon *w = ctx; Bullet *b = bs->owner; Enemy *e = es->owner; if (e->isDead || Bullet_HasAlreadyHitObject(b, e, e->isDead)) return; Enemy_GetDamaged(e, Weapon_PPower(w), (int)w->hitVFX, 0, w->bulletType); w->stats_inflictedDamage += Weapon_PPower(w); } static void W_Gatti_OnStart(Weapon *w) { Weapon_ResetFiringTimer(w); physics_addOverlap(&w->pool->group, &Core.Enemies, W_Gatti_onCatOverlapsEnemy, w); physics_addOverlap(&w->pool->group, &Core.playerGroup, W_Gatti_onCatOverlapsPlayer, w); physics_addOverlap(&w->pool->group, &Core.Destructibles, Weapon_onBulletOverlapsDestuctible, w); physics_addOverlapSelf(&w->pool->group, W_Gatti_OnBulletOverlapsBullet, w); physics_addOverlap(&w->pool->group, &Core.PickupGroup, W_Gatti_OnBulletOverlapsPickup, w); if (w->hitsWalls && Core.Stage && Core.Stage->hasTileset) for (int i = 0; i < n_CollisionLayers; i++) w->wallsColliders[w->n_wallsColliders++] = physics_addColliderLayerCb(&w->pool->group, CollisionLayers[i], Weapon_onBulletOverlapsWall, w); w->secondaryPool = BulletPool_new(w, &B_FireExplosion); w->scratchPool = BulletPool_new(w, &B_Gatti_Scratch); w->scufflePool = BulletPool_new(w, &B_Gatti_Scuffle); physics_addOverlap(&w->secondaryPool->group, &Core.Enemies, Weapon_onBulletOverlapsEnemy, w); physics_addOverlap(&w->secondaryPool->group, &Core.Destructibles, Weapon_onBulletOverlapsDestuctible, w); physics_addOverlap(&w->scratchPool->group, &Core.Enemies, Weapon_onBulletOverlapsEnemy, w); physics_addOverlap(&w->scufflePool->group, &Core.Enemies, W_Gatti_OnBulletOverlapsEnemyNoKB, w); } // LevelUp/MakeLevelOne: ChangeBGMRate agisce solo con BGM_Gatti in riproduzione (non nella Foresta) static const WeaponVT W_Gatti = { BASE, .CheckArcanas = CA_gatti, .bullet = &B_Gatti, .ctor = W_Gatti_ctor, .OnStart = W_Gatti_OnStart }; // Gemini: W_Gatti_Counter (0x27c6): altri gatti, PLUSMINUS spostato di -2, niente CheckArcanas ne' BGM static void W_GattiCounter_ctor(Weapon *w) { static const char *const cats[3] = { "cat4_i0", "cat6_i0", "cat5_i0" }; W_Gatti_ctor(w); w->catBaseFrames = cats, w->nCatBaseFrames = 3; for (int i = 0; i < 0x1f4; i++) w->PLUSMINUS[i] -= 2; } static const WeaponVT W_Gatti_Counter = { BASE, .CheckArcanas = CA_none, .bullet = &B_Gatti, .ctor = W_GattiCounter_ctor, .OnStart = W_Gatti_OnStart }; // --- Stigrangatti: W_Grangatti (0xa914), B_Grangatti (0x1446c) ------------------------------------------------- // Occhi evocati attorno al giocatore che inseguono i pickup: l'oro va al giocatore, il cibo e i nemici uccisi diventano monete. static Vector2 Grangatti_ellipse[5], Grangatti_edge[0x30]; static void B_Grangatti_ctor(Bullet *b) { static Animation idle; static const char *const smoke[6] = { "SmokeB1.png", "SmokeB2.png", "SmokeB3.png", "SmokeB4.png", "SmokeB5.png", "SmokeB6.png" }; if (!idle.n) { make_anim(&idle, "vfx", "eyeanim_", 0, 0x1d, 0, 0x10, -1); for (int i = 0; i < 5; i++) Grangatti_ellipse[i] = (Vector2){ 0.5f * game_width * cosf(2 * PI * i / 5), 0.5f * game_height * sinf(2 * PI * i / 5) }; // Ellipse.getPoints(5) for (int i = 0; i < 0x30; i++) Grangatti_edge[i] = (Vector2){ 0x18 * cosf(2 * PI * i / 0x30), 0x18 * sinf(2 * PI * i / 0x30) }; // explosionCircle, edge quantity 48 } EmitterConfig c = { .nframes = 6, .angle = ERND(0, 0x168), .speed = ERND(0xf, 0x1e), .quantity = 1, .lifespan = EOP(0x2ee), .alpha = ERANGE(1, 0), .scale = ERANGE(1, 0), .on = 0 }; for (int i = 0; i < 6; i++) c.frames[i] = frame_get("vfx", smoke[i]); b->Pfx = particles_add(); c.hasZone = 1, c.zoneRadius = 0x18; b->PfxEmitter = particles_createEmitter(b->Pfx, c); b->PfxExplosion = particles_add(); c.hasZone = 0, c.edge = Grangatti_edge, c.nEdge = 0x30; b->PfxEmitter2 = particles_createEmitter(b->PfxExplosion, c); b->defaultSpeed = b->_speed; sprite_init(&b->summon, frame_get("vfx", "summon.png"), 0, 0); b->summon.visible = 0; children_add(&b->summon); anims_play(&b->s, &idle, 0); b->summonTween = b->entryTween = b->onExpireAlphaTween = TWEEN_NONE; b->chooseTimer = b->ExpireTimer = b->HitboxTimer = (Timer){ -1, 0 }; } static void B_Grangatti_ChooseTarget(void *ctx) { Bullet *b = ctx; Vector2 t; Sprite *best = NULL; float bd = 1e30f; for (int i = 0; i < Core.PickupGroup.n; i++) { // physics.closest(this, PickupGroup.children.entries) Pickup *p = Core.PickupGroup.items[i]->owner; float dx = b->s.x - p->s.body.center.x, dy = b->s.y - p->s.body.center.y, d = dx * dx + dy * dy; if (d < bd) bd = d, best = &p->s; } if (!best) { Vector2 e = Grangatti_ellipse[(int)floorf(frand() * 5)]; // RND.pick t = (Vector2){ Core.Player->s.x + e.x, Core.Player->s.y + e.y }; } else { t = (Vector2){ best->x, best->y }; } float dx = t.x - b->s.x, dy = t.y - b->s.y, l = sqrtf(dx * dx + dy * dy); if (l > 0) dx /= l, dy /= l; b->aimVec = (Vector2){ Bullet_TrueSpeed(b) * dx, Bullet_TrueSpeed(b) * dy }; } static void B_Grangatti_hitbox(void *ctx) { ((Bullet *)ctx)->n_hit = 0; } // objectsHit = [] static void B_Grangatti_OnRecycle(Bullet *b) { Weapon *w = b->weapon; Bullet_OnRecycle(b); tween_stop(b->summonTween), tween_stop(b->entryTween), tween_stop(b->onExpireAlphaTween); b->s.visible = 1; b->isCullable = 0; sprite_setOrigin(&b->s, 0.5f, 0.5f); sprite_setScale(&b->s, 1); body_setCircle(&b->s.body, 0xe, b->s.body.offset.x, b->s.body.offset.y); sprite_setScale(&b->s, Weapon_PArea(w)); b->s.alpha = 0.7f; sprite_setScale(&b->summon, 0); b->summon.visible = 1, b->summon.alpha = 1; b->s.tint = 0xffffff; b->_speed = b->defaultSpeed; b->summonTween = tweens_add((TweenConfig){ .props = { { &b->summon.scaleX, &b->summon.scaleY, Weapon_PArea(w) }, { &b->summon.alpha, NULL, 0 } }, .nprops = 2, .duration = 0x3e8 }); sprite_setScale(&b->s, 0); // entryTween onStart: scaleX = scaleY = 0 b->entryTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, Weapon_PArea(w) } }, .nprops = 1, .duration = 0x12c }); float a = 2 * PI * frand(); b->s.x += cosf(a) * game_width * 0.45f, b->s.y += sinf(a) * game_height * 0.45f; b->summon.x = b->s.x, b->summon.y = b->s.y + 0x18; b->save_vel_x = b->save_vel_y = 1; B_Gatti_TargetPlayer(b); time_removeEvent(b->chooseTimer); // come in B_Gatti: dopo il DeSpawn continua a girare b->chooseTimer = time_addEvent(0x5dc / Weapon_PSpeed(w), 0, -1, B_Grangatti_ChooseTarget, b); time_removeEvent(b->ExpireTimer); b->ExpireTimer = time_addEvent(Weapon_PDuration(w), 0, 0, B_Gatti_onExpire, b); time_removeEvent(b->HitboxTimer); b->HitboxTimer = time_addEvent(w->hitBoxDelay, 1, 0, B_Grangatti_hitbox, b); Sound_PlaySound("MagicMissile", 0.2f, 1, -0x3e8, 0xc8, 0xc); } static void B_Grangatti_Update(Bullet *b, float delta) { (void)delta; if (b->indexInWeapon < 6) manager_emitParticleAt(b->Pfx, b->s.x, b->s.y), manager_emitParticleAt(b->PfxExplosion, b->s.x, b->s.y); b->s.depth = b->s.y - Core.Player->s.y - 0x20; b->Pfx->s.depth = b->s.depth - 1, b->PfxExplosion->s.depth = b->s.depth + 1; sprite_setVelocity(&b->s, b->aimVec.x * b->save_vel_x, b->aimVec.y * b->save_vel_y); b->s.flipX = b->s.body.velocity.x < 0; b->summon.x = b->s.x, b->summon.y = b->s.y + 0x18; } static void B_Grangatti_DeSpawn(Bullet *b) { time_removeEvent(b->HitboxTimer); b->s.visible = 0; base_DeSpawn(b); } // OnHasHitWall rimbalza, ma W_Grangatti.OnStart non aggiunge i collider dei muri: non scatta mai static const BulletVT B_Grangatti = { "vfx", "eye.png", B_Grangatti_ctor, NULL, B_Grangatti_OnRecycle, NULL, B_Grangatti_Update, B_Grangatti_DeSpawn }; static void W_Grangatti_ctor(Weapon *w) { w->goldChance = 0.005f; for (int i = 0; i < 0x3e8; i++) w->RANDOMS[i] = w->PLUSMINUS[i] = i / 1000.0f; shuffle(w->RANDOMS, 0x3e8), shuffle(w->PLUSMINUS, 0x3e8); } static int W_Grangatti_TurnToGold(Weapon *w, float x, float y) { if (!(w->RANDOMS[w->randomIndex++ % 0x3e8] < w->goldChance * Player_PLuck(Core.Player))) return 0; // PLuck Pickup *p = Core_MakePickup(x, y, "COIN"); if (p) p->time = 1, p->goToPlayer = 1, p->value = 1, p->feverMS = 0x32; if (p) po_add("RunHunger", p->value * GoldMultiplier * Player_PGreed(Core.Player)); return 1; } static void W_Grangatti_OnBulletOverlapsPickup(void *ctx, Sprite *bs, Sprite *ps) { static const char *const gold[] = { "COIN", "COINBAG1", "COINBAGMAX" }, *const edible[] = { "ROAST", "CLOVER", "OROLOGION", "ROSARY", "NFT", "GEM", "VACUUM" }; Weapon *w = ctx; Pickup *p = ps->owner; if (Bullet_HasAlreadyHitObject(bs->owner, p, 0)) return; for (int i = 0; i < 3; i++) if (!strcmp(p->itemType, gold[i])) { p->time = 1, p->goToPlayer = 1; return; } for (int i = 0; i < 7; i++) if (!strcmp(p->itemType, edible[i])) { if ((p->value <= 2 && w->PLUSMINUS[w->plusMinusIndex++ % 0x3e8] >= 0.25f) || W_Grangatti_TurnToGold(w, p->s.x, p->s.y)) { Sound_PlaySound("Roast", 0.1f, 2, -0x3e8, 0xc8, 2); Pickup_DeSpawn(p); } return; } } static void W_Grangatti_OnBulletOverlapsEnemyNoKB(void *ctx, Sprite *bs, Sprite *es) { Weapon *w = ctx; Enemy *e = es->owner; if (e->isDead || Bullet_HasAlreadyHitObject(bs->owner, e, e->isDead)) return; Enemy_GetDamaged(e, Weapon_PPower(w), (int)w->hitVFX, 0, w->bulletType); w->stats_inflictedDamage += Weapon_PPower(w); if (e->isDead) W_Grangatti_TurnToGold(w, e->s.x, e->s.y); } static void W_Grangatti_OnStart(Weapon *w) { // niente collider dei muri Weapon_ResetFiringTimer(w); physics_addOverlap(&w->pool->group, &Core.Enemies, W_Grangatti_OnBulletOverlapsEnemyNoKB, w); physics_addOverlap(&w->pool->group, &Core.Destructibles, Weapon_onBulletOverlapsDestuctible, w); physics_addOverlap(&w->pool->group, &Core.PickupGroup, W_Grangatti_OnBulletOverlapsPickup, w); } // MakeLevelOne: il power di GATTI rimosso alza il proprio (e goldChance) solo se supera 3, cioe' col limit break; counterWeapon: arcana Aquarius static const WeaponVT W_Grangatti = { BASE, .CheckArcanas = CA_grangatti, .bullet = &B_Grangatti, .ctor = W_Grangatti_ctor, .OnStart = W_Grangatti_OnStart }; // --- Song of Mana: W_Song (0x144b9), B_Song (0x9ab5) --------------------------------------------------------- // Colonna verticale che segue il giocatore; a schermo due Blitter di particelle additive che rimbalzano nella colonna. typedef struct { float x, y, alpha, vx, vy, bounce; const Frame *f; float defaultBounce; } Bob; // defaultBounce: B_Song2 typedef struct Blitter { Sprite s; Bob *bobs; int n, cap; } Blitter; // GameObjects.Blitter (scrollFactor 0, ADD) static void Blitter_draw(Sprite *s) { Blitter *bl = s->owner; if (!s->visible || s->alpha <= 0) return; float cx = s->scrollFactor0 ? 0 : camera_scrollX, cy = s->scrollFactor0 ? 0 : camera_scrollY; if (s->blendAdd) BeginBlendMode(BLEND_ADDITIVE); for (int i = 0; i < bl->n; i++) { // Bob: origine in alto a sinistra, alpha del bob per quella del blitter Bob *b = &bl->bobs[i]; const Frame *f = b->f; DrawTexturePro(*f->tex, (Rectangle){ f->x, f->y, f->w, f->h }, (Rectangle){ roundf(b->x + f->ox - cx), roundf(b->y + f->oy - cy), f->w, f->h }, (Vector2){ 0, 0 }, 0, (Color){ 255, 255, 255, (unsigned char)(255 * fminf(1, b->alpha * s->alpha)) }); } if (s->blendAdd) EndBlendMode(); } static Blitter *Blitter_add(void) { // scene.add.blitter(0, 0, 'vfx') Blitter *bl = calloc(1, sizeof(Blitter)); sprite_init(&bl->s, NULL, 0, 0); bl->s.owner = bl; bl->s.draw = Blitter_draw; bl->s.scrollFactor0 = 1; bl->s.blendAdd = 1; children_add(&bl->s); return bl; } static void B_Song_AddBobs(Blitter *bl, int n) { static const char *const fr[3] = { "PfxPink.png", "PfxYellow.png", "PfxBlue.png" }; for (int i = 0; i < n; i++) { float a = frand() * PI; if (bl->n == bl->cap) bl->bobs = realloc(bl->bobs, (bl->cap = bl->cap ? bl->cap * 2 : 128) * sizeof(Bob)); bl->bobs[bl->n++] = (Bob){ 0.5f * game_width, 0.5f * game_height, 0.5f, 2 * sinf(a), 0xa * cosf(a), 1 + 0.2f * frand(), frame_get("vfx", fr[i % 3]) }; } } static void B_Song_ctor(Bullet *b) { // MakeBlitters b->blitter = Blitter_add(); B_Song_AddBobs(b->blitter, 0x64); b->blitter->s.alpha = 0; b->blitterBG = Blitter_add(); B_Song_AddBobs(b->blitterBG, 0x64); b->blitterBG->s.alpha = 0; b->HitboxTimer = b->ExpireTimer = b->FadeOutTimer = (Timer){ -1, 0 }; b->ScaleTween = b->FadeOutTween = TWEEN_NONE; } static void B_Song_UpdateBlitter(Blitter *bl, float mul) { for (int i = 0; i < bl->n; i++) { Bob *o = &bl->bobs[i]; float a = frand() * PI * 2; o->vx = 0.5f * (1 + i % 7) * sinf(a) * mul, o->vy = 5 * cosf(a) * mul, o->bounce = 0.8f + 0.2f * frand(); o->x = 0.5f * game_width, o->y = 0.5f * game_height; } } static void B_Song_despawn(void *ctx) { Bullet_DeSpawn(ctx); } // CheckExplodeOnExpire: vuota static void B_Song_fadeOut(void *ctx) { Bullet *b = ctx; b->isBroken = 1; b->s.body.enable = 0; tween_stop(b->FadeOutTween); b->FadeOutTween = tweens_add((TweenConfig){ .props = { { &b->blitter->s.alpha, NULL, 0 }, { &b->blitterBG->s.alpha, NULL, 0 } }, .nprops = 2, .duration = 0x3e8, .onComplete = B_Song_despawn, .ctx = b }); } static void B_Song_Shoot(Bullet *b) { b->blitter->s.depth = Core.Player->s.depth + game_height; b->blitterBG->s.depth = Core.Player->s.depth - game_height; b->blitter->s.alpha = b->blitterBG->s.alpha = 1; B_Song_UpdateBlitter(b->blitter, 1); B_Song_UpdateBlitter(b->blitterBG, 1); time_removeEvent(b->FadeOutTimer); b->FadeOutTimer = time_addEvent(Weapon_PDuration(b->weapon), 0, 0, B_Song_fadeOut, b); } static void B_Song_resetHits(void *ctx) { ((Bullet *)ctx)->n_hit = 0; } // 'SM Hitbox' static void B_Song_OnRecycle(Bullet *b) { Weapon *w = b->weapon; float a = Weapon_PArea(w); b->s.visible = 0; Bullet_OnRecycle(b); sprite_setScale(&b->s, 0); b->s.body.enable = 1; b->isCullable = 0; time_removeEvent(b->HitboxTimer), time_removeEvent(b->ExpireTimer); b->HitboxTimer = time_addEvent(w->hitBoxDelay, 1, 0, B_Song_resetHits, b); tween_stop(b->ScaleTween); b->ScaleTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, NULL, 0x20 * a }, { &b->s.scaleY, NULL, 0x1c8 } }, .nprops = 2, .duration = 0x1f4 }); // GAMEPLAY_PIXEL_HEIGHT if (a >= 1.5f && b->blitter->n < 0xc8) B_Song_AddBobs(b->blitter, 0x64), B_Song_AddBobs(b->blitterBG, 0x64); if (a >= 2 && b->blitter->n < 0x12c) B_Song_AddBobs(b->blitter, 0x64), B_Song_AddBobs(b->blitterBG, 0x64); if (a >= 2.5f && b->blitter->n < 0x1f4) B_Song_AddBobs(b->blitter, 0xc8), B_Song_AddBobs(b->blitterBG, 0xc8); if (a >= 3 && b->blitter->n < 0x3e8) B_Song_AddBobs(b->blitter, 0x64), B_Song_AddBobs(b->blitterBG, 0x64); b->isBroken = 0; B_Song_Shoot(b); Sound_PlaySound("Song", 0.4f, 1, 0x1f4 * frand(), 0x96, 3); } static void B_Song_BlitterBounce(Blitter *bl, float right, float left, float top, float bottom) { for (int i = 0; i < bl->n; i++) { Bob *o = &bl->bobs[i]; o->y += o->vy, o->x += o->vx; if (o->x > right) o->x = right, o->vx *= -o->bounce; else if (o->x < left) o->x = left, o->vx *= -o->bounce; if (o->y > bottom) o->y = bottom, o->vy *= -o->bounce; if (o->y < top) o->y = top, o->vy *= -o->bounce; } } static void B_Song_Update(Bullet *b, float delta) { (void)delta; b->s.x = Core.Player->s.x, b->s.y = Core.Player->s.y; float a = Weapon_PArea(b->weapon), right = 0.5f * game_width + 0x10 * a, left = 0.5f * game_width - 0x10 * a, top = -0.25f * game_height, bottom = 1.25f * game_height; if (b->isBroken) right = game_width, left = 0; B_Song_BlitterBounce(b->blitter, right, left, top, bottom); B_Song_BlitterBounce(b->blitterBG, right, left, top, bottom); } static void B_Song_DeSpawn(Bullet *b) { b->isCullable = 1; time_removeEvent(b->HitboxTimer), time_removeEvent(b->ExpireTimer); base_DeSpawn(b); } static const BulletVT B_Song = { "vfx", "WhiteDot.png", B_Song_ctor, NULL, B_Song_OnRecycle, NULL, B_Song_Update, B_Song_DeSpawn }; // W_Song: PAmount 1 (amount -> SecondaryPAmount, non usato) static void W_SongAstro_Fire(Weapon *w) { base_Fire(w); if (Arcanas.hasAstronomia) Arcanas_TriggerAstronomia(w); } // Song, Song2 static const WeaponVT W_Song = { BASE, .PPower = blood2_PPower, .CheckArcanas = CA_twilight, .bullet = &B_Song, .PAmount = one_PAmount, .Fire = W_SongAstro_Fire }; // --- Mannajja: W_Song2 (0x9e66), B_Song2 (0x10bd9) ------------------------------------------------------------ // Song of Mana evoluta: 800 bob per Blitter dentro lo schermo, dissolvenza a meta' durata, rallenta chi colpisce. static void B_Song2_ctor(Bullet *b) { B_Song_ctor(b); b->blitter->n = b->blitterBG->n = 0; B_Song_AddBobs(b->blitter, 0x320), B_Song_AddBobs(b->blitterBG, 0x320); for (int k = 0; k < 2; k++) { Blitter *bl = k ? b->blitterBG : b->blitter; for (int i = 0; i < bl->n; i++) bl->bobs[i].bounce = bl->bobs[i].defaultBounce = 0.8f + 0.2f * frand(); } } static void B_Song2_UpdateBlitter(Blitter *bl) { for (int i = 0; i < bl->n; i++) { Bob *o = &bl->bobs[i]; float a = frand() * PI * 2; o->vx = 0.125f * (1 + i % 5) * sinf(a) * 5, o->vy = 0.125f * (1 + i % 5) * cosf(a) * 5, o->bounce = o->defaultBounce; o->x = 0.5f * game_width, o->y = 0.5f * game_height; } } static void B_Song2_broken(void *ctx) { Bullet *b = ctx; b->isBroken = 1, b->s.body.enable = 0; } static void B_Song2_OnRecycle(Bullet *b) { Weapon *w = b->weapon; b->s.visible = 0; Bullet_OnRecycle(b); sprite_setScale(&b->s, 0); b->s.body.enable = 1; b->isCullable = 0; time_removeEvent(b->HitboxTimer), time_removeEvent(b->ExpireTimer); b->HitboxTimer = time_addEvent(w->hitBoxDelay, 1, 0, B_Song_resetHits, b); // 'MN Hitbox' tween_stop(b->ScaleTween); b->ScaleTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, NULL, 0x20 * Weapon_PArea(w) }, { &b->s.scaleY, NULL, 0x1c8 } }, .nprops = 2, .duration = 0x1f4 }); b->isBroken = 0; // Shoot b->blitter->s.depth = Core.Player->s.depth + game_height; b->blitterBG->s.depth = Core.Player->s.depth - game_height; b->blitter->s.alpha = b->blitterBG->s.alpha = 1; B_Song2_UpdateBlitter(b->blitter), B_Song2_UpdateBlitter(b->blitterBG); time_removeEvent(b->FadeOutTimer); b->FadeOutTimer = time_addEvent(Weapon_PDuration(w), 0, 0, B_Song2_broken, b); tween_stop(b->FadeOutTween); b->FadeOutTween = tweens_add((TweenConfig){ .props = { { &b->blitter->s.alpha, NULL, 0 }, { &b->blitterBG->s.alpha, NULL, 0 } }, .nprops = 2, .delay = 0.5f * Weapon_PDuration(w), .duration = 0.5f * Weapon_PDuration(w), .onComplete = B_Song_despawn, .ctx = b }); for (int i = 0; i < 3; i++) Sound_PlaySound("Song", 0.4f, 1, 0x3e8 * frand(), 0x96, 3); } static void B_Song2_Update(Bullet *b, float delta) { (void)delta; b->s.x = Core.Player->s.x, b->s.y = Core.Player->s.y; // copyPosition float a = Weapon_PArea(b->weapon), right = 0.5f * game_width + 0x10 * a, left = 0.5f * game_width - 0x10 * a; if (b->isBroken) right = game_width, left = 0; B_Song_BlitterBounce(b->blitter, right, left, 0, game_height); B_Song_BlitterBounce(b->blitterBG, right, left, 0, game_height); } static void B_Song2_OnHasHitAnObject(Bullet *b, void *o, int isDead) { // sui Destructible res_Debuffs e slow sono undefined: niente (void)b; if (isDead || !(((Sprite *)o)->groups & Core.Enemies.bit)) return; Enemy *e = o; if (e->res_Debuffs >= 1) return; if (e->slow > 0.2f) e->slow -= 0.05f; } // DamageAllEnemies: solo con le arcane static const BulletVT B_Song2 = { "vfx", "WhiteDot.png", B_Song2_ctor, NULL, B_Song2_OnRecycle, B_Song2_OnHasHitAnObject, B_Song2_Update, B_Song_DeSpawn }; // W_Song2: PAmount 1 static const WeaponVT W_Song2 = { BASE, .CheckArcanas = CA_twilight, .bullet = &B_Song2, .PAmount = one_PAmount, .Fire = W_SongAstro_Fire }; // --- Shadow Pinion: W_Trapano (0x8cbc), B_Trapano (0x4906) -------------------------------------------------- // Zone a terra lasciate camminando; quando il giocatore si ferma scattano nella direzione dell'ultimo passo. static void Trapano_groundDraw(Sprite *s) { // scene.add.circle(0, 0, 8, 0x440000), ADD: raggio 8 * scala Bullet *b = s->owner; if (!s->visible || s->alpha <= 0 || s->scaleX <= 0) return; BeginBlendMode(BLEND_ADDITIVE); DrawCircle((int)roundf(s->x - camera_scrollX), (int)roundf(s->y - camera_scrollY), b->radius * s->scaleX, hexc(s->tint, s->alpha)); EndBlendMode(); } static void Trapano_trailDraw(Sprite *s) { // Graphics: ogni passata usa l'ultimo lineStyle per tutti i segmenti Bullet *b = s->owner; if (b->npos < 2 || s->alpha <= 0) return; float w = ceilf(Weapon_PArea(b->weapon)), ox = s->x - camera_scrollX, oy = s->y - camera_scrollY; for (int i = 1; i < b->npos; i++) DrawLineEx((Vector2){ ox + b->positions[i - 1].x, oy + b->positions[i - 1].y }, (Vector2){ ox + b->positions[i].x, oy + b->positions[i].y }, w, hexc(0, s->alpha)); int last = 0; for (int i = 1; i < 0x32 && i < b->npos; i++) last = i; float a = fminf(1, 1.0f / (last / 20.0f)) * s->alpha; for (int i = 1; i <= last; i++) DrawLineEx((Vector2){ ox + b->positions[i - 1].x, oy + b->positions[i - 1].y }, (Vector2){ ox + b->positions[i].x, oy + b->positions[i].y }, 0.5f * w, hexc(0x444444, a)); } static void B_Trapano_ctor(Bullet *b) { static Animation idle; b->radius = 8; sprite_init(&b->trail, NULL, 0, 0); b->trail.owner = b; b->trail.draw = Trapano_trailDraw; children_add(&b->trail); sprite_init(&b->GroundFx, NULL, 0, 0); b->GroundFx.owner = b; b->GroundFx.draw = Trapano_groundDraw; b->GroundFx.tint = 0x440000, b->GroundFx.alpha = 0.5f, b->GroundFx.visible = 1; children_add(&b->GroundFx); b->s.visible = 0; sprite_init(&b->spikeSprite, frame_get("items", "trapano.png"), b->s.x, b->s.x); // (sic) x, x sprite_setScale(&b->spikeSprite, 0); sprite_setOrigin(&b->spikeSprite, 0.5f, 1); b->spikeSprite.angle = -0x2d; children_add(&b->spikeSprite); b->AngleTween = tweens_add((TweenConfig){ .props = { { &b->spikeSprite.angle, NULL, 0x2d } }, .nprops = 1, .duration = 0x3e8, .repeat = -1, .yoyo = 1, .delay = 0x1f4 * frand() + 0xef * b->indexInWeapon, .persist = 1 }); if (!idle.n) make_anim(&idle, "vfx", "trapano", 1, 0xa, 0, 0x10, -1); anims_play(&b->spikeSprite, &idle, 0); b->tween1 = TWEEN_NONE; b->HitboxTimer = b->ExpireTimer = (Timer){ -1, 0 }; } static void B_Trapano_resetHits(void *ctx) { ((Bullet *)ctx)->n_hit = 0; } static void B_Trapano_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void B_Trapano_FadeOut(void *ctx) { Bullet *b = ctx; if (b->isFading) return; b->isFading = 1; tweens_add((TweenConfig){ .props = { { &b->spikeSprite.alpha, NULL, 0 }, { &b->s.alpha, NULL, 0 }, { &b->GroundFx.alpha, NULL, 0 } }, .nprops = 3, .duration = 0xc8, .onComplete = B_Trapano_despawn, .ctx = b }); tweens_add((TweenConfig){ .props = { { &b->trail.alpha, NULL, 0 } }, .nprops = 1, .duration = 0xc8 }); // 4 target: il trail nel secondo tween if (b->weapon->explodeOnExpire) Weapon_SpawnExplosionAt(b->weapon, b->s.x, b->s.y, 0); } static void B_Trapano_OnRecycle(Bullet *b) { Weapon *w = b->weapon; float a = Weapon_PArea(w); Bullet_OnRecycle(b); b->isCullable = 0; b->isFading = 0; b->npos = 0; // trail.clear() b->trail.alpha = 1; b->spikeSprite.angle = -0x2d; tween_play(b->AngleTween); b->trail.x = b->s.x - Core.Player->s.x, b->trail.y = b->s.y - Core.Player->s.y; sprite_setScale(&b->s, 1); body_setCircle(&b->s.body, 8, -4, -4); b->s.body.enable = 1; b->n_hit = 0; b->isYeeted = 0; b->spikeSprite.visible = 1, b->GroundFx.visible = 1, b->s.visible = 0; b->s.alpha = 1, b->spikeSprite.alpha = 1, b->GroundFx.alpha = 0.5f; b->save_vel_x = b->save_vel_y = 1; b->aimVec = (Vector2){ 0, 0 }; Vector2 pv = Core.Player->s.body.velocity; float l = sqrtf(pv.x * pv.x + pv.y * pv.y); b->previousVector = l > 0 ? (Vector2){ pv.x / l, pv.y / l } : pv; sprite_setVelocity(&b->s, 0, 0); b->spikeSprite.x = b->s.x, b->spikeSprite.y = b->s.y + 8; b->spikeSprite.angle = 0; b->GroundFx.x = b->s.x, b->GroundFx.y = b->s.y; b->s.scaleX = b->s.scaleY = b->GroundFx.scaleX = b->GroundFx.scaleY = 0; tween_stop(b->tween1); b->spikeSprite.scaleX = b->spikeSprite.scaleY = 0; // tween1 onStart b->tween1 = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, a }, { &b->spikeSprite.scaleX, &b->spikeSprite.scaleY, a } }, .nprops = 2, .duration = 0x12c }); tweens_add((TweenConfig){ .props = { { &b->GroundFx.scaleX, &b->GroundFx.scaleY, 1.1f * a } }, .nprops = 1, .duration = 0x12c, .yoyo = 1 }); time_removeEvent(b->HitboxTimer); b->HitboxTimer = time_addEvent(w->hitBoxDelay, 1, 0, B_Trapano_resetHits, b); b->durata = 0; time_removeEvent(b->ExpireTimer); b->ExpireTimer = time_addEvent(Weapon_PDuration(w), 1, 0, B_Trapano_FadeOut, b); } static void B_Trapano_yeetStart(void *ctx) { // onStart del tween dello scatto (dopo il suo delay) Bullet *b = ctx; tween_stop(b->AngleTween); b->spikeSprite.angle = b->s.angle + 0x5a; Sound_PlaySound("Shot", 0.45f, 1, -0xc8 - -0xc8 * b->indexInWeapon, 0xc8, 0xa); } static void B_Trapano2_yeetStart(void *ctx); static void B_Trapano2_FadeOut(void *ctx); static const BulletVT B_Trapano2; static void B_Trapano_Yeet(Bullet *b) { int v2 = b->vt == &B_Trapano2; // B_Trapano2: 450 invece di 150, suono MagicMissile, AngleTween assente float a = Bullet_AngleFromVelocityRadians(b->previousVector); b->s.angle = a * (180 / PI); sprite_setVelocity(&b->s, 0, 0); float d = (v2 ? 0x1c2 : 0x96) * Weapon_PArea(b->weapon), delay = 0x32 * b->indexInWeapon; time_addEvent(delay, 0, 0, v2 ? B_Trapano2_yeetStart : B_Trapano_yeetStart, b); tweens_add((TweenConfig){ .props = { { &b->s.x, NULL, b->s.x + d * cosf(a) }, { &b->s.y, NULL, b->s.y + d * sinf(a) } }, .nprops = 2, .duration = 0x96, .delay = delay, .ease = Ease_SineInOut, .onComplete = v2 ? B_Trapano2_FadeOut : B_Trapano_FadeOut, .ctx = b }); } static void B_Trapano_Update(Bullet *b, float delta) { b->s.depth = b->GroundFx.depth = -game_height; b->spikeSprite.depth = b->s.y - Core.Player->s.y - 1; b->spikeSprite.x = b->s.x, b->spikeSprite.y = b->s.y; if (b->isYeeted) { b->trail.depth = b->s.y - Core.Player->s.y + 0.5f * game_height; int n = (int)ceilf(delta / 0x10); for (int i = 0; i < n; i++) { // trailUpdate (attivo): positions.unshift, al massimo 50 memmove(&b->positions[1], &b->positions[0], 49 * sizeof(Vector2)); b->positions[0] = (Vector2){ b->s.x, b->s.y }; if (b->npos < 50) b->npos++; } return; } b->durata += delta; Vector2 pv = Core.Player->s.body.velocity; if (pv.x == 0 && pv.y == 0) { if (b->previousVector.x == 0 && b->previousVector.y == 0) return; B_Trapano_Yeet(b); b->isYeeted = 1; } else { b->previousVector = pv; float sp = Weapon_PSpeed(b->weapon); if (sp > 1) { b->aimVec.x = b->aimVec.x - 0.002f * (pv.x - b->aimVec.x), b->aimVec.y = b->aimVec.y - 0.002f * (pv.y - b->aimVec.y); sprite_setVelocity(&b->s, b->aimVec.x * sp, b->aimVec.y * sp); } } } static void B_Trapano_DeSpawn(Bullet *b) { time_removeEvent(b->ExpireTimer), time_removeEvent(b->HitboxTimer); tween_stop(b->tween1); // SpeedTween, tween2: mai creati b->spikeSprite.visible = 0; b->s.scaleX = b->s.scaleY = 0; b->GroundFx.visible = 0; b->s.visible = 0; b->s.body.enable = 0; base_DeSpawn(b); } static const BulletVT B_Trapano = { "vfx", "circle8.png", B_Trapano_ctor, NULL, B_Trapano_OnRecycle, NULL, B_Trapano_Update, B_Trapano_DeSpawn }; static void W_Trapano_MakeLevelOne(Weapon *w) { base_MakeLevelOne(w); w->pool->isUncapped = 1; } // Init: pool.isUncapped static void W_Trapano_Update(Weapon *w, float delta) { base_Update(w, delta); w->totalTime += delta; w->totalTime += Core.Player->frameWalk * (delta / (1000.0f / 60)); if (w->totalTime >= Weapon_PInterval(w)) { w->totalTime = 0; Weapon_Fire(w); } } static void W_Trapano_onBulletOverlapsEnemy(Weapon *w, Bullet *b, Enemy *e) { if (e->isDead || Bullet_HasAlreadyHitObject(b, e, e->isDead)) return; float p = Weapon_PPower(w) + (b->isYeeted ? b->durata / 1000 * Weapon_PPower(w) : 0); Enemy_GetDamaged(e, p, (int)w->hitVFX, w->knockback, w->bulletType); w->stats_inflictedDamage += p; } // pfxEmitter della Weapon: creato e mai emesso, non tradotto static const WeaponVT W_Trapano = { BASE, .CheckArcanas = CA_twilight, .bullet = &B_Trapano, .MakeLevelOne = W_Trapano_MakeLevelOne, .Update = W_Trapano_Update, .ResetFiringTimer = noop_ResetFiringTimer, .onBulletOverlapsEnemy = W_Trapano_onBulletOverlapsEnemy }; // --- Valkyrie Turner: W_Trapano2 (0x3539), B_Trapano2 (0x14f4) ------------------------------------------------ // Shadow Pinion evoluto: fiamme colorate al posto delle trivelle, scatto piu' lungo, scia additiva del colore della fiamma. static void Trapano2_trailDraw(Sprite *s) { // due passate, lineStyle(4 * PArea, color, 0.25) e (meta', bianco, 0.25), ADD Bullet *b = s->owner; if (b->npos < 2 || s->alpha <= 0) return; float w = ceilf(4 * Weapon_PArea(b->weapon)), ox = s->x - camera_scrollX, oy = s->y - camera_scrollY; BeginBlendMode(BLEND_ADDITIVE); for (int i = 1; i < b->npos; i++) DrawLineEx((Vector2){ ox + b->positions[i - 1].x, oy + b->positions[i - 1].y }, (Vector2){ ox + b->positions[i].x, oy + b->positions[i].y }, w, hexc(b->color, 0.25f * s->alpha)); for (int i = 1; i < 0x32 && i < b->npos; i++) DrawLineEx((Vector2){ ox + b->positions[i - 1].x, oy + b->positions[i - 1].y }, (Vector2){ ox + b->positions[i].x, oy + b->positions[i].y }, 0.5f * w, hexc(0xffffff, 0.25f * s->alpha)); EndBlendMode(); } static void B_Trapano2_ctor(Bullet *b) { static Animation idle; static const unsigned colors[4] = { 0xff0000, 0xffff00, 0xff, 0xff00ff }; b->radius = 8; sprite_init(&b->trail, NULL, 0, 0); b->trail.owner = b; b->trail.draw = Trapano2_trailDraw; children_add(&b->trail); b->color = colors[b->indexInWeapon % 4]; sprite_init(&b->GroundFx, NULL, 0, 0); b->GroundFx.owner = b; b->GroundFx.draw = Trapano_groundDraw; b->GroundFx.tint = b->color, b->GroundFx.alpha = 0.5f, b->GroundFx.visible = 1; children_add(&b->GroundFx); b->s.visible = 0; sprite_init(&b->spikeSprite, frame_get("vfx", "flame000.png"), b->s.x, b->s.x); // (sic) x, x sprite_setScale(&b->spikeSprite, 0); sprite_setOrigin(&b->spikeSprite, 0.5f, 0.5f); children_add(&b->spikeSprite); if (!idle.n) make_anim(&idle, "vfx", "flame", 0, 0x1c, 3, 0x10, -1); anims_play(&b->spikeSprite, &idle, 0); b->tween1 = TWEEN_NONE; b->HitboxTimer = b->ExpireTimer = (Timer){ -1, 0 }; } static void B_Trapano2_FadeOut(void *ctx) { // senza la guardia isFading di B_Trapano Bullet *b = ctx; tweens_add((TweenConfig){ .props = { { &b->spikeSprite.alpha, NULL, 0 }, { &b->s.alpha, NULL, 0 }, { &b->GroundFx.alpha, NULL, 0 } }, .nprops = 3, .duration = 0xc8, .onComplete = B_Trapano_despawn, .ctx = b }); tweens_add((TweenConfig){ .props = { { &b->trail.alpha, NULL, 0 } }, .nprops = 1, .duration = 0xc8 }); } static void B_Trapano2_OnRecycle(Bullet *b) { Weapon *w = b->weapon; float a = Weapon_PArea(w); Bullet_OnRecycle(b); b->isCullable = 0; b->npos = 0; // trail.clear() b->trail.alpha = 1; b->trail.x = b->s.x - Core.Player->s.x, b->trail.y = b->s.y - Core.Player->s.y; sprite_setScale(&b->s, 1); body_setCircle(&b->s.body, 8, -4, -4); b->s.body.enable = 1; b->n_hit = 0; b->isYeeted = 0; b->spikeSprite.visible = 1, b->GroundFx.visible = 1, b->s.visible = 0; b->s.alpha = 1, b->spikeSprite.alpha = 1, b->GroundFx.alpha = 0.5f; b->save_vel_x = b->save_vel_y = 1; b->aimVec = (Vector2){ 0, 0 }; Vector2 pv = Core.Player->s.body.velocity; float l = sqrtf(pv.x * pv.x + pv.y * pv.y); b->previousVector = l > 0 ? (Vector2){ pv.x / l, pv.y / l } : pv; sprite_setVelocity(&b->s, 0, 0); b->spikeSprite.x = b->s.x, b->spikeSprite.y = b->s.y + 8; b->spikeSprite.angle = 0; b->GroundFx.x = b->s.x, b->GroundFx.y = b->s.y; b->s.scaleX = b->s.scaleY = b->GroundFx.scaleX = b->GroundFx.scaleY = 0; tween_stop(b->tween1); b->spikeSprite.scaleX = b->spikeSprite.scaleY = 0; // tween1 onStart b->tween1 = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, a }, { &b->spikeSprite.scaleX, &b->spikeSprite.scaleY, a } }, .nprops = 2, .duration = 0x12c }); tweens_add((TweenConfig){ .props = { { &b->GroundFx.scaleX, &b->GroundFx.scaleY, 1.1f * a } }, .nprops = 1, .duration = 0x12c, .yoyo = 1 }); time_removeEvent(b->HitboxTimer); b->HitboxTimer = time_addEvent(w->hitBoxDelay, 1, 0, B_Trapano_resetHits, b); b->durata = 0; time_removeEvent(b->ExpireTimer); b->ExpireTimer = time_addEvent(Weapon_PDuration(w), 1, 0, B_Trapano2_FadeOut, b); } static void B_Trapano2_yeetStart(void *ctx) { Sound_PlaySound("MagicMissile", 0.15f, 1, -0x64 * ((Bullet *)ctx)->indexInWeapon, 0xc8, 0xc); } static void B_Trapano2_Update(Bullet *b, float delta) { B_Trapano_Update(b, delta); b->GroundFx.x = b->s.x, b->GroundFx.y = b->s.y; } static const BulletVT B_Trapano2 = { "vfx", "circle8.png", B_Trapano2_ctor, NULL, B_Trapano2_OnRecycle, NULL, B_Trapano2_Update, B_Trapano_DeSpawn }; // Init, Update e danno come W_Trapano; esplosioni (FireExplosion, onSecondaryBulletOverlapsEnemy) solo con l'arcana T19_FIRE static const WeaponVT W_Trapano2 = { BASE, .CheckArcanas = CA_trapano2, .bullet = &B_Trapano2, .MakeLevelOne = W_Trapano_MakeLevelOne, .Update = W_Trapano_Update, .ResetFiringTimer = noop_ResetFiringTimer, .onBulletOverlapsEnemy = W_Trapano_onBulletOverlapsEnemy }; static const WeaponVT W_Corridor_vt; // --- Clock Lancet / Infinite Corridor: W_Lancet (0x16b3a), W_Corridor (0x7819), B_Lancet (0x10da9), B_SpaceTime (0x6caa) --- // Sei colpi istantanei in fila lungo una delle 12 ore dell'orologio, che avanza di uno scatto a ogni sparo; congelano i nemici. static void B_Lancet_despawn(void *ctx) { Bullet_DeSpawn(ctx); } // 'Lancet Expire' static void B_Lancet_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); body_setCircle(&b->s.body, 0x10, b->s.body.offset.x, b->s.body.offset.y); sprite_setScale(&b->s, 2 * PixelScale); b->s.visible = 0; time_removeEvent(b->ExpireTimer); b->ExpireTimer = time_addEvent(0x14, 0, 0, B_Lancet_despawn, b); } static void B_Lancet_OnHasHitAnObject(Bullet *b, void *o, int isDead) { // solo i nemici hanno Freeze if (isDead || !(((Sprite *)o)->groups & Core.Enemies.bit)) return; Enemy_Freeze(o, Weapon_PDuration(b->weapon), 1); if (Arcanas_has(12)) Arcanas_TriggerCold(((Sprite *)o)->x, ((Sprite *)o)->y); // Out of Time } static const BulletVT B_Lancet = { "vfx", "Rings3.png", NULL, NULL, B_Lancet_OnRecycle, B_Lancet_OnHasHitAnObject, NULL, NULL }; static void W_Lancet_imageStart(void *ctx) { ((Weapon *)ctx)->image.alpha = 1; } static void W_Lancet_ctor(Weapon *w) { static Animation pierce; w->ticks = 8; for (int i = 0; i < 0xc; i++) { float a = i / 12.0f * (2 * PI); w->lancetTargets[i] = (Vector2){ cosf(a), sinf(a) }; w->lancetAngles[i] = a; } sprite_init(&w->image, frame_get("vfx", "Pierce1.png"), Core.Player->s.x, Core.Player->s.y); sprite_setOrigin(&w->image, 0, 0.5f); w->image.visible = 0; sprite_setTint(&w->image, 0xcceeff); w->image.scaleX = 2, w->image.scaleY = 1; children_add(&w->image); w->imageTween = tweens_add((TweenConfig){ .props = { { &w->image.alpha, NULL, 0 } }, .nprops = 1, .delay = 0xc8, .duration = 0x1f4, .onStart = W_Lancet_imageStart, .ctx = w, .persist = 1 }); if (!pierce.n) make_anim(&pierce, "vfx", "Pierce", 1, 5, 0, 0x1e, 0); w->pierceAnim = &pierce; } static float six_PAmount(Weapon *w) { (void)w; return 6; } static void W_Lancet_Fire(Weapon *w) { if (++w->ticks >= 0xc) w->ticks = 0; if (w->vt == &W_Corridor_vt && w->ticks == 9) // FireCorridor BulletPool_SpawnAt(w->corridorPool, Core.Player->s.x, Core.Player->s.y, w, 0); Vector2 t = w->lancetTargets[w->ticks]; tween_restart(w->imageTween); w->image.x = Core.Player->s.x, w->image.y = Core.Player->s.y; w->image.angle = w->lancetAngles[w->ticks] * (180 / PI); w->image.visible = 1; w->image.depth = Core.Player->s.depth + game_height; anims_play(&w->image, w->pierceAnim, 0); for (int i = 0; i < Weapon_PAmount(w); i++) { // FireOneLancet: FireOneBullet + SetTarget + setAngle Bullet *b = BulletPool_SpawnAt(w->pool, Core.Player->s.x, Core.Player->s.y, w, i); if (!b) continue; b->s.x += 0x32 * t.x * (1 + b->indexInWeapon), b->s.y += 0x32 * t.y * (1 + b->indexInWeapon); b->s.angle = w->lancetAngles[w->ticks] * (180 / PI); } if (w->lastFiringInterval != Weapon_PInterval(w)) { w->lastFiringInterval = Weapon_PInterval(w); Weapon_ResetFiringTimer(w); } if (Arcanas.hasAstronomia) Arcanas_TriggerAstronomia(w); } // B_SpaceTime: il corridoio che si apre attorno al giocatore e dimezza gli HP static void B_SpaceTime_ctor(Bullet *b) { sprite_setScale(&b->s, 1); sprite_init(&b->corridorLight, frame_get("vfx", "corridor_light.png"), 0, 0); children_add(&b->corridorLight); } static void B_SpaceTime_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void B_SpaceTime_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); sprite_setScale(&b->s, 1); body_setCircle(&b->s.body, 0x40, b->s.body.offset.x, b->s.body.offset.y); float a = 1, la = 0.75f; // FlashingVFXEnabled sprite_setScale(&b->s, 0); b->s.alpha = 0; sprite_setScale(&b->corridorLight, 0); b->corridorLight.alpha = la; tween_stop(b->scaleTween); float sc = game_width / 128.0f; b->scaleTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, sc }, { &b->s.alpha, NULL, a } }, .nprops = 2, .duration = 0x3e8, .yoyo = 1, .ease = Ease_SineInOut, .onComplete = B_SpaceTime_despawn, .ctx = b }); Sound_PlaySound("Corridor", 0.9f, 1, 0x1f4, 0x190, 1); tween_stop(b->AngleTween); b->AngleTween = tweens_add((TweenConfig){ .props = { { &b->s.angle, NULL, -0x5a0 } }, .nprops = 1, .duration = 0x7d0 }); // dal secondo in poi parte gia' da -1440 tween_stop(b->lightTween); b->lightTween = tweens_add((TweenConfig){ .props = { { &b->corridorLight.scaleX, &b->corridorLight.scaleY, sc }, { &b->corridorLight.alpha, NULL, a } }, .nprops = 2, .duration = 0x3e8, .yoyo = 1, .ease = Ease_SineInOut }); } static void B_SpaceTime_Update(Bullet *b, float delta) { (void)delta; b->s.x = Core.Player->s.x, b->s.y = Core.Player->s.y; b->s.depth = -game_height; b->corridorLight.x = b->s.x, b->corridorLight.y = b->s.y; b->corridorLight.depth = b->s.depth + 1; } static const BulletVT B_SpaceTime = { "vfx", "corridor_bg.png", B_SpaceTime_ctor, NULL, B_SpaceTime_OnRecycle, NULL, B_SpaceTime_Update, NULL }; static void W_Corridor_onCorridorOverlapsEnemy(void *ctx, Sprite *bs, Sprite *es) { Weapon *w = ctx; Bullet *b = bs->owner; Enemy *e = es->owner; if (e->isDead || e->res_Corridor || Bullet_HasAlreadyHitObject(b, e, e->isDead)) return; float d = 0.5f * e->hp; Enemy_GetDamaged(e, d, (int)w->hitVFX, w->knockback, w->bulletType); w->stats_inflictedDamage += d; } static void W_Corridor_OnStart(Weapon *w) { base_OnStart(w); w->corridorPool = BulletPool_new(w, &B_SpaceTime); physics_addOverlap(&w->corridorPool->group, &Core.Enemies, W_Corridor_onCorridorOverlapsEnemy, w); } static const WeaponVT W_Lancet = { BASE, .bullet = &B_Lancet, .ctor = W_Lancet_ctor, .PAmount = six_PAmount, .Fire = W_Lancet_Fire }; static const WeaponVT W_Corridor_vt = { BASE, .bullet = &B_Lancet, .ctor = W_Lancet_ctor, .PAmount = six_PAmount, .Fire = W_Lancet_Fire, .OnStart = W_Corridor_OnStart }; // --- Vento Sacro: W_Vento (0x11f65), B_Vento (0xe4d) ------------------------------------------------------------ // Colpi di petali davanti al giocatore, piu' frequenti camminando; pBonus (camminata continua) regola solo le particelle. static Animation VentoStrike; static const WeaponVT W_Vento2; static float B_Vento_TrueSpeed(Bullet *b) { float s = Weapon_PSpeed(b->weapon); return s <= 1 ? 0 : (s - 1) * ProjectileSpeed * b->_speed; } static void B_Vento_ctor(Bullet *b) { if (!VentoStrike.n) make_anim(&VentoStrike, "vfx", "petal", 1, 5, 0, 0x3c, 0); sprite_setOrigin(&b->s, 0, 0.5f); } static void B_Vento_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void B_Vento_OnRecycle(Bullet *b) { static const unsigned color[3] = { 0xccffff, 0xfffff, 0x44ccff }; // (sic) 0xfffff static const float off[13] = { 0, 5, -5, 1.5f, -2.5f, 0xa, -0xa, 7.5f, -7.5f, 0xf, -0xf, 12.5f, -12.5f }; Weapon *w = b->weapon; int i = b->indexInWeapon; Bullet_OnRecycle(b); b->s.alpha = 0.5f; anims_play(&b->s, &VentoStrike, 0); b->s.tint = color[i % 3]; if (b->hasTween) tween_stop(b->tween); sprite_setScale(&b->s, 0); b->tween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, Weapon_PArea(w) } }, .nprops = 1, .duration = 0xc8, .yoyo = 1 }); b->hasTween = 1; if (b->hasTween2) tween_stop(b->tween2); b->tween2 = tweens_add((TweenConfig){ .props = { { &b->s.alpha, NULL, 0 } }, .nprops = 1, .duration = Weapon_PDuration(w), .delay = 0x64, .onComplete = B_Vento_despawn, .ctx = b }); b->hasTween2 = 1; int flip = Core.Player->s.flipX; b->s.flipX = flip; float ox = -8 * (flip ? 1 : -1); b->s.originX = flip ? 1 : 0; b->s.flipY = i % 2 == (flip ? 0 : 1); float oy = -0x10 - off[i % 13]; b->s.angle = off[i % 6]; b->_speed = 1; b->s.body.velocity.x = (flip ? -1 : 1) * B_Vento_TrueSpeed(b) + Core.Player->s.body.velocity.x; b->s.x = Core.Player->s.x + ox, b->s.y = Core.Player->s.y + oy; Sound_PlaySound("Whip", b->weapon->vt == &W_Vento2 ? 1 : 1.7f, 2, 0x64 * i, 0, 0); // B_Vento2: volume 1 } static void B_Vento_Init(Bullet *b, float x, float y) { Bullet_Init(b, x, y); // super.Init chiama gia' OnRecycle sprite_setScale(&b->s, 0); b->previousArea = Weapon_PArea(b->weapon); b->tween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, PixelScale * Weapon_PArea(b->weapon) } }, .nprops = 1, .duration = 0x64 }); b->hasTween = 1; } static void B_Vento_Update(Bullet *b, float delta) { (void)b, (void)delta; } // vuoto: niente scia, niente Update della base static const BulletVT B_Vento = { "vfx", "petal5.png", B_Vento_ctor, B_Vento_Init, B_Vento_OnRecycle, NULL, B_Vento_Update, NULL }; static void W_Vento_ctor(Weapon *w) { w->mul = 1000.0f / 6; w->ventoPfx = particles_add(); particles_createEmitter(w->ventoPfx, (EmitterConfig){ .frames = { frame_get("vfx", "PfxHoly1.png"), frame_get("vfx", "PfxHoly2.png") }, .nframes = 2, .angle = ERND(0, 0xb4), .speed = ERND(0x19, 0x32), .quantity = 1, .lifespan = ERND(0x32, 0x64), .alpha = ERANGE(1, 0), .blendAdd = 1, .gravityY = -0x1f4, .on = 0 }); w->ventoPfx->s.depth = -1; w->walkedTimer = (Timer){ -1, 0 }; } static void W_Vento_walkedCheck(void *ctx) { Weapon *w = ctx; if (Core.Player->walked <= 0) w->walkedW = 0, w->hasWalkedTimer = 0, w->pBonus = 0; // altrimenti il riferimento resta (sic) } static void W_Vento_Update(Weapon *w, float delta) { base_Update(w, delta); if (Core.Player->walked <= 0) { if (!w->hasWalkedTimer) w->walkedTimer = time_addEvent(0x1f4, 0, 0, W_Vento_walkedCheck, w), w->hasWalkedTimer = 1; } else { time_removeEvent(w->walkedTimer); w->hasWalkedTimer = 0; w->walkedW += Core.Player->frameWalk; w->pBonus = fminf(0.5f * w->level, w->walkedW / 0x30d40); w->ventoPfx->emitters[0]->c.lifespan = EOP(0x64 + 0x28 * w->pBonus); // setLifespan for (int i = 0; i < w->pBonus; i++) manager_emitParticleAt(w->ventoPfx, Core.Player->s.x, Core.Player->s.y - 0x18); } w->totalTime += delta; w->totalTime += Core.Player->frameWalk * (delta / w->mul); if (w->totalTime >= Weapon_PInterval(w)) { w->totalTime = 0; Weapon_Fire(w); } } // canCrit (StandardCritical): solo con l'arcana Slash static const WeaponVT W_Vento = { BASE, .PPower = blood2_PPower, .CheckArcanas = CA_slash, .onBulletOverlapsEnemy = W_canCrit_onBulletOverlapsEnemy, .bullet = &B_Vento, .ctor = W_Vento_ctor, .Update = W_Vento_Update, .ResetFiringTimer = noop_ResetFiringTimer }; // --- Fuwalafuwaloo: W_Vento2 (0x7051), B_Vento2 (0x5eb8), B_Vento2extra (0xfb3d), B_Vento2explo (0x132ca) -------------- // Vento Sacro + Vampirica: tagli scuri con due fantasmi, un petalo in piu' a raggiera per colpo; i critici curano ed esplodono. static void Vento2_ghosts(Bullet *b, float ox) { // ghost1/ghost2: rosso e viola additivo, origine e verso del colpo b->ghost.originX = b->ghost2.originX = ox, b->ghost.originY = b->ghost2.originY = 0.5f; b->ghost.angle = b->ghost2.angle = b->s.angle; b->ghost.flipX = b->ghost2.flipX = b->s.flipX, b->ghost.flipY = b->ghost2.flipY = b->s.flipY; } static void Vento2_ghostsInit(Bullet *b, float ox) { sprite_init(&b->ghost, frame_get("vfx", "petal5.png"), b->s.x, b->s.y); sprite_init(&b->ghost2, frame_get("vfx", "petal5.png"), b->s.x, b->s.y); sprite_setOrigin(&b->ghost, ox, 0.5f), sprite_setOrigin(&b->ghost2, ox, 0.5f); b->ghost.tint = 0xff0000, b->ghost2.tint = 0x660066, b->ghost2.blendAdd = 1; // le loro anims 'strike' non partono mai children_add(&b->ghost), children_add(&b->ghost2); b->s.tint = 0x110011; } static void Vento2_ghostsUpdate(Bullet *b) { b->ghost.scaleX = b->ghost2.scaleX = b->s.scaleX, b->ghost.scaleY = b->ghost2.scaleY = b->s.scaleY; b->ghost.x = b->s.x + 4, b->ghost2.x = b->s.x - 4, b->ghost.y = b->s.y + 2, b->ghost2.y = b->s.y - 2; b->ghost.alpha = b->ghost2.alpha = b->s.alpha; } static void B_Vento2_ctor(Bullet *b) { B_Vento_ctor(b); Vento2_ghostsInit(b, 0); } static void B_Vento2_OnRecycle(Bullet *b) { unsigned tint = b->s.tint; B_Vento_OnRecycle(b); // il tint per indice di B_Vento non c'e': resta 0x110011 b->s.tint = tint; Vento2_ghosts(b, b->s.originX); } static void B_Vento2_Update(Bullet *b, float delta) { (void)delta; Vento2_ghostsUpdate(b); } static const BulletVT B_Vento2 = { "vfx", "petal5.png", B_Vento2_ctor, B_Vento_Init, B_Vento2_OnRecycle, NULL, B_Vento2_Update, NULL }; static Animation Vento2Strike; static void B_Vento2extra_ctor(Bullet *b) { if (!Vento2Strike.n) make_anim(&Vento2Strike, "vfx", "petal", 1, 5, 0, 0x1e, 0); sprite_setOrigin(&b->s, 0.5f, 0.5f); Vento2_ghostsInit(b, 0.5f); b->hasTween = b->hasTween2 = 0; } static void B_Vento2extra_OnRecycle(Bullet *b) { Weapon *w = b->weapon; Bullet_OnRecycle(b); b->s.alpha = 0.75f; anims_play(&b->s, &Vento2Strike, 0); body_setCircle(&b->s.body, 0x18, b->s.body.offset.x, b->s.body.offset.y); if (b->hasTween) tween_stop(b->tween); sprite_setScale(&b->s, 0); b->tween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, 0.7f * Weapon_PArea(w) } }, .nprops = 1, .duration = 0xc8, .yoyo = 1 }); if (b->hasTween2) tween_stop(b->tween2); // (sic) 400 * PDuration ms: a scala 0 dopo 400 ms, il petalo resta nel pool per minuti b->tween2 = tweens_add((TweenConfig){ .props = { { &b->s.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x190 * Weapon_PDuration(w), .delay = 0x64, .onComplete = B_Vento_despawn, .ctx = b }); b->hasTween = b->hasTween2 = 1; b->s.flipY = b->indexInWeapon % 2 == (b->s.flipX ? 0 : 1); float a = 360.0f / Weapon_PAmount(w) * b->indexInWeapon; b->s.body.velocity = velocityFromRotation(a * (PI / 180), B_Vento_TrueSpeed(b)); b->s.angle = a; b->s.x = Core.Player->s.x, b->s.y = Core.Player->s.y; Vento2_ghosts(b, b->s.originX); } static void B_Vento2extra_Update(Bullet *b, float delta) { (void)delta; b->s.depth = b->ghost.depth = b->ghost2.depth = -1; Vento2_ghostsUpdate(b); } static const BulletVT B_Vento2extra = { "vfx", "petal5.png", B_Vento2extra_ctor, NULL, B_Vento2extra_OnRecycle, NULL, B_Vento2extra_Update, NULL }; static int Vento2_detunesIndex; static void B_Vento2explo_ctor(Bullet *b) { Weapon *w = b->weapon; static const unsigned colors[3] = { 0x220022, 0x660066, 0xee0000 }; sprite_setOrigin(&b->s, 0.5f, 0.5f); b->s.blendAdd = 1; b->Pfx = particles_add(); // particles('castoro0'): la foglia animata della RenderTexture EmitterConfig c = { .frameRef = &w->leafSprite.frame, .lifespan = EOP(0x1f4), .angle = { 0, 0x168, 1 }, .angleSteps = 0x1e, .rotate = ERND(0, 0x168), .alpha = ERANGE(1, 0), .speed = ERND(0x15e, 0x1c2), .quantity = 2, .ntints = 3, .scale = EOP(4), .on = 0 }; // 'Expo.easIn' non esiste: Linear for (int i = 0; i < 3; i++) c.tints[i] = colors[i]; b->PfxEmitter1 = particles_createEmitter(b->Pfx, c); c.lifespan = EOP(0x3e8), c.angle = (EmitterOp){ 0x5a, 0x1c2, 1 }, c.speed = ERND(0x96, 0xfa); b->PfxEmitter2 = particles_createEmitter(b->Pfx, c); b->tween = TWEEN_NONE; } static void B_Vento2explo_Init(Bullet *b, float x, float y) { static const unsigned colorss[3] = { 0xff00ff, 0x660066, 0xff0000 }; Bullet_Init(b, x, y); body_setCircle(&b->s.body, 0x1c, 4, 4); b->s.tint = colorss[b->colorCount++ % 3]; } static void B_Vento2explo_onStart(void *ctx) { Bullet *b = ctx; b->s.alpha = 1, b->s.scaleX = b->s.scaleY = 0; emitter_start(b->PfxEmitter1), emitter_start(b->PfxEmitter2); b->s.body.enable = 1; } static void B_Vento2explo_onRepeat(void *ctx) { static const unsigned colorss[3] = { 0xff00ff, 0x660066, 0xff0000 }; Bullet *b = ctx; b->n_hit = 0; b->s.tint = colorss[b->colorCount++ % 3]; if (++b->repeatCount > 1) emitter_stop(b->PfxEmitter1), emitter_stop(b->PfxEmitter2); } static void B_Vento2explo_onComplete(void *ctx) { Bullet *b = ctx; emitter_stop(b->PfxEmitter1), emitter_stop(b->PfxEmitter2); Bullet_DeSpawn(b); b->s.body.enable = 0; } static void B_Vento2explo_OnRecycle(Bullet *b) { static const float detunes[4] = { 0, 0x190, 0x320, 0x4b0 }, mul[4] = { 0.4f, 0.6f, 0.8f, 1 }; Bullet_OnRecycle(b); b->s.depth = -game_height; b->PfxEmitter1->x = b->PfxEmitter2->x = b->s.x, b->PfxEmitter1->y = b->PfxEmitter2->y = b->s.y; b->Pfx->s.depth = b->s.depth + 1; b->repeatCount = 0; int k = Vento2_detunesIndex++ % 4; float m = mul[k]; b->PfxEmitter1->c.speed = ERND(0x15e * m, 0x1c2 * m), b->PfxEmitter2->c.speed = ERND(0x96 * m, 0xfa * m); b->PfxEmitter1->c.scale = b->PfxEmitter2->c.scale = EOP(4 * m); Sound_PlaySound("Rose", 1, 1, detunes[k], 0, 0); b->s.body.enable = 0; tween_stop(b->tween); sprite_setScale(&b->s, 0); b->tween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, m * (game_height / 64.0f) }, { &b->s.alpha, NULL, 0 } }, .nprops = 2, .duration = 0x15e, .repeat = 2, .onStart = B_Vento2explo_onStart, .onRepeat = B_Vento2explo_onRepeat, .onComplete = B_Vento2explo_onComplete, .ctx = b }); } static void B_Vento2explo_Update(Bullet *b, float delta) { (void)b, (void)delta; } static const BulletVT B_Vento2explo = { "vfx", "sPFX_ring_64.png", B_Vento2explo_ctor, B_Vento2explo_Init, B_Vento2explo_OnRecycle, NULL, B_Vento2explo_Update, NULL }; static void W_Vento2_ctor(Weapon *w) { static Animation spin; w->mul = 1000.0f / 6; w->canHeal = 1, w->healDelay = 0x1f4, w->canExplodeV2 = 1, w->explodeDelay = 0x1f4; w->walkedTimer = w->healTimer = w->explodeTimerV2 = (Timer){ -1, 0 }; if (!spin.n) make_anim(&spin, "vfx", "leaf", 0, 0x13, 4, 0x1e, -1); // leaf0000..leaf0019, frameRate [30,20,24,14][0] sprite_init(&w->leafSprite, frame_get("vfx", "leaf0000.png"), -1e9f, -1e9f); sprite_setOrigin(&w->leafSprite, 0, 0); children_add(&w->leafSprite); anims_play(&w->leafSprite, &spin, 0); } static float W_Vento2_PPower(Weapon *w) { return base_PPower(w) + w->pBonus; } // pBonus = walkBonus static void W_Vento2_canHeal(void *ctx) { ((Weapon *)ctx)->canHeal = 1; } static void W_Vento2_canExplode(void *ctx) { ((Weapon *)ctx)->canExplodeV2 = 1; } static float W_Vento2_crit(Weapon *w) { // critico: cura 8 (al massimo ogni healDelay) float crit = frand() < w->critChance * Player_PLuck(Core.Player) ? w->critMul * Arcanas.CritMul : 1; // PLuck if (crit > 1 && w->canHeal) { w->canHeal = 0; Player_RecoverHp(Core.Player, 8, 1, 0); w->healTimer = time_addEvent(w->healDelay, 0, 0, W_Vento2_canHeal, w); } return crit; } static void W_Vento2_onBulletOverlapsEnemy(Weapon *w, Bullet *b, Enemy *e) { if (e->isDead) return; float crit = W_Vento2_crit(w); if (crit > 1 && w->canExplodeV2) { w->canExplodeV2 = 0; w->explodeTimerV2 = time_addEvent(w->explodeDelay, 0, 0, W_Vento2_canExplode, w); BulletPool_SpawnAt(w->secondaryPool, e->s.x, e->s.y, w, 0); } if (Bullet_HasAlreadyHitObject(b, e, e->isDead)) return; Enemy_GetDamaged(e, Weapon_PPower(w) * crit, (int)w->hitVFX, w->knockback, w->bulletType); w->stats_inflictedDamage += Weapon_PPower(w) * crit; } static void W_Vento2_onExplosionOverlapsEnemy(void *ctx, Sprite *bs, Sprite *es) { Weapon *w = ctx; Bullet *b = bs->owner; Enemy *e = es->owner; if (e->isDead) return; float crit = W_Vento2_crit(w); if (Bullet_HasAlreadyHitObject(b, e, e->isDead)) return; Enemy_GetDamaged(e, Weapon_PPower(w) * crit, (int)w->hitVFX, w->knockback, w->bulletType); w->stats_inflictedDamage += Weapon_PPower(w) * crit; } static void W_Vento2_OnStart(Weapon *w) { base_OnStart(w); w->secondaryPool = BulletPool_new(w, &B_Vento2explo); w->extraPool = BulletPool_new(w, &B_Vento2extra); w->canCrit = 1; physics_addOverlap(&w->secondaryPool->group, &Core.Enemies, W_Vento2_onExplosionOverlapsEnemy, w); physics_addOverlap(&w->secondaryPool->group, &Core.Destructibles, Weapon_onBulletOverlapsDestuctible, w); physics_addOverlap(&w->extraPool->group, &Core.Enemies, Weapon_onBulletOverlapsEnemy, w); physics_addOverlap(&w->extraPool->group, &Core.Destructibles, Weapon_onBulletOverlapsDestuctible, w); } static Bullet *W_Vento2_FireOneBullet(Weapon *w, float x, float y, int index) { // target: sempre vuoto per quest'arma Bullet *b = BulletPool_SpawnAt(w->pool, x, y, w, index); BulletPool_SpawnAt(w->extraPool, x, y, w, index); return b; } static void W_Vento2_walkedCheck(void *ctx) { Weapon *w = ctx; if (Core.Player->walked <= 0) w->walkedW = 0, w->hasWalkedTimer = 0, w->pBonus = 0; } static void W_Vento2_Update(Weapon *w, float delta) { base_Update(w, delta); if (Core.Player->walked <= 0) { if (!w->hasWalkedTimer) w->walkedTimer = time_addEvent(0x1f4, 0, 0, W_Vento2_walkedCheck, w), w->hasWalkedTimer = 1; } else { time_removeEvent(w->walkedTimer); w->hasWalkedTimer = 0; w->walkedW += Core.Player->frameWalk; w->pBonus = fminf(4, w->walkedW / 0x30d40); } w->totalTime += delta; w->totalTime += Core.Player->frameWalk * (delta / w->mul); if (w->totalTime >= Weapon_PInterval(w)) { w->totalTime = 0; Weapon_Fire(w); } // _coinRT: la RenderTexture si ridisegna col fotogramma corrente di leafSprite (frameRef) } static const WeaponVT W_Vento2 = { BASE, .CheckArcanas = CA_slash, .bullet = &B_Vento2, .ctor = W_Vento2_ctor, .PPower = W_Vento2_PPower, .OnStart = W_Vento2_OnStart, .Update = W_Vento2_Update, .ResetFiringTimer = noop_ResetFiringTimer, .onBulletOverlapsEnemy = W_Vento2_onBulletOverlapsEnemy, .FireOneBullet = W_Vento2_FireOneBullet }; // --- Bone: W_Bone (0x41b2), B_Bone (0x6cd3) --------------------------------------------------------------------- // Osso che rimbalza sui bordi dello schermo e sui nemici. BONE2 (Anima of Mortaccio): sotto, W_BoneGiant. static void B_Bone_BounceMore(Bullet *b) { if (b->accelOnBounce) b->physBounce = 0.1f; } // setBounce: il rimbalzo sui bordi usa worldBounce (1, 1) static void B_Bone_Bounce(void *ctx) { Bullet *b = ctx; B_Bone_BounceMore(b); b->n_hit = 0; } // 'worldbounds' static void B_Bone_ctor(Bullet *b) { tweens_add((TweenConfig){ .props = { { &b->s.angle, NULL, 0x168 } }, .nprops = 1, .duration = 0x3e8, .repeat = -1 }); // AngleTween: gira per sempre b->BounceTimer = b->ExpireTimer = (Timer){ -1, 0 }; } static void B_Bone_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void B_Bone_OnRecycle(Bullet *b) { Weapon *w = b->weapon; Bullet_OnRecycle(b); body_setCircle(&b->s.body, 8, b->s.body.offset.x, b->s.body.offset.y); b->canBounce = 1; sprite_setScale(&b->s, 0.5f * PixelScale * Weapon_PArea(w)); b->physBounce = 0; if (IsHalloween) sprite_setFrame(&b->s, frame_get("items", "pumpkin.png")); b->isCullable = 0; time_removeEvent(b->ExpireTimer); b->s.body.collideWorldBounds = 1, b->s.body.hasWorldBounce = 1, b->s.body.worldBounce = (Vector2){ 1, 1 }; b->s.body.customBounds = &Core.Player->WorldBoxCollider; b->s.body.onWorldBounds = B_Bone_Bounce, b->s.body.onWorldBoundsCtx = b; Bullet_AimForRandomEnemy(b); b->s.angle = 0x168 * frand(); tween_stop(b->ScaleTween); b->ScaleTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, 0 } }, .nprops = 1, .duration = 0x1f4, .delay = Weapon_PDuration(w), .onComplete = B_Bone_despawn, .ctx = b }); Sound_PlaySound("Shot", 0.45f, 1, -0x64 * b->indexInWeapon, 0xc8, 0xa); } static void B_Bone_canBounce(void *ctx) { ((Bullet *)ctx)->canBounce = 1; } static void B_Bone_OnHasHitAnObject(Bullet *b, void *o, int isDead) { (void)o; if (isDead || !b->canBounce) return; B_Bone_BounceMore(b); b->canBounce = 0; time_removeEvent(b->BounceTimer); b->BounceTimer = time_addEvent(0x1e, 0, 0, B_Bone_canBounce, b); sprite_setVelocity(&b->s, b->s.body.velocity.x * -(1 + b->physBounce), b->s.body.velocity.y * -(1 + b->physBounce)); b->n_hit = 0; } static void B_Bone_OnHasHitWall(Bullet *b, Tile *t) { b->save_vel_x *= t && (t->faceRight || t->faceLeft) ? -1 : 1; b->save_vel_y *= t && (t->faceTop || t->faceBottom) ? -1 : 1; sprite_setVelocity(&b->s, b->save_vel_x, b->save_vel_y); b->n_hit = 0; } static void B_Bone_Update(Bullet *b, float delta) { (void)delta; b->save_vel_x = b->s.body.velocity.x == 0 ? b->save_vel_x : b->s.body.velocity.x; b->save_vel_y = b->s.body.velocity.y == 0 ? b->save_vel_y : b->s.body.velocity.y; } static void B_Bone_DeSpawn(Bullet *b) { b->isCullable = 1; time_removeEvent(b->ExpireTimer); base_DeSpawn(b); if (b->weapon->explodeOnExpire) Weapon_SpawnExplosionAt(b->weapon, b->s.x, b->s.y, 0); // trueWeapon } static const BulletVT B_Bone = { "vfx", "ProjectileBone2.png", B_Bone_ctor, NULL, B_Bone_OnRecycle, B_Bone_OnHasHitAnObject, B_Bone_Update, B_Bone_DeSpawn, NULL, NULL, B_Bone_OnHasHitWall }; // CheckArcanas (beginning, Twilight Requiem): arcane; SecondaryPPower: non usato static const WeaponVT W_Bone = { BASE, .SecondaryPPower = power_noBloodline, .CheckArcanas = CA_inverseBeginning, .bullet = &B_Bone }; // --- Anima of Mortaccio: W_BoneGiant (0x1df7, BONE2) con B_Bone; braccia B_BoneGiant (0x8343, BONE_ARM) ------- // Lo scheletro fantasma di Mortaccio (testa, torso, aureola) segue il giocatore; ogni 6 colpi le due braccia girano e poi si staccano. static void B_BoneArm_OnAttached(Bullet *b) { tween_stop(b->AngleTween); b->display.angle = 0; sprite_setOrigin(&b->display, 11.0f / 60, 13.0f / 60); b->display.x = b->anchor.x, b->display.y = b->anchor.y; b->s.x = b->display.x, b->s.y = b->display.y; b->isSpinning = 0, b->isAttached = 1; tween_stop(b->ScaleTween); sprite_setScale(&b->s, 1); sprite_setVelocity(&b->s, 0, 0); b->s.angle = 0; } static void B_BoneArm_attachDone(void *ctx) { B_BoneArm_OnAttached(ctx); } static void B_BoneArm_Attach(Bullet *b) { Sound_PlaySound("Shot", 0.45f, 0.3f + 0.1f * b->indexInWeapon, 0, 0xc8, 0xa); tween_stop(b->attachTween); b->attachTween = tweens_add((TweenConfig){ .props = { { &b->s.x, NULL, b->anchor.x }, { &b->s.y, NULL, b->anchor.y } }, .nprops = 2, .duration = 0xc8, .onComplete = B_BoneArm_attachDone, .ctx = b }); } static void B_BoneArm_Detach(Bullet *b, float spin) { Sound_PlaySound("Shot", 0.45f, 1, -0x64 * (0xa + b->indexInWeapon), 0xc8, 0xa); tween_stop(b->AngleTween); b->AngleTween = tweens_add((TweenConfig){ .props = { { &b->display.angle, NULL, b->s.angle + spin } }, .nprops = 1, .duration = 0x3e8, .repeat = -1 }); b->isSpinning = 0, b->isAttached = 0; sprite_setOrigin(&b->display, 0.5f, 0.5f); b->n_hit = 0; Bullet_AimForRandomEnemy(b); } static void B_BoneArm_shot(void *ctx) { (void)ctx; Sound_PlaySound("Shot", 0.2f, 0.2f, 0, 0xc8, 0xa); } static void B_BoneArm_Spinnn(Bullet *b, float spin, float duration, int repeat) { b->isSpinning = 1, b->isAttached = 0; B_BoneArm_shot(NULL); tween_stop(b->AngleTween); b->AngleTween = tweens_add((TweenConfig){ .props = { { &b->display.angle, NULL, b->s.angle + spin } }, .nprops = 1, .duration = duration, .repeat = repeat, .onRepeat = B_BoneArm_shot, .ctx = b }); } static void B_BoneArm_ctor(Bullet *b) { static Animation idle; b->s.visible = 0; b->maxHistory = 2; b->BounceTimer = (Timer){ -1, 0 }; b->AngleTween = b->ScaleTween = b->attachTween = (TweenRef){ -1, 0 }; sprite_init(&b->display, frame_get("characters", "Gash_arm_i01.png"), b->s.x, b->s.y); sprite_setOrigin(&b->display, 11.0f / 60, 13.0f / 60); children_add(&b->display); if (!idle.n) make_anim(&idle, "characters", "Gash_arm_i", 1, 5, 2, 0x18, -1); anims_play(&b->display, &idle, 0); for (int i = 0; i < b->maxHistory; i++) { Sprite *g = &b->ghosts[i]; b->posHistory[i] = (Vector2){ b->s.x, b->s.y }; sprite_init(g, b->s.frame, 0, 0), g->visible = 0, g->alpha = 0.65f - 0.25f * i; g->tint = 0xe0e0ff; // semplificazione: setTint a 4 angoli (e0e0ff, ff, e0e0ff, ff): qui il primo children_add(g); } } static void B_BoneArm_Bounce(void *ctx) { ((Bullet *)ctx)->n_hit = 0; } // 'worldbounds' static void B_BoneArm_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void B_BoneArm_scaleStart(void *ctx) { sprite_setScale(&((Bullet *)ctx)->display, 1); } static void B_BoneArm_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); body_setCircle(&b->s.body, 0xe, 0xe, 0xe); b->s.visible = 0; b->canBounce = 1; sprite_setScale(&b->s, 1); // setBounce(1.1): sui bordi vale worldBounce (1, 1), come B_Bone b->isCullable = 0, b->isAttached = b->isSpinning = 0; b->s.body.collideWorldBounds = 1, b->s.body.hasWorldBounce = 1, b->s.body.worldBounce = (Vector2){ 1, 1 }; b->s.body.customBounds = &Core.Player->WorldBoxCollider; b->s.body.onWorldBounds = B_BoneArm_Bounce, b->s.body.onWorldBoundsCtx = b; sprite_setScale(&b->display, 1); Bullet_AimForRandomEnemy(b); tween_stop(b->ScaleTween); b->ScaleTween = tweens_add((TweenConfig){ .props = { { &b->display.scaleX, &b->display.scaleY, 0 } }, .nprops = 1, .duration = 0x64, .delay = Weapon_PDuration(b->weapon), .onStart = B_BoneArm_scaleStart, .onComplete = B_BoneArm_despawn, .ctx = b }); } static void B_BoneArm_OnHasHitAnObject(Bullet *b, void *o, int isDead) { (void)o; if (isDead || !b->canBounce || b->isAttached) return; b->canBounce = 0; time_removeEvent(b->BounceTimer); b->BounceTimer = time_addEvent(0x1e, 0, 0, B_Bone_canBounce, b); sprite_setVelocity(&b->s, -1.1f * b->s.body.velocity.x, -1.1f * b->s.body.velocity.y); b->n_hit = 0; } static void B_BoneArm_UpdateGhosts(Bullet *b, int visible) { b->historyIndex = b->historyIndex < b->maxHistory - 1 ? b->historyIndex + 1 : 0; float sc = 0.5f * (b->display.scaleX + b->display.scaleY); // displaySprite.scale for (int i = 0; i < b->maxHistory; i++) { Vector2 h = b->posHistory[getHistoryIndex(b, i)]; Sprite *g = &b->ghosts[i]; g->angle = b->display.angle, g->x = h.x, g->y = h.y, g->scaleX = g->scaleY = sc, g->visible = visible; } b->posHistory[b->historyIndex] = (Vector2){ b->s.x, b->s.y }; } static void B_BoneArm_AdjustBodyOffset(Bullet *b) { // il corpo sta sulla mano, non sul perno float sc = 0.5f * (b->display.scaleX + b->display.scaleY); float r = (sc > 0 ? b->display.angle : b->display.angle + 0xb4) * DEG2RAD, c = cosf(r), s = sinf(r); if (sc > 0) b->s.x = b->display.x - 0x1c * s + 0x24 * c, b->s.y = b->display.y + 0x1c * c + 0x24 * s; else b->s.x = b->display.x + (0x1c * s + 0x24 * c), b->s.y = b->display.y - (0x1c * c - 0x24 * s); } static void B_BoneArm_Update(Bullet *b, float delta) { (void)delta; if (b->isSpinning || b->isAttached) { b->display.x = b->anchor.x, b->display.y = b->anchor.y; b->s.x = b->display.x, b->s.y = b->display.y; B_BoneArm_AdjustBodyOffset(b); B_BoneArm_UpdateGhosts(b, 0); return; } b->save_vel_x = b->s.body.velocity.x == 0 ? b->save_vel_x : b->s.body.velocity.x; b->save_vel_y = b->s.body.velocity.y == 0 ? b->save_vel_y : b->s.body.velocity.y; b->display.x = b->s.x, b->display.y = b->s.y; // copyPosition B_BoneArm_UpdateGhosts(b, 1); } static void B_BoneArm_DeSpawn(Bullet *b) { b->isCullable = 1; for (int i = 0; i < b->maxHistory; i++) b->ghosts[i].visible = 0; base_DeSpawn(b); } // OnHasHitWall: il pool delle braccia non ha collider coi muri static const BulletVT B_BoneGiant = { "vfx", "Gash_arm_i01.png", B_BoneArm_ctor, NULL, B_BoneArm_OnRecycle, B_BoneArm_OnHasHitAnObject, B_BoneArm_Update, B_BoneArm_DeSpawn }; static Bullet *W_BoneGiant_FireOneBullet(Weapon *w, float x, float y, int index) { Bullet *b = BulletPool_SpawnAt(w->pool, x, y, w, index); if (b) b->accelOnBounce = 1; return b; } static void W_BoneGiant_attachBack(void *ctx) { B_BoneArm_Attach(((Weapon *)ctx)->backArm); } static void W_BoneGiant_AttachArms(void *ctx) { Weapon *w = ctx; w->AreArmsAttached = 1; B_BoneArm_Attach(w->frontArm); time_addEvent(0x64, 0, 0, W_BoneGiant_attachBack, w); // semplificazione: setTimeout va col tempo reale, qui col Clock della scena w->isAttacking = 0; } static void W_BoneGiant_detachBack(void *ctx) { B_BoneArm_Detach(((Weapon *)ctx)->backArm, -0x168); } static void W_BoneGiant_DetachArms(void *ctx) { Weapon *w = ctx; w->AreArmsAttached = 0; B_BoneArm_Detach(w->frontArm, 0x168); time_addEvent(0x64, 0, 0, W_BoneGiant_detachBack, w); // setTimeout, come sopra time_addEvent(fmaxf(0xfa0, floorf(Weapon_PDuration(w))), 0, 0, W_BoneGiant_AttachArms, w); } static void W_BoneGiant_SpinArms(Weapon *w) { w->isAttacking = 1, w->AreArmsAttached = 1; int n = (int)fmaxf(8, floorf(Weapon_PDuration(w) / 0x1f4)); B_BoneArm_Spinnn(w->frontArm, -0x167, 0x1f4, n), B_BoneArm_Spinnn(w->backArm, 0x167, 0x1f4, n); time_addEvent(0x1f4 * n, 0, 0, W_BoneGiant_DetachArms, w); } static void W_BoneGiant_Fire(Weapon *w) { base_Fire(w); if (++w->firedTimes >= 6 && !w->isAttacking) w->firedTimes = 0, W_BoneGiant_SpinArms(w); // secondaryFireCounter } static void W_BoneGiant_onGiantArmOverlapsEnemy(void *ctx, Sprite *bs, Sprite *es) { Weapon *w = ctx; Enemy *e = es->owner; if (e->isDead || Bullet_HasAlreadyHitObject(bs->owner, e, e->isDead)) return; float p = Weapon_PPower(w) * (0.5f * Weapon_PAmount(w)); Enemy_GetDamaged(e, p, (int)w->hitVFX, w->knockback, w->bulletType); w->stats_inflictedDamage += p; } static void W_BoneGiant_InitSkeleton(Weapon *w) { static Animation idle; w->topDepth = game_height; w->frontArm = BulletPool_SpawnAt(w->armPool, 0, 0, w, 0), B_BoneArm_Attach(w->frontArm); w->backArm = BulletPool_SpawnAt(w->armPool, 0, 0, w, 1), B_BoneArm_Attach(w->backArm); sprite_init(&w->head, frame_get("characters", "Gash_head_i01.png"), 0, 0), children_add(&w->head); if (!idle.n) make_anim(&idle, "characters", "Gash_head_i", 1, 5, 2, 0x18, -1); anims_play(&w->head, &idle, 0); sprite_init(&w->torso, frame_get("characters", "Gash_body_i01.png"), 0, 0), children_add(&w->torso); sprite_init(&w->halo, frame_get("characters", "Halo.png"), 0, 0), w->halo.depth = -1, sprite_setOrigin(&w->halo, 0.5f, 1), children_add(&w->halo); w->head.tint = w->torso.tint = 0xe0e0ff; // semplificazione: setTint a 4 angoli (e0e0ff, ff, e0e0ff, ff): qui il primo w->head.alpha = 0.65f, w->head.depth = -1, sprite_setOrigin(&w->head, 0, 0); w->torso.alpha = 0.65f, w->torso.depth = -2, sprite_setOrigin(&w->torso, 0.5f, 1); physics_addOverlap(&w->armPool->group, &Core.Enemies, W_BoneGiant_onGiantArmOverlapsEnemy, w); physics_addOverlap(&w->armPool->group, &Core.Destructibles, Weapon_onBulletOverlapsDestuctible, w); } static void W_BoneGiant_UpdateSkeleton(Weapon *w) { Sprite *P = &Core.Player->s; w->torso.x = P->x, w->torso.y = P->y, w->torso.flipX = P->flipX; // copyPosition float x0 = w->torso.x - 0x1f, y0 = w->torso.y - 0x31; int fx = w->torso.flipX; w->head.flipX = fx; w->head.x = x0 + (fx ? -0x1a : 0x34), w->head.y = y0 - 0x15; w->halo.x = w->head.x + (fx ? 0x1e : 0xc), w->halo.y = w->head.y - 1; Bullet *f = w->frontArm, *k = w->backArm; if (w->AreArmsAttached) { f->display.scaleX = k->display.scaleX = fx ? -1 : 1, f->display.scaleY = k->display.scaleY = 1; f->display.depth = 1, k->display.depth = -3; } else f->display.depth = k->display.depth = w->topDepth; f->anchor = (Vector2){ x0 + (fx ? 0x15 : 0x2c), y0 + 0xa }; k->anchor = (Vector2){ x0 + (fx ? 0x4 : 0x3d), y0 + 0x16 }; } static void W_BoneGiant_Update(Weapon *w, float delta) { base_Update(w, delta); if (!w->hasSkeleton) W_BoneGiant_InitSkeleton(w), w->hasSkeleton = 1; W_BoneGiant_UpdateSkeleton(w); } static void W_BoneGiant_ctor(Weapon *w) { w->AreArmsAttached = 1, w->armPool = BulletPool_new(w, &B_BoneGiant); } static const WeaponVT W_BoneGiant = { BASE, .SecondaryPPower = power_noBloodline, .CheckArcanas = CA_inverseBeginning, .bullet = &B_Bone, .ctor = W_BoneGiant_ctor, .Fire = W_BoneGiant_Fire, .Update = W_BoneGiant_Update, .FireOneBullet = W_BoneGiant_FireOneBullet }; // --- Cherry Bomb: W_Cherry (0x3e35), B_Cherry (0xe3ce) ----------------------------------------------------------- // Bomba che rimbalza sui nemici, rallenta e poi esplode con probabilita' chance * Luck (fuochi d'artificio), altrimenti sparisce. // CHERRY2 (Yatta Daikarin, 0xf01f): arma speciale del personaggio, con i personaggi; isStars (SetToStars): idem. static void B_Cherry_ctor(Bullet *b) { static const unsigned TINTS[4] = { 0xff8888, 0xff88ff, 0xff88ff, 0xffff88 }; static const char *const blur[3] = { "_blur.png", "_blur2.png", "_blur3.png" }; Weapon *w = b->weapon; b->bombDeceleration = 1; b->canBounce = 1; sprite_init(&b->ring, frame_get("vfx", "sPFX_ring_64.png"), 0, 0), b->ring.visible = 0, children_add(&b->ring); sprite_init(&b->rainbow, frame_get("vfx", "s_pfx_rainbow_64.png"), 0, 0), b->rainbow.visible = 0, children_add(&b->rainbow); sprite_init(&b->rays, frame_get("vfx", "fuzzA.png"), 0, 0), b->rays.visible = 0, children_add(&b->rays); tweens_add((TweenConfig){ .props = { { &b->s.angle, NULL, 0x167 } }, .nprops = 1, .duration = 0x3e8, .repeat = -1 }); // AngleTween b->Pfx = particles_add(); // particles('vfx') b->PfxEmitter = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", blur[b->indexInWeapon % 3]) }, .nframes = 1, .lifespan = EOP(0x320), .rotate = ERND(0, 0x168), .alpha = { 0, 1, 2, Ease_ExpoOut }, .angle = { 0, 0x168, 1 }, .angleSteps = 0x10, .speed = ERND(0x32, 0x64), .quantity = 0x40, .scale = ERANGE(2, 0), .frequency = 0x40, .blendAdd = 1, .on = 0 }); b->Pfx2 = particles_add(); // particles('cherryBomb0'): la RenderTexture con la foglia animata b->PfxEmitter2 = particles_createEmitter(b->Pfx2, (EmitterConfig){ .frameRef = &w->leafSprite.frame, .lifespan = EOP(0x4b0), .rotate = ERND(0, 0x168), .alpha = { 0, 1, 2, Ease_ExpoOut }, .angle = { 0, 0x168, 1 }, .angleSteps = 0x1f, .speed = ERND(0x32, 0x64), .quantity = 0x40, .scale = ERANGE(2, 0.1f), .frequency = 0x40, .tints = { TINTS[0], TINTS[1], TINTS[2], TINTS[3] }, .ntints = 4, .blendAdd = 1, .on = 0 }); b->BounceTimer = b->ExpireTimer = (Timer){ -1, 0 }; b->SpeedTween = b->ScaleTween = TWEEN_NONE; } static void B_Cherry_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void B_Cherry_tween5Done(void *ctx) { Bullet *b = ctx; emitter_stop(b->PfxEmitter), emitter_stop(b->PfxEmitter2); b->s.body.enable = 0; } static void B_Cherry_tween6Start(void *ctx) { Bullet *b = ctx; b->PfxEmitter->x = b->s.x, b->PfxEmitter->y = b->s.y; emitter_start(b->PfxEmitter); } // FlashingVFXEnabled static void B_Cherry_tween6Done(void *ctx) { Bullet *b = ctx; emitter_stop(b->PfxEmitter), emitter_stop(b->PfxEmitter2); Bullet_DeSpawn(b); } static void B_Cherry_TryDetonate(void *ctx) { Bullet *b = ctx; Weapon *w = b->weapon; if (frand() < w->chance * Player_PLuck(Core.Player)) { // PLuck b->s.visible = 1; // FlashingVFXEnabled sprite_setFrame(&b->s, frame_get("items", "blurBlack.png")); b->PfxEmitter2->x = b->s.x, b->PfxEmitter2->y = b->s.y; emitter_start(b->PfxEmitter2); b->ring.visible = 1, sprite_setScale(&b->ring, 0), b->ring.alpha = 1, b->ring.angle = 0, b->ring.x = b->s.x, b->ring.y = b->s.y; b->rainbow.visible = 1, sprite_setScale(&b->rainbow, 0), b->rainbow.alpha = 0.75f, b->rainbow.angle = 0, b->rainbow.x = b->s.x, b->rainbow.y = b->s.y, b->rainbow.blendAdd = 1; b->rays.visible = 1, sprite_setScale(&b->rays, 0), b->rays.alpha = 1, b->rays.angle = 0, b->rays.x = b->s.x, b->rays.y = b->s.y; float k = fmaxf(3, w->level) / 8; tweens_add((TweenConfig){ .props = { { &b->ring.scaleX, &b->ring.scaleY, 4 * k }, { &b->ring.angle, NULL, 0x168 } }, .nprops = 2, .duration = 0x64 }); tweens_add((TweenConfig){ .props = { { &b->ring.alpha, NULL, 0 }, { &b->rays.alpha, NULL, 0 } }, .nprops = 2, .delay = 0x64, .duration = 0x64 }); tweens_add((TweenConfig){ .props = { { &b->rays.scaleX, &b->rays.scaleY, 3 * k } }, .nprops = 1, .duration = 0x64 }); tweens_add((TweenConfig){ .props = { { &b->rainbow.scaleX, &b->rainbow.scaleY, 5 * k }, { &b->rainbow.alpha, NULL, 0 }, { &b->rainbow.angle, NULL, 0x168 } }, .nprops = 3, .duration = 0x1f4 }); Sound_PlaySound("Explosion2", 0.5f, 1, 0x64 * b->indexInWeapon - 0x1f4, 0x96, 3); Sound_PlaySound("Whistle", 0.1f, 1.5f, 0x64 * b->indexInWeapon, 0x96, 3); tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, 8 * Weapon_PArea(w) }, { &b->s.alpha, NULL, 0.1f } }, .nprops = 2, .duration = 0x78, .onComplete = B_Cherry_tween5Done, .ctx = b }); tweens_add((TweenConfig){ .props = { { &b->s.alpha, NULL, 0.1f } }, .nprops = 1, .duration = 0x64, .delay = 0xc8, .onStart = B_Cherry_tween6Start, .onComplete = B_Cherry_tween6Done, .ctx = b }); } else { tween_stop(b->ScaleTween); b->ScaleTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, 0 } }, .nprops = 1, .duration = 0x12c, .onComplete = B_Cherry_despawn, .ctx = b }); } } static void B_Cherry_OnRecycle(Bullet *b) { Weapon *w = b->weapon; float a = Weapon_PArea(w); Bullet_OnRecycle(b); body_setCircle(&b->s.body, 8, b->s.body.offset.x, b->s.body.offset.y); b->s.body.enable = 1; b->canBounce = 1; b->s.visible = 1; sprite_setFrame(&b->s, frame_get("items", IsHalloween ? "pumpkin.png" : "Cherry.png")); b->s.alpha = 1; sprite_setScale(&b->s, PixelScale * a * 0.5f); // setBounce(1, 1): senza collideWorldBounds ne' collider, nessun effetto b->PfxEmitter->c.quantity = 8 + 4 * (int)floorf(w->level / 3.0f); b->PfxEmitter->c.speed = ERND(0x32 * a, 0x64 * a); b->PfxEmitter2->c.quantity = 8 + 8 * (int)floorf(w->level / 3.0f); b->PfxEmitter2->c.speed = ERND(5 * a, 0xa * a); b->PfxEmitter2->c.hasZone = 1, b->PfxEmitter2->c.zoneRadius = 8 * a * 8; if (w->isStars) { // TrueWeapon.isStars: fuochi a stelle colorate, stelle al posto delle foglie static const char *const C3[3] = { "Blue", "Purple", "Red" }; static const unsigned T2[4] = { 0x4444ff, 0xff44ff, 0xff44ff, 0xff4444 }; char f1[32], f2[32]; snprintf(f1, sizeof(f1), "2Spell3%s.png", C3[b->indexInWeapon % 3]), snprintf(f2, sizeof(f2), "2Spell4%s.png", C3[b->indexInWeapon % 3]); b->PfxEmitter->c.frames[0] = frame_get("vfx", f1), b->PfxEmitter->c.frames[1] = frame_get("vfx", f2), b->PfxEmitter->c.nframes = 2; b->PfxEmitter->c.scale = ERANGE(3, 0); for (int i = 0; i < 4; i++) b->PfxEmitter2->c.tints[i] = T2[i]; b->PfxEmitter2->c.scale = ERANGE(1, 0.05f); // la stella e' disegnata a scala 0.5 nella RenderTexture 16x16: qui il fotogramma intero a meta' scala } b->isCullable = 0; time_removeEvent(b->ExpireTimer); b->save_vel_x = b->save_vel_y = 1; Sprite *t = physics_closest(&Core.Player->s, &Core.Enemies); // SetForNearestEnemy(aimVec) float dx, dy; if (!t) { Vector2 *d = &Core.Player->lastFacedDirection; float l = sqrtf(d->x * d->x + d->y * d->y); if (l > 0) d->x /= l, d->y /= l; if (d->x == 0 && d->y == 0) d->x = 1; dx = d->x, dy = d->y; } else { dx = t->body.position.x - Core.Player->s.x, dy = t->body.position.y - Core.Player->s.y; float l = sqrtf(dx * dx + dy * dy); if (l > 0) dx /= l, dy /= l; } b->aimVec = (Vector2){ Bullet_TrueSpeed(b) * dx, Bullet_TrueSpeed(b) * dy }; sprite_setVelocity(&b->s, b->aimVec.x, b->aimVec.y); tween_stop(b->SpeedTween); b->bombDeceleration = 1; b->SpeedTween = tweens_add((TweenConfig){ .props = { { &b->bombDeceleration, NULL, 0 } }, .nprops = 1, .delay = 0.25f * Weapon_PDuration(w), .duration = 0.75f * Weapon_PDuration(w), .onComplete = B_Cherry_TryDetonate, .ctx = b }); Sound_PlaySound("Shot", 0.45f, 1, -0x64 * b->indexInWeapon, 0xc8, 0xa); } static void B_Cherry_canBounce(void *ctx) { ((Bullet *)ctx)->canBounce = 1; } static void B_Cherry_OnHasHitAnObject(Bullet *b, void *o, int isDead) { (void)o; if (isDead || !b->canBounce) return; b->save_vel_x *= -1, b->save_vel_y *= -1; b->n_hit = 0; b->canBounce = 0; time_removeEvent(b->BounceTimer); b->BounceTimer = time_addEvent(0x3c, 0, 0, B_Cherry_canBounce, b); } static void B_Cherry_OnHasHitWall(Bullet *b, Tile *t) { b->save_vel_x *= t && (t->faceRight || t->faceLeft) ? -1 : 1; b->save_vel_y *= t && (t->faceTop || t->faceBottom) ? -1 : 1; b->n_hit = 0; } static void B_Cherry_Update(Bullet *b, float delta) { (void)delta; sprite_setVelocity(&b->s, b->aimVec.x * b->save_vel_x * b->bombDeceleration, b->aimVec.y * b->save_vel_y * b->bombDeceleration); } static void B_Cherry_DeSpawn(Bullet *b) { b->isCullable = 1; time_removeEvent(b->ExpireTimer); emitter_stop(b->PfxEmitter), emitter_stop(b->PfxEmitter2); base_DeSpawn(b); } static const BulletVT B_Cherry = { "items", "Cherry.png", B_Cherry_ctor, NULL, B_Cherry_OnRecycle, B_Cherry_OnHasHitAnObject, B_Cherry_Update, B_Cherry_DeSpawn, NULL, NULL, B_Cherry_OnHasHitWall }; static void W_Cherry_ctor(Weapon *w) { // la foglia che gira, ridisegnata a ogni frame nella RenderTexture 'cherryBomb0' (qui: il suo fotogramma corrente) static Animation spin; if (!spin.n) make_anim(&spin, "vfx", "leaf", 0, 0x13, 4, 0x1e, -1); // leaf0000..leaf0019, frameRate [30,20,24,14][0] sprite_init(&w->leafSprite, frame_get("vfx", "leaf0000.png"), -1e9f, -1e9f); sprite_setOrigin(&w->leafSprite, 0, 0); children_add(&w->leafSprite); anims_play(&w->leafSprite, &spin, 0); } static const WeaponVT W_Cherry = { BASE, .CheckArcanas = CA_inverseBeginning, .bullet = &B_Cherry, .ctor = W_Cherry_ctor }; // --- Cherry Stars / Yatta Daikarin: W_CherryStars (0xf01f, CHERRY2), B_CherryStar (0x1438f), B_CherryStarExplosion (0x139b8) --------- // La bomba fa stelle invece di foglie; un "disegnatore" corre tra 7 punti vicini al giocatore lasciando stelle e scia, poi le fa esplodere. static void W_Cherry_SetToStars(Weapon *w) { static Animation star; w->isStars = 1; if (!star.n) make_anim(&star, "vfx", "image_004_", 0, 0x16, 4, 0x10, -1); anims_play(&w->leafSprite, &star, 0); sprite_setScale(&w->leafSprite, 0.5f); } static void CherryStar_trailDraw(Sprite *s) { // come Diamond: ogni passata col lineStyle dell'ultimo segmento; spessori 3 e 1.5 Bullet *b = s->owner; if (b->nStarTrail < 2 || b->trailAlpha <= 0) return; float ox = b->trail.x - camera_scrollX, oy = b->trail.y - camera_scrollY, al = fminf(1, b->trailAlpha); Vector2 *P = b->starTrail; BeginBlendMode(BLEND_ADDITIVE); float a = fminf(1, 1.0f / ((b->nStarTrail - 1) / 20.0f)) * al; for (int i = 1; i < b->nStarTrail; i++) DrawLineEx((Vector2){ ox + P[i - 1].x, oy + P[i - 1].y }, (Vector2){ ox + P[i].x, oy + P[i].y }, 3, hexc(b->color, a)); int last = 0; for (int i = 1; i < 0xc8 && i < b->nStarTrail; i++) last = i; if (last) { a = fminf(1, 0.8f / (last / 20.0f)) * al; for (int i = 1; i <= last; i++) DrawLineEx((Vector2){ ox + P[i - 1].x, oy + P[i - 1].y }, (Vector2){ ox + P[i].x, oy + P[i].y }, 1.5f, hexc(0xffffff, a)); } EndBlendMode(); } static void B_CherryStar_ctor(Bullet *b) { b->color = 0xff0000; sprite_init(&b->trail, NULL, 0, 0); b->trail.owner = b, b->trail.draw = CherryStar_trailDraw; children_add(&b->trail); b->isCullable = 0; b->stars1 = gmem_calloc(7, sizeof(Sprite)), b->stars2 = gmem_calloc(7, sizeof(Sprite)), b->starTrail = gmem_calloc(0x190, sizeof(Vector2)); for (int i = 0; i < 7; i++) { Sprite *a = &b->stars1[i], *c = &b->stars2[i]; sprite_init(a, frame_get("vfx", "2Spell4Blue.png"), 0, 0), a->scaleX = 1, a->scaleY = 4, a->visible = 0, a->alpha = 0.65f, children_add(a); sprite_init(c, frame_get("vfx", "2Spell4Red.png"), 0, 0), c->scaleX = 1, c->scaleY = 4, c->angle = 0x2d, c->visible = 0, c->alpha = 0.65f, children_add(c); tweens_add((TweenConfig){ .props = { { &a->angle, NULL, 0x2d0 }, { &a->scaleX, NULL, 4 }, { &a->scaleY, NULL, 1 } }, .nprops = 3, .duration = 0x3e8, .yoyo = 1, .repeat = -1 }); tweens_add((TweenConfig){ .props = { { &c->angle, NULL, 0x2fd }, { &c->scaleX, NULL, 1 }, { &c->scaleY, NULL, 4 } }, .nprops = 3, .duration = 0x40f, .yoyo = 1, .repeat = -1 }); } tweens_add((TweenConfig){ .props = { { &b->s.angle, NULL, 0x2d0 }, { &b->s.scaleX, NULL, 4 }, { &b->s.scaleY, NULL, 1 } }, .nprops = 3, .duration = 0x3e8, .yoyo = 1, .repeat = -1 }); b->BounceTimer = (Timer){ -1, 0 }; } static void B_CherryStar_PickNewTarget(Bullet *b) { b->n_hit = 0; float m = fminf(game_width, game_height); Vector2 t = { Core.Player->s.x - (frand() - 0.5f) * m, Core.Player->s.y - (frand() - 0.5f) * m }; b->lastTargets[0] = b->lastTargets[1], b->lastTargets[1] = b->lastTargets[2], b->lastTargets[2] = t; // targets.push: servono gli ultimi tre b->nTargets++; if (frand() < 0.3f && b->nTargets > 2) { // a volte riparte da uno dei due bersagli precedenti Vector2 o = b->lastTargets[frand() >= 0.5f ? 1 : 0]; b->s.x = o.x, b->s.y = o.y; } b->starTarget = t; float a = atan2f(b->s.y - t.y, b->s.x - t.x); b->starSin = fabsf(sinf(a)), b->starCos = fabsf(cosf(a)); } static void B_CherryStar_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); body_setCircle(&b->s.body, 9, -4.5f, -4.5f); b->isCullable = 0; sprite_setScale(&b->s, 2); b->trail.x = b->s.x - Core.Player->s.x, b->trail.y = b->s.y - Core.Player->s.y; // (sic) come Diamond b->color = 0xffffff, b->trailAlpha = 1, b->s.alpha = 1; b->nStarTrail = 0; B_CherryStar_PickNewTarget(b); b->canUpdate = 1; } static void B_CherryStar_DeSpawn(Bullet *b) { (void)b; } // il disegnatore non sparisce mai static void B_CherryStar_resume(void *ctx) { Bullet *b = ctx; b->trailAlpha = 1, b->canUpdate = 1; } static void B_CherryStar_StartTimer(void *ctx) { Bullet *b = ctx; b->BounceTimer = time_addEvent(0x1f4, 0, 0, B_CherryStar_resume, b); } static void B_CherryStar_ExplodeAll(Bullet *b) { Weapon *w = b->weapon; for (int i = 0; i < 7; i++) BulletPool_SpawnAt(w->explosionPool, b->stars1[i].x, b->stars1[i].y, w, i); // ShootStarAt tweens_add((TweenConfig){ .props = { { &b->trailAlpha, NULL, 2 } }, .nprops = 1, .duration = 0x1f4 }); tweens_add((TweenConfig){ .props = { { &b->trailAlpha, NULL, 0 } }, .nprops = 1, .duration = 0x1f4, .delay = 0x1f4 }); for (int i = 0; i < 7; i++) { tweens_add((TweenConfig){ .props = { { &b->stars1[i].alpha, NULL, 0 } }, .nprops = 1, .duration = 0x1f4, .delay = 0x1f4 }); tweens_add((TweenConfig){ .props = { { &b->stars2[i].alpha, NULL, 0 } }, .nprops = 1, .duration = 0x1f4, .delay = 0x1f4 }); } time_addEvent(0x1f4 + 0x32 * 7, 0, 0, B_CherryStar_StartTimer, b); } static float Approach(float v, float to, float d); static void B_CherryStar_Update(Bullet *b, float delta) { if (!b->canUpdate) return; b->trail.depth = b->s.y - Core.Player->s.y + 0.5f * game_height; for (int k = 0, n = (int)ceilf(delta / 16); k < n; k++) { // trailUpdate (sempre attivo): unshift, al massimo 400 int m = b->nStarTrail < 0x190 ? b->nStarTrail : 0x18f; memmove(&b->starTrail[1], &b->starTrail[0], m * sizeof(Vector2)); b->starTrail[0] = (Vector2){ b->s.x, b->s.y }; b->nStarTrail = m + 1; } float step = 0.5f * Weapon_PSpeed(b->weapon) * delta; b->s.x = Approach(b->s.x, b->starTarget.x, step * b->starCos); b->s.y = Approach(b->s.y, b->starTarget.y, step * b->starSin); if (b->s.x == b->starTarget.x && b->s.y == b->starTarget.y) { Sprite *a = &b->stars1[b->starIndex], *c = &b->stars2[b->starIndex]; // MakeStar a->x = c->x = b->starTarget.x, a->y = c->y = b->starTarget.y; a->visible = c->visible = 1, a->alpha = c->alpha = 0.65f; b->starIndex++; B_CherryStar_PickNewTarget(b); b->canUpdate = 0; time_removeEvent(b->BounceTimer); // CheckTimer if (++b->bouncedTimes >= 7) b->starIndex = 0, B_CherryStar_ExplodeAll(b), b->bouncedTimes = 0, b->nStarTrail = 0; else B_CherryStar_StartTimer(b); } } static const BulletVT B_CherryStar = { "vfx", "2Spell4Blue.png", B_CherryStar_ctor, NULL, B_CherryStar_OnRecycle, NULL, B_CherryStar_Update, B_CherryStar_DeSpawn }; // B_CherryStarExplosion: la stessa esplosione della bomba, subito static void B_CherryExplo_ctor(Bullet *b) { static const char *const blur[3] = { "_blur.png", "_blur2.png", "_blur3.png" }; b->bombDeceleration = 1; sprite_init(&b->ring, frame_get("vfx", "sPFX_ring_64.png"), 0, 0), b->ring.visible = 0, children_add(&b->ring); sprite_init(&b->rainbow, frame_get("vfx", "s_pfx_rainbow_64.png"), 0, 0), b->rainbow.visible = 0, children_add(&b->rainbow); sprite_init(&b->rays, frame_get("vfx", "fuzzA.png"), 0, 0), b->rays.visible = 0, children_add(&b->rays); b->Pfx = particles_add(); b->PfxEmitter = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", blur[b->indexInWeapon % 3]) }, .nframes = 1, .lifespan = EOP(0x320), .rotate = ERND(0, 0x168), .alpha = { 0, 1, 2, Ease_ExpoOut }, .angle = { 0, 0x168, 1 }, .angleSteps = 0x10, .speed = ERND(0x32, 0x64), .quantity = 0x40, .scale = ERANGE(3, 0), .frequency = 0x40, .blendAdd = 1, .on = 0 }); } static void B_CherryExplo_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void B_CherryExplo_t5(void *ctx) { Bullet *b = ctx; emitter_stop(b->PfxEmitter); b->s.body.enable = 0; } static void B_CherryExplo_t6start(void *ctx) { Bullet *b = ctx; b->PfxEmitter->x = b->s.x, b->PfxEmitter->y = b->s.y; emitter_start(b->PfxEmitter); } // FlashingVFXEnabled static void B_CherryExplo_t6done(void *ctx) { emitter_stop(((Bullet *)ctx)->PfxEmitter); } static void B_CherryExplo_OnRecycle(Bullet *b) { static const char *const C3[3] = { "Blue", "Purple", "Red" }; if (b->alreadyRecycled) return; b->alreadyRecycled = 1; Weapon *w = b->weapon; float a = Weapon_PArea(w); Bullet_OnRecycle(b); body_setCircle(&b->s.body, 8, b->s.body.offset.x, b->s.body.offset.y); b->s.body.enable = 1, b->s.visible = 0; char f1[32], f2[32]; snprintf(f1, sizeof(f1), "2Spell3%s.png", C3[b->indexInWeapon % 3]), snprintf(f2, sizeof(f2), "2Spell4%s.png", C3[b->indexInWeapon % 3]); b->PfxEmitter->c.frames[0] = frame_get("vfx", f1), b->PfxEmitter->c.frames[1] = frame_get("vfx", f2), b->PfxEmitter->c.nframes = 2; b->s.alpha = 1, sprite_setScale(&b->s, a); b->PfxEmitter->c.speed = ERND(0x32 * a, 0x64 * a); b->isCullable = 0; // Detonate (FlashingVFXEnabled) b->ring.visible = 1, sprite_setScale(&b->ring, 0), b->ring.alpha = 1, b->ring.angle = 0, b->ring.x = b->s.x, b->ring.y = b->s.y; b->rainbow.visible = 1, sprite_setScale(&b->rainbow, 0), b->rainbow.alpha = 0.75f, b->rainbow.angle = 0, b->rainbow.x = b->s.x, b->rainbow.y = b->s.y, b->rainbow.blendAdd = 1; b->rays.visible = 1, sprite_setScale(&b->rays, 0), b->rays.alpha = 1, b->rays.angle = 0, b->rays.x = b->s.x, b->rays.y = b->s.y; tweens_add((TweenConfig){ .props = { { &b->ring.scaleX, &b->ring.scaleY, 4 }, { &b->ring.angle, NULL, 0x168 } }, .nprops = 2, .duration = 0x64 }); tweens_add((TweenConfig){ .props = { { &b->ring.alpha, NULL, 0 }, { &b->rays.alpha, NULL, 0 } }, .nprops = 2, .delay = 0x64, .duration = 0x64 }); tweens_add((TweenConfig){ .props = { { &b->rays.scaleX, &b->rays.scaleY, 3 } }, .nprops = 1, .duration = 0x64 }); tweens_add((TweenConfig){ .props = { { &b->rainbow.scaleX, &b->rainbow.scaleY, 5 }, { &b->rainbow.alpha, NULL, 0 }, { &b->rainbow.angle, NULL, 0x168 } }, .nprops = 3, .duration = 0x1f4, .onComplete = B_CherryExplo_despawn, .ctx = b }); Sound_PlaySound("Explosion2", 0.5f, 1, 0x64 * b->indexInWeapon - 0x1f4, 0x96, 3); Sound_PlaySound("Whistle", 0.1f, 1.5f, 0x64 * b->indexInWeapon, 0x96, 3); tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, 8 * a }, { &b->s.alpha, NULL, 0.1f } }, .nprops = 2, .duration = 0x78, .onComplete = B_CherryExplo_t5, .ctx = b }); tweens_add((TweenConfig){ .props = { { &b->s.alpha, NULL, 0.1f } }, .nprops = 1, .duration = 0x64, .delay = 0xc8, .onStart = B_CherryExplo_t6start, .onComplete = B_CherryExplo_t6done, .ctx = b }); } static void B_CherryExplo_DeSpawn(Bullet *b) { b->alreadyRecycled = 0, b->isCullable = 1; emitter_stop(b->PfxEmitter); base_DeSpawn(b); } static const BulletVT B_CherryStarExplosion = { "items", "Cherry.png", B_CherryExplo_ctor, NULL, B_CherryExplo_OnRecycle, NULL, NULL, B_CherryExplo_DeSpawn }; static float W_CherryStars_SecondaryPPower(Weapon *w) { float c = w->critChancesArray[w->critIndex % 1000]; w->critIndex++; float crit = c < w->critChance * Player_PLuck(Core.Player) ? Player_PLuck(Core.Player) * Arcanas.CritMul : 1; return fminf(10, (Arcanas.silentMight + Core.Player->power) * sinev(Core.Player->sineMight)) * (w->power * Weapon_PAmount(w) * crit) + Arcanas.bloodlineDamage; } static void W_CherryStars_ctor(Weapon *w) { W_Cherry_ctor(w); w->critChance = 0.05f; } static void W_CherryStars_Fire(Weapon *w) { base_Fire(w); if (w->hasBullets) return; w->hasBullets = 1; // InitBullets w->drawerPool = BulletPool_new(w, &B_CherryStar); physics_addOverlap(&w->drawerPool->group, &Core.Enemies, Weapon_onSecondaryBulletOverlapsEnemy, w); physics_addOverlap(&w->drawerPool->group, &Core.Destructibles, Weapon_onBulletOverlapsDestuctible, w); w->explosionPool = BulletPool_new(w, &B_CherryStarExplosion); physics_addOverlap(&w->explosionPool->group, &Core.Enemies, Weapon_onSecondaryBulletOverlapsEnemy, w); physics_addOverlap(&w->explosionPool->group, &Core.Destructibles, Weapon_onBulletOverlapsDestuctible, w); BulletPool_SpawnAt(w->drawerPool, Core.Player->s.x, Core.Player->s.y, w, 0); // BulletA } static void W_CherryStars_Update(Weapon *w, float delta) { base_Update(w, delta); if (!w->hasImage) { // InitImage: la mucca fantasma dietro al giocatore static Animation idle; w->hasImage = 1; if (!idle.n) make_anim(&idle, "characters", "yattaCowi0", 1, 4, 0, 8, -1); sprite_init(&w->cow, frame_get("characters", "yattaCowi01.png"), 0, 0); children_add(&w->cow); anims_play(&w->cow, &idle, 0); w->cow.alpha = 0.65f, w->cow.depth = -2; sprite_setOrigin(&w->cow, 0.5f, 1); } w->cow.x = Core.Player->s.x, w->cow.y = Core.Player->s.y, w->cow.flipX = Core.Player->s.flipX; // UpdateImage } static const WeaponVT W_CherryStars = { BASE, .CheckArcanas = CA_inverseBeginning, .bullet = &B_Cherry, .ctor = W_CherryStars_ctor, .SecondaryPPower = W_CherryStars_SecondaryPPower, .Fire = W_CherryStars_Fire, .Update = W_CherryStars_Update }; // --- Carréllo: W_Cart2 (0x13a01), B_Cart2 (0x9494) -------------------------------------------------------------- // Carrello che corre in orizzontale e rimbalza sui bordi dello schermo (rimbalzi = Amount), con le scintille. static Animation Cart_end, Cart_idle; static void B_Cart2_ctor(Bullet *b) { if (!Cart_end.n) make_anim(&Cart_end, "vfx", "CartEnd_", 0, 0x1d, 0, 0x1e, 0), make_anim(&Cart_idle, "vfx", "CartEnd_", 0, 0, 0, 0x1e, 0); b->makeSparks = 1; b->Pfx = particles_add(); b->PfxEmitter = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "PfxYellow.png") }, .nframes = 1, .rotate = ERND(0, 0x168), .speed = ERND(0x32, 0x64), .quantity = 1, .lifespan = EOP(0xc8), .scale = ERANGE(1, 0), .on = 0 }); b->defaultSpeed = b->_speed; b->disappearTween = b->enterTween = TWEEN_NONE; } static void B_Cart2_vanish(void *ctx) { Bullet *b = ctx; b->s.visible = 0; Bullet_DeSpawn(b); } static void B_Cart2_FadeOut(Bullet *b) { b->isFadingOut = 1; b->s.body.velocity = (Vector2){ 0, 0 }; b->makeSparks = 0; Sound_PlaySound("Carrello", 1, 2, -0xc8 * frand(), 0x96, 2); tween_stop(b->disappearTween); b->disappearTween = tweens_add((TweenConfig){ .props = { { &b->s.x, NULL, b->s.x + -0.5f * b->save_vel_x }, { &b->s.scaleX, &b->s.scaleY, 1.5f * b->s.scaleX } }, .nprops = 2, .duration = 0x1f4, .onComplete = B_Cart2_vanish, .ctx = b }); } static void B_Cart2_OnBounce(Bullet *b) { if (--b->bounces <= 0) { if (!b->isFadingOut) { anims_play(&b->s, &Cart_end, 0); B_Cart2_FadeOut(b); } } else { b->n_hit = 0; Sound_PlaySound("Brakes", 0.3f, 1, 0xc8 * frand(), 0x96, 2); } } static void B_Cart2_Bounce(void *ctx) { B_Cart2_OnBounce(ctx); } // 'worldbounds' static void B_Cart2_OnHasHitWall(Bullet *b, Tile *t) { if (b->bounces > 0) { b->save_vel_x *= t && (t->faceRight || t->faceLeft) ? -1 : 1; b->save_vel_y *= t && (t->faceTop || t->faceBottom) ? -1 : 1; } sprite_setVelocity(&b->s, b->save_vel_x, b->save_vel_y); B_Cart2_OnBounce(b); } static void B_Cart2_enterDone(void *ctx) { ((Bullet *)ctx)->enterTweenCompleted = 1; } static void B_Cart2_OnRecycle(Bullet *b) { Weapon *w = b->weapon; Bullet_OnRecycle(b); sprite_setScale(&b->s, 1); sprite_setOrigin(&b->s, 0.5f, 1); body_setCircle(&b->s.body, 0x18, b->s.body.offset.x, b->s.body.offset.y); b->s.alpha = 1; b->_speed = b->defaultSpeed; b->makeSparks = 1; b->s.visible = 1; b->n_hit = 0; anims_play(&b->s, &Cart_idle, 0); if (IsHalloween) sprite_setFrame(&b->s, frame_get("vfx", "hCartEnd_0.png")); // (sic) l'animazione resta quella normale b->isFadingOut = 0; tween_stop(b->disappearTween); b->enterTweenCompleted = 0; sprite_setScale(&b->s, 0); tween_stop(b->enterTween); b->enterTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, Weapon_PArea(w) } }, .nprops = 1, .duration = 0xc8, .onComplete = B_Cart2_enterDone, .ctx = b }); b->s.body.collideWorldBounds = 1, b->s.body.hasWorldBounce = 1, b->s.body.worldBounce = (Vector2){ 1, 1 }; b->s.body.customBounds = &Core.Player->WorldBoxCollider; b->s.body.onWorldBounds = B_Cart2_Bounce, b->s.body.onWorldBoundsCtx = b; int goingRight = Core.Player->lastFacedDirection.x * 1 + Core.Player->lastFacedDirection.y * 0 < 0; // (sic) dot(RIGHT) < 0 -> 180 gradi b->s.depth = Core.Player->s.depth + 1; b->Pfx->s.depth = b->s.depth - 1; b->s.body.velocity = velocityFromRotation((goingRight ? 0xb4 : 0) * (PI / 180), Bullet_TrueSpeed(b)); Sound_PlaySound("Brakes", 0.3f, 1, 0xc8 * frand(), 0x96, 2); } static void B_Cart2_Update(Bullet *b, float delta) { float a = Weapon_PArea(b->weapon); b->_speed += 1 * delta; // (sic) la velocita' si calcola solo in OnRecycle if (b->enterTweenCompleted) sprite_setScale(&b->s, a); if (b->makeSparks) { float o = b->save_vel_x < 0 ? 0xc : -0xc; manager_emitParticleAt(b->Pfx, b->s.x + o, b->s.y - 2 * a); manager_emitParticleAt(b->Pfx, b->s.x + o, b->s.y - 0x16 * a); } b->save_vel_x = b->s.body.velocity.x == 0 ? b->save_vel_x : b->s.body.velocity.x; b->save_vel_y = b->s.body.velocity.y == 0 ? b->save_vel_y : b->s.body.velocity.y; } static const BulletVT B_Cart2 = { "vfx", "CartEnd_0.png", B_Cart2_ctor, NULL, B_Cart2_OnRecycle, NULL, B_Cart2_Update, NULL, NULL, NULL, B_Cart2_OnHasHitWall }; static float W_Cart2_PBounces(Weapon *w) { return floorf(Weapon_PAmount(w)) + w->bonusBounces + w->bounces; } static void W_Cart2_Fire(Weapon *w) { Weapon_FireOneBullet(w, Core.Player->s.x, Core.Player->s.y + 0xc, 0); if (w->lastFiringInterval != Weapon_PInterval(w)) { w->lastFiringInterval = Weapon_PInterval(w); Weapon_ResetFiringTimer(w); } } static void W_Cart2_ctor(Weapon *w) { w->mul = 1000.0f / 12; } static void W_Cart2_Update(Weapon *w, float delta) { base_Update(w, delta); w->totalTime += delta; if (w->cooldownAffectedByMovement) w->totalTime += Core.Player->frameWalk * (delta / w->mul); if (w->totalTime >= Weapon_PInterval(w)) { w->totalTime -= Weapon_PInterval(w); Weapon_Fire(w); } } // CheckArcanas (Tragic Princess, Pearls, Iron Blue, Twilight): arcane static const WeaponVT W_Cart2 = { BASE, .CheckArcanas = CA_cart2, .bullet = &B_Cart2, .ctor = W_Cart2_ctor, .PBounces = W_Cart2_PBounces, .Fire = W_Cart2_Fire, .Update = W_Cart2_Update, .ResetFiringTimer = noop_ResetFiringTimer }; // --- Celestial Dusting: W_Flower (0xa698), B_Flower (0xa60b) ---------------------------------------------------- // Un fiore che si allontana nella direzione opposta al passo del giocatore, rallenta e svanisce; l'area verde a terra fa danno. static float B_Flower_MyScale(Bullet *b) { return Weapon_PArea(b->weapon) * b->bounceAreaMod * b->scaleAfterBounceMod; } static void B_Flower_ctor(Bullet *b) { static const unsigned TINTS[4] = { 0xff8888, 0x88ff88, 0x88ff88, 0xffff88 }; static const char *const blur[2] = { "_blur.png", "_blur2.png" }; Weapon *w = b->weapon; b->bombDeceleration = 1; b->canBounce = 1; b->bounceAreaMod = 1, b->maxBounceAreaMod = 1.5f; b->radius = 8; sprite_init(&b->GroundFx, NULL, 0, 0); // scene.add.circle(0, 0, 8, 0x00ff00), ADD, alpha 0.1 b->GroundFx.owner = b; b->GroundFx.draw = Trapano_groundDraw; b->GroundFx.tint = 0xff00, b->GroundFx.alpha = 0.1f, b->GroundFx.visible = 1; children_add(&b->GroundFx); b->s.visible = 0; b->Pfx = particles_add(); // particles('vfx'): fwEmitter (mai avviato) e fwEmitterK (mai usato) b->PfxEmitter = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", blur[b->indexInWeapon % 2]) }, .nframes = 1, .lifespan = EOP(0x320), .rotate = ERND(0, 0x168), .alpha = { 0, 1, 2, Ease_ExpoOut }, .angle = { 0, 0x168, 1 }, .angleSteps = 0x10, .speed = ERND(0x32, 0x64), .quantity = 0x10, .scale = ERANGE(1, 0), .frequency = 0x10, .blendAdd = 1, .on = 0 }); b->Pfx2 = particles_add(); // particles('dusting0'): la foglia animata della Weapon b->PfxEmitter2 = particles_createEmitter(b->Pfx2, (EmitterConfig){ .frameRef = &w->leafSprite.frame, .lifespan = EOP(0x258), .rotate = ERND(0, 0x168), .alpha = { 0, 1, 2, Ease_ExpoOut }, .angle = { 0, 0x168, 1 }, .angleSteps = 0x1f, .speed = ERND(0x96, 0xc8), .quantity = 1, .scale = ERANGE(2, 0.1f), .frequency = 1, .tints = { TINTS[0], TINTS[1], TINTS[2], TINTS[3] }, .ntints = 4, .blendAdd = 1, .on = 0 }); char nm[16]; if (IsHalloween) snprintf(nm, sizeof(nm), "Ecto%d.png", 1 + (int)floorf(frand() * 6)); else snprintf(nm, sizeof(nm), "fl%02d.png", (int)floorf(frand() * 0x59)); // RND.pick(flowerNames) sprite_init(&b->flowerSprite, frame_get("vfx", nm), b->s.x, b->s.x); // (sic) x, x sprite_setScale(&b->flowerSprite, 0); sprite_setOrigin(&b->flowerSprite, 0.5f, 1); b->flowerSprite.angle = -0x2d; children_add(&b->flowerSprite); tweens_add((TweenConfig){ .props = { { &b->flowerSprite.angle, NULL, 0x2d } }, .nprops = 1, .duration = 0x3e8, .repeat = -1, .yoyo = 1 }); // AngleTween b->BounceTimer = b->HitboxTimer = (Timer){ -1, 0 }; b->SpeedTween = b->tween1 = b->tween2 = TWEEN_NONE; } static void B_Flower_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void B_Flower_FadeOut(void *ctx) { Bullet *b = ctx; tweens_add((TweenConfig){ .props = { { &b->flowerSprite.alpha, NULL, 0 }, { &b->s.alpha, NULL, 0 }, { &b->GroundFx.alpha, NULL, 0 } }, .nprops = 3, .duration = 0x1f4, .onComplete = B_Flower_despawn, .ctx = b }); } static void B_Flower_tween1Start(void *ctx) { Bullet *b = ctx; b->s.scaleX = b->s.scaleY = 0; b->flowerSprite.scaleX = b->flowerSprite.scaleY = 0; } static void B_Flower_tween2Done(void *ctx) { Bullet *b = ctx; b->canBounce = 1; tweens_add((TweenConfig){ .props = { { &b->scaleAfterBounceMod, NULL, fmaxf(1, Core.Player->moveSpeed) } }, .nprops = 1, .duration = fmaxf(0x1f4, Weapon_PDuration(b->weapon) - 0x258) }); } static void B_Flower_resetHits(void *ctx) { ((Bullet *)ctx)->n_hit = 0; } static void B_Flower_OnRecycle(Bullet *b) { static const char *const steps[4] = { "STEP1", "STEP2", "STEP3", "STEP4" }; Weapon *w = b->weapon; float a = Weapon_PArea(w); Bullet_OnRecycle(b); b->isCullable = 0; sprite_setScale(&b->s, 1); body_setCircle(&b->s.body, 8, -4, -4); b->s.body.enable = 1; b->totalTime = 0; b->n_hit = 0; b->PfxEmitter2->c.hasZone = 1, b->PfxEmitter2->c.zoneRadius = 8 * a; b->flowerSprite.visible = 1, b->GroundFx.visible = 1, b->s.visible = 0; b->bounceAreaMod = 1; b->s.alpha = 1; b->GroundFx.alpha = 0.1f; b->canBounce = 0; // setBounce(1.1, 1.1): le velocita' si riscrivono a ogni Update b->PfxEmitter->c.speed = ERND(0x32 * a, 0x64 * a); b->isCullable = 1; b->save_vel_x = b->save_vel_y = 1; b->aimVec = (Vector2){ -1 * Core.Player->s.body.velocity.x, -1 * Core.Player->s.body.velocity.y }; sprite_setVelocity(&b->s, b->aimVec.x * Weapon_PSpeed(w), b->aimVec.y * Weapon_PSpeed(w)); // (sic) Update la riscrive senza PSpeed tween_stop(b->SpeedTween); b->bombDeceleration = 1; b->SpeedTween = tweens_add((TweenConfig){ .props = { { &b->bombDeceleration, NULL, 0 } }, .nprops = 1, .delay = 0.25f * Weapon_PDuration(w), .duration = 0.75f * Weapon_PDuration(w), .onComplete = B_Flower_FadeOut, .ctx = b }); if (b->indexInWeapon < 4) Sound_PlaySound(steps[b->indexInWeapon % 4], 0.05f - 0.01f * b->indexInWeapon, 1, 0xc8 * b->indexInWeapon, 0xc8, 0xa); b->flowerSprite.scaleX = b->flowerSprite.scaleY = 0; b->flowerSprite.alpha = 1, b->flowerSprite.visible = 1; b->scaleAfterBounceMod = 1; b->flowerSprite.x = b->s.x, b->flowerSprite.y = b->s.y + 8 * B_Flower_MyScale(b); float sc = B_Flower_MyScale(b); b->s.scaleX = b->s.scaleY = 0; tween_stop(b->tween1); b->tween1 = tweens_add((TweenConfig){ .props = { { &b->s.scaleY, NULL, sc } }, .nprops = 1, .duration = 0x1f4, .ease = Ease_BackOut, .onStart = B_Flower_tween1Start, .ctx = b }); tween_stop(b->tween2); b->tween2 = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, NULL, sc } }, .nprops = 1, .duration = 0x258, .ease = Ease_BackOut, .onComplete = B_Flower_tween2Done, .ctx = b }); time_removeEvent(b->HitboxTimer); b->HitboxTimer = time_addEvent(w->hitBoxDelay, 1, 0, B_Flower_resetHits, b); } static void B_Flower_canBounce(void *ctx) { ((Bullet *)ctx)->canBounce = 1; } static void B_Flower_SizeUp(Bullet *b) { // (sic) non cambia bounceAreaMod: solo le foglie if (!b->canBounce) return; b->canBounce = 0; emitter_emitParticleAt(b->PfxEmitter2, b->s.x, b->s.y, 0); time_removeEvent(b->BounceTimer); b->BounceTimer = time_addEvent(0x3c, 0, 0, B_Flower_canBounce, b); } static void B_Flower_OnHasHitWall(Bullet *b, Tile *t) { b->save_vel_x *= t && (t->faceRight || t->faceLeft) ? -1 : 1; b->save_vel_y *= t && (t->faceTop || t->faceBottom) ? -1 : 1; b->n_hit = 0; } static void B_Flower_Update(Bullet *b, float delta) { (void)delta; sprite_setVelocity(&b->s, b->aimVec.x * b->save_vel_x * b->bombDeceleration, b->aimVec.y * b->save_vel_y * b->bombDeceleration); if (b->canBounce) { float sc = B_Flower_MyScale(b); b->s.scaleX = b->s.scaleY = sc; } b->s.depth = b->GroundFx.depth = -game_height; b->flowerSprite.depth = b->s.y - Core.Player->s.y - 1; b->Pfx->s.depth = b->s.depth - 1; b->GroundFx.x = b->flowerSprite.x = b->s.x; b->GroundFx.y = b->flowerSprite.y = b->s.y; b->GroundFx.scaleX = b->s.scaleX, b->GroundFx.scaleY = b->s.scaleY; b->flowerSprite.scaleX = 0.65f * b->s.scaleX, b->flowerSprite.scaleY = 0.65f * b->s.scaleY; b->flowerSprite.y = b->s.y + 8 * b->s.scaleY; } static void B_Flower_DeSpawn(Bullet *b) { tween_stop(b->SpeedTween); emitter_stop(b->PfxEmitter); tween_stop(b->tween1), tween_stop(b->tween2); b->flowerSprite.visible = 0; b->s.scaleX = b->s.scaleY = 0; b->GroundFx.visible = 0; b->s.visible = 0; b->s.body.enable = 0; if (b->weapon->explodeOnExpire) Weapon_SpawnExplosionAt(b->weapon, b->s.x, b->s.y, 0); base_DeSpawn(b); } static const BulletVT B_Flower = { "vfx", "circle8.png", B_Flower_ctor, NULL, B_Flower_OnRecycle, NULL, B_Flower_Update, B_Flower_DeSpawn, NULL, NULL, B_Flower_OnHasHitWall }; static void W_Flower_ctor(Weapon *w) { w->mul = 1000.0f / 60; W_Cherry_ctor(w); // la stessa foglia animata ('dusting0'), frameRate 30 } static void W_Flower_Update(Weapon *w, float delta) { base_Update(w, delta); w->totalTime += delta; w->totalTime += Core.Player->frameWalk * (delta / w->mul); if (w->totalTime >= Weapon_PInterval(w)) { w->totalTime = 0; Weapon_Fire(w); } } static void W_Flower_OnBulletOverlapsBullet(void *ctx, Sprite *as, Sprite *bs) { (void)ctx; Bullet *a = as->owner, *b = bs->owner; if (Bullet_HasAlreadyHitObject(a, b, 0)) return; Bullet_pushHit(b, a), Bullet_pushHit(a, b); B_Flower_SizeUp(b), B_Flower_SizeUp(a); } static void W_Flower_OnStart(Weapon *w) { base_OnStart(w); physics_addColliderSelf(&w->pool->group, W_Flower_OnBulletOverlapsBullet, w); } static void W_Flower_onBulletOverlapsEnemy(Weapon *w, Bullet *b, Enemy *e) { if (e->isDead || Bullet_HasAlreadyHitObject(b, e, e->isDead)) return; Enemy_GetDamaged(e, Weapon_PPower(w), (int)w->hitVFX, w->knockback, w->bulletType); w->stats_inflictedDamage += Weapon_PPower(w); if (!e->isDead || w->level < 8) return; float r = w->critChancesArray[w->critIndex % 1000]; w->critIndex++; if (r >= 0.33f) { Pickup *h = Core_MakePickup(e->s.x, e->s.y, "LITTLEHEART"); if (h) h->goToPlayer = 1, h->time = 1; // volume = 0.1: solo il suono } } static const WeaponVT W_Flower = { BASE, .CheckArcanas = CA_inverseBeginning, .bullet = &B_Flower, .ctor = W_Flower_ctor, .Update = W_Flower_Update, .OnStart = W_Flower_OnStart, .ResetFiringTimer = noop_ResetFiringTimer, .onBulletOverlapsEnemy = W_Flower_onBulletOverlapsEnemy }; static void GizmoManager_ShowHighlightAt(float x, float y); static void Core_debug_destructibles(float mul); // --- Greatest Jubilee: W_Jubilee (0x185ad), B_Jubilee (0x10079) ------------------------------------------------- // Fuochi d'artificio: il primo sul nemico piu' vicino, gli altri a caso sopra il giocatore; a volte fonti di luce. // MakeRays / SpawnExplosionAt (JUBILEE_RAYS): dal livello 9 (RaysLevel), che i dati non raggiungono senza limit break. static void B_Jubilee_counterStart(void *ctx) { Bullet *b = ctx; ParticleEmitter *e = b->jubEmitter; e->c.scale = ERANGE(fminf(4, Weapon_PArea(b->weapon)), 0); e->c.quantity = 0x40; e->x = b->jubX, e->y = b->jubY; if (!isnan(b->jubX)) emitter_start(e); // senza nemici la posizione e' undefined (NaN): niente da vedere, ne' da disegnare } static void B_Jubilee_counterDone(void *ctx) { emitter_stop(((Bullet *)ctx)->jubEmitter); } static void B_Jubilee_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void B_Jubilee_OnRecycle(Bullet *b) { Weapon *w = b->weapon; Bullet_OnRecycle(b); sprite_setScale(&b->s, 1); body_setCircle(&b->s.body, 1, -0.5f, -0.5f); sprite_setScale(&b->s, 0); ParticleEmitter *e = w->fwEmitters[b->indexInWeapon % 5]; float x = NAN, y = NAN; if (Weapon_PAmount(w) < 4 && b->indexInWeapon == 0) { Sprite *t = physics_closest(&Core.Player->s, &Core.Enemies); if (t) x = t->x, y = t->y; } else { x = b->s.x + (frand() - 0.5f) * (0.75f * game_width), y = b->s.y - 0x40 - 0x80 * frand(); } b->s.x = x, b->s.y = y; tween_stop(b->scaleTween); b->scaleTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, 0x30 * Weapon_PArea(w) } }, .nprops = 1, .duration = Weapon_PDuration(w), .yoyo = 1, .onComplete = B_Jubilee_despawn, .ctx = b }); if (tween_get(b->emitterCounter) && b->jubEmitter) emitter_stop(b->jubEmitter); // stop() -> onStop tween_stop(b->emitterCounter); b->jubEmitter = e, b->jubX = x, b->jubY = y; b->counterVal = 0; b->emitterCounter = tweens_add((TweenConfig){ .props = { { &b->counterVal, NULL, 1 } }, .nprops = 1, .duration = 0.3f * Weapon_PDuration(w), .onStart = B_Jubilee_counterStart, .onComplete = B_Jubilee_counterDone, .ctx = b }); } static void B_Jubilee_ctor(Bullet *b) { b->s.visible = 0; b->scaleTween = b->emitterCounter = TWEEN_NONE; } static const BulletVT B_Jubilee = { "vfx", "WhiteDot.png", B_Jubilee_ctor, NULL, B_Jubilee_OnRecycle, NULL, NULL, NULL }; static void W_Jubilee_ctor(Weapon *w) { static const char *const fr[5] = { "PfxYellow.png", "PfxPink.png", "PfxRed.png", "PfxGreen.png", "PfxBlue.png" }; w->canPlaySounds = 1; w->fwManager = particles_add(); // MakeFireworks for (int i = 0; i < 5; i++) w->fwEmitters[i] = particles_createEmitter(w->fwManager, (EmitterConfig){ .frames = { frame_get("vfx", fr[i]) }, .nframes = 1, .lifespan = EOP(0x5dc), .rotate = ERND(0, 0x168), .angle = { 0, 0x168, 1 }, .angleSteps = 0x10, .speed = ERND(0x32, 0x64), .quantity = 0x40, .scale = ERANGE(1, 0), .frequency = 0x40, .blendAdd = 1, .on = 0 }); w->fwManager->hasWell = 1; // createGravityWell({ power: 0.5, epsilon: 25, gravity: 100 }) w->fwManager->wellPower = 0.5f * 0x64, w->fwManager->wellEpsilon = 0x19 * 0x19; w->soundTimer = (Timer){ -1, 0 }; } static void W_Jubilee_step(void *ctx) { static const char *const steps[4] = { "STEP1", "STEP2", "STEP3", "STEP4" }; Weapon *w = ctx; w->jubSoundN++; Sound_PlaySound(steps[w->jubSoundIdx % 4], 0.3f, 1, 0xc8 * w->jubSoundN, 0x32, 5); TimerEvent *t = time_get(w->soundTimer); if (t && t->repeatCount == 0) w->canPlaySounds = 1; } static void W_Jubilee_Fire(Weapon *w) { static const char *const steps[4] = { "STEP1", "STEP2", "STEP3", "STEP4" }; base_Fire(w); if (frand() < w->chance * Player_PLuck(Core.Player)) Core_debug_destructibles(0.25f * Player_PLuck(Core.Player)); // PLuck if (!w->canPlaySounds) return; w->canPlaySounds = 0; w->jubSoundN = 0, w->jubSoundIdx = w->soundIndex; Sound_PlaySound(steps[w->soundIndex % 4], 0.3f, 1, 0, 0x32, 5); if (Weapon_PAmount(w) > 1) w->soundTimer = time_addEvent(w->repeatInterval, 0, (int)Weapon_PAmount(w) - 1, W_Jubilee_step, w); else w->canPlaySounds = 1; w->soundIndex++; } static void W_Jubilee_Update(Weapon *w, float delta) { base_Update(w, delta); w->fwManager->wellX = Core.Player->s.x, w->fwManager->wellY = Core.Player->s.y; } // onSecondaryBulletOverlapsEnemy (critico con la Luck): solo per i raggi del livello 9 static const WeaponVT W_Jubilee = { BASE, .bullet = &B_Jubilee, .ctor = W_Jubilee_ctor, .Fire = W_Jubilee_Fire, .Update = W_Jubilee_Update }; // --- Vandalier: W_Silf3 (0xa7cc), B_Silf3 (0x500f) --------------------------------------------------------------- // Peachone ed Ebony Wings insieme: due zone speculari, 24 bersagli, archi sopra la testa del giocatore. static void W_Silf3_ctor(Weapon *w) { static Animation idle; w->silf3 = 1; w->ntargets = 24; w->rayDuration = 0x190; w->runSpeed = PlayerPxSpeed; w->damageZoneDistance = 0x1c8 * 0.5f; // IS_PORTRAIT ? GAMEPLAY_PIXEL_WIDTH : GAMEPLAY_PIXEL_HEIGHT w->damageZoneDefaultRadius = 0.25f * w->damageZoneDistance; w->damageZoneDistance -= w->damageZoneDefaultRadius; Silf_zone(&w->damageZone, w->damageZoneDefaultRadius, 2, 0xffff00), w->damageZone.visible = 0; Silf_zone(&w->targetZone, w->damageZoneDefaultRadius, 1, 0xffffff), w->targetZone.alpha = 0.5f; Silf_zone(&w->damageZone2, w->damageZoneDefaultRadius, 2, 0xffff00), w->damageZone2.visible = 0; Silf_zone(&w->targetZone2, w->damageZoneDefaultRadius, 1, 0xffffff), w->targetZone2.alpha = 0.5f; sprite_init(&w->sprite, frame_get("vfx", "ProjectileBird2.png"), Core.Player->s.x, Core.Player->s.y); children_add(&w->sprite); physics_existing(&w->sprite); if (!idle.n) make_anim(&idle, "vfx", "ProjectileBird", 7, 8, 0, 6, -1); anims_play(&w->sprite, &idle, 0); w->sprite.depth = MAX_SAFE_INTEGER - 0x3e7; } static void Silf_randomIn(Vector2 *out, const Sprite *zone) { // Geom.Circle.Random float t = 2 * PI * frand(), u = frand() + frand(), k = u > 1 ? 2 - u : u; *out = (Vector2){ k * cosf(t) * zone->scaleX + zone->x, k * sinf(t) * zone->scaleX + zone->y }; } static void W_Silf3_Fire(Weapon *w) { if (w->blockFire) return; w->repeatInterval = w->interval / Weapon_PAmount(w); w->damageZone.scaleX = w->damageZone2.scaleX = w->damageZoneDefaultRadius; for (int i = 0; i < 12; i++) Silf_randomIn(&w->targets[i], &w->damageZone); for (int i = 0; i < 12; i++) Silf_randomIn(&w->targets[12 + i], &w->damageZone2); base_Fire(w); } static void W_Silf3_Update(Weapon *w, float delta) { base_Update(w, delta); w->totalTime += delta; w->angleTime += delta; float ox = Core.Player->s.flipX ? 0x18 : -0x18; Sprite *s = &w->sprite; float dx = Core.Player->s.x + ox - s->x, dy = Core.Player->s.y - s->y; if (dx * dx + dy * dy > 0x1388) { Vector2 *d = &w->_currentDirection; d->x = Core.Player->s.x + ox - s->x, d->y = Core.Player->s.y - 0x18 - s->y; float l = sqrtf(d->x * d->x + d->y * d->y); if (l > 0) d->x /= l, d->y /= l; s->flipX = d->x < 0; sprite_setVelocity(s, w->runSpeed * d->x * Core.Player->moveSpeed, w->runSpeed * d->y * Core.Player->moveSpeed); } else { sprite_setVelocity(s, 0x23 * w->_currentDirection.x, 0x23 * w->_currentDirection.y); } float px = Core.Player->s.x, py = Core.Player->s.y, r = w->damageZoneDistance, a = 0.001f * (w->angleTime - w->rayDuration) * Weapon_PSpeed(w); w->targetZone.x = px + cosf(a) * r, w->targetZone.y = py + sinf(a) * r; w->targetZone2.x = px + cosf(-a) * r, w->targetZone2.y = py + sinf(-a) * r; a = 0.001f * w->angleTime * Weapon_PSpeed(w); w->damageZone.x = px + cosf(a) * r, w->damageZone.y = py + sinf(a) * r; w->damageZone2.x = px + cosf(-a) * r, w->damageZone2.y = py + sinf(-a) * r; if (w->totalTime >= Weapon_PDuration(w)) { w->totalTime = -Weapon_PDuration(w) * (w->interval / 1000) * Core.Player->cooldown; w->blockFire = 1; w->targetZone.alpha = w->targetZone2.alpha = 0.1f; if (w->totalTime >= Weapon_PDuration(w)) w->totalTime = 0, w->blockFire = 0, w->targetZone.alpha = w->targetZone2.alpha = 0.5f; } else if (w->totalTime > 0) { w->blockFire = 0; w->targetZone.alpha = w->targetZone2.alpha = 0.5f; } } // LevelUp / ApplyLimitBreak: counterWeapon1/2 solo con l'arcana Aquarius static const WeaponVT W_Silf3 = { BASE, .CheckArcanas = CA_silf3, .bullet = &B_Silf3, .ctor = W_Silf3_ctor, .Fire = W_Silf3_Fire, .Update = W_Silf3_Update }; static const WeaponVT W_PowerUp = { BASE, .bullet = &B_Whip, .LevelUp = PowerUp_LevelUp, .MakeLevelOne = PowerUp_MakeLevelOne, .ResetFiringTimer = noop_ResetFiringTimer }; // --- Bracelet / Bi-Bracelet / Tri-Bracelet: W_Triace (0x1071b), B_Triace (0x40b6) -------------------------------- // Sfere a ventaglio (0, -15, +15 gradi) verso un nemico a caso, che si allargano fino a 16 * area dentro lo schermo. static void B_Triace_ctor(Bullet *b) { static const unsigned colors[3] = { 0xffff, 0x66ff, 0xffff66 }; b->radius = 0x10; b->color = colors[(int)floorf(frand() * 3)]; // myColor: RND.pick sprite_init(&b->GroundFx, NULL, 0, 0); // scene.add.circle(0, 0, 1, myColor), ADD: raggio = scala b->GroundFx.draw = MoonGroundFx_draw; b->GroundFx.tint = b->color, b->GroundFx.alpha = 0.2f, b->GroundFx.visible = 1; children_add(&b->GroundFx); b->s.visible = 0; // la sfera vera resta invisibile: si vedono il cerchio e le particelle b->Pfx = particles_add(); b->PfxEmitter1 = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "PfxGreen.png"), frame_get("vfx", "PfxYellow.png") }, .nframes = 2, .angle = ERND(0, 0x168), .speed = ERND(0xf, 0x1e), .quantity = 1, .lifespan = EOP(0x64), .alpha = ERANGE(1, 0), .scale = ERANGE(1, 0), .on = 0 }); b->PfxEmitter2 = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "ProjectileBlue1.png"), frame_get("vfx", "ProjectileBlue2.png"), frame_get("vfx", "PfxLightGreen.png") }, .nframes = 3, .speed = ERND(0xf, 0x1e), .rotate = ERND(0, 0x168), .angle = { 0, 0xb4, 1 }, .angleSteps = 0x10, .quantity = 1, .lifespan = EOP(0x64), .alpha = ERANGE(1, 0), .scale = ERANGE(0, 2), .on = 0 }); // projEmitter b->ScaleTween = TWEEN_NONE; } static void B_Triace_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void B_Triace_OnRecycle(Bullet *b) { Weapon *w = b->weapon; Bullet_OnRecycle(b); body_setCircle(&b->s.body, 1, b->s.body.offset.x, b->s.body.offset.y); sprite_setScale(&b->s, PixelScale * Weapon_PArea(w)); sprite_setTintFill(&b->s, b->color); b->s.y -= 0x18; Sound_PlaySound("Fireloop", 1, 2.5f, -0x64 * b->indexInWeapon, 0xc8, 1); b->GroundFx.alpha = 0.4f, b->GroundFx.scaleX = b->GroundFx.scaleY = 0, b->GroundFx.visible = 1; b->s.alpha = 0, sprite_setScale(&b->s, 0); b->PfxEmitter2->c.scale = ERANGE(0, fmaxf(2, Weapon_PArea(w))); tween_stop(b->ScaleTween); float sc = b->radius * Weapon_PArea(w); TweenProp pr[4] = { { &b->GroundFx.alpha, NULL, 0 }, { &b->GroundFx.scaleX, &b->GroundFx.scaleY, sc }, { &b->s.alpha, NULL, 0 }, { &b->s.scaleX, &b->s.scaleY, sc } }; b->ScaleTween = tweens_add((TweenConfig){ .many = pr, .nmany = 4, .duration = Weapon_PDuration(w), .onComplete = B_Triace_despawn, .ctx = b }); b->s.body.collideWorldBounds = 1, b->s.body.hasWorldBounce = 1, b->s.body.worldBounce = (Vector2){ 0.1f, 0.1f }; b->s.body.customBounds = &Core.Player->WorldBoxCollider; b->s.body.onWorldBounds = NULL; // onWorldBounds = true: solo l'evento 'worldbounds', che nessuno ascolta } static void B_Triace_Update(Bullet *b, float delta) { (void)delta; b->GroundFx.x = b->s.x, b->GroundFx.y = b->s.y; manager_emitParticleAt(b->Pfx, b->s.x, b->s.y); b->s.depth = -2, b->Pfx->s.depth = -1; } static void B_Triace_DeSpawn(Bullet *b) { tween_stop(b->ScaleTween); b->GroundFx.visible = 0; if (b->weapon->explodeOnExpire && strcmp(b->weapon->bulletType, "TRIASSO1")) Weapon_SpawnExplosionAt(b->weapon, b->s.x, b->s.y, 0); b->s.body.collideWorldBounds = 0; base_DeSpawn(b); } static void B_Triace_OnHasHitAnObject(Bullet *b, void *o, int isDead) { if (isDead) return; if (Arcanas_has(19) && !strcmp(b->weapon->bulletType, "TRIASSO3")) Weapon_SpawnExplosionAt(b->weapon, b->s.x, b->s.y, 1); // RAYEXPLOSION (sic) if (Arcanas_has(14)) Bullet_TryFreeze(b, o); if (--b->penetrating <= 0) Bullet_DeSpawn(b); } static const float TriaceFan[3] = { 0, -0xf, 0xf }; static void B_Triace_SetTarget(Bullet *b, Vector2 t) { Bullet_SetTargetFan(b, t, TriaceFan, 3); } static void B_Triace_SetNullTarget(Bullet *b) { B_Triace_SetTarget(b, Bullet_NullTargetPoint()); } static const BulletVT B_Triace = { "vfx", "WhiteDot.png", B_Triace_ctor, NULL, B_Triace_OnRecycle, B_Triace_OnHasHitAnObject, B_Triace_Update, B_Triace_DeSpawn, B_Triace_SetTarget, B_Triace_SetNullTarget }; static void W_Triace_Fire(Weapon *w) { w->target = Core.Enemies.n ? Core.Enemies.items[(int)floorf(frand() * Core.Enemies.n)] : NULL; // RND.pick(Core.Enemies) Sound_PlaySound("MagicMissile", 0.2f, 1, 0, 0xc8, 0xa); base_Fire(w); } static const WeaponVT W_Triace = { BASE, .CheckArcanas = CA_triace, .bullet = &B_Triace, .Fire = W_Triace_Fire }; // CheckArcanas: Jewels, Twilight, Fire // --- Victory Sword: W_Victory (0x1721f), B_Victory (0xdb09) ------------------------------------------------------ // Fendenti sul nemico scelto, sei angoli a rotazione; dal livello 8 critici e colpo finale (Victory2, scintille blu). // Quando il giocatore viene colpito: sei fendenti su di lui (ritorsione), al massimo ogni 6 * repeatInterval. static void Weapon_StandardCritical(Weapon *w, Bullet *b, Enemy *e) { // Weapon.StandardCritical (0xe49a): legge in ordine la tabella mescolata if (e->isDead) return; float r = w->critChancesArray[w->critIndex++ % 1000]; float crit = r < w->critChance * Player_PLuck(Core.Player) ? w->critMul * Arcanas.CritMul : 1; // PLuck if (Bullet_HasAlreadyHitObject(b, e, e->isDead)) return; Enemy_GetDamaged(e, Weapon_PPower(w) * crit, (int)w->hitVFX, w->knockback, w->bulletType); w->stats_inflictedDamage += Weapon_PPower(w) * crit; } static const float VictoryAngles[6] = { 0x14, -0x14, -0x46, 0x1e, -0x1e, 0 }, VictoryX[6] = { -0x10, 0x10, 0, 0x10, -0x10, 0 }; static void B_Victory_ctor(Bullet *b) { b->Pfx = particles_add(); b->PfxEmitter = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "WhiteDot.png") }, .nframes = 1, .quantity = 0xa, .lifespan = EOP(0x1f4), .alpha = ERANGE(1, 0), .angle = ERND(0xe1, 0x13b), .blendAdd = 1, .speed = ERND(0x4b, 0x7d), .scale = ERANGE(2 * PixelScale, 0), .gravityY = -0x258, .tint = 0x88ff, .hasZoneRect = 1, .zoneRect = { -0x10, -0x80, 0x20, 0x100 }, .flowEveryFrame = 1, .on = 0 }); b->tween = b->tween2 = TWEEN_NONE; } static void B_Victory_Init(Bullet *b, float x, float y) { Bullet_Init(b, x, y); sprite_setScale(&b->s, 0); b->s.blendAdd = 1; b->s.depth = 0xf0; } static void B_Victory_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); emitter_stop(b->PfxEmitter); } static void B_Victory_DeSpawn(Bullet *b) { base_DeSpawn(b); emitter_stop(b->PfxEmitter); } static void B_Victory_SetNullTarget(Bullet *b) { Bullet_DeSpawn(b); } static void B_Victory_onStart(void *ctx) { Bullet *b = ctx; int f = b->victoryFinish; b->s.scaleX = 0.5f * (f ? 2 : 1), b->s.scaleY = Weapon_PArea(b->weapon) * (f ? 2 : 1); if (f) b->PfxEmitter->x = b->s.x, b->PfxEmitter->y = b->s.y, emitter_start(b->PfxEmitter); } static void B_Victory_onComplete(void *ctx) { Bullet *b = ctx; if (b->victoryFinish) emitter_stop(b->PfxEmitter); } static void B_Victory_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void B_Victory_SetTarget(Bullet *b, Vector2 t) { int k = b->indexInWeapon % 6, f = b->weapon->canFinish && k == 5; b->victoryFinish = f; if (k < 5) Sound_PlaySound("Victory1", 0.4f, 1, 0xc8 * k, 0x64, 5); else if (f) Sound_PlaySound("Victory2", 1, 1, 0x4b0, 0x12c, 1); b->s.x = t.x + VictoryX[k], b->s.y = t.y; sprite_setFrame(&b->s, frame_get("vfx", f ? "victoryCrit.png" : "victory.png")); b->s.alpha = f ? 0.5f : 0.75f; b->s.angle = VictoryAngles[k]; b->s.depth = game_height; tween_stop(b->tween); b->tween = tweens_add((TweenConfig){ .props = { { &b->s.scaleY, NULL, 0 }, { &b->s.scaleX, NULL, 0.5f } }, .nprops = 2, .duration = f ? 0x96 : 0x64, .onStart = B_Victory_onStart, .onComplete = B_Victory_onComplete, .ctx = b }); tween_stop(b->tween2); b->tween2 = tweens_add((TweenConfig){ .props = { { &b->s.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x64, .delay = 0x64, .onComplete = B_Victory_despawn, .ctx = b }); } static const BulletVT B_Victory = { "vfx", "victory.png", B_Victory_ctor, B_Victory_Init, B_Victory_OnRecycle, NULL, NULL, B_Victory_DeSpawn, B_Victory_SetTarget, B_Victory_SetNullTarget }; static Bullet *W_Victory_SpawnExplosionAt(Weapon *w, float x, float y, int index) { if (!w->secondaryPool) { // explosionType VICTORY: le esplosioni sono altri fendenti w->secondaryPool = BulletPool_new(w, &B_Victory); physics_addOverlap(&w->secondaryPool->group, &Core.Enemies, Weapon_onBulletOverlapsEnemy_Retaliation, w); physics_addOverlap(&w->secondaryPool->group, &Core.Destructibles, Weapon_onBulletOverlapsDestuctible, w); } Bullet *b = BulletPool_SpawnAt(w->secondaryPool, x, y, w, index); if (b) B_Victory_SetTarget(b, (Vector2){ Core.Player->s.x, Core.Player->s.y }); return b; } typedef struct { Weapon *w; int index; } VictoryShot; static void W_Victory_explodeLater(void *ctx) { VictoryShot *c = ctx; W_Victory_SpawnExplosionAt(c->w, Core.Player->s.x, Core.Player->s.y, c->index); } static void W_Victory_canExplode(void *ctx) { ((Weapon *)ctx)->canExplode = 1; } static void W_Victory_ExplodeOnPlayer(void *ctx) { static VictoryShot shots[64]; static int shot_i; Weapon *w = ctx; if (!w->canExplode) return; w->canExplode = 0; time_removeEvent(w->ExplodeTimer); w->ExplodeTimer = time_addEvent(6 * w->repeatInterval, 0, 0, W_Victory_canExplode, w); W_Victory_SpawnExplosionAt(w, Core.Player->s.x, Core.Player->s.y, 0); for (int i = 1; i < 6; i++) { VictoryShot *c = &shots[shot_i++ & 63]; *c = (VictoryShot){ w, i }; time_addEvent(w->repeatInterval * i, 0, 0, W_Victory_explodeLater, c); } } static void W_Victory_ctor(Weapon *w) { w->canExplode = 1; w->ExplodeTimer = (Timer){ -1, 0 }; PlayerEvents_add(EV_PLAYER_RECEIVEDDAMAGE, W_Victory_ExplodeOnPlayer, w); // explodeEvent PlayerEvents_add(EV_PLAYER_LOSTSHIELD, W_Victory_ExplodeOnPlayer, w); } static int W_Victory_LevelUp(Weapon *w) { int r = base_LevelUp(w); if (w->level >= 8) w->canCrit = 1, w->canFinish = 1; return r; } static void W_Victory_Fire(Weapon *w) { // closest(): la lista dei nemici vivi che via via si avvicinano al giocatore; l'ultimo e' il piu' vicino. // Bersaglio a caso nella meta' piu' vicina della lista. I colpi ritardati rileggono this.target allo scatto, come base_Fire. static Sprite *list[1024]; int n = 0; float best = 3.4e38f, px = Core.Player->s.x, py = Core.Player->s.y; for (int i = 0; i < Core.Enemies.n; i++) { Sprite *s = Core.Enemies.items[i]; if (((Enemy *)s->owner)->isDead) continue; float d = hypotf(s->body.center.x - px, s->body.center.y - py); // Distance.Between if (d < best && n < 1024) best = d, list[n++] = s; } w->target = n > 1 ? list[n - 1 - (int)floorf(frand() * n * 0.5f)] : n ? list[0] : NULL; base_Fire(w); } static void W_Victory_onBulletOverlapsEnemy(Weapon *w, Bullet *b, Enemy *e) { if (w->canCrit) Weapon_StandardCritical(w, b, e); else base_onBulletOverlapsEnemy(w, b, e); } // CleanUp toglie i due listener (Weapon_CleanUp generico) static const WeaponVT W_Victory = { BASE, .PPower = blood2_PPower, .bullet = &B_Victory, .ctor = W_Victory_ctor, .LevelUp = W_Victory_LevelUp, .Fire = W_Victory_Fire, .onBulletOverlapsEnemy = W_Victory_onBulletOverlapsEnemy }; // --- La Robba: W_Larobba (0xdf2e), B_Larobba (0xce07) -------------------------------------------------------- // Oggetti a caso che piovono dall'alto ruotando, con un fantasma scuro; rimbalzano sui nemici e ricadono dall'alto. static void B_Larobba_ctor(Bullet *b) { b->maxHistory = 1; b->grav = 10.0f / 48; sprite_setScale(&b->s, PixelScale * Weapon_PArea(b->weapon)); b->AngleTween = tweens_add((TweenConfig){ .props = { { &b->s.angle, NULL, 0x168 } }, .nprops = 1, .duration = 0x3e8, .repeat = -1 }); // MovementTween su moveAngle: l'originale lo anima ma non lo legge mai ghost_init(b, PixelScale, PixelScale, 0.55f); sprite_setTintFill(&b->ghost, 0x111111); // semplificazione: tintFill a quattro angoli (0, 0x222222, 0, 0x222222) reso col colore medio b->ScaleTween = TWEEN_NONE; b->BounceTimer = (Timer){ -1, 0 }; } static void B_Larobba_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void B_Larobba_OnRecycle(Bullet *b) { Weapon *w = b->weapon; Bullet_OnRecycle(b); b->canBounce = 1; w->lastRobbaIndex = (w->lastRobbaIndex + 1) % 0x14; // GetRobbaFrame: maxFrames 20 su 23 nomi const Frame *f = frame_get("items", w->robbaFrames[w->lastRobbaIndex]); sprite_setFrame(&b->s, f), sprite_setFrame(&b->ghost, f); b->s.tint = 0xffffff, b->s.tintFill = 0; sprite_setScale(&b->s, PixelScale * Weapon_PArea(w)); float r = 0.5f * fmaxf(b->s.width, b->s.height); body_setCircle(&b->s.body, r, 0, 0); b->isCullable = 0; tween_stop(b->ScaleTween); // onUpdate copia la scala sul fantasma: lo fa gia' Update b->ScaleTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, 0 } }, .nprops = 1, .duration = 0x1f4, .delay = Weapon_PDuration(w), .onComplete = B_Larobba_despawn, .ctx = b }); float px = Core.Player->s.x, py = Core.Player->s.y; b->s.x = px + (frand() - 0.5f) * game_width * 0.25f, b->s.y = py - 0.6f * game_height - r; w->lastAngleIndex = (w->lastAngleIndex + 1) % w->maxAngles; // GetAngle float a = w->targetAngles[w->lastAngleIndex]; b->startingAngle = a; // in radianti (vedi OnHasHitAnObject) b->s.body.velocity = velocityFromRotation(a, Bullet_TrueSpeed(b)); b->initialVelocity = (Vector2){ 1.5f * b->s.body.velocity.x, b->s.body.velocity.y }; b->defaultVelocityY = b->initialVelocity.y; for (int i = 0; i < b->maxHistory; i++) b->posHistory[i] = (Vector2){ b->s.x, b->s.y }; Sound_PlaySound("Shot", 0.45f, 1, -0x64 * b->indexInWeapon, 0xc8, 0xa); } static void B_Larobba_DeSpawn(Bullet *b) { tween_stop(b->ScaleTween); b->ghost.visible = 0; base_DeSpawn(b); } static void B_Larobba_canBounce(void *ctx) { ((Bullet *)ctx)->canBounce = 1; } static void B_Larobba_OnHasHitAnObject(Bullet *b, void *o, int isDead) { (void)o; if (isDead || !b->canBounce) return; b->canBounce = 0; time_removeEvent(b->BounceTimer); b->BounceTimer = time_addEvent(0x1e, 0, 0, B_Larobba_canBounce, b); b->s.body.velocity = velocityFromRotation(b->startingAngle * (PI / 180), Bullet_TrueSpeed(b)); // (sic) DegToRad di un angolo gia' in radianti b->initialVelocity.x *= -1; b->initialVelocity.y = fmaxf(-0x258, b->s.body.velocity.y); b->n_hit = 0; } static void B_Larobba_Update(Bullet *b, float delta) { b->initialVelocity.y += delta * b->grav; if (b->historyIndex < b->maxHistory - 1) b->historyIndex++; else b->historyIndex = 0; Vector2 h = b->posHistory[getHistoryIndex(b, 0)]; b->ghost.angle = b->s.angle, b->ghost.x = h.x, b->ghost.y = h.y; b->ghost.scaleX = b->s.scaleX, b->ghost.scaleY = b->s.scaleY, b->ghost.visible = 1; sprite_setVelocity(&b->s, b->initialVelocity.x, b->initialVelocity.y); b->posHistory[b->historyIndex] = (Vector2){ b->s.x, b->s.y }; if (b->s.y > Core.Player->s.y + game_height) { // ricade dall'alto b->s.x = Core.Player->s.x + (frand() - 0.5f) * game_width * 0.25f; b->s.y = Core.Player->s.y - game_height; b->initialVelocity.y = b->defaultVelocityY; } } static const BulletVT B_Larobba = { "items", "Larobba01.png", B_Larobba_ctor, NULL, B_Larobba_OnRecycle, B_Larobba_OnHasHitAnObject, B_Larobba_Update, B_Larobba_DeSpawn }; static void W_Larobba_shuffle(Weapon *w) { shuffle(w->targetAngles, w->maxAngles); for (int i = 22; i > 0; i--) { int j = (int)floorf(frand() * (i + 1)); const char *t = w->robbaFrames[i]; w->robbaFrames[i] = w->robbaFrames[j]; w->robbaFrames[j] = t; } } static void W_Larobba_ctor(Weapon *w) { static const char *const names[23] = { "Larobba01.png", "Larobba02.png", "Larobba03.png", "Larobba04.png", "Larobba05.png", "Larobba06.png", "Larobba07.png", "Larobba08.png", "Larobba09.png", "Larobba10.png", "Larobba11.png", "Larobba12.png", "Larobba13.png", "Larobba14.png", "Larobba15.png", "Larobba16.png", "Larobba17.png", "Larobba18.png", "Larobba19.png", "Larobba20.png", "Larobba21.png", "Larobba22.png", "Larobba23.png" }; w->maxAngles = 0xc; for (int i = 0; i < w->maxAngles; i++) w->targetAngles[i] = 0.25f * PI + 0.5f * PI * i / w->maxAngles; for (int i = 0; i < 23; i++) w->robbaFrames[i] = names[i]; W_Larobba_shuffle(w); } static int W_Larobba_LevelUp(Weapon *w) { W_Larobba_shuffle(w); return base_LevelUp(w); } // CheckArcanas: beginning (amount + 1) e Twilight: arcane static const WeaponVT W_Larobba = { BASE, .CheckArcanas = CA_inverseBeginning, .bullet = &B_Larobba, .ctor = W_Larobba_ctor, .PBounces = bonus_PBounces, .LevelUp = W_Larobba_LevelUp }; // --- Dairy Cart: W_Cart (0xa23f), B_Cart (0x3717) ------------------------------------------------------------ // Un carretto che sfreccia verso destra dal punto in cui e' stato rotto un distruttibile (sottoclasse di 0x13fb9, // OnDestroyed: AddHiddenWeapon(CART), Location, RemoveHiddenWeapon dopo 5 s). Quel distruttibile arriva con il suo stage. static void B_Cart_ctor(Bullet *b) { b->Pfx = particles_add(); particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "PfxYellow.png") }, .nframes = 1, .rotate = ERND(0, 0x168), .angle = ERND(0, 0x168), .speed = ERND(0x32, 0x64), .quantity = 1, .lifespan = EOP(0xc8), .scale = ERANGE(1, 0), .on = 0 }); b->defaultSpeed = b->_speed; } static void B_Cart_OnRecycle(Bullet *b) { Weapon *w = b->weapon; Bullet_OnRecycle(b); sprite_setScale(&b->s, 1); sprite_setOrigin(&b->s, 0.5f, 1); body_setCircle(&b->s.body, 0x30, b->s.body.offset.x, b->s.body.offset.y); b->_speed = b->defaultSpeed; b->s.x = w->hasLocation ? w->Location.x : Core.Player->s.x, b->s.y = w->hasLocation ? w->Location.y : Core.Player->s.y; b->s.depth = b->s.y - Core.Player->s.y + game_height; b->Pfx->s.depth = b->s.depth - 1; b->s.body.velocity = velocityFromRotation(0, Bullet_TrueSpeed(b)); Sound_PlaySound("Hit", 0.7f, 1, 0x1f4 * (-1 - frand()), 0x96, 2); Sound_PlaySound("Brakes", 0.3f, 1, 0xc8 * frand(), 0x96, 2); } static void B_Cart_Update(Bullet *b, float delta) { b->_speed += 1 * delta; // (sic) la velocita' si e' gia' fissata in OnRecycle: non accelera manager_emitParticleAt(b->Pfx, b->s.x, b->s.y - 2); manager_emitParticleAt(b->Pfx, b->s.x, b->s.y - 0x16); } static const BulletVT B_Cart = { "items", "Cart1.png", B_Cart_ctor, NULL, B_Cart_OnRecycle, NULL, B_Cart_Update, NULL }; static float W_Cart_PPower(Weapon *w) { return Core.Player->power * w->power * (1 + 2 * frand()); } static float W_Cart_PInterval(Weapon *w) { return fmaxf(fmaxf(0.1f, Core.Player->cooldown) * w->interval, 0x2710); } // onBulletOverlapsEnemy: come la base (GetDamaged con il tipo CART); ResetFiringTimer: solo destroy, parte su richiesta static const WeaponVT W_Cart = { BASE, .bullet = &B_Cart, .PAmount = one_PAmount, .PPower = W_Cart_PPower, .PInterval = W_Cart_PInterval, .ResetFiringTimer = noop_ResetFiringTimer }; // --- Crimson Shroud: W_Shroud (0xe905), B_Shroud (0x16767) --------------------------------------------------- // Alloro evoluto: danno subito al massimo 10, e ogni scudo perso restituisce il colpo con un'onda (10% del danno assorbito). static void Shroud_inverseDraw(Sprite *s) { // inverseFilter: colori invertiti in un cerchio attorno al centro dello schermo Weapon *w = s->owner; if (w->invRadius <= 0 || Core.weaponWithShader) return; // MakeInverseCameraPlugin non crea il filtro con SOLES rlSetBlendFactorsSeparate(RL_ONE_MINUS_DST_COLOR, RL_ZERO, RL_ZERO, RL_ONE, RL_FUNC_ADD, RL_FUNC_ADD); // rgb = 1 - sotto; alpha della render texture intatto BeginBlendMode(BLEND_CUSTOM_SEPARATE); DrawCircleV((Vector2){ s->x, s->y }, w->invRadius, WHITE); EndBlendMode(); } static void W_Shroud_CheckColor(Weapon *w, float dmg) { w->image.visible = 1; switch ((int)Core.Player->shields) { default: case 0: w->image.visible = 0; break; case 1: w->image.tint = 0xffff00; break; case 2: w->image.tint = 0xff8800; break; case 3: w->image.tint = 0xff0000; break; } if (dmg <= 0) return; w->lastReceivedDamage = 0.1f * fminf(dmg, 0x64); base_Fire(w); } static void W_Shroud_onLostShield(void *ctx) { W_Shroud_CheckColor(ctx, PlayerEvents_arg); } static void W_Shroud_ctor(Weapon *w) { W_Laurel_ctor(w); // maxCharges, image Shockwave2 coi suoi due tween PlayerEvents_remove(w), laurel = NULL; // il colorEvent di Shroud passa il danno PlayerEvents_add(EV_PLAYER_LOSTSHIELD, W_Shroud_onLostShield, w); sprite_init(&w->inverse, NULL, 0, 0); // Core.MakeInverseCameraPlugin (rexInversePostFx); nessun filtro negli stage BATCOUNTRY e FOSCARI, ne' con SOLES w->inverse.owner = w, w->inverse.draw = Shroud_inverseDraw, w->inverse.scrollFactor0 = 1, w->inverse.depth = MAX_SAFE_INTEGER; children_add(&w->inverse); } static void W_Shroud_OnStart(Weapon *w) { // niente collider dei muri Weapon_ResetFiringTimer(w); time_addEvent(1, 0, 0, Weapon_FireCb, w); Core.Player->shroud = 0xa; physics_addOverlap(&w->pool->group, &Core.Enemies, Weapon_onBulletOverlapsEnemy_Retaliation, w); physics_addOverlap(&w->pool->group, &Core.Destructibles, Weapon_onBulletOverlapsDestuctible, w); w->canPlayInversionVFX = 1; } static void W_Shroud_Fire(Weapon *w) { Player *p = Core.Player; if (p->shields < w->charges && p->shields < w->maxCharges) p->shields += 1; W_Shroud_CheckColor(w, 0); if (w->lastFiringInterval != Weapon_PInterval(w)) { w->lastFiringInterval = Weapon_PInterval(w); Weapon_ResetFiringTimer(w); } } static float W_Shroud_PPower(Weapon *w) { return fminf(10, (Arcanas.silentMight + Core.Player->power) * sinev(Core.Player->sineMight)) * (w->power + w->lastReceivedDamage) * Player_PCurse(Core.Player) + Arcanas.bloodlineDamage; } static void W_Shroud_canPlay(void *ctx) { ((Weapon *)ctx)->canPlayInversionVFX = 1; } static void W_Shroud_InversionVFX(Weapon *w, float radius, float duration, float offY) { if (!w->canPlayInversionVFX) return; // weaponWithShader: nessuna arma tradotta lo imposta w->canPlayInversionVFX = 0; Sound_PlaySound("Shroud", 1, fmaxf(1, 2 - 0.25f * Weapon_PAmount(w)), 0, 0x190, 1); float d = Weapon_PAmount(w) * duration * 0.5f; w->inverse.x = 0.5f * game_width, w->inverse.y = 0.5f * game_height - offY; // setCenter w->invRadius = 0; // onStart tweens_add((TweenConfig){ .props = { { &w->invRadius, NULL, radius } }, .nprops = 1, .duration = d, .yoyo = 1, .onComplete = W_Shroud_canPlay, .ctx = w }); } static void B_Shroud_ctor(Bullet *b) { b->radius = 0x10; b->s.x = Core.Player->s.x, b->s.y = Core.Player->s.y; sprite_init(&b->summon, frame_get("vfx", "bubblevb.png"), 0, 0); // bubble sprite_setOrigin(&b->summon, 0.5f, 0.75f); b->summon.alpha = 0; children_add(&b->summon); sprite_setOrigin(&b->s, 0.5f, 0.75f); b->ScaleTween = TWEEN_NONE; b->ExpireTimer = (Timer){ -1, 0 }; } static void B_Shroud_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void B_Shroud_OnRecycle(Bullet *b) { Weapon *w = b->weapon; Bullet_OnRecycle(b); sprite_setScale(&b->s, 1); body_setCircle(&b->s.body, b->radius, b->s.body.offset.x, b->s.body.offset.y); sprite_setScale(&b->s, 0); b->s.alpha = 0.5f; b->s.visible = 0; b->summon.blendAdd = 1; time_removeEvent(b->ExpireTimer); b->summon.alpha = 1; sprite_setScale(&b->summon, 0); tween_stop(b->ScaleTween); float sc = 2 * PixelScale * Weapon_PArea(w); TweenProp pr[4] = { { &b->s.scaleX, &b->s.scaleY, sc }, { &b->s.alpha, NULL, 0 }, { &b->summon.scaleX, &b->summon.scaleY, sc }, { &b->summon.alpha, NULL, 0 } }; b->ScaleTween = tweens_add((TweenConfig){ .many = pr, .nmany = 4, .duration = 0x190, .onComplete = B_Shroud_despawn, .ctx = b }); float r = 2 * b->radius * Weapon_PArea(w); W_Shroud_InversionVFX(w, r, 0xc8, r * (1 - 0.75f)); } static void B_Shroud_Update(Bullet *b, float delta) { (void)delta; b->s.x = Core.Player->s.x, b->s.y = Core.Player->s.y; b->summon.x = b->s.x, b->summon.y = b->s.y; } static const BulletVT B_Shroud = { "vfx", "Rings4.png", B_Shroud_ctor, NULL, B_Shroud_OnRecycle, NULL, B_Shroud_Update, NULL }; // hasThorns: sempre falso (il costruttore lo riceve dalla factory a false); TriggerAstronomia(SHROUD) non fa nulla static const WeaponVT W_Shroud = { BASE, .bullet = &B_Shroud, .ctor = W_Shroud_ctor, .PPower = W_Shroud_PPower, .Fire = W_Shroud_Fire, .OnStart = W_Shroud_OnStart, .Update = W_Laurel_Update, .LevelUp = W_Laurel_LevelUp }; // --- Candybox: W_Candybox (0x11d27), W_Candybox2 (0x12d83) ------------------------------------------------------ // Appena presa si toglie da sola e apre la scelta di un'arma (UI_selectWeaponScene): base, o evoluta per Candybox II. static void Core_RemoveWeapon(const char *type); static void W_Candybox_OnWeaponAdded(Weapon *w) { Core.EnterWeaponSelection = 1, Core.WeaponSelectionEvo = 0; Core_RemoveWeapon(w->bulletType); cJSON *d = cJSON_GetArrayItem(w->data, 0); if (has(d, "addEvolvedWeapon")) LevelUpFactory_AddLateWeapon(str(d, "addEvolvedWeapon")); } static void W_Candybox2_OnWeaponAdded(Weapon *w) { Core.EnterWeaponSelection = 1, Core.WeaponSelectionEvo = 1; Core_RemoveWeapon(w->bulletType); Core_SetSeenWeapon(w->bulletType); } // interval/repeatInterval MAX_SAFE_INTEGER: non spara mai (e si toglie subito) static const WeaponVT W_Candybox = { BASE, .bullet = &B_Whip, .ResetFiringTimer = noop_ResetFiringTimer, .OnWeaponAdded = W_Candybox_OnWeaponAdded }; static const WeaponVT W_Candybox2 = { BASE, .bullet = &B_Whip, .ResetFiringTimer = noop_ResetFiringTimer, .OnWeaponAdded = W_Candybox2_OnWeaponAdded }; static void Player_SetInvulForMilliSecondsNonCumulative(Player *p, float ms); // --- Sole Solution: W_SoleSolution (0x4ebb), B_SoleSolution (0x491d) ------------------------------------------ // Ogni 20 s: la mappa si spegne, il giocatore sparisce in una galassia (galaxy.glsl) e un cerchio grande quasi // tutto lo schermo colpisce ogni 100 ms per 10 s; il giocatore e' invulnerabile e raccoglie solo l'oro. // Decisione di Federico (2026-10-10): galaxy.glsl alleggerito sulla Vita (meno iterazioni, texture piu' piccola). #ifdef __vita__ #define GALAXY_ITER "24" // semplificazione: 24 x 8 iterazioni su un quarto della texture; il desktop fa le 100 dell'originale #define GALAXY_DIV 2 // texture a meta' risoluzione (scalata x2 a schermo) #else #define GALAXY_ITER "100" #define GALAXY_DIV 1 #endif static const char *GALAXY_FS_BODY = "uniform float time; uniform float force; uniform float speed; uniform vec2 resolution;\n" "vec4 galaxy(vec2 fragCoord) {\n" " vec2 uv = (fragCoord.xy / resolution.xy) - .5; float len = length(uv.xy); float t = speed * time;\n" " float myTime = t + (5. + sin(t)) * (force * .11) / (len + .07); float si = sin(myTime), co = cos(myTime);\n" " uv *= mat2(co, si, -si, co); float c = 0., v1 = 0., v2 = 0., v3; vec3 p;\n" " for (int i = 0; i < " GALAXY_ITER "; i++) {\n" " p = (.035 * 100.0 / " GALAXY_ITER ".0) * float(i) * vec3(uv, 1.); p += vec3(.22, .3, -1.5 - sin(t * 1.3) * .1);\n" " for (int j = 0; j < 8; j++) p = abs(p) / dot(p, p) - 0.659;\n" " float p2 = dot(p, p) * .0015 * (100.0 / " GALAXY_ITER ".0);\n" " v1 += p2 * (1.8 + sin(len * 13.0 + .5 - t * 2.)); v2 += p2 * (1.5 + sin(len * 13.5 + 2.2 - t * 3.));\n" " }\n" " c = length(p.xy) * .175; v1 *= smoothstep(.7, .0, len); v2 *= smoothstep(.6, .0, len); v3 = smoothstep(.15, .0, len);\n" " vec3 col = vec3(c, (v1 + c) * .25, v2); col = col + v3 * .9; return vec4(col, 1.);\n" "}\n"; static struct { Shader sh; RenderTexture2D rt; int locTime, locForce, locSpeed, locRes, ok; float time; } Galaxy; static void Galaxy_init(void) { // scene.add.shader('galaxyShader', 0, 0, W/2, H/2).setRenderToTexture('rt_soleSolution') if (Galaxy.ok) return; char fs[4096]; #ifdef __vita__ snprintf(fs, sizeof(fs), "#version 100\nprecision mediump float;\nvarying vec2 fragTexCoord;\n%s" "void main() { gl_FragColor = galaxy(gl_FragCoord.xy); }\n", GALAXY_FS_BODY); #else snprintf(fs, sizeof(fs), "#version 330\nin vec2 fragTexCoord;\nout vec4 finalColor;\n%s" "void main() { finalColor = galaxy(gl_FragCoord.xy); }\n", GALAXY_FS_BODY); #endif Galaxy.sh = LoadShaderFromMemory(NULL, fs); Galaxy.locTime = GetShaderLocation(Galaxy.sh, "time"), Galaxy.locForce = GetShaderLocation(Galaxy.sh, "force"); Galaxy.locSpeed = GetShaderLocation(Galaxy.sh, "speed"), Galaxy.locRes = GetShaderLocation(Galaxy.sh, "resolution"); Galaxy.rt = LoadRenderTexture(game_width / 2 / GALAXY_DIV, game_height / 2 / GALAXY_DIV); Galaxy.ok = 1; } static void Galaxy_render(float force) { // la Shader di Phaser si ridisegna a ogni frame nella sua texture; fragCoord = gl_FragCoord (pixel della texture) float res[2] = { (float)Galaxy.rt.texture.width, (float)Galaxy.rt.texture.height }, speed = 1; SetShaderValue(Galaxy.sh, Galaxy.locTime, &Galaxy.time, SHADER_UNIFORM_FLOAT); SetShaderValue(Galaxy.sh, Galaxy.locForce, &force, SHADER_UNIFORM_FLOAT); SetShaderValue(Galaxy.sh, Galaxy.locSpeed, &speed, SHADER_UNIFORM_FLOAT); SetShaderValue(Galaxy.sh, Galaxy.locRes, res, SHADER_UNIFORM_VEC2); BeginTextureMode(Galaxy.rt); BeginShaderMode(Galaxy.sh); DrawRectangle(0, 0, Galaxy.rt.texture.width, Galaxy.rt.texture.height, WHITE); EndShaderMode(); EndTextureMode(); } static void SoleImage_draw(Sprite *s) { // image di 'rt_soleSolution': origine 0.5, scrollFactor 0, ADD if (!s->visible || s->alpha <= 0 || s->scaleX <= 0 || !Galaxy.ok) return; float w = Galaxy.rt.texture.width * GALAXY_DIV * s->scaleX, h = Galaxy.rt.texture.height * GALAXY_DIV * s->scaleY; BeginBlendMode(BLEND_ADDITIVE); DrawTexturePro(Galaxy.rt.texture, (Rectangle){ 0, 0, Galaxy.rt.texture.width, -Galaxy.rt.texture.height }, (Rectangle){ s->x - w / 2, s->y - h / 2, w, h }, (Vector2){ 0, 0 }, 0, (Color){ 255, 255, 255, (unsigned char)(255 * fminf(1, s->alpha)) }); EndBlendMode(); } static void B_SoleSolution_ctor(Bullet *b) { sprite_setScale(&b->s, 1); b->s.visible = 0; b->scaleTween = b->ScaleTween = TWEEN_NONE; b->HitboxTimer = (Timer){ -1, 0 }; } static void B_SoleSolution_despawn(void *ctx) { Bullet_DeSpawn(ctx); } static void B_SoleSolution_OnRecycle(Bullet *b) { Weapon *w = b->weapon; Bullet_OnRecycle(b); sprite_setScale(&b->s, 1); body_setCircle(&b->s.body, 1, -0.5f, -0.5f); sprite_setScale(&b->s, 0); b->s.alpha = 0; tween_stop(b->scaleTween); b->scaleTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, 0.475f * game_width } }, .nprops = 1, .duration = 0x3e8, .ease = Ease_SineInOut }); tween_stop(b->ScaleTween); // scaleTween2 b->ScaleTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, 0 } }, .nprops = 1, .duration = 0x3e8, .delay = 0x2328, .ease = Ease_SineInOut, .onComplete = B_SoleSolution_despawn, .ctx = b }); time_removeEvent(b->HitboxTimer); b->HitboxTimer = time_addEvent(w->hitBoxDelay, 1, 0, B_Song_resetHits, b); } static void B_SoleSolution_Update(Bullet *b, float delta) { (void)delta; b->s.x = Core.Player->s.x, b->s.y = Core.Player->s.y; } static const BulletVT B_SoleSolution = { "vfx", "blackDot.png", B_SoleSolution_ctor, NULL, B_SoleSolution_OnRecycle, NULL, B_SoleSolution_Update, NULL }; static void W_SoleSolution_layersTo(Weapon *w, float alpha) { // FadeOutLayers / RestoreLayers: tutti i layer tranne le ombre (void)w; TilingTileset *t = Core.Stage ? Core.Stage->tilingTileset : NULL; if (!t) return; TweenProp pr[64]; int n = 0; for (int i = 0; i < t->mapsAmount; i++) for (int j = 0; j < t->layerContainers[i].n && n < 64; j++) { TilemapLayer *l = t->layerContainers[i].layers[j]; if (l != t->layerContainers[i].ShadowLayer) pr[n++] = (TweenProp){ &l->s.alpha, NULL, alpha }; // 'Shadows' e 'ShadowDecals' esclusi } if (n) tweens_add((TweenConfig){ .many = pr, .nmany = n, .duration = 0x12c }); } static void W_SoleSolution_ctor(Weapon *w) { w->canFire = 1; w->galaxyForce = 1; w->pfx = particles_add(); // particles('vfx') nella MainScene, con il pozzo gravitazionale w->pfxEmitter = particles_createEmitter(w->pfx, (EmitterConfig){ .frames = { frame_get("vfx", "WhiteDot.png") }, .nframes = 1, .quantity = 0xa, .lifespan = EOP(0x3e8), .alpha = ERANGE(1, 0), .angle = ERND(0, 0x168), .speed = ERND(0x12c, 0x1f4), .scale = ERANGE(2 * PixelScale, 0), .tint = 0xffffbb, .flowEveryFrame = 1, .on = 0 }); w->pfx->hasWell = 1, w->pfx->wellPower = 0 * 0x14, w->pfx->wellEpsilon = 0x32 * 0x32; // createGravityWell({ y: -20, power: 0, epsilon: 50, gravity: 20 }) Core.weaponWithShader = w; // Core.StopInversePlugin() se c'e' SHROUD } static float W_SoleSolution_PInterval(Weapon *w) { (void)w; return 0x4e20; } static float W_SoleSolution_PPower(Weapon *w) { return fminf(10, (Arcanas.silentMight + Core.Player->power) * sinev(Core.Player->sineMight)) * (w->power + 0.1f * floorf(Core.kills / 5000.0f)) + Arcanas.bloodlineDamage; } // RunEnemies static void W_SoleSolution_OnWeaponAdded(Weapon *w) { // spostata fra le HiddenWeapons; nella HUD diventa un'icona extra for (int i = 0; i < Core.n_weapons; i++) if (Core.Weapons[i] == w) { memmove(&Core.Weapons[i], &Core.Weapons[i + 1], (Core.n_weapons - i - 1) * sizeof(Weapon *)); Core.n_weapons--; break; } if (Core.n_HiddenWeapons < 16) Core.HiddenWeapons[Core.n_HiddenWeapons++] = w; MainUI_Remove(w->bulletType); MainUI_AddExtra(w->bulletType); } static void W_SoleSolution_MakeLevelOne(Weapon *w) { base_MakeLevelOne(w); time_addEvent(0x64, 0, 0, Weapon_FireCb, w); } static void W_SoleSolution_galaxyTo(Weapon *w, float from, float to, float ms) { // Motion1 / Motion2: onStart forza = from w->galaxyForce = from; tweens_add((TweenConfig){ .props = { { &w->galaxyForce, NULL, to } }, .nprops = 1, .duration = ms }); } static void W_SoleSolution_pfxStop(void *ctx) { emitter_stop(((Weapon *)ctx)->pfxEmitter); } static void W_SoleSolution_second(void *ctx) { (void)ctx; Sound_PlaySound("SoleSSecond", 2, 1, 0, 0x190, 1); } static void W_SoleSolution_motion2(void *ctx) { W_SoleSolution_galaxyTo(ctx, 1, -3, 0x578); } static void W_SoleSolution_imageEnd(void *ctx) { // la galassia si chiude: il giocatore torna Weapon *w = ctx; Core.Player->s.visible = 1, Core.Player->ghostsHidden = 0; Core.pickupCollider->active = 1, Core.pickupColliderImmaterial->active = 0; emitter_stop(w->pfxEmitter); } static void W_SoleSolution_imageStart(void *ctx) { Weapon *w = ctx; base_FireOneBullet(w, Core.Player->s.x, Core.Player->s.y, 0); w->image.alpha = 0, w->image.scaleX = w->image.scaleY = 0; w->pfxEmitter->c.quantity = 0x64; w->pfx->wellPower = 1 * 0x14; time_addEvent(0x64, 0, 0, W_SoleSolution_pfxStop, w); // tweens.addCounter({ duration: 100 }) W_SoleSolution_galaxyTo(w, -1, 1, 0x1f4); // Motion1 Sound_PlaySound("SoleSFirst", 2, 1, 0, 0x190, 1); time_addEvent(0xaf0, 0, 0, W_SoleSolution_second, w); time_addEvent(0x1e78, 0, 0, W_SoleSolution_motion2, w); PlayerUI.hpBarBG.visible = PlayerUI.hpBar.visible = 0; // ToggleHealthBar(false) Player_SetInvulForMilliSecondsNonCumulative(Core.Player, 0x2710); Core.Player->s.visible = 0, Core.Player->ghostsHidden = 1; Core.pickupCollider->active = 0, Core.pickupColliderImmaterial->active = 1; tweens_add((TweenConfig){ .props = { { &w->image.scaleX, &w->image.scaleY, 0 } }, .nprops = 1, .duration = 0x12c, .delay = 0x23f0, .onComplete = W_SoleSolution_imageEnd, .ctx = w }); } static void W_SoleSolution_bgEnd(void *ctx) { Weapon *w = ctx; W_SoleSolution_layersTo(w, 1); // RestoreLayers PlayerUI.hpBarBG.visible = PlayerUI.hpBar.visible = 1; w->canFire = 1; } static void W_SoleSolution_bgStart(void *ctx) { Weapon *w = ctx; w->image2.alpha = 0, w->image2.scaleX = w->image2.scaleY = 0; tweens_add((TweenConfig){ .props = { { &w->image2.alpha, NULL, 0 }, { &w->image2.scaleX, &w->image2.scaleY, 0 } }, .nprops = 2, .duration = 0x12c, .delay = 0x23f0, .onComplete = W_SoleSolution_bgEnd, .ctx = w }); } static void W_SoleSolution_bgDone(void *ctx) { W_SoleSolution_layersTo(ctx, 0); } // FadeOutLayers static void W_SoleSolution_Fire(Weapon *w) { if (!w->canFire) return; if (!Galaxy.ok) { // InitialiseRT Galaxy_init(); sprite_init(&w->image, NULL, 0.5f * game_width, 0.5f * game_height); w->image.draw = SoleImage_draw, w->image.scrollFactor0 = 1, w->image.alpha = 0, w->image.depth = 2 * -game_height + 1; sprite_setScale(&w->image, 0); children_add(&w->image); sprite_init(&w->image2, frame_get("vfx", "solesBG.png"), 0.5f * game_width, 0.5f * game_height); // background w->image2.scrollFactor0 = 1, w->image2.depth = 2 * -game_height; sprite_setScale(&w->image2, 0); children_add(&w->image2); } w->canFire = 0; Sound_PlaySound("SoleSAnti", 2, 1, 0, 0x190, 1); w->pfx->wellPower = 0; w->pfxEmitter->c.quantity = 1; emitter_start(w->pfxEmitter); TweenProp pi[2] = { { &w->image.alpha, NULL, 1 }, { &w->image.scaleX, &w->image.scaleY, 2 } }; tweens_add((TweenConfig){ .many = pi, .nmany = 2, .duration = 0x12c, .delay = 0xbb8, .onStart = W_SoleSolution_imageStart, .ctx = w }); tweens_add((TweenConfig){ .props = { { &w->image2.alpha, NULL, 1 }, { &w->image2.scaleX, NULL, 0.5f * game_width }, { &w->image2.scaleY, NULL, 0.5f * game_height } }, .nprops = 3, .duration = 0x12c, .delay = 0xce4, .onStart = W_SoleSolution_bgStart, .onComplete = W_SoleSolution_bgDone, .ctx = w }); if (w->lastFiringInterval != Weapon_PInterval(w)) { w->lastFiringInterval = Weapon_PInterval(w); Weapon_ResetFiringTimer(w); } } static void W_SoleSolution_Update(Weapon *w, float delta) { base_Update(w, delta); if (!Galaxy.ok) return; w->pfxEmitter->x = Core.Player->s.x, w->pfxEmitter->y = Core.Player->s.y; w->pfx->wellX = Core.Player->s.x, w->pfx->wellY = Core.Player->s.y + 0x10; Galaxy.time += delta / 1000; if (w->image.scaleX > 0) Galaxy_render(w->galaxyForce); // galaxy.setUniform('force.value'): la texture serve solo quando si vede } // CleanUp: StopSound di SoleSAnti / SoleSFirst / SoleSSecond (Weapon_CleanUp generico non li ferma: solo a fine partita) static const WeaponVT W_SoleSolution = { BASE, .bullet = &B_SoleSolution, .ctor = W_SoleSolution_ctor, .PInterval = W_SoleSolution_PInterval, .PPower = W_SoleSolution_PPower, .MakeLevelOne = W_SoleSolution_MakeLevelOne, .Fire = W_SoleSolution_Fire, .Update = W_SoleSolution_Update, .OnWeaponAdded = W_SoleSolution_OnWeaponAdded }; // WeaponFactory.GetWeapon (0x9ff0): i tipi non ancora tradotti restano fuori dal LevelUpFactory // --- Foscari: attacchi forzati del personaggio (0xb7e6 e affini: meleeA / rangedA) --------------------------------------- static void Player_forcedAnimDone(void *ctx) { Player *p = ctx; p->isAnimForced = 0, p->canFlipX = 1; p->s.onAnimationComplete = NULL; anims_play(&p->s, &p->walk, 0); } static void Player_OnMeleeAttackAnim(Player *p) { if (!p->hasMeleeA) return; p->isAnimForced = 1, p->canFlipX = 0; p->s.onAnimationComplete = Player_forcedAnimDone; anims_play(&p->s, &p->meleeA, 0); } static void Player_OnRangedAttackAnim(Player *p) { if (!p->hasRangedA) return; p->isAnimForced = 1; p->s.onAnimationComplete = Player_forcedAnimDone; anims_play(&p->s, &p->meleeA, 0); } static void fx_init(Sprite *s, const char *frame, int add) { // scene.add.image(...).setVisible(false) sprite_init(s, frame ? frame_get("vfx", frame) : NULL, 0, 0); s->blendAdd = add, s->visible = 0; children_add(s); } static void Circle_draw(Sprite *s) { // scene.add.circle: raggio in width, scala e tinta dello sprite, ADD if (!s->visible || s->scaleX <= 0) return; BeginBlendMode(BLEND_ADDITIVE); DrawCircle((int)roundf(s->x - camera_scrollX), (int)roundf(s->y - camera_scrollY), s->width * s->scaleX, hexc(s->tint, s->alpha)); EndBlendMode(); } static void Ribbon_draw(Sprite *s) { Bullet *b = s->owner; if (s->visible && b->npos > 1) Rope_drawH(b->ropePts, b->npos, b->trailFrame, 1, s->alpha, b->trailAdd, 0); } static void Ribbon_update(Bullet *b, float x, float y, int max) { // RibbonTrail.trailUpdate (0x7c1) memmove(&b->ropePts[1], &b->ropePts[0], (max - 1) * sizeof(Vector2)); b->ropePts[0] = (Vector2){ x, y }; if (b->npos < max) b->npos++; } static void Ribbon_init(Bullet *b, const char *frame, int add) { sprite_init(&b->trail, NULL, 0, 0); b->trail.owner = b, b->trail.draw = Ribbon_draw, b->trail.visible = 0; b->trailFrame = frame_get("vfx", frame), b->trailAdd = add; children_add(&b->trail); } static void B_despawnIfActive(void *ctx) { Bullet *b = ctx; if (b->s.active) Bullet_DeSpawn(b); } static void Sprite_hide(void *ctx) { ((Sprite *)ctx)->visible = 0; } static void B_disableBody(void *ctx) { ((Bullet *)ctx)->s.body.enable = 0; } // --- B_Sword (0x107b3): il fendente; SetDetune arriva dopo OnRecycle, il suono usa quello del giro prima (sic) ------------ static void B_Sword_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); b->s.alpha = 1; sprite_setScale(&b->s, 0); tween_stop(b->tween), tween_stop(b->tween2); b->tween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, PixelScale * Weapon_PArea(b->weapon) } }, .nprops = 1, .duration = 0x64 }); b->tween2 = tweens_add((TweenConfig){ .props = { { &b->s.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x64, .delay = 0x64, .onComplete = B_despawnIfActive, .ctx = b }); int flip = Core.Player->s.flipX ? b->indexInWeapon % 2 != 1 : b->indexInWeapon % 2 == 1; b->s.x += flip ? -0x40 : 0x40, b->s.y -= 0x10; b->s.flipY = b->indexInWeapon % 2 == 1, b->s.flipX = flip; Sound_PlaySound("Attack1", 1, 1, -0x64 * b->indexInWeapon + 0x190 * b->detuneMul, 0, 0); } static void B_Sword_ctor(Bullet *b) { b->tween = b->tween2 = (TweenRef){ -1, 0 }; } static const BulletVT B_Sword = { "vfx", "slash_sword.png", B_Sword_ctor, NULL, B_Sword_OnRecycle }; // --- B_SwordFinisher (0x?): il colpo a terra, la crepa resta quattro secondi ------------------------------------------------- static void W_Sword_shake(void *ctx) { (void)ctx; Weapon_ScreenShake(4); } static void B_Finisher_ctor(Bullet *b) { fx_init(&b->kanji, "ground.png", 0); // crackSprite sprite_setTint(&b->kanji, 0); fx_init(&b->lightning, "ground2.png", 1); // highlightSprite sprite_setTint(&b->lightning, 0xff6600); fx_init(&b->flash, "Hit1.png", 0); // impactSprite b->Pfx = particles_add(); b->PfxEmitter = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "rock0000.png"), frame_get("vfx", "rock0010.png"), frame_get("vfx", "rock0020.png"), frame_get("vfx", "rock0030.png"), frame_get("vfx", "rock0040.png") }, .nframes = 5, .quantity = 5, .lifespan = ERND(0x258, 0x44c), .rotate = ERND(0, 0x168), .angle = ERND(0xe1, 0x13b), .speed = ERND(0x32, 0x190), .scale = ERANGE(0.5f, 0), .gravityY = 0x190, .tint = 0x2c1f16, .flowEveryFrame = 1, .on = 0 }); } static void B_Finisher_bodyOff(void *ctx) { Bullet *b = ctx; b->s.body.enable = 0; emitter_stop(b->PfxEmitter); } static void B_Finisher_impactDone(void *ctx) { Bullet *b = ctx; sprite_setScale(&b->flash, 0), b->flash.visible = 0; } static void B_Finisher_OnRecycle(Bullet *b) { Weapon *w = b->weapon; float a = Weapon_PArea(w); Bullet_OnRecycle(b); b->s.visible = 0, sprite_setScale(&b->s, 0), b->indexInWeapon = 0; b->s.alpha = 1; b->s.x += Core.Player->s.flipX ? -0x40 : 0x40, b->s.y -= 0x10; float hd = -game_height; Sprite *hl = &b->lightning, *cr = &b->kanji, *im = &b->flash; hl->x = cr->x = im->x = b->s.x, hl->y = cr->y = im->y = b->s.y; hl->alpha = 0, cr->alpha = 1, hl->visible = cr->visible = im->visible = 1; hl->depth = hd - 1, cr->depth = hd, im->depth = 0; sprite_setScale(hl, 0), sprite_setScale(cr, 0), sprite_setScale(im, 0); b->PfxEmitter->c.scale = ERANGE(0.5f * a, 0); b->PfxEmitter->x = b->s.x, b->PfxEmitter->y = b->s.y - 8; emitter_start(b->PfxEmitter); tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, 3 * a } }, .nprops = 1, .duration = 0x64, .onComplete = W_Sword_shake }); tweens_add((TweenConfig){ .props = { { &im->scaleX, &im->scaleY, 6 * a } }, .nprops = 1, .duration = 0x64, .onComplete = B_Finisher_impactDone, .ctx = b }); tweens_add((TweenConfig){ .props = { { &b->s.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x64, .delay = 0x64, .onComplete = B_Finisher_bodyOff, .ctx = b }); float s = 3 * a * (0x39 / 128.0f); // spriteRatio tweens_add((TweenConfig){ .props = { { &hl->scaleX, NULL, 1.05f * s }, { &hl->scaleY, NULL, 0.95f * s }, { &cr->scaleX, NULL, 1.05f * s } }, .nprops = 3, .duration = 0x78 }); tweens_add((TweenConfig){ .props = { { &cr->scaleY, NULL, 0.95f * s } }, .nprops = 1, .duration = 0x78 }); tweens_add((TweenConfig){ .props = { { &hl->y, NULL, b->s.y - 4 } }, .nprops = 1, .duration = 0x384, .delay = 0x64 }); tweens_add((TweenConfig){ .props = { { &hl->alpha, NULL, 0.65f } }, .nprops = 1, .duration = 0x1c2, .delay = 0x64, .yoyo = 1 }); tweens_add((TweenConfig){ .props = { { &cr->alpha, NULL, 0.65f } }, .nprops = 1, .duration = 0x1f4, .delay = 0x1f4 }); tweens_add((TweenConfig){ .props = { { &cr->alpha, NULL, 0 } }, .nprops = 1, .duration = 0x3e8, .delay = 0xbb8, .onComplete = B_despawnIfActive, .ctx = b }); Sound_PlaySound("Attack2", 1, 1, 0, 0, 0); } static void B_Finisher_DeSpawn(Bullet *b) { b->lightning.visible = b->kanji.visible = 0; base_DeSpawn(b); } static const BulletVT B_SwordFinisher = { "vfx", "slash_sword.png", B_Finisher_ctor, NULL, B_Finisher_OnRecycle, NULL, NULL, B_Finisher_DeSpawn }; // --- B_Legionnaire (0x?): la copia del personaggio che cammina ---------------------------------------------------------------- static void B_Legion_stop(void *ctx) { Bullet *b = ctx; b->isGrounded = 0; anims_stop(&b->s); sprite_setVelocity(&b->s, 0, 0); } static void B_Legion_ctor(Bullet *b) { static const unsigned T[4] = { 0xa14444, 0x7f7070, 0xff7070, 0xc37070 }; // semplificazione: le quattro tinte d'angolo, col colore medio b->_speed = 2; sprite_setTint(&b->s, T[b->indexInWeapon % 4]); b->s.alpha = 0; b->alphaTween = b->despawnTween = (TweenRef){ -1, 0 }; } static void B_Legion_OnRecycle(Bullet *b) { Weapon *w = b->weapon; Bullet_OnRecycle(b); if (b->alreadyRecycled) return; b->alreadyRecycled = 1; anims_play(&b->s, &Core.Player->walk, 0); // semplificazione: la camminata del giocatore e' quella del suo skin Vector2 *d = &Core.Player->lastFacedDirection; // ApplyPlayerFacingVelocity(false) col TrueSpeed di questa classe float l = sqrtf(d->x * d->x + d->y * d->y), v = Weapon_PSpeed(w) * PlayerPxSpeed * Core.Player->moveSpeed * b->_speed; if (l > 0) d->x /= l, d->y /= l; if (d->x == 0 && d->y == 0) d->x = 1; sprite_setVelocity(&b->s, v * d->x, v * d->y); b->s.flipX = b->s.body.velocity.x < 0; sprite_setScale(&b->s, fmaxf(1, Weapon_PArea(w) - 0.4f)); b->isGrounded = 1; // isMoving b->s.alpha = 0; tween_stop(b->alphaTween), tween_stop(b->despawnTween); b->alphaTween = tweens_add((TweenConfig){ .props = { { &b->s.alpha, NULL, 0.65f } }, .nprops = 1, .duration = 0xc8 }); b->despawnTween = tweens_add((TweenConfig){ .props = { { &b->s.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x1f4, .delay = Weapon_PDuration(w), .onStart = B_Legion_stop, .onComplete = B_despawnIfActive, .ctx = b }); } static void B_Legion_DeSpawn(Bullet *b) { base_DeSpawn(b); b->alreadyRecycled = 0; } static void B_Legion_Update(Bullet *b, float delta) { (void)delta; if (b->isGrounded) emitter_emitParticleAt(b->weapon->SmokeEmitter, b->s.x, b->s.y + 0.35f * b->s.height * b->s.scaleY, 0); } static const BulletVT B_Legionnaire = { "vfx", "Rings3.png", B_Legion_ctor, NULL, B_Legion_OnRecycle, NULL, B_Legion_Update, B_Legion_DeSpawn }; // --- W_Sword (0x166c0) / W_Legionnaire (0x12a4c): ogni quinto giro, l'ultimo colpo e' il finisher -------------------------- typedef struct { Weapon *w; int index, detune, retal, finisher; } SwordShot; static void W_Sword_one(const SwordShot *c) { Weapon *w = c->w; float x = Core.Player->s.x, y = Core.Player->s.y; if (c->finisher) { BulletPool_SpawnAt(w->finisherPool, x, y, w, c->index); return; } Bullet *b = BulletPool_SpawnAt(c->retal ? w->retaliationPool : w->pool, x, y, w, c->index); if (b) b->detuneMul = c->detune; } static void W_Sword_later(void *ctx) { W_Sword_one(ctx); } static void W_Sword_melee(void *ctx) { (void)ctx; Player_OnMeleeAttackAnim(Core.Player); } static void W_Sword_Fire(Weapon *w) { static SwordShot shots[256]; static int shot_i; int retal = w->retalNext; w->retalNext = 0; if (w->level >= 5 || w->canDoFinisher) w->firingCounter++; float amount = Weapon_PAmount(w); int detune = w->firingCounter, isF = w->firingCounter == 5; float fIdx = isF ? amount - 1 : -1; if (isF) { time_removeEvent(w->MeleeAnimEvent); w->MeleeAnimEvent = time_addEvent(fmaxf(0, w->repeatInterval * fIdx - 0x118), 0, 0, W_Sword_melee, NULL); } if (w->firingCounter >= 5) w->firingCounter = 0; W_Sword_one(&(SwordShot){ w, 0, detune, retal, !(fIdx > 0 || fIdx == -1) }); for (int i = 1; i < amount; i++) { if (w->repeatInterval * i > 0) { SwordShot *c = &shots[shot_i++ & 255]; *c = (SwordShot){ w, i, detune, retal, fIdx == i }; w->lastShotTimer = time_addEvent(w->repeatInterval * i, 0, 0, W_Sword_later, c); } else W_Sword_one(&(SwordShot){ w, i, detune, retal, 0 }); } if (w->lastFiringInterval != Weapon_PInterval(w)) w->lastFiringInterval = Weapon_PInterval(w), Weapon_ResetFiringTimer(w); } static void W_Sword_canRetaliate(void *ctx) { ((Weapon *)ctx)->canRetaliate = 1; } static void W_Sword_OnPlayerHit(void *ctx) { Weapon *w = ctx; if (!w->canRetaliate) return; w->canRetaliate = 0; time_removeEvent(w->RetaliationTimer); w->RetaliationTimer = time_addEvent(0x5dc, 0, 0, W_Sword_canRetaliate, w); w->retalNext = 1; w->vt->Fire(w); } static void W_Sword_ctor(Weapon *w) { w->canRetaliate = 1; w->RetaliationTimer = w->MeleeAnimEvent = (Timer){ -1, 0 }; PlayerEvents_add(EV_PLAYER_RECEIVEDDAMAGE, W_Sword_OnPlayerHit, w); PlayerEvents_add(EV_PLAYER_LOSTSHIELD, W_Sword_OnPlayerHit, w); } static void W_Sword_OnStart(Weapon *w) { base_OnStart(w); w->retaliationPool = BulletPool_new(w, &B_Sword); w->finisherPool = BulletPool_new(w, &B_SwordFinisher); BulletPool *p[2] = { w->retaliationPool, w->finisherPool }; for (int k = 0; k < 2; k++) { physics_addOverlap(&p[k]->group, &Core.Destructibles, Weapon_onBulletOverlapsDestuctible, w); physics_addOverlap(&p[k]->group, &Core.Enemies, Weapon_onBulletOverlapsEnemy_Retaliation, w); } } static const WeaponVT W_Sword = { BASE, .bullet = &B_Sword, .ctor = W_Sword_ctor, .OnStart = W_Sword_OnStart, .Fire = W_Sword_Fire, .CheckArcanas = CA_slash, .onBulletOverlapsEnemy = W_canCrit_onBulletOverlapsEnemy }; static void W_Legion_ctor(Weapon *w) { W_Sword_ctor(w); w->canDoFinisher = 1; fx_init(&w->image, "foscari.png", 0); // cursor: non si vede mai w->image.alpha = 0.65f, w->image.depth = game_height; w->pfx = particles_add(); w->SmokeEmitter = particles_createEmitter(w->pfx, (EmitterConfig){ .frames = { frame_get("vfx", "Smoke1.png"), frame_get("vfx", "Smoke2.png") }, .nframes = 2, .speed = ERND(0xa, 0x14), .quantity = 2, .rotate = ERND(0, 0x168), .lifespan = ERND(0x32, 0x96), .alpha = ERANGE(0.65f, 0), .scale = ERND(0.5f, 1.25f), .tint = 0xffeedd, .on = 0 }); } static void W_Legion_OnStart(Weapon *w) { W_Sword_OnStart(w); w->legionnairePool = BulletPool_new(w, &B_Legionnaire); physics_addOverlap(&w->legionnairePool->group, &Core.Enemies, Weapon_onBulletOverlapsEnemy_Retaliation, w); } static void W_Legion_Fire(Weapon *w) { W_Sword_Fire(w); float x = w->image.x, y = w->image.y, n = Weapon_PAmount(w); BulletPool_SpawnAt(w->legionnairePool, x, y, w, 0); if (n >= 1) for (int i = 0; i < (int)n; i++) { // Circle.getPoints(n) float a = 2 * PI * i / (int)n; BulletPool_SpawnAt(w->legionnairePool, x + 0x40 * cosf(a), y + 0x40 * sinf(a), w, i); } } static void W_Legion_Update(Weapon *w, float delta) { base_Update(w, delta); Vector2 d = Core.Player->lastFacedDirection; float a = atan2f(-d.y, -d.x); w->image.x = Core.Player->s.x + cosf(a) * game_width * 0.5f, w->image.y = Core.Player->s.y + sinf(a) * game_height * 0.5f; w->image.angle = a * (180 / PI); } static const WeaponVT W_Legionnaire = { BASE, .bullet = &B_Sword, .ctor = W_Legion_ctor, .OnStart = W_Legion_OnStart, .Fire = W_Legion_Fire, .Update = W_Legion_Update, .CheckArcanas = CA_slash, .onBulletOverlapsEnemy = W_canCrit_onBulletOverlapsEnemy }; // --- B_FlashArrow (0xb048) ------------------------------------------------------------------------------------------------- static void W_Millionaire_Fire(Weapon *w, float x, float y, int count); static const WeaponVT W_Millionaire; static void B_Flash_Bounce(void *ctx) { Bullet *b = ctx; if (b->bounces > 0) b->bounces--, b->s.body.velocity.x *= -1, b->s.body.velocity.y *= -1, b->n_hit = 0; else b->s.body.collideWorldBounds = 0; } static void B_Flash_ctor(Bullet *b) { sprite_setScale(&b->s, PixelScale * Weapon_PArea(b->weapon)); b->s.angle = -0x5a; b->Pfx = particles_add(); particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "WhiteDot.png") }, .nframes = 1, .angle = EOP(0), .speed = EOP(0), .quantity = 1, .lifespan = EOP(0x12c), .alpha = ERANGE(1, 0), .on = 0 }); fx_init(&b->flatSprite, "disc.png", 1), fx_init(&b->sideSprite, "WhiteLineH.png", 1), fx_init(&b->starSprite, "blurredSharpStar.png", 1); } static void B_Flash_OnRecycle(Bullet *b) { Weapon *w = b->weapon; Bullet_OnRecycle(b); body_setCircle(&b->s.body, 8, b->s.body.offset.x, b->s.body.offset.y); b->_speed = 2; sprite_setScale(&b->s, Weapon_PArea(w)); b->s.y -= 0x16; Bullet_ApplyPlayerFacingVelocity(b); b->hasHitFirstEnemy = 0; Sound_PlaySound("Shot", w->volume ? w->volume : 0.4f, 1, -0x64 * b->indexInWeapon, 0xc8, 0xa); Bullet_activateBounce(b, B_Flash_Bounce); } static void B_Flash_VFX(Bullet *b) { // PlayUselessVFX Sprite *d = &b->flatSprite, *l = &b->sideSprite, *f = &b->starSprite; d->angle = l->angle = b->s.angle + 0x5a; sprite_setScale(d, 1), sprite_setScale(l, 1), sprite_setScale(f, 0); d->alpha = l->alpha = f->alpha = 1, d->visible = l->visible = f->visible = 1; d->x = l->x = f->x = b->s.x, d->y = l->y = f->y = b->s.y; tweens_add((TweenConfig){ .props = { { &l->alpha, NULL, 0 }, { &l->scaleX, NULL, 5 }, { &d->alpha, NULL, 0 } }, .nprops = 3, .duration = 0x64 }); tweens_add((TweenConfig){ .props = { { &d->scaleX, NULL, 5 } }, .nprops = 1, .duration = 0x64 }); tweens_add((TweenConfig){ .props = { { &f->alpha, NULL, 0 }, { &f->angle, NULL, 0x2d0 }, { &f->scaleX, &f->scaleY, 2 } }, .nprops = 3, .duration = 0xc8 }); } static void B_Flash_OnHasHitAnObject(Bullet *b, void *o, int isDead) { (void)o; if (isDead || b->hasHitFirstEnemy) return; b->hasHitFirstEnemy = 1; if (po_is("FlashingVFXEnabled")) B_Flash_VFX(b); sprite_setVelocity(&b->s, 2 * b->s.body.velocity.x, 2 * b->s.body.velocity.y); if (b->weapon->vt == &W_Millionaire) W_Millionaire_Fire(b->weapon, b->s.x, b->s.y, 4); // TrueWeapon.Millionaire: vuoto su FLASHARROW } static void B_Flash_Update(Bullet *b, float delta) { (void)delta; manager_emitParticleAt(b->Pfx, b->s.x, b->s.y); } static const BulletVT B_FlashArrow = { "vfx", "2Arrow.png", B_Flash_ctor, NULL, B_Flash_OnRecycle, B_Flash_OnHasHitAnObject, B_Flash_Update }; // --- B_Millionaire (0x?): la freccia dal cielo, spezzandosi diventa l'area di danno ------------------------------------------ static void B_Mill_ctor(Bullet *b) { const Frame *F[3] = { frame_get("vfx", "PfxYellow.png"), frame_get("vfx", "PfxPurple.png"), frame_get("vfx", "PfxLine.png") }; b->_speed = 2; b->PositionTween = (TweenRef){ -1, 0 }; b->HitboxTimer = b->ExpireTimer = (Timer){ -1, 0 }; fx_init(&b->GroundFx, NULL, 1); b->GroundFx.draw = Circle_draw, b->GroundFx.width = 0x10, b->GroundFx.alpha = 0.1f, b->GroundFx.tint = 0xff; b->Pfx = particles_add(); b->PfxEmitter1 = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { F[0], F[1], F[2] }, .nframes = 3, .speed = EOP(1), .quantity = 1, .rotate = EOP(0x5a), .lifespan = EOP(0x12c), .alpha = ERANGE(1, 0), .scale = ERANGE(1, 2), .hasZone = 1, .zoneRadius = 8, .on = 0 }); b->PfxEmitter2 = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { F[0], F[1], F[2] }, .nframes = 3, .speed = EOP(1), .quantity = 1, .rotate = EOP(0x5a), .lifespan = EOP(0x12c), .alpha = ERANGE(0.2f, 0), .scale = ERANGE(1, 0.5f), .blendAdd = 1, .hasZone = 1, .zoneRadius = 8, .on = 0 }); b->PfxExplosion = particles_add(); particles_createEmitter(b->PfxExplosion, (EmitterConfig){ .frames = { frame_get("vfx", "disc.png") }, .nframes = 1, .quantity = 1, .lifespan = EOP(0x64), .alpha = ERANGE(0.65f, 0.35f), .scale = ERANGE(PixelScale / 4, 2 * PixelScale), .on = 0 }); particles_createEmitter(b->PfxExplosion, (EmitterConfig){ .frames = { frame_get("vfx", "blurredSharpStar.png") }, .nframes = 1, .quantity = 1, .rotate = ERND(0, 0x168), .lifespan = EOP(0x64), .alpha = ERANGE(0.35f, 0.15f), .scale = ERANGE(PixelScale / 4, PixelScale), .on = 0 }); } static void B_Mill_OnRecycle(Bullet *b) { Weapon *w = b->weapon; Bullet_OnRecycle(b); b->_speed = 2; body_setCircle(&b->s.body, 0x10, -8, -8); sprite_setScale(&b->s, PixelScale); b->s.flipX = 0, b->isBroken = 0, b->s.body.enable = 0, b->isCullable = 0; time_removeEvent(b->HitboxTimer), time_removeEvent(b->ExpireTimer); int y = frand() >= 0.5f; sprite_setFrame(&b->s, frame_get("vfx", frand() >= 0.5f ? "2Arrow3Y.png" : "2Arrow3P.png")); // (sic) due estrazioni indipendenti b->s.blendAdd = 1; b->GroundFx.tint = y ? 0xffff00 : 0x8800ff; float r = 8 * Weapon_PArea(w) * 3; int q = 1 + (int)floorf(w->level / 3.0f); b->PfxEmitter1->c.zoneRadius = b->PfxEmitter2->c.zoneRadius = r; b->PfxEmitter1->c.quantity = b->PfxEmitter2->c.quantity = q; b->startingPoint = (Vector2){ b->s.x, b->s.y }; // target b->s.x = b->startingPoint.x + (frand() - 0.5f) * game_width * 0.5f, b->s.y = Core.Player->s.y - 0.6f * game_height; float a = frand() * (2 * PI), d = 0xf0 * frand(); b->startingPoint.x += cosf(a) * d, b->startingPoint.y += sinf(a) * d; b->s.depth = b->s.y - Core.Player->s.y + game_height; b->s.visible = po_is("FlashingVFXEnabled"); } static void B_Mill_expire(void *ctx) { Bullet *b = ctx; b->GroundFx.visible = 0; time_removeEvent(b->HitboxTimer), time_removeEvent(b->ExpireTimer); Bullet_DeSpawn(b); } static void B_Mill_Break(void *ctx) { Bullet *b = ctx; if (b->isBroken) return; b->isBroken = 1, b->s.visible = 0; sprite_setVelocity(&b->s, 0, 0); b->n_hit = 0, b->s.body.enable = 1; float a = Weapon_PArea(b->weapon); b->GroundFx.x = b->s.x, b->GroundFx.y = b->s.y; sprite_setScale(&b->GroundFx, a); b->GroundFx.visible = po_is("FlashingVFXEnabled"); sprite_setScale(&b->s, a); b->ExpireTimer = time_addEvent(0x64, 0, 0, B_Mill_expire, b); float dp = b->s.y - Core.Player->s.y - 0.5f * game_height; if (po_is("FlashingVFXEnabled")) manager_emitParticleAt(b->PfxExplosion, b->s.x, b->s.y), b->Pfx->s.depth = dp; b->GroundFx.depth = dp; Sound_PlaySound("Holywater", 0.35f, 2, -0xc8 + 0x32 * b->indexInWeapon, 0xc8, 0xc); } static void B_Mill_setDisplayDirection(Bullet *b, int flip) { float k = 0.5f * game_width; b->s.flipX = flip; b->s.x = Core.Player->s.x + (flip ? k : -k), b->s.y = b->startingPoint.y - k; tween_stop(b->PositionTween); b->PositionTween = tweens_add((TweenConfig){ .props = { { &b->s.x, NULL, b->startingPoint.x }, { &b->s.y, NULL, b->startingPoint.y } }, .nprops = 2, .duration = 0x64, .onComplete = B_Mill_Break, .ctx = b }); } static void B_Mill_Update(Bullet *b, float delta) { (void)delta; if (b->isBroken) manager_emitParticleAt(b->Pfx, b->s.x, b->s.y); } static void B_Mill_DeSpawn(Bullet *b) { b->isCullable = 1; time_removeEvent(b->HitboxTimer), time_removeEvent(b->ExpireTimer); b->GroundFx.visible = 0; base_DeSpawn(b); } static const BulletVT B_Millionaire = { "vfx", "2Arrow3.png", B_Mill_ctor, NULL, B_Mill_OnRecycle, NULL, B_Mill_Update, B_Mill_DeSpawn }; // --- W_FlashArrow (0x47c3) / W_Millionaire (0x9dc2) ---------------------------------------------------------------------------- static float W_Flash_PPower(Weapon *w) { return Might_P(w->power * Weapon_PAmount(w)); } static void W_Flash_rangedAnim(void *ctx) { (void)ctx; Player_OnRangedAttackAnim(Core.Player); } static void W_Flash_PlayNext(Weapon *w) { time_removeEvent(w->RangedAnimEvent); w->RangedAnimEvent = time_addEvent(fmaxf(0, Weapon_PInterval(w) - 0x78), 0, 0, W_Flash_rangedAnim, NULL); } static void W_Flash_OnStart(Weapon *w) { base_OnStart(w); w->RangedAnimEvent = (Timer){ -1, 0 }; W_Flash_PlayNext(w); w->canCrit = 1; } static void W_Flash_Fire(Weapon *w) { Weapon_FireOneBullet(w, Core.Player->s.x, Core.Player->s.y, 0); W_Flash_PlayNext(w); if (w->lastFiringInterval != Weapon_PInterval(w)) w->lastFiringInterval = Weapon_PInterval(w), Weapon_ResetFiringTimer(w); } static void CA_flash(Weapon *w) { if (ARC_T(7)) w->penetrating = 0xffff, w->bounces = 3, IronBlue_noWalls(w); base_CheckArcanas(w); } static const WeaponVT W_FlashArrow = { BASE, .bullet = &B_FlashArrow, .PPower = W_Flash_PPower, .OnStart = W_Flash_OnStart, .Fire = W_Flash_Fire, .CheckArcanas = CA_flash, .onBulletOverlapsEnemy = W_canCrit_onBulletOverlapsEnemy }; static Weapon *Core_coinListener; // Core.OnCoinPickup: la usa solo W_Millionaire, che e' unica static void W_Mill_OnCoinPickup(float value) { if (Core_coinListener) Core_coinListener->CoinsQueue += value ? value : 1; } static void W_Mill_ctor(Weapon *w) { w->explosionType = "SEC_MILLIONAIRE"; static const unsigned T[2] = { 0xffff00, 0xffccff }; for (int k = 0; k < 2; k++) { Sprite *r = &w->rays[k]; sprite_init(r, frame_get("vfx", "rays.png"), 0.5f * game_width, 0); sprite_setOrigin(r, 0, 1); r->angle = 0x5a, r->alpha = 0, r->scrollFactor0 = 1, r->blendAdd = 1, r->tint = T[k]; children_add(r); w->millTween[k] = (TweenRef){ -1, 0 }; } Core_coinListener = w; } static void W_Mill_RaysVFX(Weapon *w, int flip, int repeat) { for (int k = 0; k < 2; k++) { Sprite *r = &w->rays[k]; tween_stop(w->millTween[k]); r->x = flip ? game_width + 0x30 : -0x30, r->y = -0x30, r->alpha = 0; r->angle = flip ? (k ? 0xb9 : 0xaf) : (k ? 0x5f : 0x55); r->scaleX = flip ? 8 : 4, r->scaleY = flip ? 4 : 8; w->millTween[k] = tweens_add((TweenConfig){ .props = { { &r->alpha, NULL, 0.25f } }, .nprops = 1, .yoyo = 1, .repeat = repeat, .duration = 0x32 }); } } typedef struct { Weapon *w; float x, y, amount; int flip; } MillShot; static void W_Mill_one(const MillShot *c) { for (int j = 0; j < c->amount; j++) { Bullet *b = Weapon_SpawnExplosionAt(c->w, c->x, c->y, j); if (b) B_Mill_setDisplayDirection(b, c->flip); } } static void W_Mill_later(void *ctx) { W_Mill_one(ctx); } static void W_Millionaire_Fire(Weapon *w, float x, float y, int count) { static MillShot shots[256]; static int shot_i; float amount = Weapon_PAmount(w), total = count * amount; int flip = x < Core.Player->s.x; w->secondaryPower = w->power; MillShot now = { w, x, y, amount, flip }; for (int i = 0; i < total; i++) { if (w->repeatInterval * i > 0) { MillShot *c = &shots[shot_i++ & 255]; *c = now; w->lastShotTimer = time_addEvent(w->repeatInterval * i, 0, 0, W_Mill_later, c); } else W_Mill_one(&now); } if (po_is("FlashingVFXEnabled")) W_Mill_RaysVFX(w, flip, (int)(2 * amount)); } static void W_Mill_Update(Weapon *w, float delta) { base_Update(w, delta); w->CoinsTime += delta; if (w->CoinsTime < 0x64) return; w->CoinsTime = 0; if (w->CoinsQueue < 1) return; w->CoinsQueue -= 1; int left = Core.Player->lastFacedDirection.x < 0; W_Millionaire_Fire(w, Core.Player->s.x + 0.25f * game_width * (left ? -1 : 1), Core.Player->s.y, 1); } static const WeaponVT W_Millionaire = { BASE, .bullet = &B_FlashArrow, .ctor = W_Mill_ctor, .PPower = W_Flash_PPower, .OnStart = W_Flash_OnStart, .Fire = W_Flash_Fire, .Update = W_Mill_Update, .CheckArcanas = CA_flash, .onBulletOverlapsEnemy = W_canCrit_onBulletOverlapsEnemy }; // --- B_ShadowServant (0xf72e) / _Counter (0x15aa6): il serpente che punta un nemico a caso e sale in fumo ---------------------- static Animation SnakeIdle[2], SnakeDie[2]; static void B_Shadow_ctor(Bullet *b) { Weapon *w = b->weapon; b->_speed = 0.5f; sprite_setFrame(&b->s, frame_get("vfx", w->snakeKind ? "bubbleSphere3.png" : "bubbleSphere2.png")); fx_init(&b->flash, NULL, 0); // DisplaySprite anims_play(&b->flash, &SnakeIdle[w->snakeKind], 0); Ribbon_init(b, w->snakeKind ? "BlackTrail2.png" : "BlackTrail.png", 0); b->trail.depth = b->s.depth; } static void B_Shadow_OnRecycle(Bullet *b) { Bullet_OnRecycle(b); sprite_setScale(&b->s, 1); body_setCircle(&b->s.body, 8, b->s.body.offset.x, b->s.body.offset.y); b->s.body.enable = 1, b->s.visible = 0, b->trail.visible = 0, b->isExploding = 0; b->counterVal = 1; b->flash.visible = 1; anims_play(&b->flash, &SnakeIdle[b->weapon->snakeKind], 0); b->s.x += (frand() - 0.5f) * b->indexInWeapon * 0xa, b->s.y += (frand() - 0.5f) * b->indexInWeapon * 0xa; Bullet_AimForRandomEnemy(b); Sound_PlaySound("MagicMissile", 0.1f, 1, -0x64 * b->indexInWeapon - 0x1f4, 0xc8, 3); } static void B_Shadow_exploStart(void *ctx) { Bullet *b = ctx; sprite_setScale(&b->s, 0), b->s.visible = po_is("FlashingVFXEnabled"); } static void B_Shadow_exploUpdate(void *ctx) { Bullet *b = ctx; if (po_is("FlashingVFXEnabled")) manager_emitParticleAt(b->weapon->pfx, b->s.x, b->s.y); } static void B_Shadow_exploDone(void *ctx) { Bullet *b = ctx; b->s.visible = 0, b->s.body.enable = 0; } static void B_Shadow_followUpdate(void *ctx) { Bullet *b = ctx; b->jubX = b->s.x + 0x28 * b->counterVal * sinf(0.1f * b->jubY); b->trail.alpha = 0.1f + 0.55f * b->counterVal; } static void B_Shadow_followDone(void *ctx) { Bullet *b = ctx; b->trail.visible = 0; B_despawnIfActive(b); } static void B_Shadow_Explode(Bullet *b) { if (b->isExploding) return; b->isExploding = 1; anims_play(&b->flash, &SnakeDie[b->weapon->snakeKind], 0); sprite_setScale(&b->s, 0), b->s.visible = po_is("FlashingVFXEnabled"); tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, 2 * Weapon_PArea(b->weapon) } }, .nprops = 1, .duration = 0x78, .yoyo = 1, .onStart = B_Shadow_exploStart, .onComplete = B_Shadow_exploDone, .onUpdate = B_Shadow_exploUpdate, .ctx = b }); b->jubX = b->s.x, b->jubY = b->s.y; // TrailFollower b->npos = 0; b->trail.visible = 1, b->trail.alpha = 0.65f; tweens_add((TweenConfig){ .props = { { &b->jubY, NULL, b->s.y - 0xc8 }, { &b->counterVal, NULL, 0 } }, .nprops = 2, .duration = 0x12c, .ease = Ease_SineInOut, .onUpdate = B_Shadow_followUpdate, .onComplete = B_Shadow_followDone, .ctx = b }); } static void B_Shadow_OnHasHitAnObject(Bullet *b, void *o, int isDead) { B_Shadow_Explode(b); if (isDead || !(((Sprite *)o)->groups & Core.Enemies.bit)) return; // sui Destructible res_Debuffs e slow sono undefined Enemy *e = o; Weapon *w = b->weapon; if (e->res_Debuffs >= 1) return; if (e->slow > 0.2f && w->critChancesArray[w->critIndex++ % 1000] < w->chance * Player_PLuck(Core.Player)) e->slow -= 0.05f; } static void B_Shadow_Update(Bullet *b, float delta) { (void)delta; b->flash.x = b->s.x, b->flash.y = b->s.y, b->flash.angle = b->s.angle; if (b->isExploding) Ribbon_update(b, b->jubX, b->jubY, 0x10); b->flash.depth = -game_height; } static void B_Shadow_DeSpawn(Bullet *b) { b->flash.visible = 0; base_DeSpawn(b); } static const BulletVT B_ShadowServant = { "vfx", "bubbleSphere2.png", B_Shadow_ctor, NULL, B_Shadow_OnRecycle, B_Shadow_OnHasHitAnObject, B_Shadow_Update, B_Shadow_DeSpawn }; // --- B_Ophion (0x17bef) ------------------------------------------------------------------------------------------------------- static void B_Oph_clearHits(void *ctx) { ((Bullet *)ctx)->n_hit = 0; } static void B_Oph_ctor(Bullet *b) { static Animation loop; if (!loop.n) make_anim(&loop, "vfx", "Ophion", 0, 0x1f, 4, 0x10, -1); b->_speed = 2, b->s.visible = 0; fx_init(&b->flash, "_OPBubble.png", 0), b->flash.visible = 1; // DisplaySprite fx_init(&b->flash2, "Ophion0000.png", 0), b->flash2.visible = 1; // SnakeSprite anims_play(&b->flash2, &loop, 0); b->Pfx = particles_add(); b->PfxEmitter2 = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "OPpfx.png") }, .nframes = 1, .lifespan = EOP(0x1f4), .rotate = ERND(0, 0x168), .angle = { 0, 0x168, 3, NULL }, .angleSteps = 0x10, .speed = ERND(0x32, 0x50), .quantity = 1, .scale = ERANGE(1, 0), .alpha = ERANGE(0.5f, 0), .frequency = 1, .hasZone = 1, .zoneRadius = 0x10, .flowEveryFrame = 1, .on = 0 }); b->PfxEmitter1 = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "OPpfx2.png") }, .nframes = 1, .lifespan = EOP(0x1f4), .rotate = ERND(0, 0x168), .angle = { 0, 0x168, 3, NULL }, .angleSteps = 0x10, .speed = ERND(0x32, 0x50), .quantity = 1, .scale = ERANGE(1, 0), .alpha = ERANGE(0.5f, 0), .frequency = 1, .hasZone = 1, .zoneRadius = 0x10, .flowEveryFrame = 1, .on = 0 }); float d = -game_height; b->flash2.depth = d - 2, b->Pfx->s.depth = d - 1, b->flash.depth = d; b->HitboxTimer = b->ExpireTimer = (Timer){ -1, 0 }; b->fangTween = b->growTween = b->scaleGroundTween = b->exploTween = b->fadeOutTween = (TweenRef){ -1, 0 }; } static void B_Oph_OnRecycle(Bullet *b) { Weapon *w = b->weapon; Bullet_OnRecycle(b); sprite_setScale(&b->s, 1); body_setCircle(&b->s.body, 0x18, -0xc, -0xc); b->s.body.enable = 1, b->s.visible = 0, b->isExploding = 0; b->PfxEmitter1->c.zoneRadius = 0x10 * Weapon_PArea(w); b->PfxEmitter2->c.quantity = 1 + (int)floorf(w->level / 3.0f); // (sic) setEmitZone e setQuantity sempre sugli stessi: 1 la zona, 2 la quantita' Bullet_AimForRandomEnemy(b); time_removeEvent(b->HitboxTimer); b->HitboxTimer = time_addEvent(w->hitBoxDelay, 1, 0, B_Oph_clearHits, b); } static void B_Oph_Explode2(void *ctx); static void B_Oph_Implode(void *ctx) { Bullet *b = ctx; emitter_stop(b->PfxEmitter1), emitter_stop(b->PfxEmitter2); tween_stop(b->growTween); b->growTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, 0 }, { &b->flash.scaleX, &b->flash.scaleY, 0 }, { &b->flash.alpha, NULL, 1 } }, .nprops = 3, .duration = 0x64, .onComplete = B_Oph_Explode2, .ctx = b }); } static void B_Oph_grown(void *ctx) { Bullet *b = ctx; emitter_start(b->PfxEmitter1), emitter_start(b->PfxEmitter2); tween_stop(b->scaleGroundTween); b->scaleGroundTween = tweens_add((TweenConfig){ .props = { { &b->flash.scaleX, &b->flash.scaleY, 0.9f * b->flash.scaleX } }, .nprops = 1, .duration = 0x64, .yoyo = 1, .repeat = -1 }); } static void B_Oph_Explode(Bullet *b) { if (b->isExploding) return; Weapon *w = b->weapon; float k = 2 * Weapon_PArea(w); Sound_PlaySound("Ophion1", 0.3f, 1, -0xc8 * b->indexInWeapon, 0xc8, 6); if (b->indexInWeapon == 1) Sound_PlaySound("Ophion2", 0.3f, 1, 0, 0xc8, 2); b->isExploding = 1; sprite_setVelocity(&b->s, 0, 0); b->flash.x = b->flash2.x = b->s.x, b->flash.y = b->flash2.y = b->s.y; b->PfxEmitter1->x = b->PfxEmitter2->x = b->s.x, b->PfxEmitter1->y = b->PfxEmitter2->y = b->s.y; tween_stop(b->fangTween), tween_stop(b->growTween), tween_stop(b->scaleGroundTween); b->flash2.alpha = 0, sprite_setScale(&b->flash2, 0); b->fangTween = tweens_add((TweenConfig){ .props = { { &b->flash2.scaleX, &b->flash2.scaleY, 1 }, { &b->flash2.alpha, NULL, 0.65f } }, .nprops = 2, .duration = 0x1f4 }); sprite_setScale(&b->s, 0), sprite_setScale(&b->flash, 0), b->flash.alpha = 1; b->growTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, k }, { &b->flash.scaleX, &b->flash.scaleY, k }, { &b->flash.alpha, NULL, 0.65f } }, .nprops = 3, .duration = 0x1f4, .onComplete = B_Oph_grown, .ctx = b }); time_removeEvent(b->ExpireTimer); b->ExpireTimer = time_addEvent(Weapon_PDuration(w), 0, 0, B_Oph_Implode, b); } static void B_Oph_OnHasHitAnObject(Bullet *b, void *o, int isDead) { (void)o, (void)isDead; B_Oph_Explode(b); } static void B_Oph_fadeIn(void *ctx) { ((Bullet *)ctx)->flash.alpha = 0; } static void B_Oph_Explode2(void *ctx) { Bullet *b = ctx; Weapon *w = b->weapon; float k = 4 * Weapon_PArea(w); Sound_PlaySound("Ophion3", 0.3f, 1, -0xc8 * b->indexInWeapon, 0x1f4, 6); tween_stop(b->fangTween), tween_stop(b->growTween), tween_stop(b->scaleGroundTween); if (w->pfxEmitter) emitter_emitParticleAt(w->pfxEmitter, b->s.x, b->s.y, 0x3c); b->flash2.alpha = 1; tween_stop(b->exploTween); b->exploTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, k }, { &b->flash2.scaleX, &b->flash2.scaleY, k }, { &b->flash2.alpha, NULL, 0 } }, .nprops = 3, .duration = 0xc8, .onComplete = B_disableBody, .ctx = b }); b->flash.alpha = 0; tweens_add((TweenConfig){ .props = { { &b->flash.scaleX, &b->flash.scaleY, k }, { &b->flash.alpha, NULL, 1 } }, .nprops = 2, .duration = 0xc8, .onComplete = B_Oph_fadeIn, .ctx = b }); tweens_add((TweenConfig){ .delay = 0xc8, .props = { { &b->flash.alpha, NULL, 0 } }, .nprops = 1, .duration = 0xc8, .onStart = B_Oph_fadeIn, .onComplete = B_despawnIfActive, .ctx = b }); } static void B_Oph_DeSpawn(Bullet *b) { if (b->indexInWeapon == 1) Sound_StopSound("Ophion2"); emitter_stop(b->PfxEmitter1), emitter_stop(b->PfxEmitter2); base_DeSpawn(b); } static const BulletVT B_Ophion = { "vfx", "bubbleSphere2.png", B_Oph_ctor, NULL, B_Oph_OnRecycle, B_Oph_OnHasHitAnObject, NULL, B_Oph_DeSpawn }; // --- W_ShadowServant (0x17dee), _Counter, W_Ophion (0x5050) --------------------------------------------------------------------- static void W_Shadow_common(Weapon *w, int kind) { if (!SnakeIdle[0].n) { make_anim(&SnakeIdle[0], "vfx", "snakeW_i0", 1, 6, 0, 0xc, -1), make_anim(&SnakeDie[0], "vfx", "snakeW_", 0, 0xb, 0, 0x10, -1); make_anim(&SnakeIdle[1], "vfx", "snakeS_i0", 1, 6, 0, 0xc, -1), make_anim(&SnakeDie[1], "vfx", "snakeS_", 0, 0xb, 0, 0x10, -1); } w->snakeKind = kind; fx_init(&w->image, "summon2.png", 0); // SummonSprite w->image.depth = -game_height; w->imageTween = (TweenRef){ -1, 0 }; w->pfx = particles_add(); w->pfxEmitter = particles_createEmitter(w->pfx, (EmitterConfig){ .frames = { frame_get("vfx", "PfxGray1.png"), frame_get("vfx", "PfxGray2.png"), frame_get("vfx", "PfxPurple2.png"), frame_get("vfx", "PfxPurple3.png") }, .nframes = 4, .angle = ERND(0, 0x168), .rotate = ERND(0, 0x168), .speed = ERND(0x64, 0xc8), .quantity = 2, .lifespan = EOP(0x190), .alpha = ERANGE(1, 0), .scale = ERANGE(1, 1), .on = 0 }); w->pfx->hasWell = 1, w->pfx->wellPower = 1 * 0x14, w->pfx->wellEpsilon = 0x32 * 0x32; } static void W_Shadow_ctor(Weapon *w) { W_Shadow_common(w, 0); } static void W_ShadowC_ctor(Weapon *w) { W_Shadow_common(w, 1); } static void W_Shadow_Fire(Weapon *w) { base_Fire(w); Sprite *s = &w->image; // SummonAnimation sprite_setScale(s, 0), s->visible = 1, s->alpha = 1; tween_stop(w->imageTween); w->imageTween = tweens_add((TweenConfig){ .props = { { &s->scaleX, &s->scaleY, Weapon_PArea(w) }, { &s->alpha, NULL, 0 } }, .nprops = 2, .duration = 0x1f4 }); } static void W_Shadow_Update(Weapon *w, float delta) { base_Update(w, delta); w->image.x = w->pfx->wellX = Core.Player->s.x, w->image.y = w->pfx->wellY = Core.Player->s.y; } static void CA_shadow(Weapon *w) { if (ARC_T(1)) { if (Core_GetHiddenWeapon("SHADOWSERVANT_COUNTER")) return; w->counterWeapon = Aquarius_Add("SHADOWSERVANT_COUNTER", w->level); } base_CheckArcanas(w); } static void CA_ophion(Weapon *w) { if (ARC_T(1)) { if (Core_GetHiddenWeapon("SHADOWSERVANT_COUNTER")) return; Weapon *c = Core_AddHiddenWeapon("SHADOWSERVANT_COUNTER"); w->counterWeapon = c; if (c) c->skipAddingEvolution = 1; while (c && c->level < w->level && Weapon_LevelUp(c)) {} } base_CheckArcanas(w); } static const WeaponVT W_ShadowServant = { BASE, .bullet = &B_ShadowServant, .ctor = W_Shadow_ctor, .Fire = W_Shadow_Fire, .Update = W_Shadow_Update, .CheckArcanas = CA_shadow }; static const WeaponVT W_ShadowServant_Counter = { BASE, .bullet = &B_ShadowServant, .ctor = W_ShadowC_ctor, .Fire = W_Shadow_Fire, .Update = W_Shadow_Update, .CheckArcanas = CA_none }; static void W_Oph_ctor(Weapon *w) { w->skipAddingEvolution = 1; w->pfx = particles_add(); w->pfxEmitter = particles_createEmitter(w->pfx, (EmitterConfig){ .frames = { frame_get("vfx", "OPpfx.png"), frame_get("vfx", "OPpfx2.png"), frame_get("vfx", "PfxPurple2.png"), frame_get("vfx", "PfxPurple3.png") }, .nframes = 4, .angle = ERND(0, 0x168), .rotate = ERND(0, 0x168), .speed = ERND(1, 0x190), .quantity = 4, .lifespan = EOP(0x190), .alpha = ERANGE(0.65f, 0), .scale = ERANGE(1, 0), .on = 0 }); w->pfx->hasWell = 1, w->pfx->wellPower = 0xa * 0xc8, w->pfx->wellEpsilon = 0x1f4 * 0x1f4; } static void W_Oph_Update(Weapon *w, float delta) { base_Update(w, delta); w->pfx->wellX = Core.Player->s.x, w->pfx->wellY = Core.Player->s.y; } static void W_Oph_onBulletOverlapsEnemy(Weapon *w, Bullet *b, Enemy *e) { if (e->isDead || Bullet_HasAlreadyHitObject(b, e, e->isDead)) return; float p = Weapon_PPower(w); if (!e->res_Rosary && w->critChancesArray[w->critIndex++ % 1000] < w->chance * Player_PLuck(Core.Player)) p = e->hp; Enemy_GetDamaged(e, p, (int)w->hitVFX, w->knockback, w->bulletType); w->stats_inflictedDamage += Weapon_PPower(w); } static const WeaponVT W_Ophion = { BASE, .bullet = &B_Ophion, .ctor = W_Oph_ctor, .Update = W_Oph_Update, .CheckArcanas = CA_ophion, .onBulletOverlapsEnemy = W_Oph_onBulletOverlapsEnemy }; // --- B_PrismaticMissile (0x407e) ------------------------------------------------------------------------------------------------- static const WeaponVT W_PrismaticMissile, W_Luminaire; static void B_Prism_ctor(Bullet *b) { b->radius = 0x40, b->_speed = 0, b->s.alpha = 0.5f; fx_init(&b->GroundFx, NULL, 1); b->GroundFx.draw = Circle_draw, b->GroundFx.width = 1, b->GroundFx.alpha = 0.1f, b->GroundFx.tint = 0xff, b->GroundFx.depth = -game_height; b->Pfx = particles_add(); b->pfxEmitterB = particles_createEmitter(b->Pfx, (EmitterConfig){ .frames = { frame_get("vfx", "HitSmokeA.png"), frame_get("vfx", "HitSmokeA2.png") }, .nframes = 2, .lifespan = EOP(0x1f4), .rotate = ERND(0, 0x168), .angle = { 0, 0x168, 3, NULL }, .angleSteps = 0x10, .speed = ERND(0x32, 0x50), .quantity = 1, .scale = ERANGE(1, 0), .alpha = ERANGE(0.25f, 0), .frequency = 1, .blendAdd = 1, .hasZone = 1, .zoneRadius = 0x10, .flowEveryFrame = 1, .on = 0 }); b->Pfx->hasWell = 1, b->Pfx->wellPower = 2 * 0x14, b->Pfx->wellEpsilon = 0x32 * 0x32; Ribbon_init(b, "Gradient3_4px.png", 1); b->trail.depth = 1; b->fadeOutTween = b->scaleTween = b->scaleGroundTween = (TweenRef){ -1, 0 }; } static void B_Prism_groundStart(void *ctx) { Bullet *b = ctx; b->GroundFx.x = b->s.x, b->GroundFx.y = b->s.y, b->GroundFx.visible = 1; b->pfxEmitterB->x = b->s.x, b->pfxEmitterB->y = b->s.y; emitter_start(b->pfxEmitterB); } static void B_Prism_groundDone(void *ctx) { Bullet *b = ctx; b->GroundFx.visible = 0; emitter_stop(b->pfxEmitterB); } static void B_Prism_landed(void *ctx) { Bullet *b = ctx; b->s.body.enable = 1; tween_stop(b->fadeOutTween); b->fadeOutTween = tweens_add((TweenConfig){ .props = { { &b->trail.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x64 }); } static void B_Prism_OnRecycle(Bullet *b) { static const char L[7] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G' }; static const unsigned Col[7] = { 0xff0000, 0xffa500, 0xffff00, 0x8000, 0xff, 0x4b0082, 0xee82ee }; Weapon *w = b->weapon; Bullet_OnRecycle(b); sprite_setScale(&b->s, 1); body_setCircle(&b->s.body, 0x10, b->s.body.offset.x, b->s.body.offset.y); b->s.body.enable = 0, b->isCullable = 0; float fall = fmaxf(0x1f4, 0x5dc / Weapon_PSpeed(w)); b->startingAngle = (2 * PI / 7) * (b->indexInWeapon + 0.5f * w->firedTimes); b->angleIncrement = w->firedTimes % 2 == 0 ? 0.25f : -0.25f; b->startingPoint.x = b->s.x = Core.Player->s.x; b->startingPoint.y = b->s.y = Core.Player->s.y - game_height; float ty = Core.Player->s.y; b->s.visible = 0; char n[32]; int i = b->indexInWeapon % 7; snprintf(n, sizeof n, "Prism%c.png", L[i]); b->trailFrame = frame_get("vfx", n); snprintf(n, sizeof n, "HitSmoke%c.png", L[i]); b->pfxEmitterB->c.frames[0] = frame_get("vfx", n); snprintf(n, sizeof n, "HitSmoke%c2.png", L[i]); b->pfxEmitterB->c.frames[1] = frame_get("vfx", n); b->GroundFx.tint = Col[i]; b->updateLoops = 0, b->npos = 0; int fl = po_is("FlashingVFXEnabled"); b->trail.visible = 1, b->trail.alpha = fl ? 1 : 0.2f; Sound_PlaySound("Magic3", 0.15f, 1, -0x1f4 + 0x64 * b->indexInWeapon, 0x12c, 7); tween_stop(b->fadeOutTween); b->radius = 0; sprite_setScale(&b->GroundFx, 0); tween_stop(b->scaleTween); b->scaleTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleX, &b->s.scaleY, Weapon_PArea(w) }, { &b->s.alpha, NULL, 0 } }, .nprops = 2, .duration = 0x78, .delay = fall, .onComplete = B_despawnIfActive, .ctx = b }); tween_stop(b->scaleGroundTween); B_Prism_groundDone(b); // onStop del tween di prima if (fl) b->scaleGroundTween = tweens_add((TweenConfig){ .props = { { &b->GroundFx.scaleX, &b->GroundFx.scaleY, 0x20 * Weapon_PArea(w) } }, .nprops = 1, .duration = 0x78, .delay = fall, .yoyo = 1, .onStart = B_Prism_groundStart, .onComplete = B_Prism_groundDone, .ctx = b }); float a = Weapon_PArea(w); tweens_add((TweenConfig){ .props = { { &b->startingPoint.y, NULL, ty }, { &b->radius, NULL, 0x40 + (a > 1 ? 0x10 * (a - 1) : 0) } }, .nprops = 2, .duration = fall, .onComplete = B_Prism_landed, .ctx = b }); } static void B_Prism_DeSpawn(Bullet *b) { Weapon *w = b->weapon; if (w->firstArcana == 2 && w->explodeOnExpire) Weapon_SpawnExplosionAt(w, b->s.x, b->s.y, 0); base_DeSpawn(b); } static void B_Prism_Update(Bullet *b, float delta) { (void)delta; Ribbon_update(b, b->s.x, b->s.y, 0x18); b->startingAngle += b->angleIncrement; b->s.x = b->startingPoint.x + cosf(b->startingAngle) * b->radius, b->s.y = b->startingPoint.y + sinf(b->startingAngle) * b->radius; b->Pfx->wellX = b->s.x, b->Pfx->wellY = b->s.y - 0x28; } static void B_Prism_OnHasHitAnObject(Bullet *b, void *o, int isDead) { Weapon *w = b->weapon; if (isDead) return; if (w->firstArcana == 19) Weapon_SpawnExplosionAt(w, b->s.x, b->s.y, 1); else if (w->firstArcana == 14) Bullet_TryFreeze(b, o); } static const BulletVT B_PrismaticMissile = { "vfx", "HitWhite1.png", B_Prism_ctor, NULL, B_Prism_OnRecycle, B_Prism_OnHasHitAnObject, B_Prism_Update, B_Prism_DeSpawn }; static const BulletVT B_Luminaire; // --- B_Luminaire (0xbf39): il raggio sul nemico a caso ------------------------------------------------------------------------ static void B_Lum_ctor(Bullet *b) { b->s.blendAdd = 1, b->scaleTween = b->alphaTween = (TweenRef){ -1, 0 }; } // semplificazione: SCREEN reso come ADD, il motore non ha SCREEN static void B_Lum_scaleStart(void *ctx) { Bullet *b = ctx; if (b->weapon->explodeOnExpire) Weapon_SpawnExplosionAt(b->weapon, b->s.x, b->s.y, 0); } static void B_Lum_alphaStart(void *ctx) { ((Bullet *)ctx)->s.body.enable = 0; } static void B_Lum_OnRecycle(Bullet *b) { static const unsigned C[4] = { 0xff0000, 0xffff00, 0xff, 0xff00ff }; static const short D[32] = { 0, 0, 0, 0, 0x258, 0x258, 0x320, 0x320, 0, 0, 0, 0, 0x258, 0x258, 0x320, 0x320, -0x190, -0x190, -0x190, -0x190, 0xc8, 0xc8, 0x190, 0x190, -0x190, -0x190, -0x190, -0x190, 0xc8, 0xc8, 0x190, 0x190 }; Weapon *w = b->weapon; Bullet_OnRecycle(b); if (b->alreadyRecycled) return; b->alreadyRecycled = 1; Sprite *t = Bullet_AimForRandomEnemyInScreen(w->lumRect); b->s.x = t ? t->x : Core.Player->s.x, b->s.y = t ? t->y : Core.Player->s.y; Sound_PlaySound("Magic3", 0.15f, 1, D[b->indexInWeapon % 32], 0x190, 7); int fl = po_is("FlashingVFXEnabled"); b->s.alpha = fl ? 0.65f : 0.1f, b->s.blendAdd = fl; sprite_setScale(&b->s, 1), sprite_setTint(&b->s, C[b->indexInWeapon % 4]); b->s.body.enable = 1; tween_stop(b->scaleTween), tween_stop(b->alphaTween); b->scaleTween = tweens_add((TweenConfig){ .props = { { &b->s.scaleY, NULL, game_height / 8.0f }, { &b->s.scaleX, NULL, Weapon_PArea(w) } }, .nprops = 2, .duration = 0xc8, .onStart = B_Lum_scaleStart, .ctx = b }); b->alphaTween = tweens_add((TweenConfig){ .props = { { &b->s.alpha, NULL, 0 } }, .nprops = 1, .delay = 0xc8, .duration = 0x64, .onStart = B_Lum_alphaStart, .onComplete = B_despawnIfActive, .ctx = b }); } static void B_Lum_DeSpawn(Bullet *b) { base_DeSpawn(b); b->alreadyRecycled = 0; } static const BulletVT B_Luminaire = { "vfx", "_phaser.png", B_Lum_ctor, NULL, B_Lum_OnRecycle, B_Prism_OnHasHitAnObject, NULL, B_Lum_DeSpawn }; // --- W_PrismaticMissile (0x9eb3) / W_Luminaire (0xdeff) --------------------------------------------------------------------------- static void W_Prism_ctor(Weapon *w) { w->firstArcana = -1; } static void W_Prism_Fire(Weapon *w) { base_Fire(w); w->firedTimes++; } static Bullet *W_Prism_FireOneBullet(Weapon *w, float x, float y, int index) { (void)index; w->firingCounter = (w->firingCounter + 1) % 7; // currentIndex return BulletPool_SpawnAt(w->pool, x, y, w, w->firingCounter); } static void CA_prism(Weapon *w) { if (w->firstArcana == -1) { // semplificazione: l'originale scorre le arcane nell'ordine di arrivo e l'ultima vince; qui Fuoco, Gioielli, Crepuscolo in ordine fisso if (ARC_T(19)) { w->firstArcana = 19, w->explosionType = "FIREEXPLOSION"; if (FIREW) FIREW->power = 0.5f * w->power; } if (ARC_T(14)) w->firstArcana = 14, w->freezeChance = 0.25f; if (ARC_T(2)) w->firstArcana = 2, w->explosionType = "RAYEXPLOSION", w->explodeOnExpire = 1; } base_CheckArcanas(w); } static const WeaponVT W_PrismaticMissile = { BASE, .bullet = &B_PrismaticMissile, .ctor = W_Prism_ctor, .Fire = W_Prism_Fire, .FireOneBullet = W_Prism_FireOneBullet, .CheckArcanas = CA_prism }; static void Pickup_Bless(Pickup *p, float k, int fl) { p->value += k; if (fl) manager_emitParticleAt(Core.PfxEmitter_Pickups, p->s.x, p->s.y); } static void W_Lum_ctor(Weapon *w) { w->firstArcana = -1; w->lumRect = (Rectangle){ 0, 0, 0.85f * game_width, 0.85f * game_height }; } static void W_Lum_Update(Weapon *w, float delta) { base_Update(w, delta); if (w->hasBullets) return; // IsInitialised w->hasBullets = 1; for (int i = 0; i < 9; i++) { Sprite *d = &w->orbs[i]; char n[16]; snprintf(n, sizeof n, "doi0%d.png", i + 1); sprite_init(d, frame_get("vfx", n), 0.5f * game_width, 0); d->scrollFactor0 = 1, d->blendAdd = 1, d->alpha = 0.05f, d->depth = -0x7ce, d->tint = 0xfff6f6; // semplificazione: SCREEN come ADD, tinte d'angolo col colore medio children_add(d); tweens_add((TweenConfig){ .props = { { &d->alpha, NULL, 0.15f }, { &d->scaleX, &d->scaleY, 2 + 0.25f * i } }, .nprops = 2, .ease = Ease_SineInOut, .delay = 0x320 * i, .duration = 0xfa0, .repeat = -1, .yoyo = 1 }); tweens_add((TweenConfig){ .props = { { &d->angle, NULL, 0x167 } }, .nprops = 1, .delay = 8 * i, .duration = 0x2710, .repeat = -1 }); } w->nOrbs = 9; w->pfx = particles_add(); w->pfx->scrollFactor0 = 1; w->pfxEmitter = particles_createEmitter(w->pfx, (EmitterConfig){ .frames = { frame_get("vfx", "Beam.png") }, .nframes = 1, .lifespan = EOP(0x7d0), .rotate = EOP(0), .quantity = 1, .scale = ERANGE(3, 0), .scaleY = ERANGE(0x32, 0x32), .hasScaleY = 1, .alpha = ERANGE(0.25f, 0), .hasZoneRect = 1, .zoneRect = { 0, 0, game_width, game_height }, .frequency = 0x190, .blendAdd = 1, .on = 1 }); } static void W_Lum_Fire(Weapon *w) { base_Fire(w); int fl = po_is("FlashingVFXEnabled"); if (w->pfxEmitter) { if (fl) emitter_start(w->pfxEmitter); else emitter_stop(w->pfxEmitter); } w->lumRect.x = Core.Player->s.x - 0.5f * w->lumRect.width, w->lumRect.y = Core.Player->s.y - 0.5f * w->lumRect.height; float amount = Weapon_PAmount(w); static const char *const coins[3] = { "COIN", "COINBAG1", "COINBAGMAX" }; int nc = 0; PickupSlot *sl[3]; for (int k = 0; k < 3; k++) sl[k] = PickupPool_slot(&Core.pickupPool, coins[k]), nc += sl[k]->n_spawned; float kc = nc ? (amount + logf(nc)) / nc : 0; for (int k = 0; k < 3; k++) for (int i = 0; i < sl[k]->n_spawned; i++) { Pickup *p = sl[k]->spawned[i]; Pickup_Bless(p, kc, fl); if (p->value >= 0x64) sprite_setFrame(&p->s, frame_get("items", "MoneyBagColor.png")); else if (p->value >= 0x19) sprite_setFrame(&p->s, frame_get("items", "MoneyBagGreen.png")); else if (p->value > 0xa) sprite_setFrame(&p->s, frame_get("items", "MoneyBagRed.png")); } static const char *Gems[11] = { "Gem1.png", "Gem2.png", "Gem3.png", "Gem4.png", "Gem5.png", "Gem6.png", "Gem7.png", "Gem8.png", "Gem9.png", "Gem10.png", "Gem11.png" }; for (int i = 10; i > 0; i--) { int j = (int)floorf(frand() * (i + 1)); const char *t = Gems[i]; Gems[i] = Gems[j], Gems[j] = t; } // RND.shuffle(GEMFRAMES) PickupSlot *gs = PickupPool_slot(&Core.gemsPool, "GEM"); int ng = gs->n_spawned; float kg = ng ? (amount + logf(ng)) / ng : 0; for (int i = 0; i < ng; i++) { Pickup *g = gs->spawned[i]; Pickup_Bless(g, kg, fl); if (fl) sprite_setFrame(&g->s, frame_get("items", Gems[i % 11])); // BlessColor } } static const WeaponVT W_Luminaire = { BASE, .bullet = &B_Luminaire, .ctor = W_Lum_ctor, .Fire = W_Lum_Fire, .Update = W_Lum_Update, .CheckArcanas = CA_prism }; // --- B_Party (0x5d4f): stelle, cuori, triangoli e cerchi che salgono e rimbalzano ------------------------------------------------ typedef struct PartyData { float velX[12], velY[12]; int angles[20], frames[24], frameI; } PartyData; static Animation PartyAnim[4]; // star, heart, triangle, circle: uguali per tutti i colpi static void shuffle_i(int *a, int n) { for (int i = n - 1; i > 0; i--) { int j = (int)floorf(frand() * (i + 1)), t = a[i]; a[i] = a[j], a[j] = t; } } static void Party_trailDraw(Sprite *s) { // Graphics: ogni segmento il suo lineStyle, alpha 1 / (i / 20) Bullet *b = s->owner; if (b->npos < 2 || b->trailAlpha <= 0) return; float ox = b->trail.x - camera_scrollX, oy = b->trail.y - camera_scrollY; BeginBlendMode(BLEND_ADDITIVE); for (int i = 1; i < b->npos; i++) { Vector2 p0 = { ox + b->positions[i - 1].x, oy + b->positions[i - 1].y }, p1 = { ox + b->positions[i].x, oy + b->positions[i].y }; DrawLineEx(p0, p1, 2, hexc(b->color, fminf(1, 20.0f / i) * b->trailAlpha)); DrawLineEx(p0, p1, 1, hexc(0xbbbbbb, fminf(1, 16.0f / i) * b->trailAlpha)); } EndBlendMode(); } static void B_Party_ClearObjectsHit(Bullet *b) { if (!b->canClearObjectsHit) return; b->canClearObjectsHit = 0, b->clearObjectTime = 0, b->n_hit = 0; } static void B_Party_Bounce(void *ctx) { B_Party_ClearObjectsHit(ctx); } static void B_Party_ctor(Bullet *b) { PartyData *d = b->party = calloc(1, sizeof(PartyData)); b->selfGravity = -1.8f, b->bounceValue = 0.9f; if (!PartyAnim[0].n) { make_anim(&PartyAnim[0], "vfx", "image_004_", 0, 0x17, 4, 0x10, -1); make_anim(&PartyAnim[1], "vfx", "image_003_", 0, 0x17, 4, 0x10, -1); make_anim(&PartyAnim[2], "vfx", "image_005_", 0, 0x17, 4, 0x10, -1); make_anim(&PartyAnim[3], "vfx", "image_002_", 0, 0x17, 4, 0x10, -1); } sprite_init(&b->trail, NULL, 0, 0); b->trail.owner = b, b->trail.draw = Party_trailDraw; children_add(&b->trail); for (int i = 0; i < 12; i++) d->velX[i] = 1 + 0.5f * frand(), d->velY[i] = 1 + 0.5f * frand(); for (int i = 1; i < 20; i++) d->angles[i] = 2 * i; shuffle_i(&d->angles[1], 19); // shuffle + unshift(0) for (int i = 0; i < 0x17; i++) d->frames[i] = i; shuffle_i(d->frames, 0x17); tweens_add((TweenConfig){ .props = { { &b->s.angle, NULL, 0x167 } }, .nprops = 1, .duration = 0x3e8 + 0xc8 * frand(), .repeat = -1 }); b->tween = (TweenRef){ -1, 0 }; b->ExpireTimer = (Timer){ -1, 0 }; } static void B_Party_FadeOut(void *ctx) { Bullet *b = ctx; tweens_add((TweenConfig){ .props = { { &b->trailAlpha, NULL, 0 }, { &b->s.alpha, NULL, 0 } }, .nprops = 2, .duration = 0x64, .onComplete = B_despawnIfActive, .ctx = b }); if (b->weapon->explodeOnExpire) Weapon_SpawnExplosionAt(b->weapon, b->s.x, b->s.y, 0); } static void B_Party_expire(void *ctx) { Bullet *b = ctx; time_removeEvent(b->ExpireTimer); B_Party_FadeOut(b); } static void B_Party_OnRecycle(Bullet *b) { Weapon *w = b->weapon; Bullet_OnRecycle(b); b->enemiesHit = 0; body_setCircle(&b->s.body, 8, b->s.body.offset.x, b->s.body.offset.y); b->_speed = 1, b->selfGravity = 0; tween_stop(b->tween); b->tween = tweens_add((TweenConfig){ .props = { { &b->selfGravity, NULL, -6 * Weapon_PSpeed(w) } }, .nprops = 1, .duration = 0x12c }); sprite_setScale(&b->s, 0.65f * Weapon_PArea(w)); time_removeEvent(b->ExpireTimer); b->s.body.collideWorldBounds = 1, b->s.body.hasWorldBounce = 1, b->s.body.worldBounce = (Vector2){ b->bounceValue, b->bounceValue }; b->s.body.customBounds = &Core.Player->WorldBoxCollider; b->s.body.onWorldBounds = B_Party_Bounce, b->s.body.onWorldBoundsCtx = b; b->trail.x = b->s.x - Core.Player->s.x, b->trail.y = b->s.y - Core.Player->s.y; b->color = (unsigned)(0xffffff * frand()); b->trailAlpha = 1, b->s.alpha = 1, b->npos = 0; b->bounceValue = w->level == 1 ? 0.5f : w->level <= 3 ? 0.6f : w->level <= 5 ? 0.7f : w->level <= 7 ? 0.8f : 0.9f; b->ExpireTimer = time_addEvent(Weapon_PDuration(w), 0, 0, B_Party_expire, b); } static const unsigned PartyColors[2][4][8] = { { { 0xbbbb00, 0xbbbb22, 0xcccc00, 0xaaaa00, 0xbbbb00, 0xbbbb00, 0xbbbb00, 0xbbbb00 }, { 0xbb0066, 0xbb2266, 0xcc0066, 0xaa0066, 0xbb0066, 0xbb0066, 0xbb0066, 0xbb0066 }, { 0xbb6600, 0xbb6622, 0xcc6600, 0xaa6600, 0xbb6600, 0xbb6600, 0xbb6600, 0xbb6600 }, { 0xbb0000, 0xbb2222, 0xcc0000, 0xaa0000, 0xbb0000, 0xbb0000, 0xbb0000, 0xbb0000 } }, { { 0xbb, 0x22, 0xbbbbbb, 0xaaaabb, 0xbb, 0xbb, 0xbb, 0xbb }, { 0xbb66, 0x2266, 0xbbbb66, 0xaabb66, 0xbb66, 0xbb66, 0xbb66, 0xbb66 }, { 0x66bb, 0x6622, 0xbb66bb, 0xaa66bb, 0x66bb, 0x66bb, 0x66bb, 0x66bb }, { 0xbbbb, 0x2222, 0xbbbbbb, 0xaabbbb, 0xbbbb, 0xbbbb, 0xbbbb, 0xbbbb } } }; static void B_Party_SetType(Bullet *b, int type) { // 0 stella, 1 cuore, 2 triangolo, 3 cerchio Weapon *w = b->weapon; PartyData *d = b->party; float a = Weapon_PAmount(w); b->bounces = type == 1 ? 1 : type == 3 ? a : 0; b->penetrating = type == 0 ? 0xffff : type == 3 ? 0 : a; b->_speed = type == 1 ? 0.8f : type == 3 ? 1.2f : 1; d->frameI++; if (d->frameI > 0x17) d->frameI = 0; anims_play(&b->s, &PartyAnim[type], d->frames[d->frameI]); w->colorIndex = (w->colorIndex + 1) % 8; b->color = PartyColors[w->frontFiring ? 0 : 1][type][w->colorIndex]; sprite_setTint(&b->s, b->color); } static void B_Party_SetTarget(Bullet *b) { Weapon *w = b->weapon; PartyData *d = b->party; int side = w->frontFiring ? Core.Player->s.flipX : !Core.Player->s.flipX; float a = (side ? 0xd2 : -0x3c) * (PI / 180) + d->angles[b->indexInWeapon % 20] * (PI / 180), v = Bullet_TrueSpeed(b); sprite_setVelocity(&b->s, v * cosf(a), v * sinf(a)); b->s.angle = Bullet_AngleFromVelocityRadians(b->s.body.velocity) * (180 / PI); b->s.body.velocity.x *= d->velX[(int)floorf(frand() * 12)]; } static void B_Party_OnHasHitWall(Bullet *b, Tile *t) { b->save_vel_x *= t && (t->faceRight || t->faceLeft) ? -b->bounceValue : b->bounceValue; b->save_vel_y *= t && (t->faceTop || t->faceBottom) ? -b->bounceValue : b->bounceValue; sprite_setVelocity(&b->s, b->save_vel_x, b->save_vel_y); B_Party_ClearObjectsHit(b); } static void B_Party_DeSpawn(Bullet *b) { time_removeEvent(b->ExpireTimer); base_DeSpawn(b); } static void B_Party_trailUpdate(Bullet *b) { memmove(&b->positions[1], &b->positions[0], 0x18 * sizeof(Vector2)); b->positions[0] = (Vector2){ b->s.x, b->s.y + 0x18 }; if (b->npos < 0x19) b->npos++; } static void B_Party_Update(Bullet *b, float delta) { b->trail.depth = b->s.y - Core.Player->s.y + 0.5f * game_height; int n = (int)ceilf(delta / 0x10); for (int i = 0; i < n; i++) B_Party_trailUpdate(b); b->clearObjectTime += delta; b->canClearObjectsHit = b->clearObjectTime >= b->weapon->hitBoxDelay; b->save_vel_x = b->s.body.velocity.x == 0 ? b->save_vel_x : b->s.body.velocity.x; b->save_vel_y = b->s.body.velocity.y == 0 ? b->save_vel_y : b->s.body.velocity.y; b->s.body.velocity.y -= b->selfGravity; } static void B_Party_OnHasHitAnObject(Bullet *b, void *o, int isDead) { (void)o; if (isDead) return; if (b->bounces > 0) { b->bounces--; b->save_vel_x *= -1, b->save_vel_y *= -1; sprite_setVelocity(&b->s, b->save_vel_x, b->save_vel_y); B_Party_ClearObjectsHit(b); return; } if (--b->penetrating <= 0) B_Party_FadeOut(b); } static const BulletVT B_Party = { "vfx", "party2.png", B_Party_ctor, NULL, B_Party_OnRecycle, B_Party_OnHasHitAnObject, B_Party_Update, B_Party_DeSpawn, NULL, NULL, B_Party_OnHasHitWall }; // --- W_Party (0xa099) / W_Party_Counter --------------------------------------------------------------------------------------------- static void W_Party_common(Weapon *w, int front) { w->frontFiring = front; w->pfx = particles_add(); w->pfxEmitter = particles_createEmitter(w->pfx, (EmitterConfig){ .frames = { frame_get("vfx", "2Spell1.png"), frame_get("vfx", "WhiteDot.png") }, .nframes = 2, .quantity = 1, .lifespan = EOP(0x7d0), .alpha = ERANGE(1, 0), .scale = ERANGE(2, 0), .blendAdd = 1, .nonRadial = 1, .speed = ERND(0x64, 0xc8), .speedY = ERND(-0x64, -0xc8), .angle = ERND(0xe1, 0x13b), .gravityY = 0x12c, .on = 0 }); } static void W_Party_ctor(Weapon *w) { W_Party_common(w, 1); } static void W_PartyC_ctor(Weapon *w) { W_Party_common(w, 0); } static void W_Party_Fire(Weapon *w) { w->fireType = (int)floorf(frand() * 5); // pickType base_Fire(w); Sound_PlaySound("Party", 0.5f, 1, -0x258 * w->critChancesArray[w->critIndex++ % 1000], 0xc8, 0xa); int side = w->frontFiring ? Core.Player->s.flipX : !Core.Player->s.flipX; float k = side ? -1 : 1; w->pfxEmitter->c.speed = ERND(0x64 * k, 0xc8 * k); emitter_emitParticleAt(w->pfxEmitter, Core.Player->s.x, Core.Player->s.y - 0x18, 0x40); if (w->counterWeapon) w->counterWeapon->vt->Fire(w->counterWeapon); } static Bullet *W_Party_FireOneBullet(Weapon *w, float x, float y, int index) { Bullet *b = BulletPool_SpawnAt(w->pool, x, y - 0x18, w, index); if (!b) return NULL; B_Party_SetType(b, w->fireType == 4 ? (int)floorf(frand() * 4) : w->fireType); B_Party_SetTarget(b); return b; } static void CA_party(Weapon *w) { if (ARC_T(1)) { if (Core_GetHiddenWeapon("PARTY_COUNTER")) return; Weapon *c = Core_AddHiddenWeapon("PARTY_COUNTER"); w->counterWeapon = c; if (c) time_removeEvent(c->firingTimer), c->resetDisabled = 1; // CleanUp + ResetFiringTimer vuoto: spara solo con l'arma madre while (c && c->level < w->level && Weapon_LevelUp(c)) {} } base_CheckArcanas(w); } static const WeaponVT W_Party = { BASE, .bullet = &B_Party, .ctor = W_Party_ctor, .Fire = W_Party_Fire, .FireOneBullet = W_Party_FireOneBullet, .CheckArcanas = CA_party }; static const WeaponVT W_Party_Counter = { BASE, .bullet = &B_Party, .ctor = W_PartyC_ctor, .Fire = W_Party_Fire, .FireOneBullet = W_Party_FireOneBullet, .CheckArcanas = CA_none }; // --- W_Insatiable (0x119ae): il colpo sta sul magnete; il proiettile (0x17282) e' quello di Blood Astronomia ------------------------ static float W_Insat_PPower(Weapon *w) { return base_PPower(w) * Player_PGreed(Core.Player); } static void W_Insat_ctor(Weapon *w) { sprite_init(&w->image, frame_get("vfx", "_Insatiable.png"), Core.Magnet->s.x, Core.Magnet->s.y); w->image.alpha = 0.6f, w->image.depth = 0.5f * -game_height; sprite_setScale(&w->image, Core.Magnet->radius / 0x20); children_add(&w->image); tweens_add((TweenConfig){ .props = { { &w->image.alpha, NULL, 0.2f } }, .nprops = 1, .loop = 1, .yoyo = 1, .duration = 0x3e8, .repeat = -1 }); } static void W_Insat_Fire(Weapon *w) { sprite_setScale(&w->image, Weapon_PArea(w) / 0x20); base_Fire(w); } static void W_Insat_Update(Weapon *w, float delta) { base_Update(w, delta); w->image.x = Core.Magnet->s.x, w->image.y = Core.Magnet->s.y; } static const WeaponVT W_Insatiable = { BASE, .bullet = &B_BloodAstronomia, .ctor = W_Insat_ctor, .PPower = W_Insat_PPower, .PAmount = one_PAmount, .PArea = W_Astro_PArea, .Fire = W_Insat_Fire, .Update = W_Insat_Update }; // ============================================================================ // Personaggi di Foscari: 0xb7e6 Eleanor, 0x2470 Maruto, 0x16b6d Keitha, 0xb1f1 Luminaire, 0x7c3 Genevieve, 0x98d5 Je-Ne-Viv, 0x796b Sammy // ============================================================================ static void Foscari_gift(const char *weapon, int spawned) { // l'arma regalata al livello: sotto il giocatore, con la freccia float x = Core.Player->s.x, y = Core.Player->s.y + 0.45f * game_height; Pickup *p = Core_MakeStagePickup(x, y, "WEAPON", weapon); if (p && spawned) p->hasSpawned = 1; GizmoManager_ShowHighlightAt(x, y); } static void Foscari_makeAttack(Player *p) { // spriteAnims.meleeAttack: 'meleeA' o 'rangedA' cJSON *m = cJSON_GetObjectItem(cJSON_GetObjectItem(cJSON_GetArrayItem(p->data, 0), "spriteAnims"), "meleeAttack"); if (!m) return; char prefix[64]; snprintf(prefix, sizeof prefix, "%s", str(m, "spriteName")); char *e = strstr(prefix, "01.png"); if (e) *e = 0; make_anim(&p->meleeA, str(m, "textureName"), prefix, 1, (int)num(m, "framesNumber", 0), 2, num(m, "frameRate", 8), 0); } // --- WorldEaterVFX (0x178dc): il teschio che divora quello che c'e' a schermo ------------------------------------------------- static struct { int made, playing; Sprite image, fader, rays[0xd]; TweenRef t1, t2, t3; void (*callback)(void); } WE; static void WE_Make(void) { float cx = 0.5f * game_width, cy = 0.5f * game_height; memset(&WE, 0, sizeof WE); WE.made = 1; WE.t1 = WE.t2 = WE.t3 = (TweenRef){ -1, 0 }; sprite_init(&WE.image, frame_get("vfx", "2Skull1.png"), cx, cy); WE.image.scrollFactor0 = 1, WE.image.alpha = 0, WE.image.depth = 0x2710; children_add(&WE.image); sprite_init(&WE.fader, frame_get("vfx", "blackDot.png"), 0, 0); sprite_setOrigin(&WE.fader, 0, 0); WE.fader.scrollFactor0 = 1, WE.fader.alpha = 0, WE.fader.depth = 0x270f, WE.fader.scaleX = game_width, WE.fader.scaleY = game_height; children_add(&WE.fader); for (int i = 0; i < 0xd; i++) { Sprite *r = &WE.rays[i]; sprite_init(r, frame_get("vfx", "RayRay.png"), cx, cy); sprite_setScale(r, 0); r->scrollFactor0 = 1, r->blendAdd = 1, r->depth = 0x270e; children_add(r); } } typedef struct { float x, y; } WEHeart; static void WE_heart(void *ctx) { WEHeart *h = ctx; Pickup *p = Core_MakePickup(h->x, h->y, "LITTLEHEART"); if (p) p->goToPlayer = 1, p->time = 1; } static void WE_DoSoulSteal(void) { static WEHeart hearts[256]; static int hi; for (int i = 0; i < Core.Enemies.n; i++) { Enemy *e = Core.Enemies.items[i]->owner; if (e->res_Rosary || !ContainmentRect_Contains(&Core.containmentRect_Screen, &e->s)) continue; Enemy_GetDamaged(e, fmaxf(0x42, e->maxHp), HIT_NONE, 0, "ROSARY"); WEHeart *h = &hearts[hi++ & 255]; *h = (WEHeart){ e->s.x, e->s.y }; time_addEvent(0xa * i, 0, 0, WE_heart, h); } } static void WE_eaten(void *ctx) { (void)ctx; WE_DoSoulSteal(); Weapon_ScreenShake(0xc); Sound_PlaySound("Attack2", 1, 0.5f, 0, 0, 0); sprite_setFrame(&WE.image, frame_get("vfx", "2Skull2.png")); if (WE.callback) WE.callback(); } static void WE_start2(void *ctx) { (void)ctx; WE.image.alpha = 1; } static void WE_over(void *ctx) { (void)ctx; WE.playing = 0; } static void WE_CastSoulSteal(void (*callback)(void)) { if (WE.playing) { WE_DoSoulSteal(); return; } WE.playing = 1, WE.callback = callback; Sound_PlaySound("WorldEater", 1, 1, 0, 0, 0); sprite_setScale(&WE.image, 0), WE.image.alpha = 0; sprite_setFrame(&WE.image, frame_get("vfx", "2Skull1.png")); tween_stop(WE.t1), tween_stop(WE.t2), tween_stop(WE.t3); WE.t1 = tweens_add((TweenConfig){ .props = { { &WE.image.scaleX, &WE.image.scaleY, game_height / 256.0f }, { &WE.image.alpha, NULL, 0.75f } }, .nprops = 2, .duration = 0x1f4, .onComplete = WE_eaten }); WE.t2 = tweens_add((TweenConfig){ .props = { { &WE.image.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x1f4, .delay = 0x1f4, .onStart = WE_start2, .onComplete = WE_over }); WE.t3 = tweens_add((TweenConfig){ .props = { { &WE.fader.alpha, NULL, 0.35f } }, .nprops = 1, .duration = 0x1f4, .yoyo = 1 }); for (int i = 0; i < 0xd; i++) { Sprite *r = &WE.rays[i]; r->angle = 0x168 * (frand() - 0.5f), r->alpha = 1; sprite_setScale(r, 0); tweens_add((TweenConfig){ .props = { { &r->alpha, NULL, 0 }, { &r->scaleX, &r->scaleY, 2 }, { &r->angle, NULL, 2 * r->angle } }, .nprops = 3, .duration = 0x12c }); // (sic) ogni tween ha un solo bersaglio: lo stagger resta al primo valore } } // --- Luminaire: al level-up il rosario, alla rinascita il bonus ------------------------------------------------------------------ static struct { Sprite d[9], fog; Animation fogLoop; TweenRef t[9]; } LV; static void Lum_Make(Player *p) { float cx = 0.5f * game_width, cy = 0.5f * game_height; for (int i = 0; i < 9; i++) { char n[16]; snprintf(n, sizeof n, "doi0%d.png", i + 1); Sprite *d = &LV.d[i]; sprite_init(d, frame_get("vfx", n), cx, cy); d->scrollFactor0 = 1, d->blendAdd = 1, d->alpha = 0, d->depth = 0x2710, d->tint = 0xfff6f6; // semplificazione: tinte d'angolo col colore medio children_add(d); LV.t[i] = (TweenRef){ -1, 0 }; } morphVfx.made = 0; MorphVFX_Make(0); sprite_setFrame(&morphVfx.spark, frame_get("vfx", "s_pfx_rainbow_64.png")); sprite_setFrame(&morphVfx.ring, frame_get("vfx", "bubbleSphere.png")); morphVfx.burst.tint = 0x1111; sprite_init(&LV.fog, frame_get("vfx", "fogRays1.png"), 0, 0); sprite_setOrigin(&LV.fog, 0, 0); LV.fog.scaleX = game_width / 160.0f, LV.fog.scaleY = game_height / 100.0f; LV.fog.blendAdd = 1, LV.fog.alpha = 0, LV.fog.visible = 0, LV.fog.scrollFactor0 = 1, LV.fog.depth = ZInGameUI - 4; // semplificazione: SCREEN come ADD children_add(&LV.fog); make_anim(&LV.fogLoop, "vfx", "fogRays", 1, 2, 0, 0x18, -1); anims_play(&LV.fog, &LV.fogLoop, 0); p->timesRevived = 0; } static void Lum_RosaryDamage(void *ctx) { (void)ctx; Core_RosaryDamageEx(0); Sound_PlaySound("Rosary", 1.8f, 2, 0, 0x1f4, 2); if (!po_is("FlashingVFXEnabled")) return; for (int i = 0; i < 9; i++) { Sprite *d = &LV.d[i]; tween_stop(LV.t[i]); sprite_setScale(d, 0), d->alpha = 0; LV.t[i] = tweens_add((TweenConfig){ .props = { { &d->alpha, NULL, 0.35f + 0.05f * i }, { &d->angle, NULL, 0x168 }, { &d->scaleX, &d->scaleY, 2 + 0.25f * i } }, .nprops = 3, .ease = Ease_SineInOut, .delay = 0xa * i, .duration = 0x64, .yoyo = 1 }); } } static void Lum_Revive(Player *p) { p->timesRevived++; Sound_PlaySound("Morph", 1, 0.5f, 0, 0x7d0, 1); MorphVFX_PlaySparkle(); p->ElapsedGFBonusTime = 0; if (p->hasBonus) return; Player_SetInvulForMilliSecondsNonCumulative(p, 0xfa0 + 0x7d0 * p->timesRevived); if (po_is("FlashingVFXEnabled")) LV.fog.visible = 1, LV.fog.alpha = 1; p->hasBonus = 1, p->MightBonus = 2, p->CooldownBonus = -1, p->MoveBonus = fmaxf(0, 2 - p->moveSpeed); p->power += p->MightBonus, p->cooldown += p->CooldownBonus, p->moveSpeed += p->MoveBonus; for (int i = 0; i < Core.n_weapons; i++) if (!Core.Weapons[i]->isPowerUp) Core.Weapons[i]->vt->Fire(Core.Weapons[i]); } static void Lum_Update(Player *p, float delta) { if (!p->hasBonus) return; p->ElapsedGFBonusTime += delta; float d = 0x3a98 + 0x7d0 * p->timesRevived; if (p->ElapsedGFBonusTime >= d - 0x7d0) LV.fog.alpha = 1 - (p->ElapsedGFBonusTime - (d - 0x7d0)) / 0x3e8; if (p->ElapsedGFBonusTime >= d) { LV.fog.visible = 0; p->hasBonus = 0; p->power -= p->MightBonus, p->cooldown -= p->CooldownBonus, p->moveSpeed -= p->MoveBonus; } } // --- Genevieve e Je-Ne-Viv: Vacuum al level-up, l'ultimo respiro e (la seconda) i muri mangiati ------------------------------------- static void Gen_vacuum(void *ctx) { (void)ctx; Sound_PlaySound("Vacuum", 0.3f, 1, 0, 0x3e8, 1); Core_TurnOnVacuum(); } static struct { unsigned char *removed; int w, h; short queue[512][2]; int n; float eatTimer; ParticleManager *m; ParticleEmitter *smoke, *black; } GE; static void Gen_grow(void *ctx) { Player *p = ctx; sprite_setScale(&p->s, p->s.scaleX + 0.1f); } static int Gen_isEdible(const char *n) { static const char *const L[6] = { "Walls", "PlayerWall", "Obstacle", "FakeWalls", "Decals", "Overlay1" }; for (int i = 0; i < 6; i++) if (n && !strcmp(n, L[i])) return 1; return 0; } static void Gen_EatTile(int tx, int ty) { TilingTileset *t = Core.Stage->tilingTileset; Tilemap *m = t->MainMap; // i LayerData sono condivisi dalle copie: una passata vale per tutte LayerContainer *c = &t->layerContainers[0]; for (int k = 0; k < c->n; k++) { TilemapLayer *l = c->layers[k]; if (!l) continue; for (int i = 0; i < m->n_layers; i++) if (m->layerData[i] == l->data && Gen_isEdible(m->layerName[i])) tilemapLayer_removeTileAt(l, tx, ty); } } typedef struct { short x, y; } GenTile; static void Gen_tileEaten(void *ctx) { GenTile *g = ctx; Player *p = Core.Player; Gen_EatTile(g->x, g->y); float x = g->x * 0x20 + Core.Stage->tilingTileset->current.x, y = g->y * 0x20 + Core.Stage->tilingTileset->current.y; emitter_emitParticleAt(GE.smoke, x, y, 0xa), emitter_emitParticleAt(GE.black, x, y, 0xa); Player_RecoverHp(p, 1, 1, 1); Weapon_ScreenShake(0xc); Sound_PlaySound("Attack2", 1, 1, 0, 0x3e8, 1); } static void Gen_TryEatingWorld(void) { // CheckTiles: Magnet contro i muri if (GE.eatTimer <= 0x1388 || !Core.Stage->hasTileset) return; GE.eatTimer = 0, GE.n = 0; Magnet *mg = Core.Magnet; for (int k = 0; k < n_CollisionLayers; k++) { TilemapLayer *l = CollisionLayers[k]; Tilemap *m = l->map; if (!GE.removed) GE.w = m->width, GE.h = m->height, GE.removed = calloc(GE.w * GE.h, 1); int x0 = (int)floorf((mg->s.x - mg->radius - l->x) / m->tileWidth), x1 = (int)floorf((mg->s.x + mg->radius - l->x) / m->tileWidth); int y0 = (int)floorf((mg->s.y - mg->radius - l->y) / m->tileHeight), y1 = (int)floorf((mg->s.y + mg->radius - l->y) / m->tileHeight); for (int y = y0 < 0 ? 0 : y0; y <= y1 && y < m->height; y++) for (int x = x0 < 0 ? 0 : x0; x <= x1 && x < m->width; x++) { Tile *t = &l->data[y * m->width + x]; if (t->index < 0 || !t->collides || GE.removed[y * GE.w + x] || GE.n >= 512) continue; GE.removed[y * GE.w + x] = 1; GE.queue[GE.n][0] = x, GE.queue[GE.n++][1] = y; } } } static void Gen_Update(Player *p, float delta) { if (p->level > 1) GE.eatTimer += delta; if (GE.n > 0 && p->s.scaleX < 2) time_addEvent(0x1f4, 0, 0, Gen_grow, p); static GenTile ring[512]; static int ri; while (GE.n > 0) { // StartEatingTile; semplificazione: l'immagine nera dell'originale sta alle coordinate di griglia, fuori dalla vista GE.n--; GenTile *g = &ring[ri++ & 511]; *g = (GenTile){ GE.queue[GE.n][0], GE.queue[GE.n][1] }; time_addEvent(0x1f4, 0, 0, Gen_tileEaten, g); } if (GE.m) GE.m->wellX = p->s.x, GE.m->wellY = p->s.y - 0x18; } static void Gen_Make(Player *p) { (void)p; GE.removed = NULL, GE.n = 0, GE.eatTimer = 0; GE.m = particles_add(); GE.smoke = particles_createEmitter(GE.m, (EmitterConfig){ .frames = { frame_get("vfx", "Smoke1.png"), frame_get("vfx", "Smoke2.png") }, .nframes = 2, .lifespan = EOP(0x3e8), .rotate = ERND(0, 0x168), .angle = { 0, 0xb4, 3, NULL }, .angleSteps = 0x10, .speed = ERND(0x64, 0xc8), .quantity = 4, .scale = ERANGE(1, 0), .frequency = 4, .alpha = ERANGE(0.65f, 0), .on = 0 }); GE.black = particles_createEmitter(GE.m, (EmitterConfig){ .frames = { frame_get("vfx", "blackDot.png") }, .nframes = 1, .lifespan = EOP(0x3e8), .rotate = ERND(0, 0x168), .alpha = ERANGE(0.65f, 0), .angle = { 0, 0x168, 3, NULL }, .angleSteps = 0x10, .speed = ERND(0x32, 0x50), .quantity = 4, .scale = ERANGE(0x20, 0), .frequency = 2, .on = 0 }); GE.m->hasWell = 1, GE.m->wellPower = 1 * 0x28, GE.m->wellEpsilon = 0x64 * 0x64; } // --- Sammy: le monete fanno esperienza; al 30 la febbre dell'oro con la sua musica ------------------------------------------------ static void Sammy_fever(void *ctx) { (void)ctx; GoldFever_Start(0x2710); } static void Sammy_t1(void *ctx) { (void)ctx; GoldFever_Start(0x2710); time_addEvent(0x1388, 1, 3, Sammy_fever, NULL); Core_TurnOnVacuumForGold(); Sound_StopMusic(); } static void Sammy_t2(void *ctx) { (void)ctx; Sound_PlayMusic("BGM_HB", 0.4f, 0); } static void Sammy_t3(void *ctx) { (void)ctx; Sound_StopMusic(); Sound_SetupAndPlayBGM_Banger(1); } static void Sammy_30(void *ctx) { (void)ctx; Sound_FadeMusic(0, 0x1f4); time_addEvent(0x1f4, 0, 0, Sammy_t1, NULL); // setTimeout: qui il tempo di gioco time_addEvent(0x258, 0, 0, Sammy_t2, NULL); time_addEvent(0x7918, 0, 0, Sammy_t3, NULL); } static void Sammy_OnCoinPickup(Player *p, float value) { float v = value * GoldMultiplier * Player_PGreed(p) * Player_PGrowth(p); p->xp += v * ExperienceMultiplier; if (Players_n > 1) Slots[game_context ? 0 : 1].player->xp += v * ExperienceMultiplier; // AddXP_IgnoretGameKiller: senza il moltiplicatore che Game Killer azzera Sound_PlaySound("Gem", 0.1f, 1, 0, 1, 1); PlayerUI_Update(); } // --- Gli agganci chiamati dalle funzioni comuni di Player ----------------------------------------------------------------------------- static void Foscari_MakeLevelOne(Player *p) { if (Player_is(p, "VICTOR")) p->armorBonus = 0, p->armorTime = 0, Foscari_makeAttack(p), p->hasMeleeA = 1; if (Player_is(p, "KEIRA")) Foscari_makeAttack(p), p->hasRangedA = 1; if (Player_is(p, "MEGAGENEVIEVE")) Gen_Make(p); } static void Foscari_AfterFullInit(Player *p) { if (Player_is(p, "LUMINAIRE")) Lum_Make(p); if (Player_is(p, "GENEVIEVE") || Player_is(p, "MEGAGENEVIEVE")) WE_Make(), p->isLastBreathEnabled = 1; if (Player_is(p, "CTRPCAKE")) { Weapon *h = Core_GetWeapon("STIGRANGATTI"); if (h) h->goldChance = 0.165f; p->gfeverMul = 1.25f; } } static void Foscari_LevelUp(Player *p) { if (Player_is(p, "ELEANOR")) { if (p->level == 0xa) Foscari_gift("SPELL_STREAM", 1); else if (p->level == 0x14) Foscari_gift("SPELL_STRIKE", 1); else if (p->level == 0x1e) Foscari_gift("ACADEMYBADGE", 1); } if ((Player_is(p, "VICTOR") || Player_is(p, "KEIRA")) && p->level == 0x1e) Foscari_gift("ACADEMYBADGE", 0); if (Player_is(p, "LUMINAIRE")) time_addEvent(0x64, 0, 0, Lum_RosaryDamage, NULL); if (Player_is(p, "GENEVIEVE")) time_addEvent(0x64, 0, 0, Gen_vacuum, NULL); if (Player_is(p, "MEGAGENEVIEVE")) { time_addEvent(0x64, 0, 0, Gen_vacuum, NULL); if (p->level == 0xa) Foscari_gift("SPELL_STRING", 1); else if (p->level == 0x14) Foscari_gift("SPELL_STREAM", 1); else if (p->level == 0x1e) Foscari_gift("SPELL_STRIKE", 1); if (p->level % 6 == 0) WE_CastSoulSteal(Gen_TryEatingWorld); } if (Player_is(p, "CTRPCAKE")) { Weapon *h = Core_GetWeapon("STIGRANGATTI"); if (h && h->goldChance < 0.65f) h->goldChance += 0.005f; if (p->level == 0x1e) time_addEvent(0xc8, 0, 0, Sammy_30, NULL); } } static void Foscari_Update(Player *p, float delta) { if (Player_is(p, "VICTOR")) { p->armorTime += delta; if (p->armorTime >= 0x2710) p->armorBonus = 0, p->armorTime = 0; } if (Player_is(p, "LUMINAIRE")) Lum_Update(p, delta); if (Player_is(p, "MEGAGENEVIEVE")) Gen_Update(p, delta); } static void Foscari_OnLastBreath(Player *p) { if (Player_is(p, "GENEVIEVE")) Player_SetInvulForMilliSecondsNonCumulative(p, 0xbb8), WE_CastSoulSteal(NULL); if (Player_is(p, "MEGAGENEVIEVE")) Player_SetInvulForMilliSecondsNonCumulative(p, 0x7d0), WE_CastSoulSteal(Gen_TryEatingWorld); } static void Seal_dev(void); static void Foscari_dev(void *ctx) { (void)ctx; const char *e = getenv("VS_FOSC"); Player *p = Core.Player; if (!strcmp(e, "seal")) { Seal_dev(); return; } if (!strcmp(e, "breath")) Foscari_OnLastBreath(p); else if (!strcmp(e, "revive")) Lum_Revive(p); else p->level = atoi(e), Foscari_LevelUp(p); } static void Foscari_OnCoinPickup(float value) { if (Player_is(Core.Player, "CTRPCAKE")) Sammy_OnCoinPickup(Core.Player, value); } static const WeaponVT *weapon_vt(const char *type) { cJSON *d = cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("weapons"), type), 0); if (cJSON_IsTrue(cJSON_GetObjectItem(d, "isPowerUp"))) return &W_PowerUp; if (!strcmp(type, "WHIP")) return &W_Whip; if (!strcmp(type, "SILVERWIND")) return &W_SilverWind; if (!strcmp(type, "SILVERWIND2")) return &W_SilverWind2; if (!strcmp(type, "MIRAGEROBE")) return &W_MirageRobe; if (!strcmp(type, "MIRAGEROBE2")) return &W_MirageRobe2; if (!strcmp(type, "BUBBLES")) return &W_Bubble; if (!strcmp(type, "BUBBLES2")) return &W_Bubble2; if (!strcmp(type, "SUMMONNIGHT")) return &W_SummonNight; if (!strcmp(type, "SUMMONNIGHT2")) return &W_SummonNight2; if (!strcmp(type, "NIGHTSWORD")) return &W_NightSword; if (!strcmp(type, "SWORD")) return &W_Sword; if (!strcmp(type, "SWORD2")) return &W_Legionnaire; if (!strcmp(type, "FLASHARROW")) return &W_FlashArrow; if (!strcmp(type, "FLASHARROW2")) return &W_Millionaire; if (!strcmp(type, "SHADOWSERVANT")) return &W_ShadowServant; if (!strcmp(type, "SHADOWSERVANT_COUNTER")) return &W_ShadowServant_Counter; if (!strcmp(type, "SHADOWSERVANT2")) return &W_Ophion; if (!strcmp(type, "PRISMATICMISS")) return &W_PrismaticMissile; if (!strcmp(type, "PRISMATICMISS2")) return &W_Luminaire; if (!strcmp(type, "PARTY")) return &W_Party; if (!strcmp(type, "PARTY_COUNTER")) return &W_Party_Counter; if (!strcmp(type, "INSATIABLE")) return &W_Insatiable; if (!strcmp(type, "NIGHTSWORD2")) return &W_NightSword2; if (!strcmp(type, "BOCCE")) return &W_Bocce; if (!strcmp(type, "SPELL_STRING")) return &W_Spellstring; if (!strcmp(type, "SPELL_STREAM")) return &W_Spellstream; if (!strcmp(type, "SPELL_STRIKE")) return &W_Spellstrike; if (!strcmp(type, "SPELL_STROM")) return &W_Spellstrom; if (!strcmp(type, "FOURSEASONS")) return &W_FourSeasons; if (!strcmp(type, "FOURSEASONS2")) return &W_FourSeasons2; if (!strcmp(type, "WINDOW")) return &W_WindowW; if (!strcmp(type, "MAGIC_MISSILE")) return &W_MagicMissile; if (!strcmp(type, "KNIFE")) return &W_Knife; if (!strcmp(type, "AXE")) return &W_Axe; if (!strcmp(type, "HOLYBOOK")) return &W_HolyBook; if (!strcmp(type, "HOLYWATER")) return &W_HolyWater; if (!strcmp(type, "LAUREL")) return &W_Laurel; if (!strcmp(type, "SHROUD")) return &W_Shroud; if (!strcmp(type, "VICTORY")) return &W_Victory; if (!strcmp(type, "ROBBA")) return &W_Larobba; if (!strcmp(type, "CART")) return &W_Cart; if (!strcmp(type, "CANDYBOX")) return &W_Candybox; if (!strcmp(type, "CANDYBOX2")) return &W_Candybox2; if (!strcmp(type, "SOLES")) return &W_SoleSolution; if (!strncmp(type, "TRIASSO", 7)) return &W_Triace; // TRIASSO1-3: stessa classe if (!strcmp(type, "VAMPIRICA")) return &W_Vampirica; if (!strcmp(type, "HOLY_MISSILE")) return &W_HolyWand; if (!strcmp(type, "THOUSAND")) return &W_Knife; if (!strcmp(type, "SCYTHE")) return &W_Scythe; if (!strcmp(type, "VESPERS")) return &W_Vespers; if (!strcmp(type, "BORA")) return &W_Bora; if (!strcmp(type, "NDUJA")) return &W_Misspell; if (!strcmp(type, "MISSPELL")) return &W_MisspellTrue; if (!strcmp(type, "MISSPELL2")) return &W_MisspellTrue2; if (!strcmp(type, "CROSS")) return &W_Cross; if (!strcmp(type, "HEAVENSWORD")) return &W_HeavenSword; if (!strcmp(type, "FIREBALL")) return &W_Fireball; if (!strcmp(type, "HELLFIRE")) return &W_Hellfire; if (!strcmp(type, "GARLIC")) return &W_Garlic; if (!strcmp(type, "VORTEX")) return &W_Vortex; if (!strcmp(type, "DIAMOND")) return &W_Diamond; if (!strcmp(type, "LIGHTNING")) return &W_Lightning; if (!strcmp(type, "LOOP")) return &W_Loop; if (!strcmp(type, "PENTAGRAM")) return &W_Pentagram; if (!strcmp(type, "SIRE")) return &W_Sire; if (!strcmp(type, "ROCHER")) return &W_Carnage; if (!strcmp(type, "SILF")) return &W_Silf; if (!strcmp(type, "SILF2")) return &W_Silf2; if (!strcmp(type, "SILF3")) return &W_Silf3; if (!strcmp(type, "GUNS")) return &W_Guns; if (!strcmp(type, "GUNS2")) return &W_Guns2; if (!strcmp(type, "GUNS3")) return &W_Guns3; if (!strcmp(type, "GATTI")) return &W_Gatti; if (!strcmp(type, "FIREEXPLOSION")) return &W_FireExplosion; if (!strcmp(type, "COLDEXPLOSION")) return &W_ColdExplosion; if (!strcmp(type, "SARABANDE")) return &W_Sarabande; if (!strcmp(type, "BLOODLINE")) return &W_DivineBloodline; if (!strcmp(type, "ASTRONOMIA")) return &W_BloodAstronomia; if (!strcmp(type, "WINDOW2")) return &W_GemCannon; if (!strcmp(type, "GUNS_COUNTER")) return &W_Guns_Counter; if (!strcmp(type, "GUNS2_COUNTER")) return &W_Guns2_Counter; if (!strcmp(type, "SILF_COUNTER")) return &W_Silf_Counter; if (!strcmp(type, "SILF2_COUNTER")) return &W_Silf2_Counter; if (!strcmp(type, "GATTI_COUNTER")) return &W_Gatti_Counter; if (!strcmp(type, "NDUJA_COUNTER")) return &W_Misspell_Counter; if (!strcmp(type, "STIGRANGATTI")) return &W_Grangatti; if (!strcmp(type, "SONG")) return &W_Song; if (!strcmp(type, "MANNAGGIA")) return &W_Song2; if (!strcmp(type, "TRAPANO")) return &W_Trapano; if (!strcmp(type, "TRAPANO2")) return &W_Trapano2; if (!strcmp(type, "LANCET")) return &W_Lancet; if (!strcmp(type, "CORRIDOR")) return &W_Corridor_vt; if (!strcmp(type, "VENTO")) return &W_Vento; if (!strcmp(type, "VENTO2")) return &W_Vento2; if (!strcmp(type, "BONE")) return &W_Bone; if (!strcmp(type, "BONE2")) return &W_BoneGiant; if (!strcmp(type, "CHERRY")) return &W_Cherry; if (!strcmp(type, "CHERRY2")) return &W_CherryStars; if (!strcmp(type, "CART2")) return &W_Cart2; if (!strcmp(type, "FLOWER")) return &W_Flower; if (!strcmp(type, "JUBILEE")) return &W_Jubilee; return NULL; } static const char *const *Weapon_baseList(int *n) { // UI_selectWeaponScene.getBaseWeapons: base, sbloccate, non gia' prese (DLC: assenti nei dati) static const char *list[96]; *n = 0; cJSON *it; cJSON_ArrayForEach(it, data_get("weapons")) { cJSON *d = cJSON_GetArrayItem(it, 0); if (!d || !cJSON_IsTrue(cJSON_GetObjectItem(d, "isUnlocked"))) continue; if (cJSON_IsTrue(cJSON_GetObjectItem(d, "isSpecialOnly")) || cJSON_IsTrue(cJSON_GetObjectItem(d, "hidden")) || cJSON_IsTrue(cJSON_GetObjectItem(d, "isEvolution")) || cJSON_IsTrue(cJSON_GetObjectItem(d, "isPowerUp")) || !strcmp(it->string, "CANDYBOX") || !strcmp(it->string, "VOID")) continue; int taken = 0; for (int i = 0; i < Core.n_weapons; i++) taken |= !strcmp(Core.Weapons[i]->bulletType, it->string); for (int i = 0; i < Core.n_RemovedWeapons; i++) taken |= !strcmp(Core.RemovedWeapons[i]->bulletType, it->string); if (!taken && *n < 96) list[(*n)++] = it->string; } return list; } static Weapon *Weapon_new(const char *bulletType) { const WeaponVT *vt = weapon_vt(bulletType); if (!vt) return NULL; Weapon *w = calloc(1, sizeof(Weapon)); w->player = game_context; w->vt = vt; w->bulletType = bulletType; w->interval = 0x3e8; w->repeatInterval = 0x64; w->secondaryPower = w->power = w->area = w->speed = w->amount = 1; w->duration = 0x3e8; w->critMul = 2; w->hitVFX = HIT_DEFAULT; w->penetrating = 1; w->hitBoxDelay = 0x3e8; w->knockback = 5; w->hitsWalls = 1; w->lastFiringInterval = 0x186a0; w->explosionType = "RAYEXPLOSION"; if (vt == &W_Fireball || vt == &W_Hellfire || vt == &W_Guns || vt == &W_Guns_Counter || vt == &W_MisspellTrue || vt == &W_MisspellTrue2 || vt == &W_Trapano2) w->explosionType = "FIREEXPLOSION"; // costruttori di queste classi w->firingTimer = (Timer){ -1, 0 }; w->data = cJSON_GetObjectItem(data_get("weapons"), bulletType); static const char *const curse[] = { "BONE", "DIAMOND", "FLOWER", "HOLYBOOK", "LIGHTNING", "LOOP", "SILF", "SILF2", "SILF3", "SILF_COUNTER", "SILF2_COUNTER", "TRAPANO", "TRIASSO1", "TRIASSO2", "TRIASSO3", "VESPERS" }; // SecondaryOvarlapDamageType = CURSE for (size_t i = 0; i < sizeof(curse) / sizeof(curse[0]); i++) w->secondaryCurse |= !strcmp(bulletType, curse[i]); if (vt->ctor) vt->ctor(w); return w; } static void Weapon_Init(Weapon *w) { w->pool = calloc(1, sizeof(BulletPool)); w->pool->weapon = w; w->pool->upperLimit = 0x32; w->stats_lifetime = w->stats_inflictedDamage = 0; w->vt->MakeLevelOne(w); w->vt->OnStart(w); } // Core.AddWeapon / Core.GetWeapon / Core.LevelWeaponUp static Weapon *Core_GetWeapon(const char *type) { for (int i = 0; i < Core.n_weapons; i++) if (!strcmp(Core.Weapons[i]->bulletType, type)) return Core.Weapons[i]; return NULL; } static void LevelUpFactory_RemoveFromStore(const char *type); static void LevelUpFactory_CalculateXPfactor(void); static void LevelUpFactory_calculateWeights(void); // PlayerOptions.AddCoins: oro * GoldMultiplier * PGreed; restituisce quanto e' stato aggiunto static float PlayerOptions_AddCoins(float v) { v *= GoldMultiplier; if (Core.Player) v *= Player_PGreed(Core.Player); // PGreed (nel menu: il giocatore dell'ultima partita, o nessuno) if (Core.Player && Arcanas.HealOnCoins) Player_RecoverHp(Core.Player, v, 1, 0); // Arcanas.PickedUpCoin (Disco of Gold) Core.RunCoins += v; po_add("Coins", v), po_add("LifetimeCoins", v), po_add("TotalCoins", v); // SaveCoins: solo Storage del web return v; } static void Arcanas_CheckSilent(void); static Weapon *Core_AddWeapon(const char *type, int removeFromStore) { if (Core.n_weapons >= 16) return NULL; Weapon *w = Weapon_new(type); // WeaponFactory.GetWeapon -> new + Init if (!w) return NULL; Weapon_Init(w); w->level = 1; Core.Weapons[Core.n_weapons++] = w; if (removeFromStore) LevelUpFactory_RemoveFromStore(type); else LevelUpFactory_calculateWeights(); MainUI_AddWeaponIcon(type); if (w->vt->OnWeaponAdded) w->vt->OnWeaponAdded(w); Arcanas_CheckSilent(); return w; } static void MainUI_Remove(const char *type); static void Weapon_CleanUp(Weapon *w) { time_removeEvent(w->firingTimer); while (w->pool && w->pool->group.n) Bullet_DeSpawn(w->pool->group.items[w->pool->group.n - 1]->owner); // pool.spawned.forEach(DeSpawn) for (int i = 0; i < w->n_rays; i++) w->rays[i].visible = 0; // W_Guns3.CleanUp w->image.visible = 0; // CleanUp di Laurel, Shroud, Garlic, Vortex: image.setVisible(false).destroy() for (int i = 0; i < w->nOrbs; i++) w->orbs[i].visible = 0; // Bocce, Four Seasons if (w->vt == &W_Millionaire && Core_coinListener == w) Core_coinListener = NULL; if (w->vt == &W_Luminaire && w->pfxEmitter) emitter_stop(w->pfxEmitter); if (w->stormPfx) { // W_Spellstrom.CleanUp Weapon_CleanUp(w->Weapon_Stream), Weapon_CleanUp(w->Weapon_Strike), Weapon_CleanUp(w->Weapon_String); emitter_stop(w->stormE1), emitter_stop(w->stormE2), emitter_stop(w->circleE); } PlayerEvents_remove(w); // removeListener('Player_LostShield', colorEvent) // semplificazione: imageTween/imageTween2 infiniti restano su uno sprite nascosto (2 slot su 4096); stop() se servono gli slot for (int k = 0; k < 2; k++) { // secondaryPool / extraPool (W_Vento2.CleanUp) BulletPool *p = k ? w->extraPool : w->secondaryPool; while (p && p->group.n) Bullet_DeSpawn(p->group.items[p->group.n - 1]->owner); } } static void Core_RemoveWeapon(const char *type) { MainUI_Remove(type); for (int i = 0; i < Core.n_weapons; i++) { Weapon *w = Core.Weapons[i]; if (strcmp(w->bulletType, type)) continue; Weapon_CleanUp(w); memmove(&Core.Weapons[i], &Core.Weapons[i + 1], (Core.n_weapons - i - 1) * sizeof(Weapon *)); Core.n_weapons--; if (Core.n_RemovedWeapons < 16) Core.RemovedWeapons[Core.n_RemovedWeapons++] = w; return; } } static void Core_RemoveHiddenWeapon(const char *type) { for (int i = 0; i < Core.n_HiddenWeapons; i++) { Weapon *w = Core.HiddenWeapons[i]; if (strcmp(w->bulletType, type)) continue; memmove(&Core.HiddenWeapons[i], &Core.HiddenWeapons[i + 1], (Core.n_HiddenWeapons - i - 1) * sizeof(Weapon *)); Core.n_HiddenWeapons--; Weapon_CleanUp(w); return; } } static Weapon *Core_AddHiddenWeapon(const char *type) { // WeaponFactory.GetWeapon, livello 1, in HiddenWeapons (niente icona, niente LevelUpFactory) if (Core.n_HiddenWeapons >= 16) return NULL; Weapon *w = Weapon_new(type); if (!w) return NULL; Weapon_Init(w); w->level = 1; return Core.HiddenWeapons[Core.n_HiddenWeapons++] = w; } static void Core_LevelWeaponUp(const char *type, int removeFromStore) { if (!cJSON_GetObjectItem(data_get("weapons"), type)) return; Weapon *w = Core_GetWeapon(type); if (w) { if (!Weapon_LevelUp(w)) { PlayerOptions_AddCoins(10); MainUI_UpdateCoins(); } if (removeFromStore) LevelUpFactory_RemoveFromStore(w->bulletType); } else { Core_AddWeapon(type, removeFromStore); } Core_SetSeenWeapon(type); } // ============================================================================ // 0xeac3: LevelUpFactory // ============================================================================ typedef struct { const char *weaponType; float weight; } WeightedWeapon; // 0xce11 static struct { const char *WeaponStore[1024], *ExcludedWeapons[256], *SpecialWeapons[64], *BanishedWeapons[64]; int n_store, n_excl, n_special, n_banished; WeightedWeapon WeightedStore[256]; int n_weighted; float accumulatedWeight, chanceForExistingPowerUp; int levelUpOptions, maxTrueWeapons, maxPowerUpWeapons; } LUF_of[2]; #define LUF LUF_of[game_context] static int strin(const char **a, int n, const char *s) { for (int i = 0; i < n; i++) if (!strcmp(a[i], s)) return i; return -1; } static void LevelUpFactory_DoExclude(const char *t) { if (LUF.n_excl < 256) LUF.ExcludedWeapons[LUF.n_excl++] = t; } static int count_weapons(int powerups) { int n = 0; for (int i = 0; i < Core.n_weapons; i++) if ((Core.Weapons[i]->isPowerUp == 1) == powerups) n++; return n; } static void LevelUpFactory_CalculateXPfactor(void) { float a = Core.defaultXPfactor + 1.5f * floorf(Core.Player->level / 20.0f); a = fminf(a, 8); float b = Core.defaultXPfactor + 1.5f * floorf((Core.Player->level - 1) / 20.0f); b = fminf(b, 8); Core.currentXPfactor = a * Core.Player->level * Core.Player->level; Core.previousXPfactor = b * (Core.Player->level - 1) * (Core.Player->level - 1); } static float PLuck(void) { return Player_PLuck(Core.Player); } static void LevelUpFactory_calculateWeights(void) { LUF.accumulatedWeight = 0; LUF.n_weighted = 0; cJSON *it; cJSON_ArrayForEach(it, data_get("weapons")) { const char *k = it->string; if (strin(LUF.ExcludedWeapons, LUF.n_excl, k) >= 0 || strin(LUF.SpecialWeapons, LUF.n_special, k) >= 0) continue; cJSON *d = cJSON_GetArrayItem(it, 0); int isPU = cJSON_IsTrue(cJSON_GetObjectItem(d, "isPowerUp")); if (!Core_GetWeapon(k) && count_weapons(isPU) >= (isPU ? LUF.maxPowerUpWeapons : LUF.maxTrueWeapons)) continue; float m = cJSON_IsTrue(cJSON_GetObjectItem(d, "dropRateAffectedByLuck")) ? PLuck() : 1; LUF.accumulatedWeight += num(d, "rarity", 0) * m; if (num(d, "rarity", 0) > 0) LUF.WeightedStore[LUF.n_weighted++] = (WeightedWeapon){ k, LUF.accumulatedWeight }; } } static void LevelUpFactory_Init(void) { LUF.chanceForExistingPowerUp = 0.3f; LUF.levelUpOptions = 3; LUF.maxTrueWeapons = LUF.maxPowerUpWeapons = 6; LevelUpFactory_CalculateXPfactor(); cJSON *it; cJSON_ArrayForEach(it, data_get("weapons")) { const char *k = it->string; cJSON *d = cJSON_GetArrayItem(it, 0); if (cJSON_IsTrue(cJSON_GetObjectItem(d, "isEvolution"))) LevelUpFactory_DoExclude(k); else if (cJSON_IsTrue(cJSON_GetObjectItem(d, "isUnlocked"))) { if (num(d, "rarity", 0) == 0 || cJSON_IsTrue(cJSON_GetObjectItem(d, "isSpecialOnly"))) LevelUpFactory_DoExclude(k); else if (!weapon_vt(k)) LevelUpFactory_DoExclude(k); // semplificazione: armi non ancora tradotte fuori dalla scelta; togliere man mano } else LevelUpFactory_DoExclude(k); for (int i = 0; i < cJSON_GetArraySize(it) && LUF.n_store < 1024; i++) LUF.WeaponStore[LUF.n_store++] = k; if (getenv("VS_EMPTYSTORE")) LevelUpFactory_DoExclude(k); // sviluppo: niente da scegliere (oggetti, [Always], Limit Break) } LevelUpFactory_calculateWeights(); } static void LevelUpFactory_RemoveFromStore(const char *t) { int i = strin(LUF.WeaponStore, LUF.n_store, t); if (i >= 0) { memmove(&LUF.WeaponStore[i], &LUF.WeaponStore[i + 1], (LUF.n_store - i - 1) * sizeof(char *)); LUF.n_store--; } if (strin(LUF.WeaponStore, LUF.n_store, t) < 0) LevelUpFactory_DoExclude(t); LevelUpFactory_calculateWeights(); } static int LevelUpFactory_HasPowerupsInStore(void) { return LUF.n_weighted > 0; } static int LevelUpFactory_GetLevelUpOptions(void) { return frand() > 1 / PLuck() ? LUF.levelUpOptions + 1 : LUF.levelUpOptions; } static float LevelUpFactory_ChanceForExistingPowerUp(void) { return (Core.Player->level % 2 == 0 ? 2 : 1) * LUF.chanceForExistingPowerUp + 1 - 1 / PLuck(); } static const char *LevelUpFactory_GetRandomWeightedWeaponOrPowerup(void) { float r = frand() * LUF.accumulatedWeight; for (int i = 0; i < LUF.n_weighted; i++) if (LUF.WeightedStore[i].weight >= r) return LUF.WeightedStore[i].weaponType; return NULL; } static const char *LevelUpFactory_GetRandomWeightedWeapon(void) { WeightedWeapon tmp[256]; int n = 0; float acc = 0; cJSON *it; cJSON_ArrayForEach(it, data_get("weapons")) { const char *k = it->string; if (strin(LUF.ExcludedWeapons, LUF.n_excl, k) >= 0) continue; cJSON *d = cJSON_GetArrayItem(it, 0); if (cJSON_IsTrue(cJSON_GetObjectItem(d, "isPowerUp"))) continue; float m = cJSON_IsTrue(cJSON_GetObjectItem(d, "dropRateAffectedByLuck")) ? PLuck() : 1; acc += num(d, "rarity", 0) * m; if (num(d, "rarity", 0) > 0 && n < 256) tmp[n++] = (WeightedWeapon){ k, acc }; } float r = frand() * acc; for (int i = 0; i < n; i++) if (tmp[i].weight >= r) return tmp[i].weaponType; return NULL; } static const char *LevelUpFactory_GetRandomExistingWeapon(void) { if (frand() <= LevelUpFactory_ChanceForExistingPowerUp()) { const char *list[16]; int n = 0; for (int i = 0; i < Core.n_weapons; i++) list[n++] = Core.Weapons[i]->bulletType; while (n > 0) { const char *w = frand() > 0.5f ? list[0] : list[(int)floorf(frand() * n)]; Weapon *we = Core_GetWeapon(w); int lvl = we ? we->level : 0, idx = strin(list, n, w); if (!(2.5f * (lvl + 1) > Core.Player->level) && strin(LUF.BanishedWeapons, LUF.n_banished, w) < 0 && strin(LUF.WeaponStore, LUF.n_store, w) >= 0) return w; memmove(&list[idx], &list[idx + 1], (n - idx - 1) * sizeof(char *)); // splice n--; } } return NULL; } // GetLevelUpPowerups: le opzioni del pannello, gia' rovesciate come l'originale static int LevelUpFactory_GetLevelUpPowerups(const char **out) { int n = 0, guard = 0; const char *w = LevelUpFactory_GetRandomExistingWeapon(); if (w) out[n++] = w; if ((w = LevelUpFactory_GetRandomExistingWeapon()) && strin(out, n, w) < 0) out[n++] = w; int opts = LevelUpFactory_GetLevelUpOptions(), trueW = count_weapons(0); while (n < opts && guard < 1000) { guard++; w = Core.Player->level <= 3 && trueW < LUF.maxTrueWeapons ? LevelUpFactory_GetRandomWeightedWeapon() : LevelUpFactory_GetRandomWeightedWeaponOrPowerup(); if (w && strin(out, n, w) < 0) out[n++] = w; } for (int i = 0; i < n / 2; i++) { const char *t = out[i]; out[i] = out[n - 1 - i]; out[n - 1 - i] = t; } return n; } // Pesca pesata su una lista di tipi (WeightedWeapon con peso cumulato): find(weight >= r) static const char *weighted_pick(WeightedWeapon *w, int n, float total) { float r = frand() * total; for (int i = 0; i < n; i++) if (w[i].weight >= r) return w[i].weaponType; return NULL; // undefined } static float rarity_weight(cJSON *d) { return num(d, "rarity", 0) * (cJSON_IsTrue(cJSON_GetObjectItem(d, "dropRateAffectedByLuck")) ? PLuck() : 1); } static const char *LevelUpFactory_PullRemainingPowerUp(void) { static WeightedWeapon w[256]; int n = 0; float acc = 0; cJSON *it; cJSON_ArrayForEach(it, data_get("weapons")) { if (strin(LUF.ExcludedWeapons, LUF.n_excl, it->string) >= 0) continue; cJSON *d = cJSON_GetArrayItem(it, 0); if (!cJSON_IsTrue(cJSON_GetObjectItem(d, "isPowerUp"))) continue; acc += rarity_weight(d); if (num(d, "rarity", 0) > 0 && n < 256) w[n++] = (WeightedWeapon){ it->string, acc }; } return weighted_pick(w, n, acc); } static const char *LevelUpFactory_PullExistingRemainingWeapon(int includePowerUps) { WeightedWeapon w[16]; int n = 0; float acc = 0; for (int i = 0; i < Core.n_weapons; i++) { const char *k = Core.Weapons[i]->bulletType; if (strin(LUF.ExcludedWeapons, LUF.n_excl, k) >= 0) continue; cJSON *d = cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("weapons"), k), 0); if (!includePowerUps && cJSON_IsTrue(cJSON_GetObjectItem(d, "isPowerUp"))) continue; acc += rarity_weight(d); if (num(d, "rarity", 0) > 0) w[n++] = (WeightedWeapon){ k, acc }; } return weighted_pick(w, n, acc); } static const char *LevelUpFactory_PullExisting(const char *t) { for (int i = 0; i < LUF.n_weighted; i++) if (!strcmp(LUF.WeightedStore[i].weaponType, t)) return t; return NULL; } static void LevelUpFactory_RemoveFromSpecialWeapons(const char *t) { int i = strin(LUF.SpecialWeapons, LUF.n_special, t); if (i >= 0) { memmove(&LUF.SpecialWeapons[i], &LUF.SpecialWeapons[i + 1], (LUF.n_special - i - 1) * sizeof(char *)); LUF.n_special--; } } static const char *LevelUpFactory_GetSpecialWeapon(const char *t) { if (strin(LUF.SpecialWeapons, LUF.n_special, t) < 0) return NULL; LevelUpFactory_RemoveFromSpecialWeapons(t); return t; } static int LevelUpFactory_InStore(const char *t) { return strin(LUF.WeaponStore, LUF.n_store, t) >= 0; } // WeaponStore.indexOf(t) > -1 static void LevelUpFactory_AddLateWeapon(const char *t) { if (!weapon_vt(t)) return; // WeaponFactory: i tipi non ancora tradotti restano fuori dal LevelUpFactory if (Core_GetWeapon(t) || strin(LUF.BanishedWeapons, LUF.n_banished, t) >= 0) return; if (LUF.n_special < 64) LUF.SpecialWeapons[LUF.n_special++] = t; int i = strin(LUF.ExcludedWeapons, LUF.n_excl, t); if (i >= 0) { memmove(&LUF.ExcludedWeapons[i], &LUF.ExcludedWeapons[i + 1], (LUF.n_excl - i - 1) * sizeof(char *)); LUF.n_excl--; } LevelUpFactory_calculateWeights(); } static const char *LevelUpFactory_PullEvolution(void) { WeightedWeapon w[64]; int n = 0; float acc = 0; int candy = strin(LUF.SpecialWeapons, LUF.n_special, "CANDYBOX2"); if (candy >= 0) LevelUpFactory_RemoveFromSpecialWeapons("CANDYBOX2"); cJSON *weapons = data_get("weapons"); for (int s = 0; s < LUF.n_special; s++) { const char *k = LUF.SpecialWeapons[s]; cJSON *d = cJSON_GetArrayItem(cJSON_GetObjectItem(weapons, k), 0); if (!d || !cJSON_IsTrue(cJSON_GetObjectItem(d, "isEvolution")) || num(d, "rarity", 0) <= 0) continue; int ok = 1; cJSON *r; cJSON_ArrayForEach(r, cJSON_GetObjectItem(d, "requires")) if (!Core_GetWeapon(cJSON_GetStringValue(r))) { ok = 0; break; } if (ok) cJSON_ArrayForEach(r, cJSON_GetObjectItem(d, "requiresMax")) { const char *rk = cJSON_GetStringValue(r); Weapon *have = Core_GetWeapon(rk); if (!have || have->level < cJSON_GetArraySize(cJSON_GetObjectItem(weapons, rk))) { ok = 0; break; } // Object.keys(levels).length } if (ok && n < 64) { acc += num(d, "rarity", 0); w[n++] = (WeightedWeapon){ k, acc }; } } float r = frand() * acc; if (candy >= 0) { if (frand() <= 0.01f * Player_PLuck(Core.Player)) return "CANDYBOX2"; if (LUF.n_special < 64) LUF.SpecialWeapons[LUF.n_special++] = "CANDYBOX2"; } const char *got = NULL; for (int i = 0; i < n; i++) if (w[i].weight >= r) { got = w[i].weaponType; break; } if (got) LevelUpFactory_RemoveFromSpecialWeapons(got); LevelUpFactory_calculateWeights(); return got; } static void LevelUpFactory_CalculateWeightsWithExclusions(const char **excl, int n_excl) { // calculateWeights senza le armi gia' proposte LUF.accumulatedWeight = 0; LUF.n_weighted = 0; cJSON *it; cJSON_ArrayForEach(it, data_get("weapons")) { const char *k = it->string; if (strin(LUF.ExcludedWeapons, LUF.n_excl, k) >= 0 || strin(LUF.SpecialWeapons, LUF.n_special, k) >= 0 || strin(excl, n_excl, k) >= 0) continue; cJSON *d = cJSON_GetArrayItem(it, 0); int isPU = cJSON_IsTrue(cJSON_GetObjectItem(d, "isPowerUp")); if (!Core_GetWeapon(k) && count_weapons(isPU) >= (isPU ? LUF.maxPowerUpWeapons : LUF.maxTrueWeapons)) continue; LUF.accumulatedWeight += rarity_weight(d); if (num(d, "rarity", 0) > 0) LUF.WeightedStore[LUF.n_weighted++] = (WeightedWeapon){ k, LUF.accumulatedWeight }; } } static int LevelUpFactory_RerollLevelUpPowerups(const char **picked, int n_picked, const char **out) { // gia' rovesciate come l'originale int n = 0, guard = 0; const char *w = LevelUpFactory_GetRandomExistingWeapon(); if (w) out[n++] = w; int opts = LevelUpFactory_GetLevelUpOptions(); LevelUpFactory_CalculateWeightsWithExclusions(picked, n_picked); while (n < opts && guard < 1000) { guard++; w = LevelUpFactory_GetRandomWeightedWeaponOrPowerup(); if (w && strin(out, n, w) < 0) out[n++] = w; } for (int i = 0; i < n / 2; i++) { const char *t = out[i]; out[i] = out[n - 1 - i]; out[n - 1 - i] = t; } return n; } static int LevelUpFactory_GetLevelUpItems(const char **out) { // gia' rovesciati int n = 0; if (num(cJSON_GetObjectItem(data_get("items"), "COINBAG2"), "pickedupAmount", 0) >= 0x64) out[n++] = "ALWAYS_ROAST", out[n++] = "ALWAYS_COINBAG2"; out[n++] = "ROAST", out[n++] = "COINBAG2"; return n; } static void LevelUpFactory_Banish(const char *t) { LevelUpFactory_DoExclude(t); if (LUF.n_banished < 64) LUF.BanishedWeapons[LUF.n_banished++] = t; LevelUpFactory_calculateWeights(); } // ============================================================================ // 0xf8d5: LimitBreakManager (con la reliquia Great Gospel e SelectedLimitBreak, a scelte finite) // ExcludedWeapons resta sempre vuoto, WeightedStore non lo legge nessuno: qui niente calculateWeights // ============================================================================ typedef struct { const char *weaponType; float weight; cJSON *keyValues; int wi, li; } WeightedLimitBreak; // 0xce11, id = wi + '-' + li static int LB_capped(Weapon *w, cJSON *kv) { // un valore con max: escluso se una proprieta' dell'arma ci e' gia' arrivata if (!has(kv, "max")) return 0; float mx = num(kv, "max", 0); for (cJSON *k = kv->child; k; k = k->next) { if (!strcmp(k->string, "max") || !strcmp(k->string, "rarity")) continue; float *f = Weapon_field(w, k->string); if (f && *f >= mx) return 1; } return 0; } static int LimitBreakManager_GetRandomWeightedWeapon(WeightedLimitBreak *out) { static WeightedLimitBreak L[256]; int n = 0, wi = 0; float acc = 0; for (int i = 0; i < Core.n_weapons; i++) { Weapon *w = Core.Weapons[i]; if (w->isPowerUp) continue; cJSON *lb = cJSON_GetObjectItem(data_get("weapons_limitbreak"), w->bulletType); int li = 0; for (cJSON *kv = lb ? lb->child : NULL; kv; kv = kv->next, li++) if (!LB_capped(w, kv) && n < 256) acc += num(kv, "rarity", 0), L[n++] = (WeightedLimitBreak){ w->bulletType, acc, kv, wi, li }; wi++; } float r = frand() * acc; for (int i = 0; i < n; i++) if (L[i].weight >= r) { *out = L[i]; return 1; } return 0; // undefined } static int LimitBreakManager_GetLevelUpOptions(void) { return frand() > 1 / PLuck() ? 4 : 3; } static int LimitBreakManager_GetLimitBreakBonuses(WeightedLimitBreak *out) { int n = 0, opts = LimitBreakManager_GetLevelUpOptions(); for (int tries = 0; n < opts && tries < 4; ) { tries++; WeightedLimitBreak b; if (!LimitBreakManager_GetRandomWeightedWeapon(&b)) continue; int dup = 0; for (int i = 0; i < n; i++) dup |= out[i].wi == b.wi && out[i].li == b.li; if (!dup) out[n++] = b; } return n; } static int LimitBreakManager_hasLimitBreaks(void) { for (int i = 0; i < Core.n_weapons; i++) { Weapon *w = Core.Weapons[i]; if (w->isPowerUp) continue; cJSON *lb = cJSON_GetObjectItem(data_get("weapons_limitbreak"), w->bulletType); for (cJSON *kv = lb ? lb->child : NULL; kv; kv = kv->next) { if (!has(kv, "max")) return 1; for (cJSON *k = kv->child; k; k = k->next) { if (!strcmp(k->string, "max") || !strcmp(k->string, "rarity")) continue; float *f = Weapon_field(w, k->string); if (f && *f < num(kv, "max", 0)) return 1; } } } return 0; } // Weapon.ApplyLimitBreak (0xe49a); Gatti, Grangatti, Silf, Silf2 (eredita), Guns3 e Silf3 lo passano anche alle gemelle di Aquarius static int Weapon_ApplyLimitBreak(Weapon *w, cJSON *kv) { for (cJSON *k = kv ? kv->child : NULL; k; k = k->next) { float *f = strcmp(k->string, "rarity") ? Weapon_field(w, k->string) : NULL; if (f && cJSON_IsNumber(k)) { *f += (float)k->valuedouble; int seen = 0; for (int i = 0; i < w->nLbKeys; i++) seen |= !strcmp(w->lbKeys[i], k->string); if (!seen && w->nLbKeys < 16) w->lbKeys[w->nLbKeys++] = k->string; // accumulatedLimitBreaks } } Weapon_ResetFiringTimer(w); w->limitBreakLevel++; if (!w->isPowerUp) Weapon_Fire(w); if (has(kv, "addEvolvedWeapon")) LevelUpFactory_AddLateWeapon(str(kv, "addEvolvedWeapon")); const WeaponVT *v = w->vt; if (v == &W_Gatti || v == &W_Grangatti || v == &W_Silf || v == &W_Silf2 || v == &W_Guns3 || v == &W_Silf3) { if (w->counterWeapon) Weapon_ApplyLimitBreak(w->counterWeapon, kv); if (w->counterWeapon2) Weapon_ApplyLimitBreak(w->counterWeapon2, kv); } return kv != NULL; } static int Core_LimitBreakWeaponUp(const WeightedLimitBreak *lb) { if (!lb || !cJSON_GetObjectItem(data_get("weapons"), lb->weaponType)) return 0; Weapon *w = Core_GetWeapon(lb->weaponType); if (!w) return 0; if (!Weapon_ApplyLimitBreak(w, lb->keyValues)) { PlayerOptions_AddCoins(10); MainUI_UpdateCoins(); } return 1; } // ============================================================================ // HitVFX (0xb68b + pool 0x4669): stella e onda d'urto con i fotogrammi del tipo (0xd195), 120 ms // ============================================================================ typedef struct { Sprite hit, impact; TweenRef t1, t2; int alive; Timer despawn; } HitVFX; static HitVFX hitvfx[64]; static void HitVFX_DeSpawn(void *ctx) { HitVFX *h = ctx; h->alive = 0; children_remove(&h->hit); children_remove(&h->impact); } static void Core_ShowHitVFXAt(float x, float y, int type) { HitVFX *h = NULL; for (int i = 0; i < 64; i++) if (!hitvfx[i].alive) { h = &hitvfx[i]; break; } if (!h) return; // setPosition: la stella a (x + 2, y - 16), l'onda a (x, y - 8); OnRecycle(type) cambia i fotogrammi sprite_init(&h->hit, frame_get("vfx", HitVFXData[type].hitFrameName), x + 2, y - 0x10); sprite_init(&h->impact, frame_get("vfx", HitVFXData[type].impactFrameName), x, y - 8); h->hit.depth = h->impact.depth = 1e9f; sprite_setScale(&h->hit, 0.25f * PixelScale); sprite_setScale(&h->impact, 0.25f * PixelScale); h->t1 = tweens_add((TweenConfig){ .props = { { &h->hit.scaleX, NULL, 0.75f * PixelScale }, { &h->hit.scaleY, NULL, 1.5f * PixelScale } }, .nprops = 2, .duration = 0x5a }); tweens_add((TweenConfig){ .props = { { &h->hit.angle, NULL, 0xb4 } }, .nprops = 1, .duration = 0x5a }); h->t2 = tweens_add((TweenConfig){ .props = { { &h->impact.scaleX, &h->impact.scaleY, PixelScale } }, .nprops = 1, .duration = 0x5a, .delay = 0x1e }); children_add(&h->impact); children_add(&h->hit); h->alive = 1; h->despawn = time_addEvent(0x78, 0, 0, HitVFX_DeSpawn, h); } // ============================================================================ // 0x11163: DamageNumber (BitmapText 'damage') + 0x6687: il suo pool; Core.ShowDamageAt / ShowRecoveryAt // ============================================================================ typedef struct { short x, y, w, h, xo, yo, adv; } Glyph; typedef struct { Texture2D tex; Glyph g[256]; int lineHeight, loaded; } BMFont; // fonts/.xml + png (BMFont) static void BMFont_load(BMFont *f, const char *name) { if (f->loaded) return; f->loaded = 1; f->tex = LoadTexture(vs_path(TextFormat("fonts/%s.png", name))); char *xml = LoadFileText(vs_path(TextFormat("fonts/%s.xml", name))); if (!xml) return; const char *p = strstr(xml, "lineHeight=\""); if (p) f->lineHeight = atoi(p + 12); for (p = xml; (p = strstr(p, "= 0 && id < 256) f->g[id] = (Glyph){ x, y, w, h, xo, yo, adv }; } UnloadFileText(xml); } // BitmapText in coordinate di schermo: larghezza = somma degli xadvance, altezza = lineHeight (GetBitmapTextSize) static void BMFont_draw(BMFont *f, const char *text, float x, float y, float ox, float oy, float sx, float sy, Color c) { if (!f->tex.id || c.a == 0) return; float w = 0, adv = 0; for (const char *ch = text; *ch; ch++) w += f->g[(unsigned char)*ch].adv; for (const char *ch = text; *ch; ch++) { Glyph g = f->g[(unsigned char)*ch]; Rectangle dst = { roundf(x + (adv + g.xo - ox * w) * sx), roundf(y + (g.yo - oy * f->lineHeight) * sy), g.w * sx, g.h * sy }; DrawTexturePro(f->tex, (Rectangle){ g.x, g.y, g.w, g.h }, dst, (Vector2){ 0, 0 }, 0, c); adv += g.adv; } } static BMFont FontDamage; static void FontDamage_load(void) { BMFont_load(&FontDamage, "damNum-export"); } typedef struct DamageNumber { Sprite s; char text[16]; TweenRef tween1, tween2; float duration; int inUse; } DamageNumber; static float DN_RANDOMS[0x1f4], DN_RANDOMSY[0x1f4]; static int DN_INDEX, DN_INDEXY, DN_haveRandoms; static struct { DamageNumber *items[2048]; int n_spawned, n_stored; DamageNumber *stored[2048]; } DamagePool; static void DamageNumber_draw(Sprite *s) { // BitmapText con origine (0.5, 1): larghezza = somma degli xadvance, altezza = lineHeight DamageNumber *d = s->owner; if (!s->visible || s->alpha <= 0 || !FontDamage.tex.id) return; float w = 0; for (const char *c = d->text; *c; c++) w += FontDamage.g[(unsigned char)*c & 127].adv; float ox = s->originX * w, oy = s->originY * FontDamage.lineHeight, adv = 0; Color col = { (s->tint >> 16) & 255, (s->tint >> 8) & 255, s->tint & 255, (unsigned char)(255 * s->alpha) }; for (const char *c = d->text; *c; c++) { Glyph g = FontDamage.g[(unsigned char)*c & 127]; Rectangle dst = { roundf(s->x - camera_scrollX + (adv + g.xo - ox) * s->scaleX), roundf(s->y - camera_scrollY + (g.yo - oy) * s->scaleY), g.w * s->scaleX, g.h * s->scaleY }; DrawTexturePro(FontDamage.tex, (Rectangle){ g.x, g.y, g.w, g.h }, dst, (Vector2){ 0, 0 }, 0, col); adv += g.adv; } } static void DamageNumber_DeSpawn(void *ctx) { // pool.Return (resta nella lista di disegno con alpha 0, come l'originale) DamageNumber *d = ctx; for (int i = 0; i < DamagePool.n_spawned; i++) if (DamagePool.items[i] == d) { DamagePool.items[i] = DamagePool.items[--DamagePool.n_spawned]; break; } // ordine irrilevante: solo il conteggio conta if (DamagePool.n_stored < 2048) DamagePool.stored[DamagePool.n_stored++] = d; } static void DamageNumber_tween1Done(void *ctx) { DamageNumber *d = ctx; if (d->duration == 0x12c) { tween_resume(d->tween2); tween_restart(d->tween2); } else { d->s.visible = 0; DamageNumber_DeSpawn(d); } } static DamageNumber *DamageNumber_new(void) { // constructor + Init DamageNumber *d = calloc(1, sizeof(DamageNumber)); sprite_init(&d->s, NULL, 0, 0); d->s.owner = d; d->s.draw = DamageNumber_draw; d->tween2 = tweens_add((TweenConfig){ .props = { { &d->s.alpha, NULL, 0 }, { &d->s.scaleX, &d->s.scaleY, PixelScale } }, .nprops = 2, .duration = 0x258, .paused = 1, .onComplete = DamageNumber_DeSpawn, .ctx = d, .persist = 1 }); if (!DN_haveRandoms) { DN_haveRandoms = 1; for (int i = 0; i < 0x1f4; i++) DN_RANDOMS[i] = frand() - 0.5f, DN_RANDOMSY[i] = 0xc * frand(); } children_add(&d->s); // scene.add.existing d->s.depth = ZDamageNumber; sprite_setOrigin(&d->s, 0.5f, 1); return d; } static unsigned GetColor3(int r, int g, int b) { return (unsigned)r << 16 | (unsigned)g << 8 | (unsigned)b; } // Display.Color.GetColor static void DamageNumber_OnRecycle(DamageNumber *d, float x, float y, float amount, float duration) { float r = DN_RANDOMS[DN_INDEX % 0x1f4]; DN_INDEX++; float shown = 0xa * (amount + r); d->s.visible = 1; d->s.alpha = 1; sprite_setScale(&d->s, PixelScale); d->s.x = x + 0x20 * r; d->s.y = y - 0x10; snprintf(d->text, sizeof(d->text), "%.0f", shown); // toFixed() if (amount >= 0xa) sprite_setTint(&d->s, 0xffff00); else if (amount >= 6) sprite_setTint(&d->s, GetColor3(0xff, 0x99, 0x80)); else if (amount >= 3) sprite_setTint(&d->s, GetColor3(0xff, 76, 0x40)); // GetColor(255, 76.5, 64): Phaser tronca else if (amount < 0) { sprite_setTint(&d->s, GetColor3(0, 0xff, 0)); snprintf(d->text, sizeof(d->text), "%.0f", -amount); } else sprite_setTint(&d->s, 0xffffff); tween_stop(d->tween1); float dy = DN_RANDOMSY[DN_INDEXY % 0x1f4]; DN_INDEXY++; d->duration = duration; d->tween1 = tweens_add((TweenConfig){ .props = { { &d->s.y, NULL, d->s.y - dy }, { &d->s.scaleX, &d->s.scaleY, 2 } }, .nprops = 2, .duration = duration, .onComplete = DamageNumber_tween1Done, .ctx = d }); } // Profilo Prestazioni: con questo numero di danni gia' a schermo i nuovi non compaiono (le cure si'). A centinaia, ammucchiati, // non si leggono; sulla Vita costano, e ognuno resta poi per sempre nella lista di disegno con i suoi tween. #define DN_PERF_MAX 166 static void DamagePool_SpawnAt(float x, float y, float amount) { float dur = 0x12c; if (amount > 0 && DamagePool.n_spawned > 0x1f4) dur = 0x96; else if (amount > 0 && DamagePool.n_spawned > 0x3e8) return; // irraggiungibile, come nell'originale if (amount > 0 && DamagePool.n_spawned >= DN_PERF_MAX && !vs_quality_mode()) return; if (DamagePool.n_spawned >= 2048) return; // limite dell'array C DamageNumber *d = DamagePool.n_stored ? DamagePool.stored[--DamagePool.n_stored] : DamageNumber_new(); DamagePool.items[DamagePool.n_spawned++] = d; DamageNumber_OnRecycle(d, x, y, amount, dur); } static void Core_ShowDamageAt(float x, float y, float amount) { // i chiamanti controllano DamageNumbersEnabled: qui, una volta per tutti if (!po_is("DamageNumbersEnabled")) return; FontDamage_load(); DamagePool_SpawnAt(x, y, amount); } static void Core_ShowRecoveryAt(float x, float y, float amount) { if (po_is("DamageNumbersEnabled") && amount >= 1) { FontDamage_load(); DamagePool_SpawnAt(x, y, -amount); } } // ============================================================================ // 0x29bc: LootManager (cosa lasciano i bracieri) // ============================================================================ typedef struct { const char *itemType; float weight; } WeightedItem; static struct { WeightedItem WeightedStore[32]; int n; float accumulatedWeight; } LootManager; static void LootManager_calculateWeights(void) { LootManager.accumulatedWeight = 0; LootManager.n = 0; cJSON *it; cJSON_ArrayForEach(it, data_get("items")) { if (str(it, "requiresItem") && !po_has("CollectedItems", str(it, "requiresItem"))) continue; // 'missing required item' float ua = Arcanas.pewpew && !strcmp(it->string, "VACUUM") ? 0 : num(it, "unlocksAt", 0); // Game Killer: VACUUM.unlocksAt = 0 if (Core.Player->level < ua) continue; float r = num(it, "rarity", 0), m = !strcmp(it->string, "OROLOGION") && Arcanas_has(12) ? 2 : 1; // Out of Time: Orologion doppio LootManager.accumulatedWeight += cJSON_IsTrue(cJSON_GetObjectItem(it, "isRare")) ? r * Player_PLuck(Core.Player) * m : r; // PLuck if (r > 0 && LootManager.n < 32) LootManager.WeightedStore[LootManager.n++] = (WeightedItem){ it->string, LootManager.accumulatedWeight }; } // coins_WeightedStore (COIN, COINBAG1, COINBAGMAX): usato da GetRandomWeightedCoin, non ancora chiamato } static void LootManager_MakeCustomLootTable(cJSON *table) { // Stage.LootTable (Bone Zone, Bat Country, ...): solo questi oggetti LootManager.accumulatedWeight = 0; LootManager.n = 0; cJSON *t; cJSON_ArrayForEach(t, table) { cJSON *it = cJSON_GetObjectItem(data_get("items"), cJSON_GetStringValue(t)); if (!it || (str(it, "requiresItem") && !Collected(str(it, "requiresItem")))) continue; // 'missing required item' if (Core.Player->level < num(it, "unlocksAt", 0)) continue; float r = num(it, "rarity", 0); LootManager.accumulatedWeight += cJSON_IsTrue(cJSON_GetObjectItem(it, "isRare")) ? r * Player_PLuck(Core.Player) : r; if (r > 0 && LootManager.n < 32) LootManager.WeightedStore[LootManager.n++] = (WeightedItem){ it->string, LootManager.accumulatedWeight }; } } static cJSON *forcedLootTable; // SetPlainLootTable (il pianoforte della Biblioteca) static void LootManager_RecalculateLoot(void) { if (forcedLootTable) LootManager_MakeCustomLootTable(forcedLootTable); else if (Core.Stage && Core.Stage->LootTable) LootManager_MakeCustomLootTable(Core.Stage->LootTable); else LootManager_calculateWeights(); } static void LootManager_Init(void) { forcedLootTable = NULL; LootManager_calculateWeights(); } static void LootManager_SetPlainLootTable(void) { static cJSON *plain; if (!plain) plain = cJSON_CreateStringArray((const char *[]){ "COIN", "COINBAG1", "COINBAGMAX", "ROAST", "NFT" }, 5); forcedLootTable = plain; LootManager_RecalculateLoot(); } static const char *LootManager_GetRandomWeightedItem(void) { float r = frand() * LootManager.accumulatedWeight; for (int i = 0; i < LootManager.n; i++) if (LootManager.WeightedStore[i].weight >= r) return LootManager.WeightedStore[i].itemType; // SealedItems: nessuno return NULL; // undefined } // ============================================================================ // 0x13fb9: Destructible (braciere) + 0x9297: il suo pool // ============================================================================ // Stage.hasLights (The Bone Zone): scene.lights con luce ambiente 0x302020, il riflettore sul giocatore e una luce per braciere. // Solo lo sfondo a piastrelle (BGMan.bgtile) usa la pipeline Light2D: lo shader e' quello di Phaser 3.55 (Light-frag) con la normale piatta. #define LIGHTS_MAX 12 // riflettore + maxDestructibles + 1 luci di candela (10 + 1 nella Bone Zone) typedef struct Light2D { float x, y, radius, intensity; unsigned color; int visible; void *owner; } Light2D; static struct { int on; Light2D lights[LIGHTS_MAX]; int n; unsigned ambient; Shader sh; int locPos, locCol, locRad, locInt, locAmb, locRes; } Lights; static Light2D *Core_GetLight(void *owner) { // Core.GetLight: la prima luce di candela libera for (int i = 1; i < Lights.n; i++) if (!Lights.lights[i].owner) { Lights.lights[i].owner = owner; return &Lights.lights[i]; } return NULL; } static void Lights_Init(int maxDestructibles) { // Core: scene.lights.enable(), addLight(0, 0, 280).setIntensity(0.65), candele memset(&Lights.lights, 0, sizeof(Lights.lights)); Lights.on = 1, Lights.ambient = 0x302020; Lights.lights[0] = (Light2D){ 0, 0, 0x118, 0.65f, 0xffffff, 1, NULL }; Lights.n = 1; for (int i = 0; i <= maxDestructibles && Lights.n < LIGHTS_MAX; i++) Lights.lights[Lights.n++] = (Light2D){ -0x61a80, -0x61a80, 0x50, 0.9f, 0xdd8800, 0, NULL }; static TweenProp props[2 * LIGHTS_MAX]; int k = 0; for (int i = 1; i < Lights.n; i++) props[k++] = (TweenProp){ &Lights.lights[i].radius, NULL, 0x5a }, props[k++] = (TweenProp){ &Lights.lights[i].intensity, NULL, 1.1f }; tweens_add((TweenConfig){ .many = props, .nmany = k, .yoyo = 1, .duration = 0x1f4, .repeat = -1 }); if (!Lights.sh.id) { static const char *BODY = "uniform vec2 lpos[12]; uniform vec3 lcol[12]; uniform float lrad[12]; uniform float lint[12]; uniform vec3 ambient; uniform vec2 res;\n" "vec4 lit(vec4 color) {\n" " vec3 fc = vec3(0.0); float rr = min(res.x, res.y);\n" " for (int i = 0; i < 12; i++) {\n" " vec3 d = vec3((lpos[i] - gl_FragCoord.xy) / rr, 0.1); float len = length(d);\n" " float rad = lrad[i] / rr; float att = clamp(1.0 - len * len / (rad * rad), 0.0, 1.0);\n" " fc += att * lcol[i] * (0.1 / len) * lint[i];\n" // diffuseFactor = dot((0,0,1), normalize(d)) " }\n" " return color * vec4(ambient + fc, 1.0);\n" "}\n"; char fs[2048]; #ifdef __vita__ snprintf(fs, sizeof(fs), "#version 100\nprecision mediump float;\nvarying vec2 fragTexCoord;\nvarying vec4 fragColor;\nuniform sampler2D texture0;\n%s" "void main() { gl_FragColor = lit(texture2D(texture0, fragTexCoord) * fragColor); }\n", BODY); #else snprintf(fs, sizeof(fs), "#version 330\nin vec2 fragTexCoord;\nin vec4 fragColor;\nuniform sampler2D texture0;\nout vec4 finalColor;\n%s" "void main() { finalColor = lit(texture(texture0, fragTexCoord) * fragColor); }\n", BODY); #endif Lights.sh = LoadShaderFromMemory(NULL, fs); Lights.locPos = GetShaderLocation(Lights.sh, "lpos"), Lights.locCol = GetShaderLocation(Lights.sh, "lcol"); Lights.locRad = GetShaderLocation(Lights.sh, "lrad"), Lights.locInt = GetShaderLocation(Lights.sh, "lint"); Lights.locAmb = GetShaderLocation(Lights.sh, "ambient"), Lights.locRes = GetShaderLocation(Lights.sh, "res"); } } static void Lights_Begin(void) { // uniform delle luci in coordinate di gl_FragCoord (origine in basso a sinistra del render target) float pos[2 * LIGHTS_MAX] = { 0 }, col[3 * LIGHTS_MAX] = { 0 }, rad[LIGHTS_MAX], in[LIGHTS_MAX] = { 0 }; for (int i = 0; i < LIGHTS_MAX; i++) { Light2D *l = &Lights.lights[i]; rad[i] = i < Lights.n ? l->radius : 1; if (i >= Lights.n || !l->visible) continue; pos[2 * i] = l->x - camera_scrollX, pos[2 * i + 1] = game_height - (l->y - camera_scrollY); col[3 * i] = (l->color >> 16 & 0xff) / 255.0f, col[3 * i + 1] = (l->color >> 8 & 0xff) / 255.0f, col[3 * i + 2] = (l->color & 0xff) / 255.0f; in[i] = l->intensity; } float amb[3] = { (Lights.ambient >> 16 & 0xff) / 255.0f, (Lights.ambient >> 8 & 0xff) / 255.0f, (Lights.ambient & 0xff) / 255.0f }, res[2] = { game_width, game_height }; SetShaderValueV(Lights.sh, Lights.locPos, pos, SHADER_UNIFORM_VEC2, LIGHTS_MAX); SetShaderValueV(Lights.sh, Lights.locCol, col, SHADER_UNIFORM_VEC3, LIGHTS_MAX); SetShaderValueV(Lights.sh, Lights.locRad, rad, SHADER_UNIFORM_FLOAT, LIGHTS_MAX); SetShaderValueV(Lights.sh, Lights.locInt, in, SHADER_UNIFORM_FLOAT, LIGHTS_MAX); SetShaderValue(Lights.sh, Lights.locAmb, amb, SHADER_UNIFORM_VEC3); SetShaderValue(Lights.sh, Lights.locRes, res, SHADER_UNIFORM_VEC2); BeginShaderMode(Lights.sh); } typedef struct DestructiblePool DestructiblePool; typedef struct { Sprite s; float hp, maxHp; int isDead, receivingDamage, isTeleportOnCull; const char *destructibleType; DestructiblePool *pool; Animation idle; Timer _blinkTimeout; int hasFired; // Prop_Window (0x85ba) Light2D *light; // Stage.hasLights: Core.GetLight int sealKind, alreadyDestroyed; // Prop_FoscariSeal1/2/3 Animation destroyAnim; } Destructible; struct DestructiblePool { const char *propType; Destructible **stored, **spawned; int n_stored, n_spawned, cap_stored, cap_spawned; }; static Destructible *Destructible_new(DestructiblePool *pool, const char *type) { Destructible *d = calloc(1, sizeof(Destructible)); sprite_init(&d->s, frame_get("items", "Brazier1.png"), 0, 0); d->s.owner = d; d->hp = d->maxHp = 1; d->pool = pool; d->destructibleType = type; d->_blinkTimeout = (Timer){ -1, 0 }; cJSON *pd = cJSON_GetObjectItem(data_get("props"), type); d->maxHp = num(pd, "maxHp", 1); make_anim(&d->idle, str(pd, "textureName"), str(pd, "frameName"), 1, 3, 0, 0xa, -1); physics_existing(&d->s); d->s.body.immovable = 1; sprite_setScale(&d->s, PixelScale); sprite_setOrigin(&d->s, 0.5f, 1); d->s.depth = d->s.y; // body.setSize(2 x frame): sostituito da setCircle(16) in OnRecycle if (Core.Stage && Core.Stage->hasLights) d->light = Core_GetLight(d); return d; } static void Destructible_OnRecycle(Destructible *d) { d->hp = d->maxHp; d->isDead = 0; d->s.visible = 1; d->s.body.enable = 1; body_setCircle(&d->s.body, 0x10, d->s.body.offset.x, d->s.body.offset.y); if (d->light) d->light->visible = 1, d->light->x = d->s.x, d->light->y = d->s.y; sprite_setTint(&d->s, 0xffffff); d->s.depth = d->s.y - Core.Player->s.y; if (!strcmp(d->destructibleType, "WINDOW")) d->hasFired = 0, d->s.y += 0xb; // Prop_Window: dopo la depth (sic) } static void DestructiblePool_Return(DestructiblePool *pool, Destructible *d) { children_remove(&d->s); for (int i = 0; i < pool->n_spawned; i++) if (pool->spawned[i] == d) { memmove(&pool->spawned[i], &pool->spawned[i + 1], (pool->n_spawned - i - 1) * sizeof(Destructible *)); pool->n_spawned--; break; } list_remove(&Core.Destructibles, &d->s); if (pool->n_stored == pool->cap_stored) { pool->cap_stored = pool->cap_stored ? 2 * pool->cap_stored : 16; pool->stored = realloc(pool->stored, pool->cap_stored * sizeof(Destructible *)); } pool->stored[pool->n_stored++] = d; } static void Destructible_DeSpawn(Destructible *d); static void Destructible_DeSpawnFwd(void *d) { Destructible_DeSpawn(d); } static void Destructible_DeSpawn(Destructible *d) { time_removeEvent(d->_blinkTimeout); d->isDead = 1; DestructiblePool_Return(d->pool, d); d->s.body.enable = 0; d->s.visible = 0; if (d->light) d->light->visible = 0; } static void Destructible_restoreTint(void *ctx) { Destructible *d = ctx; sprite_setTint(&d->s, 0xffffff); if (d->hp <= 0) { time_removeEvent(d->_blinkTimeout); Destructible_DeSpawn(d); } } static void Destructible_OnGetDamaged(Destructible *d) { sprite_setTintFill(&d->s, 0xffffff); // FlashingVFXEnabled time_removeEvent(d->_blinkTimeout); d->_blinkTimeout = time_addEvent(0x78, 0, 0, Destructible_restoreTint, d); // 'Blink' } static Pickup *Core_MakePickup(float x, float y, const char *type); static void Destructible_OnDestroyed(Destructible *d) { if (!strcmp(d->destructibleType, "WINDOW")) { // Prop_Window: niente bottino; vicino al giocatore la vetrata spara (fancyBG.WindowWeapon) if (d->hasFired) return; d->hasFired = 1; if (fabsf(d->s.x - Core.Player->s.x) >= 0.5f * game_width || fabsf(d->s.y - Core.Player->s.y) >= 0.5f * game_height) return; json_inc(cJSON_GetObjectItem(data_get("props"), d->destructibleType), "destroyedAmount"); if (Core.Stage->WindowWeapon) Weapon_FireOneBullet(Core.Stage->WindowWeapon, d->s.x, d->s.y, 0); return; } const char *it = LootManager_GetRandomWeightedItem(); if (it) Core_MakePickup(d->s.x, d->s.y, it); json_inc(cJSON_GetObjectItem(data_get("props"), d->destructibleType), "destroyedAmount"); if (Arcanas_has(19)) Arcanas_TriggerFire(d->s.x, d->s.y - 0x18); } static void Seal_GetDamaged(Destructible *d, float amount); static void Destructible_GetDamaged(Destructible *d, float amount) { if (d->sealKind) { Seal_GetDamaged(d, amount); return; } if (d->isDead) return; d->hp -= amount; if (d->hp <= 0) { d->isDead = 1; Destructible_OnDestroyed(d); Destructible_OnGetDamaged(d); } Destructible_OnGetDamaged(d); } static void Destructible_GetDamagedFwd(void *d, float amount) { Destructible_GetDamaged(d, amount); } // per le armi, definite prima static int Destructible_isDead(void *d) { return ((Destructible *)d)->isDead; } static Destructible *DestructiblePool_SpawnAt(DestructiblePool *pool, float x, float y, const char *type) { Destructible *d = pool->n_stored ? pool->stored[--pool->n_stored] : NULL; // Spawn if (!d) { d = Destructible_new(pool, type); anims_play(&d->s, &d->idle, 0); } // Make + Init children_add(&d->s); // this.add(obj, true): anche nella lista di disegno if (pool->n_spawned == pool->cap_spawned) { pool->cap_spawned = pool->cap_spawned ? 2 * pool->cap_spawned : 16; pool->spawned = realloc(pool->spawned, pool->cap_spawned * sizeof(Destructible *)); } pool->spawned[pool->n_spawned++] = d; list_add(&Core.Destructibles, &d->s); d->s.x = x, d->s.y = y; Destructible_OnRecycle(d); return d; } // Core.GetPositionOutOfSight(angleRange, margin) static Vector2 Core_GetPositionOutOfSight(float angleRange, float margin) { Player *p = Core.Player; float a = angleRange <= 0 ? 2 * PI * frand() : atan2f(p->s.body.velocity.y, p->s.body.velocity.x) + (frand() - 0.5f) * angleRange * DEG2RAD; if (margin > 0) { float c = cosf(a), s = sinf(a); return (Vector2){ p->s.x + 0.5f * c * game_width + (c > 0 ? 1 : c < 0 ? -1 : 0) * margin, p->s.y + 0.5f * s * game_height + (s > 0 ? 1 : s < 0 ? -1 : 0) * margin }; } return (Vector2){ p->s.x + 0.9f * cosf(a) * game_width, p->s.y + 0.9f * sinf(a) * game_height }; } // Core.MakeDestructible: x/y assenti = fuori vista (nella direzione di marcia se ci si muove) static Destructible *Core_MakeDestructibleAt(const char *type, Vector2 pos); static Destructible *Core_MakeDestructible(const char *type) { float range = Core.Player->s.body.velocity.x == 0 && Core.Player->s.body.velocity.y == 0 ? 0 : 0x2d; return Core_MakeDestructibleAt(type, Core_GetPositionOutOfSight(range, 0)); } static Destructible *Core_MakeDestructibleAt(const char *type, Vector2 pos) { DestructiblePool *pool = NULL; for (int i = 0; i < Core.n_destructiblesPools; i++) if (!strcmp(Core.destructiblesPools[i]->propType, type)) pool = Core.destructiblesPools[i]; if (!pool) { if (Core.n_destructiblesPools >= 8) return NULL; pool = calloc(1, sizeof(DestructiblePool)); pool->propType = type; Core.destructiblesPools[Core.n_destructiblesPools++] = pool; } Destructible *d = DestructiblePool_SpawnAt(pool, pos.x, pos.y, type); while (pool->n_spawned > Core.MaxDestructibles) { // il piu' lontano sparisce Destructible *far = NULL; float best = -1; for (int i = 0; i < pool->n_spawned; i++) { float dx = pool->spawned[i]->s.x - Core.Player->s.x, dy = pool->spawned[i]->s.y - Core.Player->s.y; if (dx * dx + dy * dy > best) best = dx * dx + dy * dy, far = pool->spawned[i]; } if (!far) break; Destructible_DeSpawn(far); } return d; } // Stage: DestructibleTimer ('Desct Timer') static void Stage_SpawnDestructibleWallsCheck(Stage *st); static void Stage_SpawnDestructibleInRandomLocation(Stage *st); static void Stage_SpawnCartInRandomLocation(Stage *st); static void Stage_SpawnWindowInRandomLocation(Stage *st); static void Stage_SpawnDestructibleOutOfSight(Stage *st) { if (0x64 * frand() <= fminf(st->destructibleChance * Player_PLuck(Core.Player), st->destructibleChanceMax)) Core_MakeDestructible(st->destructibleType); } static void Stage_DestructibleTick(void *ctx) { Stage *st = ctx; if (st->hasWallsCheckDestructibleLogic) Stage_SpawnDestructibleWallsCheck(st); else if (st->hasTileset && st->n_DestructibleLocations > 0) Stage_SpawnWindowInRandomLocation(st), Stage_SpawnDestructibleInRandomLocation(st), Stage_SpawnCartInRandomLocation(st); else Stage_SpawnDestructibleOutOfSight(st); } // ============================================================================ // Core.RosaryDamage (0x1bf7 RosaryVFX), Core.TimeStop (0x68d2 OrologionVFX), TurnOnVacuum // Ogni Play dell'originale crea un nuovo oggetto mai distrutto; qui se ne riusa uno (stesso aspetto). // ============================================================================ static struct { Sprite burst, flash; Animation enter; } RosaryVFX; static void RosaryVFX_Play(void) { children_remove(&RosaryVFX.burst); children_remove(&RosaryVFX.flash); sprite_init(&RosaryVFX.burst, frame_get("vfx", "Burst1.png"), 0.5f * game_width, 0.5f * game_height); RosaryVFX.burst.scrollFactor0 = 1; children_add(&RosaryVFX.burst); sprite_init(&RosaryVFX.flash, frame_get("vfx", "WhiteDot.png"), 0, 0); Sprite *f = &RosaryVFX.flash; f->scrollFactor0 = 1; f->scaleX = game_width, f->scaleY = game_height; f->alpha = 0; sprite_setOrigin(f, 0, 0); f->depth = 0x2710; children_add(f); tweens_add((TweenConfig){ .props = { { &f->alpha, NULL, 1 } }, .nprops = 1, .duration = 0x64, .yoyo = 1 }); make_anim(&RosaryVFX.enter, "vfx", "Burst", 1, 6, 0, 0x1e, 0); sprite_setScale(&RosaryVFX.burst, 8); RosaryVFX.burst.depth = 0x2710; RosaryVFX.burst.blendAdd = 1; anims_play(&RosaryVFX.burst, &RosaryVFX.enter, 0); Sound_PlaySound("Rosary", 1.8f, 2, 0, 0x1f4, 2); // Play(1.8) } static void Core_RosaryDamage(void) { Core_RosaryDamageEx(1); } static void Core_RosaryDamageEx(int vfx) { if (vfx) RosaryVFX_Play(); // FlashingVFXEnabled for (int i = 0; i < Core.Enemies.n; i++) { Enemy *e = Core.Enemies.items[i]->owner; if (!e->res_Rosary && ContainmentRect_Contains(&Core.containmentRect_Screen, &e->s)) Enemy_GetDamaged(e, fmaxf(0x42, e->maxHp), 0, 0, "ROSARY"); } } static struct { Sprite wave, flash; } OrologionVFX; static void OrologionVFX_Play(void) { Sprite *w = &OrologionVFX.wave, *f = &OrologionVFX.flash; children_remove(w); children_remove(f); sprite_init(w, frame_get("vfx", "Shockwave3.png"), 0.5f * game_width, 0.5f * game_height); w->scrollFactor0 = 1; children_add(w); sprite_init(f, frame_get("vfx", "WhiteDot.png"), 0, 0); f->scrollFactor0 = 1; f->scaleX = game_width, f->scaleY = game_height; f->alpha = 0; sprite_setOrigin(f, 0, 0); sprite_setTint(f, 0xff); f->blendAdd = 1; children_add(f); tweens_add((TweenConfig){ .props = { { &f->alpha, NULL, 0.2f } }, .nprops = 1, .duration = 0x1f4 }); // tween1 (Play lo riavvia) tweens_add((TweenConfig){ .props = { { &f->alpha, NULL, 0 } }, .nprops = 1, .duration = 0x1f4, .delay = 0x251c }); tweens_add((TweenConfig){ .props = { { &w->angle, NULL, 0x167 } }, .nprops = 1, .duration = 0x3e8, .repeat = -1 }); tweens_add((TweenConfig){ .props = { { &w->alpha, NULL, 0 } }, .nprops = 1, .duration = 0x3e8, .delay = 0x2328 }); float dh = w->height * w->scaleY; tweens_add((TweenConfig){ .props = { { &w->scaleX, &w->scaleY, dh > 0 ? 1.2f * game_height / dh : 1 } }, .nprops = 1, .duration = 0xc8 }); w->depth = 0x3e8; w->blendAdd = 1; sprite_setTint(w, 0xff); Sound_PlaySound("Orologion", 1.8f, 2, 0, 0, 0); } static void Enemy_ResumeFromTimeStop(Enemy *e) { e->IsTimeStopped = 0; e->speed = e->defaultSpeed; Enemy_restoreTint(e); if (e->idleFrameCount) anims_resume(&e->s); } static void Core_ClearTimeStop(void *ctx) { (void)ctx; for (int i = 0; i < Core.Enemies.n; i++) Enemy_ResumeFromTimeStop(Core.Enemies.items[i]->owner); Core.IsTimeStopped = 0; } static void Core_TimeStop(void) { OrologionVFX_Play(); // FlashingVFXEnabled Core.IsTimeStopped = 1; for (int i = 0; i < Core.Enemies.n; i++) { Enemy_TimeStop(Core.Enemies.items[i]->owner); if (Arcanas_has(12)) Arcanas_TriggerCold(Core.Enemies.items[i]->x, Core.Enemies.items[i]->y); // Out of Time } time_removeEvent(Core.TimeStopTimer); // TimeStopTimer.destroy Core.TimeStopTimer = time_addEvent(0x2710, 0, 0, Core_ClearTimeStop, NULL); // TimeStopConfig } static void Core_TurnOnVacuum(void) { PickupSlot *gp = PickupPool_slot(&Core.gemsPool, "GEM"); for (int i = 0; gp && i < gp->n_spawned; i++) gp->spawned[i]->goToPlayer = 1; } static void Core_TurnOnVacuumForGold(void) { static const char *gold[] = { "COIN", "COINBAG1", "COINBAGMAX" }; for (int k = 0; k < 3; k++) { PickupSlot *sl = PickupPool_slot(&Core.pickupPool, gold[k]); for (int i = 0; sl && i < sl->n_spawned; i++) sl->spawned[i]->goToPlayer = 1, sl->spawned[i]->time = 1; } } // ============================================================================ // 0x11804: Stage (spawn nemici) // ============================================================================ static float GetPermanentEnemiesNumber(Stage *st) { return Core.Enemies.n - st->stageEventManager_spawned; } static void Stage_CalculateEnemySpeed(Stage *st) { EnemySpeed = _baseEnemySpeed * st->StageModifiers.EnemySpeed * Player_PCurse(Core.Player) * st->EnemySpeedMultiplier; } static void Stage_RecalculateCurse(Stage *st) { float a = Player_PCurse(Core.Player) + 0.5f * st->StageModifiers.EndCycles, b = Player_PCurse(Core.Player) + 1 * st->StageModifiers.EndCycles; st->minimumMultiplier = b; Stage_CalculateEnemySpeed(st); st->EffectiveSpawnFrequency = st->frequency / fmaxf(0.1f, a); st->minimum += Core.Player->charm, st->maximum = st->defaultMaximum + Core.Player->charm; } static void Stage_updateEnemyPools(Stage *st) { for (int i = 0; i < st->n_pools; i++) st->pools[i]->enabled = 0; cJSON *e; cJSON_ArrayForEach(e, st->enemies) { const char *t = cJSON_GetStringValue(e); EnemyPool *found = NULL; for (int i = 0; i < st->n_pools; i++) if (!strcmp(st->pools[i]->enemyType, t)) { found = st->pools[i]; break; } if (found) found->enabled = 1; else if (st->n_pools < 256) st->pools[st->n_pools++] = EnemyPool_new(t); } for (int i = 0; i < st->n_bossPools; i++) st->bossPools[i]->enabled = 0; cJSON_ArrayForEach(e, st->bosses) { const char *t = cJSON_GetStringValue(e); EnemyPool *found = NULL; for (int i = 0; i < st->n_bossPools; i++) if (!strcmp(st->bossPools[i]->enemyType, t)) { found = st->bossPools[i]; break; } if (found) found->enabled = 1; else if (st->n_bossPools < 64) st->bossPools[st->n_bossPools++] = EnemyPool_new(t); } for (int i = 0; i < st->n_arcanaPools; i++) st->arcanaPools[i]->enabled = 0; if (st->arcanaHolder) { EnemyPool *found = NULL; for (int i = 0; i < st->n_arcanaPools; i++) if (!strcmp(st->arcanaPools[i]->enemyType, st->arcanaHolder)) found = st->arcanaPools[i]; if (found) found->enabled = 1; else if (st->n_arcanaPools < 4) st->arcanaPools[st->n_arcanaPools++] = EnemyPool_new(st->arcanaHolder); } } static Vector2 RandomOutside(Rectangle o, Rectangle in) { // Phaser.Geom.Rectangle.RandomOutside (inner contenuto in outer) float x = 0, y = 0; switch (RND_between(0, 3)) { case 0: x = o.x + frand() * (in.x + in.width - o.x); y = o.y + frand() * (in.y - o.y); break; case 1: x = in.x + frand() * (o.x + o.width - in.x); y = in.y + in.height + frand() * (o.y + o.height - (in.y + in.height)); break; case 2: x = o.x + frand() * (in.x - o.x); y = in.y + frand() * (o.y + o.height - in.y); break; case 3: x = in.x + in.width + frand() * (o.x + o.width - (in.x + in.width)); y = o.y + frand() * (in.y + in.height - o.y); break; } return (Vector2){ x, y }; } static int geomRect_contains(Rectangle r, float x, float y) { return r.width > 0 && r.height > 0 && r.x <= x && r.x + r.width >= x && r.y <= y && r.y + r.height >= y; } // Rectangle.Contains static int Stage_isSpawnType(Stage *st, const char *t) { return st->spawnType && !strcmp(st->spawnType, t); } static int Stage_hasSpawners(Stage *st) { return st->hasTileset && st->n_EnemySpanwersLocations > 0; } static Vector2 Stage_pickSpawner(Stage *st) { return st->EnemySpanwersLocations[(int)floorf(frand() * st->n_EnemySpanwersLocations)]; } // RND.pick static Vector2 Stage_GetBossyPosition(Stage *st) { if (Stage_isSpawnType(st, "HORIZONTAL") && Stage_hasSpawners(st)) { float ox = frand() < 0.5f ? st->rectOuter.x : st->rectOuter.x + st->rectOuter.width; return (Vector2){ Core.Player->s.x + ox, Stage_pickSpawner(st).y }; } if (Stage_isSpawnType(st, "VERTICAL") && Stage_hasSpawners(st)) { float oy = frand() >= 0.5f ? st->rectOuter.y : st->rectOuter.y + st->rectOuter.height; return (Vector2){ Stage_pickSpawner(st).x, Core.Player->s.y + oy }; } if (Stage_isSpawnType(st, "TILED")) { float a = 2 * PI * frand(), r = 0x100 * frand(); return (Vector2){ Core.Player->s.x + 0.9f * cosf(a) * (game_width + r), Core.Player->s.y + 0.9f * sinf(a) * (game_height + r) }; } Vector2 r = RandomOutside(st->rectOuter, st->rectInner); return (Vector2){ Core.Player->s.x + r.x, Core.Player->s.y + r.y }; } static Enemy *Stage__spawnOneOutOfSight(EnemyPool *pool) { float a = 2 * PI * frand(), r = 0x100 * frand(); return EnemyPool_SpawnAt(pool, Core.Player->s.x + 0.9f * cosf(a) * (game_width + r), Core.Player->s.y + 0.9f * sinf(a) * (game_height + r)); } static Enemy *Stage__spawnOneInRandomLocationHorizontal(Stage *st, EnemyPool *pool) { float ox = frand() < 0.5f ? st->rectOuter.x : st->rectOuter.x + st->rectOuter.width; return EnemyPool_SpawnAt(pool, Core.Player->s.x + ox, Stage_pickSpawner(st).y); } static Enemy *Stage__spawnOneInRandomLocationVertical(Stage *st, EnemyPool *pool) { float oy = frand() >= 0.5f ? st->rectOuter.y : st->rectOuter.y + st->rectOuter.height; float x = Stage_pickSpawner(st).x; return EnemyPool_SpawnAt(pool, x, Core.Player->s.y + oy); } static Enemy *Stage__spawnOneInOuterRect(Stage *st, EnemyPool *pool, int checkWalls) { Vector2 r = RandomOutside(st->rectOuter, st->rectInner); float x = Core.Player->s.x + r.x, y = Core.Player->s.y + r.y; if (checkWalls && st->tilingTileset && TilingTileset_isPointWithinCollisionLayer(st->tilingTileset, x, y)) return NULL; return EnemyPool_SpawnAt(pool, x, y); } static void Stage_SwarmCheck(Stage *st); static void Stage_SpawnEnemiesInOuterRect(Stage *st) { if (GetPermanentEnemiesNumber(st) >= st->maximum) return; Enemy *r = NULL; for (int i = 0; i < st->n_pools; i++) if (st->pools[i]->enabled) r = Stage__spawnOneInOuterRect(st, st->pools[i], 1); if (r) Stage_SwarmCheck(st); } static void Stage_SwarmCheck(Stage *st) { if (GetPermanentEnemiesNumber(st) >= st->maximum) return; float target = fminf(st->minimum * st->minimumMultiplier, st->maximum); for (int i = 0; GetPermanentEnemiesNumber(st) < target && i < st->maximum;) { Stage_SpawnEnemiesInOuterRect(st); i++; } } static Enemy *Stage__spawnOneByType(Stage *st, EnemyPool *pool) { // SpawnBoss / SpawnArcanaHolder if (Stage_isSpawnType(st, "HORIZONTAL") && Stage_hasSpawners(st)) return Stage__spawnOneInRandomLocationHorizontal(st, pool); if (Stage_isSpawnType(st, "VERTICAL") && Stage_hasSpawners(st)) return Stage__spawnOneInRandomLocationVertical(st, pool); if (Stage_isSpawnType(st, "TILED")) return Stage__spawnOneOutOfSight(pool); return Stage__spawnOneInOuterRect(st, pool, 0); } // SpawnEnemiesOutOfSight: definita ma mai chiamata nell'originale static void Stage_SpawnInRandomLocationH(Stage *st) { if (GetPermanentEnemiesNumber(st) >= st->maximum) return; float target = fminf(st->minimum * st->minimumMultiplier, st->maximum); for (int i = 0; GetPermanentEnemiesNumber(st) < target && i < st->maximum; i++) for (int k = 0; k < st->n_pools; k++) if (st->pools[k]->enabled) Stage__spawnOneInRandomLocationHorizontal(st, st->pools[k]); } static void Stage_SpawnInRandomLocationV(Stage *st) { if (GetPermanentEnemiesNumber(st) >= st->maximum) return; float target = fminf(st->minimum * st->minimumMultiplier, st->maximum); for (int i = 0; GetPermanentEnemiesNumber(st) < target && i < st->maximum; i++) for (int k = 0; k < st->n_pools; k++) if (st->pools[k]->enabled) Stage__spawnOneInRandomLocationVertical(st, st->pools[k]); } static Tile *TilingTileset_getSpawningLayerTile(struct TilingTileset *t, float x, float y); static void Stage_SpawnEnemiesMapped(Stage *st) { // Astral Stair: il layer Spawning dice quale nemico (poolsMapping[tile.index]) if (GetPermanentEnemiesNumber(st) >= st->maximum) return; float target = fminf(st->minimum * st->minimumMultiplier, st->maximum); for (int i = 0; GetPermanentEnemiesNumber(st) < target && i < st->maximum; i++) { Vector2 r = RandomOutside(st->rectOuter, st->rectInner); float x = Core.Player->s.x + r.x, y = Core.Player->s.y + r.y; Tile *t = TilingTileset_getSpawningLayerTile(st->tilingTileset, x, y); if (t) { if (t->index < st->n_mappedPools && st->mappedPools[t->index]) EnemyPool_SpawnAt(st->mappedPools[t->index], x, y); } else if (TilingTileset_isPointWithinCollisionLayer(st->tilingTileset, x, y)) continue; else for (int k = 0; k < st->n_pools; k++) if (st->pools[k]->enabled) EnemyPool_SpawnAt(st->pools[k], x, y); } } static void shuffleV(Vector2 *a, int n) { // RND.shuffle for (int i = n - 1; i > 0; i--) { int j = (int)floorf(frand() * (i + 1)); Vector2 t = a[i]; a[i] = a[j]; a[j] = t; } } static void Stage_SpawnEnemiesTiled(Stage *st) { // Il Molise: nemici fermi su una griglia di 32 px attorno allo schermo if (GetPermanentEnemiesNumber(st) >= st->maximum) return; shuffleV(st->tiledPositions, st->n_tiledPositions); EnemyPool *en[32]; int ne = 0; for (int i = 0; i < st->n_pools; i++) if (st->pools[i]->enabled) en[ne++] = st->pools[i]; for (int i = 0, k = 0; i < st->n_tiledPositions; i++) { float x = 0x20 * floorf((Core.Player->s.x + st->tiledPositions[i].x) / 0x20), y = 0x20 * floorf((Core.Player->s.y + st->tiledPositions[i].y) / 0x20); if (physics_overlapCirc(x, y, 1) > 0) continue; if (ne) EnemyPool_SpawnAt(en[k % ne], x, y); k++; if (GetPermanentEnemiesNumber(st) >= st->maximum) return; } } static void Stage_SpawnByType(Stage *st) { // startingSpawns e SpawnTimer if (Stage_isSpawnType(st, "HORIZONTAL") && Stage_hasSpawners(st)) Stage_SpawnInRandomLocationH(st); else if (Stage_isSpawnType(st, "VERTICAL") && Stage_hasSpawners(st)) Stage_SpawnInRandomLocationV(st); else if (Stage_isSpawnType(st, "TILED")) Stage_SpawnEnemiesTiled(st); else if (Stage_isSpawnType(st, "MAPPED")) Stage_SpawnEnemiesMapped(st); else Stage_SpawnEnemiesInOuterRect(st); } static void Stage_SpawnTick(void *ctx) { Stage_SpawnByType(ctx); } static void Stage_startTimers(void *ctx) { Stage *st = ctx; time_removeEvent(st->SpawnTimer); st->SpawnTimer = time_addEvent(st->EffectiveSpawnFrequency, 1, 0, Stage_SpawnTick, st); time_removeEvent(st->DestructibleTimer); st->DestructibleTimer = time_addEvent(st->destructibleFreq, 1, 0, Stage_DestructibleTick, st); // 'Desct Timer' } static void Stage_updateTimers(Stage *st) { if (st->pause) time_addEvent(st->pause, 0, 0, Stage_startTimers, st); else Stage_startTimers(st); } // Stage.SetTreasureLevelFromChance: i primi forzieri della carriera hanno livello fisso (BeginnersLuck) static int Stage_SetTreasureLevelFromChance(cJSON *t, int *level) { float luck = Player_PLuck(Core.Player); // PLuck int b = (int)po_num("BeginnersLuck"), lv = 0; if (b < 6) { switch (b) { case 0: case 1: case 3: case 4: lv = 1; break; case 2: lv = 2; break; case 5: lv = 3; break; } po_add("BeginnersLuck", 1); // SaveBLuck: solo Storage del web if (lv > 0) return *level = lv; } cJSON *c = cJSON_GetObjectItem(t, "chances"); float r0 = 0x64 * frand(), r1 = 0x64 * frand(), r2 = 0x64 * frand(); if (r0 <= cJSON_GetNumberValue(cJSON_GetArrayItem(c, 0)) * luck) return *level = 3; if (r1 <= cJSON_GetNumberValue(cJSON_GetArrayItem(c, 1)) * luck) return *level = 2; if (r2 <= cJSON_GetNumberValue(cJSON_GetArrayItem(c, 2)) * luck) return *level = 1; return 0; } static void Stage_SpawnBoss(Stage *st) { for (int i = 0; i < st->n_bossPools; i++) { if (!st->bossPools[i]->enabled) continue; Enemy *e = Stage__spawnOneByType(st, st->bossPools[i]); if (!e) continue; e->isTeleportOnCull = 1; int lv; if (!st->hasAttachedTreasure && st->treasure && Stage_SetTreasureLevelFromChance(st->treasure, &lv) > 0) { st->hasAttachedTreasure = 1; e->treasure = st->treasure; // AttachTreasure e->treasureLevel = lv; } } } static int RandomazzoEnabled(void); static void Stage_SpawnArcanaHolder(Stage *st) { // solo con Randomazzo: il portatore porta il forziere dell'arcana for (int i = 0; i < st->n_arcanaPools; i++) { if (!st->arcanaPools[i]->enabled) continue; Enemy *e = Stage__spawnOneByType(st, st->arcanaPools[i]); if (!e) continue; e->isTeleportOnCull = 1; int lv; if (st->arcanaTreasure && Stage_SetTreasureLevelFromChance(st->arcanaTreasure, &lv) > 0) { cJSON *h = cJSON_GetObjectItem(st->arcanaTreasure, "hasArcana"); // arcanaTreasure.hasArcana = true (sui dati) if (h) cJSON_SetBoolValue(h, 1); else cJSON_AddTrueToObject(st->arcanaTreasure, "hasArcana"); e->treasure = st->arcanaTreasure, e->treasureLevel = lv; } } } // ============================================================================ // Boss di Gallo Tower: BOSS_XLCRAB (0x1aef) con le chele BOSS_XLPINCER (0xbb5c), BOSS_XLDROWNER (0x155c5) e la sua onda BULLET_W (0xa3ee) // ============================================================================ static void base_EnemyDisappear(Enemy *e); static void E_ui_hide(void *ctx) { ((Sprite *)ctx)->visible = 0; } static Sprite *ui_image(const char *atlas, const char *frame, float x, float y) { // scene.add.image(...).setScrollFactor(0) Sprite *s = calloc(1, sizeof(Sprite)); sprite_init(s, frame_get(atlas, frame), x, y); s->scrollFactor0 = 1; children_add(s); return s; } // --- BOSS_XLPINCER (0xbb5c): la chela; non si muove (la porta il granchio), ogni colpo mortale le toglie una vita e la ingrandisce --- typedef struct { int pincerRespawnDelayL, pincerRespawnDelayR, summonDelay, freshlySpawned, isPlayerBelow, DrownerSummoned, rash; Enemy *leftPincer, *rightPincer, *drowner; EnemyPool *PincersPool; Timer leftEvent, rightEvent; } CrabX; static void E_Pincer_OnRecycle(Enemy *e) { if (!e->lives) e->lives = 0xc; // costruttore base_EnemyOnRecycle(e); cJSON *d = enemy_data(e); if (num(d, "lives", 0)) e->lives = (int)num(d, "lives", 0); e->isCullable = 0; sprite_setScale(&e->s, 0); float sc = e->owner ? e->owner->s.scaleX : 1; e->OnEnterTween = tweens_add((TweenConfig){ .props = { { &e->s.scaleX, &e->s.scaleY, sc } }, .nprops = 1, .duration = 0x12c }); } static void E_Pincer_Die(Enemy *e) { if (--e->lives <= 0) { base_EnemyDie(e); if (e->owner && e->OnDead) e->OnDead(e->owner); return; } e->isDead = 0; time_removeEvent(e->_blinkTimeout); json_inc(tbl0("enemies", e->enemyType), "killedAmount"); Core.kills++, MainUI_UpdateKills(); e->hp = e->maxHp; sprite_setScale(&e->s, fminf(4, 1.1f * e->s.scaleX)); } static void E_Pincer_Update(Enemy *e) { (void)e; } static const EnemyVT E_Pincer = { .OnRecycle = E_Pincer_OnRecycle, .Die = E_Pincer_Die, .Update = E_Pincer_Update }; // --- BOSS_XLCRAB (0x1aef): sbuca da sotto lo schermo; se il giocatore gli passa sotto per 6 s, arriva il Drowner ------------------ static void Crab_RegrowLeft(Enemy *crab); static void Crab_RegrowRight(Enemy *crab); static Enemy *Crab_spawnPincer(Enemy *crab, int flip, void (*OnDead)(Enemy *)) { CrabX *c = crab->x; Enemy *p = EnemyPool_SpawnAt(c->PincersPool, crab->s.x, crab->s.y); p->s.flipX = flip, p->owner = crab, p->OnDead = OnDead; return p; } static void Crab_leftBack(void *ctx) { Enemy *e = ctx; CrabX *c = e->x; if (!c->leftPincer || c->leftPincer->isDead) c->leftPincer = Crab_spawnPincer(e, 0, Crab_RegrowLeft); } static void Crab_rightBack(void *ctx) { Enemy *e = ctx; CrabX *c = e->x; if (!c->rightPincer || c->rightPincer->isDead) c->rightPincer = Crab_spawnPincer(e, 1, Crab_RegrowRight); } static void Crab_RegrowLeft(Enemy *e) { CrabX *c = e->x; c->leftPincer = NULL; c->leftEvent = time_addEvent(c->pincerRespawnDelayL, 0, 0, Crab_leftBack, e); sprite_setScale(&e->s, fminf(5, 1.1f * e->s.scaleX)); } static void Crab_RegrowRight(Enemy *e) { CrabX *c = e->x; c->rightPincer = NULL; c->rightEvent = time_addEvent(c->pincerRespawnDelayR, 0, 0, Crab_rightBack, e); sprite_setScale(&e->s, fminf(4, 1.1f * e->s.scaleX)); // 4 a destra e 5 a sinistra (sic) } static void E_Crab_OnRecycle(Enemy *e) { if (!e->x) { // costruttore: il pool delle chele e le due chele, sul granchio CrabX *c = e->x = calloc(1, sizeof(CrabX)); c->pincerRespawnDelayL = c->pincerRespawnDelayR = 0x5dc, c->summonDelay = 0x1770; c->leftEvent = c->rightEvent = (Timer){ -1, 0 }; c->PincersPool = EnemyPool_new("BOSS_XLPINCER"); c->rash = !strcmp(e->enemyType, "BOSS_XLCRAB_RASH"); // 0x4e24: SummonDrowner vuota c->leftPincer = Crab_spawnPincer(e, 0, Crab_RegrowLeft); // OnDead non legato, ma la chela lo chiama sul granchio c->rightPincer = Crab_spawnPincer(e, 1, Crab_RegrowRight); } base_EnemyOnRecycle(e); e->isTeleportOnCull = 1; ((CrabX *)e->x)->freshlySpawned = 1; } static void Drowner_Dismiss(Enemy *e); static void E_Crab_DeSpawn(Enemy *e) { CrabX *c = e->x; if (c->DrownerSummoned && c->drowner) Drowner_Dismiss(c->drowner); // DismissDrowner (OnDismissDrowner: mai assegnato) time_removeEvent(c->leftEvent), time_removeEvent(c->rightEvent); if (c->leftPincer) Enemy_Disappear(c->leftPincer); if (c->rightPincer) Enemy_Disappear(c->rightPincer); base_EnemyDeSpawn(e); } static void Crab_SingleWarning(float x) { Sprite *s = ui_image("UI", "ExclamationMark.png", x, game_height); sprite_setScale(s, 0), sprite_setOrigin(s, 0.5f, 1), s->depth = 0x2328; Sound_PlaySound("Pizza", 0.9f, 1, 0x1f4 * frand(), 0x96, 2); tweens_add((TweenConfig){ .props = { { &s->scaleX, &s->scaleY, 1 } }, .nprops = 1, .duration = 0xc8 }); tweens_add((TweenConfig){ .props = { { &s->scaleX, &s->scaleY, 0 } }, .nprops = 1, .duration = 0xc8, .delay = 0xc8 + 0xc8 }); // onComplete del primo + delay } static void Crab_warn2(void *ctx) { (void)ctx; Crab_SingleWarning(0.5f * game_width); } static void Crab_warn3(void *ctx) { (void)ctx; Crab_SingleWarning(0.75f * game_width); } static void Crab_redOut(void *ctx) { Sprite *s = ctx; tweens_add((TweenConfig){ .props = { { &s->alpha, NULL, 0 } }, .nprops = 1, .duration = 0x64, .onComplete = E_ui_hide, .ctx = s }); } static void Crab_spawnDrowner(void *ctx) { Enemy *e = ctx; ((CrabX *)e->x)->drowner = EnemyPool_SpawnAt(EnemyPool_new("BOSS_XLDROWNER"), Core.Player->s.x, Core.Player->s.y + game_height); } static void Crab_SummonDrowner(void *ctx) { Enemy *e = ctx; CrabX *c = e->x; c->isPlayerBelow = 0; if (c->rash || Core.Player->s.y <= e->s.y || c->DrownerSummoned) return; Sprite *r = ui_image("vfx", "WhiteLine.png", 0, game_height); // RedWarning r->scaleX = game_width, r->scaleY = 1, sprite_setOrigin(r, 0, 1), r->depth = 0x2328, r->alpha = 0.25f, sprite_setTint(r, 0xff0000); tweens_add((TweenConfig){ .props = { { &r->alpha, NULL, 0.5f } }, .nprops = 1, .duration = 0xc8, .repeat = 3, .yoyo = 1, .onComplete = Crab_redOut, .ctx = r }); Crab_SingleWarning(0.25f * game_width); time_addEvent(0xc8, 0, 0, Crab_warn2, NULL); time_addEvent(0x190, 0, 0, Crab_warn3, NULL); time_addEvent(0x64, 0, 0, Crab_spawnDrowner, e); c->DrownerSummoned = 1; } static void E_Crab_Update(Enemy *e) { CrabX *c = e->x; base_EnemyUpdate(e); if (c->freshlySpawned) c->freshlySpawned = 0, e->s.y = Core.Player->s.y + 0.5f * game_height + 0x30, e->s.x = Core.Player->s.x; if (c->leftPincer) { Sprite *p = &c->leftPincer->s; p->x = e->s.x - 0x1b * e->s.scaleX, p->y = e->s.y - 0x1c * e->s.scaleY, p->depth = e->s.depth + 1, p->angle = e->s.angle; } if (c->rightPincer) { Sprite *p = &c->rightPincer->s; p->x = e->s.x + 0x1b * e->s.scaleX, p->y = e->s.y - 0x1c * e->s.scaleY, p->depth = e->s.depth + 1, p->angle = e->s.angle; } if (Core.Player->s.y > e->s.y && !c->DrownerSummoned) { if (!c->isPlayerBelow) time_addEvent(c->summonDelay, 0, 0, Crab_SummonDrowner, e); c->isPlayerBelow = 1; } } static const EnemyVT E_Crab = { .OnRecycle = E_Crab_OnRecycle, .Update = E_Crab_Update, .DeSpawn = E_Crab_DeSpawn }; // --- MS_EVILSPIRIT (0xe8a9): lo scheletro che sale ondeggiando ----------------------------------------------------- static void E_EvilSpirit_Update(Enemy *e) { if (e->isDead) return; e->s.depth = e->s.y - Core.Player->s.y; if (e->IsTimeStopped) return; if (!e->FixedDirection || (e->_currentDirection.x == 0 && e->_currentDirection.y == 0)) { e->_currentDirection.x = e->target->x - e->s.x, e->_currentDirection.y = e->target->y - e->s.y; float l = sqrtf(e->_currentDirection.x * e->_currentDirection.x + e->_currentDirection.y * e->_currentDirection.y); if (l > 0) e->_currentDirection.x /= l, e->_currentDirection.y /= l; } e->medusaElapsed += 0.05f; e->_currentDirection.x = sinf(e->medusaElapsed); float k = e->receivingDamage ? -e->knockback * e->damageKB : 1, v = EnemySpeed * e->speed * k * e->slow; e->s.flipX = e->_currentDirection.x > 0; sprite_setVelocity(&e->s, v * e->_currentDirection.x, v * e->_currentDirection.y); e->s.angle = TweenAngles[e->moveTweenIndex]; } static const EnemyVT E_EvilSpirit = { .Update = E_EvilSpirit_Update }; // --- MS_GOSHADOKURO (0x16676): lo scheletro gigante, braccia e testa a parte; a tratti gira e accelera, e chiama gli spiriti ------ typedef struct { Sprite frontArm, backArm, head; Animation armIdle, armDie, headIdle, headDie; float speedMul, SummonTime, SummonDelay, defaultSpeed; Timer SpinTimer; TweenRef spin1, spin2, speed1, speed2; EnemyPool *SkeletonPool; } GashaX; static void Gasha_PlayDeathAnimations(Enemy *e) { GashaX *g = e->x; anims_play(&g->frontArm, &g->armDie, 0), anims_play(&g->backArm, &g->armDie, 0), anims_play(&g->head, &g->headDie, 0); } static void Gasha_AndSpinnn(void *ctx) { Enemy *e = ctx; GashaX *g = e->x; tween_stop(g->spin1), tween_stop(g->spin2), tween_stop(g->speed1), tween_stop(g->speed2); g->spin1 = tweens_add((TweenConfig){ .props = { { &g->backArm.angle, NULL, -0x167 } }, .nprops = 1, .duration = 0x1f4, .repeat = 0x13 }); g->spin2 = tweens_add((TweenConfig){ .props = { { &g->frontArm.angle, NULL, 0x167 } }, .nprops = 1, .duration = 0x1f4, .repeat = 0x13 }); g->speed1 = tweens_add((TweenConfig){ .props = { { &g->speedMul, NULL, 7 } }, .nprops = 1, .duration = 0x7d0 }); g->speed2 = tweens_add((TweenConfig){ .props = { { &g->speedMul, NULL, 1 } }, .nprops = 1, .duration = 0x7d0, .delay = 0x1f40 }); } static void Gasha_summon(void *ctx) { Enemy *e = ctx; GashaX *g = e->x; if (!g->SkeletonPool) g->SkeletonPool = EnemyPool_new("MS_EVILSPIRIT"); float step = game_width / (float)0x20, wrap = 0x20 * floorf(step), x0 = Core.Player->s.x - 0.5f * game_width, y0 = Core.Player->s.y + 0x30 + 0.5f * game_height; for (int i = 0; i < 0x50; i++) { float d = step * i; EnemyPool_SpawnAt(g->SkeletonPool, x0 + fmodf(d, wrap), y0 + 0x30 * floorf(d / wrap)); } } static void Gasha_DrownerWarning(Enemy *e) { Sprite *r = ui_image("vfx", "WhiteLine.png", 0, game_height); // RedWarning r->scaleX = game_width, r->scaleY = 1, sprite_setOrigin(r, 0, 1), r->depth = 0x2328, r->alpha = 0.25f, sprite_setTint(r, 0xff0000); tweens_add((TweenConfig){ .props = { { &r->alpha, NULL, 0.5f } }, .nprops = 1, .duration = 0xc8, .repeat = 3, .yoyo = 1, .onComplete = Crab_redOut, .ctx = r }); Crab_SingleWarning(0.25f * game_width); time_addEvent(0xc8, 0, 0, Crab_warn2, NULL); time_addEvent(0x190, 0, 0, Crab_warn3, NULL); time_addEvent(0x3e8, 0, 0, Gasha_summon, e); } static void E_Gasha_OnRecycle(Enemy *e) { GashaX *g = e->x; if (!g) { // costruttore g = e->x = calloc(1, sizeof(GashaX)); g->SummonDelay = 0xbb8; g->defaultSpeed = num(enemy_data(e), "speed", 0); g->SpinTimer = (Timer){ -1, 0 }; g->spin1 = g->spin2 = g->speed1 = g->speed2 = (TweenRef){ -1, 0 }; sprite_init(&g->frontArm, frame_get("moonspellChars", "Gash_arm_i01.png"), e->s.x, e->s.y); sprite_init(&g->backArm, frame_get("moonspellChars", "Gash_arm_i01.png"), e->s.x, e->s.y); sprite_init(&g->head, frame_get("moonspellChars", "Gash_head_i01.png"), e->s.x, e->s.y); sprite_setOrigin(&g->frontArm, 0.85f, 13.0f / 60), sprite_setOrigin(&g->backArm, 0.85f, 13.0f / 60), sprite_setOrigin(&g->head, 0, 0); children_add(&g->frontArm), children_add(&g->backArm), children_add(&g->head); make_anim(&g->armIdle, "moonspellChars", "Gash_arm_i", 1, 5, 2, 0x18, -1); make_anim(&g->armDie, "moonspellChars", "Gash_arm_", 0, 0x1d, 0, 0x1e, 0); make_anim(&g->headIdle, "moonspellChars", "Gash_head_i", 1, 5, 2, 0x18, -1); make_anim(&g->headDie, "moonspellChars", "Gash_head_", 0, 0x1d, 0, 0x1e, 0); } base_EnemyOnRecycle(e); g->speedMul = 1, e->isTeleportOnCull = 1, e->hasLostTreasure = 0, g->SummonTime = 0; g->frontArm.visible = g->backArm.visible = g->head.visible = 1; anims_play(&g->frontArm, &g->armIdle, 0), anims_play(&g->backArm, &g->armIdle, 0), anims_play(&g->head, &g->headIdle, 0); sprite_setScale(&g->frontArm, e->s.scaleX), sprite_setScale(&g->backArm, e->s.scaleX), sprite_setScale(&g->head, e->s.scaleX); g->frontArm.angle = g->backArm.angle = 0; time_removeEvent(g->SpinTimer); g->SpinTimer = time_addEvent(0x3a98, 1, 0, Gasha_AndSpinnn, e); if (getenv("VS_BOSSHP")) e->hp = e->maxHp = atof(getenv("VS_BOSSHP")); // sviluppo } static void E_Gasha_Die(Enemy *e) { base_EnemyDie(e); Gasha_PlayDeathAnimations(e); if (e->hasLostTreasure) return; // MakeTreasureChest e->hasLostTreasure = 1; static cJSON *t; if (!t) { static const char *const P[5] = { "EVOLUTION", "EXISTING_ANY", "EXISTING_ANY", "EXISTING_ANY", "EXISTING_ANY" }; static const double C[3] = { 0.1, 1, 0x64 }; t = cJSON_CreateObject(); cJSON_AddItemToObject(t, "prizeTypes", cJSON_CreateStringArray(P, 5)); cJSON_AddItemToObject(t, "chances", cJSON_CreateDoubleArray(C, 3)); } int lv = 1; Stage_SetTreasureLevelFromChance(t, &lv); Core_MakeTreasure(e->s.x, e->s.y, t, lv); } static void E_Gasha_Disappear(Enemy *e) { base_EnemyDisappear(e); Gasha_PlayDeathAnimations(e); } static void E_Gasha_DeSpawn(Enemy *e) { GashaX *g = e->x; time_removeEvent(g->SpinTimer); tween_stop(g->spin1), tween_stop(g->spin2), tween_stop(g->speed1), tween_stop(g->speed2); g->frontArm.visible = g->backArm.visible = g->head.visible = 0; base_EnemyDeSpawn(e); } static void E_Gasha_Update(Enemy *e) { GashaX *g = e->x; e->speed = fminf(g->defaultSpeed * g->speedMul, 0x1f4); base_EnemyUpdate(e); e->s.angle = 0; float sx = e->s.scaleX, sy = e->s.scaleY, dir = e->s.flipX ? -1 : 1, x0 = e->s.x - 0x1f * sx, y0 = e->s.y - 0x31 * sy; g->frontArm.scaleX = g->backArm.scaleX = sx * dir; g->frontArm.scaleY = g->backArm.scaleY = sx; g->head.flipX = e->s.flipX; g->frontArm.x = x0 + (e->s.flipX ? 0x2c : 0x15) * sx, g->frontArm.y = y0 + 0xa * sy, g->frontArm.depth = e->s.depth + 2; g->backArm.x = x0 + (e->s.flipX ? 0x3d : 4) * sx, g->backArm.y = y0 + 0x16 * sy, g->backArm.depth = e->s.depth - 1; g->head.x = x0 + (e->s.flipX ? 0x34 : -0x1a) * sx, g->head.y = y0 - 0x15 * sy, g->head.depth = e->s.depth + 1; g->SummonTime += Enemies_delta; if (g->SummonTime >= g->SummonDelay) Gasha_DrownerWarning(e), g->SummonTime = 0; g->SummonDelay = 0x1388 + e->hp / e->maxHp * 0x61a8; } static const EnemyVT E_Gasha = { .OnRecycle = E_Gasha_OnRecycle, .Die = E_Gasha_Die, .Update = E_Gasha_Update, .DeSpawn = E_Gasha_DeSpawn, .Disappear = E_Gasha_Disappear }; // --- MS_OROCHIMARIO (0x1331e) con le otto MS_OROCHIHEAD (0xf9c7): le teste sul collo a rope, attaccano allungandosi verso il giocatore --- static float FrameFreeze_ms; typedef struct { Sprite s; const Frame *frame; Vector2 pts[6]; } OroNeck; typedef struct { Enemy *owner; OroNeck *neck; int headIndex; float AttackTime, AttackDelay, attackLerp; Vector2 targetVector, startingPosition; TweenRef attack, retreat, fade; } HeadX; typedef struct { Enemy *heads[8]; int n; EnemyPool *HeadPool; } OrochiX; static void OroNeck_draw(Sprite *s) { OroNeck *n = (OroNeck *)s; if (s->visible) Rope_drawH(n->pts, 6, n->frame, 1, s->alpha, 0, 0); } static void OroHead_SetRandomStartingPosition(Enemy *e) { HeadX *h = e->x; if (h->headIndex == 0) { h->startingPosition = (Vector2){ 0, -0x2a }; return; } float d = e->s.flipX ? -1 : 1; h->startingPosition = (Vector2){ 0x40 * (frand() - 0.25f) * d, -0x2c * e->s.scaleY - 0x2d * frand() }; } static void E_OroHead_OnRecycle(Enemy *e) { HeadX *h = e->x; if (!h) { // costruttore: il collo (RibbonTrail su flagName) h = e->x = calloc(1, sizeof(HeadX)); h->attack = h->retreat = h->fade = (TweenRef){ -1, 0 }; h->neck = calloc(1, sizeof(OroNeck)); sprite_init(&h->neck->s, NULL, e->s.x, e->s.y); h->neck->s.draw = OroNeck_draw; h->neck->frame = frame_get(str(enemy_data(e), "textureName"), str(enemy_data(e), "flagName")); children_add(&h->neck->s); } base_EnemyOnRecycle(e); e->isCullable = 0; tween_stop(h->fade); h->neck->s.alpha = 1; h->AttackTime = frand() * 0x1388, h->AttackDelay = 0x1388 + frand() * 0x1388; OroHead_SetRandomStartingPosition(e); } static void OroHead_warnBack(void *ctx) { Sprite *w = ctx; tweens_add((TweenConfig){ .props = { { &w->scaleX, &w->scaleY, 0 } }, .nprops = 1, .duration = 0xc8, .delay = 0xc8, .onComplete = E_ui_hide, .ctx = w }); } static void OroHead_attackDone(void *ctx) { OroHead_SetRandomStartingPosition(ctx); } static void OroHead_Attack(Enemy *e) { HeadX *h = e->x; if (e->IsTimeStopped) return; h->targetVector = (Vector2){ Core.Player->s.x, Core.Player->s.y }; tween_stop(h->attack); h->attack = tweens_add((TweenConfig){ .props = { { &h->attackLerp, NULL, 1 } }, .nprops = 1, .duration = 0xc8, .yoyo = 1, .delay = 0x1f4, .onComplete = OroHead_attackDone, .ctx = e }); tween_stop(h->retreat); h->retreat = tweens_add((TweenConfig){ .props = { { &h->attackLerp, NULL, 0 } }, .nprops = 1, .duration = 0x190, .delay = 0x2bc }); Sprite *w = calloc(1, sizeof(Sprite)); // SingleWarning(x, y - 16) sprite_init(w, frame_get("UI", "ExclamationMark.png"), e->s.x, e->s.y - 0x10); sprite_setScale(w, 0), sprite_setOrigin(w, 0.5f, 1), w->depth = 0x2328; children_add(w); Sound_PlaySound("Pizza", 0.7f, 1, 0x1f4 * frand(), 0x96, 2); tweens_add((TweenConfig){ .props = { { &w->scaleX, &w->scaleY, 1 } }, .nprops = 1, .duration = 0xc8, .onComplete = OroHead_warnBack, .ctx = w }); } static void E_OroHead_Update(Enemy *e) { HeadX *h = e->x; base_EnemyUpdate(e); Enemy *o = h->owner; e->s.depth = o->s.depth + 9; h->neck->s.depth = e->s.depth - 8; float x = o->s.x + h->startingPosition.x, y = o->s.y + h->startingPosition.y; e->s.x = x + (h->targetVector.x - x) * h->attackLerp, e->s.y = y + (h->targetVector.y - y) * h->attackLerp; // SetCurrentVector h->AttackTime += Enemies_delta; if (h->AttackTime >= h->AttackDelay) OroHead_Attack(e), h->AttackTime = 0; Vector2 neck = { o->s.x, o->s.y - 0x36 }; // headOffset e inv_headOffset coincidono float a = h->attackLerp * (5 + (e->s.flipX ? -1 : 0) * 0xa), sn = sinf(a), cs = cosf(a), rx = e->s.x - neck.x, ry = e->s.y - neck.y; // (sic) gradi passati come radianti Vector2 p0 = { e->s.x, e->s.y - 0x10 }, p1 = { rx * cs - ry * sn + neck.x, rx * sn + ry * cs + neck.y }; for (int i = 0; i < 6; i++) { // QuadraticBezier.getPoints(5) float t = i / 5.0f, u = 1 - t; h->neck->pts[i] = (Vector2){ u * u * p0.x + 2 * u * t * p1.x + t * t * neck.x, u * u * p0.y + 2 * u * t * p1.y + t * t * neck.y }; } } static void E_OroHead_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *t) { HeadX *h = e->x; if (h->owner) Enemy_GetDamaged(h->owner, amount, HIT_NONE, 0, t); base_EnemyGetDamaged(e, amount, hitVFX, kb, t); } static void E_OroHead_Die(Enemy *e) { HeadX *h = e->x; base_EnemyDie(e); tween_stop(h->fade); h->fade = tweens_add((TweenConfig){ .props = { { &h->neck->s.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x12c }); Sound_PlaySound("Crystal12", 1, 1, -0x258 * frand(), 0x3e8, 2); FrameFreeze_ms = 0x78; // SceneManager.FrameFreeze } static const EnemyVT E_OroHead = { .OnRecycle = E_OroHead_OnRecycle, .Die = E_OroHead_Die, .GetDamaged = E_OroHead_GetDamaged, .Update = E_OroHead_Update }; static void E_Orochi_OnRecycle(Enemy *e) { OrochiX *o = e->x; if (!o) { o = e->x = calloc(1, sizeof(OrochiX)); o->HeadPool = EnemyPool_new("MS_OROCHIHEAD"); } base_EnemyOnRecycle(e); e->isTeleportOnCull = 1; if (o->n < 8) { for (int i = 0; i < 8; i++) { Enemy *h = EnemyPool_SpawnAt(o->HeadPool, e->s.x, e->s.y); if (!h) continue; o->heads[o->n++] = h; HeadX *x = h->x; x->owner = e, x->headIndex = i; // setHeadIndex if (i == 0) h->maxHp *= 2, h->hp = h->maxHp; } } for (int i = 0; i < o->n; i++) e->maxHp += o->heads[i]->maxHp; e->hp = e->maxHp; if (getenv("VS_BOSSHP")) e->hp = e->maxHp = atof(getenv("VS_BOSSHP")); // sviluppo } static void E_Orochi_Die(Enemy *e) { OrochiX *o = e->x; base_EnemyDie(e); int n = o->n; o->n = 0; // HeadEnemies = []: prima dei Die delle teste, che richiamano il proprietario for (int i = 0; i < n; i++) if (!o->heads[i]->isDead) Enemy_Die(o->heads[i]); } static void E_Orochi_Disappear(Enemy *e) { OrochiX *o = e->x; base_EnemyDisappear(e); int n = o->n; o->n = 0; for (int i = 0; i < n; i++) if (!o->heads[i]->isDead) Enemy_Disappear(o->heads[i]); } static void E_Orochi_Update(Enemy *e) { base_EnemyUpdate(e); e->s.angle = 0; } static const EnemyVT E_Orochi = { .OnRecycle = E_Orochi_OnRecycle, .Die = E_Orochi_Die, .Update = E_Orochi_Update, .Disappear = E_Orochi_Disappear }; // --- BULLET_W (0xa3ee): l'acqua del Drowner, un rettangolo largo quanto lo schermo con 1500 bolle; sotto la superficie si soffre --- typedef struct { Blitter *blitter; float elapsed; TweenRef waveTween; } WaveX; static void Wave_makeBlitters(Enemy *e) { WaveX *w = e->x; static const char *const F[3] = { "HitBlue1.png", "HitBlue2.png", "HitCloud1.png" }; Blitter *bl = w->blitter = Blitter_add(); bl->s.scrollFactor0 = 0, bl->s.blendAdd = 0; bl->bobs = calloc(bl->cap = 0x5dc, sizeof(Bob)); for (int g = 0; g < 3; g++) for (int i = 0; i < 0x1f4; i++) { float vx = g < 2 ? 0xf * (frand() - 0.5f) : 5 * (frand() - 0.5f), vy = g < 2 ? 0xa * (frand() - 0.5f) : 5 * (frand() - 0.5f); bl->bobs[bl->n++] = (Bob){ e->s.x, e->s.y + 0xc, g < 2 ? 0.5f : 0.4f, vx, vy, 1, frame_get("vfx", g < 2 ? F[i % 3] : "bubble.png") }; } static TweenProp props[0x1f4]; // waveTween: il primo gruppo pulsa for (int i = 0; i < 0x1f4; i++) props[i] = (TweenProp){ &bl->bobs[i].alpha, NULL, 0.1f }; w->waveTween = tweens_add((TweenConfig){ .many = props, .nmany = 0x1f4, .duration = 0x7d0, .ease = Ease_SineInOut, .repeat = -1, .yoyo = 1 }); } static void E_Wave_OnRecycle(Enemy *e) { if (!e->x) e->x = calloc(1, sizeof(WaveX)); base_EnemyOnRecycle(e); e->isCullable = 0; sprite_setOrigin(&e->s, 0.5f, 0); body_setSize(&e->s.body, 1, 1); e->s.alpha = 0.2f; sprite_setTint(&e->s, 0xeeeeff); e->s.scaleX = 1.1f * game_width, e->s.scaleY = game_height; if (!((WaveX *)e->x)->blitter) Wave_makeBlitters(e); ((WaveX *)e->x)->elapsed = 0; } static void E_Wave_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *t) { (void)e, (void)amount, (void)hitVFX, (void)kb, (void)t; } static void E_Wave_dismissed(void *ctx) { Enemy_DeSpawn(ctx); } static void Wave_Dismiss(Enemy *e) { WaveX *w = e->x; tweens_add((TweenConfig){ .props = { { &e->s.alpha, NULL, 0 }, { &w->blitter->s.alpha, NULL, 0 } }, .nprops = 2, .duration = 0x1f4, .onComplete = E_Wave_dismissed, .ctx = e }); } static void E_Wave_Update(Enemy *e) { WaveX *w = e->x; base_EnemyUpdate(e); e->s.angle = 0, e->s.depth = w->blitter->s.depth = 0xbb8; w->elapsed += Enemies_delta; if (w->elapsed > 0x3e8 && Core.Player->s.y > e->s.y) Player_GetDamaged(Core.Player, e->power), w->elapsed = 0x320; if (e->IsTimeStopped) return; // semplificazione: il corpo e' 1x1 scalato (1.1 * larghezza, altezza): i suoi limiti calcolati qui invece di leggerli dal Body float hw = 0.5f * 1.1f * game_width, h = game_height; for (int i = 0; i < w->blitter->n; i++) { // UpdateBlitter (gravity 0) Bob *b = &w->blitter->bobs[i]; b->y += b->vy, b->x += b->vx; if (b->x > e->s.x + hw) b->x = e->s.x + hw, b->vx *= -b->bounce; else if (b->x < e->s.x - hw) b->x = e->s.x - hw, b->vx *= -b->bounce; if (b->y > e->s.y + h) b->y = e->s.y + h, b->vy *= -b->bounce; else if (b->y < e->s.y) b->y = e->s.y, b->vy *= -b->bounce; } } static void E_Wave_Disappear(Enemy *e) { e->isDead = 1; } static const EnemyVT E_WaveW = { .OnRecycle = E_Wave_OnRecycle, .GetDamaged = E_Wave_GetDamaged, .Update = E_Wave_Update, .Disappear = E_Wave_Disappear }; // --- BOSS_XLDROWNER (0x155c5): sale dal basso con l'acqua e resta a sinistra del giocatore; dopo 30:00 e' invulnerabile e svelto --- // Rosary, Sire, Corridor, Shroud o Victory lo cacciano e lascia un forziere; il minigioco di Panini (Exdash sbloccato): F3 typedef struct { Enemy *bullet; ParticleManager *particlesManager; ParticleEmitter *PfxEmitter; int dismissed, invul, isFresh; } DrownerX; static void E_Drowner_OnRecycle(Enemy *e) { if (!e->x) e->x = calloc(1, sizeof(DrownerX)); DrownerX *d = e->x; base_EnemyOnRecycle(e); d->isFresh = 1, e->isCullable = 0, e->hasLostTreasure = 0; if (d->bullet) return; d->bullet = EnemyPool_SpawnAt(EnemyPool_new("BULLET_W"), e->s.x, e->s.y); d->particlesManager = particles_add(); d->PfxEmitter = particles_createEmitter(d->particlesManager, (EmitterConfig){ .frames = { frame_get("vfx", "WhiteDot.png") }, .nframes = 1, .quantity = 0xa, .lifespan = EOP(0x7d0), .alpha = ERANGE(0.7f, 0), .angle = ERND(0xe1, 0x13b), .speed = ERND(0x4b, 0x7d), .scale = ERANGE(2 * PixelScale, 0), .gravityY = 0x12c, .tint = 0xbbbbff, .bounce = 0.35f, .collideBottom = 1, .boundsH = 1, .flowEveryFrame = 1, .on = 0 }); // semplificazione: bounce {0.2, 0.5} a caso per particella, qui la media d->PfxEmitter->boundsY = e->s.y + 0xc8; d->PfxEmitter->x = e->s.x, d->PfxEmitter->y = e->s.y - 8; emitter_start(d->PfxEmitter); } static void E_Drowner_Disappear(Enemy *e) { DrownerX *d = e->x; e->isCullable = 1, e->isTeleportOnCull = 0; Wave_Dismiss(d->bullet); emitter_stop(d->PfxEmitter); } static void Drowner_dismissed(void *ctx) { E_Drowner_Disappear(ctx); } static void Drowner_Dismiss(Enemy *e) { ((DrownerX *)e->x)->dismissed = 1; time_addEvent(0x3e8, 0, 0, Drowner_dismissed, e); } static float approach(float v, float to, float step) { return v < to ? fminf(v + step, to) : fmaxf(v - step, to); } static void E_Drowner_Update(Enemy *e) { DrownerX *d = e->x; float delta = Enemies_delta; if (d->isFresh) e->s.x = Core.Player->s.x, e->s.y = Core.Player->s.y + game_height, d->isFresh = 0; e->isTeleportOnCull = 0, e->speed = 0; base_EnemyUpdate(e); Panini_uppercut(e); e->s.x = approach(e->s.x, Core.Player->s.x - (d->dismissed ? 2 * game_width : game_width * 0.5f - 0x60), 0x64 * delta); float k = Core.SurvivedSeconds > 0x708 ? 1.5f : 0.1f; d->invul = Core.SurvivedSeconds > 0x708; if (Core.Player->s.y - 0xc < e->s.y) e->s.y = approach(e->s.y, Core.Player->s.y - 0xc, k); if (d->bullet) { d->bullet->s.x = Core.Player->s.x, d->bullet->s.y = e->s.y; if (Core.Player->s.y - e->s.y > 0.5f * game_height) d->bullet->s.y = 0xc + Core.Player->s.y - 0.5f * game_height; } d->PfxEmitter->boundsY = e->s.y - 2; d->PfxEmitter->x = 0x18 + e->s.x, d->PfxEmitter->y = -0x42 + e->s.y; d->particlesManager->s.depth = e->s.depth - 1; } static void E_Drowner_DeSpawn(Enemy *e) { base_EnemyDeSpawn(e); emitter_stop(((DrownerX *)e->x)->PfxEmitter); } static void E_Drowner_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *t) { (void)amount, (void)hitVFX, (void)kb; DrownerX *d = e->x; if (d->invul || e->hasLostTreasure || !t) return; if (strcmp(t, "ROSARY") && strcmp(t, "SIRE") && strcmp(t, "CORRIDOR") && strcmp(t, "SHROUD") && strcmp(t, "VICTORY")) return; Drowner_Dismiss(e); e->hasLostTreasure = 1; int lv = 0; // new TreasureClass([6, 66, 100], tipi): lo stesso (sic) dello Stalker Stage_SetTreasureLevelFromChance(Stalker_treasure(), &lv); Core_MakeTreasure(e->s.x, e->s.y, Stalker_treasure(), lv); } static const EnemyVT E_Drowner = { .OnRecycle = E_Drowner_OnRecycle, .GetDamaged = E_Drowner_GetDamaged, .Update = E_Drowner_Update, .DeSpawn = E_Drowner_DeSpawn, .Disappear = E_Drowner_Disappear }; // --- BOSS_GALLO (0xbc1a): tiene la distanza; a ogni colpo una lancia in una delle 12 direzioni (6 zone che rallentano) e un proiettile --- typedef struct GalloLancet { // 0x25d9: zona invisibile che vive 120 ms; prende il giocatore una volta (rallentato, lampo blu) float x, y, radius, damage; int hasHit; ParticleManager *particlesManager; ParticleEmitter *pfxEmitter, *pfxEmitter2; Sprite GroundFx; TweenRef despawnTimer; struct LancetPool *pool; } GalloLancet; typedef struct LancetPool { GalloLancet **stored, **spawned; int nstored, nspawned, capstored, capspawned; } LancetPool; // 0x15ca3 typedef struct { int ticks; Vector2 targets[12]; float angles[12]; Sprite lancet; Animation pierce; TweenRef lancetTween; LancetPool pool; } GalloX; static void Lancet_DeSpawn(GalloLancet *l) { LancetPool *p = l->pool; emitter_stop(l->pfxEmitter), emitter_stop(l->pfxEmitter2); for (int i = 0; i < p->nspawned; i++) // Return if (p->spawned[i] == l) { memmove(&p->spawned[i], &p->spawned[i + 1], (p->nspawned - i - 1) * sizeof(*p->spawned)); p->nspawned--; break; } if (p->nstored == p->capstored) p->stored = realloc(p->stored, (p->capstored = p->capstored ? p->capstored * 2 : 16) * sizeof(*p->stored)); p->stored[p->nstored++] = l; tween_stop(l->despawnTimer), l->despawnTimer = TWEEN_NONE; l->GroundFx.visible = 0; } static void Lancet_despawnCb(void *ctx) { Lancet_DeSpawn(ctx); } static void Lancet_grow(GalloLancet *l) { // despawnTimer: il cerchio arriva al raggio in 120 ms, poi DeSpawn tween_stop(l->despawnTimer); l->despawnTimer = tweens_add((TweenConfig){ .props = { { &l->GroundFx.scaleX, NULL, l->radius } }, .nprops = 1, .duration = 0x78, .onComplete = Lancet_despawnCb, .ctx = l }); } static GalloLancet *Lancet_new(LancetPool *p) { GalloLancet *l = calloc(1, sizeof(GalloLancet)); l->pool = p; l->radius = 0x1e, l->despawnTimer = TWEEN_NONE; const Frame *F[2] = { frame_get("vfx", "feedback-5.png"), frame_get("vfx", "feedback-4.png") }; l->particlesManager = particles_add(); l->pfxEmitter2 = particles_createEmitter(l->particlesManager, (EmitterConfig){ .frames = { F[0], F[1] }, .nframes = 2, .lifespan = EOP(0x1f4), .rotate = ERND(0, 0x168), .angle = { 0, 0xb4, 1 }, .angleSteps = 0x10, .speed = ERND(0x64, 0xc8), .quantity = 2, .scale = ERANGE(1, 0), .frequency = 2, .alpha = ERANGE(0.5f, 0), .on = 0 }); l->pfxEmitter = particles_createEmitter(l->particlesManager, (EmitterConfig){ .frames = { F[0], F[1] }, .nframes = 2, .lifespan = EOP(0x1f4), .rotate = ERND(0, 0x168), .angle = { 0, 0x168, 1 }, .angleSteps = 0x10, .speed = ERND(0x32, 0x50), .quantity = 2, .scale = ERANGE(1, 0), .frequency = 1, .blendAdd = 1, .on = 0 }); l->particlesManager->hasWell = 1; // createGravityWell({ power: 1, epsilon: 50, gravity: 20 }) l->particlesManager->wellPower = 1 * 0x14, l->particlesManager->wellEpsilon = 0x32 * 0x32; sprite_init(&l->GroundFx, NULL, 0, 0); // scene.add.circle(0, 0, 1, 0xff), ADD l->GroundFx.draw = MoonGroundFx_draw; l->GroundFx.tint = 0xff, l->GroundFx.alpha = 1, l->GroundFx.visible = 0, l->GroundFx.scaleX = 1; children_add(&l->GroundFx); return l; } static void Lancet_SpawnAt(LancetPool *p, float x, float y, float damage, float radius, float angle) { GalloLancet *l = p->nstored ? p->stored[--p->nstored] : NULL; if (!l) l = Lancet_new(p), l->x = l->y = -0x3e8, Lancet_grow(l); // Init: OnRecycle a (-1000, -1000) if (p->nspawned == p->capspawned) p->spawned = realloc(p->spawned, (p->capspawned = p->capspawned ? p->capspawned * 2 : 16) * sizeof(*p->spawned)); p->spawned[p->nspawned++] = l; l->x = x, l->y = y, l->damage = damage, l->radius = radius; l->GroundFx.depth = l->particlesManager->s.depth = y + 1 - Core.Player->s.y; l->hasHit = 0; // OnRecycle: circleArea = (x, y, radius) Lancet_grow(l); (void)angle; // setAngle sulla zona invisibile: non cambia nulla } static void Lancet_Update(GalloLancet *l) { float dx = Core.Player->s.x - l->x, dy = Core.Player->s.y - l->y; if (l->hasHit || l->radius <= 0 || dx * dx + dy * dy > l->radius * l->radius) return; l->hasHit = 1; Core.Player->slowTime += 0x12c; // duration Player_OnGetDamaged(Core.Player, 0xff, 0x1e, 0); l->particlesManager->wellX = l->x, l->particlesManager->wellY = l->y - 0x14; // OnHit l->pfxEmitter->x = l->pfxEmitter2->x = l->x, l->pfxEmitter->y = l->pfxEmitter2->y = l->y; emitter_start(l->pfxEmitter), emitter_start(l->pfxEmitter2); l->GroundFx.x = l->x, l->GroundFx.y = l->y, l->GroundFx.visible = 1, l->GroundFx.scaleX = 1; // FlashingVFXEnabled Lancet_grow(l); Sound_PlaySound("Explosion", 0.5f, 1, 0x1f4 * (frand() - 0.5f), 0x96, 3); } static void Gallo_Fire(void *ctx) { Enemy *e = ctx; GalloX *g = e->x; if (e->IsTimeStopped || e->isDead) return; if (++g->ticks >= 0xc) g->ticks = 0; Vector2 t = g->targets[g->ticks]; tween_restart(g->lancetTween); g->lancet.x = e->s.x, g->lancet.y = e->s.y, g->lancet.angle = g->angles[g->ticks] * RAD2DEG, g->lancet.visible = 1, g->lancet.depth = game_height; anims_play(&g->lancet, &g->pierce, 0); for (int i = 0; i < 6; i++) Lancet_SpawnAt(&g->pool, e->s.x + 0x32 * t.x * (1 + i), e->s.y + 0x32 * t.y * (1 + i), 0x1e, 0x1e, g->angles[g->ticks]); Stage_FireEnemyBulletAt(e->s.x, e->s.y); // BULLET_2 chiesto, BULLET_1 sparato } static void E_Gallo_OnRecycle(Enemy *e) { if (!e->x) { // costruttore: InitLancet GalloX *g = e->x = calloc(1, sizeof(GalloX)); for (int i = 0; i < 0xc; i++) g->angles[i] = i / 12.0f * (2 * PI), g->targets[i] = (Vector2){ cosf(g->angles[i]), sinf(g->angles[i]) }; sprite_init(&g->lancet, frame_get("vfx", "Pierce1.png"), e->s.x, e->s.y); sprite_setOrigin(&g->lancet, 0, 0.5f), g->lancet.visible = 0, sprite_setTint(&g->lancet, 0xcceeff), g->lancet.scaleX = 2, g->lancet.scaleY = 1; children_add(&g->lancet); g->lancetTween = tweens_add((TweenConfig){ .props = { { &g->lancet.alpha, NULL, 0 } }, .nprops = 1, .delay = 0xc8, .duration = 0x1f4, .persist = 1 }); g->pierce.n = anims_generateFrameNames("vfx", "Pierce", 1, 5, 0, g->pierce.frames, ANIM_MAX_FRAMES); g->pierce.frameRate = 0x1e, g->pierce.msPerFrame = 1000.0f / 0x1e, g->pierce.repeat = 0; e->keepMoving = 1; } base_EnemyOnRecycle(e); sprite_setScale(&e->s, 0), e->firetime = 0; cJSON *d = enemy_data(e); e->fireDelay = num(d, "fireDelay", 0) ? num(d, "fireDelay", 0) : 0x7d0; e->bulletType = str(d, "bulletType") ? str(d, "bulletType") : "BULLET_2"; tween_restartOrAdd(&e->OnEnterTween, (TweenConfig){ .props = { { &e->s.scaleX, &e->s.scaleY, e->scaleMul } }, .nprops = 1, .duration = 0x12c }); tween_restartOrAdd(&e->OnFireTimer, (TweenConfig){ .props = { { &e->firetime, NULL, 1 } }, .nprops = 1, .duration = e->fireDelay, .repeat = -1, .onRepeat = Gallo_Fire, .ctx = e }); } static void E_Gallo_Update(Enemy *e) { GalloX *g = e->x; if (e->isDead) return; e->s.depth = e->s.y - Core.Player->s.y; if (e->IsTimeStopped) return; if (!e->FixedDirection || (e->FixedDirection && e->_currentDirection.x == 0 && e->_currentDirection.y == 0)) { e->_currentDirection.x = e->target->x - e->s.x; e->_currentDirection.y = e->target->y - e->s.y; float l = sqrtf(e->_currentDirection.x * e->_currentDirection.x + e->_currentDirection.y * e->_currentDirection.y); if (l > 0) { e->_currentDirection.x /= l; e->_currentDirection.y /= l; } } float dx = Core.Player->s.x - e->s.x, dy = Core.Player->s.y - e->s.y, d2 = dx * dx + dy * dy, dist = 0xc350; if (d2 < dist - 0xbb8) e->keepMoving = -1; else if (d2 > dist + 0xbb8) e->keepMoving = 1; float k = e->receivingDamage ? -e->knockback * e->damageKB : 1; e->s.flipX = e->_currentDirection.x > 0; float v = e->keepMoving * EnemySpeed * e->speed * k * e->slow; sprite_setVelocity(&e->s, v * e->_currentDirection.x, v * e->_currentDirection.y); e->s.angle = TweenAngles[e->moveTweenIndex]; for (int i = 0; i < g->pool.nspawned; i++) Lancet_Update(g->pool.spawned[i]); } static const EnemyVT E_Gallo = { .OnRecycle = E_Gallo_OnRecycle, .Die = E_Pile_Die, .Update = E_Gallo_Update, .DeSpawn = E_Pile_DeSpawn }; // --- BOSS_XLLEDA (0x12236): in fondo a Gallo Tower; dorme (immobile e invulnerabile) finche' il giocatore non scende sotto y 0x14000 --- static float FrameFreeze_ms; static void Leda_fire(void *ctx) { Enemy *e = ctx; if (!e->IsTimeStopped && !e->isDead) Stage_FireEnemyBulletAt(e->s.x, e->s.y); } // BULLET_Z chiesto, BULLET_1 sparato static void E_Leda_OnRecycle(Enemy *e) { base_EnemyOnRecycle(e); cJSON *d = enemy_data(e); e->defaultSpeed = num(d, "speed", 0), e->sineF = 1, e->isCullable = 0, e->isTeleportOnCull = 0, e->s.alpha = 0.8f, e->activated = 0; // _defaultSpeed tween_restartOrAdd(&e->OnSineTween, (TweenConfig){ .props = { { &e->sineF, NULL, 0.1f }, { &e->s.alpha, NULL, 0.6f } }, .nprops = 2, .duration = 0x7d0, .repeat = -1, .yoyo = 1, .ease = Ease_SineInOut }); e->firetime = 0; e->fireDelay = num(d, "fireDelay", 0) ? num(d, "fireDelay", 0) : 0x7d0; e->bulletType = str(d, "bulletType") ? str(d, "bulletType") : "BULLET_Z"; tween_restartOrAdd(&e->OnFireTimer, (TweenConfig){ .props = { { &e->firetime, NULL, 1 } }, .nprops = 1, .duration = e->fireDelay, .repeat = -1, .onRepeat = Leda_fire, .ctx = e }); } static void E_Leda_Update(Enemy *e) { e->speed = e->defaultSpeed * e->sineF * e->activated; if (Core.Player->s.y > 0x14000) e->activated = 1; base_EnemyUpdate(e); } static void E_Leda_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *t) { if (e->activated) base_EnemyGetDamaged(e, amount, hitVFX, kb, t); } static void E_Leda_Die(Enemy *e) { base_EnemyDie(e); tween_stop(e->OnFireTimer); if (e->onDefeat) e->onDefeat(e); } static void E_Leda_DeSpawn(Enemy *e) { base_EnemyDeSpawn(e); tween_stop(e->OnFireTimer); } static const EnemyVT E_Leda = { .OnRecycle = E_Leda_OnRecycle, .Die = E_Leda_Die, .GetDamaged = E_Leda_GetDamaged, .Update = E_Leda_Update, .DeSpawn = E_Leda_DeSpawn, .Disappear = E_Noob_Disappear }; // Disappear: quello dello Stalker / del conte // --- BRIDGE_BOSS (0x17b7f): in fondo a Tiny Bridge; si sveglia quando il giocatore passa x 0x9800. Battuto: fermo immagine e scossone --- // Battuto senza Scorej: segreto HearTheThunder e, finito lo scossone, la scena del personaggio (CharQueue) static void E_BridgeBoss_OnRecycle(Enemy *e) { base_EnemyOnRecycle(e); e->defaultSpeed = num(enemy_data(e), "speed", 0), e->isCullable = 0, e->isTeleportOnCull = 0, e->activated = 0; } static void E_BridgeBoss_Disappear(Enemy *e) { e->isCullable = 1, e->isTeleportOnCull = 0; } static void E_BridgeBoss_Update(Enemy *e) { e->speed = e->defaultSpeed * e->activated; if (Core.Player->s.x > 0x9800) e->activated = 1; base_EnemyUpdate(e); } static void E_BridgeBoss_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *t) { if (e->activated) base_EnemyGetDamaged(e, amount, hitVFX, kb, t); } static void BridgeBoss_shakeStart(void *ctx) { (void)ctx; camera_followOffsetX = -2; } static int BridgeBoss_found; static void BridgeBoss_shakeDone(void *ctx) { (void)ctx; camera_followOffsetX = 0; if (BridgeBoss_found && Core.n_CharQueue < 8) Core.CharQueue[Core.n_CharQueue++] = "SCOREJ"; } static void E_BridgeBoss_Die(Enemy *e) { base_EnemyDie(e); BridgeBoss_found = 0; if (!po_has("UnlockedCharacters", "SCOREJ")) Sound_PlaySound("ThingFound", 1, 0.5f, -0x3e8, 0, 0), AchievementManager_UnlockSecret("HearTheThunder"), BridgeBoss_found = 1; Sound_PlaySound("Crystal12", 1.5f, 1, -0x258 * frand(), 0, 0); FrameFreeze_ms = 0x78; tweens_add((TweenConfig){ .props = { { &camera_followOffsetX, NULL, 2 } }, .nprops = 1, .duration = 0x10, .yoyo = 1, .repeat = 6, .onStart = BridgeBoss_shakeStart, .onComplete = BridgeBoss_shakeDone }); } static const EnemyVT E_BridgeBoss = { .OnRecycle = E_BridgeBoss_OnRecycle, .Die = E_BridgeBoss_Die, .GetDamaged = E_BridgeBoss_GetDamaged, .Update = E_BridgeBoss_Update, .Disappear = E_BridgeBoss_Disappear }; // --- BRIDGE_ARMOR/MINION/TETRA/TRAINEE (0x14f9d): le due fazioni del ponte; chi nasce a destra del giocatore usa l'aspetto 'alias' --- typedef struct { int useAlias; Animation aliasDie, aliasIdle; } BridgeX; static void E_Bridge_OnRecycle(Enemy *e) { if (!e->x) { // costruttore: le animazioni dell'alias BridgeX *b = e->x = calloc(1, sizeof(BridgeX)); cJSON *a = cJSON_GetObjectItem(enemy_data(e), "alias"); if (a) { cJSON *names = cJSON_GetObjectItem(a, "frameNames"); const char *tex = str(a, "textureName"), *name = cJSON_GetStringValue(cJSON_GetArrayItem(names, (int)floorf(frand() * cJSON_GetArraySize(names)))); char prefix[96]; snprintf(prefix, sizeof(prefix), "%s", name); char *q = strstr(prefix, "0.png"); if (q) *q = 0; b->aliasDie.n = anims_generateFrameNames(tex, prefix, 0, (int)num(a, "end", 0), 0, b->aliasDie.frames, ANIM_MAX_FRAMES); b->aliasDie.frameRate = 0x18, b->aliasDie.msPerFrame = 1000.0f / 0x18, b->aliasDie.repeat = 0; char ip[100]; snprintf(ip, sizeof(ip), "%si", prefix); b->aliasIdle.n = anims_generateFrameNames(tex, ip, 1, (int)num(a, "idleFrameCount", 0), 2, b->aliasIdle.frames, ANIM_MAX_FRAMES); b->aliasIdle.frameRate = 8, b->aliasIdle.msPerFrame = 1000.0f / 8, b->aliasIdle.repeat = -1; } } base_EnemyOnRecycle(e); } static void E_Bridge_setOwner(Enemy *e) { BridgeX *b = e->x; b->useAlias = e->s.x > Core.Player->s.x; if (b->useAlias) anims_play(&e->s, &b->aliasIdle, 0); } static void E_Bridge_Die(Enemy *e) { base_EnemyDie(e); BridgeX *b = e->x; if (b->useAlias) anims_play(&e->s, &b->aliasDie, 0); } static void E_Bridge_Disappear(Enemy *e) { base_EnemyDisappear(e); BridgeX *b = e->x; if (b->useAlias) anims_play(&e->s, &b->aliasDie, 0); } static const EnemyVT E_Bridge = { .OnRecycle = E_Bridge_OnRecycle, .Die = E_Bridge_Die, .Disappear = E_Bridge_Disappear, .setOwner = E_Bridge_setOwner }; // ============================================================================ // 0x5ba7: StageEventManager (eventi della Foresta: BAT_SWARM, GHOST_SWARM, FLOWER_WALL) // ============================================================================ #define dontSpawnIfAbove 0x1f4 typedef struct { int n; Enemy *list[]; } EventGroup; // l'array di nemici catturato dalla closure del timer static void base_EnemyDisappear(Enemy *e) { e->isDead = 1; anims_play(&e->s, &e->die, 0); } static void Enemy_Disappear(Enemy *e) { if (e->vt && e->vt->Disappear) e->vt->Disappear(e); else base_EnemyDisappear(e); } static EnemyPool *StageEvent_pool(Stage *st, const char *type) { // stage.pools.find || new + push, enabled = false EnemyPool *p = NULL; for (int i = 0; i < st->n_pools; i++) if (!strcmp(st->pools[i]->enemyType, type)) p = st->pools[i]; if (!p && st->n_pools < 256) p = st->pools[st->n_pools++] = EnemyPool_new(type); if (p) p->enabled = 0; return p; } static void StageEvent_disappear(void *ctx) { // 'batswarm disappear' / 'ghostswarm disappear' / 'flower disappear' EventGroup *g = ctx; for (int i = 0; i < g->n; i++) { Core.Stage->stageEventManager_spawned--; Enemy *e = g->list[i]; if (!e->isDead) { e->isCullable = 1; Enemy_Disappear(e); } } free(g); } // PlayBatSwarm / PlayGhostSwarm / PlayCircle: count nemici su un arco dell'ellisse attorno al giocatore static void StageEvent_ring(const char *type, float duration, int count, float angleStep, float sizeMul) { Stage *st = Core.Stage; EnemyPool *pool = StageEvent_pool(st, type); if (!pool) return; float a = 2 * PI * frand(); EventGroup *g = calloc(1, sizeof(EventGroup) + count * sizeof(Enemy *)); for (int i = 0; i < count; i++) { float x = Core.Player->s.x + 0.8f * cosf(a) * (game_width * sizeMul), y = Core.Player->s.y + 0.8f * sinf(a) * (game_height * sizeMul); a += angleStep; Enemy *e = EnemyPool_SpawnAt(pool, x, y); if (!e) continue; e->isCullable = 0; g->list[g->n++] = e; st->stageEventManager_spawned++; } time_addEvent(duration, 0, 0, StageEvent_disappear, g); } static void PlayBatSwarm(float d) { StageEvent_ring("BATSWARM", d ? d : 0x2710, 0x32, PI / 0x1f4, 0.9f); } static void PlayGhostSwarm(float d) { StageEvent_ring("GHOSTSWARM", d ? d : 0x2710, 0x14, PI / 0x1f4, 0.9f); } // I parametri arrivano da TriggerSwitchEvent con moreX = 0 e moreZ = 0 se mancano nei dati: lo 0 passato vince sui default // delle funzioni (JS usa il default solo per undefined), quindi per esempio JELLY_WALL senza moreX non genera nessuna medusa (sic). static void PlayCircle(float d, int count, const char *type, float mul) { StageEvent_ring(type, d ? d : 0xea60, count, PI / (0.5f * count), mul); } static void PlaySwarm(float d, int count, const char *type) { StageEvent_ring(type, d ? d : 0x2710, count, PI / 0x1f4, 0.9f); } static EventGroup *StageEvent_group(int count) { return calloc(1, sizeof(EventGroup) + (count > 0 ? count : 1) * sizeof(Enemy *)); } static void StageEvent_add(EventGroup *g, EnemyPool *pool, float x, float y) { // SpawnAt, isCullable = false, push, spawned++ Enemy *e = EnemyPool_SpawnAt(pool, x, y); if (!e) return; e->isCullable = 0; g->list[g->n++] = e; Core.Stage->stageEventManager_spawned++; } static void PlayJellyfish(float d, int count, const char *type) { // JELLY_WALL: un anello di meduse ferme che si apre e si chiude EnemyPool *pool = StageEvent_pool(Core.Stage, type ? type : "JELLYFISH"); if (!pool) return; float a = 2 * PI * frand(); EventGroup *g = StageEvent_group(count); for (int i = 0; i < count; i++) { float x = Core.Player->s.x + 0.6f * cosf(a) * (0.9f * game_width), y = Core.Player->s.y + 0.6f * sinf(a) * (0.9f * game_height); a += PI / 0x28; StageEvent_add(g, pool, x, y); } time_addEvent(d ? d : 0xea60, 0, 0, StageEvent_disappear, g); // 'Jellyfish disappear' } static void PlayMedusaSwarm(float d, int count, const char *type) { // una colonna di count nemici da un lato dello schermo Stage *st = Core.Stage; EnemyPool *pool = StageEvent_pool(st, type ? type : "MEDUSA1"); if (!pool) return; float side = frand() < 0.5f ? st->rectOuter.x : st->rectOuter.x + st->rectOuter.width; EventGroup *g = StageEvent_group(count); for (int i = 0; i < count; i++) StageEvent_add(g, pool, Core.Player->s.x + side, Core.Player->s.y + 8 * (i - 0.5f * count)); time_addEvent(d ? d : 0x3a98, 0, 0, StageEvent_disappear, g); // 'medusaswarm disappear' } static void PlayMedusaWall(float d, int count, const char *type) { // come sopra, ma alle altezze degli spawner della mappa Stage *st = Core.Stage; if (!st->hasTileset) { PlayMedusaSwarm(d, count, type); return; } EnemyPool *pool = StageEvent_pool(st, type ? type : "MEDUSA1"); float side = frand() < 0.5f ? st->rectOuter.x : st->rectOuter.x + st->rectOuter.width; int m = st->n_EnemySpanwersLocations - 1; if (!pool || st->n_EnemySpanwersLocations <= 0) return; EventGroup *g = StageEvent_group(count); for (int i = 0; i < count; i++) StageEvent_add(g, pool, Core.Player->s.x + side, st->EnemySpanwersLocations[m > 0 ? i % m : 0].y); // i % (n - 1) (sic) time_addEvent(d ? d : 0x3a98, 0, 0, StageEvent_disappear, g); } static void PlayShadeBomb(float d, const char *color, int count) { // ogni ombra in un punto a caso dell'ellisse EnemyPool *pool = StageEvent_pool(Core.Stage, !strcmp(color, "red") ? "SHADERED" : "SHADEBLUE"); if (!pool) return; EventGroup *g = StageEvent_group(count); for (int i = 0; i < count; i++) { float a = 2 * PI * frand(); StageEvent_add(g, pool, Core.Player->s.x + 0.8f * cosf(a) * (0.9f * game_width), Core.Player->s.y + 0.8f * sinf(a) * (0.9f * game_height)); } time_addEvent(d ? d : 0xea60, 0, 0, StageEvent_disappear, g); // 'shadebomb disappear' } static void PlaySkullSwarm(float d, int count, const char *type) { StageEvent_ring(type ? type : "SKULL2_SWARM", d ? d : 0x3a98, count, PI / 0x32, 0.9f); } static void PlayPileAssault(float d, int count, const char *type, float z) { // un cerchio di pile attorno al giocatore (raggio z) EnemyPool *pool = StageEvent_pool(Core.Stage, type ? type : "PILE1"); if (!pool) return; float a = 2 * PI * frand(), half = 0.5f * count; EventGroup *g = StageEvent_group(count); for (int i = 0; i < count; i++) { StageEvent_add(g, pool, Core.Player->s.x + cosf(a) * z * (0.9f * game_width), Core.Player->s.y + sinf(a) * z * (0.9f * game_height)); a += PI / half; } time_addEvent(d ? d : 0x7530, 0, 0, StageEvent_disappear, g); // 'pile assault disappear' } static void E_Stalker_MulSpeed(Enemy *e, float m); static void Stalker_disappear(void *ctx) { Enemy *e = ctx; if (!e->isDead) e->isCullable = 1, Enemy_Disappear(e); } static void PlayStalker(float d, float mul) { // fuori dal conto di 'spawned' EnemyPool *pool = StageEvent_pool(Core.Stage, "BOSS_XLSTALKER"); if (!pool) return; float a = 2 * PI * frand(); Enemy *e = EnemyPool_SpawnAt(pool, Core.Player->s.x + 0.8f * cosf(a) * (0.9f * game_width), Core.Player->s.y + 0.8f * sinf(a) * (0.9f * game_height)); if (!e) return; e->isCullable = 0; if (mul) E_Stalker_MulSpeed(e, mul); time_addEvent(d ? d : 0xea60, 0, 0, Stalker_disappear, e); // 'stalker disappear' } static void PlayEraseEnemies(void) { RosaryVFX_Play(); // FlashingVFXEnabled for (int i = 0; i < Core.Enemies.n; i++) { Enemy *e = Core.Enemies.items[i]->owner; if (!e->res_Rosary) Enemy_Disappear(e); } // semplificazione: BGMan.RunTimeHue = false e bgtile tinto verso 0x880000 in 2 s. Il bgtile della Foresta e' bg_null, // nero pieno sotto la mappa: la tinta (moltiplicativa) non si vede, come il DayNightHue. BGMan entra con gli stage senza tileset. } static void PlayCycleComplete(void) { PlayEraseEnemies(); } // SelectedReapers falso: Stage.OnCycleComplete solo con l'opzione // --- ShootingStarsManager (0xc8fd) e le sue stelle (0x10924 / 0xb406): "!" a terra, poi la stella cala ad arco ed esplode --------- typedef struct ShootingStar { float x, y, radius, damage, arcAngle, arcRadius; int hasHit, exploding; unsigned color; ParticleManager *particlesManager; ParticleEmitter *pfxEmitter, *pfxEmitter2; Sprite GroundFx, WarningSprite, StarSprite, GroundWarning, trail; Animation explode; TweenRef despawnTimer; int mirror; // ShootingStarsManager2 (0xe956 / 0xef44): arco da destra, rossa } ShootingStar; static unsigned star_color(int mirror, int recycle) { static const unsigned C[3] = { 0xffff, 0xb7192, 0xd4e6f }, R[3] = { 0x920909, 0x920c22, 0x993200 }, R2[3] = { 0x920909, 0x920c12, 0x990200 }; // (sic) due terne rosse const unsigned *t = !mirror ? C : recycle ? R2 : R; return t[(int)floorf(frand() * 3)]; } static void StarTrail_draw(Sprite *s) { // graphics.arc(R, R, R, 180 -> arcAngle) a larghezza 4 (alpha 0.5) e 2 (alpha 0.8), ADD ShootingStar *st = s->owner; if (!s->visible || s->alpha <= 0 || st->arcAngle <= 180) return; Vector2 c = { s->x + (st->mirror ? -1 : 1) * st->arcRadius - camera_scrollX, s->y + st->arcRadius - camera_scrollY }; // mirror: setScale(-1, 1) float a0 = st->mirror ? 180 - st->arcAngle : 180, a1 = st->mirror ? 0 : st->arcAngle; BeginBlendMode(BLEND_ADDITIVE); DrawRing(c, st->arcRadius - 2, st->arcRadius + 2, a0, a1, 64, hexc(st->color, 0.5f * s->alpha)); DrawRing(c, st->arcRadius - 1, st->arcRadius + 1, a0, a1, 64, hexc(st->color, 0.8f * s->alpha)); EndBlendMode(); } static void Star_DeSpawn(ShootingStar *st) { emitter_stop(st->pfxEmitter), emitter_stop(st->pfxEmitter2); typeof(Core.starPool) *p = st->mirror ? &Core.starPool2 : &Core.starPool; // Return for (int i = 0; i < p->nspawned; i++) if (p->spawned[i] == st) { memmove(&p->spawned[i], &p->spawned[i + 1], (p->nspawned - i - 1) * sizeof(*p->spawned)); p->nspawned--; break; } if (p->nstored == p->capstored) p->stored = realloc(p->stored, (p->capstored = p->capstored ? p->capstored * 2 : 16) * sizeof(*p->stored)); p->stored[p->nstored++] = st; st->exploding = 0, st->trail.visible = 0; tween_stop(st->despawnTimer), st->despawnTimer = TWEEN_NONE; st->GroundFx.visible = 0; } static void Star_despawnCb(void *ctx) { Star_DeSpawn(ctx); } static void Star_place(ShootingStar *st) { float a = st->arcAngle * DEG2RAD; float m = st->mirror ? -1 : 1; st->StarSprite.x = st->x - m * st->arcRadius + m * cosf(a) * st->arcRadius, st->StarSprite.y = st->y + sinf(a) * st->arcRadius; } static void Star_Explode(void *ctx) { ShootingStar *st = ctx; anims_stop(&st->StarSprite), anims_play(&st->StarSprite, &st->explode, 0); st->exploding = 1, st->hasHit = 0; st->particlesManager->wellX = st->x, st->particlesManager->wellY = st->y - 0x14; st->pfxEmitter->x = st->pfxEmitter2->x = st->x, st->pfxEmitter->y = st->pfxEmitter2->y = st->y; emitter_start(st->pfxEmitter), emitter_start(st->pfxEmitter2); st->GroundFx.x = st->x, st->GroundFx.y = st->y, st->GroundFx.visible = 1, st->GroundFx.scaleX = 1; // FlashingVFXEnabled tween_stop(st->despawnTimer); st->despawnTimer = tweens_add((TweenConfig){ .props = { { &st->GroundFx.scaleX, NULL, st->radius } }, .nprops = 1, .duration = 0x96, .onComplete = Star_despawnCb, .ctx = st }); tweens_add((TweenConfig){ .props = { { &st->trail.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x64 }); Sound_PlaySound("Explosion", 0.5f, 1, 0x1f4 * (frand() - 0.5f), 0x96, 3); } static void Star_arcStart(void *ctx) { ShootingStar *st = ctx; st->trail.visible = 1, st->StarSprite.visible = 1; Star_place(st); } static void Star_warnBack(void *ctx) { Sprite *s = ctx; tweens_add((TweenConfig){ .props = { { &s->scaleX, &s->scaleY, 0 } }, .nprops = 1, .duration = 0xc8, .delay = 0xc8 }); } static void Star_OnRecycle(ShootingStar *st) { sprite_setFrame(&st->StarSprite, frame_get("vfx", "Star_0.png")), st->StarSprite.visible = 0; st->arcRadius = 0.5f * game_width, st->exploding = 0; st->GroundWarning.x = st->x, st->GroundWarning.y = st->y; st->WarningSprite.x = st->x, st->WarningSprite.y = st->y - 0x10, sprite_setScale(&st->WarningSprite, 0); st->GroundWarning.alpha = 0, st->GroundWarning.visible = 1; st->color = star_color(st->mirror, 1); // solo la scia: i cerchi tengono il colore del costruttore Sound_PlaySound("Pizza", 0.9f, 1, 0x1f4 * frand(), 0x96, 2); tweens_add((TweenConfig){ .props = { { &st->WarningSprite.scaleX, &st->WarningSprite.scaleY, 1 } }, .nprops = 1, .duration = 0xc8, .onComplete = Star_warnBack, .ctx = &st->WarningSprite }); tweens_add((TweenConfig){ .props = { { &st->GroundWarning.alpha, NULL, 0.2f }, { &st->GroundWarning.scaleX, &st->GroundWarning.scaleY, st->radius } }, .nprops = 2, .duration = 0x1f4, .yoyo = 1, .repeat = 1 }); st->arcAngle = 0xb4; tweens_add((TweenConfig){ .props = { { &st->arcAngle, NULL, 0x168 } }, .nprops = 1, .duration = 0x1f4, .delay = 0x5dc, .onStart = Star_arcStart, .onComplete = Star_Explode, .ctx = st }); st->trail.x = st->x + (st->mirror ? 2 : -2) * st->arcRadius, st->trail.y = st->y - st->arcRadius, st->trail.alpha = 1, st->trail.depth = 0xbb8; } static ShootingStar *Star_new(int mirror) { ShootingStar *st = calloc(1, sizeof(ShootingStar)); st->mirror = mirror; st->radius = st->damage = 1, st->arcRadius = 0xfa, st->despawnTimer = TWEEN_NONE; st->particlesManager = particles_add(); st->pfxEmitter2 = particles_createEmitter(st->particlesManager, (EmitterConfig){ .frames = { frame_get("vfx", "Star_0.png"), frame_get("vfx", "Star2.png") }, .nframes = 2, .lifespan = EOP(0x3e8), .rotate = ERND(0, 0x168), .angle = { 0, 0xb4, 1 }, .angleSteps = 0x10, .speed = ERND(0x64, 0xc8), .quantity = 2, .scale = ERANGE(1, 0), .frequency = 2, .alpha = ERANGE(0.5f, 0), .tint = mirror ? 0xff4444 : 0, .on = 0 }); st->pfxEmitter = particles_createEmitter(st->particlesManager, (EmitterConfig){ .frames = { frame_get("vfx", mirror ? "_blur.png" : "_blur3.png"), frame_get("vfx", mirror ? "HitSmoke2.png" : "HitCloud2.png") }, .nframes = 2, .lifespan = EOP(0x1f4), .rotate = ERND(0, 0x168), .angle = { 0, 0x168, 1 }, .angleSteps = 0x10, .speed = ERND(0x50, 0x78), .quantity = 2, .scale = ERANGE(1, 0), .frequency = 2, .blendAdd = 1, .on = 0 }); st->particlesManager->hasWell = 1; // createGravityWell({ power: 1, epsilon: 50, gravity: 20 }) st->particlesManager->wellPower = 1 * 0x14, st->particlesManager->wellEpsilon = 0x32 * 0x32; st->color = star_color(mirror, 0); Sprite *c[2] = { &st->GroundFx, &st->GroundWarning }; // scene.add.circle(0, 0, 1, color), alpha 0.4, ADD for (int i = 0; i < 2; i++) { sprite_init(c[i], NULL, 0, 0); c[i]->draw = MoonGroundFx_draw, c[i]->tint = st->color, c[i]->alpha = 0.4f, c[i]->visible = 0, c[i]->scaleX = c[i]->scaleY = 1; children_add(c[i]); } sprite_init(&st->WarningSprite, frame_get("UI", "ExclamationMark.png"), 0.5f * game_width, 0.5f * game_height - 0x30); sprite_setScale(&st->WarningSprite, 0), sprite_setOrigin(&st->WarningSprite, 0.5f, 1), st->WarningSprite.depth = 0x2328; children_add(&st->WarningSprite); sprite_init(&st->StarSprite, frame_get("vfx", "Star_0.png"), 0.5f * game_width, 0.5f * game_height - 0x30); sprite_setScale(&st->StarSprite, 2), sprite_setOrigin(&st->StarSprite, 0.5f, 1), st->StarSprite.depth = 0x2328, st->StarSprite.angle = 0xf; if (mirror) sprite_setTint(&st->StarSprite, 0xff0000); children_add(&st->StarSprite); sprite_init(&st->trail, NULL, 0, 0); st->trail.owner = st, st->trail.draw = StarTrail_draw; children_add(&st->trail); st->explode.n = anims_generateFrameNames("vfx", "Star_", 0, 0x12, 0, st->explode.frames, ANIM_MAX_FRAMES); st->explode.frameRate = 0x1e, st->explode.msPerFrame = 1000.0f / 0x1e, st->explode.repeat = 0; return st; } static void ShootingStars_shootStarAt(float x, float y, int mirror) { // explosionStarPool.SpawnAt(x, y, 30, 60) typeof(Core.starPool) *p = mirror ? &Core.starPool2 : &Core.starPool; ShootingStar *st = p->nstored ? p->stored[--p->nstored] : NULL; if (!st) st = Star_new(mirror), st->x = st->y = -0x3e8, Star_OnRecycle(st); // Init: un primo giro a (-1000, -1000), "!" e suono compresi if (p->nspawned == p->capspawned) p->spawned = realloc(p->spawned, (p->capspawned = p->capspawned ? p->capspawned * 2 : 16) * sizeof(*p->spawned)); p->spawned[p->nspawned++] = st; st->x = x, st->y = y, st->damage = 0x1e, st->radius = 0x3c; st->GroundFx.depth = st->particlesManager->s.depth = y + 1 - Core.Player->s.y; // setDepthPlease Star_OnRecycle(st); } typedef struct { float z; int mirror; } StarShot; static void ShootingStars_shootOne(void *ctx) { StarShot *s = ctx; ShootingStars_shootStarAt(Core.Player->s.x + (frand() - 0.5f) * game_width * 0.5f * s->z, Core.Player->s.y + (frand() - 0.5f) * game_height * 0.5f * s->z, s->mirror); } static void ShootStars(int count, float step, float z, int mirror) { // AimRandom: count stelle, una ogni step ms, sparse di z mezzi schermi (mirror: SHOOTING_STAR2) StarShot *s = calloc(1, sizeof(StarShot)); s->z = z, s->mirror = mirror; for (int i = 0; i < count; i++) time_addEvent(step * i, 0, 0, ShootingStars_shootOne, s); } static void ShootingStars_UpdatePool(typeof(Core.starPool) *p, float delta) { for (int i = 0; i < p->nspawned; i++) { ShootingStar *st = p->spawned[i]; if (st->hasHit) continue; float dx = Core.Player->s.x - st->x, dy = Core.Player->s.y - st->y; if (st->exploding && st->radius > 0 && dx * dx + dy * dy <= st->radius * st->radius) st->hasHit = 1, Player_GetDamaged(Core.Player, st->damage); if (ceilf(delta / 0x10) > 0) Star_place(st); // trailUpdate (ceil(delta / 16) volte: la scia si ridisegna a ogni frame) } } static void ShootingStars_Update(float delta) { ShootingStars_UpdatePool(&Core.starPool, delta), ShootingStars_UpdatePool(&Core.starPool2, delta); } typedef struct { EventGroup *g; EnemyPool *pool; float y; int k, count; } DragonStream; static void PlayDragonStreamEnd(void *ctx) { // 'dragonstream disappear' DragonStream *s = ctx; StageEvent_disappear(s->g); s->g = NULL; // le waves + 1 ondate finiscono dopo d: l'ultima arriva a gruppo gia' liberato } static void PlayDragonStream_wave(void *ctx) { // da sinistra e da destra a turno, count draghi in colonna DragonStream *s = ctx; Stage *st = Core.Stage; float side = s->k++ % 2 == 0 ? st->rectOuter.x : st->rectOuter.x + st->rectOuter.width; for (int i = 0; i < s->count; i++) { Enemy *e = EnemyPool_SpawnAt(s->pool, Core.Player->s.x + side, s->y + 8 * (i - 0.5f * s->count)); if (!e) continue; e->isCullable = 0, e->speed *= 1.5f; if (s->g) s->g->list[s->g->n++] = e; st->stageEventManager_spawned++; } } static void PlayDragonStream(float d, int waves, const char *type, int count) { Stage *st = Core.Stage; d = d ? d : 0xea60; EnemyPool *pool = StageEvent_pool(st, type ? type : "XLDRAGON1_FLAG"); if (!pool) return; DragonStream *s = calloc(1, sizeof(DragonStream)); s->g = StageEvent_group((waves + 1) * count), s->pool = pool, s->count = count; s->y = Core.Player->s.y + (Core.Player->lastFacedDirection.y <= 0 ? st->rectOuter.y : st->rectOuter.y + st->rectOuter.height); // dot(UP) >= 0 time_addEvent(floorf(d / waves), 0, waves, PlayDragonStream_wave, s); // repeat: waves + 1 ondate time_addEvent(d, 0, 0, PlayDragonStreamEnd, s); } static void PlayPolterRoulette(float d, int count, const char *type, int dest) { // anello di poltergeist; dest posti a caso sono distruttibili Stage *st = Core.Stage; EnemyPool *pool = StageEvent_pool(st, type ? type : "POLTER_DEST"); if (!pool) return; float a = 2 * PI * frand(); int *pick = calloc(dest > 0 ? dest : 1, sizeof(int)); for (int i = 0; i < dest; i++) pick[i] = (int)floorf(frand() * count); EventGroup *g = StageEvent_group(count); for (int i = 0; i < count; i++) { float x = Core.Player->s.x + 0.6f * cosf(a) * (0.85f * game_width), y = Core.Player->s.y + 0.6f * sinf(a) * (0.85f * game_height); a += PI / (0.5f * count); if (st->tilingTileset && TilingTileset_isPointWithinCollisionLayer(st->tilingTileset, x, y)) continue; int isDest = 0; for (int j = 0; j < dest; j++) isDest |= pick[j] == i; if (isDest) Core_MakeDestructibleAt(st->destructibleType, (Vector2){ x, y }); else StageEvent_add(g, pool, x, y); } time_addEvent(d ? d : 0xea60, 0, 0, StageEvent_disappear, g); // 'POLTER disappear' } static void PlayVerticalSwarm(float d, int count, const char *type) { // MONSTER_RAIN: una fila di count nemici in cima allo schermo Stage *st = Core.Stage; EnemyPool *pool = StageEvent_pool(st, type ? type : "XLSWORDIAN_V"); if (!pool) return; float w = st->rectOuter.width / count; EventGroup *g = StageEvent_group(count); for (int i = 0; i < count; i++) StageEvent_add(g, pool, Core.Player->s.x - 0.5f * st->rectOuter.width + w * i, Core.Player->s.y - 0.5f * st->rectOuter.height); time_addEvent(d ? d : 0x3a98, 0, 0, StageEvent_disappear, g); // 'vertical swarm disappear' } static void PlaySkeleStream(float d, int count, const char *type) { // SKELESTREAM: count stendardi da sinistra e destra a turno, a meta' altezza Stage *st = Core.Stage; EnemyPool *pool = StageEvent_pool(st, type ? type : "XLDRAGON3_FLAG"); if (!pool) return; float y = Core.Player->s.y + 0.5f * (Core.Player->lastFacedDirection.y <= 0 ? st->rectOuter.y : st->rectOuter.y + st->rectOuter.height); // dot(UP) >= 0 EventGroup *g = StageEvent_group(count); for (int i = 0; i < count; i++) StageEvent_add(g, pool, Core.Player->s.x + (i % 2 == 0 ? st->rectOuter.x : st->rectOuter.x + st->rectOuter.width), y + 8 * (i - 0.5f * count)); time_addEvent(d ? d : 0x4e20, 0, 0, StageEvent_disappear, g); // 'PlaySkeleStream disappear' } static void Drowner_eventEnd(void *ctx) { // 'drowner disappear' Enemy *e = ctx; if (e->isDead) return; e->isCullable = 1; if (e->x) ((DrownerX *)e->x)->dismissed = 1; Enemy_Disappear(e); } static void PlayDrowner(float d) { EnemyPool *pool = StageEvent_pool(Core.Stage, "BOSS_XLDROWNER"); if (!pool) return; Enemy *e = EnemyPool_SpawnAt(pool, Core.Player->s.x, Core.Player->s.y + game_height); if (!e) return; e->isCullable = 0; time_addEvent(d ? d : 0xea60, 0, 0, Drowner_eventEnd, e); } typedef struct { EventGroup *g; EnemyPool *pool; int col, k; float y0, step; } PilePile; static void PilePile_spawn(void *ctx) { // una pila ogni 30 ms, alternando lato e salendo PilePile *p = ctx; Stage *st = Core.Stage; float x = 0.65f * (p->k % 2 == 0 ? st->rectOuter.x - 0x20 * p->col : st->rectOuter.x + st->rectOuter.width + 0x20 * p->col); Enemy *e = EnemyPool_SpawnAt(p->pool, Core.Player->s.x + x, 0x10 * p->col + p->y0 - p->step * p->k); p->k++; if (!e) return; e->isCullable = 0, e->speed = 0; p->g->list[p->g->n++] = e; st->stageEventManager_spawned++; } static void PlaySkullPilePile(float d, int cols, const char *type) { // TWINS_PILES Stage *st = Core.Stage; EnemyPool *pool = StageEvent_pool(st, type ? type : "PILE4_SCALED"); if (!pool) return; int n = (int)(3 * st->rectOuter.height / 0x22); EventGroup *g = StageEvent_group(cols * n + 1); for (int c = 0; c < cols; c++) { PilePile *p = calloc(1, sizeof(PilePile)); p->g = g, p->pool = pool, p->col = c, p->y0 = Core.Player->s.y + 1.5f * game_height, p->step = 3 * game_height / (3 * st->rectOuter.height / 0x22); time_addEvent(0x1e, 0, n - 1, PilePile_spawn, p); } time_addEvent(d ? d : 0x7530, 0, 0, StageEvent_disappear, g); // 'PlaySkullPilePile disappear' } // --- Gli eventi "a sorpresa" (fn*) dello StageEventManager, usati da Trisection ------------------------------------------------------- static void Stage_updateNormalEnemyPoolsOnly(Stage *st) { for (int i = 0; i < st->n_pools; i++) st->pools[i]->enabled = 0; cJSON *e; cJSON_ArrayForEach(e, st->enemies) { const char *t = cJSON_GetStringValue(e); EnemyPool *found = NULL; for (int i = 0; i < st->n_pools; i++) if (!strcmp(st->pools[i]->enemyType, t)) { found = st->pools[i]; break; } if (found) found->enabled = 1; else if (st->n_pools < 256) st->pools[st->n_pools++] = EnemyPool_new(t); // new EnemyPool: abilitato (sic) } } static void fn_restoreSpawnType(void *ctx) { Core.Stage->spawnType = ctx; } static void fn_tiled30s(void) { // spawnType = TILED per 30 s (i nemici cambiati restano fino al minuto dopo) time_addEvent(0x7530, 0, 0, fn_restoreSpawnType, (void *)Core.Stage->spawnType); Core.Stage->spawnType = "TILED"; } static void fn_setEnemies(const char *const *t, int n, int append) { Stage *st = Core.Stage; cJSON *a = cJSON_CreateArray(), *e; if (append) cJSON_ArrayForEach(e, st->enemies) cJSON_AddItemToArray(a, cJSON_CreateString(cJSON_GetStringValue(e))); for (int i = 0; i < n; i++) cJSON_AddItemToArray(a, cJSON_CreateString(t[i])); st->enemies = a; // semplificazione: l'array vecchio era dei dati (non si libera), il nuovo resta fino al prossimo minuto } static void fnGoldVacuum(void *ctx) { (void)ctx; Core_TurnOnVacuumForGold(); } static void Core_DoPraise(int n) { // cuoricini in cerchio che volano verso il giocatore, uno ogni 8 ms Player *p = Core.Player; for (int i = 0; i < n; i++) { float a = 2 * PI / n * i, r = 0.5f * game_height; Pickup *h = Core_MakePickup(p->s.x + sinf(a) * r, p->s.y + cosf(a) * r, "LITTLEHEART"); if (h) h->goToPlayer = 1, tweens_add((TweenConfig){ .props = { { &h->time, NULL, 1 } }, .nprops = 1, .duration = 0x10, .delay = 8 * i }); } } static int TriggerFnEvent(const char *type) { // 1 se il tipo e' uno di questi Player *p = Core.Player; float px = p->s.x, py = p->s.y; if (!strcmp(type, "ROSARY")) Core_MakePickup(px, py, "ROSARY"), GizmoManager_ShowHighlightAt(px, py); else if (!strcmp(type, "PET")) Core_DoPraise(0x6c), GizmoManager_ShowHighlightAt(px, py); // DoPraise(108) else if (!strcmp(type, "CHICKEN_BONANZA")) { for (int i = 0; i < 0xc; i++) { float a = 2 * PI / 0xc * i; Core_MakePickup(px + 0xaf * sinf(a), py + 0xaf * cosf(a), "ROAST"); } GizmoManager_ShowHighlightAt(px, py); } else if (!strcmp(type, "GOLD_FEVER")) GoldFever_Start(0x2710), time_addEvent(0xbb8, 0, 2, fnGoldVacuum, NULL), GizmoManager_ShowHighlightAt(px, py); else if (!strcmp(type, "FREE_PASSIVE")) { static const char *const P[17] = { "AMOUNT", "AREA", "ARMOR", "COOLDOWN", "CURSE", "DURATION", "GREED", "GROWTH", "LUCK", "MAGNET", "MAXHEALTH", "MIGHT", "MOVESPEED", "REGEN", "REVIVAL", "SPEED", "PANDORA" }; Core_MakeStagePickup(px, py + 0.45f * game_height, "WEAPON", P[(int)floorf(frand() * 17)]), GizmoManager_ShowHighlightAt(px, py + 0.45f * game_height); } else if (!strcmp(type, "LIGHT_SOURCES")) Core_debug_destructibles(1); else if (!strcmp(type, "FIREBREATHING")) Core_MakePickup(px, py, "NFT"), GizmoManager_ShowHighlightAt(px, py); else if (!strcmp(type, "LUCK_BOOST")) { for (int i = 0; i < 5; i++) { float a = 2 * PI / (5 / 3.0f) * i, r = 0.5f * game_width; Pickup *c = Core_MakePickup(px + sinf(a) * r, py + cosf(a) * r, "CLOVER"); if (c) c->goToPlayer = 1, c->time = 1; } GizmoManager_ShowHighlightAt(px, py); } else if (!strcmp(type, "CURSE_BOOST")) {} // fnSkull: vuota else if (!strcmp(type, "ULTRA_WAVE")) fn_tiled30s(); else if (!strcmp(type, "SUMMON_MOLISE")) { static const char *const M[5] = { "MOLISANO_BELLO", "MOLISANO_FAGIOLO", "MOLISANO_GIALLO", "MOLISANO_GROSSO", "MOLISANO_VECCHIO" }; fn_tiled30s(), fn_setEnemies(M, 5, 0); Core.Stage->minimum = Core.Stage->maximum = 0x1f4, Core.Stage->frequency = 0x64; Stage_updateNormalEnemyPoolsOnly(Core.Stage); } else if (!strcmp(type, "SUMMON_NIGHT")) { static const char *const B[6] = { "BAT1", "BAT2", "BAT3", "BAT6", "BATSWARM", "XLBAT" }; fn_tiled30s(), fn_setEnemies(B, 6, 0), Stage_updateNormalEnemyPoolsOnly(Core.Stage); } else if (!strcmp(type, "PANIC_TIME")) { static const char *const X[3] = { "SHADERED", "POLTER", "POLTER_GEM" }; fn_tiled30s(), fn_setEnemies(X, 3, 1), Core.Stage->minimum += 0x32, Stage_updateNormalEnemyPoolsOnly(Core.Stage); } else if (!strcmp(type, "CANDYBOX")) { Pickup *c = Core_MakeStagePickup(px, py + 0.45f * game_height, "WEAPON", "CANDYBOX"); if (c) c->despawnOnUnavailable = 0; GizmoManager_ShowHighlightAt(px, py + 0.45f * game_height); } else if (!strcmp(type, "CRAB_FEST")) { static const char *const C[1] = { "MOON_CRABBINO" }; fn_tiled30s(), fn_setEnemies(C, 1, 1), Core.Stage->minimum += 0x32, Stage_updateNormalEnemyPoolsOnly(Core.Stage); } else return 0; return 1; // GRAVITY_JUGGLE (gravita' del mondo) e SLEEPER: nessuno stage del gioco base li usa } static void SpawnInSteps(float d, int count, const char *type); // Bat Country: piu' avanti, con le sue classi static void PlayDiamond_Square(int rings, const char *type); static void PlayDiamond_Road(int roads); static void PlayDiamond_Concrete(float cx, float cy); static void PlayDiamond_RandomPattern(float d); static int TriggerSwitchEvent(const char *type, float chance, float duration, float moreX, const char *moreY, float moreZ, float moreYn) { if (!strcmp(type, "ERASE_ENEMIES")) { PlayEraseEnemies(); return 1; } if (!strcmp(type, "CYCLE_COMPLETE")) { PlayCycleComplete(); return 1; } if (Core.Enemies.n > dontSpawnIfAbove) return 0; // la condizione sui tipi dell'originale e' sempre vera float luck = Player_PLuck(Core.Player); // PLuck if (chance && 0x64 * frand() > chance * (1 / luck)) return 0; int x = (int)moreX; if (TriggerFnEvent(type)) return 1; if (!strcmp(type, "STALKER")) PlayStalker(duration, moreX); else if (!strcmp(type, "JELLY_WALL")) PlayJellyfish(duration, x, moreY); else if (!strcmp(type, "FLOWER_WALL")) PlayCircle(duration, 0x64, "FLOWER", 0.9f); else if (!strcmp(type, "BAT_SWARM")) PlayBatSwarm(duration); else if (!strcmp(type, "GHOST_SWARM")) PlayGhostSwarm(duration); else if (!strcmp(type, "MEDUSA_SWARM") || !strcmp(type, "DRAGON_SWARM")) PlayMedusaSwarm(duration, x, moreY); else if (!strcmp(type, "MEDUSA_WALL")) PlayMedusaWall(duration, x, moreY); else if (!strcmp(type, "SHADE_BOMB_RED")) PlayShadeBomb(duration, "red", x); else if (!strcmp(type, "SKULL_SWARM")) PlaySkullSwarm(duration, x, moreY); else if (!strcmp(type, "PILE_ASSAULT")) PlayPileAssault(duration, x, moreY, moreZ); else if (!strcmp(type, "MINO_RUSH")) PlaySwarm(duration, x, "MIGNO_3_5SWARM"); else if (!strcmp(type, "JELLY_SWARM")) PlaySwarm(duration, x, "JELLYFISH2_SWARM"); else if (!strcmp(type, "ECTO_SWARM")) PlaySwarm(duration, x, "ECTO2"); else if (!strcmp(type, "GENERIC_SWARM") || !strcmp(type, "SKELETON_SWARM")) PlaySwarm(duration, x, moreY ? moreY : "BATSWARM"); else if (!strcmp(type, "IMP_SWARM")) PlaySwarm(duration, x, "IMP"); else if (!strcmp(type, "POLTER_SWARM")) PlayCircle(duration, x, "POLTER", 0.7f); else if (!strcmp(type, "GENERIC_CIRCLE")) PlayCircle(duration, x, moreY ? moreY : "FLOWER", moreZ); else if (!strcmp(type, "DRAGONSTREAM")) PlayDragonStream(duration, x, moreY, (int)moreZ); else if (!strcmp(type, "POLTER_ROULETTE")) PlayPolterRoulette(duration, x, moreY, (int)moreZ); else if (!strcmp(type, "SHOOTING_STAR")) ShootStars(x, moreYn, moreZ, 0); else if (!strcmp(type, "SHOOTING_STAR2")) ShootStars(x, moreYn, moreZ, 1); else if (!strcmp(type, "MONSTER_RAIN")) PlayVerticalSwarm(duration, x, moreY); else if (!strcmp(type, "SKELESTREAM")) PlaySkeleStream(duration, (int)moreZ, moreY); else if (!strcmp(type, "DROWNER")) PlayDrowner(duration); else if (!strcmp(type, "TWINS_PILES")) PlaySkullPilePile(duration, x, moreY); else if (!strcmp(type, "MONSTER_DANCE")) SpawnInSteps(duration, x, moreY); else if (!strcmp(type, "DIAMOND_SQUARE")) PlayDiamond_Square(x, moreY); else if (!strcmp(type, "DIAMOND_ROAD")) PlayDiamond_Road(x); else if (!strcmp(type, "DIAMOND_CONCRETE")) PlayDiamond_Concrete(0, 0); else if (!strcmp(type, "DIAMOND_MAZE")) PlayDiamond_RandomPattern(duration); // gli altri eventi arrivano con i loro stage (S3...) return 1; } static int TriggerEvent_switch(cJSON *ev) { return TriggerSwitchEvent(str(ev, "eventType"), num(ev, "chance", 0), num(ev, "duration", 0), num(ev, "moreX", 0), str(ev, "moreY"), num(ev, "moreZ", 0), num(ev, "moreY", 0)); } static void TriggerEvent_cb(void *ctx) { TriggerEvent_switch(ctx); } static int TriggerEvent(cJSON *ev) { float delay = num(ev, "delay", 0); if (delay) { time_addEvent(delay, 0, (int)num(ev, "repeat", 0), TriggerEvent_cb, ev); return 0; } // 'trigger event' return TriggerEvent_switch(ev); } // Stage.FireEnemyBulletAt(x, y, tipo): il tipo non conta, il pool e' sempre BULLET_1; qualche proiettile oltre il massimo dei nemici static void Stage_FireEnemyBulletAt(float x, float y) { Stage *st = Core.Stage; if (GetPermanentEnemiesNumber(st) < st->maximum + st->bulletAllowance) EnemyPool_SpawnAt(st->BulletPool1, x, y); } static void Stage_UpdateAllData(Stage *st, cJSON *d) { if (has(d, "frequency")) st->frequency = num(d, "frequency", 0); if (has(d, "minimum")) st->minimum = (int)num(d, "minimum", 0); if (has(d, "maximum")) st->maximum = (int)num(d, "maximum", 0); if (has(d, "defaultMaximum")) st->defaultMaximum = (int)num(d, "defaultMaximum", 0); if (has(d, "pause")) st->pause = num(d, "pause", 0); if (has(d, "startingSpawns")) st->startingSpawns = (int)num(d, "startingSpawns", 0); if (has(d, "destructibleType")) st->destructibleType = str(d, "destructibleType"); if (has(d, "destructibleFreq")) st->destructibleFreq = num(d, "destructibleFreq", 0); if (has(d, "destructibleChance")) st->destructibleChance = num(d, "destructibleChance", 0); if (has(d, "destructibleChanceMax")) st->destructibleChanceMax = num(d, "destructibleChanceMax", 0); if (has(d, "maxDestructibles")) st->maxDestructibles = (int)num(d, "maxDestructibles", 0); if (st->dataMinute == 0) st->pizzaEvents = cJSON_GetObjectItem(d, "pizzaEvents"); if (has(d, "spawnType")) st->spawnType = str(d, "spawnType"); if (has(d, "BGTextureName")) st->BGTextureName = str(d, "BGTextureName"); if (has(d, "randomMinutes")) st->randomMinutes = cJSON_IsTrue(cJSON_GetObjectItem(d, "randomMinutes")); if (has(d, "dayNight")) st->dayNight = cJSON_IsTrue(cJSON_GetObjectItem(d, "dayNight")); if (has(d, "hasLights")) st->hasLights = cJSON_IsTrue(cJSON_GetObjectItem(d, "hasLights")); if (has(d, "isMerchantBanned")) st->isMerchantBanned = cJSON_IsTrue(cJSON_GetObjectItem(d, "isMerchantBanned")); if (has(d, "stopCheckingMinutes")) st->stopCheckingMinutes = cJSON_IsTrue(cJSON_GetObjectItem(d, "stopCheckingMinutes")); if (has(d, "DayColor")) st->DayColor = (unsigned)num(d, "DayColor", 0); if (has(d, "NightColor")) st->NightColor = (unsigned)num(d, "NightColor", 0); if (has(d, "InverseDayColor")) st->InverseDayColor = (unsigned)num(d, "InverseDayColor", 0); if (has(d, "InverseNightColor")) st->InverseNightColor = (unsigned)num(d, "InverseNightColor", 0); if (has(d, "bulletAllowance")) st->bulletAllowance = num(d, "bulletAllowance", 0); if (has(d, "pizzaIntervalInMilliSeconds")) st->pizzaIntervalInMilliSeconds = num(d, "pizzaIntervalInMilliSeconds", 0); if (has(d, "poolsMapping")) st->poolsMapping = cJSON_GetObjectItem(d, "poolsMapping"); if (has(d, "LootTable")) st->LootTable = cJSON_GetObjectItem(d, "LootTable"); st->enemies = has(d, "enemies") ? cJSON_GetObjectItem(d, "enemies") : st->enemies; st->bosses = cJSON_GetObjectItem(d, "bosses"); st->treasure = cJSON_GetObjectItem(d, "treasure"); if (cJSON_IsNull(st->treasure)) st->treasure = NULL; st->arcanaHolder = str(d, "arcanaHolder"); // UpdateAllData: azzerati a ogni minuto, poi copiati dai dati st->arcanaTreasure = cJSON_GetObjectItem(d, "arcanaTreasure"); if (cJSON_IsNull(st->arcanaTreasure)) st->arcanaTreasure = NULL; float c1 = Player_PCurse(Core.Player) + 0.5f * st->StageModifiers.EndCycles; float c2 = Player_PCurse(Core.Player) + 1 * st->StageModifiers.EndCycles; st->minimumMultiplier = c2; Stage_CalculateEnemySpeed(st); st->EffectiveSpawnFrequency = st->frequency / fmaxf(0.1f, c1); st->minimum += (int)Core.Player->charm; st->maximum = st->defaultMaximum + (int)Core.Player->charm; Stage_updateEnemyPools(st); Stage_updateTimers(st); cJSON *ev; // playEvents: events del minuto (nessuno = []) cJSON_ArrayForEach(ev, cJSON_GetObjectItem(d, "events")) TriggerEvent(ev); st->lastMinimum = st->minimum; st->lastMaximum = st->maximum; } // Stage.GetValidUnlockedStages: gli sbloccati fra i cinque stage base static int Stage_GetValidUnlockedStages(const char **out) { static const char *const V[] = { "FOREST", "LIBRARY", "WAREHOUSE", "TOWER", "CHAPEL" }; int n = 0; cJSON *v; cJSON_ArrayForEach(v, po("UnlockedStages")) for (int i = 0; i < 5; i++) if (cJSON_IsString(v) && !strcmp(v->valuestring, V[i]) && n < 16) out[n++] = v->valuestring; return n; } // randomMinutes (Green Acres): con almeno 2 stage validi il minuto viene da uno a caso static const char *Stage_RandomMinuteStage(Stage *st) { const char *v[16]; int n = st->randomMinutes ? Stage_GetValidUnlockedStages(v) : 0; return n >= 2 ? v[RND_between(0, n - 1)] : st->stageType; } static void Stage_UpdateMinuteData(Stage *st) { cJSON *d = cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("stages"), Stage_RandomMinuteStage(st)), st->dataMinute); st->bosses = cJSON_GetObjectItem(d, "bosses"); st->arcanaHolder = str(d, "arcanaHolder"); st->treasure = cJSON_IsNull(cJSON_GetObjectItem(d, "treasure")) ? NULL : cJSON_GetObjectItem(d, "treasure"); st->arcanaTreasure = cJSON_IsNull(cJSON_GetObjectItem(d, "arcanaTreasure")) ? NULL : cJSON_GetObjectItem(d, "arcanaTreasure"); if (has(d, "enemies")) st->enemies = cJSON_GetObjectItem(d, "enemies"); Stage_updateEnemyPools(st); Stage_updateTimers(st); cJSON *ev; cJSON_ArrayForEach(ev, cJSON_GetObjectItem(d, "events")) TriggerEvent(ev); } static void Stage_SpawnYellowItems(void) { // stage senza mappa: anelli e Metaglio lontani, con la reliquia RELIC_YELLOW static const char *const W[4] = { "SILVER", "GOLD", "LEFT", "RIGHT" }, *const E[4] = { "MASK_SILVER", "MASK_GOLD", "MASK_LEFT", "MASK_RIGHT" }; static const float X[4] = { 0, 0, -0x3800, 0x3800 }, Y[4] = { -0x3800, 0x3800, 0, 0 }; if (!Collected("RELIC_YELLOW")) return; for (int i = 0; i < 4; i++) { Pickup *p = Core_MakeStagePickup(X[i], Y[i], "WEAPON", W[i]); if (p) p->spawnQuantity = 1, p->spawnAngle = 0x168, p->enemyType = E[i]; // spawnAngle 360 senza DegToRad (sic) } } static void Stage_InitMappedPools(Stage *st) { // poolsMapping[i].pool = pools.find || new (disattivato) + push cJSON *m; st->n_mappedPools = 0; cJSON_ArrayForEach(m, st->poolsMapping) { const char *type = str(m, "type"); EnemyPool *p = NULL; for (int i = 0; i < st->n_pools; i++) if (!strcmp(st->pools[i]->enemyType, type)) p = st->pools[i]; if (!p && st->n_pools < 256) p = st->pools[st->n_pools++] = EnemyPool_new(type), p->enabled = 0; if (st->n_mappedPools < 32) st->mappedPools[st->n_mappedPools++] = p; } } // distruttibili nei punti della mappa fuori dallo schermo (filtro comune di InRandomLocation, Cart, Window) static Vector2 *Stage_pickOutOfView(Stage *st, Vector2 *list, int n) { int idx[256], m = 0; float hw = 0.5f * game_width, hh = 0.5f * game_height; for (int i = 0; i < n && m < 256; i++) { float x = st->tilingTileset->current.x + list[i].x, y = st->tilingTileset->current.y + list[i].y; if (x < Core.Player->s.x - hw || x > Core.Player->s.x + hw || y < Core.Player->s.y - hh || y > Core.Player->s.y + hh) idx[m++] = i; } return m ? &list[idx[(int)floorf(frand() * m)]] : NULL; // RND.pick } static void Stage_SpawnDestructibleInRandomLocation(Stage *st) { if (0x64 * frand() > fminf(st->destructibleChance * Player_PLuck(Core.Player), st->destructibleChanceMax)) return; Vector2 *p = Stage_pickOutOfView(st, st->DestructibleLocations, st->n_DestructibleLocations); if (p) Core_MakeDestructibleAt(st->destructibleType, (Vector2){ st->tilingTileset->current.x + p->x, st->tilingTileset->current.y + p->y }); } static void Stage_SpawnDestructibleWallsCheck(Stage *st) { if (0x64 * frand() > fminf(st->destructibleChance * Player_PLuck(Core.Player), st->destructibleChanceMax)) return; Vector2 r = RandomOutside(st->rectOuter, st->rectInner); float x = Core.Player->s.x + r.x, y = Core.Player->s.y + r.y; if (!TilingTileset_isPointWithinCollisionLayer(st->tilingTileset, x, y)) Core_MakeDestructibleAt(st->destructibleType, (Vector2){ x, y }); } // SpawnDestructibleClosest (hasClosestDestructibleLogic): definita ma mai chiamata nell'originale static void Stage_SpawnCartInRandomLocation(Stage *st) { if (st->n_CartLocations <= 0 || 0x64 * frand() > 0x32 * Player_PLuck(Core.Player)) return; Vector2 *p = Stage_pickOutOfView(st, st->CartLocations, st->n_CartLocations); if (!p) return; Destructible *d = Core_MakeDestructibleAt("CART", (Vector2){ st->tilingTileset->current.x + p->x, st->tilingTileset->current.y + p->y }); if (d && st->tilingTileset->inverted && po_is("VisuallyInvertStages")) d->s.x -= 0x1c2, d->s.y += 0x22; } static void Stage_SpawnWindowInRandomLocation(Stage *st) { if (st->n_WindowLocations <= 0 || 0x64 * frand() > 0x32 * Player_PLuck(Core.Player)) return; Vector2 *p = Stage_pickOutOfView(st, st->WindowLocations, st->n_WindowLocations); if (!p) return; Destructible *d = Core_MakeDestructibleAt("WINDOW", (Vector2){ st->tilingTileset->current.x + p->x, st->tilingTileset->current.y + p->y }); if (d && st->tilingTileset->inverted && po_is("VisuallyInvertStages")) d->s.angle = 0xb4, d->s.x += 0xc0, d->s.y -= 0x16; } // pizze: entrando in un cerchio PIZZA della mappa parte un evento a caso di pizzaEvents (al piu' uno ogni pizzaDelay) static void Stage_WarningOut(void *ctx) { Stage *st = ctx; tweens_add((TweenConfig){ .props = { { &st->WarningSprite.scaleX, &st->WarningSprite.scaleY, 0 } }, .nprops = 1, .duration = 0xc8, .delay = 0xc8 }); } static void Stage_showWarning(Stage *st, Vector2 c) { Sound_PlaySound("Pizza", 0.9f, 1, 0x1f4 * frand(), 0x96, 2); tweens_add((TweenConfig){ .props = { { &st->WarningSprite.scaleX, &st->WarningSprite.scaleY, 1 } }, .nprops = 1, .duration = 0xc8, .onComplete = Stage_WarningOut, .ctx = st }); st->PizzaSprite.x = c.x + st->tilingTileset->current.x, st->PizzaSprite.y = c.y + st->tilingTileset->current.y; tweens_add((TweenConfig){ .props = { { &st->PizzaSprite.alpha, NULL, 1 }, { &st->PizzaSprite.scaleX, &st->PizzaSprite.scaleY, 1.25f } }, .nprops = 2, .duration = 0x1f4, .yoyo = 1 }); } static void Stage_playPizzaEvents(Stage *st, Vector2 c) { int n = cJSON_GetArraySize(st->pizzaEvents); if (!st->pizzaEvents || n <= 0 || st->pizzaDelay > 0 || Core.Enemies.n >= 0x1f4) return; st->pizzaDelay = fmaxf(0x1388, st->pizzaIntervalInMilliSeconds * Player_PLuck(Core.Player)); cJSON *ev = cJSON_GetArrayItem(st->pizzaEvents, (int)floorf(frand() * n)); // RND.pick if (ev && TriggerEvent(ev)) Stage_showWarning(st, c); } static void Stage_CheckPizzas(void *ctx) { Stage *st = ctx; if (st->n_PizzaLocations <= 0 || 0x64 * frand() > 0x64 / Player_PLuck(Core.Player)) return; float lx = Core.Player->s.x - st->tilingTileset->current.x, ly = Core.Player->s.y - st->tilingTileset->current.y; for (int i = 0; i < st->n_PizzaLocations; i++) { float dx = st->PizzaLocations[i].x - lx, dy = st->PizzaLocations[i].y - ly; if (fabsf(dx) <= 0x10 && fabsf(dy) <= 0x10 && dx * dx + dy * dy <= 0x10 * 0x10) { Stage_playPizzaEvents(st, st->PizzaLocations[i]); break; } // Circle(x, y, 16).contains } } static void Stage_ToggleShadows(Stage *st, int show) { for (int i = 0; i < st->tilingTileset->mapsAmount; i++) { LayerContainer *c = &st->tilingTileset->layerContainers[i]; TweenConfig cfg = { .nprops = 0, .duration = 0x64 }; if (c->ShadowLayer) cfg.props[cfg.nprops++] = (TweenProp){ &c->ShadowLayer->s.alpha, NULL, show ? 1 : 0 }; if (c->ShadowDecalsLayer) cfg.props[cfg.nprops++] = (TweenProp){ &c->ShadowDecalsLayer->s.alpha, NULL, show ? 1 : 0 }; if (cfg.nprops) tweens_add(cfg); } } static void Stage_CheckShadows(void *ctx) { Stage *st = ctx; if (st->n_NoShadowLocations <= 0) return; float lx = Core.Player->s.x - st->tilingTileset->current.x, ly = Core.Player->s.y - st->tilingTileset->current.y; int show = 1; for (int i = 0; i < st->n_NoShadowLocations; i++) if (geomRect_contains(st->NoShadowLocations[i], lx, ly)) { show = 0; break; } Stage_ToggleShadows(st, show); } // --- FOREST (0x148ea): il segreto di Neo ------------------------------------------------------------------------------ // Con la reliquia gialla, raccolti Pummarola e Skull O'Maniac della mappa, compare BOSS_NOOB lontano e una scia di torte porta da lui. static struct { ParticleManager *pfx; ParticleEmitter *em; // PfxEmitter_Pickups Sprite chicken; // la torta bianca che si gonfia sopra quella vera int hadEnoughChicken, ChickenTrailSpawned; EnemyPool *enemyPool; Enemy *boon; Timer chickenTimer; } Forest; static void Forest_emit(void *ctx) { Pickup *p = ctx; emitter_emitParticleAt(Forest.em, p->s.x, p->s.y, 0); } static void Forest_chickenStart(void *ctx) { Pickup *p = ctx; sprite_setScale(&p->s, 0), sprite_setScale(&Forest.chicken, 0); Forest.chicken.x = p->s.x, Forest.chicken.y = p->s.y, Forest.chicken.alpha = 1, Forest.chicken.depth = p->s.depth + 0x64; Forest_emit(p); } static void Forest_chickenOut(void *ctx) { tweens_add((TweenConfig){ .props = { { &Forest.chicken.scaleX, &Forest.chicken.scaleY, 0 }, { &Forest.chicken.alpha, NULL, 1 } }, .nprops = 2, .duration = 0x12c, .onStart = Forest_emit, .onComplete = Forest_emit, .ctx = ctx }); } static void Forest_SpawnFreeChicken(void *ctx) { (void)ctx; if (!Forest.boon) return; float dx = Core.Player->s.x - Forest.boon->s.x, dy = Core.Player->s.y - Forest.boon->s.y; if (dx * dx + dy * dy < 0x13880) { time_removeEvent(Forest.chickenTimer); return; } float a = atan2f(Forest.boon->s.y - Core.Player->s.y, Forest.boon->s.x - Core.Player->s.x); Pickup *p = Core_MakePickup(Core.Player->s.x + 0xb4 * cosf(a), Core.Player->s.y + 0xb4 * sinf(a), "ROAST"); if (!p) return; sprite_setFrame(&p->s, frame_get("items", "pie.png")); tweens_add((TweenConfig){ .props = { { &p->s.scaleX, &p->s.scaleY, 1 }, { &Forest.chicken.scaleX, &Forest.chicken.scaleY, 1 } }, .nprops = 2, .duration = 0x12c, .onStart = Forest_chickenStart, .onComplete = Forest_chickenOut, .ctx = p }); } static void Forest_OnDefeated(Enemy *e) { (void)e; if (Char_found("NEO", 1, 0)) Sound_PlaySound("ThingFound", 1, 0.5f, -0x3e8, 0, 0); } static void Forest_StartChickenTrail(void) { Forest.ChickenTrailSpawned = 1; Forest.boon = EnemyPool_SpawnAt(Forest.enemyPool, -0x6c00, -0x3780); if (Forest.boon) Forest.boon->onDefeat = Forest_OnDefeated; Forest.chickenTimer = time_addEvent(0x7d0, 0, 0x64, Forest_SpawnFreeChicken, NULL); } static int Forest_Siffregatoipummarola(void) { // a terra non ci sono piu' ne' Pummarola (REGEN) ne' Skull O'Maniac (CURSE) for (int i = 0; i < Core.PickupGroup.n; i++) { Pickup *p = Core.PickupGroup.items[i]->owner; if (!strcmp(p->itemType, "WEAPON") && p->weaponType && (!strcmp(p->weaponType, "REGEN") || !strcmp(p->weaponType, "CURSE"))) return 0; } return 1; } static void Forest_Create(void) { // costruttore + Create memset(&Forest, 0, sizeof(Forest)); Forest.pfx = particles_add(); Forest.em = particles_createEmitter(Forest.pfx, (EmitterConfig){ .frames = { frame_get("vfx", "PfxColor1.png"), frame_get("vfx", "PfxColor2.png") }, .nframes = 2, .angle = ERND(0, 0xb4), .speed = ERND(0x19, 0x32), .quantity = 0x1e, .lifespan = ERND(0x64, 0x190), .alpha = ERANGE(1, 0), .scale = ERANGE(2, 1), .gravityY = -0x3e8, .tint = 1, .on = 0 }); // tint 0 (nero): qui lo 0 vale "nessuna tinta", quindi 0x000001 sprite_init(&Forest.chicken, frame_get("items", "pie.png"), 0, 0), sprite_setTintFill(&Forest.chicken, 0xffffff), Forest.chicken.alpha = 0; children_add(&Forest.chicken); Forest.chickenTimer = (Timer){ -1, 0 }; if (!po_has("UnlockedCharacters", "NEO") && Collected("RELIC_YELLOW")) Forest.hadEnoughChicken = 1, Forest.enemyPool = EnemyPool_new("BOSS_NOOB"); } static void Forest_Update(float delta) { (void)delta; if (Forest.hadEnoughChicken && Forest_Siffregatoipummarola() && !Forest.ChickenTrailSpawned) Forest_StartChickenTrail(); } static const FancyBG FB_Forest = { Forest_Create, Forest_Update, NULL, NULL }; // --- LIBRARY (0x11270): il segreto di Avatar (pianoforte, Trickster, bare, Shard Infernas) ------------------------------ // Con la reliquia gialla, Greatest Jubilee sbloccato e la modalita' Inverse: vicino al pianoforte (11 mappe a est) esce il // Trickster XL; battuto, il pianoforte apre la PianoScene; la melodia giusta (BigSpoop) spiana la mappa, chiama i non morti // e mette nove bare: in quella giusta c'e' Avatar, e dopo 5 s ne esce lo Shard Infernas. static void Core_EraseEnemies(int vfx); static void SceneManager_EnterPianoScene(void); static struct { int triggerCheck, hasSpawnedTrickster, HasDefeatedTrickster, CanInteractWithPiano, pianoDone, hasSaved, saveDMG; Vector2 piano, coffin; EnemyPool *enemyPool; Timer PianoInteractionTimer, UndeadsTimer; Sprite sDarkness; Pickup *rightCoffin; char saveBGM[64], saveBGMMod[32]; } Lib; #define LIB_PIANO_OFFSET 0xb static int Library_script(const char *name, Vector2 *out) { // tilingTileset.savedScripts.find(name): gli oggetti di Scripts senza un caso proprio cJSON *o; cJSON_ArrayForEach(o, tilemap_getObjectLayerObjects(Core.Stage->tilingTileset->MainMap, "Scripts")) if (str(o, "name") && !strcmp(str(o, "name"), name)) { *out = (Vector2){ num(o, "x", 0), num(o, "y", 0) }; return 1; } return 0; } static void Library_Create(void) { memset(&Lib, 0, sizeof(Lib)); Lib.PianoInteractionTimer = Lib.UndeadsTimer = (Timer){ -1, 0 }; Lib.saveDMG = po_is("DamageNumbersEnabled"); if (!getenv("VS_PIANO")) { // quickDebug (sviluppo: VS_PIANO salta i requisiti) if (!po_has("CollectedItems", "RELIC_YELLOW")) return; if (!po_has("UnlockedWeapons", "JUBILEE")) return; if (!po_is("SelectedInverse")) return; } if (!Core.Stage->tilingTileset || !Library_script("Piano", &Lib.piano)) return; if (!Library_script("Coffin", &Lib.coffin)) return; Lib.triggerCheck = 1, Lib.CanInteractWithPiano = 0; Lib.piano.x += 0x800 * LIB_PIANO_OFFSET, Lib.coffin.x += 0x800 * LIB_PIANO_OFFSET; const char *dbg = getenv("VS_PIANO"); // sviluppo: 1 sotto il pianoforte, 2 Trickster gia' battuto e sul pianoforte, 3 poi sulla bara giusta if (dbg) Core.Player->s.x = Lib.piano.x - 0x40, Core.Player->s.y = Lib.piano.y + 0x10; // a sinistra del Trickster: la frusta lo prende if (dbg && atoi(dbg) >= 2) Lib.hasSpawnedTrickster = Lib.HasDefeatedTrickster = Lib.CanInteractWithPiano = 1, Core.Player->s.y = Lib.piano.y; if (dbg) TilingTileset_recenter(Core.Stage->tilingTileset); } static void Library_tricksterDefeated(Enemy *e) { (void)e; Lib.CanInteractWithPiano = 1, Lib.HasDefeatedTrickster = 1; if (getenv("VS_PIANO")) TraceLog(LOG_INFO, "VS: Trickster XL battuto, il pianoforte si apre"); } static void Library_RevealTrickster(void) { Lib.enemyPool = EnemyPool_new("BOSS_XLTRICKSTER"); Enemy *t = EnemyPool_SpawnAt(Lib.enemyPool, Lib.piano.x, Lib.piano.y + 0x10); if (t) t->onDefeat = Library_tricksterDefeated; } static void Library_canInteract(void *ctx) { (void)ctx; Lib.CanInteractWithPiano = 1; } static void Library_Update(float delta) { (void)delta; if (!Lib.triggerCheck) return; float dx = Core.Player->s.x - Lib.piano.x, dy = Core.Player->s.y - Lib.piano.y, d2 = dx * dx + dy * dy; if (!Lib.hasSpawnedTrickster && d2 < 0xea60) Lib.hasSpawnedTrickster = 1, Library_RevealTrickster(); if (Lib.HasDefeatedTrickster && !Lib.pianoDone && d2 < 0x12c && Lib.CanInteractWithPiano) { Lib.CanInteractWithPiano = 0; SceneManager_EnterPianoScene(); // BigPianoIn Lib.PianoInteractionTimer = time_addEvent(0x1388, 0, 0, Library_canInteract, NULL); } } static cJSON *Lib_enemies(const char *type) { // Stage.enemies = [type] (o [] con NULL): array propri, i dati dello stage restano intatti static cJSON *head, *eyes, *none; if (!none) head = cJSON_CreateStringArray((const char *[]){ "UNDEADHEAD" }, 1), eyes = cJSON_CreateStringArray((const char *[]){ "UNDEADEYES" }, 1), none = cJSON_CreateArray(); return !type ? none : !strcmp(type, "UNDEADHEAD") ? head : eyes; } static void Library_undeads(void *ctx) { // ogni 30 s (5 volte): 30 in piu', teste e occhi a turno (void)ctx; Stage *st = Core.Stage; st->minimum += 0x1e; st->enemies = arr_indexOf(st->enemies, "UNDEADHEAD") > -1 ? Lib_enemies("UNDEADEYES") : Lib_enemies("UNDEADHEAD"); Stage_updateEnemyPools(st); } static void Library_infernas(void *ctx) { (void)ctx; EnemyPool_SpawnAt(EnemyPool_new("BOSS_SHARD_INFERNAS"), Lib.rightCoffin->s.x, Lib.rightCoffin->s.y); po_sets("SelectedBGM", "BGM_Flame"), po_sets("SelectedBGMMod", "Normal"), po_setb("DamageNumbersEnabled", 1); Sound_SetupAndPlayBGM_Banger(0); } static void Library_OnRightCoffinOpened(void) { time_removeEvent(Lib.UndeadsTimer); Core_EraseEnemies(0); Sound_FadeMusic(0, 0xbb8); tweens_add((TweenConfig){ .props = { { &Lib.sDarkness.alpha, NULL, 0.5f } }, .nprops = 1, .duration = 0x1388 }); time_addEvent(0x1388, 0, 0, Library_infernas, NULL); Core.Stage->enemies = Lib_enemies(NULL), Stage_updateEnemyPools(Core.Stage); Core_EraseEnemies(0); } static void Library_MakeCoffins(void) { Pickup *all[9]; int n = 0; Lib.coffin.x -= 0x800, Lib.coffin.y -= 0x800; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) { Pickup *p = Core_MakeStagePickup(Lib.coffin.x + 0x800 * i, Lib.coffin.y + 0x800 * j, "COFFIN_EMPTY", NULL); if (p) Coffin_setChar(p, "VOID"), p->OnOpen = NULL, all[n++] = p; } if (!n) return; Lib.rightCoffin = all[(int)floorf(frand() * n)]; Coffin_setChar(Lib.rightCoffin, "AVATAR"); Lib.rightCoffin->OnOpen = Library_OnRightCoffinOpened; if (getenv("VS_PIANO") && atoi(getenv("VS_PIANO")) >= 3) Core.Player->s.x = Lib.rightCoffin->s.x, Core.Player->s.y = Lib.rightCoffin->s.y, TilingTileset_recenter(Core.Stage->tilingTileset); } static void Library_BigSpoop(void) { LootManager_SetPlainLootTable(); Lib.pianoDone = 1, SFXVolumeFactor = 0.35f, Lib.CanInteractWithPiano = 0; time_removeEvent(Lib.PianoInteractionTimer); Stage *st = Core.Stage; st->spawnType = "STANDARD"; // tilingTileset.pianificami() + spianami(): restano Floor e le righe 28-33 tilemap_removeTilesWithin(st->tilingTileset->MainMap, "Floor", 0, 0, 0x40, 0x1c); tilemap_removeTilesWithin(st->tilingTileset->MainMap, "Floor", 0, 0x22, 0x40, 0x40); st->n_DestructibleLocations = 0; sprite_init(&Lib.sDarkness, frame_get("vfx", "fog.png"), -0xa, -0xa); // displayWidth/Height = schermo + 20 sprite_setOrigin(&Lib.sDarkness, 0, 0), Lib.sDarkness.scrollFactor0 = 1, Lib.sDarkness.depth = 0xbb9, Lib.sDarkness.alpha = 1; Lib.sDarkness.scaleX = (game_width + 0x14) / 160.0f, Lib.sDarkness.scaleY = (game_height + 0x14) / 100.0f; children_add(&Lib.sDarkness); Sound_StopMusic(); if (LoopSfx.on) au_music_stop(&LoopSfx.m), LoopSfx.on = 0; // sound.stopAll Lib.saveDMG = po_is("DamageNumbersEnabled"), Lib.hasSaved = 1; snprintf(Lib.saveBGM, sizeof(Lib.saveBGM), "%s", po_str("SelectedBGM") ? po_str("SelectedBGM") : ""); snprintf(Lib.saveBGMMod, sizeof(Lib.saveBGMMod), "%s", po_str("SelectedBGMMod") ? po_str("SelectedBGMMod") : ""); po_sets("SelectedBGM", "BGM_Spoopy"), po_sets("SelectedBGMMod", "Normal"), po_setb("DamageNumbersEnabled", 0); Sound_SetupAndPlayBGM_Banger(1); time_removeEvent(Core.tickerEvent); Core_EraseEnemies(0); st->enemies = Lib_enemies("UNDEADHEAD"), st->minimum = 0x1e; Stage_updateEnemyPools(st); st->stopCheckingMinutes = 1; Lib.UndeadsTimer = time_addEvent(0x7530, 0, 5, Library_undeads, NULL); Library_MakeCoffins(); } static void Library_OnDestroy(void) { // a fine partita: musica e numeri del danno di prima if (Lib.hasSaved && Lib.saveBGM[0]) po_sets("SelectedBGM", Lib.saveBGM), po_setb("DamageNumbersEnabled", Lib.saveDMG); if (Lib.hasSaved && Lib.saveBGMMod[0]) po_sets("SelectedBGMMod", Lib.saveBGMMod); Lib.hasSaved = 0; } static const FancyBG FB_Library = { Library_Create, Library_Update, NULL, NULL }; // --- WAREHOUSE (0x7292): il segreto di Graziella ------------------------------------------------------------------------------- // Con la reliquia gialla c'e' un formaggio in (-512, -3552); raccolto, evoca 7 lupi mannari attorno; battuti tutti, Graziella si sblocca. static struct { int toDefeat, bossesDefeated, awarded; EnemyPool *enemyPool; } Plant; static void Plant_OnDefeated(Enemy *e) { (void)e; if (++Plant.bossesDefeated < Plant.toDefeat || Plant.awarded) return; Plant.awarded = 1; if (Char_found("GRAZIELLA", 1, 0)) Sound_PlaySound("ThingFound", 1, 0.5f, -0x3e8, 0, 0); } static void Plant_SpawnWerewolves(float x, float y) { float step = 2 * PI / Plant.toDefeat; for (int i = 0; i < Plant.toDefeat; i++) { Enemy *e = EnemyPool_SpawnAt(Plant.enemyPool, x + cosf(step * (i + 0.5f)) * game_width * 0.5f, y + sinf(step * (i + 0.5f)) * game_height * 0.5f); if (e) e->onDefeat = Plant_OnDefeated, e->isTeleportOnCull = 1; } } static void Plant_OnPickupCallback(Pickup *p) { Plant_SpawnWerewolves(p->s.x, p->s.y); p->OnPickupCallback = NULL; } static void Plant_Create(void) { memset(&Plant, 0, sizeof(Plant)); Plant.toDefeat = 7; // CartWeapon = new W_Cart(CART).Init(): creata ma mai usata (il carrello dei distruttibili e' un'arma nascosta del Core) if (po_has("UnlockedCharacters", "GRAZIELLA") || !Collected("RELIC_YELLOW")) return; Plant.enemyPool = EnemyPool_new("BOSS_WEREWOLF2"); Pickup *c = Core_MakePickup(-0x200, -0xde0, "ROAST"); if (c) sprite_setFrame(&c->s, frame_get("items", "cheese.png")), c->OnPickupCallback = Plant_OnPickupCallback; } static const FancyBG FB_Plant = { Plant_Create, NULL, NULL, NULL }; // --- TOWER / TOWERBRIDGE (0x2f6d): cielo in parallasse a 12 strati, rune che salgono, il lampo di BGM_Tower; Leda in fondo alla torre --- // Scendendo oltre y 0x6000 cala il buio; oltre 0x12000 le rune diventano "IAMALIVEHERE", la musica tace e soffia il vento (fino a Leda). typedef struct RuneStrip { // 0x30e (5 rune animate) / 0x898e (12 lettere rosse): seguono una spline dal basso in alto dello schermo Vector2 pts[5]; Sprite followers[12]; float z[12]; int n, letters; float alpha, heightAlpha; } RuneStrip; static const char RuneLetters[] = "IAMALIVEHERE"; static void RuneLetter_draw(Sprite *s) { // scene.add.text(lettera, { color: 'red' }): 16px, ADD if (!s->visible || s->alpha <= 0) return; char t[2] = { RuneLetters[(intptr_t)s->owner], 0 }; BeginBlendMode(BLEND_ADDITIVE); DrawTextPro(GetFontDefault(), t, (Vector2){ s->x, s->y }, (Vector2){ 0, 0 }, s->angle, 16, 1, (Color){ 255, 0, 0, (unsigned char)(255 * fminf(1, s->alpha)) }); EndBlendMode(); } static RuneStrip *RuneStrip_new(int letters, float x, float dur, float dir, float a, float b) { static Animation idle; if (!idle.n) idle.n = anims_generateFrameNames("vfx", "_runes_0", 2, 6, 0, idle.frames, ANIM_MAX_FRAMES), idle.frameRate = 8, idle.msPerFrame = 1000.0f / 8, idle.repeat = -1; RuneStrip *r = calloc(1, sizeof(RuneStrip)); float h = game_height / 3.5f; Vector2 P[5] = { { x, 4 * h }, { x - 0x19 * dir, 3 * h }, { x + 0x32 * dir, 2 * h }, { x - 0x19 * dir, h }, { x, 0 } }; memcpy(r->pts, P, sizeof(P)); r->letters = letters, r->n = letters ? 0xc : 5, r->alpha = 0.5f; for (int i = 0; i < r->n; i++) { Sprite *f = &r->followers[i]; sprite_init(f, letters ? NULL : frame_get("vfx", "_runes_02.png"), 0, -0x20); if (letters) f->draw = RuneLetter_draw, f->owner = (void *)(intptr_t)i, f->x = 0; else anims_play(f, &idle, i), sprite_setScale(f, 0.5f); f->scrollFactor0 = 1, f->angle = 0xf, f->blendAdd = 1, f->depth = -0x1869f, f->alpha = a; children_add(f); tweens_add((TweenConfig){ .props = { { &r->z[i], NULL, 1 }, { &f->angle, NULL, -0xf } }, .nprops = 2, .duration = dur, .repeat = -1, .delay = i * (0.04f * dur) }); } tweens_add((TweenConfig){ .props = { { &r->alpha, NULL, b } }, .nprops = 1, .ease = Ease_SineOut, .duration = 0.25f * dur, .repeat = -1, .yoyo = 1 }); return r; } static void RuneStrip_Update(RuneStrip *r, float ratio) { r->heightAlpha = -ratio; for (int i = 0; i < r->n; i++) { Vector2 p = Spline_getPoint(r->pts, 5, r->z[i]); r->followers[i].x = p.x, r->followers[i].y = p.y; r->followers[i].alpha = fmaxf(0, fminf(1, r->alpha * r->heightAlpha)); // Alpha.setAlpha: tra 0 e 1 } } static void RuneStrip_setVisible(RuneStrip *r, int v) { for (int i = 0; i < r->n; i++) r->followers[i].visible = v; } static struct { int hasSpawnedGuards, passed, stopp; float TowerTop, bot, bott, W, H; Sprite sBackground, sStars2, sStars1, sPeaks, sMount2, sMist3, sMount1, sFlash, sMist2, sHills, sMist1, sForest, sDarkness, sFog; RuneStrip *runeStrips[8], *runeStrips2[8]; int n_runeStrips2; ParticleManager *particles; ParticleEmitter *pfxEmitter; Timer firstEvent, recurringEvent; } Tower; static void Tower_sprite(Sprite *s, const char *atlas, const char *frame, float x, float y, float ox, float oy) { sprite_init(s, frame_get(atlas, frame), x, y); sprite_setOrigin(s, ox, oy), s->scrollFactor0 = 1; } static void Tower_flashOff(void *ctx) { (void)ctx; Tower.sFlash.alpha = 0; } static void Tower_flashBurst(void *ctx) { (void)ctx; emitter_emitParticleAt(Tower.pfxEmitter, Tower.pfxEmitter->x, Tower.pfxEmitter->y, 0x78); } static void Tower_flashBurstEnd(void *ctx) { (void)ctx; emitter_stop(Tower.pfxEmitter); } static void Tower_PlayFlash(void) { if (BGM.idx != Sound_index("BGM_Tower")) return; // FlashingVFXEnabled (di default si'), Sound.currentBGMType sprite_setScale(&Tower.sFlash, 0), Tower.sFlash.alpha = 0; float *sx = &Tower.sFlash.scaleX, *sy = &Tower.sFlash.scaleY, *al = &Tower.sFlash.alpha; for (int i = 0; i < 4; i++) tweens_add((TweenConfig){ .props = { { sx, sy, (0x18 + 8 * i) / 128.0f }, { al, NULL, 1 } }, .nprops = 2, .duration = 0x190, .yoyo = 1, .ease = Ease_SineInOut, .delay = 0x320 * i, .onComplete = Tower_flashOff }); for (int i = 0; i < 8; i++) tweens_add((TweenConfig){ .props = { { sx, sy, 0.25f }, { al, NULL, 1 } }, .nprops = 2, .delay = 0xc80 + 0x190 * i, .duration = 0xc8, .yoyo = 1, .ease = Ease_SineInOut }); tweens_add((TweenConfig){ .props = { { sx, sy, 3 * Tower.W / 128 }, { al, NULL, 1 } }, .nprops = 2, .delay = 0x1900, .duration = 0x190, .yoyo = 1, .ease = Ease_SineInOut, .onStart = Tower_flashBurst, .onComplete = Tower_flashBurstEnd }); Tower.particles->wellPower = 0; // well.power = 0, poi a 2 (x gravity 150) tweens_add((TweenConfig){ .props = { { &Tower.particles->wellPower, NULL, 2 * 0x96 } }, .nprops = 1, .delay = 0x1900, .duration = 0x320 }); } static void Tower_recurring(void *ctx) { (void)ctx; Tower_PlayFlash(); } static void Tower_first(void *ctx) { // setTimeout / setInterval: qui sull'orologio della scena (si fermano con la pausa) (void)ctx; Tower_PlayFlash(); Tower.recurringEvent = time_addEvent(0x18ab8, 1, 0, Tower_recurring, NULL); } static void Tower_StopRune2(Enemy *e) { // Leda battuta: torna la luce, Veranda (segreto BringMeBackThere) (void)e; Tower.stopp = 1; Sound_StopSound("Wind"); for (int i = 0; i < Tower.n_runeStrips2; i++) RuneStrip_setVisible(Tower.runeStrips2[i], 0); Tower.n_runeStrips2 = 0; Tower.sFog.visible = Tower.sDarkness.visible = 0; // (sic) nascosti subito, il tween dell'alpha non si vede tweens_add((TweenConfig){ .props = { { &Tower.sDarkness.alpha, NULL, 0 }, { &Tower.sFog.alpha, NULL, 0 } }, .nprops = 2, .duration = 0x2710 }); cJSON *v = tbl0("characters", "VERANDA"); obj_set(v, "hidden", cJSON_CreateFalse()), obj_set(v, "isBought", cJSON_CreateFalse()); if (!po_has("UnlockedCharacters", "VERANDA")) Sound_PlaySound("ThingFound", 1, 0.5f, -0x3e8, 0, 0), AchievementManager_UnlockSecret("BringMeBackThere"); if (Char_found("VERANDA", 0, 1)) Sound_PlaySound("ThingFound", 1, 0.5f, -0x3e8, 0, 0); // (sic) il segreto l'ha gia' sbloccato } static void Tower_stopMusic(void *ctx) { (void)ctx; Sound_StopMusic(); } // I 13 strati grandi come lo schermo pesano tutti sulla GPU: le ultime tessere in basso non facevano in tempo (lampi neri anche a 60 fps). // Si compongono in una vista a un quarto della risoluzione, un frame si' e uno no, e la scena disegna solo quella. void scene_render_one(Sprite *s, Shader fill); static RenderTexture2D TowerBake; static Sprite TowerBakeS, *TowerLayers[13]; static int TowerBake_on; static void TowerBake_draw(Sprite *s) { (void)s; DrawTexturePro(TowerBake.texture, (Rectangle){ 0, 0, TowerBake.texture.width, -TowerBake.texture.height }, (Rectangle){ 0, 0, game_width, game_height }, (Vector2){ 0, 0 }, 0, WHITE); } static void TowerBake_render(void) { static unsigned n; if (!TowerBake_on || n++ % 2) return; int w = game_width / 4, h = game_height / 4; if (TowerBake.id && TowerBake.texture.width != w) UnloadRenderTexture(TowerBake), TowerBake.id = 0; if (!TowerBake.id) TowerBake = LoadRenderTexture(w, h), SetTextureFilter(TowerBake.texture, TEXTURE_FILTER_BILINEAR); BeginTextureMode(TowerBake); ClearBackground(BLACK); rlPushMatrix(); rlScalef(0.25f, 0.25f, 1); for (int i = 0; i < 13; i++) scene_render_one(TowerLayers[i], (Shader){ 0 }); rlPopMatrix(); EndTextureMode(); } static void Tower_Create(void) { memset(&Tower, 0, sizeof(Tower)); Tower.TowerTop = -0x3000, Tower.bot = 0x6000, Tower.bott = 0xc000; float W = Tower.W = game_width, H = Tower.H = game_height; Tower_sprite(&Tower.sBackground, "background4", "06_background.png", 0, H, 0, 1); Tower_sprite(&Tower.sStars2, "background4", "07_stars.png", 0.5f * W, 0x32, 0.5f, 0.5f), Tower.sStars2.blendAdd = 1; Tower_sprite(&Tower.sStars1, "background4", "07_stars.png", 0.5f * W, 0x32, 0.5f, 0.5f), Tower.sStars1.blendAdd = 1, Tower.sStars1.angle = 0xb4; Tower_sprite(&Tower.sPeaks, "background4", "05_Peaks.png", 0, H, 0, 1); Tower_sprite(&Tower.sMount2, "background4", "04_Mountains.png", 0, H, 0, 1); Tower_sprite(&Tower.sMist3, "background4", "09_mist.png", 0, 0.5f * H, 0.5f, 0.5f), Tower.sMist3.alpha = 0.05f, Tower.sMist3.blendAdd = 1; Tower_sprite(&Tower.sMount1, "background4", "03_Mountains.png", 0, H, 0, 1); Tower_sprite(&Tower.sFlash, "vfx", "blur128.png", 0.5f * W, 0x32, 0.5f, 0.5f), Tower.sFlash.alpha = 0, Tower.sFlash.blendAdd = 1; Tower_sprite(&Tower.sMist2, "background4", "09_mist.png", W, H, 0.5f, 0.5f), Tower.sMist2.alpha = 0.05f, Tower.sMist2.blendAdd = 1; Tower_sprite(&Tower.sHills, "background4", "02_Hills.png", 0, H, 0, 1); Tower_sprite(&Tower.sMist1, "background4", "09_mist.png", 0, H, 0.5f, 0.5f), Tower.sMist1.alpha = 0.05f, Tower.sMist1.blendAdd = 1; Tower_sprite(&Tower.sForest, "background4", "01_Forest.png", 0, H, 0, 1); Tower_sprite(&Tower.sDarkness, "vfx", "blackDot.png", 0, 0, 0, 0), Tower.sDarkness.scaleX = W, Tower.sDarkness.scaleY = H, Tower.sDarkness.alpha = 0; Tower_sprite(&Tower.sFog, "vfx", "fog.png", 0, 0, 0, 0), Tower.sFog.scaleX = W / 0xa0, Tower.sFog.scaleY = H / 0x64, Tower.sFog.alpha = 0, Tower.sFog.depth = 0xbb9; children_add(&Tower.sFog); static const float RS[8][5] = { { 0x32, 0x2710, 1, 0.5f, 1 }, { 0x64, 0x1f40, -1, 0.5f, 0.7f }, { 0x96, 0x2ee0, 1, 0, 0.5f }, { 0xc8, 0x2710, -1, 0.5f, 1 }, { 0x1ea, 0x2710, -1, 0.5f, 0.5f }, { 0x230, 0x2710, 1, 0.5f, 1 }, { 0x258, 0x2ee0, 1, 0, 0.7f }, { 0x28a, 0x1f40, -1, 0.5f, 0.7f } }; for (int i = 0; i < 8; i++) Tower.runeStrips[i] = RuneStrip_new(0, RS[i][0], RS[i][1], RS[i][2], RS[i][3], RS[i][4]); // allSprites: un Container a depth -100000, i figli in quest'ordine (il buio per ultimo), tutti alla scala W / 540 (sic: anche stelle e nebbie) Sprite *all[13] = { &Tower.sBackground, &Tower.sStars2, &Tower.sStars1, &Tower.sPeaks, &Tower.sMount2, &Tower.sMist3, &Tower.sMount1, &Tower.sMist2, &Tower.sFlash, &Tower.sHills, &Tower.sMist1, &Tower.sForest, &Tower.sDarkness }; for (int i = 0; i < 13; i++) { if (i < 12) sprite_setScale(all[i], W / 0x21c); all[i]->depth = -0x186a0; TowerLayers[i] = all[i]; } sprite_init(&TowerBakeS, NULL, 0, 0); TowerBakeS.draw = TowerBake_draw, TowerBakeS.scrollFactor0 = 1, TowerBakeS.depth = -0x186a0; children_add(&TowerBakeS); TowerBake_on = 1; if (po_is("SelectedInverse")) { // sfondo capovolto (anche senza VisuallyInvertStages) for (int i = 0; i < 12; i++) { all[i]->flipY = 1; if (all[i]->originY == 1) sprite_setOrigin(all[i], 0, 0); } Tower.sBackground.y = 0, Tower.sStars2.y = H - 0x32, Tower.sStars1.y = H - 0x32, Tower.sFlash.y = H - 0x32; } tweens_add((TweenConfig){ .props = { { &Tower.sStars2.angle, NULL, 0x168 } }, .nprops = 1, .duration = 0x2710, .repeat = -1 }); tweens_add((TweenConfig){ .props = { { &Tower.sStars1.angle, NULL, 0x21c } }, .nprops = 1, .duration = 0x2710, .repeat = -1 }); tweens_add((TweenConfig){ .props = { { &Tower.sStars1.alpha, NULL, 0.5f } }, .nprops = 1, .duration = 0x1388, .repeat = -1, .yoyo = 1, .ease = Ease_SineInOut }); tweens_add((TweenConfig){ .props = { { &Tower.sMist1.alpha, NULL, 0.1f }, { &Tower.sMist1.scaleX, &Tower.sMist1.scaleY, 8 }, { &Tower.sMist1.angle, NULL, 0x168 } }, .nprops = 3, .duration = 0x7530, .repeat = -1, .yoyo = 1, .ease = Ease_SineInOut }); tweens_add((TweenConfig){ .props = { { &Tower.sMist2.alpha, NULL, 0.1f }, { &Tower.sMist2.scaleX, &Tower.sMist2.scaleY, 8 }, { &Tower.sMist2.angle, NULL, -0x168 } }, .nprops = 3, .duration = 0xafc8, .repeat = -1, .yoyo = 1, .ease = Ease_SineInOut }); TweenProp m3[4] = { { &Tower.sMist3.alpha, NULL, 0.1f }, { &Tower.sMist3.y, NULL, W }, { &Tower.sMist3.scaleX, &Tower.sMist3.scaleY, 8 }, { &Tower.sMist3.angle, NULL, 0x168 } }; static TweenProp m3s[4]; memcpy(m3s, m3, sizeof(m3)); tweens_add((TweenConfig){ .many = m3s, .nmany = 4, .duration = 0xea60, .repeat = -1, .yoyo = 1, .ease = Ease_SineInOut }); if (!strcmp(Core.Stage->stageType, "TOWER")) { Enemy *leda = EnemyPool_SpawnAt(EnemyPool_new("BOSS_XLLEDA"), 0x384, 0x14400); if (leda) leda->onDefeat = Tower_StopRune2; } else EnemyPool_SpawnAt(EnemyPool_new("BRIDGE_BOSS"), 0xa000, 0x400); Tower.particles = particles_add(); Tower.particles->s.depth = -0x1869e, Tower.particles->scrollFactor0 = 1; Tower.pfxEmitter = particles_createEmitter(Tower.particles, (EmitterConfig){ .frames = { frame_get("vfx", "_runes_02.png"), frame_get("vfx", "_runes_03.png"), frame_get("vfx", "_runes_04.png"), frame_get("vfx", "_runes_05.png"), frame_get("vfx", "_runes_06.png") }, .nframes = 5, .lifespan = EOP(0xbb8), .rotate = ERND(0, 0x168), .angle = { 0, 0x168, 1 }, .angleSteps = 0x20, .speed = ERND(0x64, 0x12c), .quantity = 0x40, .scale = ERANGE(1, 0), .alpha = ERANGE(0, 1), .frequency = 0x40, .tint = 0xaaffff, .blendAdd = 1, .on = 0 }); Tower.pfxEmitter->x = Tower.sFlash.x, Tower.pfxEmitter->y = Tower.sFlash.y; Tower.particles->hasWell = 1; // createGravityWell({ x: sFlash.x, y: sFlash.y - 200, power: 1, epsilon: 25, gravity: 150 }) Tower.particles->wellX = Tower.sFlash.x, Tower.particles->wellY = Tower.sFlash.y - 0xc8; Tower.particles->wellPower = 1 * 0x96, Tower.particles->wellEpsilon = 0x19 * 0x19; Tower.firstEvent = time_addEvent(0x140b4, 0, 0, Tower_first, NULL); // InitFlashTimers (costruttore) } static void Tower_FixY(Sprite *s, float a, float b, float r) { if (po_is("SelectedInverse")) { s->y = 0; return; } s->y = Tower.H + fmaxf(a, b * r); if (s->y > Tower.H + b) s->y = Tower.H + b; } static float dispH(const Sprite *s) { return s->height * s->scaleY; } static void Tower_Update(float delta) { (void)delta; float r = Core.Player->s.y / Tower.TowerTop, H = Tower.H; for (int i = 0; i < 8; i++) RuneStrip_Update(Tower.runeStrips[i], r); Tower.sPeaks.y = H + 0.5f * dispH(&Tower.sPeaks) * r; Tower.sMount2.y = H + 0.5f * dispH(&Tower.sMount2) * r; Tower.sMount1.y = H + 0.5f * dispH(&Tower.sMount1) * r; Tower_FixY(&Tower.sForest, 0, 0.4f * dispH(&Tower.sForest), r); Tower_FixY(&Tower.sHills, 0, 0.5f * dispH(&Tower.sHills), r); Tower_FixY(&Tower.sMount1, -0x35, 0.5f * dispH(&Tower.sMount1), r); Tower_FixY(&Tower.sMount2, -0x99, 0.5f * dispH(&Tower.sMount2), r); Tower_FixY(&Tower.sPeaks, -0xea, 0.5f * dispH(&Tower.sMount2), r); // l'altezza delle montagne (sic) if (Core.Player->s.y > Tower.bot) { float k = (Core.Player->s.y - Tower.bot) / Tower.bott; if (!Tower.stopp) Tower.sDarkness.alpha = Tower.sFog.alpha = fminf(1, k); if (k > 1) { if (!Tower.passed) { static const float RS[8][5] = { { 0x64, 0x2710, 1, 0.5f, 1 }, { 0x96, 0x1f40, -1, 0.5f, 0.7f }, { 0xc8, 0x2ee0, 1, 0, 0.5f }, { 0xfa, 0x2710, -1, 0.5f, 1 }, { 0x1ea, 0x2710, -1, 0.5f, 0.5f }, { 0x230, 0x2710, 1, 0.5f, 1 }, { 0x258, 0x2ee0, 1, 0, 0.7f }, { 0x28a, 0x1f40, -1, 0.5f, 0.7f } }; for (int i = 0; i < 8; i++) Tower.runeStrips2[i] = RuneStrip_new(1, RS[i][0], RS[i][1], RS[i][2], RS[i][3], RS[i][4]); Tower.n_runeStrips2 = 8; Sound_FadeMusic(0, 0x1f4); // saveBGM: mai riletto time_addEvent(0x1f4, 0, 0, Tower_stopMusic, NULL); Sound_PlayLoop("Wind", 1.8f); } Tower.passed = 1; for (int i = 0; i < 8; i++) RuneStrip_setVisible(Tower.runeStrips[i], 0); for (int i = 0; i < Tower.n_runeStrips2; i++) RuneStrip_setVisible(Tower.runeStrips2[i], 1), RuneStrip_Update(Tower.runeStrips2[i], r); } else { for (int i = 0; i < 8; i++) RuneStrip_setVisible(Tower.runeStrips[i], 1); for (int i = 0; i < Tower.n_runeStrips2; i++) RuneStrip_setVisible(Tower.runeStrips2[i], 0); } } if (Core.Player->s.y < Tower.TowerTop) { // in cima: Randomazzo (se non e' gia' tuo) comincia a scappare a destra e sinistra if (Collected("RELIC_RANDOMAZZO") || Tower.hasSpawnedGuards) return; Tower.hasSpawnedGuards = 1; for (int i = 0; i < Core.PickupGroup.n; i++) { Pickup *p = Core.PickupGroup.items[i]->owner; if (strcmp(p->itemType, "RELIC_RANDOMAZZO")) continue; float x0 = p->s.x; p->s.x = x0 - 0.25f * Tower.W; // onStart tweens_add((TweenConfig){ .props = { { &p->s.x, NULL, x0 + 0.25f * Tower.W } }, .nprops = 1, .ease = Ease_SineInOut, .duration = 0x2710, .repeat = -1, .yoyo = 1 }); break; } } } static const FancyBG FB_Tower = { Tower_Create, Tower_Update, NULL, NULL }; // --- Snap_Eggs / RemovePowers (Cappella e Machine): la mano schiocca, le uova d'oro volano in basso a destra, le reliquie escono dal // centro, girano e si allungano fino a sparire. Disegno a schermo dentro lo sprite di chi le usa, sul suo orologio. static struct { const char *powers[8]; int nPowers, nEggs; float powersAt, eggsAt; struct { float x0, y0, x1, y1, ang, dur, delay; } egg[0x1f4]; } SnapFX; static void SnapFX_reset(void) { memset(&SnapFX, 0, sizeof(SnapFX)), SnapFX.eggsAt = -1; } static float lerp01(float t, float start, float dur); static float ease_sine_inout(float k); static void SnapFX_eggs(float t) { // nEggs uova dal centro (+-8) verso (W - 48 - 48 r, H - 32), Circ.easeIn, 10 ms l'una dall'altra float W = game_width, H = game_height; SnapFX.eggsAt = t; for (int i = 0; i < SnapFX.nEggs; i++) SnapFX.egg[i].x0 = 0.5f * W + 0x10 * (frand() - 0.5f), SnapFX.egg[i].y0 = 0.5f * H + 0x10 * (frand() - 0.5f), SnapFX.egg[i].x1 = W - 0x30 - 0x30 * frand(), SnapFX.egg[i].y1 = H - 0x20, SnapFX.egg[i].ang = 0xb4 + 0xb4 * frand(), SnapFX.egg[i].dur = 0x12c + 0x12c * frand(), SnapFX.egg[i].delay = 0xa * i; } static void SnapFX_draw(float t) { float W = game_width, H = game_height; for (int i = 0; i < SnapFX.nPowers; i++) { // RemovePowers float d0 = SnapFX.powersAt + 0x320 + 0x64 * i, e = ease_sine_inout(lerp01(t, d0, 0x1f4)); if (t < d0) continue; float a = 2 * PI / SnapFX.nPowers, x = 0.5f * W + 0x3c * cosf(0.5f + a * i) * e, y = 0.5f * H + 0x3c * sinf(0.5f + a * i) * e; float d1 = d0 + 0x1f4 + 0x3e8 + 0x64 * i, k2 = ease_sine_inout(lerp01(t, d1, 0x1f4)); if (k2 >= 1) continue; const Frame *f = frame_get("items", SnapFX.powers[i]); if (!f) continue; Sprite p; sprite_init(&p, f, x, y); sprite_setOrigin(&p, 0.5f, 1), p.scaleX = 1 - k2, p.scaleY = 1 + 9 * k2, p.scrollFactor0 = 1; scene_render_one(&p, (Shader){ 0 }); } const Frame *g = SnapFX.eggsAt >= 0 ? frame_get("items", "goldenegg.png") : NULL; for (int i = 0; i < SnapFX.nEggs && g; i++) { float lt = t - SnapFX.eggsAt - SnapFX.egg[i].delay; if (lt < 0 || lt > SnapFX.egg[i].dur) continue; float k = lt / SnapFX.egg[i].dur, e = 1 - sqrtf(1 - k * k); // Circ.easeIn Sprite p; sprite_init(&p, g, SnapFX.egg[i].x0 + (SnapFX.egg[i].x1 - SnapFX.egg[i].x0) * e, SnapFX.egg[i].y0 + (SnapFX.egg[i].y1 - SnapFX.egg[i].y0) * e); p.angle = SnapFX.egg[i].ang * e, p.scrollFactor0 = 1; scene_render_one(&p, (Shader){ 0 }); } } // --- CHAPEL (0x17055): Cappella Magna. Cielo e nuvole che scorrono col vento, luci delle vetrate a terra e dal cielo --------------------- // Con la reliquia gialla (e senza aver battuto il boss finale) parte il segreto dei Mietitori e del boss finale: S3b. typedef struct TileSprite { Sprite s; Texture2D tex; float tilePositionX, tilePositionY, w, h, tileScaleX, tileScaleY; } TileSprite; // tileScale 0 = 1 static Texture2D frame_texture(const char *atlas, const char *frame) { // TileSprite su un fotogramma d'atlante: ritagliato una volta in una texture che si ripete static Texture2D cache[32]; static char names[32][64]; char key[64]; snprintf(key, sizeof(key), "%s/%s", atlas, frame); for (int i = 0; i < 32; i++) { if (!strcmp(names[i], key)) return cache[i]; if (names[i][0]) continue; const Frame *f = frame_get(atlas, frame); if (!f) return (Texture2D){ 0 }; Image a = LoadImage(vs_path(TextFormat("img/%s.png", atlas))); Image c = ImageFromImage(a, (Rectangle){ f->x, f->y, f->w, f->h }); cache[i] = LoadTextureFromImage(c); SetTextureWrap(cache[i], TEXTURE_WRAP_REPEAT); UnloadImage(c), UnloadImage(a); snprintf(names[i], sizeof(names[i]), "%s", key); return cache[i]; } return (Texture2D){ 0 }; } static void TileSprite_draw(Sprite *s) { TileSprite *t = (TileSprite *)s; if (!s->visible || s->alpha <= 0 || !t->tex.id) return; float dw = t->w * s->scaleX, dh = t->h * s->scaleY; EndShaderMode(); // texture ripetuta: u qualsiasi, non deve leggersi come riempimento (scene_render rimette il suo shader) if (s->blendAdd) BeginBlendMode(BLEND_ADDITIVE); float tsx = t->tileScaleX ? t->tileScaleX : 1, tsy = t->tileScaleY ? t->tileScaleY : 1; // tileScale: la texture ingrandita, tilePosition in pixel della texture DrawTexturePro(t->tex, (Rectangle){ t->tilePositionX, t->tilePositionY, t->w / tsx, (s->flipY ? -t->h : t->h) / tsy }, (Rectangle){ s->x - dw * s->originX, s->y - dh * s->originY, dw, dh }, (Vector2){ 0, 0 }, 0, hexc(s->tint, s->alpha)); if (s->blendAdd) EndBlendMode(); } static void TileSprite_add(TileSprite *t, const char *frame, double depth, float alpha) { // scene.add.tileSprite(W/2, H/2, W, H, 'backgroundX', frame).setScrollFactor(0) sprite_init(&t->s, NULL, 0.5f * game_width, 0.5f * game_height); t->s.draw = TileSprite_draw, t->s.scrollFactor0 = 1, t->s.depth = depth, t->s.alpha = alpha, t->s.tint = 0xffffff; t->tex = frame_texture("backgroundX", frame), t->w = game_width, t->h = game_height; children_add(&t->s); } static void Chapel_SecretCreate(void), Chapel_SecretUpdate(float delta), Chapel_CheckMinute(int m), Chapel_OnDestroy(void); static struct { int alias, hasTerraceBeenOpened; Pickup *coffin, *cosmoPavone; // SetupCoffinTrigger / SetupCosmoTrigger: vicino a loro si apre la terrazza float wind; TileSprite skyBlue, cloudsWhite, cloudsBlue, cloudsAddBlue, skyRed, cloudsRed, cloudsAddRed, floorLights, skyLights; Sprite snap, whiteFader, shootingRay, shootingRing; Animation snapAnim; } Chapel; static void Chapel_Create(void) { // costruttore + Create memset(&Chapel, 0, sizeof(Chapel)); Chapel.wind = 1; float W = game_width, H = game_height; sprite_init(&Chapel.snap, frame_get("backgroundX", "snap016.png"), W + 0x60, H + 0x10); // lo schiocco (S3b): a riposo fuori schermo sprite_setOrigin(&Chapel.snap, 1, 1), Chapel.snap.flipX = 1, Chapel.snap.scrollFactor0 = 1, sprite_setScale(&Chapel.snap, 1.5f), Chapel.snap.depth = 0x2710; children_add(&Chapel.snap); Chapel.snapAnim.n = anims_generateFrameNames("backgroundX", "snap", 0x10, 0x2a, 3, Chapel.snapAnim.frames, ANIM_MAX_FRAMES); Chapel.snapAnim.frameRate = 0x1e, Chapel.snapAnim.msPerFrame = 1000.0f / 0x1e; Weapon *ww = Core.Stage->WindowWeapon = Weapon_new("WINDOW"); // le vetrate rotte vicino al giocatore sparano con quest'arma (Prop_Window) if (ww) Weapon_Init(ww), ww->level = 1; TileSprite_add(&Chapel.skyBlue, "SkyB.png", -0x2710, 1); TileSprite_add(&Chapel.cloudsWhite, "CloudsW.png", -0x270f, 0.75f); TileSprite_add(&Chapel.cloudsBlue, "CloudsB.png", -0x270e, 0.5f); TileSprite_add(&Chapel.cloudsAddBlue, "CloudsB.png", -0x270d, 0.5f), Chapel.cloudsAddBlue.s.blendAdd = 1, Chapel.cloudsAddBlue.tilePositionX = 0x64, Chapel.cloudsAddBlue.tilePositionY = 0x32; if (po_is("SelectedInverse")) { // cielo e nuvole scuriti Chapel.skyBlue.s.tint = 0x88; Chapel.cloudsWhite.s.tint = 0x888888, Chapel.cloudsWhite.s.alpha = 0.5f; Chapel.cloudsBlue.s.tint = 0x888888, Chapel.cloudsBlue.s.alpha = 0.25f; Chapel.cloudsAddBlue.s.tint = 0x888888, Chapel.cloudsAddBlue.s.alpha = 0.25f; } TileSprite_add(&Chapel.skyRed, "SkyR.png", -0x2710, 1), Chapel.skyRed.s.visible = 0; TileSprite_add(&Chapel.cloudsRed, "CloudsR.png", -0x270e, 0.5f), Chapel.cloudsRed.s.visible = 0; TileSprite_add(&Chapel.cloudsAddRed, "CloudsR.png", -0x270d, 0.5f), Chapel.cloudsAddRed.s.blendAdd = 1, Chapel.cloudsAddRed.tilePositionX = 0x64, Chapel.cloudsAddRed.tilePositionY = 0x32, Chapel.cloudsAddRed.s.visible = 0; sprite_init(&Chapel.whiteFader, frame_get("backgroundX", "whiteDot.png"), 0.5f * W, 0.5f * H); sprite_setScale(&Chapel.whiteFader, W), Chapel.whiteFader.depth = 0x2710, Chapel.whiteFader.scrollFactor0 = 1, Chapel.whiteFader.alpha = 0; children_add(&Chapel.whiteFader); sprite_init(&Chapel.shootingRay, frame_get("vfx", "ray.png"), 0, 0), Chapel.shootingRay.alpha = 0, sprite_setTint(&Chapel.shootingRay, 0xffff00), sprite_setOrigin(&Chapel.shootingRay, 0.8f, 0.5f); sprite_init(&Chapel.shootingRing, frame_get("vfx", "sPFX_ring_64.png"), 0, 0), Chapel.shootingRing.alpha = 0, sprite_setTint(&Chapel.shootingRing, 0xffff00); children_add(&Chapel.shootingRay), children_add(&Chapel.shootingRing); TileSprite_add(&Chapel.floorLights, "WindowLight.png", -0x7cf, 0.1f), Chapel.floorLights.s.blendAdd = 1, Chapel.floorLights.tilePositionX = -0x140, sprite_setScale(&Chapel.floorLights.s, 4); TileSprite_add(&Chapel.skyLights, "LightShafts.png", -0x7cf, 0.05f), Chapel.skyLights.s.blendAdd = 1, Chapel.skyLights.tilePositionX = -0x140, sprite_setScale(&Chapel.skyLights.s, 4); Chapel.skyLights.s.y = 0x38e; tweens_add((TweenConfig){ .props = { { &Chapel.floorLights.s.alpha, NULL, 0.15f } }, .nprops = 1, .duration = 0x7530, .yoyo = 1, .repeat = -1 }); tweens_add((TweenConfig){ .props = { { &Chapel.skyLights.s.alpha, NULL, 0.2f } }, .nprops = 1, .duration = 0xea60, .yoyo = 1, .repeat = -1 }); for (int i = 0; i < Core.PickupGroup.n && !Chapel.coffin; i++) { // SetupCoffinTrigger Pickup *p = Core.PickupGroup.items[i]->owner; if (!strcmp(p->itemType, "COFFIN")) Chapel.coffin = p; } cJSON *eggs = po("EggData"), *mine = cJSON_GetObjectItem(eggs, po_str("SelectedCharacter")); // SetupCosmoTrigger if (po_has("UnlockedCharacters", "ASSUNTA") && !po_has("UnlockedCharacters", "PAVONE") && po_has("CollectedItems", "RELIC_YELLOW") && !(mine && num(eggs, "total", 0) > 0)) for (int i = 0; i < Core.PickupGroup.n; i++) { // (sic) total di EggData, non del personaggio Pickup *p = Core.PickupGroup.items[i]->owner; if (!strcmp(p->itemType, "NFT")) { Chapel.cosmoPavone = Core_MakePickup(p->s.x, p->s.y + 0x100, "COSMO_PAVONE"); break; } } Chapel_SecretCreate(); // HasKilledTheFinalBoss o niente reliquia gialla: il minuto 30 resta TRAINEE_R + BOSS_XLDEATH2 } static void Chapel_OpenTerrace(void) { // apre il passaggio verso la terrazza: 24 tile del layer 6 Sound_PlaySound("Lid", 2, 1, -0x1f4, 0x96, 2); TilemapLayer *l = Core.Stage->tilingTileset->layerContainers[0].layers[6]; if (!l) return; for (int y = 0xf; y <= 0x15; y++) tilemapLayer_removeTileAt(l, 0x1f, y), tilemapLayer_removeTileAt(l, 0x20, y); for (int y = 0x11; y <= 0x15; y++) tilemapLayer_removeTileAt(l, 0x1e, y), tilemapLayer_removeTileAt(l, 0x21, y); } static float Chapel_dist2(Pickup *p) { float dx = Core.Player->s.x - p->s.x, dy = Core.Player->s.y - p->s.y; return dx * dx + dy * dy; } static void Chapel_Update(float delta) { float a = 0.01f * delta, b = 0.02f * delta, c = 0.015f * delta, d = 0.025f * delta, vy = 0.01f * Core.Player->s.body.velocity.y, w = Chapel.wind; Chapel.skyBlue.tilePositionX -= a * w, Chapel.cloudsWhite.tilePositionX -= b * w, Chapel.cloudsBlue.tilePositionX -= c * w, Chapel.cloudsAddBlue.tilePositionX -= d * w; Chapel.skyBlue.tilePositionY -= vy * a, Chapel.cloudsWhite.tilePositionY -= vy * b, Chapel.cloudsBlue.tilePositionY -= vy * c, Chapel.cloudsAddBlue.tilePositionY -= vy * d; Chapel.skyRed.tilePositionX -= a * w, Chapel.cloudsRed.tilePositionX -= c * w, Chapel.cloudsAddRed.tilePositionX -= d * w; Chapel.skyRed.tilePositionY -= vy * a, Chapel.cloudsRed.tilePositionY -= vy * c, Chapel.cloudsAddRed.tilePositionY -= vy * d; Chapel.floorLights.tilePositionX = 0.1f * (0x80 + Core.Player->s.x), Chapel.floorLights.tilePositionY = 0.1f * (0x40 + Core.Player->s.y); Chapel.skyLights.tilePositionX = 0.2f * (0x80 + Core.Player->s.x); if (Chapel.coffin && !Chapel.hasTerraceBeenOpened && Chapel_dist2(Chapel.coffin) < 0xea60) Chapel.hasTerraceBeenOpened = 1, Chapel.coffin = NULL, Chapel_OpenTerrace(); if (Chapel.cosmoPavone && !Chapel.hasTerraceBeenOpened && Chapel_dist2(Chapel.cosmoPavone) < 0xea60 && Core_GetWeapon("SILF") && Core_GetWeapon("SILF2")) Chapel.hasTerraceBeenOpened = 1, Chapel.cosmoPavone = NULL, Chapel_OpenTerrace(); // con Peachone ed Ebony Wings Chapel_SecretUpdate(delta); } static int Chapel_HasMovingBG(void) { return !po_is("HasKilledTheFinalBoss"); } // DEBUGTHEENDER || !HasKilledTheFinalBoss static void Chapel_DisableMovingBackground(void) { FB_disableMovingBG = 1; } // backgroundMoveTween.stop(): i tween arrivano col segreto (S3b) static const FancyBG FB_Chapel = { Chapel_Create, Chapel_Update, Chapel_CheckMinute, NULL, NULL, Chapel_HasMovingBG, Chapel_DisableMovingBackground }; // --- MOLISE (0xe631): conta la vita ridata ai molisani con FLOWER; oltre 10000 Peppino si sblocca --- static struct { float restored; } Molise; static void Molise_Create(void) { memset(&Molise, 0, sizeof(Molise)); } static void Molise_RestoreHp(float v) { Molise.restored += v; if (Molise.restored > 0x2710 && Char_found("PEPPINO", 1, 1)) Sound_PlaySound("ThingFound", 1, 0.5f, -0x3e8, 0, 0); } static const FancyBG FB_Molise = { Molise_Create, NULL, NULL, NULL }; // --- MOLISANO_* (0x2037): fermi, crescono e poi diventano immobili (fuori da EnemyGroup); FLOWER li cura e da' esperienza --------- static void Molisano_entered(void *ctx) { Enemy *e = ctx; e->s.body.immovable = 1; list_remove(&Core.EnemyGroup, &e->s); } static void E_Molisano_OnRecycle(Enemy *e) { base_EnemyOnRecycle(e); e->speed = 0, sprite_setScale(&e->s, 0), e->s.body.immovable = 0; e->s.flipX = frand() >= 0.5f; if (po_is("SelectedInverse")) { if (po_is("VisuallyInvertStages")) e->s.flipY = 1, sprite_setOrigin(&e->s, 0.5f, 0); else e->s.flipY = 0, sprite_setOrigin(&e->s, 0.5f, 1); e->saveTint = 0xff88ff, sprite_setTint(&e->s, e->saveTint); } else e->s.flipY = 0, sprite_setOrigin(&e->s, 0.5f, 1), e->saveTint = 0xffffff; tween_restartOrAdd(&e->OnEnterTween, (TweenConfig){ .props = { { &e->s.scaleX, &e->s.scaleY, e->scaleMul }, { &e->speed, NULL, 0 } }, .nprops = 2, .duration = 0x12c, .onComplete = Molisano_entered, .ctx = e }); } static void E_Molisano_Die(Enemy *e) { base_EnemyDie(e); e->s.body.enable = 0; } static void E_Molisano_Update(Enemy *e) { if (e->isDead) return; e->s.depth = e->s.y - Core.Player->s.y; if (!e->IsTimeStopped) e->s.angle = TweenAngles[e->moveTweenIndex]; } static void E_Molisano_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *t) { if (!t || strcmp(t, "FLOWER")) { base_EnemyGetDamaged(e, amount, hitVFX, kb, t); return; } e->hp += amount; Player_AddXP(Core.Player, 0.005f * Core.Player->level); Core_ShowRecoveryAt(e->s.x, e->s.y, amount); if (!strcmp(Core.Stage->stageType, "MOLISE") && Core.Stage->fancyBG == &FB_Molise) Molise_RestoreHp(amount); } static const EnemyVT E_Molisano = { .OnRecycle = E_Molisano_OnRecycle, .Die = E_Molisano_Die, .GetDamaged = E_Molisano_GetDamaged, .Update = E_Molisano_Update }; // --- MOLISANO_ANFORA (0x4e61): un molisano mai specchiato; rotto, lascia una moneta che vola dal giocatore --------------------------- static void E_Anfora_OnRecycle(Enemy *e) { E_Molisano_OnRecycle(e); e->s.flipX = 0; } static void E_Anfora_Die(Enemy *e) { E_Molisano_Die(e); Pickup *c = Core_MakePickup(e->s.x, e->s.y, "COIN"); if (c) c->time = 1, c->goToPlayer = 1; } static const EnemyVT E_Anfora = { .OnRecycle = E_Anfora_OnRecycle, .Die = E_Anfora_Die, .GetDamaged = E_Molisano_GetDamaged, .Update = E_Molisano_Update }; // --- SKETAMARI (0x5fe5): una palla di 500 ossa che rotola da un lato all'altro della Bone Zone e ingoia i nemici, crescendo --------------- // Il rumore si sente piu' forte da vicino; battuto, lascerebbe la reliquia RELIC_SECRETS (F3). MapToken della mappa: non tradotto. #define SKETA_BONES (0xfa + 0x96 + 0x64) typedef struct { const char *type; Animation die, idle; } BoneAnim; typedef struct { Sprite s; const BoneAnim *a; } Bone; typedef struct { float radius, maxDistance, sineF; Sprite container; Bone bones[SKETA_BONES]; int nbones; TweenRef sine; } SketaX; static const char *const SketaEnemies[10] = { "SKELETON", "SKELETON2", "SKELETON3", "SKELETON4", "SKULLINO", "SKELEPANTHER", "SKELETONE", "SKELEWING_ZONE", "SKULLNOAURA", "SKULLNOAURA" }; static const BoneAnim *BoneAnim_get(const char *type) { // le animazioni del tipo: una per tipo invece di una per osso static BoneAnim cache[10]; for (int i = 0; i < 10; i++) { if (cache[i].type && !strcmp(cache[i].type, type)) return &cache[i]; if (cache[i].type) continue; cJSON *d = cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("enemies"), type), 0); const char *tex = str(d, "textureName"), *name = cJSON_GetStringValue(cJSON_GetArrayItem(cJSON_GetObjectItem(d, "frameNames"), 0)); char prefix[96]; snprintf(prefix, sizeof(prefix), "%s", name); char *q = strstr(prefix, "0.png"); if (q) *q = 0; cache[i].type = type; cache[i].die.n = anims_generateFrameNames(tex, prefix, 0, (int)num(d, "end", 0), 0, cache[i].die.frames, ANIM_MAX_FRAMES); cache[i].die.frameRate = 0x18, cache[i].die.msPerFrame = 1000.0f / 0x18; if (num(d, "idleFrameCount", 0)) { char ip[100]; snprintf(ip, sizeof(ip), "%si", prefix); cache[i].idle.n = anims_generateFrameNames(tex, ip, 1, (int)num(d, "idleFrameCount", 0), 2, cache[i].idle.frames, ANIM_MAX_FRAMES); cache[i].idle.frameRate = 8, cache[i].idle.msPerFrame = 1000.0f / 8, cache[i].idle.repeat = -1; } return &cache[i]; } return NULL; } static void Sketa_containerDraw(Sprite *c) { // Container: i figli trasformati da posizione, angolo e scala del contenitore SketaX *k = ((Enemy *)c->owner)->x; if (!c->visible) return; float a = c->angle * DEG2RAD, ca = cosf(a), sa = sinf(a), sc = c->scaleX; for (int i = 0; i < k->nbones; i++) { Sprite t = k->bones[i].s; float lx = t.x * sc, ly = t.y * sc; t.x = c->x + lx * ca - ly * sa, t.y = c->y + lx * sa + ly * ca; t.angle += c->angle, t.scaleX *= sc, t.scaleY *= sc; scene_render_one(&t, (Shader){ 0 }); } } static void Sketa_AddBones(Enemy *e, int n, float r0, float r1, float sr) { SketaX *k = e->x; for (int i = 0; i < n && k->nbones < SKETA_BONES; i++) { const char *type = SketaEnemies[(int)floorf(frand() * 10)]; cJSON *d = cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("enemies"), type), 0); if (!d) continue; float t = 2 * PI * i / n; Bone *b = &k->bones[k->nbones++]; b->a = BoneAnim_get(type); sprite_init(&b->s, frame_get(str(d, "textureName"), cJSON_GetStringValue(cJSON_GetArrayItem(cJSON_GetObjectItem(d, "frameNames"), 0))), ((r1 - r0) * frand() + r0) * k->radius * cosf(t), ((r1 - r0) * frand() + r0) * k->radius * sinf(t)); b->s.flipX = frand() >= 0.5f, b->s.angle = 0xb4 * frand() + t * RAD2DEG; sprite_setScale(&b->s, 1 + frand() * sr); if (b->a && b->a->idle.n) anims_play(&b->s, &b->a->idle, 0); // play('idle') senza idle: niente } } static float Sketa_dist(Enemy *e) { float dx = Core.Player->s.x - e->s.x, dy = Core.Player->s.y - e->s.y; return sqrtf(dx * dx + dy * dy); } static void E_Sketa_OnRecycle(Enemy *e) { if (!e->x) { SketaX *k = e->x = calloc(1, sizeof(SketaX)); k->radius = 0xc8, k->sine = (TweenRef){ -1, 0 }; } // costruttore SketaX *k = e->x; base_EnemyOnRecycle(e); e->isTeleportOnCull = 0, e->isCullable = 0; e->defaultSpeed = num(enemy_data(e), "speed", 0), e->_currentDirection.x = 1; Sound_PlayLoop("Noise", 0); // scene.sound.add(Noise, volume 0): suona da Update if (tween_get(k->sine)) tween_restart(k->sine); else e->sineF = 1, k->sine = tweens_add((TweenConfig){ .props = { { &e->sineF, NULL, 0.7f } }, .nprops = 1, .duration = 0x4e20, .repeat = -1, .yoyo = 1, .ease = Ease_SineInOut, .persist = 1 }); k->maxDistance = 3 * Sketa_dist(e); if (!k->container.draw) { sprite_init(&k->container, NULL, e->s.x, e->s.y); k->container.owner = e, k->container.draw = Sketa_containerDraw, k->container.scaleX = k->container.scaleY = 1; children_add(&k->container); Sketa_AddBones(e, 0xfa, 0.75f, 1, 1), Sketa_AddBones(e, 0x96, 0.5f, 0.75f, 1.5f), Sketa_AddBones(e, 0x64, 0, 0.5f, 2); } for (int i = 0; i < 10; i++) e->maxHp += 0.1f * num(cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("enemies"), SketaEnemies[i]), 0), "killedAmount", 0); if (e->maxHp > 0x2a30) e->maxHp = 0x2a30; e->hp = e->maxHp; sprite_setOrigin(&e->s, 0.5f, 0.5f), sprite_setScale(&e->s, 0.25f); body_setCircle(&e->s.body, k->radius, -k->radius, -k->radius); } static void E_Sketa_Update(Enemy *e) { SketaX *k = e->x; if (e->isDead) return; if (e->s.x > 0x2800) e->_currentDirection.x = -1, e->s.x = 0x2800; // CheckDirection else if (e->s.x <= -0x2800) e->_currentDirection.x = 1, e->s.x = -0x2800; e->speed = e->defaultSpeed * e->sineF; e->s.depth = k->container.depth = 1; float dist = Sketa_dist(e); Sound_LoopVolume((1 - fminf(1, dist / k->maxDistance)) * SoundsVolume * 0.1f); e->knockback = k->radius < 0x96 ? 0.9f : 0; float kk = e->receivingDamage ? -e->knockback : 1; int right = e->_currentDirection.x > 0; e->s.flipX = right, e->_currentDirection.y = 0; float v = EnemySpeed * e->speed * kk * e->slow; sprite_setVelocity(&e->s, v * e->_currentDirection.x, 0); k->container.x = e->s.x, k->container.y = e->s.y, k->container.scaleX = k->container.scaleY = e->s.scaleX; for (int i = 0; i < k->nbones; i++) sprite_animsUpdate(&k->bones[i].s, Enemies_delta); k->container.angle += fabsf(v) / (0xa * k->radius) * Enemies_delta * (right ? 1 : -1); if (dist >= 0xea60) return; // speed = max(...): sovrascritta al frame dopo, mai usata for (int i = 0; i < Core.Enemies.n; i++) { Enemy *o = Core.Enemies.items[i]->owner; float dx = o->s.x - e->s.x, dy = o->s.y - e->s.y; if (o == e || dx * dx + dy * dy > k->radius * k->radius || o->isDead) continue; Enemy_Disappear(o); float sc = e->s.scaleX; sc += sc < 1 ? 0.001f : sc < 1.5f ? 0.00085f : sc < 2 ? 0.00065f : sc < 3 ? 0.0005f : sc < 4 ? 0.00025f : 0; sprite_setScale(&e->s, sc); k->radius = 0xc8 * sc; float gain = fminf(0xfa, 0.2f * o->maxHp / fmaxf(1, sc)); e->hp += gain, e->maxHp += gain; } } static void Sketa_boneDie(void *ctx) { Bone *b = ctx; if (b->a) anims_play(&b->s, &b->a->die, 0); } static void Sketa_hide(void *ctx) { ((SketaX *)ctx)->container.visible = 0; } static void Sketa_MakeSpritesDisappear(Enemy *e) { SketaX *k = e->x; Sound_StopSound("Noise"); for (int i = 0; i < k->nbones; i++) time_addEvent(0x3e8 * frand(), 0, 0, Sketa_boneDie, &k->bones[i]); time_addEvent(0x5dc, 0, 0, Sketa_hide, k); } static void E_Sketa_Die(Enemy *e) { // MapToken della mappa: non tradotto if (e->isDead) return; Sketa_MakeSpritesDisappear(e); if (!po_has("CollectedItems", "RELIC_SECRETS")) Core_MakeRelic(e->s.x, e->s.y, "RELIC_SECRETS"); base_EnemyDie(e); } static void E_Sketa_Disappear(Enemy *e) { if (e->isDead) return; Sketa_MakeSpritesDisappear(e); base_EnemyDisappear(e); } static const EnemyVT E_Sketa = { .OnRecycle = E_Sketa_OnRecycle, .Die = E_Sketa_Die, .Update = E_Sketa_Update, .Disappear = E_Sketa_Disappear }; // --- BONEZONE (0xac0): lo Sketamari e il cerchio di fiori in (0, -20480) che cura; 10 s dentro e Boros si sblocca (F3) --------------- #define FLOWERS 0x18 static struct { int on; float elapsed, elapsed2, a1, a2, d1, d2; Sprite f1[FLOWERS], f2[FLOWERS], ground; TweenRef t1, t2, t3; } BoneZ; static void BoneZone_place(Sprite *g, float a, float d) { // PlaceOnCircle + RotateAroundDistance(0.02 a frame, raggio dal contatore) for (int i = 0; i < FLOWERS; i++) { float t = a + 2 * PI * i / FLOWERS; g[i].x = d * cosf(t), g[i].y = -0x5000 + d * sinf(t); } } static void BoneZone_Create(void) { memset(&BoneZ, 0, sizeof(BoneZ)); EnemyPool_SpawnAt(EnemyPool_new("SKETAMARI"), -0x1400, 0x2800); if (po_has("UnlockedCharacters", "BOROS")) return; BoneZ.on = 1, BoneZ.d1 = 0xc8, BoneZ.d2 = 0x96; char fr[16]; for (int g = 0; g < 2; g++) for (int i = 0; i < FLOWERS; i++) { Sprite *s = g ? &BoneZ.f2[i] : &BoneZ.f1[i]; snprintf(fr, sizeof(fr), "fl%02d.png", (int)floorf(frand() * 0x59)); sprite_init(s, frame_get("vfx", fr), 0, -0x5000); children_add(s); } BoneZone_place(BoneZ.f1, 0, 0xc8), BoneZone_place(BoneZ.f2, 0, 0xc8); BoneZ.t1 = tweens_add((TweenConfig){ .props = { { &BoneZ.d1, NULL, 0 } }, .nprops = 1, .duration = 0xbb8, .delay = 0x7d0, .ease = Ease_SineInOut, .repeat = -1, .yoyo = 1 }); BoneZ.d2 = 0x96; BoneZ.t2 = tweens_add((TweenConfig){ .props = { { &BoneZ.d2, NULL, 0x32 } }, .nprops = 1, .duration = 0xbb8, .delay = 0x7d0, .ease = Ease_SineInOut, .repeat = -1, .yoyo = 1 }); sprite_init(&BoneZ.ground, NULL, 0, -0x5000); // scene.add.circle(0, -20480, 200, 0x00ff00), alpha 0.1, ADD BoneZ.ground.draw = MoonGroundFx_draw, BoneZ.ground.tint = 0xff00, BoneZ.ground.alpha = 0.1f, BoneZ.ground.scaleX = 0xc8; children_add(&BoneZ.ground); BoneZ.t3 = tweens_add((TweenConfig){ .props = { { &BoneZ.ground.alpha, NULL, 0.05f } }, .nprops = 1, .duration = 0x3e8, .yoyo = 1, .repeat = -1, .ease = Ease_SineInOut }); // durata di default } static void BoneZone_Update(float delta) { if (!BoneZ.on) return; if (tween_get(BoneZ.t1) && tween_get(BoneZ.t1)->state == TS_ACTIVE) BoneZ.a1 += 0.02f; // onUpdate del contatore: solo dopo il delay if (tween_get(BoneZ.t2) && tween_get(BoneZ.t2)->state == TS_ACTIVE) BoneZ.a2 += 0.02f; BoneZone_place(BoneZ.f1, BoneZ.a1, BoneZ.d1), BoneZone_place(BoneZ.f2, BoneZ.a2, BoneZ.d2); float dx = Core.Player->s.x, dy = Core.Player->s.y + 0x5000; if (dx * dx + dy * dy > 0xc8 * 0xc8) { BoneZ.elapsed = 0; return; } BoneZ.elapsed += delta, BoneZ.elapsed2 += delta; if (BoneZ.elapsed2 >= 0x1f4) Player_RecoverHp(Core.Player, 8, 1, 1), BoneZ.elapsed2 = 0; if (BoneZ.elapsed < 0x2710 || !Char_found("BOROS", 0, 1)) return; Sound_PlaySound("ThingFound", 1, 0.5f, -0x3e8, 0, 0); tween_stop(BoneZ.t1), tween_stop(BoneZ.t2), tween_stop(BoneZ.t3); for (int i = 0; i < FLOWERS; i++) children_remove(&BoneZ.f1[i]), children_remove(&BoneZ.f2[i]); children_remove(&BoneZ.ground); BoneZ.on = 0; } static void BoneZone_OnInitCompleted(void) { if (po_is("SelectedInverse") && Lights.on) Lights.lights[0].color = 0xff2200; // Core.spotlight.setColor } static const FancyBG FB_BoneZone = { BoneZone_Create, BoneZone_Update, NULL, NULL, BoneZone_OnInitCompleted }; // --- FANGEL1-3, TRAINEE_Y (0xa021): l'aspetto alias quando la Cappella e' "impazzita" (fancyBG.alias, segreto del Maddener) --- static void E_FAngel_OnRecycle(Enemy *e) { E_Bridge_OnRecycle(e); // costruttore: le animazioni dell'alias, come i nemici del ponte if (Core.Stage->fancyBG == &FB_Chapel && Chapel.alias) anims_play(&e->s, &((BridgeX *)e->x)->aliasIdle, 0); } static void E_FAngel_Die(Enemy *e) { base_EnemyDie(e); if (Core.Stage->fancyBG == &FB_Chapel && Chapel.alias) anims_play(&e->s, &((BridgeX *)e->x)->aliasDie, 0); } static void E_FAngel_Disappear(Enemy *e) { base_EnemyDisappear(e); if (Core.Stage->fancyBG == &FB_Chapel && Chapel.alias) anims_play(&e->s, &((BridgeX *)e->x)->aliasDie, 0); } static const EnemyVT E_FAngel = { .OnRecycle = E_FAngel_OnRecycle, .Die = E_FAngel_Die, .Disappear = E_FAngel_Disappear }; // --- TRINACRIA / BOSS_TRINACRIA (0x154be): corpo, ali, serpenti e gambe che girano; ferma finche' il giocatore non arriva a 1024 px --- typedef struct { Sprite wings, snakes, legs; Animation aw, as, al; } TrinaX; static void Trina_UpdateSprites(Enemy *e) { TrinaX *t = e->x; Sprite *w = &t->wings, *sn = &t->snakes, *l = &t->legs; w->flipX = sn->flipX = l->flipX = e->s.flipX; w->scaleX = sn->scaleX = l->scaleX = e->s.scaleX, w->scaleY = sn->scaleY = l->scaleY = e->s.scaleY; w->angle = sn->angle = e->s.angle; w->originX = sn->originX = e->s.originX, w->originY = sn->originY = e->s.originY; w->x = sn->x = l->x = e->s.x; w->y = e->s.y, sn->y = e->s.y + 4 * e->s.scaleY, l->y = e->s.y - 0xc * e->s.scaleY; sn->depth = e->s.depth - 1, l->depth = e->s.depth - 2, w->depth = e->s.depth - 3; l->angle *= e->s.flipX ? 1 : -1; // sul valore del tween: senza flip le gambe girano al contrario a ogni frame (sic) } static void Trina_ctor(Enemy *e, TrinaX *t) { // costruttore: ali, serpenti e gambe struct { Sprite *s; Animation *a; const char *p; } P[3] = { { &t->wings, &t->aw, "trinaW_" }, { &t->snakes, &t->as, "trinaS_" }, { &t->legs, &t->al, "trinaL_" } }; for (int i = 0; i < 3; i++) { sprite_init(P[i].s, frame_get("enemies2", TextFormat("%s01.png", P[i].p)), e->s.x, e->s.y); P[i].a->n = anims_generateFrameNames("enemies2", P[i].p, 1, 4, 2, P[i].a->frames, ANIM_MAX_FRAMES); P[i].a->frameRate = 0xa, P[i].a->msPerFrame = 100, P[i].a->repeat = -1; anims_play(P[i].s, P[i].a, 0); children_add(P[i].s); } tweens_add((TweenConfig){ .props = { { &t->legs.angle, NULL, 0x167 } }, .nprops = 1, .duration = 0x3e8, .repeat = -1 }); e->isCullable = 0, e->activated = 0; } static void E_Trina_OnRecycle(Enemy *e) { if (!e->x) Trina_ctor(e, e->x = calloc(1, sizeof(TrinaX))); base_EnemyOnRecycle(e); TrinaX *t = e->x; Trina_UpdateSprites(e); t->wings.visible = t->snakes.visible = t->legs.visible = 1; e->defaultSpeed = num(enemy_data(e), "speed", 0); // _defaultSpeed } static void E_Trina_Update(Enemy *e) { e->speed = e->defaultSpeed * e->activated; float dx = e->s.x - Core.Player->s.x, dy = e->s.y - Core.Player->s.y; if (sqrtf(dx * dx + dy * dy) < 0x400) e->activated = 1; base_EnemyUpdate(e); Trina_UpdateSprites(e); } static void Trina_hide(Enemy *e) { TrinaX *t = e->x; t->wings.visible = t->snakes.visible = t->legs.visible = 0; } static void E_Trina_Disappear(Enemy *e) { base_EnemyDisappear(e); Trina_hide(e); } static void E_Trina_Die(Enemy *e) { base_EnemyDie(e); Trina_hide(e); } static void E_Trina_DeSpawn(Enemy *e) { base_EnemyDeSpawn(e); Trina_hide(e); } static const EnemyVT E_Trina = { .OnRecycle = E_Trina_OnRecycle, .Die = E_Trina_Die, .Update = E_Trina_Update, .DeSpawn = E_Trina_DeSpawn, .Disappear = E_Trina_Disappear }; // --- MOON_SNEK / MOON_SNEK_GREEN (0x1026f), MOON_SNEK_RED (0x14ccb): serpenti tinti a caso, il muso nella direzione di marcia ----------- static void Snake_angle(Enemy *e) { e->s.angle = -0x5a + atan2f(e->s.body.velocity.y, e->s.body.velocity.x - 1) * RAD2DEG; } // Vector2.RIGHT static void E_Snake_recycle(Enemy *e, const unsigned *tints) { base_EnemyOnRecycle(e); sprite_setOrigin(&e->s, 0.5f, 0.5f); e->saveTint = tints[(int)floorf(frand() * 3)], sprite_setTint(&e->s, e->saveTint); } static void E_Snake_OnRecycle(Enemy *e) { static const unsigned T[3] = { 0x44bbff, 0x88ffff, 0x44ffbb }; E_Snake_recycle(e, T); } static void E_SnakeRed_OnRecycle(Enemy *e) { static const unsigned T[3] = { 0xff8844, 0xff8888, 0xff4444 }; E_Snake_recycle(e, T); } static void E_Snake_Update(Enemy *e) { base_EnemyUpdate(e); Snake_angle(e); } static const EnemyVT E_Snake = { .OnRecycle = E_Snake_OnRecycle, .Update = E_Snake_Update }; static const EnemyVT E_SnakeRed = { .OnRecycle = E_SnakeRed_OnRecycle, .Update = E_Snake_Update }; // --- MOON_CRABBINO / MOON_BOSS_CRABBINO (0xf2ec): due chele come sprite a parte, che spariscono rimpicciolendo ---------------------- typedef struct { Sprite L, R; Animation idle; TweenRef fade; } CrabbinoX; static void Crabbino_place(Enemy *e) { CrabbinoX *c = e->x; c->L.x = e->s.x - 0x1b * e->s.scaleX, c->L.y = e->s.y - 0x1c * e->s.scaleY, c->L.depth = e->s.depth + 1, c->L.angle = e->s.angle; c->R.x = e->s.x + 0x1b * e->s.scaleX, c->R.y = e->s.y - 0x1c * e->s.scaleY, c->R.depth = e->s.depth + 1, c->R.angle = e->s.angle; } static void E_Crabbino_OnRecycle(Enemy *e) { if (!e->x) { CrabbinoX *c = e->x = calloc(1, sizeof(CrabbinoX)); c->idle.n = anims_generateFrameNames("enemies2", "XLPincer_i", 1, 4, 2, c->idle.frames, ANIM_MAX_FRAMES); c->idle.frameRate = 8, c->idle.msPerFrame = 125, c->idle.repeat = -1, c->fade = (TweenRef){ -1, 0 }; Sprite *p[2] = { &c->L, &c->R }; for (int i = 0; i < 2; i++) sprite_init(p[i], frame_get("enemies2", "XLPincer_i01.png"), e->s.x, e->s.y), sprite_setOrigin(p[i], 0.5f, 1), anims_play(p[i], &c->idle, 0), children_add(p[i]); } CrabbinoX *c = e->x; base_EnemyOnRecycle(e); c->R.flipX = 1, c->L.flipX = 0; tween_stop(c->fade); sprite_setScale(&c->R, e->s.scaleX), sprite_setScale(&c->L, e->s.scaleX); sprite_setTint(&c->R, e->saveTint), sprite_setTint(&c->L, e->saveTint); Crabbino_place(e); } static void Crabbino_fade(Enemy *e) { CrabbinoX *c = e->x; tween_stop(c->fade); c->fade = tweens_add((TweenConfig){ .props = { { &c->L.scaleX, &c->L.scaleY, 0 }, { &c->R.scaleX, &c->R.scaleY, 0 } }, .nprops = 2, .duration = 0xc8 }); } static void E_Crabbino_Die(Enemy *e) { base_EnemyDie(e); Crabbino_fade(e); } static void E_Crabbino_Disappear(Enemy *e) { base_EnemyDisappear(e); Crabbino_fade(e); } static void E_Crabbino_DeSpawn(Enemy *e) { Crabbino_fade(e); base_EnemyDeSpawn(e); } static void E_Crabbino_Update(Enemy *e) { base_EnemyUpdate(e); Crabbino_place(e); } static const EnemyVT E_Crabbino = { .OnRecycle = E_Crabbino_OnRecycle, .Die = E_Crabbino_Die, .Update = E_Crabbino_Update, .DeSpawn = E_Crabbino_DeSpawn, .Disappear = E_Crabbino_Disappear }; // --- MOON_EYE1-3 (0xe682): occhi che perdono sangue e lettere (h a s, t u r) da un cerchio attorno --------------------------------- typedef struct { ParticleManager *m1, *m2; ParticleEmitter *e1, *e2; Vector2 edge[0x30]; float totalTime; } MoonEyeX; static void E_MoonEye_OnRecycle(Enemy *e) { if (!e->x) { MoonEyeX *m = e->x = calloc(1, sizeof(MoonEyeX)); static const char *const F1[6] = { "Blood1.png", "Blood2.png", "Blood3.png", "h.png", "a.png", "s.png" }, *const F2[6] = { "Blood1.png", "Blood2.png", "Blood3.png", "t.png", "u.png", "r.png" }; EmitterConfig c = { .nframes = 6, .angle = ERND(0, 0x168), .speed = ERND(0xf, 0x1e), .quantity = 1, .lifespan = EOP(0x226), .alpha = ERANGE(1, 0), .scale = ERANGE(0.5f, 0), .on = 0 }; for (int i = 0; i < 6; i++) c.frames[i] = frame_get("vfx", F1[i]); c.hasZone = 1, c.zoneRadius = 0x10; m->m1 = particles_add(), m->e1 = particles_createEmitter(m->m1, c); for (int i = 0; i < 6; i++) c.frames[i] = frame_get("vfx", F2[i]); c.hasZone = 0, c.edge = m->edge, c.nEdge = 0x30; m->m2 = particles_add(), m->e2 = particles_createEmitter(m->m2, c); } MoonEyeX *m = e->x; base_EnemyOnRecycle(e); m->totalTime = 0; float r = 0x10 * e->s.scaleX; // explosionCircle (0, 0, 16 * scale): zona casuale e bordo (48 punti) m->e1->c.zoneRadius = r; for (int i = 0; i < 0x30; i++) m->edge[i] = (Vector2){ r * cosf(2 * PI * i / 0x30), r * sinf(2 * PI * i / 0x30) }; m->e1->c.scale = m->e2->c.scale = ERANGE(0.5f * e->s.scaleX, 0); } static void E_MoonEye_Update(Enemy *e) { MoonEyeX *m = e->x; base_EnemyUpdate(e); if (e->s.scaleX < 1) return; m->totalTime += Enemies_delta; if (m->totalTime > 0x1e) { m->totalTime -= 0x1e; emitter_emitParticleAt(m->e1, e->s.x, e->s.y - 0xc * e->s.scaleX, 0), emitter_emitParticleAt(m->e2, e->s.x, e->s.y - 0xc * e->s.scaleX, 0); } m->m1->s.depth = e->s.depth - 1, m->m2->s.depth = e->s.depth + 1; } static const EnemyVT E_MoonEye = { .OnRecycle = E_MoonEye_OnRecycle, .Update = E_MoonEye_Update }; // --- MOON_EYE1S-3S (0x150c1): girano attorno al giocatore su un'ellisse che respira ------------------------------------------------- typedef struct { float spinAngle, radius; TweenRef rt, st; } EyeSpinX; static void E_EyeSpin_OnRecycle(Enemy *e) { if (!e->x) { EyeSpinX *k = e->x = calloc(1, sizeof(EyeSpinX)); k->spinAngle = 2 * frand() * PI, k->radius = 1, k->rt = k->st = (TweenRef){ -1, 0 }; } EyeSpinX *k = e->x; base_EnemyOnRecycle(e); k->radius = 1; tween_stop(k->rt); k->rt = tweens_add((TweenConfig){ .props = { { &k->radius, NULL, 0.65f } }, .nprops = 1, .duration = 0x7d0 + 0x7d0 * frand(), .yoyo = 1, .repeat = -1, .ease = Ease_SineInOut }); sprite_setScale(&e->s, 0); tween_stop(k->st); k->st = tweens_add((TweenConfig){ .props = { { &e->s.scaleX, &e->s.scaleY, e->scaleMul } }, .nprops = 1, .duration = 0x12c + 0x3e8 * frand() }); } static void E_EyeSpin_Update(Enemy *e) { EyeSpinX *k = e->x; base_EnemyUpdate(e); // depthOverride = 0: mai usato e->s.flipX = 0; k->spinAngle += -0.001f * Enemies_delta; e->s.x = Core.Player->s.x + cosf(k->spinAngle) * game_width * 0.475f * k->radius; e->s.y = Core.Player->s.y + 0x10 + sinf(k->spinAngle) * game_height * 0.45f * k->radius; e->s.angle = -0xb4 + atan2f(e->s.body.velocity.y, e->s.body.velocity.x - 1) * RAD2DEG; } static const EnemyVT E_EyeSpin = { .OnRecycle = E_EyeSpin_OnRecycle, .Update = E_EyeSpin_Update }; // --- MOON_ANFORA (0x13f3): l'anfora del Molise tinta d'azzurro; sparisce rimpicciolendo (ma dopo la morte va via subito) ------------ static void MoonAnfora_deathDone(void *ctx) { base_EnemyDeSpawn(ctx); } // OnDeathAnimationComplete: super.DeSpawn, senza tween static void MoonAnfora_scaledOut(void *ctx) { base_EnemyDeSpawn(ctx); } static void E_MoonAnfora_OnRecycle(Enemy *e) { tween_stop(e->ScaleTween); // despawnTween E_Molisano_OnRecycle(e); e->s.flipX = 0; static const unsigned T[3] = { 0x44bbff, 0x88ffff, 0x44ffff }; e->saveTint = T[(int)floorf(frand() * 3)], sprite_setTint(&e->s, e->saveTint); e->isCullable = 0, e->isTeleportOnCull = 1; e->s.onAnimationComplete = MoonAnfora_deathDone; } static void E_MoonAnfora_Update(Enemy *e) { E_Molisano_Update(e); e->s.angle = 0; } static void E_MoonAnfora_DeSpawn(Enemy *e) { e->isDespawning = 1; tween_stop(e->ScaleTween); e->ScaleTween = tweens_add((TweenConfig){ .props = { { &e->s.scaleX, &e->s.scaleY, 0 } }, .nprops = 1, .duration = 0xc8, .onComplete = MoonAnfora_scaledOut, .ctx = e }); } static const EnemyVT E_MoonAnfora = { .OnRecycle = E_MoonAnfora_OnRecycle, .Die = E_Anfora_Die, .GetDamaged = E_Molisano_GetDamaged, .Update = E_MoonAnfora_Update, .DeSpawn = E_MoonAnfora_DeSpawn }; // --- MOON_TRINACRIA / _X (0x5cfa): la Trinacria con 20 s di scudo (il danno si accumula e arriva tutto allo scadere) ------------------- typedef struct { TrinaX t; int hasShield; float shieldDamage; Timer shieldTimer; } MoonTrinaX; static void MoonTrina_shieldOff(void *ctx) { Enemy *e = ctx; MoonTrinaX *m = e->x; m->hasShield = 0, e->hp -= m->shieldDamage; } static void E_MoonTrina_OnRecycle(Enemy *e) { if (!e->x) { MoonTrinaX *m = e->x = calloc(1, sizeof(MoonTrinaX)); m->shieldTimer = (Timer){ -1, 0 }; Trina_ctor(e, &m->t); } // TrinaX in testa MoonTrinaX *m = e->x; E_Trina_OnRecycle(e); e->isTeleportOnCull = 1, m->shieldDamage = 0, m->hasShield = 1; time_removeEvent(m->shieldTimer); m->shieldTimer = time_addEvent(0x4e20, 0, 0, MoonTrina_shieldOff, e); } static void E_MoonTrina_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *t) { (void)t; MoonTrinaX *m = e->x; if (amount > 0) Core_ShowDamageAt(e->s.x, e->s.y, amount); if (m->hasShield) m->shieldDamage += amount; else e->hp -= amount; if (e->hp <= 0) Enemy_Die(e); else e->damageKB = kb; Sound_PlaySound("Hit", 0.5f, 1, 0x1f4 * (frand() - 0.5f), 0x96, 3); if (hitVFX != HIT_NONE) Core_ShowHitVFXAt(e->s.x, e->s.y, hitVFX); Enemy_OnGetDamaged(e, hitVFX); } static void E_MoonTrina_Die(Enemy *e) { E_Trina_Die(e); if (e->onDefeat) e->onDefeat(e); } static const EnemyVT E_MoonTrina = { .OnRecycle = E_MoonTrina_OnRecycle, .Die = E_MoonTrina_Die, .GetDamaged = E_MoonTrina_GetDamaged, .Update = E_Trina_Update, .DeSpawn = E_Trina_DeSpawn, .Disappear = E_Trina_Disappear }; // --- MOON_MASK1-5, MASK_GOLD/SILVER/LEFT/RIGHT (0x862e): una maschera sopra il corpo; battuta, sbianca e svanisce ----------------------- static void E_Mask_place(Enemy *e) { Sprite *m = e->x; e->s.angle = 0, m->depth = e->s.depth + 1, m->x = e->s.x + (e->s.flipX ? 2 : -2), m->y = e->s.y - 0x2a * e->s.scaleY; m->scaleX = e->s.scaleX, m->scaleY = e->s.scaleY, m->flipX = e->s.flipX; } static void E_Mask_OnRecycle(Enemy *e) { if (!e->x) { static const char *const P[5] = { "mask1.png", "mask2.png", "mask3.png", "mask4.png", "mask5.png" }; const char *t = e->enemyType, *f = !strcmp(t, "MASK_GOLD") ? "mask1.png" : !strcmp(t, "MASK_SILVER") ? "mask2.png" : !strcmp(t, "MASK_LEFT") ? "mask4.png" : !strcmp(t, "MASK_RIGHT") ? "mask5.png" : P[(int)floorf(frand() * 5)]; Sprite *m = e->x = calloc(1, sizeof(Sprite)); sprite_init(m, frame_get("enemies2", f), e->s.x, e->s.y); children_add(m); } Sprite *m = e->x; base_EnemyOnRecycle(e); e->s.flipX = 0, e->isTeleportOnCull = 1; if (e->HPxLevel) e->maxHp = 0x3e8 + e->dataMaxHp * Core.Player->level * EnemyHealthMultiplier * Core.Stage->EnemyHealthMultiplier; e->hp = e->maxHp; m->alpha = 1, m->tintFill = 0, m->tint = 0xffffff; } static void E_Mask_Die(Enemy *e) { Sprite *m = e->x; base_EnemyDie(e); Core_MakeStagePickup(e->s.x, e->s.y, "RELIC_GOLDENEGG", NULL); sprite_setTintFill(m, 0xffffff); tweens_add((TweenConfig){ .props = { { &m->alpha, NULL, 0 } }, .nprops = 1, .duration = 0x1f4 }); } static void E_Mask_Update(Enemy *e) { base_EnemyUpdate(e); E_Mask_place(e); } static const EnemyVT E_Mask = { .OnRecycle = E_Mask_OnRecycle, .Die = E_Mask_Die, .Update = E_Mask_Update }; // --- SINKING (0x545e): Moongolow. L'acqua in sovraimpressione e, per 14 minuti, l'eclissi: luce rossa, buio, la musica che rallenta, // poi la camera a occhio di pesce (rexFishEyePostFx) e arrivano gli occhi e la Trinacria. Battuta lei: Holy Forbidden (sblocco: F3). static struct { int on, mode; float intensity, radius; Shader sh; int locMode, locTex, locCenter, locRadius, locInt; } FishEye; static struct { int canTriggerEclipse; TileSprite bgtile; Sprite moonpresence, fader, sDarkness; EnemyPool *pool_Anfora, *pool_Eyespin1, *pool_Eyespin2, *pool_Eyespin3, *pool_Trinacria; float rate, detune; int waterBGM; Timer anforaTimer; } Moon; static int Moon_validCharacter(void) { // StageX.GetValidCharacters: i 20 personaggi del gioco base senza segreti static const char *const V[20] = { "ANTONIO", "IMELDA", "PASQUALINA", "GENNARO", "CAMILLO", "CIRO", "PORTA", "LAMA", "CROCI", "CRISTINA", "DOMMARIO", "GERMANA", "MORTACCIO", "CAVALLO", "TATANKA", "MARIA", "PUGNALA", "CONCETTA", "POPPEA", "GIOVANNA" }; for (int i = 0; i < 20; i++) if (Player_is(Core.Player, V[i])) return 1; return 0; } static void Moon_setMinute(int m, int minimum, const char *const *en, int nen, const char *const *bo, int nbo) { // StageData.SINKING[m]: cambia i dati cJSON *d = cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("stages"), "SINKING"), m); if (minimum) cJSON_ReplaceItemInObject(d, "minimum", cJSON_CreateNumber(minimum)); cJSON_ReplaceItemInObject(d, "enemies", cJSON_CreateStringArray(en, nen)); cJSON_ReplaceItemInObject(d, "bosses", cJSON_CreateStringArray(bo, nbo)); } static void Moon_RestoreEclipse(void) { static const char *const E1[1] = { "MOON_EYE1" }, *const B1[2] = { "MOON_EYE2", "MOON_EYE2" }, *const E2[2] = { "MOON_EYE2", "MOON_EYE1" }, *const B2[2] = { "MOON_EYE3", "MOON_EYE3" }, *const E3[1] = { "MOON_SNEK_RED" }; Moon_setMinute(0xc, 0xc8, E1, 1, B1, 2), Moon_setMinute(0xd, 0x78, E2, 2, B2, 2), Moon_setMinute(0xe, 0xc8, E3, 1, NULL, 0); } static void Moon_RemoveEclipse(void) { static const char *const G[1] = { "MOON_SNEK_GREEN" }, *const GB[1] = { "MOON_BOSS_GARLIC" }, *const GR[2] = { "MOON_SNEK_GREEN", "MOON_SNEK_RED" }, *const R[1] = { "MOON_SNEK_RED" }, *const M[3] = { "MOON_MASK1", "MOON_MASK2", "MOON_MASK3" }; Moon_setMinute(0xc, 0xc8, G, 1, GB, 1), Moon_setMinute(0xd, 0xc8, GR, 2, GB, 1), Moon_setMinute(0xe, 0, R, 1, M, 3); } static void AchievementManager_GetNewSecretsEarnedOnThisRun(void); static void AchievementManager_GetNewAchievementsEarnedOnThisRun(void); static int SM_restart; static void Moon_HiddenGround_unlock(void *ctx) { // onStart: Holy Forbidden sbloccato e salvato prima della transizione (void)ctx; if (!po_has("UnlockedStages", "STAGEX")) po_push("UnlockedStages", "STAGEX"); cJSON *t = tbl0("stages", "STAGEX"); if (t) obj_set(t, "unlocked", cJSON_CreateTrue()), obj_set(t, "hidden", cJSON_CreateFalse()); AchievementManager_GetNewSecretsEarnedOnThisRun(); AchievementManager_GetNewAchievementsEarnedOnThisRun(); PlayerOptions_Save(); PlayerOptions_SaveRunBackup(); Player_SetInvulForMilliSeconds(Core.Player, 0x7530); Player_restoreTint(Core.Player); time_addEvent(0x64, 0, 0, Player_restoreTint, Core.Player); } static void Moon_HiddenGround_go(void *ctx) { // onComplete: la stessa partita riparte a Holy Forbidden (RestartMainScene) (void)ctx; Moon.sDarkness.visible = 1; po_sets("SelectedStage", "STAGEX"), po_sets("SelectedBGM", "BGM_Chapet"), po_sets("SelectedBGMMod", "Normal"); po_setb("SelectedHurry", 0), po_setb("SelectedMazzo", 0); SM_restart = 1; } static void Moon_SendToHiddenGround(Enemy *e) { // la Trinacria lunare battuta: si va a Holy Forbidden (void)e; if (Collected("RELIC_YELLOW") || !Moon_validCharacter()) return; Core.canInterrupt = 0; Sound_FadeMusic(0, 0x1388); Sound_PlaySound("BGM_Intro", 0.7f, 1, -0x76c, 0, 0); tweens_add((TweenConfig){ .props = { { &FishEye.radius, NULL, FB_disableMovingBG ? FishEye.radius : 1 }, { &FishEye.intensity, NULL, FB_disableMovingBG ? 0 : 0.2f } }, .nprops = 2, .ease = Ease_SineInOut, .duration = 0x2710, .onStart = Moon_HiddenGround_unlock, .onComplete = Moon_HiddenGround_go }); // Sine.easeIn } static void Moon_Cry(void *ctx) { (void)ctx; if (!Moon_validCharacter()) return; for (int i = 0; i < 0x3c; i++) EnemyPool_SpawnAt(Moon.pool_Eyespin1, 0, 0); for (int i = 0; i < 0x28; i++) EnemyPool_SpawnAt(Moon.pool_Eyespin2, 0, 0); for (int i = 0; i < 0x14; i++) EnemyPool_SpawnAt(Moon.pool_Eyespin3, 0, 0); Vector2 p = Stage_GetBossyPosition(Core.Stage); Enemy *t = EnemyPool_SpawnAt(Moon.pool_Trinacria, p.x, p.y); if (t) t->onDefeat = Moon_SendToHiddenGround; } static void Moon_waterBGM(void *ctx) { // BGM_Water (mod Normal): rate 1.125 e detune -1000 in 13 minuti (void)ctx; if (BGM.idx != Sound_index("BGM_Water")) return; Moon.waterBGM = 1, Moon.rate = 1, Moon.detune = 0; tweens_add((TweenConfig){ .props = { { &Moon.rate, NULL, 1.125f }, { &Moon.detune, NULL, -0x3e8 } }, .nprops = 2, .duration = 0xea60 * 0xd }); } static Vector2 Moon_GetPositionOutOfSight(float range) { Player *p = Core.Player; float a = p->s.body.velocity.x == 0 && p->s.body.velocity.y == 0 ? 2 * PI * frand() : atan2f(p->s.body.velocity.y, p->s.body.velocity.x) + (frand() - 0.5f) * range * DEG2RAD; return (Vector2){ p->s.x + 0.75f * cosf(a) * game_width, p->s.y + 0.75f * sinf(a) * game_height }; } static void Moon_SpawnAnforaCluster(void *ctx) { (void)ctx; int n = (int)fminf(6 * Player_PLuck(Core.Player), 0x12); Vector2 p = Moon_GetPositionOutOfSight(0xf); for (int i = 0; i < n; i++) EnemyPool_SpawnAt(Moon.pool_Anfora, p.x, p.y); } static void Moon_Create(void) { // costruttore + Create memset(&Moon, 0, sizeof(Moon)); FishEye.on = 0; Moon.canTriggerEclipse = !Collected("RELIC_YELLOW") && Moon_validCharacter(); if (Moon.canTriggerEclipse) FishEye.on = 1, FishEye.mode = 1, FishEye.radius = 0.5f * game_height, FishEye.intensity = 0; Moon.pool_Anfora = EnemyPool_new("MOON_ANFORA"), Moon.pool_Anfora->upperLimit = 0x64, Moon.pool_Anfora->isUncapped = 1; Moon.pool_Eyespin1 = EnemyPool_new("MOON_EYE1S"), Moon.pool_Eyespin2 = EnemyPool_new("MOON_EYE2S"), Moon.pool_Eyespin3 = EnemyPool_new("MOON_EYE3S"); Moon.pool_Trinacria = EnemyPool_new("MOON_TRINACRIA"); // spawnEggman: con la reliquia gialla, un milione di monete e 5000 uova (tranne Sigma); spawnHealer: reliquia gialla e 5000 uova del personaggio if (Collected("RELIC_YELLOW") && num(Egg_char(0), "total", 0) >= 0x1388) Core_MakeStagePickup(0x400, 0x800, "HEALER", NULL); if (strcmp(po_str("SelectedCharacter"), "SIGMA") && Collected("RELIC_YELLOW") && po_num("Coins") >= 0xf4240 && num(po("EggData"), "total", 0) >= 0x1388) { Pickup *eg = Core_MakeStagePickup(0x3f8, -0x410, "EGGMAN", NULL); if (eg) eg->s.flipX = 1; } float W = game_width, H = game_height, k = W / 0x200, hurry = po_is("SelectedHurry") ? 0.5f : 1; sprite_init(&Moon.moonpresence, frame_get("backgroundW", "whiteDot.png"), 0.5f * W, 0.5f * H); sprite_setScale(&Moon.moonpresence, W), Moon.moonpresence.depth = -0x7b2, Moon.moonpresence.scrollFactor0 = 1, Moon.moonpresence.alpha = 0, Moon.moonpresence.blendAdd = 1, sprite_setTint(&Moon.moonpresence, 0xff0000); // Vita: nero con alpha a e sopra rosso additivo con lo stesso alpha fanno bg * (1 - a) + rosso * a: un solo strato rosso, stessa immagine e meta' riempimento per la GPU Moon.moonpresence.visible = 0; sprite_init(&Moon.fader, frame_get("backgroundW", "whiteDot.png"), 0.5f * W, 0.5f * H); sprite_setScale(&Moon.fader, W), Moon.fader.depth = -0x7bc, Moon.fader.scrollFactor0 = 1, Moon.fader.alpha = 0, sprite_setTint(&Moon.fader, 0xff0000); children_add(&Moon.moonpresence), children_add(&Moon.fader); sprite_init(&Moon.bgtile.s, NULL, 0.5f * W, 0.5f * H); Moon.bgtile.s.draw = TileSprite_draw, Moon.bgtile.s.scrollFactor0 = 1, Moon.bgtile.s.depth = -0x7c6, Moon.bgtile.s.blendAdd = 1, Moon.bgtile.s.alpha = 0.25f, Moon.bgtile.s.tint = 0xffffff; Moon.bgtile.tex = frame_texture("backgroundW", "spr_water_0.png"), Moon.bgtile.w = W, Moon.bgtile.h = H; sprite_setScale(&Moon.bgtile.s, k); children_add(&Moon.bgtile.s); sprite_init(&Moon.sDarkness, frame_get("vfx", "blackDot.png"), 0, 0); sprite_setOrigin(&Moon.sDarkness, 0, 0), Moon.sDarkness.scrollFactor0 = 1, Moon.sDarkness.scaleX = W, Moon.sDarkness.scaleY = H, Moon.sDarkness.alpha = 0, Moon.sDarkness.depth = 0x2710; children_add(&Moon.sDarkness); if (Moon.canTriggerEclipse) { Moon_RestoreEclipse(); float m = getenv("VS_MOONFAST") ? 0x3e8 : 0xea60; // StartEclipse (sviluppo: VS_MOONFAST=1, minuti da un secondo) tweens_add((TweenConfig){ .props = { { &Moon.moonpresence.alpha, NULL, 0.6f }, { &Moon.fader.alpha, NULL, 0.6f } }, .nprops = 2, .duration = m * hurry * 0xe }); tweens_add((TweenConfig){ .props = { { &FishEye.intensity, NULL, 0.2f } }, .nprops = 1, .ease = Ease_SineInOut, .duration = 0x2710, .delay = m * hurry * 0xe, .onStart = Moon_Cry }); // Sine.easeIn time_addEvent(0x3e8, 0, 0, Moon_waterBGM, NULL); } else Moon_RemoveEclipse(); tweens_add((TweenConfig){ .props = { { &Moon.bgtile.s.scaleX, NULL, 1.25f * k } }, .nprops = 1, .ease = Ease_SineInOut, .duration = 0x1388, .yoyo = 1, .repeat = -1 }); // Sine.easeIn tweens_add((TweenConfig){ .props = { { &Moon.bgtile.s.scaleY, NULL, 1.25f * k } }, .nprops = 1, .ease = Ease_SineOut, .duration = 0x1770, .yoyo = 1, .repeat = -1 }); tweens_add((TweenConfig){ .props = { { &Moon.bgtile.s.alpha, NULL, 0.15f } }, .nprops = 1, .ease = Ease_SineInOut, .duration = 0x1b58, .yoyo = 1, .repeat = -1 }); Moon.anforaTimer = time_addEvent(0x2710 * hurry, 1, 0, Moon_SpawnAnforaCluster, NULL); // 'Desct Timer' del fancyBG: i bracieri dello stage restano } static void Moon_Update(float delta) { (void)delta; Moon.bgtile.tilePositionX = Core.Player->s.x, Moon.bgtile.tilePositionY = Core.Player->s.y; // visible = FlashingVFXEnabled Moon.bgtile.s.visible = vs_quality_mode(); // Vita: l'acqua a tutto schermo solo nel profilo Grafica; in Performance si risparmia la passata (era un rimedio ai lampi neri) if (Moon.waterBGM && BGM.playing) SetMusicPitch(BGM.music, Moon.rate * powf(2, Moon.detune / 1200)); } static const FancyBG FB_Moon = { Moon_Create, Moon_Update, NULL, NULL }; static void FishEye_Begin(void) { // fisheye.js (rex): fuori dal raggio la distanza si piega con sin (modo 1) o asin, mescolata per intensita' if (!FishEye.sh.id) { static const char *BODY = "uniform float mode; uniform vec2 texSize; uniform vec2 center; uniform float radius; uniform float intensity;\n" "vec2 fish(vec2 uv) {\n" " vec2 tc = uv * texSize - center; float dist = length(tc) / radius;\n" " if (dist > 1.0) { float f = mode > 0.0 ? sin(dist * 1.570795) : asin(dist) / 1.570795; tc *= mix(1.0, f, intensity); }\n" " return (tc + center) / texSize;\n" "}\n"; char fs[1024]; #ifdef __vita__ snprintf(fs, sizeof(fs), "#version 100\nprecision mediump float;\nvarying vec2 fragTexCoord;\nvarying vec4 fragColor;\nuniform sampler2D texture0;\n%s" "void main() { gl_FragColor = texture2D(texture0, fish(fragTexCoord)) * fragColor; }\n", BODY); #else snprintf(fs, sizeof(fs), "#version 330\nin vec2 fragTexCoord;\nin vec4 fragColor;\nuniform sampler2D texture0;\nout vec4 finalColor;\n%s" "void main() { finalColor = texture(texture0, fish(fragTexCoord)) * fragColor; }\n", BODY); #endif FishEye.sh = LoadShaderFromMemory(NULL, fs); FishEye.locMode = GetShaderLocation(FishEye.sh, "mode"), FishEye.locTex = GetShaderLocation(FishEye.sh, "texSize"); FishEye.locCenter = GetShaderLocation(FishEye.sh, "center"), FishEye.locRadius = GetShaderLocation(FishEye.sh, "radius"), FishEye.locInt = GetShaderLocation(FishEye.sh, "intensity"); } float mode = FishEye.mode, tex[2] = { game_width, game_height }, c[2] = { 0.5f * game_width, game_height - 0.5f * game_height }; SetShaderValue(FishEye.sh, FishEye.locMode, &mode, SHADER_UNIFORM_FLOAT); SetShaderValue(FishEye.sh, FishEye.locTex, tex, SHADER_UNIFORM_VEC2); SetShaderValue(FishEye.sh, FishEye.locCenter, c, SHADER_UNIFORM_VEC2); SetShaderValue(FishEye.sh, FishEye.locRadius, &FishEye.radius, SHADER_UNIFORM_FLOAT); SetShaderValue(FishEye.sh, FishEye.locInt, &FishEye.intensity, SHADER_UNIFORM_FLOAT); BeginShaderMode(FishEye.sh); } // ============================================================================ // Boss Rash (RASH 0x321d) e i boss "normali" del finale: Maddener (0xa58f), Stalker (0x1afe), Trickster (0xa25a), // Drowner (0x14807, Rash 0xdb12), Ender Rash (0x9201 su 0x4d66) con le zone (0xde50, pool 0x9612) e le falci (0x529e), granchio Rash (0x4e24) // ============================================================================ static void Boss_ringHide(void *ctx) { ((Sprite *)ctx)->visible = 0; } static void Boss_ring(Enemy *e) { // ringSprite: scene.add.image('vfx', 'sPFX_ring_64.png').setScale(0), ADD if (e->ringSprite) return; Sprite *r = e->ringSprite = calloc(1, sizeof(Sprite)); sprite_init(r, frame_get("vfx", "sPFX_ring_64.png"), e->s.x, e->s.y); sprite_setScale(r, 0), r->blendAdd = 1; children_add(r); } static void Boss_enterStart(void *ctx) { sprite_setScale(&((Enemy *)ctx)->s, 0); } static void Boss_enter(Enemy *e) { // OnEnterTween nuovo a ogni riciclo: da 0 alla scala dei dati in 300 ms sprite_setScale(&e->s, 0); e->OnEnterTween = tweens_add((TweenConfig){ .props = { { &e->s.scaleX, &e->s.scaleY, e->scaleMul } }, .nprops = 1, .duration = 0x12c, .onStart = Boss_enterStart, .ctx = e }); } static void Boss_ringStart(void *ctx) { Enemy *e = ctx; e->ringSprite->x = e->s.x, e->ringSprite->y = e->s.y, sprite_setScale(e->ringSprite, 0), e->ringSprite->visible = 1; } static void Boss_DeathScream(Enemy *e) { Sound_PlaySound("Deathscream", 4, 1, 0, 0x96, 2); tweens_add((TweenConfig){ .props = { { &e->ringSprite->scaleX, &e->ringSprite->scaleY, 0x10 } }, .nprops = 1, .duration = 0x12c, .repeat = 1, .onStart = Boss_ringStart, .onComplete = Boss_ringHide, .ctx = e }); } static int Boss_isCaster(const char *t) { // armi che li battono subito (e niente minigioco: hasLostTreasure) return t && (!strcmp(t, "PENTAGRAM") || !strcmp(t, "ROSARY") || !strcmp(t, "SIRE") || !strcmp(t, "CORRIDOR") || !strcmp(t, "SHROUD")); } static void Boss_defeat(Enemy *e) { if (e->onDefeat) { void (*f)(Enemy *) = e->onDefeat; e->onDefeat = NULL; f(e); } } // il minigioco di Panini (Exdash sbloccato: Invio + Giu') di Stalker, Trickster e Drowner: F3 // --- BOSS_MADDENER_NORMAL: un angelo (alias della Cappella) che entra con un "!" a sinistra del giocatore --------------------------------- static void Maddener_warnBack(void *ctx) { Sprite *s = ctx; tweens_add((TweenConfig){ .props = { { &s->scaleX, &s->scaleY, 0 } }, .nprops = 1, .duration = 0xc8, .delay = 0xc8 }); } static void Maddener_warnSound(void *ctx) { (void)ctx; Sound_PlaySound("Pizza", 0.9f, 1, 0x4b0, 0x96, 2); } static void E_Maddener_OnRecycle(Enemy *e) { E_FAngel_OnRecycle(e); Boss_ring(e), Boss_enter(e); e->isCullable = 0, e->s.depth = 0x2710, e->isTeleportOnCull = 1; // isSpinning, spinRadius, runningTweenValue, rosaried: mai letti sprite_setOrigin(&e->s, 0.5f, 0.5f); e->s.x = Core.Player->s.x - (0.5f * game_height - 0x18), e->s.y = Core.Player->s.y; if (e->idle.n) anims_play(&e->s, &e->idle, 0); Sprite *w = calloc(1, sizeof(Sprite)); // SingleWarning(x + 32, y - 16) sprite_init(w, frame_get("UI", "ExclamationMark.png"), e->s.x + 0x20, e->s.y - 0x10); sprite_setScale(w, 0), sprite_setOrigin(w, 0.5f, 1), w->depth = 0x2328; children_add(w); tweens_add((TweenConfig){ .props = { { &w->scaleX, &w->scaleY, 1 } }, .nprops = 1, .duration = 0xc8, .delay = 0x3e8, .onStart = Maddener_warnSound, .onComplete = Maddener_warnBack, .ctx = w }); } static void E_Maddener_Die(Enemy *e) { E_FAngel_Die(e); Boss_DeathScream(e); Boss_defeat(e); } static void E_Maddener_DeSpawn(Enemy *e) { base_EnemyDeSpawn(e); Boss_defeat(e); } static const EnemyVT E_Maddener = { .OnRecycle = E_Maddener_OnRecycle, .Die = E_Maddener_Die, .DeSpawn = E_Maddener_DeSpawn, .Disappear = E_FAngel_Disappear }; // --- BOSS_STALKER_NORMAL: lo Stalker che si puo' battere (le armi "da caccia" lo uccidono subito, Stained Glass fa 10 volte il danno) ------- static void E_StalkerN_OnRecycle(Enemy *e) { base_EnemyOnRecycle(e); sprite_setTint(&e->s, 0xccccff); Boss_ring(e), Boss_enter(e); e->defaultSpeed = num(enemy_data(e), "speed", 0), e->sineF = 1, e->isCullable = 0, e->isTeleportOnCull = 1, e->s.alpha = 0.8f, e->hasLostTreasure = 0; tween_restartOrAdd(&e->OnSineTween, (TweenConfig){ .props = { { &e->sineF, NULL, 0.1f }, { &e->s.alpha, NULL, 0.6f } }, .nprops = 2, .duration = 0x7d0, .repeat = -1, .yoyo = 1, .ease = Ease_SineInOut }); } static void E_StalkerN_Update(Enemy *e) { e->speed = e->defaultSpeed * e->sineF; base_EnemyUpdate(e); Panini_uppercut(e); } static void E_StalkerN_Die(Enemy *e) { base_EnemyDie(e); Boss_DeathScream(e); Boss_defeat(e); } static void E_StalkerN_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *t) { if (e->hasLostTreasure) return; if (Boss_isCaster(t)) { Enemy_Die(e); e->hasLostTreasure = 1; return; } if (t && !strcmp(t, "WINDOW")) amount *= 0xa; base_EnemyGetDamaged(e, amount, hitVFX, kb, t); } static const EnemyVT E_StalkerN = { .OnRecycle = E_StalkerN_OnRecycle, .Die = E_StalkerN_Die, .GetDamaged = E_StalkerN_GetDamaged, .Update = E_StalkerN_Update, .Disappear = E_Noob_Disappear }; // --- BOSS_TRICKSTER_NORMAL: ogni 30 s un anello di 48 gemme-poltergeist che esplodono; battuto, le fa esplodere tutte ------------------- typedef struct { EnemyPool *gemPool, *gemPoolStatic; Timer gemSummonEvent; } TricksterX; static void Gems_disappear(void *ctx) { // 'gems disappear': non contano tra i nemici degli eventi EventGroup *g = ctx; for (int i = 0; i < g->n; i++) if (!g->list[i]->isDead) g->list[i]->isCullable = 1, Enemy_Disappear(g->list[i]); } static void Trickster_SummonGems(Enemy *e, float d, int count, float k, int isStatic) { TricksterX *t = e->x; float a = 2 * PI * frand(); EventGroup *g = StageEvent_group(count); for (int i = 0; i < count; i++) { float x = Core.Player->s.x + 0.8f * cosf(a) * (game_width * k), y = Core.Player->s.y + 0.8f * sinf(a) * (game_height * k); a += PI / (0.5f * count); Enemy *gem = EnemyPool_SpawnAt(isStatic ? t->gemPoolStatic : t->gemPool, x, y); if (gem) gem->isCullable = 0, g->list[g->n++] = gem; } time_addEvent(d ? d : 0xea60, 0, 0, Gems_disappear, g); // 'gems disappear' } static void Trickster_summon(void *ctx) { Enemy *e = ctx; if (!e->isDead) Trickster_SummonGems(e, 0x7530, 0x30, 0.8f, frand() >= 0.5f); } static void E_Trickster_OnRecycle(Enemy *e) { if (!e->x) { TricksterX *t = e->x = calloc(1, sizeof(TricksterX)); t->gemSummonEvent = (Timer){ -1, 0 }; } TricksterX *t = e->x; base_EnemyOnRecycle(e); Boss_ring(e); if (!t->gemPool) t->gemPoolStatic = EnemyPool_new("POLTER_GEM_STATIC"), t->gemPool = EnemyPool_new("POLTER_GEM"); Boss_enter(e); Trickster_SummonGems(e, 0x7530, 0x30, 0.8f, frand() >= 0.5f); time_removeEvent(t->gemSummonEvent); t->gemSummonEvent = time_addEvent(0x7530, 0, -1, Trickster_summon, e); e->defaultSpeed = num(enemy_data(e), "speed", 0), e->sineF = 1, e->isCullable = 0, e->isTeleportOnCull = 1, e->hasLostTreasure = 0; tween_restartOrAdd(&e->OnSineTween, (TweenConfig){ .props = { { &e->sineF, NULL, 0.1f } }, .nprops = 1, .duration = 0x7d0, .repeat = -1, .yoyo = 1, .ease = Ease_SineInOut }); } static void E_Trickster_Die(Enemy *e) { TricksterX *t = e->x; base_EnemyDie(e); Boss_DeathScream(e), Boss_defeat(e); for (int i = 0; i < t->gemPool->n_spawned; i++) Enemy_OnSelfDestruct(t->gemPool->spawned[i]); for (int i = 0; i < t->gemPoolStatic->n_spawned; i++) Enemy_OnSelfDestruct(t->gemPoolStatic->spawned[i]); } static void E_Trickster_DeSpawn(Enemy *e) { base_EnemyDeSpawn(e); time_removeEvent(((TricksterX *)e->x)->gemSummonEvent); } static const EnemyVT E_Trickster = { .OnRecycle = E_Trickster_OnRecycle, .Die = E_Trickster_Die, .GetDamaged = E_StalkerN_GetDamaged, .Update = E_StalkerN_Update, .DeSpawn = E_Trickster_DeSpawn, .Disappear = E_Noob_Disappear }; // --- BOSS_XLTRICKSTER (0x10ee5): il guardiano del pianoforte; fermo (speed 0), anelli di 48 gemme, poltergeist e ombre ogni 10 s -------- typedef struct { EnemyPool *gemPool, *gemPoolStatic, *polterPool, *shadePool; Timer gemSummonEvent; } XLTricksterX; static void XLGems_cullable(void *ctx) { // 'gems disappear': tornano solo eliminabili fuori schermo EventGroup *g = ctx; for (int i = 0; i < g->n; i++) if (!g->list[i]->isDead) g->list[i]->isCullable = 1; free(g); } static void XLTrickster_SummonAll(Enemy *e, float d, int count, float k) { XLTricksterX *t = e->x; d = d ? d : 0xea60; float a = 2 * PI * frand(); EventGroup *g = StageEvent_group(count); for (int i = 0; i < count; i++) { EnemyPool *pools[3] = { t->gemPool, t->polterPool, t->shadePool }, *pool = pools[(int)floorf(frand() * 3)]; // RND.pick float x = Core.Player->s.x + 0.8f * cosf(a) * (game_width * k), y = Core.Player->s.y + 0.8f * sinf(a) * (game_height * k); a += PI / (0.5f * count); Enemy *s = EnemyPool_SpawnAt(pool, x, y); if (s) s->isCullable = 0, s->speed = 0xfa, g->list[g->n++] = s; } time_addEvent(d, 0, 0, XLGems_cullable, g); } static void XLTrickster_summon(void *ctx) { Enemy *e = ctx; if (!e->isDead) XLTrickster_SummonAll(e, 0x7530, 0x30, 0.8f); } static void E_XLTrickster_OnRecycle(Enemy *e) { if (!e->x) { XLTricksterX *t = e->x = calloc(1, sizeof(XLTricksterX)); t->gemSummonEvent = (Timer){ -1, 0 }; } XLTricksterX *t = e->x; base_EnemyOnRecycle(e); if (!t->gemPool) t->gemPoolStatic = EnemyPool_new("POLTER_GEM_STATIC"), t->gemPool = EnemyPool_new("POLTER_GEM"), t->polterPool = EnemyPool_new("POLTER"), t->shadePool = EnemyPool_new("SHADERED"); Boss_enter(e); if (e->maxHp < 0x1a04) e->maxHp = 0x1a04, e->hp = e->maxHp; e->hp = e->maxHp; if (getenv("VS_BOSSHP")) e->hp = e->maxHp = atof(getenv("VS_BOSSHP")); // sviluppo: HP del boss del pianoforte XLTrickster_SummonAll(e, 0x2710, 0x30, 0.8f); time_removeEvent(t->gemSummonEvent); t->gemSummonEvent = time_addEvent(0x2710, 0, -1, XLTrickster_summon, e); e->defaultSpeed = num(enemy_data(e), "speed", 0), e->sineF = 1, e->isCullable = 0, e->hasLostTreasure = 0; tween_restartOrAdd(&e->OnSineTween, (TweenConfig){ .props = { { &e->sineF, NULL, 0.1f } }, .nprops = 1, .duration = 0x7d0, .repeat = -1, .yoyo = 1, .ease = Ease_SineInOut }); } static void E_XLTrickster_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *t) { if (!e->hasLostTreasure && t && (!strcmp(t, "ROSARY") || !strcmp(t, "SIRE") || !strcmp(t, "CORRIDOR") || !strcmp(t, "SHROUD") || !strcmp(t, "VICTORY") || !strcmp(t, "CART"))) e->hasLostTreasure = 1; if (!t || (strcmp(t, "ROSARY") && strcmp(t, "SIRE"))) base_EnemyGetDamaged(e, amount, hitVFX, kb, t); } static void XLTrickster_onDefeat(Enemy *e) { if (e->onDefeat) ((void (*)(Enemy *))e->onDefeat)(e); } // senza azzerarlo: Disappear e Die lo chiamano entrambi static void E_XLTrickster_Die(Enemy *e) { base_EnemyDie(e); XLTrickster_onDefeat(e); } static void E_XLTrickster_Disappear(Enemy *e) { tween_stop(e->OnSineTween); e->sineF = -2, e->isCullable = 1, e->isTeleportOnCull = 0; tweens_add((TweenConfig){ .props = { { &e->sineF, NULL, -0xa } }, .nprops = 1, .duration = 0x7d0 }); XLTrickster_onDefeat(e); } static void E_XLTrickster_DeSpawn(Enemy *e) { base_EnemyDeSpawn(e); time_removeEvent(((XLTricksterX *)e->x)->gemSummonEvent); } // spritte: Panini_update static const EnemyVT E_XLTrickster = { .OnRecycle = E_XLTrickster_OnRecycle, .Die = E_XLTrickster_Die, .GetDamaged = E_XLTrickster_GetDamaged, .Update = E_StalkerN_Update, .DeSpawn = E_XLTrickster_DeSpawn, .Disappear = E_XLTrickster_Disappear }; // --- BOSS_SHARD_INFERNAS (0xc4f7): esce dalla bara giusta; battuto sblocca MaFaiPianooo e Avatar, toglie le armi e chiama la mano bianca --- static int Infernas_found; static void E_Infernas_OnRecycle(Enemy *e) { base_EnemyOnRecycle(e); e->isCullable = 0; sprite_setScale(&e->s, 0); e->OnEnterTween = tweens_add((TweenConfig){ .props = { { &e->s.scaleX, &e->s.scaleY, 2 } }, .nprops = 1, .duration = 0x1f4 }); if (getenv("VS_BOSSHP")) e->hp = e->maxHp = atof(getenv("VS_BOSSHP")); // sviluppo: HP del boss del pianoforte } static void E_Infernas_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *t) { (void)hitVFX; base_EnemyGetDamaged(e, amount, HIT_NONE, kb, t); } static void Infernas_shakeDone(void *ctx) { (void)ctx; camera_followOffsetX = 0; if (Infernas_found && Core.n_CharQueue < 8) Core.CharQueue[Core.n_CharQueue++] = "AVATAR"; } static void Infernas_hand(void *ctx) { (void)ctx; WhiteHand_Summon(); } static void Infernas_BlockInput(void) { Core.canPause = 0; Player_SetInvulForMilliSeconds(Core.Player, 0x7530); Player_restoreTint(Core.Player); time_addEvent(0x64, 0, 0, Player_restoreTint, Core.Player); while (Core.n_weapons > 0) Weapon_CleanUp(Core.Weapons[--Core.n_weapons]); // Weapons.pop().CleanUp() while (Core.n_HiddenWeapons > 0) Weapon_CleanUp(Core.HiddenWeapons[--Core.n_HiddenWeapons]); } static void E_Infernas_Die(Enemy *e) { if (e->isDead) return; Infernas_found = 0; if (!po_has("UnlockedCharacters", "AVATAR")) Sound_PlaySound("ThingFound", 1, 0.5f, -0x3e8, 0, 0), AchievementManager_UnlockSecret("MaFaiPianooo"), Infernas_found = 1; Sound_PlaySound("Crystal12", 1.5f, 1, -0x258 * frand(), 0, 0); FrameFreeze_ms = 0x78; // SceneManager.FrameFreeze tweens_add((TweenConfig){ .props = { { &camera_followOffsetX, NULL, 2 } }, .nprops = 1, .duration = 0x10, .yoyo = 1, .repeat = 6, .onStart = BridgeBoss_shakeStart, .onComplete = Infernas_shakeDone }); time_addEvent(0x1f4, 0, 0, Infernas_hand, NULL); Infernas_BlockInput(); base_EnemyDie(e); } static void E_Infernas_Disappear(Enemy *e) { (void)e; } static const EnemyVT E_Infernas = { .OnRecycle = E_Infernas_OnRecycle, .Die = E_Infernas_Die, .GetDamaged = E_Infernas_GetDamaged, .Disappear = E_Infernas_Disappear }; // --- BOSS_DROWNER_NORMAL (0x14807) e _RASH (0xdb12): il Drowner battibile, con l'acqua; impazzisce dal minuto 10 (Rash: 15) ------------- typedef struct { DrownerX d; int GoNutsMinute, rash; float distanceMultiplier; } DrownerNX; static void E_DrownerN_OnRecycle(Enemy *e) { if (!e->x) { DrownerNX *n = e->x = calloc(1, sizeof(DrownerNX)); n->rash = !strcmp(e->enemyType, "BOSS_DROWNER_RASH"); n->GoNutsMinute = n->rash ? 0xf : 0xa, n->distanceMultiplier = n->rash ? 0.3f : 0.45f; } E_Drowner_OnRecycle(e); // DrownerX in testa: acqua, goccioline, isFresh Boss_ring(e), Boss_enter(e); } static void E_DrownerN_Update(Enemy *e) { DrownerNX *n = e->x; DrownerX *d = &n->d; float delta = Enemies_delta; if (d->isFresh) e->s.x = Core.Player->s.x, e->s.y = n->rash ? fmaxf(0x580, Core.Player->s.y + 0.5f * game_height) : Core.Player->s.y + 0.5f * game_height, d->isFresh = 0; // GetSpawnY e->isTeleportOnCull = 0, e->speed = 0; base_EnemyUpdate(e); Panini_uppercut(e); if (!d->dismissed) e->s.x = approach(e->s.x, Core.Player->s.x - game_width * n->distanceMultiplier + 0x60, 0x64 * delta); float k = Core.SurvivedSeconds > 0x3c * n->GoNutsMinute ? 1.3f : 0.1f; if (!po_is("SelectedHyper")) k *= 0.5f; if (Core.Player->s.y - 0xc < e->s.y) e->s.y = approach(e->s.y, Core.Player->s.y - 0xc, k); if (d->bullet) { d->bullet->s.x = Core.Player->s.x, d->bullet->s.y = e->s.y; if (Core.Player->s.y - e->s.y > 0.5f * game_height) d->bullet->s.y = 0xc + Core.Player->s.y - 0.5f * game_height; } d->PfxEmitter->boundsY = e->s.y - 2; d->PfxEmitter->x = 0x18 + e->s.x, d->PfxEmitter->y = -0x42 + e->s.y; d->particlesManager->s.depth = e->s.depth - 1; } static void E_DrownerN_Die(Enemy *e) { base_EnemyDie(e); Boss_DeathScream(e); Boss_defeat(e); Drowner_Dismiss(e); } static const EnemyVT E_DrownerN = { .OnRecycle = E_DrownerN_OnRecycle, .Die = E_DrownerN_Die, .GetDamaged = E_StalkerN_GetDamaged, .Update = E_DrownerN_Update, .DeSpawn = E_Drowner_DeSpawn, .Disappear = E_Drowner_Disappear }; // --- BULLET_SCYTHE (0x529e): la falce dell'Ender, va dritta, gira e sparisce dopo 5,5 s o toccando il giocatore ------------------------------ static void E_Scythe_DeSpawn(Enemy *e) { if (e->isDespawning) return; e->isDespawning = 1; base_EnemyDeSpawn(e); } // .stop senza parentesi (sic) static void E_Scythe_deathDone(void *ctx) { E_Scythe_DeSpawn(ctx); } static void E_Scythe_DeathTween(Enemy *e) { tween_stop(e->OnLifetimeTween); if (tween_get(e->ScaleTween)) tween_stop(e->ScaleTween), tween_restart(e->ScaleTween); else e->ScaleTween = tweens_add((TweenConfig){ .props = { { &e->s.scaleX, &e->s.scaleY, 0 } }, .nprops = 1, .duration = 0x64, .onComplete = E_Scythe_deathDone, .ctx = e, .persist = 1 }); } static void E_Scythe_Disappear(Enemy *e) { if (!e->isDead) e->isDead = 1, E_Scythe_DeathTween(e); } static void E_Scythe_lifeDone(void *ctx) { E_Scythe_Disappear(ctx); } static void E_Scythe_OnRecycle(Enemy *e) { base_EnemyOnRecycle(e); sprite_setScale(&e->s, 0), e->isDespawning = 0, e->lifetime = 1, e->sineF = 0; // sineF: myAngle cJSON *d = enemy_data(e); e->power = num(d, "power", 0); sprite_setTint(&e->s, has(d, "tint") ? (unsigned)num(d, "tint", 0) : 0xffffff); tween_restartOrAdd(&e->OnEnterTween, (TweenConfig){ .props = { { &e->s.scaleX, &e->s.scaleY, 1 } }, .nprops = 1, .duration = 0x64 }); tween_restartOrAdd(&e->OnLifetimeTween, (TweenConfig){ .props = { { &e->lifetime, NULL, 0 } }, .nprops = 1, .duration = 0x64, .delay = 0x157c, .onComplete = E_Scythe_lifeDone, .ctx = e }); sprite_setOrigin(&e->s, 0.5f, 0.5f); } static void E_Scythe_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *t) { (void)e, (void)amount, (void)hitVFX, (void)kb, (void)t; } static void E_Scythe_OnPlayerOverlap(Enemy *e) { base_EnemyOnPlayerOverlap(e); E_Scythe_Disappear(e); } static void E_Scythe_Update(Enemy *e) { base_EnemyUpdate(e); e->s.flipX = 0, e->sineF += Enemies_delta, e->s.angle = e->sineF; } static const EnemyVT E_Scythe = { .OnRecycle = E_Scythe_OnRecycle, .Die = E_Scythe_Disappear, .GetDamaged = E_Scythe_GetDamaged, .Update = E_Scythe_Update, .DeSpawn = E_Scythe_DeSpawn, .Disappear = E_Scythe_Disappear, .OnPlayerOverlap = E_Scythe_OnPlayerOverlap }; // --- Le zone dell'Ender (0xde50): un rettangolo rosso lampeggia tre volte, poi si annerisce e per un po' fa male; quattro "pelli" di particelle --- enum { SKIN_WEAPONS, SKIN_COFFINS, SKIN_TRAINEES, SKIN_EXPLOSIONS }; typedef struct EnderZone { Sprite s, GroundFx; // s: WhiteDot nero scalato al rettangolo; GroundFx: scene.add.rectangle rosso, ADD (dimensioni in w, h) float w, h, damage, duration, hitDelay; int skin, follow, lockX, lockY, activateDamage, hasHit; Timer HitboxTimer; TweenRef despawnTimer; ParticleManager *pm[4]; ParticleEmitter *em[4][2], *cur1, *cur2; struct EnderZonePool *pool; } EnderZone; typedef struct EnderZonePool { EnderZone **stored, **spawned; int nstored, nspawned, capstored, capspawned; } EnderZonePool; static void EnderZone_rectDraw(Sprite *s) { EnderZone *z = s->owner; if (!s->visible || s->alpha <= 0) return; float w = z->w * s->scaleX, h = z->h * s->scaleY; BeginBlendMode(BLEND_ADDITIVE); DrawRectangleRec((Rectangle){ s->x - 0.5f * w - camera_scrollX, s->y - 0.5f * h - camera_scrollY, w, h }, hexc(0xff0000, s->alpha)); EndBlendMode(); } static void EnderZone_stopAll(EnderZone *z) { for (int i = 0; i < 4; i++) emitter_stop(z->em[i][0]), emitter_stop(z->em[i][1]); } static void EnderZone_DeSpawn(EnderZone *z) { EnderZonePool *p = z->pool; z->s.active = 0; for (int i = 0; i < p->nspawned; i++) // Return if (p->spawned[i] == z) { memmove(&p->spawned[i], &p->spawned[i + 1], (p->nspawned - i - 1) * sizeof(*p->spawned)); p->nspawned--; break; } if (p->nstored == p->capstored) p->stored = realloc(p->stored, (p->capstored = p->capstored ? p->capstored * 2 : 8) * sizeof(*p->stored)); p->stored[p->nstored++] = z; children_remove(&z->s); z->activateDamage = 0; tween_stop(z->despawnTimer), z->despawnTimer = TWEEN_NONE; time_removeEvent(z->HitboxTimer); z->GroundFx.visible = 0, z->s.visible = 0; EnderZone_stopAll(z); } static void EnderZone_done(void *ctx) { EnderZone *z = ctx; z->activateDamage = 0; EnderZone_stopAll(z); EnderZone_DeSpawn(z); } static void EnderZone_armed(void *ctx) { ((EnderZone *)ctx)->activateDamage = 1; } static void EnderZone_shootStart(void *ctx) { EnderZone *z = ctx; z->s.visible = 1, z->s.alpha = 0; } static void EnderZone_Shoot(void *ctx) { EnderZone *z = ctx; Sound_PlaySound("Explosion", 0.5f, 1, 0x1f4 * (frand() - 0.5f), 0x96, 3); tweens_add((TweenConfig){ .props = { { &z->s.scaleX, NULL, z->w }, { &z->s.scaleY, NULL, z->h }, { &z->s.alpha, NULL, 0.1f } }, .nprops = 3, .duration = 0x1f4, .onStart = EnderZone_shootStart, .onComplete = EnderZone_armed, .ctx = z }); emitter_start(z->em[z->skin][0]), emitter_start(z->em[z->skin][1]); z->cur1 = z->em[z->skin][0], z->cur2 = z->em[z->skin][1]; ParticleManager *m = z->pm[z->skin]; float wx[4] = { z->s.x, z->s.x, z->s.x - 0.4f * z->w, z->s.x + 0.4f * z->w }, wy[4] = { z->s.y - 0x20, z->s.y - 0x20, z->s.y, z->s.y }; m->wellX = wx[z->skin], m->wellY = wy[z->skin]; z->despawnTimer = tweens_add((TweenConfig){ .props = { { &z->GroundFx.scaleY, NULL, z->GroundFx.scaleY } }, .nprops = 1, .duration = z->duration, .onComplete = EnderZone_done, .ctx = z }); // 'nothing' } static void EnderZone_rearm(void *ctx) { ((EnderZone *)ctx)->hasHit = 0; } static void EnderZone_fxStart(void *ctx) { ((EnderZone *)ctx)->GroundFx.visible = 1; } static EnderZone *EnderZone_new(EnderZonePool *pool) { EnderZone *z = calloc(1, sizeof(EnderZone)); z->pool = pool, z->HitboxTimer = (Timer){ -1, 0 }, z->despawnTimer = TWEEN_NONE; sprite_init(&z->s, frame_get("vfx", "WhiteDot.png"), 0, 0); z->s.visible = 0, z->s.alpha = 0.2f, sprite_setOrigin(&z->s, 0.5f, 0.5f), sprite_setTintFill(&z->s, 0); sprite_init(&z->GroundFx, NULL, 0, 0); z->GroundFx.owner = z, z->GroundFx.draw = EnderZone_rectDraw, z->GroundFx.alpha = 0, z->GroundFx.visible = 0, z->GroundFx.scaleX = z->GroundFx.scaleY = 1; children_add(&z->GroundFx); static const char *const W[17] = { "Axe.png", "Cat.png", "Cross.png", "Diamond2.png", "Garlic.png", "Guns.png", "Guns2.png", "HolyBook.png", "HolyWater.png", "Knife.png", "LighningRing.png", "Pentagram.png", "Song.png", "trapano.png", "WandHoly.png", "WandFire.png", "Whip.png" }; static const char *const H[5] = { "HoodieR_i01.png", "HoodieP_i01.png", "HoodieG_i01.png", "HoodieB_i01.png", "HoodieY_i01.png" }; EmitterConfig c; for (int i = 0; i < 4; i++) { z->pm[i] = particles_add(); z->pm[i]->hasWell = 1, z->pm[i]->wellPower = 1 * 0x14, z->pm[i]->wellEpsilon = 0x32 * 0x32; } c = (EmitterConfig){ .nframes = 17, .lifespan = EOP(0x3e8), .angle = { 0x46, 0x6e, 1 }, .angleSteps = 0x15, .speed = ERND(0x258, 0x320), .quantity = 1, .scale = ERANGE(2, 0), .frequency = 1, .bounce = 0.9f, .collideTop = 1, .collideBottom = 1, .collideLeftRight = 1, .boundsW = 0x64, .boundsH = 0x64, .on = 0 }; for (int i = 0; i < 17; i++) c.frames[i] = frame_get("items", W[i]); z->em[SKIN_WEAPONS][1] = particles_createEmitter(z->pm[SKIN_WEAPONS], c); c.angleSteps = 0x10, c.speed = ERND(0x190, 0x258), c.quantity = 2; z->em[SKIN_WEAPONS][0] = particles_createEmitter(z->pm[SKIN_WEAPONS], c); c = (EmitterConfig){ .frames = { frame_get("items", "CoffinLid.png"), frame_get("items", "Coffin.png") }, .nframes = 2, .lifespan = EOP(0x3e8), .rotate = ERND(0, 0x168), .angle = { 0, 0x168, 1 }, .angleSteps = 0x15, .speed = ERND(0x190, 0x258), .quantity = 1, .scale = ERANGE(1, 0), .frequency = 1, .bounce = 0.9f, .collideTop = 1, .collideBottom = 1, .collideLeftRight = 1, .boundsW = 0x64, .boundsH = 0x64, .on = 0 }; z->em[SKIN_COFFINS][1] = particles_createEmitter(z->pm[SKIN_COFFINS], c); c.angleSteps = 0x10, c.speed = ERND(0x12c, 0x190), c.bounce = 0.5f; z->em[SKIN_COFFINS][0] = particles_createEmitter(z->pm[SKIN_COFFINS], c); c = (EmitterConfig){ .nframes = 5, .lifespan = EOP(0x3e8), .angle = { 0xa0, 0xc8, 1 }, .angleSteps = 0x10, .speed = ERND(0x1f4, 0x258), .quantity = 1, .scale = ERANGE(1, 1), .frequency = 1, .alpha = ERANGE(0.5f, 0), .bounce = 0.9f, .collideTop = 1, .collideBottom = 1, .collideLeftRight = 1, .boundsW = 0x64, .boundsH = 0x64, .on = 0 }; for (int i = 0; i < 5; i++) c.frames[i] = frame_get("enemies3", H[i]); z->em[SKIN_TRAINEES][1] = particles_createEmitter(z->pm[SKIN_TRAINEES], c); c.lifespan = EOP(0x7d0), c.speed = ERND(0x1c2, 0x226), c.alpha = (EmitterOp){ 0 }, c.collideLeftRight = 0, c.hasZoneRect = 1, c.zoneRect = (Rectangle){ 0, -0x20, 0, 0x40 }; // Line(0,-32,0,32) z->em[SKIN_TRAINEES][0] = particles_createEmitter(z->pm[SKIN_TRAINEES], c); c = (EmitterConfig){ .frames = { frame_get("vfx", "Smoke1.png"), frame_get("vfx", "Smoke2.png") }, .nframes = 2, .lifespan = EOP(0x3e8), .rotate = ERND(0, 0x168), .angle = { -0x14, 0x14, 1 }, .angleSteps = 0x10, .speed = ERND(0x320, 0x4b0), .quantity = 2, .scale = ERANGE(2, 1), .frequency = 1, .alpha = ERANGE(0.5f, 0), .bounce = 0.9f, .collideTop = 1, .collideBottom = 1, .collideLeftRight = 1, .boundsW = 0x64, .boundsH = 0x64, .on = 0 }; z->em[SKIN_EXPLOSIONS][1] = particles_createEmitter(z->pm[SKIN_EXPLOSIONS], c); c.frames[0] = frame_get("vfx", "HitSmoke1.png"), c.frames[1] = frame_get("vfx", "HitSmoke2.png"), c.scale = ERANGE(1, 0), c.alpha = (EmitterOp){ 0 }, c.blendAdd = 1; c.collideLeftRight = 0, c.hasZoneRect = 1, c.zoneRect = (Rectangle){ 0, -0x20, 0, 0x40 }; z->em[SKIN_EXPLOSIONS][0] = particles_createEmitter(z->pm[SKIN_EXPLOSIONS], c); return z; } static void EnderZone_OnRecycle(EnderZone *z) { z->s.active = 1, z->GroundFx.scaleX = z->GroundFx.scaleY = 1, sprite_setScale(&z->s, 0), z->GroundFx.depth = 1; z->lockX = z->lockY = 0, z->activateDamage = 0, z->hasHit = 0; time_removeEvent(z->HitboxTimer); z->HitboxTimer = time_addEvent(z->hitDelay, 1, 0, EnderZone_rearm, z); tweens_add((TweenConfig){ .props = { { &z->GroundFx.alpha, NULL, 0.5f } }, .nprops = 1, .yoyo = 1, .repeat = 2, .duration = 0x12c, .onStart = EnderZone_fxStart, .onComplete = EnderZone_Shoot, .ctx = z }); tween_stop(z->despawnTimer), z->despawnTimer = TWEEN_NONE; Sound_PlaySound("Pizza", 0.9f, 1, 0x1f4 * frand(), 0x96, 2); } static EnderZone *EnderZone_SpawnAt(EnderZonePool *p, float x, float y, float w, float h, float damage, float duration, float hitDelay, int skin, int follow) { EnderZone *z = p->nstored ? p->stored[--p->nstored] : NULL; if (!z) z = EnderZone_new(p), z->s.x = z->s.y = -0x3e8, z->hitDelay = 0x1f4, EnderZone_OnRecycle(z); // Init if (p->nspawned == p->capspawned) p->spawned = realloc(p->spawned, (p->capspawned = p->capspawned ? p->capspawned * 2 : 8) * sizeof(*p->spawned)); p->spawned[p->nspawned++] = z; z->s.x = x, z->s.y = y; z->GroundFx.x = x, z->GroundFx.y = y, z->w = w, z->h = h, z->s.scaleX = w, z->s.scaleY = h; // SetExplosionSize z->damage = damage, z->duration = duration, z->hitDelay = hitDelay; // SetExplosionDamage z->skin = skin, z->follow = follow; children_add(&z->s); EnderZone_OnRecycle(z); return z; } static void EnderZone_Update(EnderZone *z, float delta) { if (z->follow) z->s.x = approach(z->s.x, Core.Player->s.x, 0.01f * delta), z->s.y = approach(z->s.y, Core.Player->s.y, 0.01f * delta); if (z->lockX) z->s.x = Core.Player->s.x; if (z->lockY) z->s.y = Core.Player->s.y; z->GroundFx.x = z->s.x, z->GroundFx.y = z->s.y; if (!z->cur1) return; float ex[4] = { z->s.x, z->s.x, z->s.x + 0.5f * z->w, z->s.x - 0.5f * z->w }, ey[4] = { z->s.y - 0.5f * z->h, z->s.y, z->s.y, z->s.y }; // in alto, al centro, a destra, a sinistra ParticleEmitter *c[2] = { z->cur1, z->cur2 }; for (int i = 0; i < 2; i++) { c[i]->x = ex[z->skin], c[i]->y = ey[z->skin]; c[i]->c.boundsX = z->GroundFx.x - 0.5f * z->w, c[i]->boundsY = z->GroundFx.y - 0.5f * z->h, c[i]->c.boundsW = z->w, c[i]->c.boundsH = z->h; // SetEmittersBounds } float px = Core.Player->s.x, py = Core.Player->s.y; if (!z->hasHit && z->activateDamage && px >= z->s.x - 0.5f * z->w && px <= z->s.x + 0.5f * z->w && py >= z->s.y - 0.5f * z->h && py <= z->s.y + 0.5f * z->h) z->hasHit = 1, Player_GetDamaged(Core.Player, z->damage); } // --- BOSS_ENDER (0x4d66) / BOSS_ENDER_RASH (0x9201): scudo per 90 s (Rash 45), ogni 5 s una zona scelta dalla vita rimasta, falci sempre piu' fitte --- typedef struct { EnderZonePool zones; EnemyPool *scythePool; Timer shieldTimer, AItimer; float totalTime, scitheTime, shieldDamage, ShieldTime, attacksDurationMultiplier; int hasShield; } EnderX; static void Ender_shieldOff(void *ctx) { Enemy *e = ctx; EnderX *x = e->x; x->hasShield = 0, e->hp -= x->shieldDamage; } static void Ender_TriggerExplosion(void *ctx); static void E_Ender_OnRecycle(Enemy *e) { if (!e->x) { EnderX *x = e->x = calloc(1, sizeof(EnderX)); int rash = !strcmp(e->enemyType, "BOSS_ENDER_RASH"); x->ShieldTime = rash ? 0xafc8 : 0x15f90, x->attacksDurationMultiplier = rash ? 0.6f : 1, x->shieldTimer = x->AItimer = (Timer){ -1, 0 }; } EnderX *x = e->x; base_EnemyOnRecycle(e); e->isTeleportOnCull = 1, x->totalTime = 0, x->scitheTime = 0x1388, x->shieldDamage = 0; Boss_ring(e); if (!x->scythePool) x->scythePool = EnemyPool_new("BULLET_SCYTHE"); time_removeEvent(x->AItimer); // StartVerySmartAI x->AItimer = time_addEvent(0x1388, 0, -1, Ender_TriggerExplosion, e); x->hasShield = 1; time_removeEvent(x->shieldTimer); x->shieldTimer = time_addEvent(x->ShieldTime, 0, 0, Ender_shieldOff, e); } static void E_Ender_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *t) { (void)t; EnderX *x = e->x; if (amount > 0) Core_ShowDamageAt(e->s.x, e->s.y, amount); if (x->hasShield) x->shieldDamage += amount; else e->hp -= amount; if (e->hp <= 0) Enemy_Die(e); else e->damageKB = kb; Sound_PlaySound("Hit", 0.5f, 1, 0x1f4 * (frand() - 0.5f), 0x96, 3); if (hitVFX != HIT_NONE) Core_ShowHitVFXAt(e->s.x, e->s.y, hitVFX); Enemy_OnGetDamaged(e, hitVFX); } static void E_Ender_Update(Enemy *e) { EnderX *x = e->x; base_EnemyUpdate(e); if (e->isDead) return; float left = x->hasShield ? e->maxHp - x->shieldDamage : e->hp; x->scitheTime = 0x1f4 + fmaxf(0, left / e->maxHp * 0xfa0); for (int i = 0; i < x->zones.nspawned; i++) EnderZone_Update(x->zones.spawned[i], Enemies_delta); x->totalTime += Enemies_delta; if (x->totalTime > x->scitheTime) x->totalTime = 0, EnemyPool_SpawnAt(x->scythePool, e->s.x, e->s.y); // ThrowScithe } static void Ender_zone(Enemy *e, int skin, float dx, float dy, int follow, float duration) { // DamagingZone_*: colonne (Weapons, Coffins) o righe (Trainees, Explosions) EnderX *x = e->x; int col = skin == SKIN_WEAPONS || skin == SKIN_COFFINS; EnderZone *z = EnderZone_SpawnAt(&x->zones, Core.Player->s.x + dx, Core.Player->s.y + dy, col ? 0x64 : game_width, col ? game_height : 0x64, 0xc, duration * x->attacksDurationMultiplier, 0x1f4, skin, follow); if (col) z->lockY = 1; else z->lockX = 1; } static void Ender_TriggerExplosion(void *ctx) { Enemy *e = ctx; EnderX *x = e->x; if (e->isDead) { time_removeEvent(x->AItimer); return; } float step = e->maxHp / 9, left = x->hasShield ? e->maxHp - x->shieldDamage : e->hp; int k = 9 - (int)roundf(left / step); static const char *const BAG8[4] = { "Trainees", "Coffins", "Weapons", "Explosions" }; const char *a = k == 0 ? "Trainees" : k == 1 ? "Coffins" : k == 2 ? (frand() < 0.5f ? "DoubleTrainees" : "DoubleCoffins") : k == 3 ? "Explosions" : k == 4 ? "DoubleExplosions" : k == 5 ? "Weapons" : k == 6 ? "DoubleWeapons" : BAG8[(int)floorf(frand() * 4)]; if (!strcmp(a, "Coffins")) Ender_zone(e, SKIN_COFFINS, 0, 0, 1, 0x2710); else if (!strcmp(a, "Trainees")) Ender_zone(e, SKIN_TRAINEES, 0, 0, 1, 0x1388); else if (!strcmp(a, "Explosions")) Ender_zone(e, SKIN_EXPLOSIONS, 0, 0, 1, 0x2328); else if (!strcmp(a, "DoubleWeapons")) Ender_zone(e, SKIN_WEAPONS, -0x96, 0, 0, 0x2710), Ender_zone(e, SKIN_WEAPONS, 0x96, 0, 0, 0x2710); else if (!strcmp(a, "DoubleCoffins")) Ender_zone(e, SKIN_COFFINS, -0x15e, 0, 1, 0xfa0), Ender_zone(e, SKIN_COFFINS, 0x15e, 0, 1, 0xfa0); else if (!strcmp(a, "DoubleTrainees")) Ender_zone(e, SKIN_TRAINEES, 0, -0x64, 0, 0x2328), Ender_zone(e, SKIN_TRAINEES, 0, 0x64, 0, 0x2328); else if (!strcmp(a, "DoubleExplosions")) Ender_zone(e, SKIN_EXPLOSIONS, 0, -0x64, 0, 0x2710), Ender_zone(e, SKIN_EXPLOSIONS, 0, 0x64, 0, 0x2710); else Ender_zone(e, SKIN_WEAPONS, 0, 0, 1, 0x2710); } static float Ease_BounceInOut(float v) { // math/easing/bounce/InOut.js int rev = 0; if (v < 0.5f) v = 1 - v * 2, rev = 1; else v = v * 2 - 1; if (v < 1 / 2.75f) v = 7.5625f * v * v; else if (v < 2 / 2.75f) v -= 1.5f / 2.75f, v = 7.5625f * v * v + 0.75f; else if (v < 2.5f / 2.75f) v -= 2.25f / 2.75f, v = 7.5625f * v * v + 0.9375f; else v -= 2.625f / 2.75f, v = 7.5625f * v * v + 0.984375f; return rev ? (1 - v) * 0.5f : v * 0.5f + 0.5f; } static void E_EnderRash_Die(Enemy *e) { // 0x9201: niente camera ne' Mano Bianca (quelli sono del finale, F3): gemme, forziere e lo schiacciamento if (e->isDead) return; e->isDead = 1; float v = EnemySpeed * e->speed * -e->deathKB * e->slow; sprite_setVelocity(&e->s, v * e->_currentDirection.x, v * e->_currentDirection.y); time_removeEvent(e->_blinkTimeout); int value = (int)floorf((frand() + 0.5f) * e->xp); if (value > 0) Core_MakeGem(e->s.x, e->s.y, value); if (e->treasure) { int lv = e->treasureLevel; Stage_SetTreasureLevelFromChance(e->treasure, &lv); Core_MakeTreasure(e->s.x, e->s.y, e->treasure, lv); e->treasure = NULL; } if (GoldFever_isActive()) GoldFever_OnEnemyDeath(e); json_inc(tbl0("enemies", e->enemyType), "killedAmount"); Core.kills++, MainUI_UpdateKills(); anims_stop(&e->s); Boss_DeathScream(e); tweens_add((TweenConfig){ .props = { { &e->s.scaleX, NULL, 0 }, { &e->s.scaleY, NULL, 5 } }, .nprops = 2, .duration = 0x7d0, .ease = Ease_BounceInOut }); // SpecialDeathAnimation } static const EnemyVT E_EnderRash = { .OnRecycle = E_Ender_OnRecycle, .Die = E_EnderRash_Die, .GetDamaged = E_Ender_GetDamaged, .Update = E_Ender_Update }; // --- RASH (0x321d): l'arena con 2000 spettatori che si agitano (i cerchi delle pizze e i limiti rigidi: codice morto nell'originale) --------------- static struct { Blitter *bl; struct { float vx, vy, left, right, top, bottom; } *d; } Rash; static void Rash_Create(void) { static const char *const WATCH[16] = { "stklAntonio_0.png", "stklArca_0.png", "stklChristine_0.png", "stklConcetta_0.png", "stklDommario_0.png", "stklGennaro_0.png", "stklGiovanna_0.png", "stklImelda_0.png", "stklKrochi_0.png", "stklLama_0.png", "stklOld3_0.png", "stklPasqualina_0.png", "stklPoppea_0.png", "stklPorta_0.png", "stklPugnala_0.png", "stklSuora_0.png" }; memset(&Rash, 0, sizeof(Rash)); Blitter *bl = Rash.bl = Blitter_add(); // tutti e quattro i gruppi nel blitter di sinistra (sic) static const char *const INV[2] = { "Migno1_0.png", "Werewolf1_0.png" }; int inv = po_is("SelectedInverse"); // watchersTexture = enemies, watchers = Migno e lupo mannaro bl->s.scrollFactor0 = 0, bl->s.blendAdd = 0, bl->s.depth = 0; bl->bobs = calloc(bl->cap = 0x7d0, sizeof(Bob)); Rash.d = calloc(0x7d0, sizeof(*Rash.d)); for (int g = 0; g < 4; g++) for (int i = 0; i < 0x1f4; i++) { float x = g == 0 ? 0x140 + 0x100 * frand() : g == 1 ? 0x5a0 + 0x100 * frand() : g == 2 ? 0x120 + 0x580 * frand() : 0x140 + 0x580 * frand(); float y = g < 2 ? 0x180 + 0x400 * frand() : g == 2 ? 0x180 + 0x80 * frand() : 0x590 + 0x80 * frand(); int k = bl->n++; bl->bobs[k] = (Bob){ x, y, 1, 0, 0, 0, inv ? frame_get("enemies", INV[i % 2]) : frame_get("enemies3", WATCH[i % 16]) }; Rash.d[k].vx = frand() - 0.5f, Rash.d[k].vy = frand() - 0.5f, Rash.d[k].right = x + 2, Rash.d[k].left = x - 2, Rash.d[k].top = y + 4, Rash.d[k].bottom = y; // flipX dei Bob: il Blitter qui non specchia (semplificazione: nessun Bob ribaltato, aggiungerlo a Blitter_draw se si nota) } } static void Rash_Update(float delta) { (void)delta; for (int i = 0; i < Rash.bl->n; i++) { // UpdateBlitter: tremolano in una scatola di 4x4 Bob *b = &Rash.bl->bobs[i]; b->y += Rash.d[i].vy, b->x += Rash.d[i].vx; if (b->x > Rash.d[i].right || b->x < Rash.d[i].left) Rash.d[i].vx *= -1; if (b->y > Rash.d[i].top || b->y < Rash.d[i].bottom) Rash.d[i].vy *= -1; } } static void Rash_OnInitCompleted(void) { Core_SetHardBounds(0x200, 0x200, 0x600, 0x600); } static const FancyBG FB_Rash = { Rash_Create, Rash_Update, NULL, NULL, Rash_OnInitCompleted }; static void Moonspell_OnInitCompleted(void) { Core_SetHardBounds(0x100, 0x100, 0x2700, 0x2700); } // 0x7a95 static const FancyBG FB_Moonspell = { .OnInitCompleted = Moonspell_OnInitCompleted }; static const FancyBG FB_GreenAcres; // dopo BGMan // le classi degli stage (fancyBG): le altre arrivano con i loro stage (S4...) // --- 0x15196: D_MASK_* (le maschere in orbita del Directer, nemici fermi: si rompono solo con BreakOnNextAttack) ------------------- // 0xa2b: D_SKULL / D_EYE, una maschera con gli occhi sopra (eyes_1, alpha 0.5 in yoyo) typedef struct { int canBreak, isInvul; Sprite eyes; int hasEyes; } DMaskX; static void DirecterE_OnMaskBroken(Enemy *d); static void DMask_shakeStart(void *c) { (void)c; camera_followOffsetX = -2; } static void DMask_shakeDone(void *c) { (void)c; camera_followOffsetX = 0; } static DMaskX *DMask_x(Enemy *e) { if (!e->x) e->x = calloc(1, sizeof(DMaskX)); return e->x; } static void E_DMask_OnRecycle(Enemy *e) { DMask_x(e); base_EnemyOnRecycle(e); e->isCullable = 0; sprite_setScale(&e->s, 0); tweens_add((TweenConfig){ .props = { { &e->s.scaleX, &e->s.scaleY, 1 } }, .nprops = 1, .duration = 0x64 }); // OnEnterTween } static void E_DMask_Update(Enemy *e) { e->s.depth = e->s.y - Core.Player->s.y; } // la posizione la da' il Directer static void E_DMask_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *t) { DMaskX *m = DMask_x(e); if (m->isInvul) return; if (m->canBreak) { base_EnemyDisappear(e); Sound_PlaySound("Crystal12", 1.5f, 1, -0x258 * frand(), 0, 0); FrameFreeze_ms = 0x78; // SceneManager.FrameFreeze tweens_add((TweenConfig){ .props = { { &camera_followOffsetX, NULL, 2 } }, .nprops = 1, .duration = 0x10, .yoyo = 1, .repeat = 6, .onStart = DMask_shakeStart, .onComplete = DMask_shakeDone }); if (e->owner) DirecterE_OnMaskBroken(e->owner); } base_EnemyGetDamaged(e, amount, hitVFX, kb, t); } static void E_DMask_Nop(Enemy *e) { (void)e; } // Die / Disappear vuoti: le maschere non muoiono static void DMask_ScriptedDisappear(Enemy *e) { base_EnemyDisappear(e); } static void DMask_BreakOnNextAttack(Enemy *e, int v) { DMask_x(e)->canBreak = v; } static const EnemyVT E_DMask = { .OnRecycle = E_DMask_OnRecycle, .Die = E_DMask_Nop, .GetDamaged = E_DMask_GetDamaged, .Update = E_DMask_Update, .Disappear = E_DMask_Nop }; static void E_DSkull_OnRecycle(Enemy *e) { DMaskX *m = DMask_x(e); if (!m->hasEyes) { // costruttore: gli occhi m->hasEyes = 1; sprite_init(&m->eyes, frame_get("enemiesM", "eyes_1.png"), e->s.x, e->s.y); children_add(&m->eyes); tweens_add((TweenConfig){ .props = { { &m->eyes.alpha, NULL, 0.5f } }, .nprops = 1, .duration = 0x1f4, .yoyo = 1, .repeat = -1 }); } E_DMask_OnRecycle(e); m->eyes.visible = 1; sprite_setOrigin(&m->eyes, e->s.originX, e->s.originY); } static void E_DSkull_Update(Enemy *e) { DMaskX *m = DMask_x(e); e->s.depth = e->s.y - Core.Player->s.y; m->eyes.depth = e->s.depth + 0x3e8, m->eyes.scaleX = e->s.scaleX, m->eyes.scaleY = e->s.scaleY, m->eyes.x = e->s.x, m->eyes.y = e->s.y + 4; } static void E_DSkull_DeSpawn(Enemy *e) { base_EnemyDeSpawn(e); DMask_x(e)->eyes.visible = 0; } static const EnemyVT E_DSkull = { .OnRecycle = E_DSkull_OnRecycle, .Die = E_DMask_Nop, .GetDamaged = E_DMask_GetDamaged, .Update = E_DSkull_Update, .Disappear = E_DMask_Nop, .DeSpawn = E_DSkull_DeSpawn }; // --- 0x1016f (shootingEyesManager) + 0x7010 (pool) + 0x7d30: l'occhio-stella che piomba ad arco sul punto e esplode ---------------------- // Avviso: "!" e cerchio a terra, poi la stella percorre un mezzo cerchio (raggio meta' schermo) in 500 ms dopo 1,5 s; esplosione di raggio 60, danno 15. typedef struct EyeBlast { Sprite s; // disegno: cerchi (avviso e esplosione) + scia ad arco Sprite star, warn; Animation explode; ParticleManager *pm; ParticleEmitter *pfx, *pfx2; float radius, damage, arcAngle, arcRadius, groundR, groundA, warnA, fxR; unsigned color; int exploding, hasHit, alive, groundOn, fxOn, trailOn; TweenRef arcTween, despawn; } EyeBlast; static struct { EyeBlast *e[48]; int n; } EyeBlasts; static void EyeBlast_draw(Sprite *s) { EyeBlast *b = s->owner; float cx = s->x - camera_scrollX, cy = s->y - camera_scrollY; BeginBlendMode(BLEND_ADDITIVE); if (b->groundOn && b->groundA > 0) DrawCircle((int)cx, (int)cy, fmaxf(1, b->groundR), hexc(b->color, b->groundA)); // GroundWarning if (b->fxOn) DrawCircle((int)cx, (int)cy, fmaxf(1, b->fxR), hexc(b->color, 0.4f)); // GroundFx if (b->trailOn && b->arcAngle > 180) { // trail: arco da 180 al punto corrente, centro (x - arcRadius, y), due passate float ax = cx - b->arcRadius, ay = cy; DrawRing((Vector2){ ax, ay }, b->arcRadius - 2, b->arcRadius + 2, 180, b->arcAngle, 48, hexc(b->color, 0.5f)); DrawRing((Vector2){ ax, ay }, b->arcRadius - 1, b->arcRadius + 1, 180, b->arcAngle, 48, hexc(b->color, 0.8f)); } EndBlendMode(); } static void EyeBlast_DeSpawn(EyeBlast *b) { b->alive = 0, b->exploding = 0, b->star.visible = 0, b->warn.visible = 0, b->fxOn = 0, b->groundOn = 0, b->trailOn = 0; emitter_stop(b->pfx), emitter_stop(b->pfx2); tween_stop(b->despawn), b->despawn = TWEEN_NONE; children_remove(&b->s); } static void EyeBlast_despawnCb(void *c) { EyeBlast_DeSpawn(c); } static void EyeBlast_Explode(void *c) { EyeBlast *b = c; anims_play(&b->star, &b->explode, 0); b->exploding = 1, b->hasHit = 0; b->pm->wellX = b->s.x, b->pm->wellY = b->s.y - 0x14; b->pfx->x = b->pfx2->x = b->s.x, b->pfx->y = b->pfx2->y = b->s.y; emitter_start(b->pfx), emitter_start(b->pfx2); if (po_is("FlashingVFXEnabled")) b->fxOn = 1, b->fxR = 1; tween_stop(b->despawn); b->despawn = tweens_add((TweenConfig){ .props = { { &b->fxR, NULL, b->radius } }, .nprops = 1, .duration = 0x96, .onComplete = EyeBlast_despawnCb, .ctx = b }); b->trailOn = 0; // trail alpha -> 0 in 100 ms Sound_PlaySound("Explosion", 0.5f, 1, 0x1f4 * (frand() - 0.5f), 0x96, 3); } static void EyeBlast_arcStart(void *c) { EyeBlast *b = c; b->trailOn = 1, b->star.visible = 1; } static void EyeBlast_warnBack(void *c) { EyeBlast *b = c; tweens_add((TweenConfig){ .props = { { &b->warn.scaleX, &b->warn.scaleY, 0 } }, .nprops = 1, .duration = 0xc8, .delay = 0xc8 }); } static EyeBlast *EyeBlast_SpawnAt(float x, float y, float damage, float radius) { EyeBlast *b = NULL; for (int i = 0; i < EyeBlasts.n; i++) if (!EyeBlasts.e[i]->alive) { b = EyeBlasts.e[i]; break; } if (!b && EyeBlasts.n < 48) { // Make + Init b = EyeBlasts.e[EyeBlasts.n++] = calloc(1, sizeof(EyeBlast)); sprite_init(&b->s, NULL, 0, 0), b->s.owner = b, b->s.draw = EyeBlast_draw; b->pm = particles_add(); static const char *const BL[3] = { "Blood1.png", "Blood2.png", "Blood3.png" }; EmitterConfig c = { .frames = { frame_get("vfx", BL[0]), frame_get("vfx", BL[1]), frame_get("vfx", BL[2]) }, .nframes = 3, .rotate = ERND(0, 0x168), .quantity = 2, .scale = ERANGE(1, 0), .frequency = 2, .on = 0 }; c.lifespan = EOP(0x3e8), c.angle = (EmitterOp){ 0, 0xb4, 0 }, c.angleSteps = 0x10, c.speed = ERND(0x64, 0xc8), c.alpha = ERANGE(0.5f, 0); b->pfx2 = particles_createEmitter(b->pm, c); c.lifespan = EOP(0x1f4), c.angle = (EmitterOp){ 0, 0x168, 0 }, c.speed = ERND(0x50, 0x78), c.alpha = EOP(1), c.blendAdd = 1; b->pfx = particles_createEmitter(b->pm, c); b->pm->hasWell = 1, b->pm->wellPower = 1 * 0x14, b->pm->wellEpsilon = 0x32 * 0x32; sprite_init(&b->warn, frame_get("UI", "ExclamationMark.png"), 0, 0), sprite_setScale(&b->warn, 0), sprite_setOrigin(&b->warn, 0.5f, 1), b->warn.depth = 0x2328; sprite_init(&b->star, frame_get("enemies2", "eye_0.png"), 0, 0), sprite_setScale(&b->star, 2), sprite_setOrigin(&b->star, 0.5f, 1), b->star.depth = 0x2328, b->star.angle = 0xf; make_anim(&b->explode, "enemies2", "eye_", 5, 0x15, 0, 0x1e, 0); children_add(&b->warn), children_add(&b->star); } if (!b) return NULL; static const unsigned COL[3] = { 0xff8800, 0xffff00, 0xff4400 }; b->alive = 1, b->s.x = x, b->s.y = y, b->damage = damage, b->radius = radius, b->color = COL[RND_between(0, 2)]; b->s.depth = b->pm->s.depth = y + 1 - Core.Player->s.y; children_add(&b->s); // OnRecycle b->star.visible = 0, sprite_setFrame(&b->star, frame_get("enemies2", "eye_0.png")), anims_stop(&b->star); b->arcRadius = 0.5f * game_width, b->exploding = 0, b->hasHit = 1; b->warn.x = x, b->warn.y = y - 0x10, sprite_setScale(&b->warn, 0), b->warn.visible = 1; b->groundA = 0, b->groundR = 1, b->groundOn = 1; Sound_PlaySound("Pizza", 0.9f, 1, 0x1f4 * frand(), 0x96, 2); tweens_add((TweenConfig){ .props = { { &b->warn.scaleX, &b->warn.scaleY, 1 } }, .nprops = 1, .duration = 0xc8, .onComplete = EyeBlast_warnBack, .ctx = b }); tweens_add((TweenConfig){ .props = { { &b->groundA, NULL, 0.2f }, { &b->groundR, NULL, radius } }, .nprops = 2, .duration = 0x1f4, .yoyo = 1, .repeat = 1 }); b->arcAngle = 0xb4; tween_stop(b->arcTween); b->arcTween = tweens_add((TweenConfig){ .props = { { &b->arcAngle, NULL, 0x168 } }, .nprops = 1, .duration = 0x1f4, .delay = 0x5dc, .onStart = EyeBlast_arcStart, .onComplete = EyeBlast_Explode, .ctx = b }); return b; } static void EyeBlasts_Update(float delta) { // explosionEyePool.Update: danno alla prima entrata nel cerchio, poi la scia for (int i = 0; i < EyeBlasts.n; i++) { EyeBlast *b = EyeBlasts.e[i]; if (!b->alive) continue; if (!b->hasHit && b->exploding) { float dx = Core.Player->s.x - b->s.x, dy = Core.Player->s.y - b->s.y; if (dx * dx + dy * dy <= b->radius * b->radius) b->hasHit = 1, Player_GetDamaged(Core.Player, b->damage); } if (b->star.visible && !b->exploding) { // trailUpdate: la stella sull'arco float a = b->arcAngle * DEG2RAD; b->star.x = b->s.x - b->arcRadius + cosf(a) * b->arcRadius, b->star.y = b->s.y + sinf(a) * b->arcRadius; } sprite_animsUpdate(&b->star, delta); } (void)delta; } static void ShootingEyes_shootOne(float k) { // shootOne: un punto a caso nella meta' centrale dello schermo attorno al giocatore float x = Core.Player->s.x + (frand() - 0.5f) * game_width * 0.5f * k, y = Core.Player->s.y + (frand() - 0.5f) * game_height * 0.5f * k; EyeBlast_SpawnAt(x, y, 0xf, 0x3c); } static void ShootingEyes_Stop(void) { for (int i = 0; i < EyeBlasts.n; i++) if (EyeBlasts.e[i]->alive) EyeBlast_DeSpawn(EyeBlasts.e[i]); } // --- 0x5b89: D_CLUSTER_COINS / D_CLUSTER_GEMS (fase 4): maschere che a ogni colpo spruzzano monete o gemme verso il giocatore ------------- typedef struct { DMaskX m; ParticleManager *pm; ParticleEmitter *pfx; int canEmit; Timer particlesTimer; } DClusterX; static void DCluster_canEmit(void *c) { ((DClusterX *)((Enemy *)c)->x)->canEmit = 1; } static void E_DCluster_OnRecycle(Enemy *e) { if (!e->x) e->x = calloc(1, sizeof(DClusterX)), ((DClusterX *)e->x)->canEmit = 1, ((DClusterX *)e->x)->particlesTimer = (Timer){ -1, 0 }; DClusterX *c = e->x; E_DMask_OnRecycle(e); const char *fr = !strcmp(e->enemyType, "D_CLUSTER_GEMS") ? "GemBlue.png" : "CoinGold.png"; if (!c->pm) c->pm = particles_add(); // scene.add.particles('items').createEmitter (uno nuovo a ogni riciclo nell'originale) c->pfx = particles_createEmitter(c->pm, (EmitterConfig){ .frames = { frame_get("items", fr) }, .nframes = 1, .quantity = 0xa, .lifespan = EOP(0x7d0), .alpha = ERANGE(1, 0), .angle = ERND(0xe1, 0x13b), .speed = ERND(0xe1, 0x113), .scale = ERANGE(2, 0), .gravityY = 0x320, .bounce = 0.2f, .collideBottom = 1, .boundsH = 1e9f, .on = 0 }); } static void E_DCluster_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *t) { DClusterX *c = e->x; if (c->m.isInvul) return; if (c->canEmit) { // (sic) canEmitParticles non torna mai falso: emette a ogni colpo emitter_emitParticleAt(c->pfx, e->s.x, e->s.y, 0); time_removeEvent(c->particlesTimer); c->particlesTimer = time_addEvent(0x5dc, 0, 0, DCluster_canEmit, e); if (!strcmp(e->enemyType, "D_CLUSTER_COINS")) { Pickup *p = Core_MakePickup(e->s.x, e->s.y, "COIN"); if (p) p->time = 1, p->goToPlayer = 1, p->value = 0.5f, p->feverMS = 0xa; } else { Pickup *p = Core_MakePickup(e->s.x, e->s.y, "GEM"); if (p) p->time = 1, p->goToPlayer = 1, p->value = 3; } } base_EnemyGetDamaged(e, amount, hitVFX, kb, t); } static const EnemyVT E_DCluster = { .OnRecycle = E_DCluster_OnRecycle, .Die = E_DMask_Nop, .GetDamaged = E_DCluster_GetDamaged, .Update = E_DMask_Update, .Disappear = E_DMask_Nop }; // --- 0x185e5: DIRECTER, il nemico. Maschere in orbita (7 pool), mani (12 animazioni), attacchi per fase, la mano bianca ----------------- enum { DH_IDLE, DH_ITALIAN, DH_POINT, DH_THROW, DH_SNAP_START, DH_SNAP_DO, DH_PINCH_START, DH_PINCH_DO, DH_REVEAL_START, DH_REVEAL_DO, DH_REVIVE_START, DH_REVIVE_DO, DH_N }; static Animation DirecterHandAnims[DH_N]; typedef struct { int currentPhase, BrokenMasks, BreakEnabled, DirectHits, attack1Index, attack2Index, attack3Index, attack4Index, stageIndex, HasHands, isInvul; float breakTimer, breakDelay, TotalDamage, attackDelay, attackTimer, attacksDurationMultiplier, xOffset, yOffset, t; float radius[7], myAngle[7], scale[7]; Enemy *eye[7]; EnemyPool *pool_mask[7], *pool_skulls, *pool_eyes, *pool_gold, *pool_gems, *pool_eggs, *pool_reapersA; EnderZonePool explosions; Sprite LeftHand, RightHand, WhiteHand, heart; Animation whiteIdle; TweenRef moveTween0, moveTween3, moveTween4; int heartOn; } DirecterEX; static Enemy *TheDirecter; // il fancyBG della Machine lo usa (BG.Directer) static void DirecterE_drawStars(Sprite *s); static void Directer_hand(Sprite *h, int a) { anims_play(h, &DirecterHandAnims[a], 0); } static void DirecterE_MakeMasks(Enemy *e) { DirecterEX *d = e->x; for (int i = 0; i < 7; i++) d->eye[i] = EnemyPool_SpawnAt(d->pool_mask[i], e->s.x, e->s.y), d->eye[i]->owner = e; } static void DirecterE_clearEyes(DirecterEX *d) { for (int i = 0; i < 7; i++) if (d->eye[i] && !d->eye[i]->isDead) DMask_ScriptedDisappear(d->eye[i]); } static void DirecterE_MakeSkulls(Enemy *e) { // fase 3: cinque teschi con gli occhi 1-5 e due occhi specchiati DirecterEX *d = e->x; DirecterE_clearEyes(d); for (int i = 0; i < 7; i++) { d->eye[i] = EnemyPool_SpawnAt(i < 5 ? d->pool_skulls : d->pool_eyes, e->s.x, e->s.y); DMaskX *m = DMask_x(d->eye[i]); if (i < 5) sprite_setFrame(&m->eyes, frame_get("enemiesM", TextFormat("eyes_%d.png", i + 1))); else m->eyes.visible = 0, d->eye[i]->s.flipX = 1; // SetEyes() senza fotogramma: nascosti d->eye[i]->owner = e; } } static void DirecterE_MakeTreasures(Enemy *e) { // fase 4: gemme e oro alternati DirecterEX *d = e->x; DirecterE_clearEyes(d); for (int i = 0; i < 7; i++) d->eye[i] = EnemyPool_SpawnAt(i % 2 ? d->pool_gold : d->pool_gems, e->s.x, e->s.y), d->eye[i]->owner = e; } static void DirecterE_Shrink(Enemy *e) { // fase 5: maschere via, il Directer si rimpicciolisce e resta un cuore che pulsa DirecterEX *d = e->x; DirecterE_clearEyes(d); e->s.body.enable = 0; tweens_add((TweenConfig){ .props = { { &e->s.scaleX, &e->s.scaleY, 0 } }, .nprops = 1, .duration = 0x3e8 }); sprite_init(&d->heart, frame_get("items", "HeartRuby.png"), e->s.x, e->s.y), d->heart.depth = e->s.depth - 1, d->heartOn = 1; children_add(&d->heart); tweens_add((TweenConfig){ .props = { { &d->heart.scaleX, &d->heart.scaleY, 1.1f } }, .nprops = 1, .duration = 0x3e8, .yoyo = 1, .repeat = -1, .ease = Ease_SineInOut }); } static void DirecterE_MakeMasksBreakable(Enemy *e) { DirecterEX *d = e->x; d->breakTimer = 0, d->BreakEnabled = 1; for (int i = 0; i < 7; i++) if (d->eye[i] && !d->eye[i]->isDead) DMask_BreakOnNextAttack(d->eye[i], 1); } static void DirecterE_OnMaskBroken(Enemy *e) { DirecterEX *d = e->x; d->BrokenMasks++, d->breakTimer = 0; for (int i = 0; i < 7; i++) if (d->eye[i] && !d->eye[i]->isDead) DMask_BreakOnNextAttack(d->eye[i], 0); } static void DirecterE_handBack(void *c) { Sprite *h = c; Directer_hand(h, DH_IDLE), h->flipY = 1; } static void DirecterE_ThrowEgg(Enemy *e, Sprite *h, float x, float y) { // ThrowEggR / ThrowEggL (sic: L senza coordinate parte dalla mano destra) DirecterEX *d = e->x; Directer_hand(h, DH_THROW), h->flipY = 0; if (x) EnemyPool_SpawnAt(d->pool_eggs, x, y); else EnemyPool_SpawnAt(d->pool_eggs, d->RightHand.x, d->RightHand.y); time_addEvent(0x1f4, 0, 0, DirecterE_handBack, h); } static void DirecterE_zone(Enemy *e, float dy) { // DamagingZone_Explosions: una riga larga lo schermo che segue il giocatore in x DirecterEX *d = e->x; EnderZone *z = EnderZone_SpawnAt(&d->explosions, Core.Player->s.x, Core.Player->s.y + dy, game_width, 0x64, 0xc, 0x2710 * d->attacksDurationMultiplier, 0x1f4, SKIN_EXPLOSIONS, 0); z->lockX = 1; } static void DirecterE_shootOne(void *c) { ShootingEyes_shootOne(*(float *)&c); } static void DirecterE_ShootEyes(int n, float delay, float k) { for (int i = 0; i < n; i++) { void *kk; memcpy(&kk, &k, sizeof(float)); time_addEvent(delay * i, 0, 0, DirecterE_shootOne, kk); } } static void DirecterE_whiteKill(void *c) { // la mano bianca arriva al centro: il giocatore muore DirecterEX *d = c; Core.Player->hp = 0; Player_Die(Core.Player); tweens_add((TweenConfig){ .props = { { &d->RightHand.scaleX, &d->RightHand.scaleY, 0 }, { &d->WhiteHand.scaleX, &d->WhiteHand.scaleY, 0 } }, .nprops = 2, .duration = 0x1f4 }); } static void DirecterE_whiteStart(void *c) { Directer_hand(&((DirecterEX *)c)->RightHand, DH_PINCH_DO); } static void DirecterE_whiteUpdate(void *c) { DirecterEX *d = c; d->RightHand.x = d->WhiteHand.x - 0xc; } static void DirecterE_DragInWhiteHand(Enemy *e) { DirecterEX *d = e->x; d->WhiteHand.x = game_width + 0x20, sprite_setScale(&d->WhiteHand, 2), d->WhiteHand.visible = 1; d->RightHand.flipX = 1, d->RightHand.flipY = 0, sprite_setOrigin(&d->RightHand, 1, 0.5f), d->RightHand.x = d->WhiteHand.x - 0xc, d->RightHand.y = 0.5f * game_height - 0x20; sprite_setScale(&d->RightHand, 4), Directer_hand(&d->RightHand, DH_PINCH_START), d->RightHand.scrollFactor0 = 1, d->RightHand.visible = 1; tweens_add((TweenConfig){ .props = { { &d->RightHand.scaleX, &d->RightHand.scaleY, 1 } }, .nprops = 1, .duration = 0x3e8 }); tweens_add((TweenConfig){ .props = { { &d->WhiteHand.x, NULL, 0.5f * game_width }, { &d->RightHand.x, NULL, 0.5f * game_width } }, .nprops = 2, .duration = 0xbb8, .delay = 0x44c, .onStart = DirecterE_whiteStart, .onUpdate = DirecterE_whiteUpdate, .onComplete = DirecterE_whiteKill, .ctx = d }); } static void DirecterE_CheckAttack(Enemy *e) { DirecterEX *d = e->x; switch (d->currentPhase) { case 0: // Attack_Behaviour0 if ((int)floorf(2 * frand()) == 0) PlaySwarm(0x4e20, 0x32, "BATSWARM"); else PlaySwarm(0xea60, 0x10, "TRAINEE_Y"); break; case 1: { d->attack1Index++; DirecterE_ThrowEgg(e, &d->RightHand, 0, 0); static const char *const T[5] = { "BATSWARM", "MUD", "MILK", "SKULLINO", "TRAINEE_Y" }; int r = (int)floorf(5 * frand()); if (r == 0) PlaySwarm(0x4e20, 0x32, T[r]); else PlaySwarm(0xea60, (r == 4 ? 0x10 : 0x18) + d->attack1Index, T[r]); break; } case 2: { float x = Core.Player->s.x + 0.5f * game_width, y = Core.Player->s.y; DirecterE_ThrowEgg(e, &d->LeftHand, x, y - 0x50), DirecterE_ThrowEgg(e, &d->RightHand, x, y + 0x50); switch (d->stageIndex) { // gli sciami dello stage che scorre sullo sfondo (attack2Index resta 0, sic) case 0: PlaySwarm(0x4e20, 0x32, "BATSWARM"), PlaySwarm(0xea60, 0x18 + d->attack2Index, "ZOMBIE"); break; case 1: PlaySwarm(0xea60, 0xc, "MUMMY"), PlaySwarm(0xea60, 0xc + d->attack2Index, "GHOST"); break; case 2: PlaySwarm(0xea60, 0xc, "LIZARD1_2"), PlaySwarm(0xea60, 0x18 + d->attack2Index, "FISHMAN_1"); break; case 3: PlaySwarm(0xea60, 0x18, "SKULOROSSO"), PlaySwarm(0xea60, 0xc + d->attack2Index, "DULL0"); break; case 4: PlaySwarm(0xea60, 0x10 + d->attack2Index, "TRAINEE_Y"), PlaySwarm(0xea60, 0x18, "SKELETON"); break; } break; } case 3: d->attack3Index++; if (Core.Player->revivals >= 1 && d->attack3Index > 3) d->attack3Index = 0, DirecterE_DragInWhiteHand(e); switch ((int)floorf(5 * frand())) { case 0: DirecterE_ShootEyes(5, 0x3c, 1); break; case 1: DirecterE_zone(e, -0x64), DirecterE_zone(e, 0x64); break; case 2: DirecterE_ShootEyes(0xa, 0x1e, 1); break; case 3: DirecterE_ShootEyes(0x14, 0x64, 0.5f); break; case 4: DirecterE_zone(e, -0xc8), DirecterE_zone(e, 0xc8); break; } PlaySwarm(0xea60, 0xc + (d->attack3Index < 0xc ? d->attack3Index : 0xc), "D_WEAK_EYE"); break; case 4: { if (!po_is("HasSeenFinalFireworks") && d->attack4Index < 1) DirecterE_DragInWhiteHand(e); d->attack4Index++; if (Core.Enemies.n > 0x6c) return; Vector2 pt[5]; // Ellipse(player, 1.4 w, 1.4 h).getPoints(5), rimescolati for (int i = 0; i < 5; i++) pt[i] = (Vector2){ Core.Player->s.x + 0.7f * game_width * cosf(2 * PI * i / 5), Core.Player->s.y + 0.7f * game_height * sinf(2 * PI * i / 5) }; for (int i = 4; i > 0; i--) { int j = (int)floorf(frand() * (i + 1)); Vector2 t = pt[i]; pt[i] = pt[j], pt[j] = t; } for (int i = 0; i < 5; i++) { Enemy *r = EnemyPool_SpawnAt(d->pool_reapersA, pt[i].x, pt[i].y); if (r) r->isCullable = 0, r->isTeleportOnCull = 1; } break; } } } static float DirecterE_approach(float v, float t, float s) { return v < t ? fminf(v + s, t) : fmaxf(v - s, t); } static void DirecterE_moveStart(void *c) { DirecterEX *d = c; d->xOffset = d->currentPhase >= 4 ? -0.3f * game_width : d->currentPhase == 3 ? -0.4f * game_width : -0.45f * game_width, d->yOffset = 8; } static void DirecterE_Movement(Enemy *e, float delta) { // Movement_Behaviour0 / 3 / 4: insegue in y, sta a sinistra del giocatore in x con un'oscillazione DirecterEX *d = e->x; if (d->currentPhase <= 2 && !tween_get(d->moveTween0)) d->moveTween0 = tweens_add((TweenConfig){ .props = { { &d->xOffset, NULL, -0.2f * game_width } }, .nprops = 1, .duration = 0x7d0, .repeat = -1, .yoyo = 1, .ease = Ease_SineInOut, .onStart = DirecterE_moveStart, .ctx = d }); if (d->currentPhase == 3 && !tween_get(d->moveTween3)) tween_stop(d->moveTween0), d->moveTween3 = tweens_add((TweenConfig){ .props = { { &d->xOffset, NULL, -0.25f * game_width }, { &d->yOffset, NULL, -8 } }, .nprops = 2, .duration = 0x3e8, .repeat = -1, .yoyo = 1, .ease = Ease_SineInOut, .onStart = DirecterE_moveStart, .ctx = d }); if (d->currentPhase == 4 && !tween_get(d->moveTween4)) tween_stop(d->moveTween3), d->moveTween4 = tweens_add((TweenConfig){ .props = { { &d->xOffset, NULL, -0.2f * game_width }, { &d->yOffset, NULL, -8 } }, .nprops = 2, .duration = 0x7d0, .repeat = -1, .yoyo = 1, .ease = Ease_SineInOut, .onStart = DirecterE_moveStart, .ctx = d }); if (d->currentPhase > 4) return; float s = PlayerPxSpeed * Core.Player->moveSpeed * 0.9f * (0.001f * delta); e->s.y = DirecterE_approach(e->s.y, Core.Player->s.y, s), e->s.x = Core.Player->s.x + d->xOffset; } static void E_Directer_OnRecycle(Enemy *e) { if (!e->x) { // costruttore DirecterEX *d = e->x = calloc(1, sizeof(DirecterEX)); d->breakDelay = 0x3e8, d->attackDelay = 0x1388, d->attacksDurationMultiplier = 1, d->HasHands = 1; static const float A[7] = { 0, 0.23f, 0.41f, 0.61f, 0.71f, 0.79f, 0.83f }, S[7] = { 2, 1.75f, 1.5f, 1.25f, 1, 0.75f, 0.5f }, S2[7] = { 0.5f, 0.75f, 1, 1.25f, 1.5f, 1.75f, 2 }; static const float D[7] = { 0x3f1, 0x4c1, 0x5d1, 0x653, 0x745, 0x833, 0x925 }; for (int i = 0; i < 7; i++) { d->radius[i] = 0x40, d->myAngle[i] = 2 * PI * A[i], d->scale[i] = S[i]; tweens_add((TweenConfig){ .props = { { &d->radius[i], NULL, 0x20 } }, .nprops = 1, .duration = D[i], .yoyo = 1, .repeat = -1 }); tweens_add((TweenConfig){ .props = { { &d->scale[i], NULL, S2[i] } }, .nprops = 1, .duration = D[i], .yoyo = 1, .repeat = -1 }); } sprite_init(&d->WhiteHand, frame_get("enemies3", "WhiteHand_i01.png"), game_width + 0x20, 0.5f * game_height); // MakeWhiteHand make_anim(&d->whiteIdle, "enemies3", "WhiteHand_i0", 1, 4, 0, 0x3c, -1); anims_play(&d->WhiteHand, &d->whiteIdle, 0); sprite_setOrigin(&d->WhiteHand, 0.5f, 1), sprite_setScale(&d->WhiteHand, 2), d->WhiteHand.scrollFactor0 = 1, d->WhiteHand.depth = 0x2710; children_add(&d->WhiteHand); static const struct { const char *p; int a, b, rep; } HA[DH_N] = { { "hand_", 1, 4, -1 }, { "hand_italian_", 1, 2, -1 }, { "hand_point_", 1, 2, -1 }, { "hand_throw_", 1, 4, 0 }, { "hand_snap_", 1, 3, -1 }, { "hand_snap_", 4, 5, 0 }, { "hand_pinch_", 1, 2, -1 }, { "hand_pinch_", 3, 4, 0 }, { "hand_reveal_", 1, 2, -1 }, { "hand_reveal_", 3, 4, 0 }, { "hand_revive_", 1, 2, -1 }, { "hand_revive_", 3, 7, 0 } }; for (int i = 0; i < DH_N; i++) make_anim(&DirecterHandAnims[i], "enemiesM", HA[i].p, HA[i].a, HA[i].b, 2, 8, HA[i].rep); for (int k = 0; k < 2; k++) { Sprite *h = k ? &d->RightHand : &d->LeftHand; sprite_init(h, frame_get("enemiesM", "hand_01.png"), e->s.x, e->s.y); sprite_setOrigin(h, k ? 0 : 1, 0.5f), h->flipX = k; Directer_hand(h, DH_ITALIAN); children_add(h); } static const char *const P[7] = { "D_MASK_SUN", "D_MASK_MOON", "D_MASK_CITY", "D_MASK_WINDS", "D_MASK_VOLCANO", "D_MASK_GREED", "D_MASK_VOID" }; for (int i = 0; i < 7; i++) d->pool_mask[i] = EnemyPool_new(P[i]); d->pool_skulls = EnemyPool_new("D_SKULL"), d->pool_eyes = EnemyPool_new("D_EYE"), d->pool_gold = EnemyPool_new("D_CLUSTER_COINS"), d->pool_gems = EnemyPool_new("D_CLUSTER_GEMS"); d->pool_eggs = EnemyPool_new("BULLET_EGG"), d->pool_reapersA = EnemyPool_new("D_WEAK_REAPER_A"); base_EnemyOnRecycle(e); // OnRecycle prima di MakeMasks: le maschere nascono sul Directer e->isCullable = 0, sprite_setOrigin(&e->s, 0.5f, 0.5f), sprite_setScale(&e->s, 5); body_setCircle(&e->s.body, 0xc, 3, 3); DirecterE_MakeMasks(e); e->s.draw = DirecterE_drawStars; TheDirecter = e; return; } base_EnemyOnRecycle(e); e->isCullable = 0, sprite_setOrigin(&e->s, 0.5f, 0.5f), sprite_setScale(&e->s, 5), body_setCircle(&e->s.body, 0xc, 3, 3); } static void E_Directer_Update(Enemy *e) { DirecterEX *d = e->x; float delta = Enemies_delta; d->t += delta; DirecterE_Movement(e, delta); d->attackTimer += delta; if (d->attackTimer >= d->attackDelay) d->attackTimer = 0, DirecterE_CheckAttack(e); if (d->BreakEnabled && (d->breakTimer += delta) > d->breakDelay) d->breakTimer = 0, DirecterE_MakeMasksBreakable(e); e->s.depth = d->currentPhase >= 4 ? 0 : -game_height; for (int i = 0; i < 7; i++) if (d->eye[i]) d->eye[i]->s.depth = 0x49 + d->eye[i]->s.y - Core.Player->s.y, sprite_setScale(&d->eye[i]->s, d->scale[i]); if (d->HasHands) d->LeftHand.x = e->s.x - 0x30, d->LeftHand.y = e->s.y, d->RightHand.x = e->s.x + 0x30, d->RightHand.y = e->s.y, d->LeftHand.depth = d->RightHand.depth = e->s.depth + 2; for (int i = 0; i < 7; i++) d->myAngle[i] += PI / 0x168 * delta * 0.25f; static const int RY[7] = { 1, 3, 5, 0, 2, 4, 6 }; for (int i = 0; i < 7; i++) if (d->eye[i]) d->eye[i]->s.x = e->s.x + 0x6c * cosf(d->myAngle[i]), d->eye[i]->s.y = -0x40 + e->s.y + sinf(d->myAngle[(i + 1) % 7]) * d->radius[RY[i]]; for (int i = 0; i < d->explosions.nspawned; i++) EnderZone_Update(d->explosions.spawned[i], delta); EyeBlasts_Update(delta); sprite_animsUpdate(&d->LeftHand, delta), sprite_animsUpdate(&d->RightHand, delta), sprite_animsUpdate(&d->WhiteHand, delta); if (d->heartOn) d->heart.x = e->s.x, d->heart.y = e->s.y; } static void E_Directer_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *t) { DirecterEX *d = e->x; if (d->isInvul) return; d->TotalDamage += amount, d->DirectHits++; base_EnemyGetDamaged(e, amount, hitVFX, kb, t); } static const EnemyVT E_Directer = { .OnRecycle = E_Directer_OnRecycle, .Die = E_DMask_Nop, .GetDamaged = E_Directer_GetDamaged, .Update = E_Directer_Update, .Disappear = E_DMask_Nop }; // TriggerPhase1-5 (le chiama il fancyBG della Machine su OnPhaseN) static void DirecterE_handsGone(void *c) { // AutoPositionHands: dopo la fase 2 le mani stanno sul bordo destro dello schermo DirecterEX *d = c; d->HasHands = 0; d->RightHand.flipX = 0, sprite_setOrigin(&d->RightHand, 1, 0.5f), d->LeftHand.scrollFactor0 = d->RightHand.scrollFactor0 = 1; d->LeftHand.x = game_width, d->LeftHand.y = 0.5f * game_height - 0x50, d->RightHand.x = game_width, d->RightHand.y = 0.5f * game_height + 0x50; d->LeftHand.depth = d->RightHand.depth = game_height; tweens_add((TweenConfig){ .props = { { &d->LeftHand.scaleX, &d->LeftHand.scaleY, 1 }, { &d->RightHand.scaleX, &d->RightHand.scaleY, 1 } }, .nprops = 2, .duration = 0x1f4 }); } static void DirecterE_TriggerPhase(Enemy *e, int n) { DirecterEX *d = e->x; d->currentPhase = n; switch (n) { case 1: d->attackDelay = 0x1388; Directer_hand(&d->LeftHand, DH_IDLE), Directer_hand(&d->RightHand, DH_IDLE), d->LeftHand.flipY = d->RightHand.flipY = 1; break; case 2: d->attackDelay = 0x1388; tweens_add((TweenConfig){ .props = { { &d->LeftHand.scaleX, &d->LeftHand.scaleY, 0 }, { &d->RightHand.scaleX, &d->RightHand.scaleY, 0 } }, .nprops = 2, .duration = 0x1f4, .onComplete = DirecterE_handsGone, .ctx = d }); break; case 3: d->DirectHits = 0; DirecterE_MakeSkulls(e); tweens_add((TweenConfig){ .props = { { &d->LeftHand.scaleX, &d->LeftHand.scaleY, 0 }, { &d->RightHand.scaleX, &d->RightHand.scaleY, 0 } }, .nprops = 2, .duration = 0x1f4 }); break; case 4: d->attackDelay = 0x1f4, DirecterE_MakeTreasures(e); break; case 5: DirecterE_Shrink(e); break; } } static void DStars_draw(Sprite *s, float t); static void DirecterE_drawStars(Sprite *s) { DStars_draw(s, ((DirecterEX *)((Enemy *)s->owner)->x)->t); } static Texture2D img_texture(const char *key); static float lerp01(float t, float start, float dur); static float ease_sine_inout(float k); static int Machine_colorOn; static void DM_init(void), DM_Update(float delta); static void Machine_devStart(void *c), Machine_Phase5Update(float delta); // --- MACHINE (0x3f1d): Eudaimonia M. Cerchi che girano, finestre, fuoco dal basso, il Directer; le fasi le guida il DirecterManager --- // Le texture dummy1..5 (2048x2048) si caricano una alla volta: tutte insieme sarebbero ~80 MB sulla Vita. static struct { int HasMirror, HasTrumpet, HasJubilee, HasUsedMirror, HasUsedTrumpet, canContinueStageZoom, stageKeyIndex; float cameraZoom, t; Sprite overlay; // snap, uova e reliquie: disegno a schermo sopra tutto Animation snapStart, snapDo; Sprite snap; int snapOn; float snapAt, snapAlpha; Sprite circles[8]; // sSun, sMoon, sWorld, sCentral (ombre tinte 0x80808), Sun, Moon, World, Central Sprite windows[40]; int nWindows; ParticleManager *pfx; ParticleEmitter *fire1, *fire2; Pickup *directer_pickup; TileSprite bgtile; int dummyLoaded; // indice + 1 della dummy in bgtile.tex (0 = nessuna o hStars1) } Machine; static void TileSprite_draw(Sprite *s); static void Machine_SetBGTexture(const char *key) { // bgtile.setTexture(key): dummyN da img/ una alla volta, il resto con img_texture if (Machine.dummyLoaded) UnloadTexture(Machine.bgtile.tex), Machine.dummyLoaded = 0; if (!strncmp(key, "dummy", 5)) { Machine.bgtile.tex = LoadTexture(vs_path(TextFormat("img/%s.png", key))); SetTextureWrap(Machine.bgtile.tex, TEXTURE_WRAP_REPEAT); Machine.dummyLoaded = atoi(key + 5); } else Machine.bgtile.tex = img_texture(key); } static void Machine_overlayDraw(Sprite *s) { (void)s; SnapFX_draw(Machine.t); if (Machine.snapOn) Machine.snap.alpha = Machine.snapAlpha, scene_render_one(&Machine.snap, (Shader){ 0 }); } static void Machine_SnapDo(void *c) { // dopo 500 ms: snap_do, GameOver acuto (detune 1000) e le uova (void)c; anims_play(&Machine.snap, &Machine.snapDo, 0); Sound_PlaySound("BGM_GameOver", 1.6f, 1, 1000, 0, 0); SnapFX_eggs(Machine.t); Machine.snapAt = Machine.t + 0x258 + 0xa * SnapFX.nEggs; // poi alpha 0 in 300 ms } static void Machine_Snap_Eggs(void) { if (!po_is("SelectedGoldenEggs")) return; int n = EggManager_RemoveBonuses(); if (n <= 0) return; SnapFX.nEggs = n < 0x1f4 ? n : 0x1f4; Machine.snapOn = 1, Machine.snapAlpha = 1, Machine.snapAt = -1; anims_play(&Machine.snap, &Machine.snapStart, 0); time_addEvent(0x1f4, 0, 0, Machine_SnapDo, NULL); } static void Machine_RemovePowerUps(void) { static const char *const R[][2] = { { "RELIC_TEAR", "Tear.png" }, { "RELIC_RANDOMAZZO", "Tarots.png" }, { "RELIC_TRUMPET", "trumpet.png" }, { "RELIC_MIRROR", "mirror.png" }, { "RELIC_GGOSPEL", "ggospel.png" }, { "RELIC_GLASSMASK", "glassmask.png" }, { "RELIC_BANGER", "banger.png" } }; SnapFX.nPowers = 0, SnapFX.powersAt = 0; for (int i = 0; i < 7; i++) if (po_has("CollectedItems", R[i][0])) SnapFX.powers[SnapFX.nPowers++] = R[i][1]; } static void Machine_MakeCircles(float x, float y) { // ombre (y + 16, tinta 0x80808) e cerchi; sole, luna e mondo girano in 12, 24 e 36 s static const char *const F[4] = { "sun.png", "moon.png", "world.png", "center.png" }; for (int i = 0; i < 8; i++) { Sprite *c = &Machine.circles[i]; sprite_init(c, frame_get("background6", F[i % 4]), x, i < 4 ? y + 0x10 : y); c->depth = i < 4 || i == 7 ? -0xbb9 : -0xbb8; if (i < 4) sprite_setTintFill(c, 0x80808); children_add(c); } } static void Machine_MakeWindows(void) { // finestre nere (shop) che si aprono in 1 s e si ripetono attorno al giocatore int cols = 1 + (int)ceilf(game_width / 128.0f), rows = 1 + (int)ceilf(game_height / 358.0f); static const char *const WF[3] = { "window2.png", "window4.png", "window5.png" }; Machine.nWindows = 0; for (int a = 0; a < cols; a++) for (int b = 0; b < rows && Machine.nWindows < 40; b++) { Sprite *w = &Machine.windows[Machine.nWindows++]; sprite_init(w, frame_get("shop", WF[(int)floorf(frand() * 3)]), 0x80 * a + 0x40, 0x166 * b); sprite_setOrigin(w, 0, 0), w->tint = 0, w->flipX = frand() >= 0.5f, w->flipY = frand() >= 0.5f, w->alpha = 0, w->scaleX = -0.1f, w->depth = -0x1324; children_add(w); tweens_add((TweenConfig){ .props = { { &w->alpha, NULL, 1 }, { &w->scaleX, NULL, 1 } }, .nprops = 2, .duration = 0x3e8 }); } } static ParticleEmitter *Machine_fire(int second) { // MakeFireEmitters: fiamme dal fondo dello schermo (colours3/4, poi 7/8) EmitterConfig c = { .frames = { frame_get("shop", "colours3.png"), frame_get("shop", "colours4.png") }, .nframes = 2, .xOffset = ERND(0, game_width), .lifespan = EOP(0x1388), .nonRadial = 1, .speed = EOP(0), .speedY = ERND(-0x12c, -0x64), .alpha = second ? ERANGE(1, 0) : ERANGE(0.9f, 0.8f), .scale = EOP(1), .scaleY = ERANGE(1, 2), .hasScaleY = 1, .quantity = 1, .on = 1, .flowEveryFrame = !second, .frequency = second ? 0x12c : 0, .blendAdd = second }; ParticleEmitter *e = particles_createEmitter(Machine.pfx, c); e->x = 0, e->y = game_height + 0x150; return e; } static void Machine_Create(void) { // costruttore + Create memset(&Machine, 0, sizeof(Machine)); SnapFX_reset(); Machine.canContinueStageZoom = 1, Machine.cameraZoom = 1; Machine.HasMirror = po_has("CollectedItems", "RELIC_MIRROR"), Machine.HasTrumpet = po_has("CollectedItems", "RELIC_TRUMPET"); Machine.HasJubilee = po_has("UnlockedWeapons", "JUBILEE"), Machine.HasUsedMirror = po_is("HasUsedMirror"), Machine.HasUsedTrumpet = po_is("HasUsedTrumpet"); sprite_init(&Machine.snap, frame_get("background6", "hand_snap_01.png"), game_width, game_height + 0x10); // in basso a destra, scala 3 sprite_setOrigin(&Machine.snap, 1, 1), sprite_setScale(&Machine.snap, 3), Machine.snap.scrollFactor0 = 1; make_anim(&Machine.snapStart, "background6", "hand_snap_", 1, 3, 2, 8, 0); make_anim(&Machine.snapDo, "background6", "hand_snap_", 4, 5, 2, 8, 0); // semplificazione: le Selected* del costruttore si scrivono qui (Create); la partita le ha gia' lette, contano per il salvataggio e il dopo po_sets("SelectedStage", "MACHINE"), po_sets("SelectedBGM", "BGM_Machine"), po_sets("SelectedBGMMod", Machine.HasMirror && Machine.HasTrumpet && !Machine.HasJubilee ? "Forsaken" : "Normal"); po_setb("SelectedHurry", 0), po_setb("SelectedMazzo", 0), po_setb("SelectedHyper", 0), po_setb("SelectedInverse", 0), po_setb("SelectedReapers", 0), po_setb("SelectedRandomEvents", 0); sprite_init(&Machine.overlay, NULL, 0, 0), Machine.overlay.draw = Machine_overlayDraw, Machine.overlay.scrollFactor0 = 1, Machine.overlay.depth = 0x2710; children_add(&Machine.overlay); Machine_RemovePowerUps(); Machine_Snap_Eggs(); Machine_MakeCircles(0x3f4, 0x190); Machine.pfx = particles_add(), Machine.pfx->s.depth = -0x1388, Machine.pfx->scrollFactor0 = 1; Machine.fire1 = Machine_fire(0), Machine.fire2 = Machine_fire(1); Machine_MakeWindows(); Machine.directer_pickup = Core_MakeStagePickup(0x3f4, 0x208, "DIRECTER", NULL); // MakeDirecter Sound_StopMusic(); // tilingBG.MakeBackground('dummy1'): tileSprite a schermo pieno, invisibile fino a ZoomOverStages sprite_init(&Machine.bgtile.s, NULL, 0.5f * game_width, 0.5f * game_height); Machine.bgtile.s.draw = TileSprite_draw, Machine.bgtile.s.scrollFactor0 = 1, Machine.bgtile.s.depth = -0xc3500, Machine.bgtile.s.tint = 0xffffff, Machine.bgtile.s.visible = 0; sprite_setScale(&Machine.bgtile.s, PixelScale), Machine.bgtile.w = game_width, Machine.bgtile.h = game_height, Machine.bgtile.tileScaleX = Machine.bgtile.tileScaleY = 1; Machine_SetBGTexture("dummy1"); children_add(&Machine.bgtile.s); TheDirecter = NULL, Machine_colorOn = 0; DM_init(); // new DirecterManager if (getenv("VS_DIRECTER")) time_addEvent(0x3e8, 0, 0, Machine_devStart, NULL); } static void Machine_Update(float delta) { Machine.t += delta; float t = Machine.t; static const float RD[3] = { 0x2ee0, 0x5dc0, 0x8ca0 }; // tween angle 0 -> 360, repeat -1 for (int i = 0; i < 3; i++) Machine.circles[i].angle = Machine.circles[4 + i].angle = 360 * fmodf(t, RD[i]) / RD[i]; if (Machine.snapOn) { sprite_animsUpdate(&Machine.snap, delta); if (Machine.snapAt >= 0) Machine.snapAlpha = 1 - lerp01(t, Machine.snapAt, 0x12c); } float bw = 0x80 * (1 + ceilf(game_width / 128.0f)), bh = 0x166 * (1 + ceilf(game_height / 358.0f)); // finestre: giro attorno al giocatore float l = Core.Player->s.x - 0.5f * game_width, tp = Core.Player->s.y - 0.5f * game_height, r = Core.Player->s.x + 0.5f * game_width, b = Core.Player->s.y + 0.5f * game_height; for (int i = 0; i < Machine.nWindows; i++) { Sprite *w = &Machine.windows[i]; if (w->x < l) w->x += bw; if (w->x > r) w->x -= bw; if (w->y < tp) w->y += bh; if (w->y > b) w->y -= bh; } float sf = 0.5f / Machine.bgtile.tileScaleX; // tilingBG.Update: speedFactor = 0.5 / tileScaleX Machine.bgtile.tilePositionX = sf * Core.Player->s.x, Machine.bgtile.tilePositionY = sf * Core.Player->s.y; DM_Update(delta); Machine_Phase5Update(delta); } static int Machine_HasMovingBG(void) { return 1; } static void Machine_DisableMovingBackground(void) {} // (sic) vuota static void DM_Cleanup(void), Machine_Phase5Destroy(void); static void Machine_OnDestroy(void) { // Core.SFXVolumeFactor = 1, stopCheckingMinutes = false, DirecterManager.Cleanup, texture dummy via SFXVolumeFactor = 1; DM_Cleanup(); if (Machine.dummyLoaded) UnloadTexture(Machine.bgtile.tex), Machine.dummyLoaded = 0; Machine_Phase5Destroy(); } // --- Machine: le fasi sullo sfondo (OnPhaseN, RemoveTileset, ZoomOverStages, RemoveCircles, TurnBGToFire, StartColorChangingBackground) --- static Sprite Machine_colorBG; static float Machine_colorBGValue; static int Machine_colorOn; static void Machine_OnPhase(int n) { if (TheDirecter) DirecterE_TriggerPhase(TheDirecter, n); } static void Machine_SwapDirecters(void) { // il Directer vero al posto di quello da raccogliere static EnemyPool *directerPool; if (!directerPool) directerPool = EnemyPool_new("DIRECTER"); EnemyPool_SpawnAt(directerPool, 0x3f4, 0x208); if (Machine.directer_pickup) Pickup_DeSpawn(Machine.directer_pickup), Machine.directer_pickup = NULL; } static void Machine_RemoveWalls(void *c) { (void)c; TilingTileset *tt = Core.Stage->tilingTileset; if (tt && tt->MainMap) tilemap_removeTilesWithin(tt->MainMap, NULL, 0, 0, 0x40, 0x40); } static void Machine_RemoveTileset(void) { Core.Stage->n_DestructibleLocations = 0; TilingTileset *tt = Core.Stage->tilingTileset; if (!tt) return; for (int c = 0; c < tt->mapsAmount; c++) for (int i = 0; i < tt->layerContainers[c].n; i++) tweens_add((TweenConfig){ .props = { { &tt->layerContainers[c].layers[i]->s.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x3e8, .onComplete = c == 0 && i == 0 ? Machine_RemoveWalls : NULL }); } static void Machine_ZoomOverStages(void); static void Machine_zoomNext(void *c) { (void)c; if (!Machine.canContinueStageZoom) return; emitter_stop(Machine.fire1), emitter_stop(Machine.fire2); Machine.stageKeyIndex = (Machine.stageKeyIndex + 1) % 5; Machine_ZoomOverStages(); } static void Machine_zoomDone(void *c) { // a fine giro: fiamme piu' veloci per 1 s, poi lo stage dopo (void)c; if (!Machine.canContinueStageZoom) return; Machine.fire1->c.speedY = Machine.fire2->c.speedY = ERND(-0x258, -0x1f4); emitter_start(Machine.fire1), emitter_start(Machine.fire2); time_addEvent(0x3e8, 0, 0, Machine_zoomNext, NULL); } static TweenRef Machine_stageZoomTween; static void Machine_ZoomOverStages(void) { Machine_SetBGTexture(TextFormat("dummy%d", Machine.stageKeyIndex + 1)); Machine.bgtile.tileScaleX = Machine.bgtile.tileScaleY = 2, Machine.bgtile.s.visible = 1; if (TheDirecter) ((DirecterEX *)TheDirecter->x)->stageIndex = Machine.stageKeyIndex; tween_stop(Machine_stageZoomTween); Machine_stageZoomTween = tweens_add((TweenConfig){ .props = { { &Machine.bgtile.tileScaleX, &Machine.bgtile.tileScaleY, 0.5f } }, .nprops = 1, .yoyo = 1, .duration = 0x2710, .ease = Ease_SineInOut, .onComplete = Machine_zoomDone }); } static void Machine_hideCentral(void *c) { (void)c; Machine.circles[7].visible = 0; } static void Machine_RemoveCircles(void *c) { (void)c; for (int i = 4; i < 7; i++) { tweens_add((TweenConfig){ .props = { { &Machine.circles[i].scaleX, &Machine.circles[i].scaleY, 7 } }, .nprops = 1, .duration = 0x7d0 }); tweens_add((TweenConfig){ .props = { { &Machine.circles[i].alpha, NULL, 0 } }, .nprops = 1, .duration = 0x1f4, .delay = 0x7d0 }); tweens_add((TweenConfig){ .props = { { &Machine.circles[i - 4].alpha, NULL, 0 } }, .nprops = 1, .duration = 0x1f4 }); } tweens_add((TweenConfig){ .props = { { &Machine.circles[7].scaleX, &Machine.circles[7].scaleY, 0 }, { &Machine.circles[3].scaleX, &Machine.circles[3].scaleY, 0 } }, .nprops = 2, .duration = 0x3e8, .onComplete = Machine_hideCentral }); } static void Machine_firesFast(void *c) { // dopo 1 s: fiamme ferme e quelle vive su a 600 (void)c; emitter_stop(Machine.fire1), emitter_stop(Machine.fire2); for (int k = 0; k < 2; k++) { ParticleEmitter *e = k ? Machine.fire2 : Machine.fire1; for (int i = 0; i < e->n; i++) e->alive[i].vy = -0x258; } } static void Machine_TurnBGToFire(void) { Machine.canContinueStageZoom = 0; for (int k = 0; k < 2; k++) { ParticleEmitter *e = k ? Machine.fire2 : Machine.fire1; e->c.frames[0] = frame_get("shop", "colours7.png"), e->c.frames[1] = frame_get("shop", "colours8.png"), e->c.speedY = EOP(-0x12c); emitter_start(e); } } static void Machine_colorIn(void *c) { (void)c; Machine_SetBGTexture("hStars1"); } // le dummy via static void Machine_colorDraw(Sprite *s) { if (!Machine_colorOn || s->alpha <= 0) return; Machine_colorBGValue += 0.01f; // addCounter onUpdate: a ogni frame unsigned col = po_is("FlashingVFXEnabled") ? ((unsigned)(0xc8 * fabsf(sinf(Machine_colorBGValue))) << 16) | ((unsigned)(0xc8 * fabsf(cosf(0.5f * Machine_colorBGValue))) << 8) | (unsigned)(0xc8 + 0x23 * fabsf(cosf(Machine_colorBGValue))) : 0x2266dd; BeginBlendMode(BLEND_ADDITIVE); DrawRectangle(0, 0, game_width, game_height, hexc(col, s->alpha)); EndBlendMode(); } static void Machine_StartColorChangingBackground(void) { for (int k = 0; k < 2; k++) { ParticleEmitter *e = k ? Machine.fire2 : Machine.fire1; e->c.frames[0] = frame_get("shop", "colours3.png"), e->c.frames[1] = frame_get("shop", "colours4.png"); } sprite_init(&Machine_colorBG, NULL, 0, 0); Machine_colorBG.draw = Machine_colorDraw, Machine_colorBG.scrollFactor0 = 1, Machine_colorBG.depth = -0x1387, Machine_colorBG.alpha = 0; children_add(&Machine_colorBG); Machine_colorOn = 1, Machine_colorBGValue = 0; tweens_add((TweenConfig){ .props = { { &Machine_colorBG.alpha, NULL, 1 } }, .nprops = 1, .duration = 0x7d0, .onComplete = Machine_colorIn }); } // --- 0x17e0c: DirecterManager. Sei musiche (Phase0-5) in coda, i passaggi agganciati alle battute con setTimeout; le soglie di Update // (livello, tempo, maschere rotte) alzano currentPhase e il cambio vero avviene al prossimo punto della musica. setTimeout va avanti // anche a gioco in pausa: qui timer a tempo reale, aggiornati da Sound_Update; la musica su canali propri (OmniScene.sound). static struct { int active, currentPhase, started[6]; float combatTimer, volume, now; struct { float at; int kind, i, ph; } timers[8]; int ntimers; struct { Music m; int on, stopAtEnd; float vol, from, to, t, dur; } ch[3]; int cur; } DM; static const float DM_delays[6][4] = { { 0 }, { 0x22ef, 0x45de, 0x68ad, 0x8b95 }, { 0x45bc, 0x8ba0, 0xae8a }, { 0x28b0, 0x5162, 0xa752 }, { 0x8ba0 }, { 0 } }; static const int DM_ndelays[6] = { 0, 4, 3, 3, 1, 0 }; enum { DMT_PHASE0, DMT_MID, DMT_LAST }; static int DM_play(const char *key, int loop, float fromVol) { int k = -1; for (int i = 0; i < 3; i++) if (!DM.ch[i].on) { k = i; break; } if (k < 0) k = (DM.cur + 1) % 3, au_music_stop(&DM.ch[k].m), Music_close(&DM.ch[k].m); int si = Sound_index(key); if (si < 0 || !IsAudioDeviceReady()) return -1; Music_open(&DM.ch[k].m, vs_path(TextFormat("sfx/%s", SOUND_FILES[si].file))); DM.ch[k].m.looping = loop; DM.ch[k].on = 1, DM.ch[k].stopAtEnd = 0, DM.ch[k].vol = fromVol, DM.ch[k].dur = 0; au_music_volume(&DM.ch[k].m, fromVol); PlayMusicStream(DM.ch[k].m); au_music_add(&DM.ch[k].m); return DM.cur = k; } static void DM_fade(int k, float to, float dur, int stop) { if (k < 0 || !DM.ch[k].on) return; DM.ch[k].from = DM.ch[k].vol, DM.ch[k].to = to, DM.ch[k].t = 0, DM.ch[k].dur = dur, DM.ch[k].stopAtEnd = stop; } static void DM_RemoveTimers(void) { DM.ntimers = 0; } static void DM_timer(float ms, int kind, int i, int ph) { if (DM.ntimers < 8) DM.timers[DM.ntimers++] = (typeof(DM.timers[0])){ DM.now + ms, kind, i, ph }; } static void DM_ChangePhase(void); static void DM_StartPhase1(void); static void DM_CheckTime1(int i, int ph, int fadeIn) { int k = DM_play(TextFormat("Phase%d", i), i < 5, fadeIn && i < 5 ? 0 : DM.volume); if (fadeIn && i < 5) DM_fade(k, DM.volume, 0x352, 0); // da 0 al volume in 850 ms (Circ.easeIn) if (i >= 5) return; for (int j = 0; j < DM_ndelays[i]; j++) DM_timer(DM_delays[i][j], j < DM_ndelays[i] - 1 ? DMT_MID : DMT_LAST, i, ph); } static void DM_fire(int kind, int i, int ph) { int k = DM.cur; if (kind == DMT_PHASE0) { DM_fade(k, 0, 0x44c, 1); DM_StartPhase1(); return; } if (DM.currentPhase >= ph) { // si passa al pezzo dopo (onStart: ChangePhase e CheckTime1, nell'ordine dell'originale) DM_RemoveTimers(); DM_fade(k, 0, kind == DMT_MID ? 0x4b0 : 0x352, 1); if (kind == DMT_MID) DM_ChangePhase(), DM_CheckTime1(i + 1, ph + 1, 1); else DM_CheckTime1(i + 1, ph + 1, 1), DM_ChangePhase(); } else if (kind == DMT_LAST) { // fine del giro senza i requisiti: lo stesso pezzo da capo, senza dissolvenza in entrata DM_RemoveTimers(); DM_fade(k, 0, 0x352, 1); DM_CheckTime1(i, ph, 0); } } static void DM_Tick(float delta) { // tempo reale: timer e dissolvenze (Circ.easeIn), anche a gioco in pausa if (!DM.active) return; DM.now += delta; for (int n = 0; n < DM.ntimers;) { if (DM.now >= DM.timers[n].at) { typeof(DM.timers[0]) t = DM.timers[n]; DM.timers[n] = DM.timers[--DM.ntimers]; DM_fire(t.kind, t.i, t.ph); n = 0; // DM_fire puo' aver svuotato o riempito la lista } else n++; } for (int k = 0; k < 3; k++) { if (!DM.ch[k].on) continue; if (DM.ch[k].dur > 0) { DM.ch[k].t += delta; float p = fminf(1, DM.ch[k].t / DM.ch[k].dur), e = 1 - sqrtf(1 - p * p); DM.ch[k].vol = DM.ch[k].from + (DM.ch[k].to - DM.ch[k].from) * e; au_music_volume(&DM.ch[k].m, DM.ch[k].vol); if (p >= 1) { DM.ch[k].dur = 0; if (DM.ch[k].stopAtEnd) { au_music_stop(&DM.ch[k].m), Music_close(&DM.ch[k].m), DM.ch[k].on = 0; continue; } } } au_music_update(&DM.ch[k].m); if (!DM.ch[k].m.looping && !IsMusicStreamPlaying(DM.ch[k].m)) Music_close(&DM.ch[k].m), DM.ch[k].on = 0; } } static void DM_Cleanup(void) { for (int k = 0; k < 3; k++) if (DM.ch[k].on) au_music_stop(&DM.ch[k].m), Music_close(&DM.ch[k].m), DM.ch[k].on = 0; DM_RemoveTimers(); DM.active = 0; } static void DM_init(void) { // costruttore (in Machine.Create) DM_Cleanup(); memset(&DM, 0, sizeof(DM)); DM.active = 1, DM.currentPhase = 1, DM.cur = -1; DM.volume = fmaxf(0.7f * MusicVolume, 0.7f); // (sic) mai sotto 0.7 Sound_tickHook = DM_Tick; } static void DirecterManager_StartPhase0(void) { DM.combatTimer = 0; Sound_StopMusic(); Machine_SwapDirecters(); DM.currentPhase = 0; DM_play("Phase0", 0, DM.volume); DM_timer(0x7a4b, DMT_PHASE0, 0, 0); // 31,3 s: dissolvenza in 1,1 s e fase 1 } static void DM_StartPhase1(void) { Machine_OnPhase(1); DM.combatTimer = 0, DM.currentPhase = 1; DM_CheckTime1(1, 2, 1); } static void DM_StartPhase2(void) { Machine_OnPhase(2); tweens_add((TweenConfig){ .props = { { &SFXVolumeFactor, NULL, 0.9f } }, .nprops = 1, .duration = 0x1388 }); Machine_RemoveTileset(); Machine_ZoomOverStages(); Machine.fire1->c.alpha = ERANGE(0.9f, 0); time_addEvent(0x1f4, 0, 0, Machine_RemoveCircles, NULL); time_addEvent(0x3e8, 0, 0, Machine_firesFast, NULL); emitter_stop(Machine.fire1), emitter_stop(Machine.fire2); // forEachAlive accelerationY *= 3: le fiamme non hanno accelerazione (sic, nessun effetto) } static void DM_StartPhase3(void) { Machine_OnPhase(3); Core_EraseEnemies(0); tweens_add((TweenConfig){ .props = { { &SFXVolumeFactor, NULL, 0.8f } }, .nprops = 1, .duration = 0x1388 }); Machine_TurnBGToFire(); } static void DM_StartPhase4(void) { Machine_OnPhase(4); Core_EraseEnemies(0); Core.Player->IsInFinalStage = 1, Core.Player->armor = 0; tweens_add((TweenConfig){ .props = { { &SFXVolumeFactor, NULL, 0.3f } }, .nprops = 1, .duration = 0x61a8 }); Machine_StartColorChangingBackground(); } static void Machine_Phase5(void); static void DM_StartPhase5(void) { tweens_add((TweenConfig){ .props = { { &SFXVolumeFactor, NULL, 0.65f } }, .nprops = 1, .duration = 0x2710 }); Machine_OnPhase(5); Core_EraseEnemies(0); Machine_Phase5(); } static void DM_ChangePhase(void) { static void (*const S[6])(void) = { NULL, NULL, DM_StartPhase2, DM_StartPhase3, DM_StartPhase4, DM_StartPhase5 }; for (int p = 2; p <= 5; p++) if (DM.currentPhase >= p && !DM.started[p]) DM.started[p] = 1, S[p](); } static void DM_Update(float delta) { // le soglie: livello, tempo di combattimento, sette maschere rotte if (!DM.active) return; DM.combatTimer += delta; DirecterEX *d = TheDirecter ? TheDirecter->x : NULL; Player *p = Core.Player; if (DM.currentPhase == 1 && p->level >= 7 && DM.combatTimer >= 0x7530) DM.currentPhase = 2, DM.combatTimer = 0; if (!d) return; if (DM.currentPhase == 2 && p->level >= 0xe && DM.combatTimer >= 0xea60) { if (d->BrokenMasks == 0) DirecterE_MakeMasksBreakable(TheDirecter); if (d->BrokenMasks >= 7) DM.currentPhase = 3, DM.combatTimer = 0, d->BrokenMasks = 0, d->BreakEnabled = 0; } if (DM.currentPhase == 3 && p->revivals < 1 && p->level >= 0x13 && DM.combatTimer >= 0xea60) { DirecterE_MakeMasksBreakable(TheDirecter); if (d->BrokenMasks >= 7) DM.currentPhase = 4, DM.combatTimer = 0, d->BrokenMasks = 0, d->BreakEnabled = 0; } if (DM.currentPhase == 4 && p->level >= 0x16 && DM.combatTimer >= 0xafc8) { DirecterE_MakeMasksBreakable(TheDirecter); if (d->BrokenMasks >= 7) { DM.currentPhase = 5, DM.combatTimer = 0, p->growth = 0, Core.canInterrupt = 0, Core.canPause = 0, d->BrokenMasks = 0, d->BreakEnabled = 0; tweens_add((TweenConfig){ .props = { { &SFXVolumeFactor, NULL, 0.3f } }, .nprops = 1, .duration = 0x1388 }); } } } // --- Machine: fase 5. Lo schermo va in cocci, le finestre si chiudono, sei barre del livello arcobaleno, pioggia di gemme e monete, // 74 mani che girano attorno e la camera che si allontana per 45 s; poi il Directer conta come ucciso e si va al finale. static int pending_ending; // definizione provvisoria: la variabile e' quella della scena dei fuochi static float camera_zoom, GoldFever_fogScale; // redFog scalata da StartZoomingOut (0 = 1) static void GoldFever_Restart(float ms); static void SceneManager_Reset(void), Core_OnPlayerQuit(void), Infernas_BlockInput(void); static struct { int on, wantSnap; float t; RenderTexture2D snap; // snapshotArea: la vista di gioco del frame, poi texture dei cocci ShatterImage *canvas; struct { float x, y, sx, dur, value; int level; Text text; } bar[6]; Sprite bars, hands, videos; struct { VsVideo *v; int key, n; float t, x[3]; } vid[3]; // PlayVideos: un decodificatore per chiamata, disegnato in n punti } M5; // PlayVideoAt (videoKeys / Starts / Ends / Blinks): ADD, scala 0.75, origine (0.5, 0); alpha 0 -> 0.5 in Starts, poi 0.5 <-> 0.9 per Blinks // volte fino a Ends, poi 0 in 1 s. Le chiamate con la stessa chiave nello stesso istante mostrano lo stesso fotogramma. static const char *const VID_KEY[3] = { "Chestnobg", "Chestnobg2", "Chestnobg3" }; static const float VID_START[3] = { 0x1388, 0xdac, 0x9c4 }, VID_END[3] = { 0x2134, 0x30d4, 0x3e80 }, VID_BLINKS[3] = { 3, 5, 7 }; static float Machine_videoAlpha(int k, float t) { if (t < VID_START[k]) return 0.5f * t / VID_START[k]; if (t < VID_END[k]) { float d = (VID_END[k] - VID_START[k]) / VID_BLINKS[k] * 0.5f, ph = fmodf((t - VID_START[k]) / d, 2); return 0.5f + 0.4f * (ph < 1 ? ph : 2 - ph); } return 0.5f * fmaxf(0, 1 - (t - VID_END[k]) / 0x3e8); // (sic) il tween a 0 parte da 0.5: l'ultimo yoyo torna li' } static void Machine_videosDraw(Sprite *s) { (void)s; BeginBlendMode(BLEND_ADDITIVE); for (int i = 0; i < 3; i++) { if (!M5.vid[i].v) continue; Texture2D tx = vs_video_texture(M5.vid[i].v); float a = Machine_videoAlpha(M5.vid[i].key, M5.vid[i].t), dw = 1268 * 0.75f, dh = 664 * 0.75f; // le dimensioni del video originale for (int j = 0; j < M5.vid[i].n; j++) DrawTexturePro(tx, (Rectangle){ 0, 0, tx.width, tx.height }, (Rectangle){ M5.vid[i].x[j] - 0.5f * dw, 0, dw, dh }, (Vector2){ 0, 0 }, 0, Fade(WHITE, a)); } EndBlendMode(); } static void Machine_playVideo(void *c) { // i passi di PlayVideos: chiave e posizioni (0.25/0.5/0.75 o 0/1 dello schermo) int k = (int)(intptr_t)c, i = 0; #ifdef __vita__ // sceAvPlayer: un solo decoder alla volta (il secondo va in STOP e chiuderlo fa crashare il primo): vince l'ultimo for (int j = 0; j < 3; j++) if (M5.vid[j].v) vs_video_close(M5.vid[j].v), M5.vid[j].v = NULL; #endif while (i < 3 && M5.vid[i].v) i++; if (i == 3) return; VsVideo *v = vs_video_open(TextFormat("video/%s.mp4", VID_KEY[k]), 640, 336); if (!v) return; // senza video/ (dati preparati prima di F3.6c) la fase va avanti senza float W = game_width; M5.vid[i].v = v, M5.vid[i].key = k, M5.vid[i].t = 0; if (k == 0) M5.vid[i].n = 3, M5.vid[i].x[0] = 0.25f * W, M5.vid[i].x[1] = 0.5f * W, M5.vid[i].x[2] = 0.75f * W; else M5.vid[i].n = 2, M5.vid[i].x[0] = 0, M5.vid[i].x[1] = W; } static void Machine_PlayVideos(void) { static const struct { float at; int key; } P[8] = { { 0, 0 }, { 0x1388, 1 }, { 0x3a98, 2 }, { 0x61a8, 0 }, { 0x7530, 1 }, { 0x88b8, 0 }, { 0x9c40, 2 }, { 0xafc8, 0 } }; sprite_init(&M5.videos, NULL, 0, 0), M5.videos.draw = Machine_videosDraw, M5.videos.scrollFactor0 = 1, M5.videos.depth = game_height; children_add(&M5.videos); Machine_playVideo((void *)0); for (int i = 1; i < 8; i++) time_addEvent(P[i].at, 0, 0, Machine_playVideo, (void *)(intptr_t)P[i].key); } static void Machine_videosUpdate(float delta) { for (int i = 0; i < 3; i++) { if (!M5.vid[i].v) continue; M5.vid[i].t += delta; if (!vs_video_update(M5.vid[i].v, delta) || M5.vid[i].t >= VID_END[M5.vid[i].key] + 0x3e8) vs_video_close(M5.vid[i].v), M5.vid[i].v = NULL; } } static void Machine_barsDraw(Sprite *s) { // 0x13633: NineSlice ProgressBox renderer.width x 18 e PfxDot (x + 5, y + 5) scala (sx, 8) con setTintFill (void)s; for (int i = 0; i < 6; i++) { float x = M5.bar[i].x, y = M5.bar[i].y, v = M5.bar[i].value; nine("frameB9.png", 6, (Rectangle){ x, y, game_width, 0x12 }, WHITE); Color c = po_is("FlashingVFXEnabled") ? (Color){ 0xff * fabsf(sinf(v)), 0xff * fabsf(cosf(0.5f * v)), 0xc8 + 0x37 * fabsf(cosf(v)), 255 } : (Color){ 0x22, 0x66, 0xdd, 255 }; DrawRectangleRec((Rectangle){ x + 5, y + 5, M5.bar[i].sx, 8 }, c); } } static float ease_expo_inout(float v) { return v <= 0 ? 0 : v >= 1 ? 1 : (v *= 2) < 1 ? 0.5f * powf(2, 10 * (v - 1)) : 0.5f * (2 - powf(2, -10 * (v - 1))); } static void Machine_handsDraw(Sprite *s) { // MakeThrowingHands: hand_reveal_01-04 a 4 fps, scala 2, origine (1, 0.5); angle +360 in 1 s, yoyo, Expo.easeInOut (void)s; float W = game_width, H = game_height, k = fmodf(M5.t, 0x7d0) / 0x3e8; float turn = 360 * ease_expo_inout(k < 1 ? k : 2 - k); const Frame *f = frame_get("enemiesM", TextFormat("hand_reveal_%02d.png", 1 + (int)(M5.t / 0xfa) % 4)); for (int i = 0; i < 0x20 + 0x2a; i++) { // Ellipse(W/2, H/2, 1.4 W, 1.4 H).getPoints(32), poi 1.7 e 42 punti int n = i < 0x20 ? 0x20 : 0x2a, j = i < 0x20 ? i : i - 0x20; float r = i < 0x20 ? 0.7f : 0.85f, a = 2 * PI * j / n, x = 0.5f * W + r * W * cosf(a), y = 0.5f * H + r * H * sinf(a); Sprite h; sprite_init(&h, f, x, y); sprite_setScale(&h, 2), sprite_setOrigin(&h, 1, 0.5f), h.scrollFactor0 = 1; h.angle = atan2f(y - 0.5f * H, x - 0.5f * W) * (180 / PI) + turn; scene_render_one(&h, (Shader){ 0 }); } } static void Machine_shatterDone(void *c) { (void)c; M5.canvas->hasTask = 0, M5.canvas->s.visible = 0; } // stopUpdate, setVisible(false) // ShatterImage: la vista appena disegnata diventa la texture dei cocci (la partita prosegue su una render texture nuova), poi il tween sulle facce. // semplificazione: snapshotArea(0, 0, width, width) nell'originale (sic, altezza = larghezza): qui la sola vista, centrata static void Machine_TakeSnapshot(RenderTexture2D *rt) { M5.wantSnap = 0; if (M5.snap.id) UnloadRenderTexture(M5.snap); M5.snap = *rt; *rt = LoadRenderTexture(game_width, game_height); SetTextureFilter(rt->texture, TEXTURE_FILTER_POINT); ShatterImage *c = M5.canvas = shatterImage_add(0.5f * game_width, 0.5f * game_height, &M5.snap.texture, game_width, game_height); c->s.depth = MAX_SAFE_INTEGER, c->s.scrollFactor0 = 1; shatterImage_shatter(c); int nf = c->nfaces; TweenProp *pr = malloc((4 * nf + 1) * sizeof(TweenProp)); for (int i = 0; i < nf; i++) pr[i] = face_prop(&c->faces[i], 0, 0), pr[nf + i] = face_prop(&c->faces[i], 1, 0xb4 * frand() - 0x5a), pr[2 * nf + i] = face_prop(&c->faces[i], 2, 1.2f * (frand() - 0.5f)), pr[3 * nf + i] = face_prop(&c->faces[i], 3, 1.2f * (frand() - 0.5f)); c->task = tweens_add((TweenConfig){ .many = pr, .nmany = 4 * nf, .duration = 0x3e8, .delay = 0x96, .onComplete = Machine_shatterDone }); c->hasTask = 1; free(pr); } static void Machine_SendGem(void *c) { // SendGem(true, i > 30): 108 gemme a spirale attorno a un punto dell'ellisse 1.4 schermi, tutte verso il giocatore static const char *const GC[13] = { "GemBlue.png", "GemBlue.png", "GemBlue.png", "GemBlue.png", "GemBlue.png", "GemBlue.png", "GemBlue.png", "GemBlue.png", "GemBlue.png", "GemGreen.png", "GemGreen.png", "GemGreen.png", "GemRed.png" }; int colored = (int)(intptr_t)c > 0x1e; float a = 2 * PI / 0x20 * floorf(frand() * 0x20), st = 2 * PI / 0x6c; float ox = Core.Player->s.x + 0.7f * game_width * cosf(a), oy = Core.Player->s.y + 0.7f * game_height * sinf(a); for (int i = 0; i < 0x6c; i++) { Pickup *g = PickupPool_SpawnAt(&Core.gemsPool, ox + 0x20 * cosf(st * i) * (i % 4), oy + 0x20 * sinf(st * i) * (i % 4), "GEM"); if (!g) continue; g->goToPlayer = 1, g->time = 1; Gem_SetValue(g, 1); if (colored) g->frameName = GC[(int)floorf(frand() * 13)], sprite_setFrame(&g->s, frame_get("items", g->frameName)); } } static void Machine_SendCoins(void *c) { // SendCoins(i > 20): 32 monete sull'ellisse, valore x 10; dopo le prime 21 anche sacchetti static const char *const CT[8] = { "COIN", "COIN", "COIN", "COIN", "COIN", "COINBAG1", "COINBAG2", "COINBAGMAX" }; int bags = (int)(intptr_t)c > 0x14; for (int i = 0; i < 0x20; i++) { float a = 2 * PI / 0x20 * i; Pickup *p = Core_MakePickup(Core.Player->s.x + 0.7f * game_width * cosf(a), Core.Player->s.y + 0.7f * game_height * sinf(a), bags ? CT[(int)floorf(frand() * 8)] : "COIN"); if (p) p->goToPlayer = 1, p->time = 1, p->speed = 0xfa - i, p->value *= 0xa; } } static void Machine_EndRun(void *c) { // a 45,5 s: il Directer conta come ucciso, salvataggio e finale (fuochi la prima volta, poi solo i crediti) (void)c; json_inc(tbl0("enemies", "DIRECTER"), "killedAmount"); PlayerOptions_Save(); pending_ending = po_is("HasSeenFinalFireworks") ? 2 : 1; Core_OnPlayerQuit(); SceneManager_Reset(); } static void Machine_zoomTo(float zoom, float scale, float tileScale, float delay) { // camera, bgtile (scala e tileScale) e redFog della Gold Fever in 500 ms tweens_add((TweenConfig){ .props = { { &camera_zoom, NULL, zoom }, { &GoldFever_fogScale, NULL, scale } }, .nprops = 2, .duration = 0x1f4, .delay = delay }); tweens_add((TweenConfig){ .props = { { &Machine.bgtile.s.scaleX, &Machine.bgtile.s.scaleY, scale }, { &Machine.bgtile.tileScaleX, &Machine.bgtile.tileScaleY, tileScale } }, .nprops = 2, .duration = 0x1f4, .delay = delay }); } static void Machine_Phase5(void) { float W = game_width; memset(&M5.bar, 0, sizeof(M5.bar)); M5.on = 1, M5.t = 0; Infernas_BlockInput(); // BlockInput: lo stesso di Infernas, piu' la barra della vita nascosta PlayerUI.hpBarBG.visible = PlayerUI.hpBar.visible = 0; M5.wantSnap = 1; // ShatterImage: alla fine del prossimo disegno for (int i = 0; i < Machine.nWindows; i++) // OpenWindows tweens_add((TweenConfig){ .props = { { &Machine.windows[i].scaleX, NULL, 0 } }, .nprops = 1, .duration = 0x3e8 }); PlayerUI.progressBox.visible = PlayerUI.progressBar.visible = 0; // AddLevelUpBars static const float BO[6][2] = { { 0, 0 }, { 8, -0x40 }, { 0x10, -0x30 }, { 8, -0x20 }, { -0x10, -0x10 }, { -0x20, -0x50 } }; sprite_init(&M5.bars, NULL, 0, 0), M5.bars.draw = Machine_barsDraw, M5.bars.scrollFactor0 = 1; children_add(&M5.bars); for (int i = 0; i < 6; i++) { M5.bar[i].x = BO[i][0], M5.bar[i].y = BO[i][1], M5.bar[i].level = Core.Player->level; M5.bar[i].dur = 0x3e8 + 0x3e8 * frand(), M5.bar[i].value = 2 * PI * frand(); add_text(&M5.bar[i].text, BO[i][0] + W - 4, BO[i][1] + 9, TextFormat("LV %d", M5.bar[i].level), 12, 1, 0.5f); } Machine_SetBGTexture("hStars1"); // RemoveColorBG Machine.bgtile.s.scaleX = Machine.bgtile.s.scaleY = 1, Machine.bgtile.tileScaleX = Machine.bgtile.tileScaleY = 1; Machine.bgtile.s.x = 0.5f * W, Machine.bgtile.s.y = 0.5f * game_height; emitter_stop(Machine.fire1), emitter_stop(Machine.fire2); tweens_add((TweenConfig){ .props = { { &Machine_colorBG.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x7d0 }); Machine_PlayVideos(); GoldFever_fogScale = 1; GoldFever_Restart(0x186a0); // StartGifts: new GoldFever e TriggerGoldFever(100000) Arcanas.xpMultiplier = 0; for (int i = 0; i < 0x78; i++) time_addEvent(0x1f4 * i, 0, 0, Machine_SendGem, (void *)(intptr_t)i), time_addEvent(0x1f4 + 0x3e8 * i, 0, 0, Machine_SendCoins, (void *)(intptr_t)i); sprite_init(&M5.hands, NULL, 0, 0), M5.hands.draw = Machine_handsDraw, M5.hands.scrollFactor0 = 1, M5.hands.depth = MAX_SAFE_INTEGER; // MakeThrowingHands children_add(&M5.hands); for (int i = 0; i < 9; i++) Machine.cameraZoom -= 0.025f, Machine_zoomTo(Machine.cameraZoom, 1 + 2 * (1 - Machine.cameraZoom), Machine.cameraZoom, 0x1388 * i); // StartZoomingOut Machine_zoomTo(0.15f, 7.8f, 0.5f, 0xafc8); time_addEvent(0xafc8 + 0x1f4, 0, 0, Machine_EndRun, NULL); // addCounter 0 -> 1, delay 45 s, 500 ms } static void Machine_Phase5Destroy(void) { if (M5.snap.id) UnloadRenderTexture(M5.snap); for (int i = 0; i < 3; i++) vs_video_close(M5.vid[i].v); memset(&M5, 0, sizeof(M5)); } static void Machine_Phase5Update(float delta) { // le barre: scaleX 0 -> W - 10 ripetuto (onRepeat: livello + 1), colore a ogni passo if (!M5.on) return; M5.t += delta; Machine_videosUpdate(delta); for (int i = 0; i < 6; i++) { M5.bar[i].value += 0.1f; M5.bar[i].sx += (game_width - 0xa) * delta / M5.bar[i].dur; if (M5.bar[i].sx < game_width - 0xa) continue; M5.bar[i].sx = 0, M5.bar[i].level++; Text_setText(&M5.bar[i].text, lang1("ingame_level", TextFormat("%d", M5.bar[i].level))); } } static void Machine_devStart(void *c) { // sviluppo: VS_DIRECTER=1 la battaglia subito, VS_DMPHASE=N fino alla fase N (void)c; DirecterManager_StartPhase0(); if (getenv("VS_DMPHASE")) DM_RemoveTimers(), DM_StartPhase1(), DM.currentPhase = atoi(getenv("VS_DMPHASE")), DM_ChangePhase(); } static const FancyBG FB_Machine = { Machine_Create, Machine_Update, NULL, NULL, NULL, Machine_HasMovingBG, Machine_DisableMovingBackground }; static const FancyBG FB_Foscari, FB_Foscari2; static const FancyBG *Stage_fancyBG(const char *stageType) { if (!strcmp(stageType, "FOSCARI")) return &FB_Foscari; if (!strcmp(stageType, "FOSCARI2")) return &FB_Foscari2; if (!strcmp(stageType, "FOREST")) return &FB_Forest; if (!strcmp(stageType, "LIBRARY")) return &FB_Library; if (!strcmp(stageType, "WAREHOUSE")) return &FB_Plant; if (!strcmp(stageType, "TOWER") || !strcmp(stageType, "TOWERBRIDGE")) return &FB_Tower; if (!strcmp(stageType, "CHAPEL")) return &FB_Chapel; if (!strcmp(stageType, "MOLISE")) return &FB_Molise; if (!strcmp(stageType, "BONEZONE")) return &FB_BoneZone; if (!strcmp(stageType, "SINKING")) return &FB_Moon; if (!strcmp(stageType, "RASH")) return &FB_Rash; if (!strcmp(stageType, "MOONSPELL")) return &FB_Moonspell; if (!strcmp(stageType, "BATCOUNTRY")) return &FB_Bat; if (!strcmp(stageType, "ASTRALSTAIR")) return &FB_Astral; if (!strcmp(stageType, "GREENACRES")) return &FB_GreenAcres; if (!strcmp(stageType, "MACHINE")) return &FB_Machine; return NULL; } static void Trisection_init(void); static void Trisection_TriggerTrisectionEvent(void); static Stage *Stage_new(const char *stageType) { Stage *st = calloc(1, sizeof(Stage)); if (po_is("SelectedRandomEvents")) Trisection_init(), st->hasTrisection = 1; // isTwitchOn: mai st->frequency = st->EffectiveSpawnFrequency = 0x3e8; st->maximum = st->defaultMaximum = 0x12c; st->minimumMultiplier = 1; st->EnemyHealthMultiplier = st->EnemySpeedMultiplier = 1; st->stageType = stageType; st->SpawnTimer = st->DestructibleTimer = (Timer){ -1, 0 }; st->destructibleType = "BRAZIER"; // valori del costruttore; UpdateAllData li sovrascrive se i dati li hanno st->destructibleFreq = 0x2710; st->destructibleChance = 5; st->destructibleChanceMax = 0x32; st->maxDestructibles = 0xa; st->DayColor = 0xffffff, st->NightColor = 0x4444ee, st->InverseDayColor = 0xffcccc, st->InverseNightColor = 0xee4444, st->BGTextureName = ""; st->bulletAllowance = 0x32, st->pizzaIntervalInMilliSeconds = 0x4e20; st->NoShadowsTimer = st->PizzaTimer = (Timer){ -1, 0 }; StageModifiers_init(&st->StageModifiers); return st; } static void Stage_Init(Stage *st) { // I nemici di tutti i minuti si preparano ora: l'atlante caricato al primo nemico di un tipo nuovo fermava il gioco // (Moongolow sulla Vita, 2026-11-11: 681 ms alle prime anfore, 523 ms al minuto 10). Con randomMinutes resta al primo uso. cJSON *mi, *ty; cJSON_ArrayForEach(mi, cJSON_GetObjectItem(data_get("stages"), st->stageType)) { cJSON_ArrayForEach(ty, cJSON_GetObjectItem(mi, "enemies")) if (cJSON_IsString(ty)) EnemyData_of(ty->valuestring); cJSON_ArrayForEach(ty, cJSON_GetObjectItem(mi, "bosses")) if (cJSON_IsString(ty)) EnemyData_of(ty->valuestring); if (cJSON_IsString(cJSON_GetObjectItem(mi, "arcanaHolder"))) EnemyData_of(cJSON_GetObjectItem(mi, "arcanaHolder")->valuestring); } StageModifiers_init(&st->StageModifiers); st->EnemyHealthMultiplier = st->EnemySpeedMultiplier = 1; st->dataMinute = 0; cJSON *d = cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("stages"), st->stageType), st->dataMinute), *ts = cJSON_GetObjectItem(d, "tileset"); st->data = d; st->cffName = str(d, "cff"); st->hasTileset = ts != NULL; st->spawnType = str(d, "spawnType"); st->pizzaEvents = NULL; if (ts) st->hasClosestDestructibleLogic = cJSON_IsTrue(cJSON_GetObjectItem(ts, "hasClosestDestructibleLogic")), st->hasWallsCheckDestructibleLogic = cJSON_IsTrue(cJSON_GetObjectItem(ts, "hasWallsCheckDestructibleLogic")); Stage_UpdateAllData(st, d); if (st->randomMinutes) Stage_UpdateMinuteData(st); float x = -0.5f * game_width, y = -0.5f * game_height; st->rectOuter = (Rectangle){ x - 0x4b, y - 0x4b, game_width + 0x96, game_height + 0x96 }; st->rectInner = (Rectangle){ x - 37.5f, y - 37.5f, game_width + 0x4b, game_height + 0x4b }; Rectangle ta = { -0x190, -0x100, 0x340, 0x220 }, tb = { -0x160, -0xd0, 0x2e0, 0x1c0 }; // tiledPositions: la cornice di 32 px fuori dallo schermo int cols = (int)ceilf(ta.width / 0x20), rows = (int)ceilf(ta.height / 0x20); st->tiledPositions = gmem_calloc((cols + 1) * (rows + 1), sizeof(Vector2)), st->n_tiledPositions = 0; for (int i = 0; i <= cols; i++) for (int j = 0; j <= rows; j++) { Vector2 p = { ta.x + 0x20 * i, ta.y + 0x20 * j }; if (!geomRect_contains(tb, p.x, p.y)) st->tiledPositions[st->n_tiledPositions++] = p; } StageModifiers_Set(&st->StageModifiers, cJSON_GetObjectItem(d, "mods")); if (po_is("SelectedHyper")) StageModifiers_Add(&st->StageModifiers, cJSON_GetObjectItem(d, "hyper")); if (po_is("SelectedInverse")) StageModifiers_Add(&st->StageModifiers, cJSON_GetObjectItem(d, "inverse")); if (po_is("SelectedHurry")) st->StageModifiers.XPBonus += 0.25f; PlayerPxSpeed = _basePlayerPxSpeed * st->StageModifiers.PlayerPxSpeed; EnemySpeed = _baseEnemySpeed * st->StageModifiers.EnemySpeed; ProjectileSpeed = _baseProjectileSpeed * st->StageModifiers.ProjectileSpeed; GoldMultiplier = _baseGoldMultiplier * st->StageModifiers.GoldMultiplier; EnemyHealthMultiplier = _baseEnemyHealthMultiplier * st->StageModifiers.EnemyHealthMultiplier; ExperienceMultiplier = _baseExperienceMultiplier * st->StageModifiers.XPBonus; Core.Player->luck += st->StageModifiers.LuckBonus; Stage_CalculateEnemySpeed(st); if (ts) st->tilingTileset = TilingTileset_new(st->stageType, num(ts, "SizeX", 0x800), num(ts, "SizeY", 0x800)); if (st->tilingTileset) { // NULL: dati senza tilesets/ TilingTileset *t = st->tilingTileset; st->n_DestructibleLocations = objectLayer_points(t->MainMap, "Destructibles", &st->DestructibleLocations); st->n_EnemySpanwersLocations = objectLayer_points(t->MainMap, "Spawners", &st->EnemySpanwersLocations); if (st->cffName) TilingTileset_MakeCoffin(t, st->cffName); st->n_NoShadowLocations = TilingTileset_GetNoShadowAreaLocations(t, "NoShadow", &st->NoShadowLocations); if (st->n_NoShadowLocations > 0) st->NoShadowsTimer = time_addEvent(0x64, 1, 0, Stage_CheckShadows, st); st->n_CartLocations = TilingTileset_GetSpecialLocations(t, "CART", &st->CartLocations); st->n_WindowLocations = TilingTileset_GetSpecialLocations(t, "Window", &st->WindowLocations); st->n_PizzaLocations = TilingTileset_GetSpecialLocations(t, "PIZZA", &st->PizzaLocations); // minTreasureX/Y, maxTreasureX/Y: l'originale li calcola ma nessuno li legge if (st->n_PizzaLocations > 0) { st->PizzaTimer = time_addEvent(0x64, 1, 0, Stage_CheckPizzas, st); sprite_init(&st->WarningSprite, frame_get("UI", "ExclamationMark.png"), 0.5f * game_width, 0.5f * game_height - 0x30); st->WarningSprite.scrollFactor0 = 1, sprite_setScale(&st->WarningSprite, 0), sprite_setOrigin(&st->WarningSprite, 0.5f, 1), st->WarningSprite.depth = 0x2328; children_add(&st->WarningSprite); sprite_init(&st->PizzaSprite, frame_get("items", "Pizza.png"), 0.5f * game_width, 0.5f * game_height - 0x30); st->PizzaSprite.depth = -1, st->PizzaSprite.alpha = 0; children_add(&st->PizzaSprite); } } else if (!ts) Stage_SpawnYellowItems(); for (int i = 0; i < st->startingSpawns; i++) Stage_SpawnByType(st); st->BulletPool1 = EnemyPool_new("BULLET_1"); if (has(d, "background") && (st->fancyBG = Stage_fancyBG(st->stageType)) && st->fancyBG->Create) st->fancyBG->Create(); Stage_InitMappedPools(st); Stage_SpawnBoss(st); } static void Stage_CheckMinute(Stage *st) { if (st->stopCheckingMinutes) return; int minute = (int)floorf(Core.SurvivedSeconds / 60.0f), m = minute; if (st->StageModifiers.EndCycles > 0 && (m = minute % (int)(st->StageModifiers.TimeLimit / 60)) == 0) return; // OnCycleComplete cJSON *found = NULL, *it; const char *key = Stage_RandomMinuteStage(st); if (minute > st->realMinutes) cJSON_ArrayForEach(it, cJSON_GetObjectItem(data_get("stages"), key)) if ((int)num(it, "minute", -1) == m) { found = it; break; } if (found) { st->dataMinute = m; st->realMinutes = minute; Stage_UpdateAllData(st, found); } if (st->fancyBG && st->fancyBG->CheckMinute) st->fancyBG->CheckMinute(m); StageModifiers *sm = &st->StageModifiers; if (sm->TimeMods.has && sm->TimeMods.start >= 0 && minute > sm->TimeMods.start) { if (sm->TimeMods.hpPerMinute) st->EnemyHealthMultiplier += sm->TimeMods.hpPerMinute; if (sm->TimeMods.speedPerMinute) st->EnemySpeedMultiplier += sm->TimeMods.speedPerMinute; } st->hasAttachedTreasure = 0; Stage_SpawnBoss(st); if (RandomazzoEnabled()) Stage_SpawnArcanaHolder(st); if (po_is("SelectedRandomEvents") && st->hasTrisection) Trisection_TriggerTrisectionEvent(); } // ============================================================================ // 0x7419: WhiteHandManager, la Mano Bianca dopo il Mietitore ucciso: 12 rintocchi, poi attraversa lo schermo e uccide // ============================================================================ static float camera_zoom = 1; // cameras.main.zoom: applicato all'intera vista di gioco nel blit (come la camera di Phaser, HUD compreso) static struct { int triggered, kill, bells; Sprite hand; Animation idle; } WhiteHand; static void WhiteHand_ZoomOnPlayer(void) { tweens_add((TweenConfig){ .props = { { &camera_zoom, NULL, camera_zoom + 0.06f } }, .nprops = 1, .duration = 0x384, .ease = Ease_SineInOut }); } static void WhiteHand_kill(void *ctx) { (void)ctx; WhiteHand.kill = 1; } static void WhiteHand_Spawn(void *ctx) { (void)ctx; Sprite *h = &WhiteHand.hand; sprite_init(h, frame_get("enemies3", "WhiteHand_i01.png"), -0x20, 0.5f * game_height); make_anim(&WhiteHand.idle, "enemies3", "WhiteHand_i0", 1, 4, 0, 0x3c, -1); anims_play(h, &WhiteHand.idle, 0); sprite_setOrigin(h, 0.5f, 1), h->flipX = 1, h->scrollFactor0 = 1, h->depth = 0x2710; children_add(h); tweens_add((TweenConfig){ .props = { { &h->x, NULL, 0.5f * game_width } }, .nprops = 1, .duration = 0x2710, .onComplete = WhiteHand_kill }); } // BellTollEvent: tween su bellTime (durata 1 s, repeat 11, repeatDelay 1 s); onRepeat parte all'inizio di ogni ripetizione: // rintocchi a 1 s, 3 s, ... 21 s, Mano Bianca a 23 s. semplificazione: gli stessi istanti con dei timer, il valore di bellTime non serve static void WhiteHand_bell(void *ctx) { (void)ctx; Sound_PlaySound("Bell", 0.9f, 1.5f, 0, 0, 0); WhiteHand_ZoomOnPlayer(); Sound_StopMusic(); time_addEvent(0x7d0, 0, 0, ++WhiteHand.bells < 0xb ? WhiteHand_bell : WhiteHand_Spawn, NULL); } static void WhiteHand_Summon(void) { if (WhiteHand.triggered) return; WhiteHand.triggered = 1; Sound_FadeMusic(0, 0x3e8); Sound_PlaySound("Bell", 0.9f, 1.5f, 0, 0, 0); time_addEvent(0x3e8, 0, 0, WhiteHand_bell, NULL); } static void WhiteHand_Update(void) { if (WhiteHand.kill && !Core.Player->isDead) Core.Player->hp = 0, Player_Die(Core.Player); // Core.GameOver(): vuoto } // ============================================================================ // 0x2bf0: BGMan, lo sfondo a piastrelle sotto la mappa (Stage.BGTextureName) con il ciclo giorno/notte // ============================================================================ static struct { Sprite bgtile; // tileSprite grande quanto lo schermo, fisso (scrollFactor 0), sotto a tutto Texture2D tex; float tilePositionX, tilePositionY, timeOffset, dayCycleDuration, speedFactor, yMul; unsigned DayColor, NightColor; int RunTimeHue, canScroll; int gradient; // setTint(alto, alto, basso, basso): Bat Country unsigned gradTop, gradBottom; } BGMan; static unsigned LerpColor(unsigned a, unsigned b, float t) { // MyUtils.LerpColor: rosso e verde interi per lo shift, poi tutto troncato (| 0) int r = a >> 16, g = a >> 8 & 0xff, bl = a & 0xff; int R = (int)(r + t * ((int)(b >> 16) - r)), G = (int)(g + t * ((int)(b >> 8 & 0xff) - g)); return (unsigned)(int)((double)(1 << 24) + (R << 16) + (G << 8) + (bl + t * ((int)(b & 0xff) - bl))) & 0xffffff; } static void BGMan_draw(Sprite *s) { // TileSprite: la texture ripetuta, spostata di tilePosition if (!BGMan.tex.id || !s->visible) return; if (s->tintFill) { DrawRectangle(0, 0, game_width, game_height, hexc(s->tint, s->alpha)); return; } // setTintFill (segreto della Cappella): bg opaco = colore pieno EndShaderMode(); // come TileSprite_draw: niente shader di riempimento sulle u ripetute if (BGMan.gradient) { // tinta per vertice: rlgl a mano (DrawTexturePro ha un solo colore) float u0 = BGMan.tilePositionX / BGMan.tex.width, v0 = BGMan.tilePositionY / BGMan.tex.height; float u1 = u0 + game_width / PixelScale / BGMan.tex.width, v1 = v0 + game_height / PixelScale / BGMan.tex.height; if (s->flipY) { float v = v0; v0 = v1, v1 = v; } // setFlipY (Inverse) Color t = hexc(BGMan.gradTop, s->alpha), b = hexc(BGMan.gradBottom, s->alpha); rlSetTexture(BGMan.tex.id); rlBegin(RL_QUADS); rlColor4ub(t.r, t.g, t.b, t.a), rlTexCoord2f(u0, v0), rlVertex2f(0, 0); rlColor4ub(b.r, b.g, b.b, b.a), rlTexCoord2f(u0, v1), rlVertex2f(0, game_height); rlColor4ub(b.r, b.g, b.b, b.a), rlTexCoord2f(u1, v1), rlVertex2f(game_width, game_height); rlColor4ub(t.r, t.g, t.b, t.a), rlTexCoord2f(u1, v0), rlVertex2f(game_width, 0); rlEnd(); rlSetTexture(0); return; } if (Lights.on) Lights_Begin(); // setPipeline('Light2D') float w = game_width * s->scaleX, h = game_height * s->scaleY; // origine 0.5 al centro dello schermo (il bordo di Green Acres lo rimpicciolisce) DrawTexturePro(BGMan.tex, (Rectangle){ BGMan.tilePositionX, BGMan.tilePositionY, game_width / PixelScale, (s->flipY ? -1 : 1) * game_height / PixelScale }, (Rectangle){ 0.5f * (game_width - w), 0.5f * (game_height - h), w, h }, (Vector2){ 0, 0 }, 0, hexc(s->tint, s->alpha)); if (Lights.on) EndShaderMode(); } static Texture2D BGMan_texture(const char *texture) { // load.image una volta per nome, in ripetizione static Texture2D cache[16]; static char names[16][32]; for (int i = 0; i < 16; i++) { if (!names[i][0]) { snprintf(names[i], sizeof(names[i]), "%s", texture); cache[i] = LoadTexture(vs_path(TextFormat("img/%s.png", !strcmp(texture, "hStars1") ? "Stars1" : texture))); // load.image('hStars1', 'Stars1.png') SetTextureWrap(cache[i], TEXTURE_WRAP_REPEAT); } if (!strcmp(names[i], texture)) return cache[i]; } return (Texture2D){ 0 }; } static void BGMan_MakeBackground(const char *texture, Stage *st) { BGMan.timeOffset = 0, BGMan.dayCycleDuration = 0x384, BGMan.RunTimeHue = 1, BGMan.canScroll = 1, BGMan.speedFactor = 1; // costruttore BGMan.DayColor = 0xffffff, BGMan.NightColor = 0x4444ee, BGMan.yMul = 1, BGMan.tex = (Texture2D){ 0 }; if (texture && *texture) { BGMan.tex = BGMan_texture(texture); sprite_init(&BGMan.bgtile, NULL, 0.5f * game_width, 0.5f * game_height); BGMan.bgtile.draw = BGMan_draw, BGMan.bgtile.scrollFactor0 = 1, BGMan.bgtile.depth = -0xdbba0; // setScale(PixelScale) children_add(&BGMan.bgtile); } if (st->DayColor) BGMan.DayColor = st->DayColor; if (st->NightColor) BGMan.NightColor = st->NightColor; if (po_is("SelectedInverse")) { if (po_is("VisuallyInvertStages")) BGMan.bgtile.flipY = 1, BGMan.yMul = -1; // bgtile.setFlipY(true) if (st->InverseDayColor) BGMan.DayColor = st->InverseDayColor; if (st->InverseNightColor) BGMan.NightColor = st->InverseNightColor; } } // --- CHAPEL, il segreto (S3b): con la reliquia gialla e il boss finale mai battuto. Lo schiocco toglie le armi "gialle", i quattro // Mietitori arrivano ai minuti 0,16 / 5 / 10 / 15 (col Maddener la Cappella diventa rossa e gli angeli alias), al 30 spariscono mappa e // cielo, i Mietitori sfilano verso l'alto e nel cielo viola scende l'Ender. Battuto: il cielo torna, la Mano Bianca chiude la partita. static struct { int on, waitIntro, nSaved, cloudsOn, overlaysOn; float introMs; float t, minuteValue, tintHelp, cloudsT, cloudsAlpha, overlayA, overlayAddA; EnemyPool *pMad, *pDrown, *pStalk, *pTrick, *pEnder; Enemy *maddener, *ender; Weapon *saved[16]; Pickup *yellow[4]; Sprite fx, clouds, friends[5], overlay, overlayAdd; float cloudAngle[4][12]; unsigned char cloudFlip[4][12]; } ChS; static struct { int on, hasFrom; float k, fromX, fromY; Enemy *e; const Sprite *sp; Sprite s; } CamPan; // StopCamera + scrollX/Y in tween + startFollow: la camera fra il giocatore e un nemico static cJSON *Chapel_minute30(void) { return cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("stages"), "CHAPEL"), 0x1e); } static void Chapel_setMinute30(int secret) { // dataStages[CHAPEL][30].enemies / bosses cJSON *m = Chapel_minute30(); if (!m) return; cJSON_ReplaceItemInObject(m, "enemies", secret ? cJSON_CreateArray() : cJSON_CreateStringArray((const char *[]){ "TRAINEE_R" }, 1)); cJSON_ReplaceItemInObject(m, "bosses", secret ? cJSON_CreateArray() : cJSON_CreateStringArray((const char *[]){ "BOSS_XLDEATH2" }, 1)); } static void ChS_fxDraw(Sprite *s) { (void)s; SnapFX_draw(ChS.t); } static void Chapel_snapHide(void *c) { (void)c; tweens_add((TweenConfig){ .props = { { &Chapel.snap.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x12c }); } static void Chapel_snapPlay(float hideAfter) { // snap.setAlpha(1), play('snap'), alpha 0 in 300 ms dopo hideAfter Chapel.snap.alpha = 1; anims_play(&Chapel.snap, &Chapel.snapAnim, 0); time_addEvent(hideAfter, 0, 0, Chapel_snapHide, NULL); } static void Chapel_snapSound(void) { Sound_PlaySound("BGM_GameOver", 1.6f, 1, 1000, 0, 0); } static void Chapel_eggsGo(void *c) { (void)c; Chapel_snapSound(); SnapFX_eggs(ChS.t); } static void Chapel_SnapEggs(void) { // minuto 4 if (!po_is("SelectedGoldenEggs")) return; int n = EggManager_RemoveBonuses(); if (n <= 0) return; SnapFX.nEggs = n < 0x1f4 ? n : 0x1f4; Chapel_snapPlay(0x1f4 + 0x258 + 0xa * SnapFX.nEggs); time_addEvent(0x1f4, 0, 0, Chapel_eggsGo, NULL); } static void Chapel_yellowsGo(void *c) { // dopo 500 ms: suono, armi e anelli via, le icone girano e spariscono (void)c; Chapel_snapSound(); SnapFX.nPowers = 0, SnapFX.powersAt = ChS.t; if (Core_GetWeapon("SHROUD")) SnapFX.powers[SnapFX.nPowers++] = "cape.png", Core_RemoveWeapon("SHROUD"); if (Core_GetWeapon("CORRIDOR")) SnapFX.powers[SnapFX.nPowers++] = "portal.png", Core_RemoveWeapon("CORRIDOR"); static const char *const icon[4] = { "goldring.png", "silverring.png", "bsleft.png", "bsright.png" }; for (int i = 0; i < 4; i++) if (ChS.yellow[i]) SnapFX.powers[SnapFX.nPowers++] = icon[i]; for (int i = 0; i < 4; i++) if (ChS.yellow[i]) Pickup_DeSpawn(ChS.yellow[i]), ChS.yellow[i] = NULL; } static void Chapel_SnapYellows(void) { // all'ingresso: Crimson Shroud, Infinite Corridor e le loro parti a terra static const char *const W[4] = { "GOLD", "SILVER", "LEFT", "RIGHT" }; int any = Core_GetWeapon("SHROUD") || Core_GetWeapon("CORRIDOR"); for (int k = 0; k < 4; k++) { ChS.yellow[k] = NULL; for (int i = 0; i < Core.PickupGroup.n && !ChS.yellow[k]; i++) { Pickup *p = Core.PickupGroup.items[i]->owner; if (p->weaponType && !strcmp(p->weaponType, W[k])) ChS.yellow[k] = p, any = 1; } } if (!any) return; Chapel_snapPlay(0x3e8); time_addEvent(0x1f4, 0, 0, Chapel_yellowsGo, NULL); } static void Chapel_ToggleBlue(int on) { Chapel.skyBlue.s.visible = Chapel.cloudsBlue.s.visible = Chapel.cloudsAddBlue.s.visible = on; if (on) Chapel.floorLights.s.tint = Chapel.skyLights.s.tint = 0xffffff; } static void Chapel_ToggleRed(int on) { Chapel.skyRed.s.visible = Chapel.cloudsRed.s.visible = Chapel.cloudsAddRed.s.visible = on; if (on) Chapel.floorLights.s.tint = Chapel.skyLights.s.tint = 0xff4422; // semplificazione: setTint(0xff0000, 0xff0088, 0xff0000, 0xffff00) ai vertici, qui la media } static void Chapel_ToggleAlias(int on) { // gli angeli (alias: FANGEL, TRAINEE_Y e il Maddener) cambiano aspetto for (int i = 0; i < Core.Enemies.n; i++) { Enemy *e = Core.Enemies.items[i]->owner; if (e->isDead || (e->vt != &E_FAngel && e->vt != &E_Maddener) || !e->x) continue; BridgeX *b = e->x; if (on && b->aliasIdle.n) anims_play(&e->s, &b->aliasIdle, 0); else if (!on && e->idle.n) anims_play(&e->s, &e->idle, 0); } } static void Chapel_faderOut(void *c) { (void)c; tweens_add((TweenConfig){ .props = { { &Chapel.whiteFader.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x1f4 }); } static void Chapel_RevertMad(Enemy *e); static void Chapel_madIn(void *c) { Chapel_ToggleBlue(0), Chapel_ToggleRed(1), Chapel_ToggleAlias(1), Chapel.alias = 1; if (ChS.maddener) ChS.maddener->onDefeat = Chapel_RevertMad; Chapel_faderOut(c); } static void Chapel_madOut(void *c) { Chapel_ToggleBlue(1), Chapel_ToggleRed(0), Chapel_ToggleAlias(0), Chapel.alias = 0; Chapel_faderOut(c); } static void Chapel_FadeToMad(void *c) { // un lampo bianco e la Cappella diventa rossa (void)c; if (!ChS.maddener || ChS.maddener->isDead) return; tweens_add((TweenConfig){ .props = { { &Chapel.whiteFader.alpha, NULL, 1 } }, .nprops = 1, .duration = 0x1f4, .delay = 0x1f4, .onComplete = Chapel_madIn }); } static void Chapel_RevertMad(Enemy *e) { (void)e; Chapel.alias = 0, ChS.maddener = NULL; tweens_add((TweenConfig){ .props = { { &Chapel.whiteFader.alpha, NULL, 1 } }, .nprops = 1, .duration = 0x1f4, .delay = 0x1f4, .onComplete = Chapel_madOut }); } static Enemy *Chapel_reaper(EnemyPool *p) { return EnemyPool_SpawnAt(p, Core.Player->s.x - 0.5f * game_width + 0x60, Core.Player->s.y); } static void Chapel_spawnMaddener(void *c) { (void)c; ChS.maddener = Chapel_reaper(ChS.pMad); if (ChS.maddener) sprite_setScale(&ChS.maddener->s, 0); time_addEvent(0x3e8, 0, 0, Chapel_FadeToMad, NULL); } // --- minuto 30: EnterTheBossi, fadeOutSky, PowerOfFriendshipGoPlanet, EnterPurpleSky, FadeOutPurpleSky --- static void Chapel_bgFill(float k) { sprite_setTintFill(&BGMan.bgtile, ((unsigned)(0x8f * k) << 16) | ((unsigned)(0x69 * k) << 8) | (unsigned)(0xca * k)); } // GetColor(143, 105, 202) * tintHelp static void Chapel_tintUpdate(void *c) { (void)c; Chapel_bgFill(ChS.tintHelp); } static void Chapel_lightsOff(void *c) { (void)c; Chapel.skyLights.s.visible = Chapel.floorLights.s.visible = 0; } static void Chapel_cloudsDraw(Sprite *s) { // 4 gruppi di 12 CloudsP: scala j * W / 1600 (stagger 50 ms, 1 s), poi y -> H/2 in 3 s; girano di 360 in 20 s + 307 j (void)s; if (!ChS.cloudsOn || ChS.cloudsAlpha <= 0) return; const Frame *f = frame_get("backgroundX", "CloudsP.png"); float t = ChS.t - ChS.cloudsT, W = game_width, H = game_height, y = 0.5f * H * ease_sine_inout(lerp01(t, 0x32 * 0xb + 0x3e8, 0xbb8)); for (int j = 0xb; j >= 0; j--) // depth -1800 - j: le nuvole con j piu' alto sotto for (int g = 0; g < 4; g++) { float sc = j * W / 0x140 / 5 * ease_sine_inout(lerp01(t, 0x32 * j, 0x3e8)), per = 0x4e20 + 0x133 * j; if (sc <= 0) continue; float a = ChS.cloudAngle[g][j] + (FB_disableMovingBG ? 0 : 360 * ease_sine_inout(fmodf(t, per) / per)); Sprite p; sprite_init(&p, f, 0.5f * W, y); sprite_setScale(&p, sc), p.angle = a, p.flipX = ChS.cloudFlip[g][j] & 1, p.flipY = ChS.cloudFlip[g][j] >> 1, p.scrollFactor0 = 1, p.alpha = ChS.cloudsAlpha; scene_render_one(&p, (Shader){ 0 }); } } static void Chapel_ShowPurpleOverlays(void *c) { (void)c; float W = game_width, H = game_height; Sprite *o[2] = { &ChS.overlay, &ChS.overlayAdd }; static const char *const fr[2] = { "CloudsOverlay.png", "CloudsOverlayAdd.png" }; for (int i = 0; i < 2; i++) { sprite_init(o[i], frame_get("backgroundX", fr[i]), 0.5f * W, 0.5f * H); o[i]->scaleX = W / 0x140, o[i]->scaleY = H / 0x140, o[i]->scrollFactor0 = 1, o[i]->alpha = 0, o[i]->depth = i ? -0x6a5 : -0x6a4, o[i]->blendAdd = i; children_add(o[i]); } tweens_add((TweenConfig){ .props = { { &ChS.overlayAdd.alpha, NULL, 1 } }, .nprops = 1, .duration = 0x3e8 }); tweens_add((TweenConfig){ .props = { { &ChS.overlay.alpha, NULL, 1 } }, .nprops = 1, .duration = 0x1388 }); } static void Chapel_EnterPurpleSky(void) { tweens_add((TweenConfig){ .props = { { &SFXVolumeFactor, NULL, 1 } }, .nprops = 1, .duration = 0x1388 }); for (int g = 0; g < 4; g++) for (int j = 0; j < 0xc; j++) ChS.cloudAngle[g][j] = 360 * frand(), ChS.cloudFlip[g][j] = (frand() >= 0.5f) | (frand() >= 0.5f) << 1; sprite_init(&ChS.clouds, NULL, 0, 0), ChS.clouds.draw = Chapel_cloudsDraw, ChS.clouds.scrollFactor0 = 1, ChS.clouds.depth = -0x708; children_add(&ChS.clouds); ChS.cloudsOn = 1, ChS.cloudsT = ChS.t, ChS.cloudsAlpha = 1, ChS.tintHelp = 0; tweens_add((TweenConfig){ .props = { { &ChS.tintHelp, NULL, 1 } }, .nprops = 1, .delay = 0x3e8, .duration = 0xbb8, .onUpdate = Chapel_tintUpdate, .onComplete = Chapel_lightsOff }); time_addEvent(0x3e8, 0, 0, Chapel_ShowPurpleOverlays, NULL); } static void Chapel_tintStart(void *c) { (void)c; ChS.tintHelp = 1; } static void Chapel_FadeOutPurpleSky(Enemy *e) { // onDefeat dell'Ender: il cielo viola se ne va, le armi si fermano (tornano a fine partita) (void)e; Chapel.skyLights.s.visible = Chapel.floorLights.s.visible = 1; while (Core.n_weapons > 0 && ChS.nSaved < 16) { Weapon *w = Core.Weapons[--Core.n_weapons]; Weapon_CleanUp(w); ChS.saved[ChS.nSaved++] = w; } tweens_add((TweenConfig){ .props = { { &ChS.cloudsAlpha, NULL, 0 } }, .nprops = 1, .duration = 0x1388, .ease = Ease_SineInOut }); tweens_add((TweenConfig){ .props = { { &ChS.overlay.alpha, NULL, 0 }, { &ChS.overlayAdd.alpha, NULL, 0 } }, .nprops = 2, .duration = 0x3e8 }); tweens_add((TweenConfig){ .props = { { &ChS.tintHelp, NULL, 0 } }, .nprops = 1, .duration = 0x1388, .onStart = Chapel_tintStart, .onUpdate = Chapel_tintUpdate }); } static void Chapel_friendHide(void *c) { ((Sprite *)c)->visible = 0; } static void Chapel_PowerOfFriendshipGoPlanet(void) { // i cinque Mietitori sfilano verso l'alto e svaniscono static const char *const F[5][2] = { { "enemies", "XLReaper_0.png" }, { "enemies3", "Trickster_0.png" }, { "enemies", "Stalker_0.png" }, { "enemies2", "XLDrowner_0.png" }, { "enemies3", "Maddener_0.png" } }; float W = game_width, H = game_height; for (int i = 0; i < 5; i++) { Sprite *s = &ChS.friends[i]; sprite_init(s, frame_get(F[i][0], F[i][1]), (0.2f + 0.15f * i) * W, H); sprite_setScale(s, 5), s->alpha = 0, s->scrollFactor0 = 1, s->depth = 0x2710; children_add(s); tweens_add((TweenConfig){ .props = { { &s->alpha, NULL, 0.75f } }, .nprops = 1, .yoyo = 1, .duration = 0x7d0, .delay = 0x64 * i, .onComplete = Chapel_friendHide, .ctx = s }); tweens_add((TweenConfig){ .props = { { &s->x, NULL, 0.5f * W }, { &s->y, NULL, -0x30 }, { &s->scaleX, &s->scaleY, 1 } }, .nprops = 3, .delay = 0x64 * i, .duration = 0xed8 }); } } static void Chapel_theEnd(void *c) { // a 20 s: TheEndIntro una volta, poi TheEndMain in loop (Chapel_SecretUpdate) (void)c; Chapel_PowerOfFriendshipGoPlanet(); po_sets("SelectedBGM", "TheEndIntro"), po_sets("SelectedBGMMod", "Normal"); Sound_SetupAndPlayBGM_Banger(0); ChS.waitIntro = 1; } static void Chapel_devEnderDie(void *c) { (void)c; if (ChS.ender && !ChS.ender->isDead) Enemy_Die(ChS.ender); } static void Chapel_enderIn(void *c) { (void)c; Chapel_EnterPurpleSky(); LootManager_SetPlainLootTable(); if (!ChS.ender && (ChS.ender = EnemyPool_SpawnAt(ChS.pEnder, Core.Player->s.x, Core.Player->s.y - 0.5f * game_height - 0x30))) ChS.ender->onDefeat = Chapel_FadeOutPurpleSky; if (getenv("VS_ENDERDIE")) time_addEvent(atof(getenv("VS_ENDERDIE")), 0, 0, Chapel_devEnderDie, NULL); // sviluppo: l'Ender muore dopo N ms } static void Chapel_fadeOutSky(void) { TileSprite *k[7] = { &Chapel.skyBlue, &Chapel.skyRed, &Chapel.cloudsBlue, &Chapel.cloudsRed, &Chapel.cloudsAddBlue, &Chapel.cloudsAddRed, &Chapel.cloudsWhite }; for (int i = 0; i < 7; i++) tweens_add((TweenConfig){ .props = { { &k[i]->s.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x3e8 }); Sound_PlayMusic("TheEndIndeed", 1.5f, 0); if (BGM.music.frameCount) SetMusicPitch(BGM.music, 0.1f); // rate 0.1 tweens_add((TweenConfig){ .props = { { &SFXVolumeFactor, NULL, 0.25f } }, .nprops = 1, .duration = 0x1388 }); time_addEvent(0x4e20, 0, 0, Chapel_theEnd, NULL); time_addEvent(0x4e20 + 0x12c0, 0, 0, Chapel_enderIn, NULL); } static void Chapel_bossi6(void *c) { (void)c; Core.Stage->n_DestructibleLocations = 0; TilingTileset *tt = Core.Stage->tilingTileset; if (tt && tt->MainMap) tilemap_removeTilesWithin(tt->MainMap, "Floor", 0, 0, 0x40, 0x40); // removeWalls Chapel_fadeOutSky(); } static void Chapel_stopMusic(void *c) { (void)c; Sound_StopMusic(); } static void Chapel_bossi5(void *c) { // a 5 s: lo sfondo nero, i nemici se ne vanno, la musica sfuma (void)c; sprite_setTintFill(&BGMan.bgtile, 0), BGMan.bgtile.visible = 1; for (int i = Core.Enemies.n - 1; i >= 0; i--) Enemy_Disappear(Core.Enemies.items[i]->owner); Sound_FadeMusic(0, 0x1f4); time_addEvent(0x1f4, 0, 0, Chapel_stopMusic, NULL); } static void Chapel_EnterTheBossi(void) { sprite_setTintFill(&BGMan.bgtile, 0), BGMan.bgtile.visible = 0; Core.Stage->stopCheckingMinutes = 1; TilingTileset *tt = Core.Stage->tilingTileset; for (int c = 0; tt && c < tt->mapsAmount; c++) for (int i = 0; i < tt->layerContainers[c].n; i++) tweens_add((TweenConfig){ .props = { { &tt->layerContainers[c].layers[i]->s.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x3e8, .delay = 0x1388 }); time_addEvent(0x1388, 0, 0, Chapel_bossi5, NULL); time_addEvent(0x1770, 0, 0, Chapel_bossi6, NULL); } static void Chapel_CheckMinute(int m) { // CheckMinute_SummonReapers (solo col segreto) if (!ChS.on) return; Enemy *r = NULL; if (m == 4) Chapel_SnapEggs(); else if (m == 5) r = Chapel_reaper(ChS.pDrown); else if (m == 0xa) r = Chapel_reaper(ChS.pStalk); else if (m == 0xf) Chapel_reaper(ChS.pTrick); else if (m == 0x1e) Chapel_EnterTheBossi(); if (r) sprite_setScale(&r->s, 0); // drowner / stalker .setScale(0) } static void Core_OnTickerEvent(void *ctx); static const Sprite *CamPan_target(void); static int SM_restart; // SceneManager.RestartMainScene // ============================================================================ // Foscari: nemici propri, boss, sigilli e i due stage (0xf7e2 Lake Foscari, 0xba51 Abyss Foscari) // ============================================================================ // --- FS_SNAK* (0x1026f, 0x11e22): vanno dove guardano --------------------------------------------------------------------------- static void Snak_angle(Enemy *e) { e->s.angle = -0x5a + atan2f(e->s.body.velocity.y, e->s.body.velocity.x - 1) * (180 / PI); } static void E_Snak_OnRecycle(Enemy *e) { static const unsigned T[3] = { 0x44bbff, 0x88ffff, 0x44ffbb }; base_EnemyOnRecycle(e); sprite_setOrigin(&e->s, 0.5f, 0.5f); e->saveTint = T[(int)floorf(frand() * 3)], e->s.tint = e->saveTint; } static void E_Snak_Update(Enemy *e) { base_EnemyUpdate(e); Snak_angle(e); } static const EnemyVT E_Snak = { .OnRecycle = E_Snak_OnRecycle, .Update = E_Snak_Update }; static void E_SnakS_endShield(void *ctx) { Enemy *e = ctx; e->sineF = 0; e->hp -= e->firetime; } // hasShield = sineF, shieldDamage = firetime static void E_SnakS_OnRecycle(Enemy *e) { base_EnemyOnRecycle(e); float d = num(enemy_data(e), "shieldDuration", 0); e->fireDelay = d ? d : 0x7d0, e->firetime = 0, e->sineF = 1; time_removeEvent(e->shieldTimer); e->shieldTimer = time_addEvent(e->fireDelay, 0, 0, E_SnakS_endShield, e); } static void E_SnakS_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *t) { // come Jeneviv: lo scudo conta il danno, non lo toglie (void)t; if (amount > 0 && po_is("DamageNumbersEnabled")) Core_ShowDamageAt(e->s.x, e->s.y, amount); if (e->sineF) e->firetime += amount; else e->hp -= amount; if (e->hp <= 0) Enemy_Die(e); else e->damageKB = kb; Sound_PlaySound("Hit", 0.5f, 1, 0x1f4 * (frand() - 0.5f), 0x96, 3); if (hitVFX != HIT_NONE) Core_ShowHitVFXAt(e->s.x, e->s.y, hitVFX); Enemy_OnGetDamaged(e, hitVFX); } static const EnemyVT E_SnakShield = { .OnRecycle = E_SnakS_OnRecycle, .GetDamaged = E_SnakS_GetDamaged, .Update = E_Snak_Update }; // --- FS_SCALING_SALMON (0xa1f6) ------------------------------------------------------------------------------------------------- static void E_Salmon2_OnRecycle(Enemy *e) { base_EnemyOnRecycle(e); sprite_setScale(&e->s, 0); float k = 0.5f * (frand() - 0.2f); tween_stop(e->OnEnterTween); e->OnEnterTween = tweens_add((TweenConfig){ .props = { { &e->s.scaleX, &e->s.scaleY, e->scaleMul + k } }, .nprops = 1, .duration = 0xc8 }); e->maxHp *= k, e->hp = e->maxHp; } static const EnemyVT E_Salmon2 = { .OnRecycle = E_Salmon2_OnRecycle }; // --- 0x1593c (FS_BROWN, FS_HTROW, FS_LAMB, FS_GEF): Song of Mana... FLOWER cura e da' esperienza ----------------------------------- static void E_Flowerfed_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *t) { if (t && !strcmp(t, "FLOWER")) { e->hp += amount; Player_AddXP(Core.Player, 0.001f * Core.Player->level); Core_ShowRecoveryAt(e->s.x, e->s.y, amount); return; } base_EnemyGetDamaged(e, amount, hitVFX, kb, t); } static const EnemyVT E_Flowerfed = { .GetDamaged = E_Flowerfed_GetDamaged }; // --- FS_CAKE (0x1459f): corre in orizzontale; lascia una torta ------------------------------------------------------------------------ static void E_Cake_setOwner(Enemy *e) { e->s.y = Core.Player->s.y + (frand() - 0.5f) * game_height; e->s.x = Core.Player->s.x + (frand() >= 0.5f ? 0.55f * game_width : -0.55f * game_width); e->speed *= 1 + frand(); } static void E_Cake_Die(Enemy *e) { if (!e->isDead && frand() < 0.21f * Player_PLuck(Core.Player)) { Pickup *p = Core_MakePickup(e->s.x, e->s.y, "ROAST"); if (p) sprite_setFrame(&p->s, frame_get("items", "pie.png")), p->goToPlayer = 1, p->time = 1; } base_EnemyDie(e); e->s.body.enable = 0; } static void E_Cake_Update(Enemy *e) { if (e->isDead) return; e->s.depth = e->s.y - Core.Player->s.y; if (e->IsTimeStopped) return; if (!e->FixedDirection || (e->_currentDirection.x == 0 && e->_currentDirection.y == 0)) { float dx = e->target->x - e->s.x; e->_currentDirection.x = dx > 0 ? 1 : dx < 0 ? -1 : 0; } e->_currentDirection.y = 0; float k = e->receivingDamage ? -e->knockback * e->damageKB : 1, v = EnemySpeed * e->speed * k * e->slow; e->s.flipX = e->_currentDirection.x > 0; sprite_setVelocity(&e->s, v * e->_currentDirection.x, 0); } static const EnemyVT E_Cake = { .GetDamaged = E_Flowerfed_GetDamaged, .Die = E_Cake_Die, .Update = E_Cake_Update, .setOwner = E_Cake_setOwner }; // --- FS_MUSH_PATROL, FS_BLINDER_PATROL (0x4332): pattugliano attorno al loro padrone ----------------------------------------------------- static void E_Patrol_OnRecycle(Enemy *e) { base_EnemyOnRecycle(e); cJSON *d = enemy_data(e); e->activated = 1; // isPatrolling e->defaultSpeed = num(d, "speed", 0), e->fireDelay = num(d, "patrolDuration", 0) ? num(d, "patrolDuration", 0) : 0x7d0, e->sineF = 1; sprite_setScale(&e->s, 0); if (tween_get(e->OnEnterTween)) { tween_restart(e->OnEnterTween); if (tween_get(e->OnSineTween)) tween_restart(e->OnSineTween); } else { e->OnEnterTween = tweens_add((TweenConfig){ .props = { { &e->s.scaleX, &e->s.scaleY, e->scaleMul } }, .nprops = 1, .duration = 0x3e8, .persist = 1 }); tween_restartOrAdd(&e->OnSineTween, (TweenConfig){ .props = { { &e->sineF, NULL, -1 } }, .nprops = 1, .delay = 0x64, .duration = e->fireDelay, .repeat = -1, .yoyo = 1, .ease = Ease_SineInOut }); } } static void E_Patrol_DeSpawn(Enemy *e) { base_EnemyDeSpawn(e); tween_stop(e->OnEnterTween); } static void E_Patrol_Update(Enemy *e) { if (!e->activated) { base_EnemyUpdate(e); return; } if (e->owner && e->owner->s.body.enable) { e->target = &e->owner->s; e->speed = e->defaultSpeed * e->sineF; base_EnemyUpdate(e); e->s.flipX = e->_currentDirection.x < 0; } else e->speed = e->defaultSpeed, e->target = &Core.Player->s, e->activated = 0; } static const EnemyVT E_Patrol = { .OnRecycle = E_Patrol_OnRecycle, .DeSpawn = E_Patrol_DeSpawn, .Update = E_Patrol_Update }; // --- FS_MUSH_HP (0xbbf2) --------------------------------------------------------------------------------------------------------------- static void E_MushHP_OnRecycle(Enemy *e) { static const unsigned T[5] = { 0xffaa88, 0xffcc88, 0xffccee, 0xffffff, 0xcccc66 }; base_EnemyOnRecycle(e); e->saveTint = T[(int)floorf(frand() * 5)], e->s.tint = e->saveTint; } static const EnemyVT E_MushHP = { .OnRecycle = E_MushHP_OnRecycle }; // --- FS_CRATE_HP (0xa34b, su 0x2037): rotta, una moneta che vola --------------------------------------------------------------------------- static void E_Crate_OnRecycle(Enemy *e) { E_Molisano_OnRecycle(e); e->s.flipX = 0, e->isCullable = 1; } static void E_Crate_Update(Enemy *e) { E_Molisano_Update(e); e->s.angle = 0; } static void E_Crate_Die(Enemy *e) { E_Molisano_Die(e); Pickup *p = Core_MakePickup(e->s.x, e->s.y, "COIN"); if (p) p->time = 1, p->goToPlayer = 1; } static const EnemyVT E_Crate = { .OnRecycle = E_Crate_OnRecycle, .Die = E_Crate_Die, .GetDamaged = E_Molisano_GetDamaged, .Update = E_Crate_Update }; // --- FS_POT_HP, FS_ANFORA_HP (0x9fb3): maxHp e' il numero di colpi -------------------------------------------------------------------------- static void E_Pot_OnRecycle(Enemy *e) { base_EnemyOnRecycle(e); e->s.flipX = 0, e->firetime = 0, e->activated = 0, e->isCullable = 1, e->speed = 0; // firetime = hitsTaken, activated = isInvul sprite_setScale(&e->s, 0); tween_stop(e->OnEnterTween); e->OnEnterTween = tweens_add((TweenConfig){ .props = { { &e->s.scaleX, &e->s.scaleY, e->scaleMul }, { &e->speed, NULL, 0 } }, .nprops = 2, .duration = 0x12c }); int inv = po_is("SelectedInverse") && po_is("VisuallyInvertStages"); e->s.flipY = inv; sprite_setOrigin(&e->s, 0.5f, inv ? 0 : 1); } static void E_Pot_Update(Enemy *e) { e->s.angle = 0; if (!e->isDead) e->s.depth = e->s.y - Core.Player->s.y; } static void E_Pot_Die(Enemy *e) { base_EnemyDie(e); e->s.body.enable = 0; } static void E_Pot_endInvul(void *ctx) { ((Enemy *)ctx)->activated = 0; } static void E_Pot_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *t) { (void)amount, (void)kb, (void)t; if (e->isDead || e->activated) return; e->activated = 1, e->firetime++; if (e->firetime >= e->maxHp) Sound_PlaySound("Pot", 0.3f, 1, -0x258 * frand() - 0x1f4, 0x64, 4), Enemy_Die(e); else Sound_PlaySound("Bumper2", 0.2f, 1, 0x64 * e->firetime - 0x1f4, 0x64, 4); time_addEvent(0x1f4, 0, 0, E_Pot_endInvul, e); Enemy_OnGetDamaged(e, hitVFX); } static const EnemyVT E_Pot = { .OnRecycle = E_Pot_OnRecycle, .Die = E_Pot_Die, .GetDamaged = E_Pot_GetDamaged, .Update = E_Pot_Update }; // --- BOSS_XLBLINDER (0x10d67): lo Stalker senza tinta (l'uscita a Panini e' di un tasto che la Vita non ha) -------------------------------- static void E_Blinder_OnRecycle(Enemy *e) { E_Stalker_OnRecycle(e); sprite_setTint(&e->s, 0xffffff); } // --- FS_BOSS_AGAEA (0x3263): il boss del lago: si rianima col conto delle uccisioni ------------------------------------------------------- typedef struct { int isInvul, bonusTimes, recoveredTimes, defeated; EnemyPool *summonPool, *summonPool2; Timer SummonEvent; } AgaeaX; static void Agaea_summon(void *ctx) { Enemy *e = ctx; AgaeaX *x = e->x; if (e->isDead) { time_removeEvent(x->SummonEvent); return; } if (!x->summonPool) x->summonPool = EnemyPool_new("FS_GGHOST"), x->summonPool2 = EnemyPool_new("FS_GGGHOST"); float ex = e->s.x, ey = e->s.y; EnemyPool_SpawnAt(x->summonPool, ex + 8, ey - 8), EnemyPool_SpawnAt(x->summonPool, ex - 8, ey + 8), EnemyPool_SpawnAt(x->summonPool, ex, ey); EnemyPool_SpawnAt(x->summonPool2, ex + 8, ey + 8), EnemyPool_SpawnAt(x->summonPool2, ex - 8, ey - 8), EnemyPool_SpawnAt(x->summonPool2, ex, ey); } static void Agaea_blink(void *ctx) { sprite_setTint(&((Enemy *)ctx)->s, 0xffffff); } typedef struct { Enemy *e; Sprite skull, heart; } AgaeaToken; static void Agaea_tokenUpdate(void *ctx) { AgaeaToken *t = ctx; t->heart.alpha = 1 - t->skull.alpha; } static void Agaea_tokenDone(void *ctx) { AgaeaToken *t = ctx; Enemy *e = t->e; AgaeaX *x = e->x; children_remove(&t->skull), children_remove(&t->heart); Sound_PlaySound("Roast", 0.6f, 0.65f, 0, 0x1f4, 1); x->recoveredTimes++; sprite_setTintFill(&e->s, 0xff00); Core_ShowDamageAt(e->s.x, e->s.y, -0x3e8); time_removeEvent(e->_blinkTimeout); e->_blinkTimeout = time_addEvent(0x78, 0, 0, Agaea_blink, e); sprite_setScale(&e->s, 1 + x->recoveredTimes / 100.0f); free(t); } static void Agaea_token(void *ctx) { // GetEnemyToken: dal contatore delle uccisioni al boss Enemy *e = ctx; AgaeaToken *t = calloc(1, sizeof *t); t->e = e; float x = Core.Player->s.x - 0.5f * game_width + MainUI.KillsIcon.x - 8, y = Core.Player->s.y - 0.5f * game_height + MainUI.KillsIcon.y; sprite_init(&t->skull, frame_get("items", "SkullToken.png"), x, y); sprite_init(&t->heart, frame_get("items", "HeartMini.png"), x, y); sprite_setScale(&t->skull, 2), t->skull.depth = t->heart.depth = ZInGameUI - 2, t->heart.alpha = 0; children_add(&t->skull), children_add(&t->heart); tweens_add((TweenConfig){ .props = { { &t->skull.scaleX, &t->skull.scaleY, 1 }, { &t->skull.alpha, NULL, -1 }, { &t->skull.x, NULL, e->s.x } }, .nprops = 3, .duration = 0x1f4, .onUpdate = Agaea_tokenUpdate, .ctx = t }); tweens_add((TweenConfig){ .props = { { &t->skull.y, NULL, e->s.y - 0x18 }, { &t->heart.x, NULL, e->s.x }, { &t->heart.y, NULL, e->s.y - 0x18 } }, .nprops = 3, .duration = 0x1f4 }); tweens_add((TweenConfig){ .props = { { &t->heart.scaleX, &t->heart.scaleY, 2 } }, .nprops = 1, .duration = 0x1f4, .onComplete = Agaea_tokenDone, .ctx = t }); } static void Agaea_start(void *ctx) { Enemy *e = ctx; AgaeaX *x = e->x; Stage *st = Core.Stage; static const char *const G[2] = { "FS_GGHOST", "FS_GGGHOST" }; st->enemies = cJSON_CreateStringArray(G, 2); st->minimum = 0x96; Stage_updateEnemyPools(st); time_removeEvent(x->SummonEvent); x->SummonEvent = time_addEvent(0x1388, 1, 0x64, Agaea_summon, e); x->isInvul = 0; } static void Agaea_tokens(void *ctx) { Enemy *e = ctx; AgaeaX *x = e->x; time_addEvent(0xc8, 1, x->bonusTimes - 1, Agaea_token, e); time_addEvent(0x7d0 + fminf(0x2710, 0xc8 * x->bonusTimes), 0, 0, Agaea_start, e); } static void E_Agaea_OnRecycle(Enemy *e) { base_EnemyOnRecycle(e); if (!e->x) e->x = calloc(1, sizeof(AgaeaX)); AgaeaX *x = e->x; x->bonusTimes = fmaxf(1, ceilf(Core.kills / 1000.0f)); e->maxHp += 0x3e8 * x->bonusTimes; if (po_is("SelectedGoldenEggs")) { cJSON *d = cJSON_GetObjectItem(po("EggData"), po_str("SelectedCharacter")); if (d) e->power += num(d, "power", 0), e->maxHp += num(d, "maxHp", 0); } e->hp = e->maxHp; if (!x->isInvul) time_addEvent(0x1f40, 0, 0, Agaea_tokens, e), x->isInvul = 1; // StartInvulTimer if (!e->ringSprite) { e->ringSprite = calloc(1, sizeof(Sprite)); fx_init(e->ringSprite, "sPFX_ring_64.png", 1), e->ringSprite->visible = 1, sprite_setScale(e->ringSprite, 0); } } static void Banger_later(void *ctx) { (void)ctx; Sound_SetupAndPlayBGM_Banger(1); } static void E_Agaea_DeSpawn(Enemy *e) { time_addEvent(0x3e8, 0, 0, Banger_later, NULL); base_EnemyDeSpawn(e); } static void E_Agaea_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *t) { if (!((AgaeaX *)e->x)->isInvul) base_EnemyGetDamaged(e, amount, hitVFX, kb, t); } static void E_Agaea_Update(Enemy *e) { if (e->isDead) return; e->s.depth = game_height; if (!e->FixedDirection || (e->_currentDirection.x == 0 && e->_currentDirection.y == 0)) { float dx = e->target->x - e->s.x, dy = e->target->y - e->s.y, l = sqrtf(dx * dx + dy * dy); e->_currentDirection = l > 0 ? (Vector2){ dx / l, dy / l } : (Vector2){ 0, 0 }; } float k = e->receivingDamage ? -e->knockback * e->damageKB : 1, v = EnemySpeed * e->speed * k * e->slow; e->s.flipX = e->_currentDirection.x > 0; sprite_setVelocity(&e->s, v * e->_currentDirection.x, v * e->_currentDirection.y); e->s.angle = 0; } static void Ring_scream(Sprite *r, float x, float y) { r->x = x, r->y = y, r->scaleX = r->scaleY = 0, r->visible = 1; tweens_add((TweenConfig){ .props = { { &r->scaleX, &r->scaleY, 0x10 } }, .nprops = 1, .duration = 0x12c, .repeat = 1, .onComplete = Sprite_hide, .ctx = r }); } static void E_Agaea_Die(Enemy *e) { base_EnemyDie(e); Sound_PlaySound("Deathscream", 4, 1, 0, 0x96, 2); Ring_scream(e->ringSprite, e->s.x, e->s.y); } static const EnemyVT E_Agaea = { .OnRecycle = E_Agaea_OnRecycle, .DeSpawn = E_Agaea_DeSpawn, .GetDamaged = E_Agaea_GetDamaged, .Update = E_Agaea_Update, .Die = E_Agaea_Die }; // --- DamagingZone (0x8fbf, pool 0x8b6e): cerchio d'avviso, poi esplosione che fa danno; aggiornate dal fancyBG --------------------------------- typedef struct { Sprite s, GroundFx, Snake; float damage, duration, radius; Timer HitboxTimer; int hasHit, activateDamage, used; TweenRef SnakeT, dispT, disp2T, explT, durT; } FZone; static FZone FZones[32]; static void FZone_despawn(void *ctx) { FZone *z = ctx; z->used = 0, z->activateDamage = 0; time_removeEvent(z->HitboxTimer); z->GroundFx.visible = 0, z->s.visible = 0, z->Snake.visible = 0; } static void FZone_reset(void *ctx) { ((FZone *)ctx)->hasHit = 0; } static void FZone_alpha0(void *ctx) { ((FZone *)ctx)->s.alpha = 0; } static void FZone_noDamage(void *ctx) { ((FZone *)ctx)->activateDamage = 0; } static void FZone_Explode2(void *ctx) { FZone *z = ctx; Sound_PlaySound("Explosion", 0.5f, 1, 0x1f4 * frand(), 0x96, 3); tween_stop(z->SnakeT), tween_stop(z->dispT), tween_stop(z->disp2T), tween_stop(z->explT); z->Snake.alpha = 1; z->explT = tweens_add((TweenConfig){ .props = { { &z->s.scaleX, &z->s.scaleY, 4 }, { &z->Snake.scaleX, &z->Snake.scaleY, 4 }, { &z->Snake.alpha, NULL, 0 } }, .nprops = 3, .duration = 0xc8, .onComplete = FZone_noDamage, .ctx = z }); z->s.alpha = 0; tweens_add((TweenConfig){ .props = { { &z->s.alpha, NULL, 1 } }, .nprops = 1, .duration = 0xc8, .onComplete = FZone_alpha0, .ctx = z }); tweens_add((TweenConfig){ .delay = 0xc8, .props = { { &z->s.alpha, NULL, 0 } }, .nprops = 1, .duration = 0xc8, .onStart = FZone_alpha0, .onComplete = FZone_despawn, .ctx = z }); } static void FZone_Implode(void *ctx) { FZone *z = ctx; tweens_add((TweenConfig){ .props = { { &z->s.scaleX, &z->s.scaleY, 0 }, { &z->s.alpha, NULL, 1 } }, .nprops = 2, .duration = 0x64, .onComplete = FZone_Explode2, .ctx = z }); } static void FZone_grown(void *ctx) { FZone *z = ctx; z->activateDamage = 1; z->disp2T = tweens_add((TweenConfig){ .props = { { &z->s.scaleX, &z->s.scaleY, 0.9f } }, .nprops = 1, .duration = 0x64, .yoyo = 1, .repeat = -1 }); } static void FZone_Explode(void *ctx) { FZone *z = ctx; Sound_PlaySound("Explosion", 0.5f, 1, 0x1f4 * (frand() - 0.5f), 0x96, 3); z->s.visible = 1, z->Snake.visible = 1, z->Snake.x = z->s.x, z->Snake.y = z->s.y; tween_stop(z->SnakeT), tween_stop(z->dispT), tween_stop(z->disp2T); z->Snake.alpha = 0, sprite_setScale(&z->Snake, 0); z->SnakeT = tweens_add((TweenConfig){ .props = { { &z->Snake.scaleX, &z->Snake.scaleY, 1 }, { &z->Snake.alpha, NULL, 0.65f } }, .nprops = 2, .duration = 0x1f4 }); sprite_setScale(&z->s, 0); z->dispT = tweens_add((TweenConfig){ .props = { { &z->s.scaleX, &z->s.scaleY, 2 }, { &z->s.alpha, NULL, 0.65f } }, .nprops = 2, .duration = 0x1f4, .onComplete = FZone_grown, .ctx = z }); z->durT = tweens_add((TweenConfig){ .props = { { &z->GroundFx.x, NULL, z->GroundFx.x } }, .nprops = 1, .duration = z->duration, .onComplete = FZone_Implode, .ctx = z }); } static void FZone_SpawnAt(float x, float y, float radius, float dmg, float duration, float hitDelay) { FZone *z = NULL; for (int i = 0; i < 32 && !z; i++) if (!FZones[i].used) z = &FZones[i]; if (!z) return; // semplificazione: 32 zone bastano al ritmo del boss (13 al massimo in volo) if (!z->s.frame) { static Animation loop; if (!loop.n) make_anim(&loop, "vfx", "Ophion", 0, 0x1f, 4, 0x10, -1); sprite_init(&z->s, frame_get("vfx", "_OPBubble.png"), 0, 0); fx_init(&z->GroundFx, NULL, 1), z->GroundFx.draw = Circle_draw, z->GroundFx.tint = 0xff0000; fx_init(&z->Snake, "Ophion0000.png", 0); anims_play(&z->Snake, &loop, 0); z->HitboxTimer = (Timer){ -1, 0 }; z->SnakeT = z->dispT = z->disp2T = z->explT = z->durT = (TweenRef){ -1, 0 }; } children_remove(&z->s), children_add(&z->s); z->used = 1, z->s.visible = 0, z->s.alpha = 0.2f; z->s.x = z->GroundFx.x = x, z->s.y = z->GroundFx.y = y, z->radius = radius, z->GroundFx.width = radius; z->damage = dmg, z->duration = duration, z->hasHit = 0, z->activateDamage = 0; sprite_setScale(&z->GroundFx, 1), sprite_setScale(&z->s, 0), sprite_setScale(&z->Snake, 0); z->GroundFx.depth = 1, z->GroundFx.alpha = 0, z->GroundFx.visible = 1; time_removeEvent(z->HitboxTimer); z->HitboxTimer = time_addEvent(hitDelay, 1, 0, FZone_reset, z); tweens_add((TweenConfig){ .props = { { &z->GroundFx.alpha, NULL, 0.5f } }, .nprops = 1, .yoyo = 1, .repeat = 2, .duration = 0x12c, .onComplete = FZone_Explode, .ctx = z }); Sound_PlaySound("Pizza", 0.9f, 1, 0x1f4 * frand(), 0x96, 2); } static void FZones_Update(void) { for (int i = 0; i < 32; i++) { FZone *z = &FZones[i]; if (!z->used || z->hasHit || !z->activateDamage) continue; float dx = Core.Player->s.x - z->s.x, dy = Core.Player->s.y - z->s.y; if (dx * dx + dy * dy <= z->radius * z->radius) z->hasHit = 1, Player_GetDamaged(Core.Player, z->damage); } } // --- FS_BOSS_JENEVIV (0x4ad9) ------------------------------------------------------------------------------------------------------------------ typedef struct { int isActivated, isInvul, PainInTheAss, SpecialDeath, hasShield, hasOnActivated; float shieldDamage, totalTime, scitheTime, activationDistance, _defaultSpeed; Timer shieldTimer, DamagingZonesEvent, SummonSnakesEvent; Sprite BreakFree, rays[0xd]; Animation Break, NoEle, NoColor; void (*OnActivated)(void); } JenX; static Enemy *Jeneviv; static void Jen_shieldOff(void *ctx) { Enemy *e = ctx; JenX *x = e->x; x->hasShield = 0; e->hp -= x->shieldDamage; } static void Jen_RestoreShield(Enemy *e) { JenX *x = e->x; x->shieldDamage = 0, x->hasShield = 1; time_removeEvent(x->shieldTimer); x->shieldTimer = time_addEvent(0xafc8, 0, 0, Jen_shieldOff, e); } static void E_Jen_OnRecycle(Enemy *e) { base_EnemyOnRecycle(e); if (!e->x) e->x = calloc(1, sizeof(JenX)); JenX *x = e->x; x->_defaultSpeed = num(enemy_data(e), "speed", 0); sprite_setScale(&e->s, 2); e->isTeleportOnCull = 0, e->isCullable = 0; x->totalTime = 0, x->scitheTime = 0x1388, x->activationDistance = 0x11170, x->shieldTimer = x->DamagingZonesEvent = x->SummonSnakesEvent = (Timer){ -1, 0 }; if (!e->ringSprite) { e->ringSprite = calloc(1, sizeof(Sprite)); fx_init(e->ringSprite, "sPFX_ring_64.png", 1), e->ringSprite->visible = 1, sprite_setScale(e->ringSprite, 0); } Jen_RestoreShield(e); sprite_init(&x->BreakFree, NULL, e->s.x, e->s.y); sprite_setOrigin(&x->BreakFree, 0.5f, 1); x->BreakFree.visible = 0; children_add(&x->BreakFree); make_anim(&x->Break, "foscariChars", "stJeneviv_", 0, 0x1b, 0, 0x10, 0); make_anim(&x->NoColor, "foscariChars", "uJeneviv_i0", 1, 5, 0, 4, -1); make_anim(&x->NoEle, "foscariChars", "noJeneviv_i0", 1, 5, 0, 8, -1); e->s.body.immovable = 1; x->isInvul = 0, x->PainInTheAss = 0, x->isActivated = 0, x->SpecialDeath = 0; Jeneviv = e; memset(FZones, 0, sizeof FZones); } static void E_Jen_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *t) { JenX *x = e->x; if (!x->isActivated || x->isInvul) return; if (t && (!strcmp(t, "PRISMATICMISS") || !strcmp(t, "GUNS3"))) amount *= 5; if (t && !strcmp(t, "PRISMATICMISS2")) amount *= 0x32; if (amount > 0 && po_is("DamageNumbersEnabled")) Core_ShowDamageAt(e->s.x, e->s.y, amount); if (x->hasShield) x->shieldDamage += amount; else e->hp -= amount; if (e->hp <= 0) Enemy_Die(e); else e->damageKB = kb; Sound_PlaySound("Hit", 0.5f, 1, 0x1f4 * (frand() - 0.5f), 0x96, 3); if (hitVFX != HIT_NONE) Core_ShowHitVFXAt(e->s.x, e->s.y, hitVFX); Enemy_OnGetDamaged(e, hitVFX); } static void Jen_SummonSnakes(int a, int b) { PlayCircle(0, a, "FS_SNAKSHIELD", 1.5f); PlayCircle(0, b, "FS_SNAKBOMB", 1.5f); } static void Jen_snakesCb(void *ctx) { (void)ctx; Jen_SummonSnakes(6, 6); } typedef struct { float spread; } JenOphion; static void Jen_zone(void *ctx) { float spread = *(float *)ctx; FZone_SpawnAt(Core.Player->s.x + (frand() - 0.5f) * spread, Core.Player->s.y + (frand() - 0.5f) * spread, 0x40, 0x14, 0x7d0, 0x2ee); } static void Jen_FireOphion(float step, float spread, float n) { static float spreads[64]; static int si; for (int i = 0; i < n; i++) { float *s = &spreads[si++ & 63]; *s = spread; time_addEvent(step * i, 0, 0, Jen_zone, s); } } static void Jen_zonesCb(void *ctx) { (void)ctx; Jen_FireOphion(0x3c + 0x3c * frand(), 0x64 + 0xc8 * frand(), 2 + 8 * frand()); } static void Jen_StartVerySmartAI(void *ctx) { Enemy *e = ctx; JenX *x = e->x; e->speed = x->_defaultSpeed * (po_is("SelectedHyper") ? 1 : 1.2f); x->isInvul = 0; Jen_SummonSnakes(0xc, 0x18); Jen_FireOphion(0x32, 0x190, 0xd); time_removeEvent(x->SummonSnakesEvent); x->SummonSnakesEvent = time_addEvent(0x1a2d, 1, 0, Jen_snakesCb, e); time_removeEvent(x->DamagingZonesEvent); x->DamagingZonesEvent = time_addEvent(0x20a1, 1, 0, Jen_zonesCb, e); } static void E_Jen_Update(Enemy *e) { JenX *x = e->x; e->s.depth = Core.Player->s.y + game_height; x->BreakFree.depth = e->s.depth + 1; if (x->PainInTheAss) Core_SetHardBounds(e->s.x - 0.5f * game_width, e->s.y - 0.5f * game_height, e->s.x + 0.5f * game_width, e->s.y + 0.5f * game_height); // physics.world.setBounds attorno al boss if (!x->isActivated) { float dx = Core.Player->s.x - e->s.x, dy = Core.Player->s.y - e->s.y; if (dx * dx + dy * dy >= x->activationDistance) return; x->isActivated = 1; if (x->OnActivated) { e->isTeleportOnCull = 1; x->OnActivated(), x->OnActivated = NULL; Jen_StartVerySmartAI(e); e->maxHp = 0x12c * Core.Player->level + 0x3e8, e->hp = e->maxHp; // ActivatedByDistance } } base_EnemyUpdate(e); if (e->isDead) return; float v = x->hasShield ? e->maxHp - x->shieldDamage : e->hp; x->scitheTime = 0x1f4 + fmaxf(0, v / e->maxHp * 0xfa0); x->totalTime += Enemies_delta; if (x->totalTime > x->scitheTime) x->totalTime = 0; } static void Jen_DeathScream(void *ctx) { Enemy *e = ctx; Sound_PlaySound("Deathscream", 4, 1, 0, 0x96, 2); Ring_scream(e->ringSprite, e->s.x, e->s.y); } static void Jen_camBack(void *ctx) { (void)ctx; CamPan.on = 0; } static void Jen_restoreTint(void *ctx) { Player_restoreTint(Core.Player); (void)ctx; } static void Jen_treasureOrHand(void *ctx) { Enemy *e = ctx; JenX *x = e->x; anims_play(&e->s, &e->die, 0); if (!x->SpecialDeath) { int lv = 0; Stage_SetTreasureLevelFromChance(Stalker_treasure(), &lv); Core_MakeTreasure(e->s.x, e->s.y, Stalker_treasure(), lv); return; } WhiteHand_Summon(); float limit = num(cJSON_GetObjectItem(cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("stages"), po_str("SelectedStage")), 0), "mods"), "TimeLimit", 0x708); if (Core.SurvivedSeconds < 0x3c + limit) Core.SurvivedSeconds = 0x3c + limit; tweens_add((TweenConfig){ .props = { { &CamPan.k, NULL, 0 } }, .nprops = 1, .duration = 0xc8, .onComplete = Jen_camBack }); while (Core.n_weapons > 0) Core_RemoveWeapon(Core.Weapons[0]->bulletType); if (Player_is(Core.Player, "ELEANOR")) tweens_add((TweenConfig){ .props = { { &Core.Player->s.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x4e20 }); } static void E_Jen_Die(Enemy *e) { JenX *x = e->x; if (e->isDead) return; base_EnemyDie(e); time_removeEvent(x->DamagingZonesEvent), time_removeEvent(x->SummonSnakesEvent); sprite_setVelocity(&e->s, 0, 0); for (int i = 0; i < 32; i++) if (FZones[i].used) FZone_despawn(&FZones[i]); if (x->SpecialDeath) { time_removeEvent(Core.tickerEvent); for (int i = 0; i < Core.Enemies.n; i++) Enemy_Disappear(Core.Enemies.items[i]->owner); PlayerUI.hpBarBG.visible = PlayerUI.hpBar.visible = 0; Sound_FadeMusic(0, 0x1f4); Player_SetInvulForMilliSeconds(Core.Player, 0x7530); Player_restoreTint(Core.Player); time_addEvent(0x64, 0, 0, Jen_restoreTint, NULL); } anims_stop(&e->s); Jen_DeathScream(e); time_addEvent(0x3e8, 1, 4, Jen_DeathScream, e); time_addEvent(0x1388, 0, 0, Jen_treasureOrHand, e); } static void E_Jen_Disappear(Enemy *e) { (void)e; } static const EnemyVT E_Jeneviv = { .OnRecycle = E_Jen_OnRecycle, .GetDamaged = E_Jen_GetDamaged, .Update = E_Jen_Update, .Die = E_Jen_Die, .Disappear = E_Jen_Disappear }; static void Jen_SealInStone(Enemy *e) { JenX *x = e->x; x->activationDistance = 0; e->speed = 0, e->isTeleportOnCull = 0, x->SpecialDeath = 1, x->isInvul = 1; anims_play(&e->s, &x->NoColor, 0), anims_stop(&e->s); sprite_setScale(&e->s, 1); e->maxHp += 0x3e8, e->hp = e->maxHp; for (int i = 0; i < 0xd; i++) { Sprite *r = &x->rays[i]; sprite_init(r, frame_get("vfx", "RayRay.png"), 0.5f * game_width, 0.5f * game_height); sprite_setScale(r, 0); r->scrollFactor0 = 1, r->blendAdd = 1, r->depth = 0x270e; children_add(r); } WE_Make(); } static void Jen_BreakAnim(Enemy *e) { JenX *x = e->x; x->BreakFree.x = e->s.x, x->BreakFree.y = e->s.y, x->BreakFree.visible = 1; anims_play(&x->BreakFree, &x->Break, 0); } static void Jen_BreakFree1(void *ctx) { Enemy *e = Jeneviv; (void)ctx; Jen_BreakAnim(e); e->maxHp = 0x12c * Core.Player->level + 0x3e8, e->hp = e->maxHp; } static void Jen_StartMoving(void *ctx) { Enemy *e = Jeneviv; JenX *x = e->x; (void)ctx; Jen_BreakAnim(e); e->isTeleportOnCull = 1, x->isActivated = 1, e->speed = 0.1f * x->_defaultSpeed, x->PainInTheAss = 1; anims_play(&e->s, &x->NoColor, 0); } static void Jen_BreakFree2(void *ctx) { Enemy *e = Jeneviv; (void)ctx; Jen_BreakAnim(e); anims_play(&e->s, &((JenX *)e->x)->NoEle, 0); e->speed = ((JenX *)e->x)->_defaultSpeed; } static void Jen_ChargeWorldEater(void *ctx) { Enemy *e = Jeneviv; JenX *x = e->x; (void)ctx; anims_play(&e->s, &x->NoEle, 0); e->speed = 0; for (int i = 0; i < 0xd; i++) { Sprite *r = &x->rays[i]; r->angle = 0x168 * (frand() - 0.5f), r->alpha = 1, sprite_setScale(r, 0); tweens_add((TweenConfig){ .props = { { &r->alpha, NULL, 0 }, { &r->scaleX, &r->scaleY, 2 }, { &r->angle, NULL, 0x19 * r->angle } }, .nprops = 3, .duration = 0xfa0 }); } } static void Jen_StealHeart(void *ctx); static void Jen_heartDone(void *ctx) { Sprite *s = ctx; children_remove(s), free(s); Sound_PlaySound("Roast", 0.3f, 0.65f, 0, 0x1f4, 1); if (Jeneviv) Core_ShowDamageAt(Jeneviv->s.x, Jeneviv->s.y, -6); } static void Jen_StealHeart(void *ctx) { Enemy *e = Jeneviv; (void)ctx; Sprite *s = calloc(1, sizeof(Sprite)); sprite_init(s, frame_get("items", "HeartMini.png"), Core.Player->s.x, Core.Player->s.y); s->depth = ZInGameUI - 2; children_add(s); tweens_add((TweenConfig){ .props = { { &s->scaleX, &s->scaleY, 2 }, { &s->x, NULL, e->s.x }, { &s->y, NULL, e->s.y - 0x18 } }, .nprops = 3, .duration = 0x1f4, .onComplete = Jen_heartDone, .ctx = s }); } static void Jen_DevourEleanor(Enemy *e) { if (!Player_is(Core.Player, "ELEANOR")) return; Core_RemoveWeapon("SPELL_STRING"), Core_RemoveWeapon("SPELL_STREAM"), Core_RemoveWeapon("SPELL_STRIKE"), Core_RemoveWeapon("SPELL_STROM"); static const char *const I[4] = { "2SpellString.png", "2SpellStream.png", "2SpellStrike.png", "2SpellStrom.png" }; static Sprite spell[4]; float px = Core.Player->s.x, py = Core.Player->s.y, a = 2 * PI / 4; for (int i = 0; i < 4; i++) { Sprite *s = &spell[i]; sprite_init(s, frame_get("items", I[i]), px, py); sprite_setOrigin(s, 0.5f, 1); s->depth = 0x2328; children_add(s); tweens_add((TweenConfig){ .props = { { &s->x, NULL, px + cosf(0.5f + a * i) * 0x3c }, { &s->y, NULL, py + sinf(0.5f + a * i) * 0x3c } }, .nprops = 2, .duration = 0x3e8, .ease = Ease_SineInOut, .delay = 0x320 + 0x64 * i }); tweens_add((TweenConfig){ .props = { { &s->scaleX, NULL, 0 }, { &s->scaleY, NULL, 0xa }, { &s->x, NULL, e->s.x } }, .nprops = 3, .duration = 0x1f4, .ease = Ease_SineInOut, .delay = 0x320 + 0x64 * i + 0x3e8 + 0x3e8 + 0x64 * i, .onComplete = Sprite_hide, .ctx = s }); } cJSON *d = cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("characters"), "ELEANOR"), 0); static Animation uwalk; char prefix[64]; snprintf(prefix, sizeof prefix, "u%s", str(d, "spriteName")); char *c = strstr(prefix, "01.png"); if (c) *c = 0; make_anim(&uwalk, str(d, "textureName"), prefix, 1, (int)num(d, "walkingFrames", 0), 2, num(d, "walkFrameRate", 8) ? num(d, "walkFrameRate", 8) : 8, -1); anims_play(&Core.Player->s, &uwalk, 0); } static void Jen_CastWorldEater(void *ctx) { Enemy *e = Jeneviv; JenX *x = e->x; (void)ctx; e->speed = 0.5f * x->_defaultSpeed; Sound_PlaySound("WorldEater", 2, 1, 0, 0, 0); tweens_add((TweenConfig){ .props = { { &SFXVolumeFactor, NULL, 1 } }, .nprops = 1, .duration = 0x1f4 }); WE_CastSoulSteal(NULL); // PlayWorldEater: lo stesso teschio tweens_add((TweenConfig){ .props = { { &e->s.scaleX, &e->s.scaleY, 2 } }, .nprops = 1, .duration = 0x3a98 }); time_addEvent(0xc8, 1, 0x4b, Jen_StealHeart, NULL); Jen_DevourEleanor(e); anims_play(&e->s, &e->idle, 0); } // --- I sigilli (Prop_FoscariSeal1 0x28be, 2 0x169f6, 3 0xdcc): si rompono solo col personaggio giusto e la sua evoluzione ----------------------- static struct { Weapon *saved[32]; int n; const char *eventW[16]; int nEvent; Sprite Darkness, Fog; int hasFx; } FoscariRun; static const struct { const char *ch, *weapon; } SealKey[3] = { { "KEIRA", "FLASHARROW2" }, { "VICTOR", "SWORD2" }, { "ELEANOR", "SPELL_STROM" } }; static void Seal_MakeLevelOne(Destructible *d) { int k = d->sealKind - 1; char prefix[16]; snprintf(prefix, sizeof prefix, "Seal%d_", k + 1); make_anim(&d->idle, "items", prefix, 1, 4, 0, 4, -1); snprintf(prefix, sizeof prefix, "Seal%d_d_", k + 1); make_anim(&d->destroyAnim, "items", prefix, 0, 0x13, 0, 8, 0); sprite_setOrigin(&d->s, 0.5f, 0.5f); d->alreadyDestroyed = 0; anims_play(&d->s, &d->idle, 0); body_setCircle(&d->s.body, 0x26, 0, 0x20); d->s.depth = k == 2 ? 0x7d0 : game_height; tweens_add((TweenConfig){ .props = { { &d->s.y, NULL, d->s.y - 8 } }, .nprops = 1, .duration = 0x3e8, .ease = Ease_SineInOut, .loop = -1, .yoyo = 1 }); } static void Seal_shake(int repeat) { camera_followOffsetX = -2; tweens_add((TweenConfig){ .props = { { &camera_followOffsetX, NULL, 2 } }, .nprops = 1, .duration = 0x10, .yoyo = 1, .repeat = repeat, .onComplete = Weapon_ScreenShake_done }); } static void Seal_camArrived(void *ctx) { Destructible *d = ctx; Sound_PlaySound("Crystal12", 0.5f, 1, -0x258 * frand(), 0, 0); FrameFreeze_ms = 0x78; Seal_shake(6); anims_stop(&d->s); sprite_setScale(&d->s, 2); anims_play(&d->s, &d->destroyAnim, 0); } static void Seal_panTo(Destructible *d) { CamPan.on = 1, CamPan.k = 0, CamPan.e = NULL, CamPan.sp = &d->s; tweens_add((TweenConfig){ .props = { { &CamPan.k, NULL, 1 } }, .nprops = 1, .duration = 0x7d0, .onComplete = Seal_camArrived, .ctx = d }); } static void Seal_common(Destructible *d) { json_inc(cJSON_GetObjectItem(data_get("props"), d->destructibleType), "destroyedAmount"); d->alreadyDestroyed = 1, d->s.visible = 1; PlayerOptions_Save(); for (int i = 0; i < Core.Enemies.n; i++) Enemy_Disappear(Core.Enemies.items[i]->owner); Sound_FadeMusic(0, 0x5dc); Core.canInterrupt = 0, Core.canPause = 0; PlayerUI.hpBarBG.visible = PlayerUI.hpBar.visible = 0; time_removeEvent(Core.tickerEvent), time_removeEvent(Core.Stage->SpawnTimer); Player_SetInvulForMilliSeconds(Core.Player, 0x7530); Player_restoreTint(Core.Player); time_addEvent(0x64, 0, 0, Jen_restoreTint, NULL); Seal_panTo(d); } static void Foscari_stashWeapons(void) { // playerWeapons: via dalle liste, tenute per il riepilogo while (Core.n_weapons > 0 && FoscariRun.n < 32) { Weapon *w = Core.Weapons[--Core.n_weapons]; Weapon_CleanUp(w); FoscariRun.saved[FoscariRun.n++] = w; if (FoscariRun.nEvent < 16) FoscariRun.eventW[FoscariRun.nEvent++] = w->bulletType; } while (Core.n_HiddenWeapons > 0 && FoscariRun.n < 32) { Weapon *w = Core.HiddenWeapons[--Core.n_HiddenWeapons]; Weapon_CleanUp(w); FoscariRun.saved[FoscariRun.n++] = w; } } // Sigillo 1: il lago si prosciuga e si cade nell'abisso, con la stessa partita (RestartMainScene su FOSCARI2) static void Seal1_shakeEarth(void *ctx) { (void)ctx; Seal_shake(0x271); } static float *FoscariWaterAlpha, *FoscariWaterScale; static void Seal1_removeWater(void *ctx) { (void)ctx; Sound_PlayMusic("TheEndIndeed", 1.5f, 1); if (FoscariWaterAlpha) tweens_add((TweenConfig){ .props = { { FoscariWaterAlpha, NULL, 0 }, { FoscariWaterScale, NULL, 8 } }, .nprops = 2, .duration = 0xfa0 }); } static void Seal1_restart(void *ctx) { (void)ctx; SM_restart = 1; } static void Seal1_toggleUI(void *ctx) { (void)ctx; po_sets("SelectedStage", "FOSCARI2"), po_sets("SelectedBGM", "BGM_Foscari2"), po_sets("SelectedBGMMod", "Normal"); time_addEvent(0x1388, 0, 0, Seal1_restart, NULL); } static void Seal1_changeStage(void *ctx) { (void)ctx; Sound_PlaySound("Scream", 0.5f, 1, 0, 0, 0); Sprite *f = &FoscariRun.Fog, *b = &FoscariRun.Darkness; sprite_init(b, frame_get("vfx", "blackDot.png"), 0, 0), sprite_setOrigin(b, 0, 0), b->scrollFactor0 = 1, b->scaleX = game_width, b->scaleY = game_height, b->alpha = 0, b->depth = 0x1771; sprite_init(f, frame_get("vfx", "fog.png"), 0, 0), sprite_setOrigin(f, 0, 0), f->scrollFactor0 = 1, f->scaleX = game_width / 160.0f, f->scaleY = game_height / 100.0f, f->alpha = 0, f->depth = 0xbb9; children_add(b), children_add(f); tweens_add((TweenConfig){ .props = { { &f->alpha, NULL, 1 }, { &b->alpha, NULL, 1 } }, .nprops = 2, .duration = 0x1f4, .onComplete = Seal1_toggleUI }); } static void Seal_OnDestroyed(Destructible *d); static void Seal2_shake(void *ctx) { (void)ctx; Sound_PlayMusic("TheEndIndeed", 1.5f, 1); Seal_shake(312); } static void Seal2_panBack(void *ctx) { (void)ctx; tweens_add((TweenConfig){ .props = { { &CamPan.k, NULL, 0 } }, .nprops = 1, .duration = 0x1f4, .onComplete = Jen_camBack }); } static void Fosc2_OnSeal2Destroyed(void); static void Seal2_done(void *ctx) { (void)ctx; Fosc2_OnSeal2Destroyed(); Core.canInterrupt = 1, Core.canPause = 1; PlayerUI.hpBarBG.visible = PlayerUI.hpBar.visible = 1; Core.tickerEvent = time_addEvent(po_is("SelectedHurry") ? 0x1f4 : 0x3e8, 1, 0, Core_OnTickerEvent, NULL); // RestoreTickerEvent Stage_startTimers(Core.Stage); } static void Fosc2_FreeJeneviv(void *ctx); static void Seal_OnDestroyed(Destructible *d) { if (d->alreadyDestroyed) return; if (d->sealKind == 1) { if (!po_has("UnlockedStages", "FOSCARI2")) po_push("UnlockedStages", "FOSCARI2"); FoscariRun.n = 0, FoscariRun.nEvent = 0; Foscari_stashWeapons(); Seal_common(d); time_addEvent(0x1388, 0, 0, Seal1_shakeEarth, NULL); time_addEvent(0x1770, 0, 0, Seal1_removeWater, NULL); time_addEvent(0x3a98, 0, 0, Seal1_changeStage, NULL); } else if (d->sealKind == 2) { Seal_common(d); time_addEvent(0x1388, 0, 0, Seal2_shake, NULL); time_addEvent(0x1b58, 0, 0, Seal2_panBack, NULL); time_addEvent(0x2710, 0, 0, Seal2_done, NULL); } else { Seal_common(d); tweens_add((TweenConfig){ .props = { { &SFXVolumeFactor, NULL, 0.1f } }, .nprops = 1, .duration = 0x9c4 }); time_addEvent(0x1388, 0, 0, Fosc2_FreeJeneviv, d); } } static void Seal_dev(void) { // sviluppo: VS_FOSC=seal rompe il sigillo presente for (int i = 0; i < Core.n_destructiblesPools; i++) for (int k = 0; k < Core.destructiblesPools[i]->n_spawned; k++) { Destructible *d = Core.destructiblesPools[i]->spawned[k]; if (d->sealKind == (getenv("VS_F2OPEN") ? 3 : d->sealKind)) { Seal_OnDestroyed(d); return; } } } static void Seal_GetDamaged(Destructible *d, float amount) { // bullet nel chiamante (Destructible_hitBy) int k = d->sealKind - 1; if (d->isDead || !Destructible_hitBy || !Player_is(Core.Player, SealKey[k].ch) || strcmp(Destructible_hitBy, SealKey[k].weapon)) return; if (fabsf(d->s.x - Core.Player->s.x) >= 0.45f * game_width || fabsf(d->s.y - Core.Player->s.y) >= 0.45f * game_height) return; d->hp -= amount; if (d->hp <= 0) { d->isDead = 1; Seal_OnDestroyed(d); } else Destructible_OnGetDamaged(d); } // --- Lake Foscari (0xf7e2): l'acqua: lo shader finche' c'e' il primo sigillo, poi l'animazione --------------------------------------------------- #ifdef __vita__ #define WATER_DIV 4 // 1/4 di risoluzione sulla Vita: misurato a 60 fps #else #define WATER_DIV 1 #endif static const char WATER_FS[] = "uniform float time;\nuniform vec2 resolution;\n" "vec4 water(vec2 fragCoord) {\n" " float varTime = time * .5 + 23.0;\n" " vec2 uv = fragCoord.xy / resolution.xy;\n" " vec2 p = mod(uv * 6.28318530718, 6.28318530718) - 250.0;\n" " vec2 i = vec2(p);\n float c = 1.0;\n float inten = .005;\n" " for (int n = 0; n < 5; n++) {\n" " float t = varTime * (1.0 - (3.5 / float(n + 1)));\n" " i = p + vec2(cos(t - i.x) + sin(t + i.y), sin(t - i.y) + cos(t + i.x));\n" " c += 1.0 / length(vec2(p.x / (sin(i.x + t) / inten), p.y / (cos(i.y + t) / inten)));\n" " }\n" " c /= float(5);\n c = 1.17 - pow(c, 1.4);\n" " vec3 colour = vec3(pow(abs(c), 8.0));\n" " colour = clamp(colour + vec3(0.0, 0.35, 0.5), 0.0, 1.0);\n" " return vec4(colour, 1.0);\n}\n"; static struct { Shader sh; RenderTexture2D rt; int locTime, locRes, ok; float time; Sprite image; } Water; static void Water_draw(Sprite *s) { // image di 'rt_waterFoscari': scala 2 sulla sua meta' schermo if (!s->visible || s->alpha <= 0 || !Water.ok) return; float res[2] = { (float)Water.rt.texture.width, (float)Water.rt.texture.height }; SetShaderValue(Water.sh, Water.locTime, &Water.time, SHADER_UNIFORM_FLOAT); SetShaderValue(Water.sh, Water.locRes, res, SHADER_UNIFORM_VEC2); EndShaderMode(); float w = Water.rt.texture.width * WATER_DIV * s->scaleX, h = Water.rt.texture.height * WATER_DIV * s->scaleY; DrawTexturePro(Water.rt.texture, (Rectangle){ 0, 0, Water.rt.texture.width, -Water.rt.texture.height }, (Rectangle){ s->x - w / 2, s->y - h / 2, w, h }, (Vector2){ 0, 0 }, 0, (Color){ 255, 255, 255, (unsigned char)(255 * fminf(1, s->alpha)) }); } static void Water_InitVFX(void) { if (!Water.ok) { char fs[4096]; #ifdef __vita__ snprintf(fs, sizeof fs, "#version 100\nprecision mediump float;\nvarying vec2 fragTexCoord;\n%svoid main() { gl_FragColor = water(gl_FragCoord.xy); }\n", WATER_FS); #else snprintf(fs, sizeof fs, "#version 330\nin vec2 fragTexCoord;\nout vec4 finalColor;\n%svoid main() { finalColor = water(gl_FragCoord.xy); }\n", WATER_FS); #endif Water.sh = LoadShaderFromMemory(NULL, fs); Water.locTime = GetShaderLocation(Water.sh, "time"), Water.locRes = GetShaderLocation(Water.sh, "resolution"); Water.rt = LoadRenderTexture(game_width / 2 / WATER_DIV, game_height / 2 / WATER_DIV); Water.ok = 1; } sprite_init(&Water.image, NULL, 0.5f * game_width, 0.5f * game_height); sprite_setScale(&Water.image, 2); Water.image.draw = Water_draw, Water.image.scrollFactor0 = 1, Water.image.depth = -0x2710; children_add(&Water.image); FoscariWaterAlpha = &Water.image.alpha, FoscariWaterScale = &Water.image.scaleX; } static void Water_render(float delta) { // la Shader di Phaser si ridisegna a ogni frame nella sua texture Water.time += delta / 1000; if (!Water.ok || Water.image.alpha <= 0) return; float res[2] = { (float)Water.rt.texture.width, (float)Water.rt.texture.height }; SetShaderValue(Water.sh, Water.locTime, &Water.time, SHADER_UNIFORM_FLOAT); SetShaderValue(Water.sh, Water.locRes, res, SHADER_UNIFORM_VEC2); BeginTextureMode(Water.rt); BeginShaderMode(Water.sh); DrawRectangle(0, 0, Water.rt.texture.width, Water.rt.texture.height, WHITE); EndShaderMode(); EndTextureMode(); } static struct { TileSprite water; Texture2D frames[8]; float clock; int hasMagic; } FL; static Vector2 Scripts_pos(const char *name, float dx, float dy) { // getObjectLayer('Scripts'), con il valore di riserva dell'originale cJSON *o; cJSON_ArrayForEach(o, tilemap_getObjectLayerObjects(Core.Stage->tilingTileset->MainMap, "Scripts")) if (str(o, "name") && !strcmp(str(o, "name"), name)) return (Vector2){ num(o, "x", dx), num(o, "y", dy) }; return (Vector2){ dx, dy }; } static int Ach_achieved(const char *key) { return cJSON_IsTrue(cJSON_GetObjectItem(cJSON_GetObjectItem(data_get("achievements"), key), "achieved")) || po_has("Achievements", key); } static void Foscari_Create(void) { FL.hasMagic = !Ach_achieved("FOSC10_BreakSeal1"); FoscariWaterAlpha = NULL; if (FL.hasMagic) Water_InitVFX(); else { char n[16]; for (int i = 0; i < 8; i++) snprintf(n, sizeof n, "water%d.png", i + 1), FL.frames[i] = frame_texture("background_Foscari", n); sprite_init(&FL.water.s, NULL, 0.5f * game_width, 0.5f * game_height); FL.water.s.draw = TileSprite_draw, FL.water.s.scrollFactor0 = 1, FL.water.s.depth = -0x2711, FL.water.s.tint = 0xffffff; FL.water.tex = frame_texture("background_Foscari", "bg_foscari.png"), FL.water.w = game_width, FL.water.h = game_height; children_add(&FL.water.s); FL.clock = 0; } Vector2 p = Scripts_pos("FS_SEAL1", 0x2260, 0x680); if (FL.hasMagic) { Destructible *d = Core_MakeDestructibleAt("FOSCARI_SEAL_1", p); if (d) d->sealKind = 1, Seal_MakeLevelOne(d); } else Core_MakeStagePickup(p.x, p.y, "WEAPON", "ACADEMYBADGE"); } static void FLake_Update(float delta) { if (FL.hasMagic) { Water_render(delta); return; } FL.clock += delta; // setFrame(waterAnim.frame.name): l'acqua cambia a 8 fps FL.water.tex = FL.frames[(int)(FL.clock / 125) % 8]; FL.water.tilePositionX = Core.Player->s.x, FL.water.tilePositionY = Core.Player->s.y; } static void Foscari_OnInitCompleted(void) { Core_SetHardBounds(0x100, 0x100, 0x2700, 0x2700); } static const FancyBG FB_Foscari = { .Create = Foscari_Create, .Update = FLake_Update, .OnInitCompleted = Foscari_OnInitCompleted }; // --- Abyss Foscari (0xba51): il battito ferma i nemici; il muro nero, il secondo e il terzo sigillo, Jeneviv ------------------------------------- static struct { TileSprite water; Sprite sDarkness, sBlackWall, sFader, PizzaSprite; ParticleManager *pm, *shadowPm; ParticleEmitter *glitch1, *glitch2, *Shadow; EnemyPool *poolJeneviv; int isBeating, beats, canPizza, isJenevivSealed, isPathBlocked, CheckForLuminaire; float tilingOffset, waterOffset, pizzaX, pizzaY; Timer beatEvent, luminairePathEvent; char saveBGM[48], saveBGMMod[48]; Sprite luminaire; Animation lumWalk; } F2; static void Fosc2_ResumeEnemiesMovement(void) { for (int i = 0; i < Core.Enemies.n; i++) { Enemy *e = Core.Enemies.items[i]->owner; anims_resume(&e->s); e->conditional_canMove = 1; } Enemy_beatMode = 1; } static void Fosc2_onBeat(void *ctx) { (void)ctx; F2.beats++; if (F2.beats % 2 == 0) { Enemy_beatMode = 1; for (int i = 0; i < Core.Enemies.n; i++) { Enemy *e = Core.Enemies.items[i]->owner; if (e->isDead) continue; anims_pause(&e->s); e->conditional_canMove = 0; sprite_setVelocity(&e->s, 0, 0); } } else Fosc2_ResumeEnemiesMovement(); } static void Fosc2_StopBeat(void) { if (!F2.isBeating) return; F2.isBeating = 0; time_removeEvent(F2.beatEvent); Core.Stage->StageModifiers.EnemySpeed -= 1; Stage_CalculateEnemySpeed(Core.Stage); } static void Fosc2_OnJenevivActivation(void) { Fosc2_StopBeat(), Fosc2_ResumeEnemiesMovement(); } static void Fosc2_ForceSpoopyMusic(void) { po_sets("SelectedBGM", "BGM_Foscari2"), po_sets("SelectedBGMMod", "Normal"); Sound_SetupAndPlayBGM_Banger(1); } static void Fosc2_SetBoundsBeforeSeal2(void) { if (po_is("SelectedInverse")) Core_SetHardBounds(0x100, 0x100, 0x1500, 0x2700), F2.sBlackWall.x = 0x1400; else Core_SetHardBounds(0x1400, 0x100, 0x2700, 0x2700); } static void Fosc2_wallGone(void *ctx) { (void)ctx; F2.sBlackWall.visible = 0; } static void Fosc2_openBounds(void *ctx) { (void)ctx; Core_SetHardBounds(0x100, 0x100, 0x2700, 0x2700); tweens_add((TweenConfig){ .props = { { &F2.sBlackWall.x, NULL, F2.sBlackWall.x - 0x400 }, { &F2.sBlackWall.alpha, NULL, 0 } }, .nprops = 2, .duration = 0x1388, .onComplete = Fosc2_wallGone }); } static void Fosc2_OnSeal2Destroyed(void) { Fosc2_ForceSpoopyMusic(); F2.isPathBlocked = 0; tweens_add((TweenConfig){ .props = { { &F2.sBlackWall.x, NULL, F2.sBlackWall.x - 0x100 } }, .nprops = 1, .duration = 0x1388, .onComplete = Fosc2_openBounds }); } static void Fosc2_SummonSnakes(void *ctx) { (void)ctx; PlayCircle(0, 0x32, "FS_SNAKSHIELD", 1.4f); PlayCircle(0, 0x32, "FS_SNAKSHIELD", 1.5f); Seal_shake(6); } static void Fosc2_wave1(void *ctx) { (void)ctx; if (po_is("SelectedGoldenEggs")) EggManager_RemoveBonuses(); Fosc2_SummonSnakes(NULL); } // DevourEggs: semplificazione: le uova che volano sono solo un effetto; il bonus sparisce davvero static const char *const Fosc2_starters[2] = { "WHIP", "MAGIC_MISSILE" }; static void Fosc2_OnWorldEater(void *ctx) { (void)ctx; Jen_CastWorldEater(NULL); FoscariRun.n = 0, FoscariRun.nEvent = 0; for (int i = 0; i < Core.n_weapons; i++) MainUI_Remove(Core.Weapons[i]->bulletType); Foscari_stashWeapons(); // l'originale tiene i PowerUp: non sparano comunque float px = Core.Player->s.x, py = Core.Player->s.y, d = 0.6f * game_height; for (int k = 0; k < 2; k++) { // CreateWeapons Pickup *p = Core_MakeStagePickup(k ? px + 0xc8 : px - 0xc8, py + d, "WEAPON", Fosc2_starters[k]); if (p) p->despawnOnUnavailable = 0, p->hasSpawned = 1; } } static void Fosc2_luminaireTick(void *ctx) { (void)ctx; float x = Core.Player->s.x, y = Core.Player->s.y + 0.25f * game_height; Weapon *pm = Core_GetWeapon("PRISMATICMISS"); Weapon *g = Core_GetWeapon("GROWTH"); const char *give = !pm || pm->level < 8 ? "PRISMATICMISS" : !g || g->level < 5 ? "GROWTH" : NULL; if (give) { Pickup *p = Core_MakeStagePickup(x, y, "WEAPON", give); if (p) p->despawnOnUnavailable = 0, GizmoManager_ShowHighlightAt(x, y), p->hasSpawned = 1; return; } int lv = 0; Stage_SetTreasureLevelFromChance(Stalker_treasure(), &lv); // [0.1, 5, 100]: mai letti, come per lo Stalker Core_MakeTreasure(x, y, Stalker_treasure(), lv); GizmoManager_ShowHighlightAt(x, y); F2.CheckForLuminaire = 1; } static void Fosc2_light(void *ctx) { (void)ctx; Core.canInterrupt = 1, Core.canPause = 1; time_removeEvent(F2.luminairePathEvent); F2.luminairePathEvent = time_addEvent(0x2710, 1, 0, Fosc2_luminaireTick, NULL); } static void Fosc2_lumBGM(void *ctx) { (void)ctx; po_sets("SelectedBGM", "BGM_Luminaire"), po_sets("SelectedBGMMod", "Normal"); Sound_SetupAndPlayBGM_Banger(1); } static void Fosc2_lumArrived(void *ctx) { (void)ctx; MainUI.SurvivedSecondsText.s.visible = 0; } static void Fosc2_LuminaireArrives(void) { Jen_RestoreShield(Jeneviv); time_removeEvent(F2.luminairePathEvent); F2.CheckForLuminaire = 0; Sound_FadeMusic(0, 0x1f4); Core.canInterrupt = 0, Core.canPause = 0; time_addEvent(0x3e8, 0, 0, Fosc2_lumBGM, NULL); Sprite *s = &F2.luminaire; make_anim(&F2.lumWalk, "foscariChars", "Luminaire_i0", 1, 5, 0, 8, -1); sprite_init(s, NULL, 0.25f * game_width, 1.2f * game_height); sprite_setScale(s, 2), s->scrollFactor0 = 1; children_add(s); anims_play(s, &F2.lumWalk, 0); tweens_add((TweenConfig){ .props = { { &s->scaleX, &s->scaleY, 1 }, { &s->x, NULL, 0.5f * game_width }, { &s->y, NULL, 0x20 } }, .nprops = 3, .ease = Ease_SineInOut, .duration = 0x5dc, .onComplete = Fosc2_lumArrived }); } static void Fosc2_camFollow(void *ctx) { (void)ctx; } static void Fosc2_FreeJeneviv(void *ctx) { (void)ctx; Fosc2_StopBeat(), Fosc2_ResumeEnemiesMovement(); CamPan.fromX = CamPan_target()->x, CamPan.fromY = CamPan_target()->y, CamPan.hasFrom = 1, CamPan.on = 1, CamPan.k = 0, CamPan.sp = NULL, CamPan.e = Jeneviv; tweens_add((TweenConfig){ .props = { { &CamPan.k, NULL, 1 } }, .nprops = 1, .duration = 0x1f4, .onComplete = Fosc2_camFollow }); po_sets("SelectedBGM", "BGM_Genevieve"), po_sets("SelectedBGMMod", "Normal"); Sound_SetupAndPlayBGM_Banger(1); Core.canInterrupt = 0, Core.canPause = 0; time_addEvent(0x1b58, 0, 0, Fosc2_wave1, NULL); time_addEvent(0x34bc, 0, 0, Fosc2_SummonSnakes, NULL); time_addEvent(0x5014, 0, 0, Fosc2_SummonSnakes, NULL); time_addEvent(0x7530, 0, 0, Jen_BreakFree1, NULL); time_addEvent(0x82dc, 0, 0, Jen_StartMoving, NULL); time_addEvent(0x9088, 0, 0, Jen_BreakFree2, NULL); time_addEvent(0xb798, 0, 0, Jen_ChargeWorldEater, NULL); time_addEvent(0xc350, 0, 0, Fosc2_OnWorldEater, NULL); time_addEvent(0xfde8, 0, 0, Jen_StartVerySmartAI, Jeneviv); time_addEvent(0x11170, 0, 0, Fosc2_light, NULL); } static void Fosc2_CheckPizzas(void) { if (!F2.canPizza || !F2.PizzaSprite.frame) return; float dx = Core.Player->s.x - F2.pizzaX, dy = Core.Player->s.y - F2.pizzaY; if (dx * dx + dy * dy > 0x10 * 0x10) return; F2.canPizza = 0; Fosc2_StopBeat(), Fosc2_ResumeEnemiesMovement(); Sound_PlaySound("Bumper", 1, 1, 0, 0x64, 4); F2.PizzaSprite.alpha = 0.65f; tweens_add((TweenConfig){ .props = { { &F2.PizzaSprite.scaleX, &F2.PizzaSprite.scaleY, 1.5f }, { &F2.PizzaSprite.alpha, NULL, 0 } }, .nprops = 2, .ease = Ease_BounceOut, .duration = 0x12c, .onComplete = Sprite_hide, .ctx = &F2.PizzaSprite }); } static void Fosc2_Create(void) { memset(&F2, 0, sizeof F2); F2.canPizza = 1, F2.isJenevivSealed = 1, F2.isPathBlocked = 1; F2.beatEvent = F2.luminairePathEvent = (Timer){ -1, 0 }; Rectangle top = { -0x40, 0, game_width, 0x40 }, bot = { -0x40, game_height - 0x40, game_width, 0x40 }; F2.pm = particles_add(); F2.pm->scrollFactor0 = 1; for (int k = 0; k < 2; k++) { ParticleEmitter *e = particles_createEmitter(F2.pm, (EmitterConfig){ .frames = { frame_get("vfx", "trueBlack.png") }, .nframes = 1, .lifespan = ERND(0x64, 0x96), .quantity = 0x64, .scale = ERANGE(1, game_width), .scaleY = ERANGE(1, 1), .hasScaleY = 1, .alpha = ERANGE(0.25f, 1), .hasZoneRect = 1, .zoneRect = k ? bot : top, .frequency = 0x64, .on = 0 }); if (k) F2.glitch2 = e; else F2.glitch1 = e; } static Vector2 line[0x40]; for (int i = 0; i < 0x40; i++) line[i] = (Vector2){ 0, -game_height + i * (3.0f * game_height / 0x3f) }; F2.shadowPm = particles_add(); F2.Shadow = particles_createEmitter(F2.shadowPm, (EmitterConfig){ .frames = { frame_get("vfx", "Smoke1.png"), frame_get("vfx", "Smoke2.png") }, .nframes = 2, .lifespan = ERND(0x64, 0x96), .speed = ERND(0x64, 0x96), .quantity = 0x64, .scale = ERANGE(1, 2), .alpha = ERANGE(1, 0), .tint = 0x000001, .edge = line, .nEdge = 0x40, .frequency = 0x64, .on = 0 }); // zona: una linea; 0x000001: tint 0 vuol dire "nessuna" F2.pm->s.depth = F2.shadowPm->s.depth = 0x2710; F2.poolJeneviv = EnemyPool_new("FS_BOSS_JENEVIV"); if (Ach_achieved("FOSC11_BreakSeal2") || getenv("VS_F2OPEN")) F2.isPathBlocked = 0; // VS_F2OPEN: sviluppo, senza il secondo sigillo if (Ach_achieved("FOSC12_BreakSeal3")) F2.isJenevivSealed = Player_is(Core.Player, "ELEANOR"); snprintf(F2.saveBGM, sizeof F2.saveBGM, "%s", po_str("SelectedBGM")); snprintf(F2.saveBGMMod, sizeof F2.saveBGMMod, "%s", po_str("SelectedBGMMod")); F2.waterOffset = po_is("SelectedInverse") ? 0.05f : -0.05f; sprite_init(&F2.water.s, NULL, 0.5f * game_width, 0.5f * game_height); F2.water.s.draw = TileSprite_draw, F2.water.s.scrollFactor0 = 1, F2.water.s.depth = -0xdbb9f, F2.water.s.tint = 0xffffff; F2.water.tex = frame_texture("background_Foscari", po_is("SelectedInverse") ? "bg_foscari_inv.png" : "bg_foscari.png"), F2.water.w = game_width, F2.water.h = game_height; children_add(&F2.water.s); sprite_init(&F2.sDarkness, frame_get("vfx", "stageShadows.png"), 0, 0); sprite_setOrigin(&F2.sDarkness, 0, 0); F2.sDarkness.scrollFactor0 = 1, F2.sDarkness.scaleX = game_width / 160.0f, F2.sDarkness.scaleY = game_height / 100.0f, F2.sDarkness.depth = 0x2710; children_add(&F2.sDarkness); sprite_init(&F2.sBlackWall, frame_get("vfx", "trueBlack.png"), 0, 0); sprite_setOrigin(&F2.sBlackWall, 0, 0); F2.sBlackWall.scaleX = 0x1400, F2.sBlackWall.scaleY = 0x2800, F2.sBlackWall.depth = 0x2710; children_add(&F2.sBlackWall); F2.beatEvent = time_addEvent(0x19b, 1, 0, Fosc2_onBeat, NULL); // gimmeAbeat F2.isBeating = 1; Core.Stage->StageModifiers.EnemySpeed += 1; Stage_CalculateEnemySpeed(Core.Stage); if (FoscariRun.nEvent > 0) { // le armi lasciate al lago, in cerchio float step = 0x168 / (float)FoscariRun.nEvent; for (int i = 0; i < FoscariRun.nEvent; i++) { const char *t = FoscariRun.eventW[i]; cJSON *d = cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("weapons"), t), 0), *from = cJSON_GetObjectItem(d, "evolvesFrom"); if (cJSON_IsTrue(cJSON_GetObjectItem(d, "isEvolution")) && cJSON_GetArrayItem(from, 0)) t = cJSON_GetArrayItem(from, 0)->valuestring; Core_MakeStagePickup(Core.Player->s.x + cosf(step * i) * 0xc8, Core.Player->s.y + sinf(step * i) * 0xc8, "WEAPON", t); } FoscariRun.nEvent = 0; sprite_init(&F2.sFader, frame_get("vfx", "blackDot.png"), 0, 0); sprite_setOrigin(&F2.sFader, 0, 0); F2.sFader.scrollFactor0 = 1, F2.sFader.scaleX = game_width, F2.sFader.scaleY = game_height, F2.sFader.depth = 0x2710; children_add(&F2.sFader); tweens_add((TweenConfig){ .props = { { &F2.sFader.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x3e8 }); } if (F2.isPathBlocked) { Destructible *d = Core_MakeDestructibleAt("FOSCARI_SEAL_2", Scripts_pos("FS_SEAL2", 0x2260, 0x680)); if (d) d->sealKind = 2, Seal_MakeLevelOne(d); } else F2.sBlackWall.visible = 0, Core_MakeStagePickup(Scripts_pos("FS_SEAL2", 0x2260, 0x680).x, Scripts_pos("FS_SEAL2", 0x2260, 0x680).y, "WEAPON", "ACADEMYBADGE"); Vector2 jp = Scripts_pos("FS_JENEVIV", 0x2260, 0x680); if (F2.isJenevivSealed) { Fosc2_ForceSpoopyMusic(); Destructible *d = Core_MakeDestructibleAt("FOSCARI_SEAL_3", Scripts_pos("FS_SEAL3", 0x2260, 0x680)); if (d) d->sealKind = 3, Seal_MakeLevelOne(d); Enemy *e = EnemyPool_SpawnAt(F2.poolJeneviv, jp.x, jp.y); if (e) Jen_SealInStone(e); } else { Vector2 s = Scripts_pos("FS_SEAL3", 0x2260, 0x680); Core_MakeStagePickup(s.x, s.y, "WEAPON", "SHADOWSERVANT"); Vector2 pz = Scripts_pos("FS_PIZZA", Core.Player->s.x, Core.Player->s.y - 0xc8); F2.pizzaX = pz.x, F2.pizzaY = pz.y; sprite_init(&F2.PizzaSprite, frame_get("items", "PizzaTime.png"), pz.x, pz.y); F2.PizzaSprite.depth = -game_height; children_add(&F2.PizzaSprite); Enemy *e = EnemyPool_SpawnAt(F2.poolJeneviv, jp.x, jp.y); if (e) ((JenX *)e->x)->OnActivated = Fosc2_OnJenevivActivation; } } static void Fosc2_CheckMinute(int m) { if (m == 0x19) { emitter_start(F2.glitch1), emitter_start(F2.glitch2); Sound_PlaySound("WorldEater", 1.5f, 0.5f, 0, 0, 0), Sound_PlaySound("WorldEater", 1.5f, 0.25f, 0, 0, 0); Sound_PlaySound("Haha", 1.5f, 0.5f, 0, 0, 0), Sound_PlaySound("Haha", 1.5f, 0.25f, 0, 0, 0); } else if (m == 0x1a) emitter_stop(F2.glitch1), emitter_stop(F2.glitch2); } static void Fosc2_Update(float delta) { F2.tilingOffset += F2.waterOffset * delta; F2.water.tilePositionX = Core.Player->s.x; F2.water.tilePositionY = Core.Player->s.y + F2.tilingOffset; if (F2.canPizza) Fosc2_CheckPizzas(); if (F2.isPathBlocked) emitter_emitParticleAt(F2.Shadow, 0x1400, Core.Player->s.y, 0); if (F2.CheckForLuminaire && Core_GetWeapon("PRISMATICMISS2")) Fosc2_LuminaireArrives(); FZones_Update(); } static void Fosc2_OnInitCompleted(void) { if (F2.isPathBlocked) Fosc2_SetBoundsBeforeSeal2(); else Core_SetHardBounds(0x100, 0x100, 0x2700, 0x2700); if (!po_has("CollectedItems", "RELIC_BANGER")) Sound_StopMusic(); } static const FancyBG FB_Foscari2 = { .Create = Fosc2_Create, .Update = Fosc2_Update, .CheckMinute = Fosc2_CheckMinute, .OnInitCompleted = Fosc2_OnInitCompleted }; static void Foscari_OnDestroy(void) { // fancyBG.OnDestroy Enemy_beatMode = 0; if (!Core.Stage || strcmp(Core.Stage->stageType, "FOSCARI2")) return; if (F2.saveBGM[0]) po_sets("SelectedBGM", F2.saveBGM), po_sets("SelectedBGMMod", F2.saveBGMMod); time_removeEvent(F2.beatEvent); for (int i = 0; i < FoscariRun.n && Core.n_weapons < 16; i++) { // playerWeapons: tornano nelle statistiche del riepilogo Weapon *w = FoscariRun.saved[i]; int known = 0; for (int k = 0; k < Core.n_weapons; k++) known |= Core.Weapons[k] == w; if (!known && !w->isPowerUp && !Core_GetHiddenWeapon(w->bulletType)) Core.Weapons[Core.n_weapons++] = w; } FoscariRun.n = 0; } static void Chapel_SecretCreate(void) { memset(&ChS, 0, sizeof(ChS)); memset(&CamPan, 0, sizeof(CamPan)); int yellow = Collected("RELIC_YELLOW"); // CollectedItems (o VS_RELICS per le prove) Chapel_setMinute30(0); if (po_is("HasKilledTheFinalBoss") || !yellow) return; // DEBUGTHEENDER: mai ChS.on = 1, ChS.minuteValue = 0xea60 * (po_is("SelectedHurry") ? 0.5f : 1); ChS.pMad = EnemyPool_new("BOSS_MADDENER_NORMAL"), ChS.pDrown = EnemyPool_new("BOSS_DROWNER_NORMAL"), ChS.pStalk = EnemyPool_new("BOSS_STALKER_NORMAL"); ChS.pTrick = EnemyPool_new("BOSS_TRICKSTER_NORMAL"), ChS.pEnder = EnemyPool_new("BOSS_ENDER"); Chapel_setMinute30(1); SnapFX_reset(); sprite_init(&ChS.fx, NULL, 0, 0), ChS.fx.draw = ChS_fxDraw, ChS.fx.scrollFactor0 = 1, ChS.fx.depth = 0x2328; children_add(&ChS.fx); Chapel_SnapYellows(); time_addEvent(0.16f * ChS.minuteValue, 0, 0, Chapel_spawnMaddener, NULL); } static void Chapel_SecretUpdate(float delta) { if (!ChS.on) return; ChS.t += delta; if (ChS.waitIntro) ChS.introMs += delta; if (ChS.waitIntro && (net_on ? ChS.introMs >= 1000 * GetMusicTimeLength(BGM.music) : !IsMusicStreamPlaying(BGM.music))) { // in rete: sul tempo di gioco, l'audio non e' uguale sulle due console // currentBGMObj.on('complete') ChS.waitIntro = 0; po_sets("SelectedBGM", "TheEndMain"), Sound_SetupAndPlayBGM_Banger(1); } } static void Chapel_OnDestroy(void) { // OnPlayerQuit e la scena dei risultati: dati del minuto 30 e armi di nuovo al loro posto if (!ChS.on) return; ChS.on = 0; SFXVolumeFactor = 1; if (Core.Stage) Core.Stage->stopCheckingMinutes = 0; Chapel_setMinute30(0); for (int i = 0; i < ChS.nSaved; i++) { int found = 0; for (int k = 0; k < Core.n_weapons; k++) found |= Core.Weapons[k] == ChS.saved[i]; if (!found && Core.n_weapons < 16) Core.Weapons[Core.n_weapons++] = ChS.saved[i]; } ChS.nSaved = 0; } // --- BOSS_ENDER (0x4d66), la morte: camera sull'Ender, cinque urli, poi lo schiacciamento, la Mano Bianca e il Great Gospel --- static void Ender_camK(float k, float ms, Callback done) { tweens_add((TweenConfig){ .props = { { &CamPan.k, NULL, k } }, .nprops = 1, .duration = ms, .onComplete = done }); } static void Ender_camOff(void *c) { (void)c; CamPan.on = 0; } // startFollow(Player); SetCollideWithWorld(false): i muri non ci sono piu' (removeWalls) static void Ender_scream(void *c) { Boss_DeathScream(c); } static void Ender_final(void *c) { Enemy *e = c; tweens_add((TweenConfig){ .props = { { &e->s.scaleX, NULL, 0 }, { &e->s.scaleY, NULL, 5 } }, .nprops = 2, .duration = 0x1388, .ease = Ease_BounceInOut }); // SpecialDeathAnimation WhiteHand_Summon(); if (!po_has("CollectedItems", "RELIC_GGOSPEL")) Core_MakeRelic(e->s.x, e->s.y, "RELIC_GGOSPEL"); Ender_camK(0, 0xc8, Ender_camOff); } static void E_Ender_Die(Enemy *e) { if (e->isDead) return; base_EnemyDie(e); Boss_defeat(e); EnderX *x = e->x; for (int i = x->zones.nspawned - 1; i >= 0; i--) EnderZone_DeSpawn(x->zones.spawned[i]); cJSON *mods = cJSON_GetObjectItem(cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("stages"), po_str("SelectedStage")), 0), "mods"); float tl = num(mods, "TimeLimit", 0x708); if (Core.SurvivedSeconds < 0x3c + tl) Core.SurvivedSeconds = (int)(0x3c + tl); time_removeEvent(Core.tickerEvent); for (int i = 0; i < Core.Enemies.n; i++) Enemy_Disappear(Core.Enemies.items[i]->owner); PlayerUI.hpBarBG.visible = PlayerUI.hpBar.visible = 0; Sound_FadeMusic(0, 0x1f4); Player_SetInvulForMilliSeconds(Core.Player, 0x7530); Player_restoreTint(Core.Player); time_addEvent(0x64, 0, 0, Player_restoreTint, Core.Player); CamPan.on = 1, CamPan.k = 0, CamPan.e = e; Ender_camK(1, 0x3e8, NULL); anims_stop(&e->s); Boss_DeathScream(e); time_addEvent(0x3e8, 0, 4, Ender_scream, e); time_addEvent(0x1388, 0, 0, Ender_final, e); } static const EnemyVT E_Ender = { .OnRecycle = E_Ender_OnRecycle, .Die = E_Ender_Die, .GetDamaged = E_Ender_GetDamaged, .Update = E_Ender_Update }; static const Sprite *CamPan_target(void) { const Sprite *t = !CamPan.on ? NULL : CamPan.sp ? CamPan.sp : CamPan.e ? &CamPan.e->s : NULL; if (!t) return &Core.Player->s; float fx = CamPan.hasFrom ? CamPan.fromX : Core.Player->s.x, fy = CamPan.hasFrom ? CamPan.fromY : Core.Player->s.y; // hasFrom: da dov'era la camera (Jeneviv) CamPan.s.x = fx + (t->x - fx) * CamPan.k, CamPan.s.y = fy + (t->y - fy) * CamPan.k; return &CamPan.s; } // --- GREENACRES (0x17b78): la reliquia RELIC_BANGER in (777, 777) e il bordo del mondo: con almeno 5 stage, Hurry, Hyper e la // reliquia gialla, oltre (-18432, 18432) si cade fuori dal mondo tra i pipistrelli XXL; battuti 128, si torna e Fino si sblocca static struct { int checkForEdgeOfTheWorld, canFallOffTheEdge, isOffTheEdge, xxlBatsDefeated; Sprite missing; char savedBGM[64], savedMod[32]; } GA; static cJSON *GA_xxl(void) { static cJSON *a; if (!a) a = cJSON_CreateStringArray((const char *[]){ "XXLBAT" }, 1); return a; } static void Core_EraseEnemies(int vfx) { if (vfx && po_is("FlashingVFXEnabled")) RosaryVFX_Play(); for (int i = 0; i < Core.Enemies.n; i++) { Enemy *e = Core.Enemies.items[i]->owner; if (!e->res_Rosary) Enemy_Disappear(e); } } static void GA_fadeIn(void) { BGMan.bgtile.scaleX = BGMan.bgtile.scaleY = 1, BGMan.bgtile.alpha = 0; tweens_add((TweenConfig){ .props = { { &BGMan.bgtile.alpha, NULL, 1 } }, .nprops = 1, .duration = 0x1f4 }); } static void GA_inTheVoid(void *c) { // ResetAndStopDayNightHue, poi bg_ram (void)c; BGMan.RunTimeHue = 0, BGMan.bgtile.tint = BGMan.DayColor; BGMan.tex = BGMan_texture("bg_ram"); GA_fadeIn(); } static void GA_backHome(void *c) { (void)c; BGMan.tex = BGMan_texture("bg_forest"); Core.Player->ghostAlpha = 0.65f, Player_SetMaxHistory(Core.Player, 3); // ResetGhostValues GA_fadeIn(); po_sets("SelectedBGM", GA.savedBGM), po_sets("SelectedBGMMod", GA.savedMod); Sound_SetupAndPlayBGM_Banger(1); } static void GA_shrink(Callback done) { tweens_add((TweenConfig){ .props = { { &BGMan.bgtile.scaleX, &BGMan.bgtile.scaleY, 0 } }, .nprops = 1, .duration = 0x2710, .onComplete = done }); } static void GA_missing_draw(Sprite *s) { // tileSprite(... '_MISSING'): la texture che manca, i quadrati verdi di Phaser ripetuti a schermo intero (void)s; for (int y = 0; y < game_height; y += 0x20) for (int x = 0; x < game_width; x += 0x20) DrawRectangleLines(x, y, 0x20, 0x20, GREEN); } static void GreenAcres_FallOffTheEdge(void) { if (!GA.canFallOffTheEdge) return; GA.isOffTheEdge = 1; SFXVolumeFactor = 0.65f; sprite_init(&GA.missing, NULL, 0, 0); GA.missing.draw = GA_missing_draw, GA.missing.depth = -0xdbba1, GA.missing.scrollFactor0 = 1; children_add(&GA.missing); Player_SetMaxHistory(Core.Player, 0x12c); Core.Player->ghostAlpha = 1; Core_EraseEnemies(1); Core.Stage->enemies = GA_xxl(); // enemies = [XXLBAT] Core.Stage->minimum = 0xa; Stage_updateEnemyPools(Core.Stage); snprintf(GA.savedBGM, sizeof(GA.savedBGM), "%s", BGM.idx >= 0 ? SOUND_FILES[BGM.idx].key : ""); // Core.CurrentBGM snprintf(GA.savedMod, sizeof(GA.savedMod), "%s", po_str("SelectedBGMMod") ?: ""); po_sets("SelectedBGM", "BGM_Glitch"), po_sets("SelectedBGMMod", "Normal"); Sound_SetupAndPlayBGM_Banger(1); GA.canFallOffTheEdge = 0; GA_shrink(GA_inTheVoid); } static void GreenAcres_ResetTilemap(void) { GA.isOffTheEdge = 0; const char *valid[16], *st = "FOREST"; int n = Stage_GetValidUnlockedStages(valid); if (n >= 2) st = valid[(int)floorf(frand() * n)]; Core_EraseEnemies(1); cJSON *d = cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("stages"), st), Core.Stage->dataMinute); Core.Stage->enemies = cJSON_GetObjectItem(d, "enemies"), Core.Stage->minimum = (int)num(d, "minimum", 0); Stage_updateEnemyPools(Core.Stage); if (!po_has("UnlockedCharacters", "FINO")) AchievementManager_UnlockSecret("EdgeOfTheWorld"), Sound_PlaySound("ThingFound", 1, 0.5f, -0x3e8, 0, 0); GA_shrink(GA_backHome); } static void GA_batDefeated(void) { if (Core.Stage->fancyBG == &FB_GreenAcres) GA.xxlBatsDefeated++; } static void GreenAcres_Create(void) { memset(&GA, 0, sizeof(GA)); GA.canFallOffTheEdge = 1; if (!po_has("CollectedItems", "RELIC_BANGER")) Core_MakeRelic(0x309, 0x309, "RELIC_BANGER"); const char *valid[16]; if (Stage_GetValidUnlockedStages(valid) >= 5 && po_is("SelectedHurry") && po_is("SelectedHyper") && po_has("CollectedItems", "RELIC_YELLOW")) GA.checkForEdgeOfTheWorld = 1; } static void GreenAcres_Update(float delta) { (void)delta; if (GA.checkForEdgeOfTheWorld && GA.canFallOffTheEdge && Core.Player->s.x < -0x4800 && Core.Player->s.y > 0x4800) GreenAcres_FallOffTheEdge(), GA.canFallOffTheEdge = 0; if (GA.isOffTheEdge && GA.xxlBatsDefeated >= 0x80) GreenAcres_ResetTilemap(); } static void GreenAcres_CheckMinute(int m) { (void)m; if (!GA.isOffTheEdge) return; Core.Stage->enemies = GA_xxl(); // enemies = [XXLBAT] if (Core.Stage->minimum > 0x14) Core.Stage->minimum = 0x14; if (Core.Stage->frequency < 0x1f4) Core.Stage->frequency = 0x1f4; Stage_updateEnemyPools(Core.Stage); } static const FancyBG FB_GreenAcres = { GreenAcres_Create, GreenAcres_Update, GreenAcres_CheckMinute, NULL }; // ============================================================================ // Bat Country (BATCOUNTRY 0x5344): diamanti (EX_DIAMOND 0x11829), pipistrelli che cadono (EX_AXE_BAT3 0xbd26, EX_DIAMOND_AXE 0x6313), // pipistrelli di taglia varia (EX_SCALING_* 0xa1f6), eventi MONSTER_DANCE e DIAMOND_*, il labirinto (0x13de8), sfondo che cambia colore // ============================================================================ // --- 0x13de8: il generatore di labirinti, 8 pattern 6x6 che si incastrano sui bordi --------------------------------------------------- static const unsigned char MazePat[8][6][6] = { { { 0 } }, { { 0, 1, 1, 1, 1, 0 }, { 0, 1, 1, 1, 1, 0 }, { 0, 1, 1, 1, 1, 0 }, { 0, 1, 1, 1, 1, 0 }, { 0, 1, 1, 1, 1, 0 }, { 0, 1, 1, 1, 1, 0 } }, { { 0, 1, 1, 1, 1, 0 }, { 1, 1, 1, 1, 1, 0 }, { 1, 1, 1, 1, 1, 0 }, { 1, 1, 1, 1, 1, 0 }, { 1, 1, 1, 1, 1, 0 }, { 0, 0, 0, 0, 0, 0 } }, { { 0, 0, 0, 0, 0, 0 }, { 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1 }, { 0, 0, 0, 0, 0, 0 } }, { { 0, 1, 1, 1, 1, 0 }, { 0, 1, 1, 1, 1, 1 }, { 0, 1, 1, 1, 1, 1 }, { 0, 1, 1, 1, 1, 1 }, { 0, 1, 1, 1, 1, 1 }, { 0, 0, 0, 0, 0, 0 } }, { { 0, 0, 0, 0, 0, 0 }, { 0, 1, 1, 1, 1, 1 }, { 0, 1, 1, 1, 1, 1 }, { 0, 1, 1, 1, 1, 1 }, { 0, 1, 1, 1, 1, 1 }, { 0, 1, 1, 1, 1, 0 } }, { { 0, 0, 0, 0, 0, 0 }, { 1, 1, 1, 1, 1, 0 }, { 1, 1, 1, 1, 1, 0 }, { 1, 1, 1, 1, 1, 0 }, { 1, 1, 1, 1, 1, 0 }, { 0, 1, 1, 1, 1, 0 } }, { { 0, 1, 1, 1, 1, 0 }, { 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1, 1 }, { 0, 1, 1, 1, 1, 0 } }, }; static unsigned char MazeNb[8][4][8]; // vicini ammessi: 0 sopra, 1 destra, 2 sotto, 3 sinistra (PatternData) static void Maze_init(void) { // costruttore: confronta i bordi (con gli stessi indici dell'originale) static int done; if (done) return; done = 1; for (int a = 0; a < 8; a++) for (int b = 0; b < 8; b++) { int top = 1, bot = 1, left = 1, right = 1; for (int k = 0; k < 6; k++) { if (MazePat[a][0][k] != MazePat[b][5][k]) top = 0; if (MazePat[a][5][k] != MazePat[b][0][k]) bot = 0; if (MazePat[a][k][0] != MazePat[b][k][5]) left = 0; if (MazePat[a][k][5] != MazePat[b][k][0]) right = 0; } MazeNb[a][0][b] = top, MazeNb[a][2][b] = bot, MazeNb[a][3][b] = left, MazeNb[a][1][b] = right; } } static void Maze_generateGrid(signed char out[100][100]) { // generateGrid(100, 100): 0 = diamante, 1 = corridoio Maze_init(); enum { C = 17, R = 17 }; // ceil(100 / 6) int g[R][C]; for (int y = 0; y < R; y++) for (int x = 0; x < C; x++) g[y][x] = -1; g[C / 2][R / 2] = 7; for (int y = 0; y < R; y++) for (int x = 0; x < C; x++) { if (g[y][x] > -1) continue; int cand[8], n = 0; for (int p = 0; p < 8; p++) { if (x > 0 && g[y][x - 1] > -1 && !MazeNb[g[y][x - 1]][1][p]) continue; if (y > 0 && g[y - 1][x] > -1 && !MazeNb[g[y - 1][x]][2][p]) continue; if (x < C - 2 && g[y][x + 1] > -1 && !MazeNb[g[y][x + 1]][3][p]) continue; if (y < R - 2 && g[y + 1][x] > -1 && !MazeNb[g[y + 1][x]][0][p]) continue; cand[n++] = p; } g[y][x] = n ? cand[(int)floorf(frand() * n)] : (int)floorf(frand() * 8); } for (int y = 0; y < 100; y++) for (int x = 0; x < 100; x++) out[y][x] = MazePat[g[y / 6][x / 6]][y % 6][x % 6]; } // --- EX_DIAMOND (0x11829): un blocco che cambia colore a ogni colpo e si rompe al quinto; da solo sparisce dopo selfDuration --------------- typedef struct { int hitsTaken, isInvul, gridX, gridY; float selfTime, selfDuration, invulDelay; } DiamondX; static const char *const DiamondFrames[5] = { "diamondBlue_i01.png", "diamondGreen_i01.png", "diamondYellow_i01.png", "diamondPink_i01.png", "diamondNeutral_i01.png" }; static void Diamond_vulnerable(void *ctx) { ((DiamondX *)((Enemy *)ctx)->x)->isInvul = 0; } static int Diamond_hit(Enemy *e, int hitVFX, float vol1, float vol2, int capped) { // GetDamaged + ChangeFrame; 1 se e' morto DiamondX *d = e->x; if (e->isDead || d->isInvul) return 0; d->isInvul = 1, d->hitsTaken++; anims_stop(&e->s); int died = d->hitsTaken >= 4; if (died) Sound_PlaySound("Crystal12", vol1, 1, -0x258 * frand(), capped ? 0x64 : 0, capped ? 4 : 0); else Sound_PlaySound("Bumper", vol2, 1, 0x64 * d->hitsTaken, 0x64, 4), sprite_setFrame(&e->s, frame_get("enemiesM", DiamondFrames[d->hitsTaken])); time_addEvent(d->invulDelay, 0, 0, Diamond_vulnerable, e); Enemy_OnGetDamaged(e, HIT_NONE); // OnGetDamaged(vfx, false): niente lampo (void)hitVFX; return died; } static void E_Diamond_OnRecycle(Enemy *e) { if (!e->x) { DiamondX *d = e->x = calloc(1, sizeof(DiamondX)); d->invulDelay = 0x1f4; } DiamondX *d = e->x; d->selfTime = 0; base_EnemyOnRecycle(e); d->hitsTaken = 0, d->isInvul = 0, e->isCullable = 0; anims_stop(&e->s), sprite_setFrame(&e->s, frame_get("enemiesM", "diamondBlue_i01.png")); d->selfDuration = 0x7530; sprite_setScale(&e->s, 0); tween_stop(e->OnEnterTween); e->OnEnterTween = tweens_add((TweenConfig){ .props = { { &e->s.scaleX, &e->s.scaleY, e->scaleMul }, { &e->speed, NULL, 0 } }, .nprops = 2, .duration = 0x12c }); sprite_setOrigin(&e->s, 0.5f, 0.5f), e->s.body.immovable = 1; } static void E_Diamond_Update(Enemy *e) { DiamondX *d = e->x; e->s.angle = 0; if (e->isDead) return; d->selfTime += Enemies_delta; if (d->selfTime >= d->selfDuration) e->isDead = 1, e->isCullable = 1, Enemy_Disappear(e); } static void E_Diamond_Die(Enemy *e) { if (frand() >= 0.2f * Core.Player->luck) { const char *it = LootManager_GetRandomWeightedItem(); if (it) Core_MakePickup(e->s.x, e->s.y, it); } base_EnemyDie(e); } static void E_Diamond_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *t) { (void)amount, (void)kb, (void)t; if (Diamond_hit(e, hitVFX, 0.6f, 0.2f, 1)) Enemy_Die(e); } static const EnemyVT E_Diamond = { .OnRecycle = E_Diamond_OnRecycle, .Die = E_Diamond_Die, .GetDamaged = E_Diamond_GetDamaged, .Update = E_Diamond_Update }; // --- EX_AXE_BAT3 (0xbd26): parte verso l'alto (5 gradi verso il giocatore) e ricade come un'ascia ------------------------------------------ typedef struct { DiamondX d; Vector2 v0; Timer selfTimer; } AxeBatX; static void E_AxeBat_OnRecycle(Enemy *e) { if (!e->x) e->x = calloc(1, sizeof(AxeBatX)), ((AxeBatX *)e->x)->selfTimer = (Timer){ -1, 0 }; base_EnemyOnRecycle(e); float a = (5 * (e->s.x > Core.Player->s.x ? -1 : 1) - 0x5a) * DEG2RAD; ((AxeBatX *)e->x)->v0 = velocityFromRotation(a, e->speed); e->s.body.velocity = ((AxeBatX *)e->x)->v0; } static void E_AxeBat_Update(Enemy *e) { AxeBatX *b = e->x; if (e->isDead) return; e->s.depth = e->s.y - Core.Player->s.y; if (e->IsTimeStopped) return; e->s.flipX = e->s.x > Core.Player->s.x; float k = 0.01f * e->speed * (e->receivingDamage ? -e->knockback * e->damageKB : 1); b->v0.y += Enemies_delta * (0xa / 32.0f); // grav sprite_setVelocity(&e->s, k * b->v0.x, k * b->v0.y); } static const EnemyVT E_AxeBat = { .OnRecycle = E_AxeBat_OnRecycle, .Update = E_AxeBat_Update }; // --- EX_DIAMOND_AXE (0x6313): il diamante-ascia, rimbalza in alto a ogni colpo, gira, sparisce dopo 10 s --------------------------------------- static void DiamondAxe_timeout(void *ctx) { Enemy *e = ctx; e->isCullable = 1; Enemy_Disappear(e); } static void E_DiamondAxe_OnRecycle(Enemy *e) { E_AxeBat_OnRecycle(e); AxeBatX *b = e->x; b->d.invulDelay = 0x15e, b->d.hitsTaken = 0, b->d.isInvul = 0, e->isCullable = 0; anims_stop(&e->s), sprite_setFrame(&e->s, frame_get("enemiesM", "diamondBlue_i01.png")); time_removeEvent(b->selfTimer); b->selfTimer = time_addEvent(0x2710, 0, 0, DiamondAxe_timeout, e); } static void E_DiamondAxe_Update(Enemy *e) { E_AxeBat_Update(e); e->s.angle += 0.01f * Enemies_delta; } static void E_DiamondAxe_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *t) { (void)amount, (void)kb, (void)t; AxeBatX *b = e->x; if (e->isDead || b->d.isInvul) return; int died = Diamond_hit(e, hitVFX, 0.7f, 0.5f, 0); b->v0.y = -0xc8; // dopo ChangeFrame, come l'originale if (died) Enemy_Die(e); } static void E_DiamondAxe_Die(Enemy *e) { const char *it = LootManager_GetRandomWeightedItem(); if (it) Core_MakePickup(e->s.x, e->s.y, it); base_EnemyDie(e); } static const EnemyVT E_DiamondAxe = { .OnRecycle = E_DiamondAxe_OnRecycle, .Die = E_DiamondAxe_Die, .GetDamaged = E_DiamondAxe_GetDamaged, .Update = E_DiamondAxe_Update }; // --- EX_SCALING_* (0xa1f6): pipistrelli di taglia a caso; la vita segue la taglia (anche negativa: maxHp *= -0.1..0.4, sic) ------------------ static void E_ScalingBat_OnRecycle(Enemy *e) { base_EnemyOnRecycle(e); sprite_setScale(&e->s, 0); float r = 0.5f * (frand() - 0.2f); tween_stop(e->OnEnterTween); e->OnEnterTween = tweens_add((TweenConfig){ .props = { { &e->s.scaleX, &e->s.scaleY, e->scaleMul + r } }, .nprops = 1, .duration = 0xc8 }); e->maxHp *= r, e->hp = e->maxHp; } static const EnemyVT E_ScalingBat = { .OnRecycle = E_ScalingBat_OnRecycle }; // --- Gli eventi di Bat Country (StageEventManager) --------------------------------------------------------------------------------------- static struct { int active; float duration, startX, startY; int prevX, prevY; signed char grid[100][100]; Enemy *enemies[100][100]; Timer disappearTimer; } Diamond; typedef struct { EventGroup *g; EnemyPool *pool; int count, k; } StepSpawn; static void SpawnInSteps_one(void *ctx) { // una fila che cresce da sinistra in basso, un nemico per passo StepSpawn *s = ctx; float w = (float)game_width / s->count; Enemy *e = EnemyPool_SpawnAt(s->pool, Core.Player->s.x - 0.5f * game_width + w * s->k++, Core.Player->s.y + 0x30 + 0.5f * game_height); Core.Stage->stageEventManager_spawned++; if (e) s->g->list[s->g->n++] = e; } static void SpawnInSteps_end(void *ctx) { StepSpawn *s = ctx; Core.Stage->stageEventManager_spawned -= s->count; for (int i = 0; i < s->g->n; i++) if (!s->g->list[i]->isDead) s->g->list[i]->isCullable = 1, Enemy_Disappear(s->g->list[i]); } static void SpawnInSteps(float d, int count, const char *type) { // MONSTER_DANCE EnemyPool *pool = StageEvent_pool(Core.Stage, type ? type : "EX_AXE_BAT3"); if (!pool || count <= 0) return; d = d ? d : 0x2710; StepSpawn *s = calloc(1, sizeof(StepSpawn)); s->g = StageEvent_group(count + 1), s->pool = pool, s->count = count; time_addEvent(d / count, 0, count, SpawnInSteps_one, s); // repeat: count + 1 nemici (sic) time_addEvent(d + 0x7530, 0, 0, SpawnInSteps_end, s); } typedef struct { EnemyPool *pool; int n; float x, y; } DiaRing; static void DiamondSquare_spawn(void *ctx) { // cornice quadrata di n diamanti per lato attorno al giocatore DiaRing *r = ctx; float x = Core.Player->s.x - 0x20 * 0.5f * r->n + 0x10, y = Core.Player->s.y - 0x20 * 0.5f * r->n + 0x18; for (int i = 0; i < r->n; i++) EnemyPool_SpawnAt(r->pool, x + 0x20 * i, y), EnemyPool_SpawnAt(r->pool, x + 0x20 * i, y + 0x20 * (r->n - 1)); for (int i = 1; i < r->n - 1; i++) EnemyPool_SpawnAt(r->pool, x, y + 0x20 * i), EnemyPool_SpawnAt(r->pool, x + 0x20 * (r->n - 1), y + 0x20 * i); } static void PlayDiamond_Square(int rings, const char *type) { EnemyPool *pool = StageEvent_pool(Core.Stage, type ? type : "EX_DIAMOND"); if (!pool) return; for (int i = 0; i < rings; i++) { DiaRing *r = calloc(1, sizeof(DiaRing)); r->pool = pool, r->n = 0xe + 2 * i; time_addEvent(0x1e, 0, 0, DiamondSquare_spawn, r); } } static void DiamondRoad_spawn(void *ctx) { // due file verticali di 47 diamanti ai lati del giocatore DiaRing *r = ctx; float l = Core.Player->s.x - 0x20 * r->n + 0x10, rr = Core.Player->s.x + 0x20 * r->n + 0x10, y = Core.Player->s.y - 0x20 * 24 + 0x18; for (int i = 1; i < 0x30; i++) EnemyPool_SpawnAt(r->pool, l, y + 0x20 * i), EnemyPool_SpawnAt(r->pool, rr, y + 0x20 * i); } static void PlayDiamond_Road(int roads) { // moreZ assente: il tipo torna EX_DIAMOND (sic) EnemyPool *pool = StageEvent_pool(Core.Stage, "EX_DIAMOND"); if (!pool) return; for (int i = 0; i < roads; i++) { DiaRing *r = calloc(1, sizeof(DiaRing)); r->pool = pool, r->n = 4 + i; time_addEvent(0x1e, 0, 0, DiamondRoad_spawn, r); } } static void PlayDiamond_Concrete(float cx, float cy) { // 14 x 14 diamanti pieni attorno al punto EnemyPool *pool = StageEvent_pool(Core.Stage, "EX_DIAMOND"); if (!pool) return; float x = (cx ? cx : Core.Player->s.x) - 0xe0 + 0x10, y = (cy ? cy : Core.Player->s.y) - 0xe0 + 0xc; for (int j = 0; j < 0xe; j++) for (int i = 0; i < 0xe; i++) EnemyPool_SpawnAt(pool, x + 0x20 * i, y + 0x20 * j); } static void PlayDiamond_RandomPatternClear(void *ctx) { (void)ctx; Diamond.active = 0; time_removeEvent(Diamond.disappearTimer); for (int y = 0; y < 100; y++) for (int x = 0; x < 100; x++) { Enemy *e = Diamond.enemies[y][x]; if (!e) continue; DiamondX *d = e->x; if (d && d->gridX == x && d->gridY == y) Enemy_Disappear(e); Diamond.enemies[y][x] = NULL, Core.Stage->stageEventManager_spawned--; } } static void PlayDiamond_RandomPattern(float d) { // DIAMOND_MAZE: un labirinto 100x100 che si costruisce attorno al giocatore PlayDiamond_RandomPatternClear(NULL); memset(Diamond.enemies, 0, sizeof(Diamond.enemies)); Diamond.startX = Core.Player->s.x - 0x640, Diamond.startY = Core.Player->s.y - 0x640; Maze_generateGrid(Diamond.grid); Diamond.active = 1, Diamond.duration = d; Diamond.disappearTimer = time_addEvent(d, 0, 0, PlayDiamond_RandomPatternClear, NULL); } static void PlayDiamond_Update(void) { // StageEventManager.Update: le celle entro 15 dal giocatore si riempiono, le altre si svuotano if (!Diamond.active) return; int gx = (int)roundf((Core.Player->s.x - Diamond.startX) / 0x20), gy = (int)roundf((Core.Player->s.y - Diamond.startY) / 0x20); if (gx == Diamond.prevX && gy == Diamond.prevY) return; Diamond.prevX = gx, Diamond.prevY = gy; EnemyPool *pool = StageEvent_pool(Core.Stage, "EX_DIAMOND"); int mx = 99, my = 99, x0 = (int)fminf(fmaxf(gx - 0xf, 0), mx), y0 = (int)fminf(fmaxf(gy - 0xf, 0), my), x1 = (int)fminf(fmaxf(x0 + 0x1e, 0), mx), y1 = (int)fminf(fmaxf(y0 + 0x1e, 0), my); for (int y = 0; y < my; y++) for (int x = 0; x < mx; x++) { if (y < y0 || y > y1 || x < x0 || x > x1) { if (Diamond.grid[y][x] != -1) continue; Diamond.grid[y][x] = 0; Enemy *e = Diamond.enemies[y][x]; if (!e) continue; DiamondX *d = e->x; if (d && d->gridX == x && d->gridY == y) Enemy_DeSpawn(e); Diamond.enemies[y][x] = NULL, Core.Stage->stageEventManager_spawned--; } else if (Diamond.grid[y][x] == 0 && pool) { Diamond.grid[y][x] = -1; Enemy *e = Diamond.enemies[y][x] = EnemyPool_SpawnAt(pool, Diamond.startX + 0x20 * x, Diamond.startY + 0x20 * y); if (e && e->x) ((DiamondX *)e->x)->selfDuration = Diamond.duration, ((DiamondX *)e->x)->gridX = x, ((DiamondX *)e->x)->gridY = y; Core.Stage->stageEventManager_spawned++; } } } // --- BATCOUNTRY (0x5344): lo sfondo bianco tinto a gradiente che cambia colore ogni 10 s; dal minuto 7 sfera, scacchiera e mappa che svanisce; // minuti 8 e 17 round bonus (nemici piu' veloci), 9 e 18 un blocco di diamanti col cartello rosso (dentro: le reliquie, F3). Le pizze: F3 #ifdef __vita__ #define SPHERE_ITER "32" // semplificazione: il ray-march della sfera con 32 passi (128 sul desktop) e la scacchiera senza fwidth (niente derivate su vitaGL) #define SPHERE_CHECKER "float checkersGradBox(vec2 p) { float s = sign(fract(p.x * 0.5) - 0.5) * sign(fract(p.y * 0.5) - 0.5); return 0.5 - 0.5 * s; }\n" #else #define SPHERE_ITER "128" #define SPHERE_CHECKER "float checkersGradBox(vec2 p) { vec2 w = fwidth(p) + 0.001; vec2 i = 2.0*(abs(fract((p-0.5*w)*0.5)-0.5)-abs(fract((p+0.5*w)*0.5)-0.5))/w; return 0.5 - 0.5*i.x*i.y; }\n" #endif static const char *SPHERE_BODY = // gottaSphereFast.glsl "uniform float time; uniform float scrollX; uniform float scrollY; uniform float scrollSpeed; uniform vec2 resolution;\n" "float camYaw; vec3 camPos;\n" SPHERE_CHECKER "vec3 distortPos(vec3 pos) { vec3 p = pos; float xx = (p - camPos).x; float zz = (p - camPos).z;\n" " float xxx = -(cos(camYaw)*zz-sin(camYaw)*xx); float zzz = -(cos(camYaw)*xx+sin(camYaw)*zz);\n" " float cx = cos(xxx * 0.3) * 1.1; if (cx < 0.0) cx *= 2.0; float cz = cos((zzz + 3.0) * 0.3) * 1.1; if (cz < 0.0) cz *= 1.5;\n" " p.y -= cx + cz; return p; }\n" "vec2 mapS(vec3 pos) { vec3 p = distortPos(pos); vec2 res = vec2(12.0, 0.0); if (p.y > 0.0) res = vec2(min(12.0, p.y), 1.0); return res; }\n" "vec3 get_normal(vec3 p) { vec2 e = vec2(0.0001, 0.0);\n" " return normalize(vec3(mapS(p + e.xyy).x - mapS(p - e.xyy).x, mapS(p + e.yxy).x - mapS(p - e.yxy).x, mapS(p + e.yyx).x - mapS(p - e.yyx).x)); }\n" "vec2 intersect(vec3 ro, vec3 rd) { float t = 0.0, dt; vec2 r = vec2(0.0);\n" " for (int i = 0; i < " SPHERE_ITER "; i++) { r = mapS(ro + rd * t); dt = r.x; if (dt < 0.002 || t > 12.0) break; t += dt * 0.8; }\n" " return vec2(t, r.y); }\n" "vec4 sphere(vec2 fragCoord) {\n" " vec2 uv = (fragCoord.xy - resolution.xy * 0.5) / resolution.xy; uv.x *= resolution.x / resolution.y;\n" " float velocity = scrollSpeed * 0.0002; vec3 ro = vec3(-scrollX * velocity, 4.5, scrollY * velocity); vec3 ta = ro + vec3(0.0, 0.85, 1.0);\n" " vec3 fwd = normalize(ro - ta); vec3 rgt = normalize(vec3(fwd.z, 0., -fwd.x)); vec3 up = cross(fwd, rgt);\n" " vec3 rd = normalize(fwd + (uv.x*rgt + uv.y*up)); camYaw = atan(fwd.z, fwd.x); camPos = ro;\n" " vec4 col = vec4(0.0); vec2 res = intersect(ro, rd);\n" " if (res.x < 12.0 && res.y >= 1.0) { vec3 pos = ro + rd * res.x; vec3 n = get_normal(pos);\n" " vec3 matte = vec3(1.0, 0.5, 0.1) * (vec3(0.4) + vec3(checkersGradBox(vec2(pos.x, pos.z))));\n" " vec3 ld0 = normalize(camPos + vec3(0.0, 1.0, -2.0) - pos); float dif = max(0.0, dot(n, ld0));\n" " col = vec4((1.0 + dif) * 0.22 * matte, 1.0); }\n" " col.xyz = pow(clamp(col.xyz, 0.0, 1.0), vec3(0.45)); col.xyz = mix(col.xyz, vec3(dot(col.xyz, vec3(0.33))), -0.5); return col; }\n"; static const char *CHECKER_BODY = // rainbowCheckerboard.glsl "uniform float time; uniform vec2 resolution;\n" "vec4 checker(vec2 fragCoord) { vec2 uv = fragCoord / resolution.xy; vec4 c = vec4(0.5 + 0.5*cos(time + uv.xyx + vec3(0.0, 2.0, 4.0)), 1.0);\n" " vec2 uv2 = uv * vec2(-1.0, 1.0) + vec2(cos(time * 0.3) + time * 0.4, time * 0.4) * vec2(0.2, 0.3);\n" " vec4 t = vec4(1.0, 1.0, 1.0, 0.0); if (sin(uv2.x * 17.0 * 3.1415) > 0.0) t = vec4(0.0, 0.0, 0.0, 1.0); if (sin(uv2.y * 10.0 * 3.1415) > 0.0) t = 1.0 - t;\n" " if (t.a > 0.0) c = mix(c, t, abs(sin(time * 0.5)) + 0.2 + uv.x / 10.0); return c; }\n"; typedef struct { Shader sh; RenderTexture2D rt; int locTime, locRes, locSX, locSY, locSpeed; Sprite img; } ShaderImage; // scene.add.shader + setRenderToTexture + image static void ShaderImage_draw(Sprite *s) { ShaderImage *k = s->owner; if (!s->visible || s->alpha <= 0) return; float w = k->rt.texture.width * s->scaleX, h = k->rt.texture.height * s->scaleY; DrawTexturePro(k->rt.texture, (Rectangle){ 0, 0, k->rt.texture.width, -k->rt.texture.height }, (Rectangle){ s->x, s->y, w, h }, (Vector2){ 0.5f * w, 0.5f * h }, s->angle, hexc(0xffffff, s->alpha)); } static void ShaderImage_init(ShaderImage *k, const char *body, const char *fn, float scale, double depth) { if (!k->sh.id) { char fs[6144]; #ifdef __vita__ snprintf(fs, sizeof(fs), "#version 100\nprecision mediump float;\nvarying vec2 fragTexCoord;\n%svoid main() { gl_FragColor = %s(gl_FragCoord.xy); }\n", body, fn); #else snprintf(fs, sizeof(fs), "#version 330\nin vec2 fragTexCoord;\nout vec4 finalColor;\n%svoid main() { finalColor = %s(gl_FragCoord.xy); }\n", body, fn); #endif k->sh = LoadShaderFromMemory(NULL, fs); k->locTime = GetShaderLocation(k->sh, "time"), k->locRes = GetShaderLocation(k->sh, "resolution"); k->locSX = GetShaderLocation(k->sh, "scrollX"), k->locSY = GetShaderLocation(k->sh, "scrollY"), k->locSpeed = GetShaderLocation(k->sh, "scrollSpeed"); k->rt = LoadRenderTexture(game_width / 2, game_height / 2); } sprite_init(&k->img, NULL, 0.5f * game_width, 0.5f * game_height); k->img.owner = k, k->img.draw = ShaderImage_draw, k->img.scrollFactor0 = 1, k->img.visible = 0, k->img.depth = depth; sprite_setScale(&k->img, scale); children_add(&k->img); } static void ShaderImage_render(ShaderImage *k, float sx, float sy) { // il Shader game object disegna nella sua RenderTexture a ogni frame (solo se si vede) if (!k->img.visible) return; float t = GetTime(), res[2] = { k->rt.texture.width, k->rt.texture.height }, one = 1; SetShaderValue(k->sh, k->locTime, &t, SHADER_UNIFORM_FLOAT), SetShaderValue(k->sh, k->locRes, res, SHADER_UNIFORM_VEC2); if (k->locSX >= 0) SetShaderValue(k->sh, k->locSX, &sx, SHADER_UNIFORM_FLOAT), SetShaderValue(k->sh, k->locSY, &sy, SHADER_UNIFORM_FLOAT), SetShaderValue(k->sh, k->locSpeed, &one, SHADER_UNIFORM_FLOAT); BeginTextureMode(k->rt); BeginShaderMode(k->sh); DrawRectangle(0, 0, k->rt.texture.width, k->rt.texture.height, WHITE); EndShaderMode(); EndTextureMode(); } static struct { ShaderImage sphere, checker; float sx, sy, lerpV; int colorIndex, canChangeColor, fixedBGColor; TweenRef sphereT, checkerT; } Bat; static const unsigned BatTop[5] = { 0x880000, 0x888800, 0x8888, 0x88, 0x880088 }, BatBottom[5] = { 0x220000, 0x222200, 0x2222, 0x22, 0x220022 }; static void Bat_colorRepeat(void *ctx) { (void)ctx; Bat.lerpV = 0; if (++Bat.colorIndex >= 5) Bat.colorIndex = 0; } static void Bat_StartColorChange(void *ctx) { (void)ctx; tweens_add((TweenConfig){ .props = { { &BGMan.bgtile.alpha, NULL, 1 } }, .nprops = 1, .duration = 0xc8 }); tweens_add((TweenConfig){ .props = { { &Bat.lerpV, NULL, 1 } }, .nprops = 1, .duration = 0x2710, .repeat = -1, .onRepeat = Bat_colorRepeat }); Bat.colorIndex = 0, Bat.canChangeColor = 1; } static void Bat_Create(void) { memset(&Bat.sx, 0, sizeof(Bat) - offsetof(typeof(Bat), sx)); ShaderImage_init(&Bat.sphere, SPHERE_BODY, "sphere", 2, -0x2328); ShaderImage_init(&Bat.checker, CHECKER_BODY, "checker", 4, -0x2710); Bat.sphereT = Bat.checkerT = TWEEN_NONE; } static void Bat_OnInitCompleted(void) { // lo sfondo nero e trasparente; dopo 10,2 s (setTimeout: qui sull'orologio della scena) comincia a cambiare colore sprite_setTint(&BGMan.bgtile, 0), BGMan.bgtile.alpha = 0, BGMan.gradient = 0; time_addEvent(0x27d8, 0, 0, Bat_StartColorChange, NULL); } static void Bat_hideImg(void *ctx) { Sprite *s = ctx; if (s->alpha <= 0) s->visible = 0; } static void Bat_fade(ShaderImage *k, TweenRef *t, float to, float d) { // FadeSphere / FadeCheckerboard if (Bat.fixedBGColor) return; if (to > 0) k->img.visible = 1, k->img.alpha = 0; tween_stop(*t); *t = tweens_add((TweenConfig){ .props = { { &k->img.alpha, NULL, to } }, .nprops = 1, .duration = d, .onComplete = Bat_hideImg, .ctx = &k->img }); } static void Bat_FadeTileset(float to, float d) { TilingTileset *ts = Core.Stage->tilingTileset; if (!ts) return; for (int i = 0; i < ts->mapsAmount; i++) { LayerContainer *c = &ts->layerContainers[i]; static TweenProp p[16]; int n = 0; for (int j = 0; j < c->n && n < 16; j++) p[n++] = (TweenProp){ &c->layers[j]->s.alpha, NULL, to }; tweens_add((TweenConfig){ .many = p, .nmany = n, .duration = d }); } } static void Bat_warnBack(void *ctx) { Sprite *s = ctx; tweens_add((TweenConfig){ .props = { { &s->scaleX, &s->scaleY, 0 } }, .nprops = 1, .duration = 0xc8, .delay = 0xc8 }); } static void Bat_SingleWarning(float x, float y) { Sprite *w = calloc(1, sizeof(Sprite)); sprite_init(w, frame_get("UI", "ExclamationMark.png"), x, y); sprite_setScale(w, 0), w->depth = 0x2328; children_add(w); Sound_PlaySound("Pizza", 0.9f, 1, 0x1f4 * frand(), 0x96, 2); tweens_add((TweenConfig){ .props = { { &w->scaleX, &w->scaleY, 2 } }, .nprops = 1, .duration = 0xc8, .onComplete = Bat_warnBack, .ctx = w }); } static Vector2 Bat_center(void) { // GetCenter: il centro della copia della mappa dove si trova il giocatore TilingTileset *ts = Core.Stage->tilingTileset; Vector2 c = { (ts ? ts->current.x : 0) + 0x400, (ts ? ts->current.y : 0) + 0x600 }; if (ts && ts->inverted && po_is("VisuallyInvertStages")) c.y -= 0x400; return c; } static Vector2 Bat_concreteAt; static void Bat_warnRepeat(void *ctx) { (void)ctx; Bat_SingleWarning(Bat_concreteAt.x, Bat_concreteAt.y); } static void Bat_zoneOut(void *ctx) { Sprite *z = ctx; tweens_add((TweenConfig){ .props = { { &z->alpha, NULL, 0 } }, .nprops = 1, .duration = 0x64, .onComplete = Boss_ringHide, .ctx = z }); } static void Bat_relicOut(void *ctx) { Pickup *p = ctx; if (p->s.active) Pickup_DoDeSpawn(p); } // dopo 60 s il cemento se la riprende static void Bat_concrete(void *ctx) { // ctx: la reliquia murata (RELIC_CHARM al minuto 9, RELIC_MALACHITE al 18) PlayDiamond_Concrete(Bat_concreteAt.x, Bat_concreteAt.y); Pickup *p = po_has("CollectedItems", ctx) ? NULL : Core_MakeRelic(Bat_concreteAt.x, Bat_concreteAt.y, ctx); if (p) time_addEvent(0xea60, 0, 0, Bat_relicOut, p); } static void Bat_SpawnRelicInConcrete(const char *relic) { Bat_concreteAt = Bat_center(); Sprite *z = calloc(1, sizeof(Sprite)); // DisplayWarningZone: rettangolo rosso 448x448, ADD sprite_init(z, frame_get("vfx", "WhiteDot.png"), Bat_concreteAt.x, Bat_concreteAt.y); sprite_setTint(z, 0xff0000), z->blendAdd = 1, z->alpha = 0.2f, z->scaleX = 0x1c0 / z->width, z->scaleY = 0x1c0 / z->height; children_add(z); Bat_SingleWarning(Bat_concreteAt.x, Bat_concreteAt.y); tweens_add((TweenConfig){ .props = { { &z->alpha, NULL, 0.5f } }, .nprops = 1, .duration = 0xc8, .yoyo = 1, .repeat = 3, .onRepeat = Bat_warnRepeat, .onComplete = Bat_zoneOut, .ctx = z }); time_addEvent(0x7d0, 0, 0, Bat_concrete, (void *)relic); } static void Bat_BonusRound(int on) { Core.Stage->StageModifiers.EnemySpeed += on ? 1 : -1; Stage_CalculateEnemySpeed(Core.Stage); } static void Bat_CheckMinute(int m) { // customBG (pizze): F3 if (m == 7) Bat_fade(&Bat.sphere, &Bat.sphereT, 1, 0x3e8); if (m == 8) Bat_FadeTileset(0, 0x3e8); if (m == 9) Bat_FadeTileset(1, 0x3e8), Bat_fade(&Bat.sphere, &Bat.sphereT, 0, 0x3e8), Bat_fade(&Bat.checker, &Bat.checkerT, 0, 0x3e8); if (m == 0xe) Bat_fade(&Bat.sphere, &Bat.sphereT, 1, 0x3e8); if (m == 0xf) Bat_fade(&Bat.checker, &Bat.checkerT, 1, 0x3e8); if (m == 0x10) Bat_FadeTileset(0, 0x3e8); if (m == 0x12) Bat_FadeTileset(1, 0x3e8), Bat_fade(&Bat.sphere, &Bat.sphereT, 0, 0x3e8), Bat_fade(&Bat.checker, &Bat.checkerT, 0, 0x3e8); if (m == 8 || m == 0x11) Bat_BonusRound(1); if (m == 9) Bat_BonusRound(0), Bat_SpawnRelicInConcrete("RELIC_CHARM"); if (m == 0x12) Bat_BonusRound(0), Bat_SpawnRelicInConcrete("RELIC_MALACHITE"); } static void Bat_Update(float delta) { (void)delta; if (Bat.canChangeColor) { // ChangeColor: in alto e in basso due colori che sfumano verso i successivi int n = Bat.colorIndex + 1 >= 5 ? 0 : Bat.colorIndex + 1; BGMan.gradient = 1, BGMan.gradTop = LerpColor(BatTop[Bat.colorIndex], BatTop[n], Bat.lerpV), BGMan.gradBottom = LerpColor(BatBottom[Bat.colorIndex], BatBottom[n], Bat.lerpV); } Vector2 v = Core.Player->s.body.velocity; if (v.x != 0 || v.y != 0) Bat.sx += v.x, Bat.sy += v.y; // gli uniform prendono il valore di prima (sic): qui un frame di ritardo non si vede ShaderImage_render(&Bat.sphere, Bat.sx, Bat.sy), ShaderImage_render(&Bat.checker, 0, 0); Bat.checker.img.angle += 0.25f; } static int Bat_HasMovingBG(void) { return 1; } static void Bat_DisableMovingBackground(void) { Bat.fixedBGColor = 1, Bat.sphere.img.visible = 0, Bat.checker.img.visible = 0; } static const FancyBG FB_Bat = { Bat_Create, Bat_Update, Bat_CheckMinute, NULL, Bat_OnInitCompleted, Bat_HasMovingBG, Bat_DisableMovingBackground }; // ============================================================================ // Astral Stair (ASTRALSTAIR 0x935): stelle, colore che cambia con la quota, intro della discesa, battiti della musica; // STARDUST_* (0x138b2: rossi o blu a tempo, feriti solo da certe armi), alias (0xa329), occhi (0xf34e, 0x17b88, 0xb71d), COSMIC_EGG (0x10c7) // ============================================================================ // --- Core.CommonVFXManager (0x116a0): le scintille blu e rosse dei cambi di colore ------------------------------------------------------- static struct { ParticleManager *m; ParticleEmitter *blue, *red; } CommonVFX; static void CommonVFX_init(void) { if (CommonVFX.m && CommonVFX.m->s.onDisplayList) return; // una per partita (la lista di disegno riparte da zero) CommonVFX.m = particles_add(); CommonVFX.m->s.depth = 0x3e8; EmitterConfig c = { .nframes = 2, .angle = ERND(0, 0xb4), .speed = ERND(0x19, 0x32), .quantity = 0xa, .lifespan = ERND(0x64, 0x190), .alpha = ERANGE(1, 0), .scale = ERANGE(2, 1), .gravityY = -0x3e8, .on = 0 }; c.frames[0] = frame_get("vfx", "PfxHoly1.png"), c.frames[1] = frame_get("vfx", "PfxHoly2.png"); CommonVFX.blue = particles_createEmitter(CommonVFX.m, c); c.frames[0] = frame_get("vfx", "PfxDarkRed.png"), c.frames[1] = frame_get("vfx", "PfxRed.png"); CommonVFX.red = particles_createEmitter(CommonVFX.m, c); CommonVFX.m->hasWell = 1; // Well1 e Well2 identici in (0, 0): un pozzo con la forza doppia CommonVFX.m->wellPower = 2 * 0x190, CommonVFX.m->wellEpsilon = 0xc8 * 0xc8; } // --- STARDUST_* (0x138b2): a ogni battito diventano rossi o blu; blu li feriscono le armi "blu", rossi le "rosse" ------------------------ typedef struct { int isBlue, isRed, invertFlip; float defaultScale; } StardustX; static const char *const StardustBlue[] = { "MAGIC_MISSILE", "KNIFE", "AXE", "CROSS", "HOLYBOOK", "HOLYWATER", "LIGHTNING", "LOOP", "CORRIDOR", "GUNS2", "GUNS2_COUNTER", "SILF_COUNTER", "SILF3", "LANCET", "VENTO", "VICTORY", "SILVERWIND", "SUMMONNIGHT2", "BUBBLES", "BUBBLES2", "SPELL_STRIKE", "SPELL_STRING", "SPELL_STREAM", "SPELL_STROM", "HOLY_MISSILE", "THOUSAND", "HEAVENSWORD", "BORA", "TRIASSO1", "TRIASSO2", "TRIASSO3", "MIRAGEROBE", "MIRAGEROBE2", "COLDEXPLOSION", "JUBILEE", "JUBILEE_RAYS", "ROCHER", "PARTY_COUNTER", "SONG", "MANNAGGIA", "ROSARY", "PENTAGRAM", "SIRE", "PRISMATICMISS", "PRISMATICMISS2", "CHERRY2", "CHERRY_STAR", "CHERRY_STAR_EXPLO", "FOURSEASONS", "FOURSEASONS2", NULL }; static const char *const StardustRed[] = { "FIREBALL", "SILF2_COUNTER", "SILF3", "GUNS", "GUNS_COUNTER", "TRAPANO", "SHROUD", "CORRIDOR", "VENTO2", "VENTO2_EXPLO", "VENTO2_EXTRA", "MISSPELL", "SUMMONNIGHT", "NIGHTSWORD", "NIGHTSWORD2", "LEGIONNAIRE", "VAMPIRICA", "HEAVENSWORD", "SCYTHE", "VESPERS", "HELLFIRE", "TRAPANO2", "MIRAGEROBE2", "FIREEXPLOSION", "NDUJA", "NDUJA_COUNTER", "ASTRONOMIA", "BLOOD_GARLIC", "BLOOD_LANCET", "BLOOD_LAUREL", "BLOOD_PENTAGRAM", "BLOOD_SONG", "JUBILEE", "JUBILEE_RAYS", "PARTY", "SONG", "MANNAGGIA", "ROSARY", "PENTAGRAM", "SIRE", "PRISMATICMISS", "PRISMATICMISS2", "CHERRY2", "CHERRY_STAR", "CHERRY_STAR_EXPLO", "FOURSEASONS", "FOURSEASONS2", NULL }; static int in_list(const char *const *l, const char *t) { for (; t && *l; l++) if (!strcmp(*l, t)) return 1; return 0; } static void Stardust_ctor(Enemy *e, StardustX *x) { float sc = num(enemy_data(e), "scale", 0); x->defaultScale = sc ? sc : 1; } static void E_Stardust_OnRecycle(Enemy *e) { if (!e->x) Stardust_ctor(e, e->x = calloc(1, sizeof(StardustX))); StardustX *x = e->x; base_EnemyOnRecycle(e); static const unsigned T[3] = { 0x888866, 0x886666, 0x888844 }; e->saveTint = T[(int)floorf(frand() * 3)], sprite_setTint(&e->s, e->saveTint); x->isBlue = x->isRed = x->invertFlip = 0; CommonVFX_init(); } static void Stardust_TurnBlue(Enemy *e) { StardustX *x = e->x; if (e->isDead) return; x->isBlue = 1, x->isRed = 0, x->invertFlip = 0, e->saveTint = 0x8888ff, sprite_setTint(&e->s, e->saveTint), sprite_setScale(&e->s, 1.2f); emitter_emitParticleAt(CommonVFX.blue, e->s.x, e->s.y, 0); } static void Stardust_TurnRed(Enemy *e) { StardustX *x = e->x; if (e->isDead) return; x->isBlue = 0, x->isRed = 1, e->saveTint = 0xff8888, sprite_setTint(&e->s, e->saveTint), sprite_setScale(&e->s, 1.2f); emitter_emitParticleAt(CommonVFX.red, e->s.x, e->s.y, 0); } static void E_Stardust_OnMusicBeat(Enemy *e) { if (((StardustX *)e->x)->isRed) Stardust_TurnBlue(e); else Stardust_TurnRed(e); } static void E_Stardust_GetDamaged(Enemy *e, float amount, int hitVFX, float kb, const char *t) { StardustX *x = e->x; float a = 0; if (!x->isBlue && !x->isRed) a = amount; else if (x->isBlue && in_list(StardustBlue, t)) a = amount; else if (x->isRed && in_list(StardustRed, t)) a = amount; if (e->damageWeakness > 1) a *= e->damageWeakness; if (a > 0) Core_ShowDamageAt(e->s.x, e->s.y, a); e->hp -= a; if (e->hp <= 0) Enemy_Die(e); else e->damageKB = kb; Sound_PlaySound("Hit", 0.5f, 1, 0x1f4 * (frand() - 0.5f), 0x96, 3); if (hitVFX != HIT_NONE) Core_ShowHitVFXAt(e->s.x, e->s.y, hitVFX); Enemy_OnGetDamaged(e, hitVFX); } static void E_Stardust_Update(Enemy *e) { // l'Update base con invertFlip, e la scala che torna a quella dei dati StardustX *x = e->x; if (e->isDead) return; e->s.depth = e->s.y - Core.Player->s.y; if (e->IsTimeStopped) return; if (!e->FixedDirection || (e->FixedDirection && e->_currentDirection.x == 0 && e->_currentDirection.y == 0)) { e->_currentDirection.x = e->target->x - e->s.x, e->_currentDirection.y = e->target->y - e->s.y; float l = sqrtf(e->_currentDirection.x * e->_currentDirection.x + e->_currentDirection.y * e->_currentDirection.y); if (l > 0) e->_currentDirection.x /= l, e->_currentDirection.y /= l; } if (e->Medusa) { e->medusaElapsed += 0.05f; e->_currentDirection.y = cosf(e->medusaElapsed); } if (e->SelfDestruct) Enemy_CheckSelfDestruct(e); float k = e->receivingDamage ? -e->knockback * e->damageKB : 1; e->s.flipX = x->invertFlip ? e->_currentDirection.x < 0 : e->_currentDirection.x > 0; float v = EnemySpeed * e->speed * k * e->slow; sprite_setVelocity(&e->s, v * e->_currentDirection.x, v * e->_currentDirection.y); e->s.angle = TweenAngles[e->moveTweenIndex]; sprite_setScale(&e->s, approach(e->s.scaleX, x->defaultScale, 0.01f)); } static const EnemyVT E_Stardust = { .OnRecycle = E_Stardust_OnRecycle, .GetDamaged = E_Stardust_GetDamaged, .Update = E_Stardust_Update, .OnMusicBeat = E_Stardust_OnMusicBeat }; // --- STARDUST_CLOAK / _GHOST (0xa329): l'alias per chi nasce sotto il giocatore -------------------------------------------------------- static void E_StardustAlias_setOwner(Enemy *e) { BridgeX *b = e->x; b->useAlias = e->s.y > Core.Player->s.y; if (b->useAlias) anims_play(&e->s, &b->aliasIdle, 0); } static const EnemyVT E_StardustAlias = { .OnRecycle = E_Bridge_OnRecycle, .Die = E_Bridge_Die, .Disappear = E_Bridge_Disappear, .setOwner = E_StardustAlias_setOwner }; // --- STARDUST_EYES / UNDEADEYES (0xf34e), STARDUST_HEAD / UNDEADHEAD (0x17b88), STARDUST_MUD (0xb71d): gli occhi sopra il corpo --------------- static void E_Eyes_OnRecycle(Enemy *e) { if (!e->x) { const char *t = e->enemyType; Sprite *eyes = e->x = calloc(1, sizeof(Sprite)); int mud = !strcmp(t, "STARDUST_MUD"), head = strstr(t, "HEAD") != NULL; sprite_init(eyes, frame_get(mud ? "enemiesM" : "enemies2", mud ? "Mud_eyes.png" : head ? "Head_eyes.png" : "Red_eyes.png"), e->s.x, e->s.y); eyes->depth = 0xc80; children_add(eyes); } Sprite *eyes = e->x; base_EnemyOnRecycle(e); sprite_setOrigin(eyes, e->s.originX, e->s.originY), eyes->scaleX = e->s.scaleX, eyes->scaleY = e->s.scaleY, eyes->visible = 1; static const unsigned T[3] = { 0x888866, 0x886666, 0x888844 }; e->saveTint = T[(int)floorf(frand() * 3)], sprite_setTint(&e->s, e->saveTint); } static void E_Eyes_Update(Enemy *e) { Sprite *eyes = e->x; base_EnemyUpdate(e); eyes->x = e->s.x, eyes->y = e->s.y, eyes->angle = e->s.angle, eyes->flipX = e->s.flipX; } static void E_Eyes_Die(Enemy *e) { base_EnemyDie(e); ((Sprite *)e->x)->visible = 0; } static void E_Eyes_Disappear(Enemy *e) { base_EnemyDisappear(e); ((Sprite *)e->x)->visible = 0; } static void E_Eyes_DeSpawn(Enemy *e) { base_EnemyDeSpawn(e); ((Sprite *)e->x)->visible = 0; } static const EnemyVT E_Eyes = { .OnRecycle = E_Eyes_OnRecycle, .Die = E_Eyes_Die, .Update = E_Eyes_Update, .DeSpawn = E_Eyes_DeSpawn, .Disappear = E_Eyes_Disappear }; // --- COSMIC_EGG (0x10c7): l'uovo con ali e occhio; ogni 15 s lancia un Infinite Corridor che dimezza la vita del giocatore ------------------ typedef struct { StardustX s; Sprite wingL, wingR, eye, corridorBG, corridorLight; Animation wing, eyeBlue, eyeRed, idleRed; float icTime; int damageDone; TweenRef scaleT, angleT, lightT, deathT; } EggX; static void Egg_anim(Animation *a, const char *prefix, float fps) { a->n = anims_generateFrameNames("enemiesM", prefix, 1, 5, 0, a->frames, ANIM_MAX_FRAMES); a->frameRate = fps, a->msPerFrame = 1000 / fps, a->repeat = -1; } static void Egg_UpdateSprites(Enemy *e) { EggX *g = e->x; Sprite *s[3] = { &g->wingL, &g->wingR, &g->eye }; for (int i = 0; i < 3; i++) s[i]->scaleX = e->s.scaleX, s[i]->scaleY = e->s.scaleY, s[i]->x = e->s.x, s[i]->y = e->s.y; e->s.depth = 0.5f * game_height; g->eye.depth = e->s.depth + 1, g->wingR.depth = g->wingL.depth = e->s.depth - 1; } static void E_Egg_OnRecycle(Enemy *e) { if (!e->x) { EggX *g = e->x = calloc(1, sizeof(EggX)); Stardust_ctor(e, &g->s); Egg_anim(&g->wing, "Wing_i0", 0xa), Egg_anim(&g->eyeBlue, "CEye_i0", 0xa), Egg_anim(&g->eyeRed, "CEyeRed_i0", 0xa), Egg_anim(&g->idleRed, "CEggRed_i0", 0xa); Sprite *s[3] = { &g->wingL, &g->wingR, &g->eye }; const char *f[3] = { "Wing_i01.png", "Wing_i01.png", "CEye_i01.png" }; for (int i = 0; i < 3; i++) sprite_init(s[i], frame_get("enemiesM", f[i]), e->s.x, e->s.y), children_add(s[i]); anims_play(&g->wingL, &g->wing, 0), anims_play(&g->wingR, &g->wing, 0), anims_play(&g->eye, &g->eyeBlue, 0); e->isTeleportOnCull = 1, g->s.isBlue = 1; sprite_init(&g->corridorBG, frame_get("vfx", "corridor_bg.png"), 0, 0), g->corridorBG.visible = 0, g->corridorBG.depth = -game_height; sprite_init(&g->corridorLight, frame_get("vfx", "corridor_light.png"), 0, 0), g->corridorLight.visible = 0, g->corridorLight.depth = -game_height; children_add(&g->corridorBG), children_add(&g->corridorLight); g->scaleT = g->angleT = g->lightT = g->deathT = TWEEN_NONE; } EggX *g = e->x; base_EnemyOnRecycle(e); // StardustX.OnRecycle: tinta a caso (sovrascritta sotto), colori azzerati g->s.isBlue = g->s.isRed = g->s.invertFlip = 0; CommonVFX_init(); Egg_UpdateSprites(e); g->wingL.visible = g->wingR.visible = g->eye.visible = 1; sprite_setOrigin(&e->s, 0.5f, 0.5f), sprite_setOrigin(&g->wingR, -0.2f, 0.5f), sprite_setOrigin(&g->wingL, 1.2f, 0.5f), g->wingL.flipX = 1; e->saveTint = 0xffffff, sprite_setTint(&e->s, 0xffffff); g->icTime = 0; } static void E_Egg_OnMusicBeat(Enemy *e) { EggX *g = e->x; if (e->isDead) return; if (g->s.isRed) { g->s.isBlue = 1, g->s.isRed = 0, g->s.invertFlip = 0; anims_play(&g->eye, &g->eyeBlue, 0); if (e->idle.n) anims_play(&e->s, &e->idle, 0); sprite_setScale(&e->s, 1.2f), emitter_emitParticleAt(CommonVFX.blue, e->s.x, e->s.y, 0); } else { g->s.isBlue = 0, g->s.isRed = 1; anims_play(&g->eye, &g->eyeRed, 0), anims_play(&e->s, &g->idleRed, 0); sprite_setScale(&e->s, 1.2f), emitter_emitParticleAt(CommonVFX.red, e->s.x, e->s.y, 0); } } static void Egg_corridorCheck(void *ctx) { // onUpdate dello scaleTween: chi e' dentro il cerchio perde meta' della vita (o uno scudo) Enemy *e = ctx; EggX *g = e->x; float dx = Core.Player->s.x - e->s.x, dy = Core.Player->s.y - e->s.y, r = 0x40 * g->corridorBG.scaleX; if (g->damageDone || dx * dx + dy * dy > r * r) return; g->damageDone = 1; Player *p = Core.Player; if (p->_invul || getenv("VS_GOD")) return; if (p->shields > 0) { p->shields -= 1; Player_OnGetDamaged(p, 0xffffbb, p->shieldInvulTime, 0); PlayerEvents_arg = 0.5f * p->hp; PlayerEvents_emit(EV_PLAYER_LOSTSHIELD); return; } p->hp *= 0.5f; Player_OnGetDamaged(p, 0xff0000, 0x78, 1); PlayerUI_Update(); } static void Egg_corridorEnd(void *ctx) { EggX *g = ((Enemy *)ctx)->x; g->corridorBG.visible = g->corridorLight.visible = 0; } static void Egg_CastInfiniteCorridor(Enemy *e) { EggX *g = e->x; float a = 1, la = 0.75f, sc = game_width / 128.0f; // FlashingVFXEnabled g->corridorBG.visible = g->corridorLight.visible = 1; sprite_setScale(&g->corridorBG, 0), g->corridorBG.alpha = 0, sprite_setScale(&g->corridorLight, 0), g->corridorLight.alpha = la; tween_stop(g->scaleT); g->scaleT = tweens_add((TweenConfig){ .props = { { &g->corridorBG.scaleX, &g->corridorBG.scaleY, sc }, { &g->corridorBG.alpha, NULL, a } }, .nprops = 2, .duration = 0x3e8, .yoyo = 1, .ease = Ease_SineInOut, .onUpdate = Egg_corridorCheck, .onComplete = Egg_corridorEnd, .ctx = e }); Sound_PlaySound("Corridor", 0.9f, 1, 0x1f4, 0x190, 1); tween_stop(g->angleT); g->angleT = tweens_add((TweenConfig){ .props = { { &g->corridorBG.angle, NULL, -0x5a0 } }, .nprops = 1, .duration = 0x7d0 }); tween_stop(g->lightT); g->lightT = tweens_add((TweenConfig){ .props = { { &g->corridorLight.scaleX, &g->corridorLight.scaleY, sc }, { &g->corridorLight.alpha, NULL, a } }, .nprops = 2, .duration = 0x3e8, .yoyo = 1, .ease = Ease_SineInOut }); } static void E_Egg_Update(Enemy *e) { EggX *g = e->x; E_Stardust_Update(e); if (e->isDead) return; Egg_UpdateSprites(e); e->s.angle = 0, g->eye.flipX = e->_currentDirection.x < 0; g->icTime += Enemies_delta; if (g->icTime > 0x3a98) g->icTime = 0, g->damageDone = 0, Egg_CastInfiniteCorridor(e); g->corridorBG.x = g->corridorLight.x = e->s.x, g->corridorBG.y = g->corridorLight.y = e->s.y; } static void Egg_hide(void *ctx) { EggX *g = ((Enemy *)ctx)->x; g->wingL.visible = g->wingR.visible = g->eye.visible = 0; } static void E_Egg_Die(Enemy *e) { EggX *g = e->x; base_EnemyDie(e); TweenProp p[3] = { { &g->wingL.scaleX, &g->wingL.scaleY, 0 }, { &g->wingR.scaleX, &g->wingR.scaleY, 0 }, { &g->eye.scaleX, &g->eye.scaleY, 0 } }; g->deathT = tweens_add((TweenConfig){ .props = { p[0], p[1], p[2] }, .nprops = 3, .duration = 0xc8, .onComplete = Egg_hide, .ctx = e }); } static void E_Egg_Disappear(Enemy *e) { base_EnemyDisappear(e); Egg_hide(e); } static void E_Egg_DeSpawn(Enemy *e) { base_EnemyDeSpawn(e); Egg_hide(e); } static const EnemyVT E_Egg = { .OnRecycle = E_Egg_OnRecycle, .Die = E_Egg_Die, .GetDamaged = E_Stardust_GetDamaged, .Update = E_Egg_Update, .DeSpawn = E_Egg_DeSpawn, .Disappear = E_Egg_Disappear, .OnMusicBeat = E_Egg_OnMusicBeat }; // --- Trisection (0x1ec0): ogni mezzo minuto la ruota a tre cerchi sceglie un evento buono, neutro o cattivo; al minuto parte -------------- typedef struct { int weight; const char *name; int minLevel; const char *type; float duration, moreX; const char *moreY; float moreZ; int repeat; float delay; } TriEvent; static const TriEvent TriGood[] = { { 2, "Rosary", 0, "ROSARY" }, { 3, "Pet", 0, "PET" }, { 5, "Chicken Bonanza", 0, "CHICKEN_BONANZA" }, { 1, "Gold Fever", 0, "GOLD_FEVER" }, { 1, "Free Passive", 0x14, "FREE_PASSIVE" }, { 1, "Free Passive", 0x64, "FREE_PASSIVE" }, { 5, "Firebreathing", 0, "FIREBREATHING" }, { 1, "Luck Boost", 0, "LUCK_BOOST" }, { 0xa, "Light Sources", 0, "LIGHT_SOURCES" }, { 1, "Candybox", 0x1e, "CANDYBOX" }, { 1, "Candybox", 0x64, "CANDYBOX" } }; static const TriEvent TriNeutral[] = { { 1, "Bat Swarm", 0, "BAT_SWARM" }, { 1, "Ghost Swarm", 0, "GHOST_SWARM", 0, 0, NULL, 0, 0xa, 0x7d0 }, { 1, "Medusa Swarm", 0, "MEDUSA_SWARM", 0, 0xc, "MEDUSA1" }, { 1, "Skull Swarm", 0, "SKULL_SWARM", 0, 0x10 }, { 1, "JellY Swarm", 0, "JELLY_SWARM", 0, 0x32 }, { 1, "Green Swarm", 0, "ECTO_SWARM", 0, 0xc8 }, { 1, "Shrimps Swarm", 0, "DRAGON_SWARM", 0, 0xc, "XLDRAGON2_FLAG" }, { 1, "Imp Swarm", 0, "IMP_SWARM", 0, 0x32 }, { 1, "Skeleton Swarm", 0xa, "SKELETON_SWARM", 0, 0, "SKELEWING_INO" }, { 1, "Roulette", 0xa, "POLTER_ROULETTE", 0x7530, 0x32, "POLTER_DEST", 1 } }; static const TriEvent TriBad[] = { { 1, "Panic Time", 0x3c, "PANIC_TIME" }, { 1, "Summon Night", 0x28, "SUMMON_NIGHT" }, { 1, "Summon Il Molise", 0xa, "SUMMON_MOLISE" }, { 1, "Ultra Wave", 0x14, "ULTRA_WAVE" }, { 1, "Crab Fest", 0x1e, "CRAB_FEST" }, { 1, "Jelly Wall", 0, "JELLY_WALL", 0x7530, 0x3c }, { 1, "Flower Wall", 0, "FLOWER_WALL", 0x9c40 }, { 1, "Pile Assault", 0, "PILE_ASSAULT", 0, 0x28, "PILE1", 0.7f }, { 1, "Mino Rush", 0xa, "MINO_RUSH", 0x3a98, 0x28 }, { 1, "Scorpion Lair", 0xf, "TWINS_PILES", 0, 3 }, { 1, "Roulette", 0xa, "POLTER_ROULETTE", 0x7530, 0x4b, "POLTER_DEST", 1 }, { 1, "Shooting Stars", 0, "SHOOTING_STAR", 0, 0x19, "100", 0.5f }, { 1, "The Stalker", 0x1e, "STALKER", 0xea60 }, { 1, "The Drowner", 0x1e, "DROWNER", 0xea60 } }; #define NTRI(a) ((int)(sizeof(a) / sizeof((a)[0]))) static struct { int on, nextChoice, previousPlayerLevel, lastCount; const TriEvent *chosen; Sprite c[4], text; // sCenter, sWorld, sMoon, sSun; nextEventText char label[32]; float counter; TweenRef tw[3], show, hide, count; } Tri; static void TriText_draw(Sprite *s) { // scene.add.text(..., { color: white, fontSize: 14px }), origin (1, 0.5), tinta per il nome scelto if (!s->visible || s->alpha <= 0 || !Tri.label[0]) return; float fs = 14 * s->scaleX; Vector2 m = MeasureTextEx(vs_font, Tri.label, fs, 1); DrawTextEx(vs_font, Tri.label, (Vector2){ s->x - m.x, s->y - 0.5f * m.y }, fs, 1, hexc(s->tint, s->alpha)); } static void Trisection_init(void) { memset(&Tri, 0, sizeof(Tri)); Tri.on = 1; for (int i = 0; i < 4; i++) { Sprite *c = &Tri.c[i]; sprite_init(c, frame_get("UI", TextFormat("Circle%d.png", i + 1)), game_width, game_height); c->depth = ZInGameUI - 0xa, sprite_setScale(c, 4), c->alpha = 0, c->scrollFactor0 = 1; children_add(c); } sprite_init(&Tri.text, NULL, game_width - 0xc, game_height - 0xc); Tri.text.draw = TriText_draw, Tri.text.scrollFactor0 = 1, Tri.text.depth = ZInGameUI - 9, Tri.text.tint = 0xffffff, Tri.text.scaleX = Tri.text.scaleY = 1; children_add(&Tri.text); for (int i = 0; i < 3; i++) Tri.tw[i] = TWEEN_NONE; Tri.show = Tri.hide = Tri.count = TWEEN_NONE; } static void Tri_circles(float alpha, float scale, TweenRef *r) { // tween su tutti e quattro con stagger(100, { start: 500 }) static TweenProp p[8]; for (int i = 0; i < 4; i++) p[2 * i] = (TweenProp){ &Tri.c[i].alpha, NULL, alpha }, p[2 * i + 1] = (TweenProp){ &Tri.c[i].scaleX, &Tri.c[i].scaleY, scale }; for (int i = 0; i < 4; i++) tweens_add((TweenConfig){ .props = { p[2 * i], p[2 * i + 1] }, .nprops = 2, .duration = 0xc8, .delay = 0x1f4 + 0x64 * i }); (void)r; } static void Trisection_ShowUI(void) { if (Tri.on) Tri_circles(1, 2, &Tri.show); } static void Tri_hide(void *ctx) { (void)ctx; Tri_circles(0, 2.5f, &Tri.hide); } static const TriEvent *Tri_pick(const TriEvent *e, int n) { // weighted: il primo con peso cumulato >= r * totale, tra quelli del livello giusto float total = 0; for (int i = 0; i < n; i++) if (Core.Player->level >= e[i].minLevel) total += e[i].weight; float r = frand() * total, acc = 0; for (int i = 0; i < n; i++) if (Core.Player->level >= e[i].minLevel && (acc += e[i].weight) >= r) return &e[i]; return NULL; } static void Tri_choose(void) { // CalculateMainChances + ChooseEvent float r = frand(); int c = r < 0.15f ? 0 : r < 0.3f ? 1 : r < 0.45f ? 2 : (0.3f + frand() < 0.5f * Player_PLuck(Core.Player) ? 0 : 2); Tri.chosen = c == 0 ? Tri_pick(TriGood, NTRI(TriGood)) : c == 1 ? Tri_pick(TriNeutral, NTRI(TriNeutral)) : Tri_pick(TriBad, NTRI(TriBad)); } static void Tri_textStart(void *ctx) { (void)ctx; sprite_setTint(&Tri.text, 0xffffff), sprite_setScale(&Tri.text, 1), Tri.text.alpha = 0.65f; } static void Tri_rotateName(void) { int n = NTRI(TriGood) + NTRI(TriNeutral) + NTRI(TriBad), k = (int)floorf(frand() * n); const TriEvent *e = k < NTRI(TriGood) ? &TriGood[k] : k < NTRI(TriGood) + NTRI(TriNeutral) ? &TriNeutral[k - NTRI(TriGood)] : &TriBad[k - NTRI(TriGood) - NTRI(TriNeutral)]; snprintf(Tri.label, sizeof(Tri.label), "%s", e->name); tweens_add((TweenConfig){ .props = { { &Tri.text.scaleX, &Tri.text.scaleY, 1.2f }, { &Tri.text.alpha, NULL, 1 } }, .nprops = 2, .duration = 0xfa, .yoyo = 1, .onStart = Tri_textStart }); } static void Tri_highlightStart(void *ctx) { (void)ctx; snprintf(Tri.label, sizeof(Tri.label), "%s", Tri.chosen->name), sprite_setTint(&Tri.text, 0xffff00); } static void Tri_counterUpdate(void *ctx) { (void)ctx; int v = (int)floorf(Tri.counter); if (v == Tri.lastCount) return; Tri.lastCount = v; if (v < 0xc) { Tri_rotateName(); return; } Tri_choose(); if (Tri.chosen) tweens_add((TweenConfig){ .props = { { &Tri.text.scaleX, &Tri.text.scaleY, 1.2f } }, .nprops = 1, .duration = 0xfa, .delay = 0xfa, .onStart = Tri_highlightStart }); else Tri.text.alpha = 0; } static int cmp_jsnum(const void *a, const void *b) { // Array.sort() senza comparatore: confronta le stringhe dei numeri (sic) char x[32], y[32]; snprintf(x, sizeof(x), "%.15g", *(const float *)a), snprintf(y, sizeof(y), "%.15g", *(const float *)b); return strcmp(x, y); } static void Trisection_Spinnn(void *ctx) { (void)ctx; if (!Tri.on) return; float d = 0x2710, k[3] = { 7 + 7 * frand(), 0xe + 0xe * frand(), 0x15 + 0x15 * frand() }; qsort(k, 3, sizeof(float), cmp_jsnum); for (int i = 0; i < 3; i++) tween_stop(Tri.tw[i]); Tri.tw[0] = tweens_add((TweenConfig){ .props = { { &Tri.c[1].angle, NULL, Tri.c[1].angle + 0x168 * k[2] } }, .nprops = 1, .duration = 0.8f * d, .ease = Ease_BounceOut }); Tri.tw[1] = tweens_add((TweenConfig){ .props = { { &Tri.c[2].angle, NULL, Tri.c[2].angle + 0x168 * k[1] } }, .nprops = 1, .duration = 0.9f * d, .ease = Ease_BounceOut }); Tri.tw[2] = tweens_add((TweenConfig){ .props = { { &Tri.c[3].angle, NULL, Tri.c[3].angle + 0x168 * k[0] } }, .nprops = 1, .duration = d, .ease = Ease_BounceOut, .onComplete = Tri_hide }); Tri.counter = 1, Tri.lastCount = 0; Tri.count = tweens_add((TweenConfig){ .props = { { &Tri.counter, NULL, 0xc } }, .nprops = 1, .duration = 0.95f * d, .onUpdate = Tri_counterUpdate }); } static void Trisection_TriggerTrisectionEvent(void) { if (!Tri.on || !Tri.chosen) return; const TriEvent *e = Tri.chosen; cJSON *ev = cJSON_CreateObject(); // stageEventManager.TriggerEvent(ev): lo stesso cammino degli eventi dei dati (delay e repeat compresi) cJSON_AddStringToObject(ev, "eventType", e->type); if (e->duration) cJSON_AddNumberToObject(ev, "duration", e->duration); if (e->moreX) cJSON_AddNumberToObject(ev, "moreX", e->moreX); if (e->moreY) { if (e->moreY[0] >= '0' && e->moreY[0] <= '9') cJSON_AddNumberToObject(ev, "moreY", atof(e->moreY)); else cJSON_AddStringToObject(ev, "moreY", e->moreY); } if (e->moreZ) cJSON_AddNumberToObject(ev, "moreZ", e->moreZ); if (e->repeat) cJSON_AddNumberToObject(ev, "repeat", e->repeat); if (e->delay) cJSON_AddNumberToObject(ev, "delay", e->delay); TriggerEvent(ev); tweens_add((TweenConfig){ .props = { { &Tri.text.alpha, NULL, 0 } }, .nprops = 1, .duration = 0xfa }); } // --- ASTRALSTAIR (0x935) ---------------------------------------------------------------------------------------------------------- // Senza le reliquie Rosalia + Trisection: niente Hurry ne' Mietitori, uova d'oro tolte, la discesa iniziale su un tappeto, poi i battiti e // (senza Trisection) la ruota; le porte (ListOfTeleporters) spente fino all'atterraggio. Con entrambe: la pizza e i battiti subito. static const char *const AstralPortraits[16] = { "stage_forest.png", "stage_batcountry.png", "stage_bone.png", "stage_bridge.png", "stage_chapel.png", "stage_foscari.png", "stage_foscari2.png", "stage_green.png", "stage_library.png", "stage_machine.png", "stage_molise.png", "stage_moonspell.png", "stage_rash.png", "stage_tower.png", "stage_x.png", "stage_water.png" }; static struct { TileSprite stars2; float startingX, startingY, distanceFromStartingY, speedFactor, yMul; int stopPlayerMovement, isPlayingIntroSequence, isOnBeatComplete, isEventTrisectionEnabled, hasTrisection; Sprite pizza; Sprite carpet, hand, portraits[0x40]; Animation pinchStart, pinchDo; TweenRef portraitT[0x40]; Timer initialTimeout, flipInterval, flipClear, mainInterval; } Astral; static Texture2D img_texture(const char *key) { // scene.textures.get(key) per le immagini sciolte (hStars2 = Stars2.png), ripetibili static Texture2D cache[8]; static char names[8][32]; for (int i = 0; i < 8; i++) { if (!strcmp(names[i], key)) return cache[i]; if (names[i][0]) continue; const char *file = !strcmp(key, "hStars1") ? "Stars1" : !strcmp(key, "hStars2") ? "Stars2" : key; cache[i] = LoadTexture(vs_path(TextFormat("img/%s.png", file))); SetTextureWrap(cache[i], TEXTURE_WRAP_REPEAT); snprintf(names[i], sizeof(names[i]), "%s", key); return cache[i]; } return (Texture2D){ 0 }; } static void Astral_OnBeat(void *ctx) { (void)ctx; if (!Astral.isOnBeatComplete) return; Astral.isOnBeatComplete = 0; for (int i = 0; i < Core.Enemies.n; i++) { Enemy *e = Core.Enemies.items[i]->owner; if (!e->isDead && e->vt && e->vt->OnMusicBeat) e->vt->OnMusicBeat(e); } } static void Astral_beatsOn(void *ctx) { (void)ctx; Astral.flipInterval = time_addEvent(0x320, 1, 0, Astral_OnBeat, NULL); } static void Astral_beatsOff(void *ctx) { (void)ctx; time_removeEvent(Astral.flipInterval); } static void Astral_StartFlipBeats(void *ctx) { // setTimeout / setInterval: qui sull'orologio della scena (con la musica che si ferma in pausa, quasi lo stesso) (void)ctx; Astral.initialTimeout = time_addEvent(0x81b0, 0, 0, Astral_beatsOn, NULL); Astral.flipClear = time_addEvent(0x124f8, 0, 0, Astral_beatsOff, NULL); } static void Astral_StartBeatsLoop(void) { Astral.mainInterval = time_addEvent(0x146c2, 1, 0, Astral_StartFlipBeats, NULL); } static void Astral_FirstTimeSetup(void) { TilingTileset *ts = Core.Stage->tilingTileset; Astral.stopPlayerMovement = 1; Astral.startingX = ts ? ts->StartPosition.x : Core.Player->s.x, Astral.startingY = (ts ? ts->StartPosition.y : Core.Player->s.y) - Astral.distanceFromStartingY; Core.Player->s.y = Astral.startingY; sprite_init(&Astral.carpet, frame_get("background_Astral", "carpet.png"), Astral.startingX, Astral.startingY); Astral.carpet.depth = -0xbb8, children_add(&Astral.carpet); for (int i = 0; i < Core.Enemies.n; i++) Enemy_Disappear(Core.Enemies.items[i]->owner); time_removeEvent(Core.tickerEvent), time_removeEvent(Core.Stage->SpawnTimer); for (int i = 0; i < 0x40; i++) { // MakeSpinningPortraits: i ritratti degli stage che scorrono da un lato all'altro Sprite *p = &Astral.portraits[i]; int left = frand() >= 0.5f; sprite_init(p, frame_get("UI", AstralPortraits[(int)floorf(frand() * 16)]), left ? -0x100 : game_width + 0x100, 0x80 * i + 0x80 * frand()); p->scrollFactor0 = 1, p->depth = -0x2710, p->angle = left ? -8 : 8; // onStart (una volta sola, all'avvio del tween) sprite_setScale(p, 0.5f + 0.5f * frand()); children_add(p); Astral.portraitT[i] = tweens_add((TweenConfig){ .props = { { &p->x, NULL, left ? game_width + 0x100 : -0x100 }, { &p->angle, NULL, left ? 8 : -8 } }, .nprops = 2, .duration = 0x1388 + 0x7d0 * frand(), .repeat = -1 }); } for (int i = 0; ts && i < ts->mapsAmount; i++) for (int j = 0; j < ts->layerContainers[i].n; j++) ts->layerContainers[i].layers[j]->s.alpha = 0; for (int i = 0; ts && i < ts->n_ListOfTeleporters; i++) ts->ListOfTeleporters[i]->canTeleport = 0; } static void Astral_MakePizza(void) { // PizzaTime.png sulla mappa; canPizza non diventa mai vero (CheckPizzas e AnimPizza: codice morto) float x = Core.Player->s.x, y = Core.Player->s.y - 0xc8; TilingTileset *ts = Core.Stage->tilingTileset; cJSON *o; if (ts) cJSON_ArrayForEach(o, tilemap_getObjectLayerObjects(ts->MainMap, "Scripts")) if (str(o, "name") && !strcmp(str(o, "name"), "ASTRALSTAIR_PIZZA")) x = num(o, "x", 0), y = num(o, "y", 0); sprite_init(&Astral.pizza, frame_get("items", "PizzaTime.png"), x, y); Astral.pizza.depth = -game_height; children_add(&Astral.pizza); } static void Astral_handPinch(void *ctx) { (void)ctx; anims_play(&Astral.hand, &Astral.pinchDo, 0); tweens_add((TweenConfig){ .props = { { &Astral.hand.y, NULL, 0.5f * game_height - 0x30 } }, .nprops = 1, .duration = 0x3e8 }); static TweenProp p[0x40 * 3]; for (int i = 0; i < 0x40; i++) p[3 * i] = (TweenProp){ &Astral.portraits[i].alpha, NULL, 0 }, p[3 * i + 1] = (TweenProp){ &Astral.portraits[i].scaleX, NULL, 0 }, p[3 * i + 2] = (TweenProp){ &Astral.portraits[i].scaleY, NULL, 4 }; tweens_add((TweenConfig){ .many = p, .nmany = 0x40 * 3, .duration = 0x5dc }); } static void Astral_EnterHand(void) { sprite_init(&Astral.hand, frame_get("enemiesM", "hand_pinch_01.png"), 0.5f * game_width, -0x30); Astral.hand.scrollFactor0 = 1, Astral.hand.angle = -0x5a, Astral.hand.depth = 0xbb8, sprite_setScale(&Astral.hand, 2); children_add(&Astral.hand); Astral.pinchStart.n = anims_generateFrameNames("enemiesM", "hand_pinch_", 1, 2, 2, Astral.pinchStart.frames, ANIM_MAX_FRAMES); Astral.pinchStart.frameRate = 8, Astral.pinchStart.msPerFrame = 125, Astral.pinchStart.repeat = -1; Astral.pinchDo.n = anims_generateFrameNames("enemiesM", "hand_pinch_", 3, 4, 2, Astral.pinchDo.frames, ANIM_MAX_FRAMES); Astral.pinchDo.frameRate = 8, Astral.pinchDo.msPerFrame = 125; anims_play(&Astral.hand, &Astral.pinchStart, 0); tweens_add((TweenConfig){ .props = { { &Astral.hand.y, NULL, 0.5f * game_height - 0x18 }, { &Astral.hand.scaleX, &Astral.hand.scaleY, 1 } }, .nprops = 2, .duration = 0x7d0, .delay = 0x7530, .onComplete = Astral_handPinch }); tweens_add((TweenConfig){ .props = { { &Astral.hand.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x1f4, .delay = 0x82dc }); } static void Astral_tilesetIn(void *ctx) { (void)ctx; Astral.stopPlayerMovement = 0, Core.canInterrupt = Core.canPause = 1; } static void Astral_landed(void *ctx) { (void)ctx; if (Astral.hasTrisection) Trisection_Spinnn(NULL); Astral.isEventTrisectionEnabled = 1; TilingTileset *ts = Core.Stage->tilingTileset; for (int i = 0; ts && i < ts->n_ListOfTeleporters; i++) ts->ListOfTeleporters[i]->canTeleport = 1; } static void Astral_descended(void *ctx) { (void)ctx; if (Astral.hasTrisection) Trisection_ShowUI(); TilingTileset *ts = Core.Stage->tilingTileset; for (int i = 0; ts && i < ts->mapsAmount; i++) { // FadeInTileset static TweenProp p[16]; int n = 0; for (int j = 0; j < ts->layerContainers[i].n && n < 16; j++) p[n++] = (TweenProp){ &ts->layerContainers[i].layers[j]->s.alpha, NULL, 1 }; tweens_add((TweenConfig){ .many = p, .nmany = n, .duration = 0x5dc, .onComplete = Astral_tilesetIn }); } tweens_add((TweenConfig){ .props = { { &Core.Player->s.y, NULL, Astral.startingY + Astral.distanceFromStartingY } }, .nprops = 1, .duration = 0x5dc, .onComplete = Astral_landed }); } static void Astral_descentUpdate(void *ctx) { (void)ctx; for (int i = 0; i < 0x40; i++) Astral.portraits[i].y -= 2; } static void Core_OnTickerEvent(void *ctx); static void Astral_descentStart(void *ctx) { (void)ctx; Core.tickerEvent = time_addEvent(po_is("SelectedHurry") ? 0x1f4 : 0x3e8, 1, 0, Core_OnTickerEvent, NULL); // RestoreTickerEvent Stage_startTimers(Core.Stage); po_sets("SelectedBGM", "BGM_AstralStair"), po_sets("SelectedBGMMod", "Normal"), Sound_SetupAndPlayBGM_Banger(1); Astral_StartFlipBeats(NULL), Astral_StartBeatsLoop(), Astral_EnterHand(); } static void Astral_StartIntroSequence(void) { if (Astral.isPlayingIntroSequence) return; Core.canInterrupt = Core.canPause = 0, Astral.isPlayingIntroSequence = 1; tweens_add((TweenConfig){ .props = { { &Astral.carpet.alpha, NULL, 0 } }, .nprops = 1, .duration = 0x1f4 }); tweens_add((TweenConfig){ .props = { { &Core.Player->s.y, NULL, Astral.startingY + Astral.distanceFromStartingY - 0x100 } }, .nprops = 1, .duration = 0x7d00, .delay = 0x1f4, .onUpdate = Astral_descentUpdate, .onStart = Astral_descentStart, .onComplete = Astral_descended }); } static int EggManager_RemoveBonuses(void); static void Stage_RecalculateCurse(Stage *st); static void Astral_Create(void) { memset(&Astral, 0, sizeof(Astral)); if (!(po_has("CollectedItems", "RELIC_ROSALIA") && po_has("CollectedItems", "RELIC_TRISECTION"))) { // il costruttore: niente scorciatoie cJSON_ReplaceItemInObject(PlayerOptions, "SelectedHurry", cJSON_CreateFalse()); cJSON_ReplaceItemInObject(PlayerOptions, "SelectedReapers", cJSON_CreateFalse()); if (po_is("SelectedGoldenEggs")) EggManager_RemoveBonuses(), Stage_RecalculateCurse(Core.Stage); } Astral.speedFactor = 1.1f, Astral.distanceFromStartingY = 0x3000; sprite_init(&Astral.stars2.s, NULL, 0.5f * game_width, 0.5f * game_height); Astral.stars2.s.draw = TileSprite_draw, Astral.stars2.s.scrollFactor0 = 1, Astral.stars2.s.depth = -0xdbb9f, Astral.stars2.s.blendAdd = 1, Astral.stars2.s.alpha = 0.15f; Astral.stars2.s.tint = 0xff0000, Astral.stars2.tex = img_texture("hStars2"), Astral.stars2.w = game_width, Astral.stars2.h = game_height; Astral.yMul = 1; if (po_is("SelectedInverse") && po_is("VisuallyInvertStages")) Astral.stars2.s.flipY = 1, Astral.yMul = -1; children_add(&Astral.stars2.s); Astral.initialTimeout = Astral.flipInterval = Astral.flipClear = Astral.mainInterval = (Timer){ -1, 0 }; } static void Astral_OnInitCompleted(void) { BGMan.bgtile.alpha = 0.35f; tweens_add((TweenConfig){ .props = { { &Astral.stars2.s.alpha, NULL, 0.45f } }, .nprops = 1, .duration = 0x3e8, .repeat = -1, .yoyo = 1 }); tweens_add((TweenConfig){ .props = { { &BGMan.bgtile.alpha, NULL, 0.2f } }, .nprops = 1, .duration = 0xbb8, .repeat = -1, .yoyo = 1 }); int rosalia = po_has("CollectedItems", "RELIC_ROSALIA"), tri = po_has("CollectedItems", "RELIC_TRISECTION"); if (rosalia && tri) { Astral_MakePizza(), Astral_StartFlipBeats(NULL), Astral_StartBeatsLoop(); return; } Astral_FirstTimeSetup(); Sound_StopMusic(); if (!tri) Trisection_init(), Astral.hasTrisection = 1; } static void Astral_Update(float delta) { (void)delta; Astral.isOnBeatComplete = 1; Player *p = Core.Player; if (Astral.stopPlayerMovement) { if (p->s.x < Astral.startingX - 0x30) p->s.x = Astral.startingX - 0x30; if (p->s.x > Astral.startingX + 0x30) p->s.x = Astral.startingX + 0x30; if (p->s.y < Astral.startingY - 0x10) p->s.y = Astral.startingY - 0x10; if (p->s.y > Astral.startingY + 0x20) Astral_StartIntroSequence(); } Astral.stars2.tilePositionX = Astral.speedFactor * p->s.x, Astral.stars2.tilePositionY = Astral.speedFactor * Astral.yMul * p->s.y; float d = p->s.y - 0x12c0, red = 0xff, blue = 0xff; // sopra rosso, sotto blu: GetColor(red, 0, blue) if (d > 0) red = fmaxf(0, 0xff - d / 0x2800 * 0xff); else if (d < 0) blue = fmaxf(0, 0xff - -d / 0x2800 * 0xff); unsigned c = (unsigned)red << 16 | (unsigned)blue; sprite_setTint(&BGMan.bgtile, c), sprite_setTint(&Astral.stars2.s, c); } static void Astral_CheckHalfMinute(void) { if (Astral.isEventTrisectionEnabled && Astral.hasTrisection) Trisection_ShowUI(), time_addEvent(0x3e8, 0, 0, Trisection_Spinnn, NULL); } static void Astral_CheckMinute(int m) { (void)m; if (Astral.isEventTrisectionEnabled && Astral.hasTrisection) Trisection_TriggerTrisectionEvent(); } static const FancyBG FB_Astral = { Astral_Create, Astral_Update, Astral_CheckMinute, Astral_CheckHalfMinute, Astral_OnInitCompleted }; static void BGMan_Update(void) { if (BGMan.canScroll && BGMan.bgtile.draw) BGMan.tilePositionX = BGMan.speedFactor * Core.Player->s.x, BGMan.tilePositionY = BGMan.speedFactor * BGMan.yMul * Core.Player->s.y; } static void BGMan_DayNightHue(void) { if (!BGMan.RunTimeHue || !BGMan.bgtile.draw) return; float t = Core.SurvivedSeconds + BGMan.timeOffset, c = fmodf(t, BGMan.dayCycleDuration); int even = (int)floorf(t / BGMan.dayCycleDuration) % 2 == 0; sprite_setTint(&BGMan.bgtile, LerpColor(BGMan.DayColor, BGMan.NightColor, even ? c / BGMan.dayCycleDuration : (BGMan.dayCycleDuration - c) / BGMan.dayCycleDuration)); } // ============================================================================ // 0x6036: GoldFever (il quadrifoglio dorato GILDED): monete dai nemici, barra e testi in basso // ============================================================================ static BMFont FontTitle; // 'titleFont' static Vector2 GF_edge[0x78]; static struct { int isActive, randomIndex, visible; float durationCap, defaultCap, total, redu, totalDuration, totalTime, durationInMS; float RANDOMS[0x3e8]; ParticleManager *coins, *colors; Sprite back, front; float fogAlpha, boxAlpha, boxY, barAlpha, barW; float titleX, titleSX, titleSY, titleAlpha, lenX, lenAlpha, totalSX, totalSY, totalY, totalAlpha; TweenRef fogTween, exitTween1; Timer exit2; int hasFog, hasExit1; } GF; static int GoldFever_isActive(void) { return GF.isActive; } static float GoldFever_GetRandom(void) { return GF.RANDOMS[GF.randomIndex++ % 0x3e8]; } static float Approach(float v, float to, float d) { return v < to ? fminf(v + d, to) : fmaxf(v - d, to); } static Vector2 Rectangle_GetPoint(Rectangle r, float pos) { // Geom.Rectangle.GetPoint: lungo il perimetro dall'angolo in alto a sinistra float p = 2 * (r.width + r.height) * pos; if (p > r.width + r.height) { if (p > 2 * r.width + r.height) return (Vector2){ r.x, r.y + r.height - (p - (2 * r.width + r.height)) }; return (Vector2){ r.x + r.width - (p - (r.width + r.height)), r.y + r.height }; } if (p > r.width) return (Vector2){ r.x + r.width, r.y + (p - r.width) }; return (Vector2){ r.x + p, r.y }; } static void GoldFever_drawBack(Sprite *s) { // redFog (ZInGameUI - 4), progressBox (- 2), progressBar (- 1) (void)s; float W = game_width, H = game_height; const Frame *f = frame_get("vfx", "redFog.png"); if (f && GF.fogAlpha > 0) { BeginBlendMode(BLEND_ADDITIVE); float fs = GoldFever_fogScale > 0 ? GoldFever_fogScale : 1; // origine (0, 0) DrawTexturePro(*f->tex, (Rectangle){ f->x, f->y, f->w, f->h }, (Rectangle){ 0, 0, W * fs, H * fs }, (Vector2){ 0, 0 }, 0, Fade(WHITE, GF.fogAlpha)); EndBlendMode(); } if (!GF.visible) return; if (GF.boxAlpha > 0) nine("frameB9.png", 6, (Rectangle){ 0, GF.boxY, W, 0x12 }, Fade(WHITE, GF.boxAlpha)); if (GF.barW > 0 && GF.barAlpha > 0) DrawRectangleRec((Rectangle){ 4, H - 0x12 + 4, GF.barW, 0xa }, Fade((Color){ 0xff, 0xcc, 0x22, 255 }, GF.barAlpha)); } static const char *GoldFever_msToTime(float ms) { int c = (int)floorf(fmodf(ms, 0x3e8) / 0xa), sec = (int)floorf(fmodf(ms / 0x3e8, 0x3c)), m = (int)floorf(fmodf(ms / 0xea60, 0x3c)); return TextFormat("%02d:%02d.%02d", m, sec, c); } static const char *GoldFever_format(float v) { // Intl.NumberFormat en-US, USD, 0 decimali long long n = llroundf(v); char d[32], o[48]; snprintf(d, sizeof(d), "%lld", n); int len = (int)strlen(d), k = 0; o[k++] = '$'; for (int i = 0; i < len; i++) { o[k++] = d[i]; if ((len - i - 1) % 3 == 0 && i < len - 1) o[k++] = ','; } o[k] = 0; return TextFormat("%s", o); } static void GoldFever_drawFront(Sprite *s) { // title, totalText, lengthText (ZInGameUI) (void)s; if (!GF.visible) return; float W = game_width, H = game_height; BMFont_draw(&FontTitle, "Gold Fever!", GF.titleX, H - 0xc, 0.5f, 1, GF.titleSX, GF.titleSY, Fade(WHITE, GF.titleAlpha)); BMFont_draw(&FontTitle, GoldFever_format(GF.total), 0.5f * W, GF.totalY, 0.5f, 1, GF.totalSX, GF.totalSY, Fade(WHITE, GF.totalAlpha)); BMFont_draw(&FontTitle, GoldFever_msToTime(GF.totalDuration), GF.lenX, H - 0xc, 1, 1, 1, 1, Fade(WHITE, GF.lenAlpha)); } static void GoldFever_init(void) { // constructor memset(&GF, 0, sizeof(GF)); GF.durationCap = GF.defaultCap = 0x2710; GF.redu = 1; BMFont_load(&FontTitle, "titleFont-export"); float W = game_width, H = game_height; GF.coins = particles_add(); // PfxEmitter: monete d'oro che saltano dal nemico particles_createEmitter(GF.coins, (EmitterConfig){ .frames = { frame_get("items", "CoinGold.png") }, .nframes = 1, .quantity = 0xa, .lifespan = EOP(0x7d0), .alpha = ERANGE(1, 0), .angle = ERND(0xe1, 0x13b), .speed = ERND(0xe1, 0x113), .scale = ERANGE(2, 0), .gravityY = 0x320, .bounce = 0.2f, .on = 0 }); // collideBottom senza bounds: Phaser non controlla i bordi for (int i = 0; i < 0x78; i++) GF_edge[i] = Rectangle_GetPoint((Rectangle){ 0, H - 0x12, W, 0x12 }, (float)i / 0x78); GF.colors = particles_add(); GF.colors->scrollFactor0 = 1; GF.colors->s.depth = ZInGameUI; particles_createEmitter(GF.colors, (EmitterConfig){ .frames = { frame_get("vfx", "_blur.png"), frame_get("vfx", "_blur2.png"), frame_get("vfx", "_blur3.png") }, .nframes = 3, .frameCycle = 1, .scale = ERANGE(1, 0), .lifespan = EOP(0x5dc), .blendAdd = 1, .edge = GF_edge, .nEdge = 0x78, .flowEveryFrame = 1, .on = 0 }); sprite_init(&GF.back, NULL, 0, 0); GF.back.draw = GoldFever_drawBack; GF.back.depth = ZInGameUI - 4; children_add(&GF.back); sprite_init(&GF.front, NULL, 0, 0); GF.front.draw = GoldFever_drawFront; GF.front.depth = ZInGameUI; children_add(&GF.front); GF.boxY = H - 0x12; for (int i = 0; i < 0x3e8; i++) GF.RANDOMS[i] = i / 1000.0f; shuffle(GF.RANDOMS, 0x3e8); // RND.shuffle } static void GoldFever_exit2(void *ctx) { (void)ctx; tweens_add((TweenConfig){ .props = { { &GF.titleAlpha, NULL, 0 }, { &GF.totalAlpha, NULL, 0 }, { &GF.lenAlpha, NULL, 0 } }, .nprops = 3, .duration = 0x1f4 }); } static void GoldFever_EnterUI(void) { float W = game_width, H = game_height; if (GF.hasExit1) tween_stop(GF.exitTween1); time_removeEvent(GF.exit2); GF.visible = 1; GF.titleAlpha = 1, GF.titleSX = 0.5f, GF.titleSY = 1, GF.titleX = W - 0x40; tweens_add((TweenConfig){ .props = { { &GF.titleX, NULL, 0x48 }, { &GF.titleSX, NULL, 1 } }, .nprops = 2, .duration = 0x190, .ease = Ease_SineInOut }); GF.lenAlpha = 1, GF.lenX = W - 0x40; tweens_add((TweenConfig){ .props = { { &GF.lenX, NULL, W - 8 } }, .nprops = 1, .duration = 0x190, .ease = Ease_SineInOut }); GF.totalY = H - 9, GF.totalSX = GF.totalSY = 1, GF.totalAlpha = 0; tweens_add((TweenConfig){ .props = { { &GF.totalAlpha, NULL, 1 }, { &GF.barAlpha, NULL, 1 } }, .nprops = 2, .duration = 0x190, .ease = Ease_SineInOut }); tweens_add((TweenConfig){ .props = { { &GF.boxAlpha, NULL, 1 } }, .nprops = 1, .duration = 0x190, .ease = Ease_SineInOut }); GF.boxY = H + 0x12; tweens_add((TweenConfig){ .props = { { &GF.boxY, NULL, H - 0x12 } }, .nprops = 1, .duration = 0x190, .ease = Ease_SineInOut }); emitter_start(GF.colors->emitters[0]); if (GF.hasFog) tween_stop(GF.fogTween); GF.fogAlpha = 0; // setAlpha(0.05), tween, setAlpha(0): il tween parte da 0 GF.fogTween = tweens_add((TweenConfig){ .props = { { &GF.fogAlpha, NULL, 0.15f } }, .nprops = 1, .duration = 0x1f4, .ease = Ease_SineInOut, .repeat = -1, .yoyo = 1 }); GF.hasFog = 1; Sound_PlaySound("Ringing", 1.5f, 1, -0x64, 0x96, 3); Sound_PlaySound("Ringing", 1.5f, 1, -0xc8, 0x96, 3); Sound_PlaySound("Ringing", 1.5f, 1, -0x12c, 0x96, 3); } static void GoldFever_ExitUI(void) { tweens_add((TweenConfig){ .props = { { &GF.barAlpha, NULL, 0 }, { &GF.boxAlpha, NULL, 0 } }, .nprops = 2, .duration = 0xc8 }); GF.exitTween1 = tweens_add((TweenConfig){ .props = { { &GF.totalSX, NULL, GF.totalSX + 0.5f }, { &GF.totalSY, NULL, GF.totalSY + 0.6f } }, .nprops = 2, .duration = 0x1f4 }); tweens_add((TweenConfig){ .props = { { &GF.totalY, NULL, GF.totalY - 0x30 } }, .nprops = 1, .duration = 0x1f4 }); GF.hasExit1 = 1; GF.exit2 = time_addEvent(0x1f4 + 0x7d0, 0, 0, GoldFever_exit2, NULL); // completeDelay 2000 emitter_stop(GF.colors->emitters[0]); if (GF.hasFog) tween_stop(GF.fogTween), GF.hasFog = 0; GF.fogAlpha = 0; } static void GoldFever_Start(float ms) { GF.durationCap = GF.defaultCap * Core.Player->gfeverMul; if (GF.isActive) { GF.durationInMS = fminf(GF.durationInMS + ms, GF.durationCap); GF.totalTime = fmaxf(GF.totalTime - ms, 0); return; } GF.durationInMS = ms, GF.totalTime = 0, GF.isActive = 1, GF.total = 0, GF.redu = 1, GF.totalDuration = 0; shuffle(GF.RANDOMS, 0x3e8); GoldFever_EnterUI(); } static void GoldFever_Restart(float ms) { GF.isActive = 0; GoldFever_Start(ms); } // semplificazione: new GoldFever = stato da capo, la UI resta la stessa static void GoldFever_CheckResults(void) { if (GF.totalDuration > po_num("LongestFever")) po_set("LongestFever", GF.totalDuration); if (GF.total > po_num("HighestFever")) po_set("HighestFever", GF.total); } static void GoldFever_Update(float delta) { if (!GF.isActive) return; GF.totalDuration += delta; GF.totalTime += delta * GF.redu * (Core.IsTimeStopped ? 0.5f : 1); if (GF.totalTime >= GF.durationInMS) { GF.totalTime = 0, GF.isActive = 0, GF.durationInMS = 0; GoldFever_CheckResults(); GoldFever_ExitUI(); } float w = game_width - 8; GF.barW = GF.durationInMS > 0 ? fminf((1 - GF.totalTime / GF.durationInMS) * w, w) : 0; // 0/0 = NaN: fillRect non disegna GF.titleSX = GF.titleSY = Approach(GF.titleSX, 1, 0.001f * delta); GF.totalSX = GF.totalSY = Approach(GF.totalSX, 1, 0.001f * delta); } static void GoldFever_OnEnemyDeath(Enemy *e) { if (GoldFever_GetRandom() > 0.75f) return; emitter_emitParticleAt(GF.coins->emitters[0], e->s.x, e->s.y - 8, 0); Pickup *c = Core_MakePickup(e->s.x, e->s.y, "COIN"); if (c) c->time = 1, c->goToPlayer = 1, c->value = 0.5f * e->feverValue, c->feverMS = 0xa; if (c) po_add("RunFever", c->value * GoldMultiplier * Player_PGreed(Core.Player)); } static void GoldFever_OnCoinPickup(Pickup *p) { if (!GF.isActive) { // Arcanas.CoinFever (Disco of Gold): i sacchetti avviano la febbre if (Arcanas.CoinFever && !strcmp(p->itemType, "COINBAG1")) GF.durationInMS = 0, GoldFever_Start(0x1388); else if (Arcanas.CoinFever && !strcmp(p->itemType, "COINBAGMAX")) GF.durationInMS = 0, GoldFever_Start(0x2710); return; } float add = p->feverMS * Core.Player->gfeverMul; GF.durationInMS = fminf(GF.durationInMS + add, GF.durationCap); GF.totalTime = fmaxf(GF.totalTime - add, 0); GF.titleSX = GF.titleSY = 1.25f; GF.total += p->value * GoldMultiplier * Player_PGreed(Core.Player); float sc; if (GF.total > 0x4e20) { float r = 1 + 0.15f * floorf(GF.total / 0x2710); sc = 1.15f + r; GF.redu = r; } else if (GF.total > 0x2710) sc = 2, GF.redu = 1.1f; else sc = GF.total > 0x3e8 ? 1.5f : GF.total > 0x64 ? 1.35f : 1.25f; GF.totalSX = GF.totalSY = sc; } // ============================================================================ // 0x119ba: GizmoManager (icona sopra la testa, pioggia del forziere rapido) // InitLevelUp/DisplayLevelUp/DisplayAngel/ShowHighlightAt: servono a level-up automatici, limit break e oggetti dello stage // ============================================================================ typedef struct { Sprite icon, text; char str[24]; float alpha, yOffset, halfW; int used; } GizmoIcon; static GizmoIcon gizmos[16]; static ParticleManager *quickTreasure; static void GizmoText_draw(Sprite *s) { // Text con setOrigin(0, 0.5), tint e setShadow(2, 2, '#000') GizmoIcon *g = s->owner; if (!g->alpha || !g->str[0]) return; Vector2 m = MeasureTextEx(vs_font, g->str, 16, 0); Vector2 at = { roundf(s->x - camera_scrollX), roundf(s->y - camera_scrollY - 0.5f * m.y) }; DrawTextEx(vs_font, g->str, (Vector2){ at.x + 2, at.y + 2 }, 16, 0, Fade(BLACK, g->alpha)); DrawTextEx(vs_font, g->str, at, 16, 0, hexc(s->tint, g->alpha)); } static void Gizmo_done(void *ctx) { GizmoIcon *g = ctx; children_remove(&g->icon); children_remove(&g->text); g->used = 0; } static void Gizmo_place(GizmoIcon *g) { // onUpdate: segue il giocatore Player *p = Core.Player; float dh = p->s.height * fabsf(p->s.scaleY) + 8; g->icon.x = p->s.x - g->halfW, g->icon.y = p->s.y - dh - g->yOffset; g->text.x = p->s.x - g->halfW + 0x10, g->text.y = p->s.y - dh - g->yOffset; g->icon.alpha = g->alpha; } static void GizmoManager_DisplayIconOverhead(const char *frame, const char *value, unsigned tint) { GizmoIcon *g = NULL; for (int i = 0; i < 16; i++) if (!gizmos[i].used) { g = &gizmos[i]; break; } if (!g) return; static const unsigned T[3] = { 0xffff00, 0xff00, 0xffff }; *g = (GizmoIcon){ .used = 1, .alpha = 1 }; snprintf(g->str, sizeof(g->str), "%s", value); sprite_init(&g->icon, frame_get("items", frame), 0, 0); g->icon.depth = 1; sprite_init(&g->text, NULL, 0, 0); g->text.owner = g; g->text.draw = GizmoText_draw; g->text.tint = tint ? tint : T[(int)floorf(frand() * 3)]; // RND.pick g->text.depth = 0xc1c; g->halfW = 0.5f * (0x10 + MeasureTextEx(vs_font, g->str, 16, 0).x); children_add(&g->icon); children_add(&g->text); Gizmo_place(g); tweens_add((TweenConfig){ .props = { { &g->alpha, NULL, 0 }, { &g->yOffset, NULL, 0x10 } }, .nprops = 2, .duration = 0x3e8, .onComplete = Gizmo_done, .ctx = g }); } static void Panini_update(void); static void GizmoManager_Update(void) { Panini_update(); for (int i = 0; i < 16; i++) if (gizmos[i].used) Gizmo_place(&gizmos[i]); } static void GizmoManager_coin(void *ctx) { // setTimeout: 100 ms * i int i = (int)(intptr_t)ctx; Sound_PlaySound("Coin", 0.5f + 0.05f * i, 1, 0x32 * i, 0, 0); } static void GizmoManager_DisplayQuickTreasureChestAnimation(void) { manager_emitParticleAt(quickTreasure, Core.Player->s.x, Core.Player->s.y); Sound_PlaySimple("Coin", 0.5f); for (int i = 1; i <= 4; i++) time_addEvent(0x64 * i, 0, 0, GizmoManager_coin, (void *)(intptr_t)i); // semplificazione: setTimeout va col tempo reale, qui col Clock della scena } // GizmoManager.ShowHighlightAt: anello verde e arcobaleno che si allargano dove compaiono le fonti di luce static struct { Sprite Highlight, Rainbow; int made; TweenRef t1, t2, r1, r2; } HL; static void HL_hStart(void *c) { (void)c; sprite_setScale(&HL.Highlight, 0); HL.Highlight.alpha = 0; HL.Highlight.angle = 0; HL.Highlight.visible = 1; } static void HL_hHide(void *c) { (void)c; HL.Highlight.visible = 0; } static void HL_hDone(void *c) { (void)c; HL.t2 = tweens_add((TweenConfig){ .props = { { &HL.Highlight.alpha, NULL, 0 } }, .nprops = 1, .duration = 0xfa, .onComplete = HL_hHide }); } static void HL_rStart(void *c) { (void)c; sprite_setScale(&HL.Rainbow, 0); HL.Rainbow.alpha = 0; HL.Rainbow.angle = 0; HL.Rainbow.visible = 1; } static void HL_rHide(void *c) { (void)c; HL.Rainbow.visible = 0; } static void HL_rDone(void *c) { (void)c; HL.r2 = tweens_add((TweenConfig){ .props = { { &HL.Rainbow.alpha, NULL, 0 }, { &HL.Rainbow.angle, NULL, 0x2d0 } }, .nprops = 2, .duration = 0xfa, .onComplete = HL_rHide }); } static void GizmoManager_ShowHighlightAt(float x, float y) { Sound_PlaySound("Lucky", 0, 1, 0, 0x1f4, 1); if (!HL.made) { HL.made = 1; sprite_init(&HL.Highlight, frame_get("vfx", "sPFX_ring_64.png"), x, y); HL.Highlight.visible = 0, HL.Highlight.blendAdd = 1, HL.Highlight.tint = 0xff00, HL.Highlight.depth = game_height; children_add(&HL.Highlight); sprite_init(&HL.Rainbow, frame_get("vfx", "s_pfx_rainbow_64.png"), x, y); HL.Rainbow.visible = 0, HL.Rainbow.blendAdd = 1, HL.Rainbow.depth = game_height; children_add(&HL.Rainbow); HL.t1 = HL.t2 = HL.r1 = HL.r2 = TWEEN_NONE; } HL.Highlight.x = HL.Rainbow.x = x, HL.Highlight.y = HL.Rainbow.y = y; tween_stop(HL.t1), tween_stop(HL.t2); HL.t1 = tweens_add((TweenConfig){ .props = { { &HL.Highlight.alpha, NULL, 0.35f }, { &HL.Highlight.scaleX, &HL.Highlight.scaleY, 4.2f } }, .nprops = 2, .duration = 0xfa, .ease = Ease_SineOut, .onStart = HL_hStart, .onComplete = HL_hDone }); tween_stop(HL.r1), tween_stop(HL.r2); HL.r1 = tweens_add((TweenConfig){ .props = { { &HL.Rainbow.alpha, NULL, 0.5f }, { &HL.Rainbow.scaleX, &HL.Rainbow.scaleY, 4.2f }, { &HL.Rainbow.angle, NULL, 0x168 } }, .nprops = 3, .duration = 0x12c, .ease = Ease_SineOut, .onStart = HL_rStart, .onComplete = HL_rDone }); } // DisplayLevelUp / DisplayBlur / DisplayAngel: level-up automatici (scelte [Always], limit break casuale sempre) enum { GFX_TEXT, GFX_BLUR, GFX_ANGEL }; typedef struct { Sprite s; float scale, yOffset; int kind, used; } GizmoFx; static GizmoFx gizmoFx[8]; static ParticleEmitter *levelUpPfx; // InitLevelUp: PfxLine2 su una linea di 32 px static Animation angelAnim; static void GizmoFx_text_draw(Sprite *s) { // bitmapText 'titleFont' "LevelUp!", origine 0.5 GizmoFx *g = s->owner; if (!s->visible || g->scale <= 0) return; BMFont_draw(&FontTitle, "LevelUp!", s->x - camera_scrollX, s->y - camera_scrollY, 0.5f, 0.5f, g->scale, g->scale, WHITE); } static void GizmoFx_update(void *ctx) { // onUpdate: segue il giocatore GizmoFx *g = ctx; Player *p = Core.Player; if (g->kind == GFX_TEXT) { g->s.x = p->s.x, g->s.y = p->s.y - (p->s.height * fabsf(p->s.scaleY) + 0x10) - g->yOffset; emitter_emitParticleAt(levelUpPfx, p->s.x, p->s.y - 0x20, 1); } else if (g->kind == GFX_BLUR) { g->s.x = p->s.x, g->s.y = p->s.y - 0x18; sprite_setScale(&g->s, g->scale); } else g->s.x = p->s.x, g->s.y = p->s.y - 0x20 - g->yOffset; } static void GizmoFx_done(void *ctx) { GizmoFx *g = ctx; g->s.visible = 0; children_remove(&g->s); g->used = 0; } static GizmoFx *GizmoFx_new(int kind, const Frame *f) { GizmoFx *g = NULL; for (int i = 0; i < 8; i++) if (!gizmoFx[i].used) { g = &gizmoFx[i]; break; } if (!g) return NULL; *g = (GizmoFx){ .kind = kind, .used = 1 }; sprite_init(&g->s, f, 0, 0); g->s.owner = g; children_add(&g->s); GizmoFx_update(g); return g; } static void GizmoManager_DisplayBlur(void) { GizmoFx *g = GizmoFx_new(GFX_BLUR, frame_get("vfx", "blur128.png")); if (!g) return; g->s.tint = 0x8888ff, g->s.depth = -2, g->s.alpha = 0; sprite_setScale(&g->s, 0); tweens_add((TweenConfig){ .props = { { &g->s.alpha, NULL, 1 }, { &g->scale, NULL, 1 } }, .nprops = 2, .duration = 0x1f4, .yoyo = 1, .onUpdate = GizmoFx_update, .onComplete = GizmoFx_done, .ctx = g }); } static void GizmoManager_DisplayLevelUp(void) { GizmoFx *g = GizmoFx_new(GFX_TEXT, NULL); if (!g) return; BMFont_load(&FontTitle, "titleFont-export"); g->s.draw = GizmoFx_text_draw, g->s.depth = 1; tweens_add((TweenConfig){ .props = { { &g->scale, NULL, 1 }, { &g->yOffset, NULL, 0x40 } }, .nprops = 2, .duration = 0x1f4, .ease = Ease_SineInOut, .yoyo = 1, .onUpdate = GizmoFx_update, .onComplete = GizmoFx_done, .ctx = g }); GizmoManager_DisplayBlur(); Sound_PlaySound("AutoLV", 1, 1, 0, 0xc8, 1); } static void GizmoManager_DisplayAngel(void) { GizmoFx *g = GizmoFx_new(GFX_ANGEL, frame_get("angel", "angel1.png")); if (!g) return; g->s.depth = -1; anims_play(&g->s, &angelAnim, 0); tweens_add((TweenConfig){ .props = { { &g->s.alpha, NULL, 0 }, { &g->yOffset, NULL, 0x20 } }, .nprops = 2, .duration = 0x1f4, .onUpdate = GizmoFx_update, .onComplete = GizmoFx_done, .ctx = g }); } static void GizmoManager_DisplayLimitBreakLevelUp(void) { GizmoManager_DisplayAngel(); GizmoManager_DisplayLevelUp(); Sound_PlaySound("AutoLB", 1, 1, 0, 0xc8, 1); } static void GizmoManager_InitLevelUp(void) { memset(gizmoFx, 0, sizeof(gizmoFx)); make_anim(&angelAnim, "angel", "angel", 1, 8, 0, 0x1e, 0); ParticleManager *m = particles_add(); levelUpPfx = particles_createEmitter(m, (EmitterConfig){ .frames = { frame_get("vfx", "PfxLine2.png") }, .nframes = 1, .lifespan = EOP(0xfa), .rotate = EOP(0), .angle = { 0, 0x168, 0 }, .angleSteps = 0x10, .speed = ERND(0x3c, 0x5a), .quantity = 1, .scale = ERANGE(0.5f, 0), .scaleY = ERANGE(4, 0), .hasScaleY = 1, .alpha = ERANGE(0.35f, 0), .hasZoneRect = 1, .zoneRect = { -0x10, 0, 0x20, 0 }, .frequency = 1, .blendAdd = 1, .on = 0 }); } // Core.debug_destructibles: un cerchio di fonti di luce attorno al giocatore (Greatest Jubilee) static void Core_debug_destructibles(float mul) { GizmoManager_ShowHighlightAt(Core.Player->s.x, Core.Player->s.y); float n = Core.Stage->maxDestructibles * mul, step = 2 * PI / n, a0 = frand() * PI; for (int i = 0; i < n; i++) Core_MakeDestructibleAt(Core.Stage->destructibleType, (Vector2){ Core.Player->s.x + 0x7d * sinf(a0 + step * i), Core.Player->s.y + 0x7d * cosf(a0 + step * i) }); } static void GizmoManager_init(void) { // InitQuickTreasureChest memset(gizmos, 0, sizeof(gizmos)); quickTreasure = particles_add(); quickTreasure->s.depth = game_height; const Frame *bag = frame_get("items", "MoneyBagGreen.png"), *coin = frame_get("items", "CoinGold.png"); particles_createEmitter(quickTreasure, (EmitterConfig){ .frames = { bag, coin, coin, coin }, .nframes = 4, .quantity = 0x14, .lifespan = EOP(0x7d0), .alpha = ERANGE(1, 0), .angle = ERND(0xf5, 0x127), .speed = ERND(0x1a9, 0x1db), .scale = ERANGE(2, 0), .gravityY = 0x320, .on = 0 }); GizmoManager_InitLevelUp(); } // ============================================================================ // 0x5103: Core // ============================================================================ static void LevelUpScene_open(void); static void ParseLimitBreakUpInfo(cJSON *kv, char *out, size_t cap); static void Core_MakeAndActivatePickup(const char *type) { Pickup *p = Core_MakePickup(Core.Player->s.x, Core.Player->s.y, type); if (p) Pickup_DoGetTaken(p); } static void SceneManager_EnterLevelUp(void) { LevelUpScene_open(); Sound_FadeMusic(0.2f, 0x1f4); } // MainScene.blockInput, FadeMusic(0.2) static void Core_levelUpCoins(void) { // il sacchetto grande al posto della scelta Core_MakeAndActivatePickup("COINBAG2"); float v = 0x19 * GoldMultiplier; if (Core.Player) v *= Core.Player->greed; GizmoManager_DisplayIconOverhead("CoinGold.png", TextFormat("+%d", (int)roundf(v)), 0xffff00); GizmoManager_DisplayLevelUp(); } static void Core_SwapToLevelUpScene(void) { // Twitch: non c'e' int gospel = po_has("CollectedItems", "RELIC_GGOSPEL") && po_is("SelectedLimitBreak"); if (LevelUpFactory_HasPowerupsInStore()) SceneManager_EnterLevelUp(); else if (gospel) { if (Core.AlwaysRandomLimitBreak && LimitBreakManager_hasLimitBreaks()) { WeightedLimitBreak lb; int got = LimitBreakManager_GetRandomWeightedWeapon(&lb); if (Core_LimitBreakWeaponUp(got ? &lb : NULL)) { char d[256]; ParseLimitBreakUpInfo(lb.keyValues, d, sizeof(d)); GizmoManager_DisplayLimitBreakLevelUp(); GizmoManager_DisplayIconOverhead(str(tbl0("weapons", lb.weaponType), "frameName"), d, 0); Sound_PlaySimple("ClickIn", 0); } else SceneManager_EnterLevelUp(); } else if (Core.AlwaysCoinbag || Core.AlwaysRoast) Core_levelUpCoins(); else SceneManager_EnterLevelUp(); } else if (Core.AlwaysRoast && Core.Player->hp < Core.Player->maxHp) { Core_MakeAndActivatePickup("ROAST"); GizmoManager_DisplayIconOverhead("Roast.png", "", 0); GizmoManager_DisplayLevelUp(); } else if (Core.AlwaysCoinbag || Core.AlwaysRoast) Core_levelUpCoins(); else SceneManager_EnterLevelUp(); } static void TreasureScene_open(void); static void ItemFoundScene_open(void); static void RelicFoundScene_open(void); static void WeaponSelectScene_open(void); static void ARC_open(int draft); static int Arcana_unlockedCount(void); static int RandomazzoEnabled(void); static void Enemy_bloodlineAgain(void *ctx) { ((Enemy *)ctx)->canBeDamagedByBloodline = 1; } static void base_EnemyOnPlayerOverlap(Enemy *e); static void Enemy_OnPlayerOverlap(Enemy *e) { if (e->vt && e->vt->OnPlayerOverlap) e->vt->OnPlayerOverlap(e); else base_EnemyOnPlayerOverlap(e); } static void base_EnemyOnPlayerOverlap(Enemy *e) { // Divine Bloodline: il nemico che tocca il giocatore prende PArmor, al massimo ogni 500 ms if (!Arcanas.hasDivineBloodline || !e->canBeDamagedByBloodline) return; float a = Player_PArmor(Core.Player); Enemy_GetDamaged(e, a, HIT_NONE, 3, NULL); // bulletType VOID Arcanas.DivineBloodlineWeapon->stats_inflictedDamage += a; if (e->isDead) Arcanas_IncreaseBloodlineBonus(); e->canBeDamagedByBloodline = 0; time_removeEvent(e->divineBloodlineDamageTimer); e->divineBloodlineDamageTimer = time_addEvent(0x1f4, 0, 0, Enemy_bloodlineAgain, e); } static void Core_onPlayerOverlapsEnemy(void *ctx, Sprite *ps, Sprite *es) { (void)ctx; Enemy *e = es->owner; if (e->isDead || e->IsTimeStopped) return; game_context_set(Players_ofSprite(ps)); Player_GetDamaged(ps->owner, e->power); Enemy_OnPlayerOverlap(e); } static void Core_onPlayerOverlapsPickup(void *ctx, Sprite *ps, Sprite *ks) { (void)ctx; Pickup *p = ks->owner; game_context_set(Players_ofSprite(ps)); Pickup_owner = game_context; // forzieri, arcane e negozio si aprono per chi li ha presi Pickup_DoGetTaken(p); // GetPickup e' vuoto; GetTaken della sottoclasse } static void Core_onImmaterialPlayerOverlapsPickup(void *ctx, Sprite *ps, Sprite *ks) { // solo l'oro si raccoglie; il resto sparisce alla vista (void)ctx; (void)ps; Pickup *p = ks->owner; if (!p->goToPlayer || p->isStationary) return; p->s.visible = 0; if (!strcmp(p->itemType, "COIN") || !strcmp(p->itemType, "COINBAG1") || !strcmp(p->itemType, "COINBAGMAX")) Pickup_DoGetTaken(p); // goldItems } static void Core_onMagnetOverlapsPickup(void *ctx, Sprite *ms, Sprite *ks) { (void)ctx; game_context_set(Players_n > 1 && ms->owner == (void *)Slots[1].magnet ? 1 : 0); ((Pickup *)ks->owner)->player = game_context; Pickup_Vacuum(ks->owner); // particelle PfxEmitter_Pickups: non ancora tradotte } static void Core_OnTickerEvent(void *ctx) { (void)ctx; Core.SurvivedSeconds++; MainUI_SetSurvivedSeconds(Core.SurvivedSeconds); if (Core.SurvivedSeconds % 60 == 0) Stage_CheckMinute(Core.Stage); else if (Core.SurvivedSeconds % 30 == 0) { // Stage.CheckHalfMinute (Twitch: no) if (Core.Stage->fancyBG && Core.Stage->fancyBG->CheckHalfMinute) Core.Stage->fancyBG->CheckHalfMinute(); if (!Core.Stage->stopCheckingMinutes && po_is("SelectedRandomEvents") && Core.Stage->hasTrisection) Trisection_ShowUI(), time_addEvent(0x3e8, 0, 0, Trisection_Spinnn, NULL); } } // ============================================================================ // 0x30b5: Arcanas // ============================================================================ static void Arcanas_Init(void) { memset(&Arcanas, 0, sizeof(Arcanas)); Arcanas.divineBloodlineHPBonusUnit = 0.5f, Arcanas.CritMul = 1, Arcanas.MaxArcanasPerRun = 3, Arcanas.xpMultiplier = 1, Arcanas.minTreasureChestLevel = 1; Arcanas.wickedSeason.seasonTime = Arcanas.wickedSeason.seasonDuration = 0x2710; Arcanas.wickedSeason.growth = Arcanas.wickedSeason.luck = Arcanas.wickedSeason.curse = Arcanas.wickedSeason.greed = 1; // il timer di GatherAllStageItems ogni 5 s del costruttore non fa mai nulla: callback senza bind, this.canGather e' del TimerEvent } static void Arcanas_CheckOnAllWeapons(void) { for (int i = 0; i < Core.n_weapons; i++) if (Core.Weapons[i]->vt->CheckArcanas) Core.Weapons[i]->vt->CheckArcanas(Core.Weapons[i]); for (int i = 0; i < Core.n_HiddenWeapons; i++) if (Core.HiddenWeapons[i]->vt->CheckArcanas) Core.HiddenWeapons[i]->vt->CheckArcanas(Core.HiddenWeapons[i]); } static void Arcanas_CheckSilent(void) { // Silent Old Sanctuary: forza e ricarica per ogni slot d'arma libero if (!Arcanas.hasSilentSanctuary) { Arcanas.silentCooldown = Arcanas.silentMight = 0; return; } int n = 0; for (int i = 0; i < Core.n_weapons; i++) n += !Core.Weapons[i]->isPowerUp; int free = n < 6 ? 6 - n : 0; Arcanas.silentMight = 0.2f * free, Arcanas.silentCooldown = -0.08f * free; } static void Arcanas_LevelUpBonus(const char *k, float v) { // ActivateLevelUpBonus: si somma a una voce gia' presente Player *p = Core.Player; for (int i = 0; i < p->n_onEveryLevelUp; i++) if (!strcmp(p->onEveryLevelUp[i].k, k)) { p->onEveryLevelUp[i].v += v; return; } if (p->n_onEveryLevelUp < 24) p->onEveryLevelUp[p->n_onEveryLevelUp].k = k, p->onEveryLevelUp[p->n_onEveryLevelUp++].v = v; } static void Arcanas_TriggerAwake(void) { // dopo ogni Rinascita Player *p = Core.Player; p->maxHp += 0.1f * p->maxHp, p->armor += 1, p->power += 0.05f, p->area += 0.05f, p->duration += 0.05f, p->speed += 0.05f; } static void Arcanas_Beginning(void) { Arcanas.n_beginning = 0; cJSON *cd = cJSON_GetArrayItem(Core.Player->data, 0), *ex = cJSON_GetObjectItem(cd, "exWeapons"), *it; const char *list[16]; int n = 0; const char *sw = Core.Player->startingWeapon; if (sw && strcmp(sw, "VOID")) list[n++] = sw; cJSON_ArrayForEach(it, ex) if (cJSON_IsString(it) && n < 16) list[n++] = it->valuestring; if (sw && !strcmp(sw, "CANDYBOX") && Core.n_weapons > 0) n = 0, list[n++] = Core.Weapons[0]->bulletType; for (int i = 0; i < n && Arcanas.n_beginning < 16; i++) Arcanas.beginning[Arcanas.n_beginning++] = list[i]; if (sw && !strcmp(sw, "TRIASSO1")) { Arcanas.beginning[Arcanas.n_beginning++] = "TRIASSO2", Arcanas.beginning[Arcanas.n_beginning++] = "TRIASSO3"; } else for (int i = 0; i < n; i++) { const char *e = str(cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("weapons"), list[i]), 0), "evoInto"); if (!e) continue; if (Arcanas.n_beginning < 16) Arcanas.beginning[Arcanas.n_beginning++] = e; const char *e2 = str(cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("weapons"), e), 0), "evoInto"); if (e2 && Arcanas.n_beginning < 16) Arcanas.beginning[Arcanas.n_beginning++] = e2; } } static Weapon *Arcanas_NewWeapon(const char *type) { // new W_x(type) + Init + ArcanaWeapons.push Weapon *w = Weapon_new(type); Weapon_Init(w); if (Arcanas.n_ArcanaWeapons < 8) Arcanas.ArcanaWeapons[Arcanas.n_ArcanaWeapons++] = w; return w; } static float WickedSeason_duration(void) { return Arcanas.wickedSeason.seasonDuration; } // --- GatherAllStageItems (Mad Groove): armi a terra, oggetti, monete e gemme in cerchio attorno al giocatore, bracieri nuovi --- static void Arcanas_canGatherAgain(void *ctx) { (void)ctx; Arcanas.canGather = 1; } static void Groove_sfx(void *ctx) { int k = (int)(intptr_t)ctx; Sound_PlaySound("Groove", 1.5f + 0.1f * k, 1, 0xc8 + 0x190 * k, 0x96, 3); } static void Gather_disable(void *ctx) { ((Pickup *)ctx)->disableGet = 1; } static void Gather_enable(void *ctx) { ((Pickup *)ctx)->disableGet = 0; } static void Gather_weaponStart(void *ctx) { // disableGet + stopFloat Pickup *p = ctx; p->disableGet = 1; if (p->hasFloat) tween_stop(p->floatTween), tween_remove(p->floatTween), p->hasFloat = 0; } static void Gather_weaponDone(void *ctx) { Pickup *p = ctx; p->disableGet = 0; WeaponPickup_float(p); } // resumeFloat; TriggerOnGet: solo maschere static void Gather_tween(Sprite *s, float x, float y, float ms, Callback start, Callback done, void *ctx) { // stagger con un solo bersaglio: ritardo 0 tweens_add((TweenConfig){ .props = { { &s->x, NULL, x }, { &s->y, NULL, y } }, .nprops = 2, .duration = ms, .ease = Ease_SineInOut, .onStart = start, .onComplete = done, .ctx = ctx }); } static void shuffle_ptr(Pickup **a, int n) { for (int i = n - 1; i > 0; i--) { int j = (int)floorf(frand() * (i + 1)); Pickup *t = a[i]; a[i] = a[j], a[j] = t; } } // RND.shuffle static void Arcanas_GatherAllStageItems(void) { static const char *const ITEMS[9] = { "CLOVER", "GILDED", "NFT", "OROLOGION", "ROSARY", "VACUUM", "TREASURE", "ROAST", "RELIC_GOLDENEGG" }; if (!Arcanas.canGather) return; Arcanas.canGather = 0; time_addEvent(0x1388, 0, 0, Arcanas_canGatherAgain, NULL); Pickup *wp[32], *it[256], *co[256], *ge[512]; int nw = 0, ni = 0, nc = 0, ng = 0; for (int i = 0; i < Core.n_StagePickups; i++) if (!strcmp(Core.StagePickups[i]->itemType, "WEAPON")) wp[nw++] = Core.StagePickups[i]; for (int i = 0; i < Core.PickupGroup.n; i++) { Pickup *p = Core.PickupGroup.items[i]->owner; const char *t = p->itemType; if (!t) continue; int item = 0; for (int k = 0; k < 9; k++) item |= !strcmp(t, ITEMS[k]); if (item && ni < 256) it[ni++] = p; else if ((!strcmp(t, "COIN") || !strcmp(t, "COINBAG1") || !strcmp(t, "COINBAGMAX")) && nc < 256) co[nc++] = p; else if (!strcmp(t, "GEM") && ng < 512) ge[ng++] = p; } shuffle_ptr(it, ni), shuffle_ptr(co, nc), shuffle_ptr(ge, ng); for (int k = 0; k < 3; k++) time_addEvent(0xfa * (k + 1), 0, 0, Groove_sfx, (void *)(intptr_t)k); float r = 0xc8, px = Core.Player->s.x, py = Core.Player->s.y; float u = PI / nw; for (int i = 0; i < nw; i++) Gather_tween(&wp[i]->s, px + cosf(u * (-i - 0.5f)) * r, py + sinf(u * (-i - 0.5f)) * r, 0x3e8, Gather_weaponStart, Gather_weaponDone, wp[i]); u = (nw ? PI : 2 * PI) / ni; for (int i = 0; i < ni; i++) Gather_tween(&it[i]->s, px - cosf(u * (-i - 0.5f)) * r, py - sinf(u * (-i - 0.5f)) * r, 0x2ee, Gather_disable, Gather_enable, it[i]); u = 2 * PI / nc; for (int i = 0; i < nc; i++) Gather_tween(&co[i]->s, px - 0xaf * cosf(u * (-i - 0.5f)), py - 0xaf * sinf(u * (-i - 0.5f)), 0x3e8, Gather_disable, Gather_enable, co[i]); u = 2 * PI / ng; for (int i = 0; i < ng; i++) Gather_tween(&ge[i]->s, px - 0x96 * cosf(u * (-i - 0.5f)), py - 0x96 * sinf(u * (-i - 0.5f)), 0x3e8, Gather_disable, Gather_enable, ge[i]); int nd = Core.Stage->maxDestructibles; u = 2 * PI / nd; for (int i = 0; i < nd; i++) { Destructible *d = Core_MakeDestructibleAt(Core.Stage->destructibleType, (Vector2){ px + sinf(u * i) * 0x7d * 4, py + cosf(u * i) * 0x7d * 4 }); if (d) Gather_tween(&d->s, px + sinf(u * i) * 0x7d, py + cosf(u * i) * 0x7d, 0x1f4, NULL, NULL, NULL); } } static void Arcanas_TriggerArcana(int t) { Player *p = Core.Player; switch (t) { case 0: // T00_KILLER: niente esperienza, forzieri almeno di livello 2, gemme che sparano; VACUUM sbloccato da subito Arcanas.xpMultiplier = 0, Arcanas.minTreasureChestLevel = 2, Arcanas.pewpew = 1; Arcanas.GemCannonWeapon = Arcanas_NewWeapon("WINDOW2"); LootManager_RecalculateLoot(); break; case 1: { // T01_AQUARIUS: le gemelle entrano nella collezione static const char *const C[] = { "GUNS_COUNTER", "GUNS2_COUNTER", "SILF_COUNTER", "SILF2_COUNTER", "GATTI_COUNTER", "SHADOWSERVANT_COUNTER", "PARTY_COUNTER" }; for (int i = 0; i < 7; i++) Core_SetSeenWeapon(C[i]); break; } case 4: p->revivals += 3; break; // T04_AWAKE case 5: // T05_CRASH (Chaos in the Dark Night) if (!p->sineSpeed) p->sineSpeed = Sine_Start(0.5f, 1.5f, 0x2710); Arcanas_LevelUpBonus("speed", 0.01f); break; case 6: Arcanas.SarabandeWeapon = Arcanas_NewWeapon("SARABANDE"); break; // T06_SARABANDE case 8: Arcanas.MadGroove = 1, Arcanas.canGather = 1, Arcanas_GatherAllStageItems(); break; // T08_MAD_FOREST case 9: // T09_DIVINE Arcanas.hasDivineBloodline = 1; if (!Arcanas.DivineBloodlineWeapon) Arcanas.DivineBloodlineWeapon = Arcanas_NewWeapon("BLOODLINE"); Arcanas_CheckOnAllWeapons(); break; case 10: Arcanas_Beginning(), Arcanas_CheckOnAllWeapons(); break; // T10_BEGINNING case 13: // T13_WICKED Arcanas.hasWickedSeason = 1; Arcanas_LevelUpBonus("luck", 0.005f), Arcanas_LevelUpBonus("growth", 0.005f), Arcanas_LevelUpBonus("greed", 0.005f), Arcanas_LevelUpBonus("curse", 0.005f); Arcanas_CheckOnAllWeapons(); break; case 15: Arcanas.HealOnCoins = Arcanas.CoinFever = 1; break; // T15_GOLD case 16: Arcanas.CritMul = 2, Arcanas_CheckOnAllWeapons(); break; // T16_SLASH case 17: // T17_PAINTING if (!p->sineDuration) p->sineDuration = Sine_Start(0.5f, 1.5f, 0x2710); Arcanas_LevelUpBonus("duration", 0.01f); break; case 18: // T18_ILLUSIONS if (!p->sineArea) p->sineArea = Sine_Start(0.75f, 1.25f, 0x2710); Arcanas_LevelUpBonus("area", 0.01f); break; case 20: // T20_SINKING (Silent Old Sanctuary) p->rerolls += 3, p->banish += 3, p->skips += 3; Arcanas.hasSilentSanctuary = 1; Arcanas_CheckSilent(); break; case 12: // T12_OUT_OF_TIME if (!Arcanas.ColdExplosionWeapon) Arcanas.ColdExplosionWeapon = Arcanas_NewWeapon("COLDEXPLOSION"); // doesRetaliate = false Arcanas_CheckOnAllWeapons(); break; case 19: // T19_FIRE: ActivateHeartOfFireRetaliation if (!Arcanas.FireExplosionWeapon) Arcanas.FireExplosionWeapon = Arcanas_NewWeapon("FIREEXPLOSION"), Arcanas.FireExplosionWeapon->area = 1.5f; Arcanas_CheckOnAllWeapons(); break; case 21: // T21_BLOODY if (!Arcanas.hasAstronomia) Arcanas.BloodAstronomiaWeapon = Arcanas_NewWeapon("ASTRONOMIA"), Arcanas.hasAstronomia = 1; Arcanas_CheckOnAllWeapons(); break; default: Arcanas_CheckOnAllWeapons(); break; // T01, T02, T03, T07, T11, T14: solo le armi } } static void Arcanas_Add(int t) { // ActiveArcanas.push + TriggerArcana (OnConfirmClicked delle scene di scelta) if (t < 0 || t >= 22 || Arcanas.active[t]) return; Arcanas.active[t] = 1, Arcanas.order[Arcanas.n++] = t; Arcanas_TriggerArcana(t); } static void Arcanas_Update(float delta) { if (Arcanas.ColdExplosionWeapon) Arcanas.ColdExplosionWeapon->power = 1 + Core.SurvivedSeconds / 300.0f; if (Arcanas.MadGroove && Core.SurvivedSeconds % 0x78 == 0) Arcanas_GatherAllStageItems(); // ogni 2 minuti (canGather: una volta) for (int i = 0; i < Arcanas.n_ArcanaWeapons; i++) Arcanas.ArcanaWeapons[i]->vt->Update(Arcanas.ArcanaWeapons[i], delta); if (Arcanas.hasWickedSeason) { // 0x13661: ogni 10 s una stagione raddoppia una tra maledizione, crescita, fortuna e avidita' static const char *const sfx[4] = { "STEP4", "STEP1", "STEP2", "STEP3" }; if ((Arcanas.wickedSeason.seasonTime += delta) > Arcanas.wickedSeason.seasonDuration) { Arcanas.wickedSeason.seasonTime = 0; if (++Arcanas.wickedSeason.seasonIndex >= 4) Arcanas.wickedSeason.seasonIndex = 0; static const unsigned colors[4] = { 0xff4488, 0x4488ff, 0x44ff88, 0xccff00 }; static const char *const icons[4] = { "Curse.png", "Crown.png", "Clover.png", "Mask.png" }; PlayerUI_OpenSeasonFan(colors[Arcanas.wickedSeason.seasonIndex], icons[Arcanas.wickedSeason.seasonIndex]); Sound_PlaySound(sfx[Arcanas.wickedSeason.seasonIndex], 0.25f, 1, 0, 0x96, 3); } Arcanas.wickedSeason.growth = Arcanas.wickedSeason.luck = Arcanas.wickedSeason.curse = Arcanas.wickedSeason.greed = 1; float *v[4] = { &Arcanas.wickedSeason.curse, &Arcanas.wickedSeason.growth, &Arcanas.wickedSeason.luck, &Arcanas.wickedSeason.greed }; *v[Arcanas.wickedSeason.seasonIndex] = 2; Stage_CalculateEnemySpeed(Core.Stage); } if (Arcanas.hasDivineBloodline) { Arcanas.bloodlineArmorValue = 0.5f * Player_PArmor(Core.Player); Arcanas.bloodlineDamage = (Core.Player->maxHp - Core.Player->hp) / 0x64; } } static void Core_ApplyBoughtPowerup(cJSON *u) { if (!u) return; Player *p = Core.Player; p->power += num(u, "power", 0), p->area += num(u, "area", 0), p->speed += num(u, "speed", 0), p->cooldown += num(u, "cooldown", 0); p->duration += num(u, "duration", 0), p->amount += num(u, "amount", 0), p->moveSpeed += num(u, "moveSpeed", 0), p->growth += num(u, "growth", 0); p->luck += num(u, "luck", 0), p->armor += num(u, "armor", 0), p->maxHp += p->maxHp * num(u, "maxHp", 0), p->regen += num(u, "regen", 0); p->greed += num(u, "greed", 0), p->revivals += num(u, "revivals", 0), p->rerolls += num(u, "rerolls", 0), p->skips += num(u, "skips", 0); p->banish += num(u, "banish", 0), p->curse += num(u, "curse", 0), p->charm += num(u, "charm", 0); p->hp = p->maxHp; Core.Magnet->radius += Core.Magnet->radius * num(u, "magnet", 0); Magnet_RefreshSize(Core.Magnet); Core.Magnet->percentage += num(u, "magnet", 0); } static int G_humbugOn, G_petOn, G_hasP; static KeyCombo G_humbug, G_pet; static void SpellsManager_ActivateSpells(void); // Cio' che ogni giocatore fa per conto suo all'inizio della partita static void Player_setupFactory(void) { Player_MakeLevelOne(Core.Player); LevelUpFactory_Init(); LUF.maxTrueWeapons = (int)po_num("SelectedMaxWeapons"); cJSON *sw; cJSON_ArrayForEach(sw, po("SealedWeapons")) { // LevelUpFactory.BanishSealedWeapons int found = 0; for (int i = 0; i < LUF.n_banished; i++) found |= cJSON_IsString(sw) && !strcmp(LUF.BanishedWeapons[i], sw->valuestring); if (cJSON_IsString(sw) && !found && LUF.n_banished < 64) LevelUpFactory_DoExclude(sw->valuestring), LUF.BanishedWeapons[LUF.n_banished++] = sw->valuestring; } } static cJSON *Net_second; // {"char":..., "levels":{potenziamento: rango}}: l'equipaggiamento di chi si e' unito static void Player_applyPowerups(void) { cJSON *pw, *secondLevels = game_context == 1 && Net_second ? cJSON_GetObjectItem(Net_second, "levels") : NULL; cJSON_ArrayForEach(pw, data_get("powerups")) { // ApplyBoughtPowerup per ogni rango comprato dei potenziamenti attivi cJSON *p0 = cJSON_GetArrayItem(pw, 0); int ranks = secondLevels ? (int)cJSON_GetNumberValue(cJSON_GetObjectItem(secondLevels, pw->string)) : (int)num(p0, "level", 0); for (int k = 0; k < ranks; k++) if (cJSON_IsTrue(cJSON_GetObjectItem(p0, "active"))) Core_ApplyBoughtPowerup(cJSON_GetArrayItem(pw, k)); } if (Core.Player->exLevels > 0) Core.Player->xp = 5; // Cristina, Pino, Febbra } static void Player_addStartingWeapons(void) { if (Core.Player->startingWeapon) Core_AddWeapon(Core.Player->startingWeapon, 1); cJSON *xw; cJSON_ArrayForEach(xw, Core.Player->exWeapons) if (cJSON_IsString(xw)) Core_AddWeapon(xw->valuestring, 1); cJSON_ArrayForEach(xw, Core.Player->hiddenWeapons) if (cJSON_IsString(xw)) Core_AddHiddenWeapon(xw->valuestring); } static void Player_addDevWeapons(void) { // Sviluppo: VS_ADD="AXE,KNIFE:8" aggiunge armi all'avvio (come debug_AddAllWeapons); ":8" le porta a quel livello const char *add = getenv("VS_ADD"); static char names[16][32]; for (int n = 0; add && *add && n < 16; n++) { const char *e = strchr(add, ','); snprintf(names[n], sizeof(names[n]), "%.*s", e ? (int)(e - add) : (int)strlen(add), add); char *lv = strchr(names[n], ':'); int to = lv ? atoi(lv + 1) : 1; if (lv) *lv = 0; cJSON *k = cJSON_GetObjectItem(data_get("weapons"), names[n]); for (int l = 0; k && l < to; l++) Core_LevelWeaponUp(k->string, 1); add = e ? e + 1 : ""; } } // Il secondo giocatore entra in partita quando il primo e' gia' pronto. Il personaggio e' il suo (VS_CHAR2 finche' non c'e' la schermata di connessione). static void Players_addSecond(const char *character) { Sprite *first = &Core.Player->s; float x = first->x, y = first->y; Players_n = 2; game_context_set(1); const char *secondChar = Net_second ? cJSON_GetStringValue(cJSON_GetObjectItem(Net_second, "char")) : NULL; const char *c2 = getenv("VS_CHAR2") ? getenv("VS_CHAR2") : secondChar ? secondChar : character; TraceLog(LOG_INFO, "NET: secondo giocatore %s", c2); Core.Player = Player_new(c2); Core.Magnet = Magnet_new(); Slots[1].player = Core.Player, Slots[1].magnet = Core.Magnet; Core.Player->s.x = x + 0x28, Core.Player->s.y = y; list_add(&Core.playerGroup, &Core.Player->s); list_add(&Core.MagnetGroup, &Core.Magnet->s); Player_setupFactory(); Player_applyPowerups(); Player_addStartingWeapons(); Player_addDevWeapons(); game_context_set(0); } static void Core_InitGame(const char *character) { memset(&Core, 0, sizeof(Core)); Players_reset(); n_PlayerEvents[0] = n_PlayerEvents[1] = 0; // la scena nuova riparte senza listener Arcanas_Init(); // Core.InitGame: new Arcanas + Init, prima del giocatore Core.EnemyGroup.bit = 1; Core.Enemies.bit = 2; Core.PickupGroup.bit = 4; Core.BulletGroup.bit = 8; Core.Destructibles.bit = 16; Core.MaxDestructibles = 0xa; Core.TimeStopTimer = (Timer){ -1, 0 }; Core.updateFreq = 4; Core.MaxGems = 0x190; Core.defaultXPfactor = 5; Core.canInterrupt = Core.canPause = 1; // MakePlayer if (character && !strcmp(character, "ARENGIJUS") && !menu_launching) Arengijus_setupRNJ(); // senza menu (VS_SCENE=game) Core.Player = Player_new(character); Core.Magnet = Magnet_new(); PlayerUI_new(); list_add(&Core.playerGroup, &Core.Player->s); list_add(&Core.MagnetGroup, &Core.Magnet->s); physics_addCollider(&Core.playerGroup, &Core.Enemies, Core_onPlayerOverlapsEnemy, NULL); physics_addColliderSelf(&Core.EnemyGroup, NULL, NULL); Core.pickupCollider = physics_addOverlap(&Core.playerGroup, &Core.PickupGroup, Core_onPlayerOverlapsPickup, NULL); Core.pickupColliderImmaterial = physics_addOverlap(&Core.playerGroup, &Core.PickupGroup, Core_onImmaterialPlayerOverlapsPickup, NULL); Core.pickupColliderImmaterial->active = 0; // lo accende W_SoleSolution mentre il giocatore e' invisibile physics_addOverlap(&Core.MagnetGroup, &Core.PickupGroup, Core_onMagnetOverlapsPickup, NULL); Core.tickerEvent = time_addEvent(po_is("SelectedHurry") ? 0x1f4 : 0x3e8, 1, 0, Core_OnTickerEvent, NULL); MainUI_new(); MainUI_UpdateCoins(); MainUI_UpdateKills(); MainUI_UpdatePlayerLevel(); Player_setupFactory(); MainUI_ShowWeaponBlocks(6 - (int)po_num("SelectedMaxWeapons")); ContainmentRect_init(&Core.containmentRect_Exact, 1, 1); ContainmentRect_init(&Core.containmentRect_Screen, 1.2f, 1.3f); Core.PfxEmitter_Pickups = particles_add(); // SpawnPickupParticlesAt: scintille dei pickup a terra particles_createEmitter(Core.PfxEmitter_Pickups, (EmitterConfig){ .frames = { frame_get("vfx", "PfxColor1.png"), frame_get("vfx", "PfxColor2.png") }, .nframes = 2, .angle = ERND(0, 0xb4), .speed = ERND(0x19, 0x32), .quantity = 0xa, .lifespan = ERND(0x64, 0x190), .alpha = ERANGE(1, 0), .scale = ERANGE(2 * PixelScale, PixelScale), .gravityY = -0x3e8, .on = 0 }); if (po_is("SelectedGoldenEggs")) EggManager_ApplyBonuses(); Player_applyPowerups(); Core.Stage = Stage_new(po_str("SelectedStage")); Stage_Init(Core.Stage); Core.MaxDestructibles = Core.Stage->maxDestructibles; if (!strcmp(po_str("SelectedStage"), "SINKING") || po_has("CollectedItems", "RELIC_GLASSMASK")) Stage_SpawnMerchant(Core.Stage); // MainScene: CurrentBGM = stage.BGM; SetupAndPlayBGM_Normal: la musica del personaggio, se ce l'ha (niente Hyper, Foresta senza BGM_detune) const char *bgm = str(cJSON_GetArrayItem(Core.Player->data, 0), "bgm"); if (!bgm) bgm = str(cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("stages"), Core.Stage->stageType), 0), "BGM"); if (po_has("CollectedItems", "RELIC_BANGER")) Sound_SetupAndPlayBGM_Banger(1); // la musica scelta nella selezione dello stage else if (bgm) Sound_PlayMusic(bgm, 0.3f, 1); Sound_Preload(); Player_addStartingWeapons(); if (RandomazzoEnabled()) Core.GiveMainArcana = 1; // MainScene.create: HasRandomazzoEnabled if (getenv("VS_ARCANADRAFT")) Core.GiveDraftArcana = 1; // sviluppo: debug_ArcanaDraft for (const char *a = getenv("VS_ARCANA"); a && *a;) { // sviluppo: VS_ARCANA="5,16" attiva le arcane (indici di arcana.json, T05_CRASH ...) Arcanas_Add(atoi(a)); a = strchr(a, ','); if (a) a++; } Player_addDevWeapons(); if (getenv("VS_EVENT")) { // sviluppo: VS_EVENT=TIPO[,moreX[,moreY[,moreZ]]] scatena l'evento subito (MEDUSA_WALL,12,MEDUSA1_FAST) static char ev[128]; snprintf(ev, sizeof(ev), "%s", getenv("VS_EVENT")); char *f[4] = { ev, NULL, NULL, NULL }; for (int i = 1; i < 4 && f[i - 1] && (f[i] = strchr(f[i - 1], ',')); i++) *f[i]++ = 0; TriggerSwitchEvent(f[0], 0, 0, f[1] ? atof(f[1]) : 0, f[2], f[3] ? atof(f[3]) : 0, f[2] ? atof(f[2]) : 0); } const char *drop = getenv("VS_DROP"); // sviluppo: VS_DROP="ROSARY,ROAST" oggetti in colonna sopra il giocatore static char drops[8][24]; for (int n = 0; drop && *drop && n < 8; n++) { const char *e = strchr(drop, ','); snprintf(drops[n], sizeof(drops[n]), "%.*s", e ? (int)(e - drop) : (int)strlen(drop), drop); Core_MakePickup(Core.Player->s.x, Core.Player->s.y - 0x28 - 0x20 * n, drops[n]); drop = e ? e + 1 : ""; } const char *boss = getenv("VS_BOSS"); // sviluppo: VS_BOSS="BOSS_WEREWOLF,BOSS_XLFLOWER" nemici in fila a destra del giocatore static char bosses[8][24]; for (int n = 0; boss && *boss && n < 8; n++) { const char *e = strchr(boss, ','); snprintf(bosses[n], sizeof(bosses[n]), "%.*s", e ? (int)(e - boss) : (int)strlen(boss), boss); EnemyPool *p = StageEvent_pool(Core.Stage, bosses[n]); if (p) EnemyPool_SpawnAt(p, Core.Player->s.x + 0x50 + 0x46 * n, Core.Player->s.y); boss = e ? e + 1 : ""; } if (getenv("VS_STAGEPICKUP") && Core.n_StagePickups) { // sviluppo: il primo pickup dello stage 80 px sopra il giocatore Pickup *sp = Core.StagePickups[0]; sp->s.x = Core.Player->s.x, sp->s.y = Core.Player->s.y - 0x50; WeaponPickup_OnRecycle(sp); TraceLog(LOG_INFO, "VS_STAGEPICKUP: %d pickup dello stage, il primo e' %s", Core.n_StagePickups, sp->weaponType); } if (getenv("VS_BRAZIER")) { // sviluppo: un braciere 50 px a destra (dove colpisce la frusta) const char *bt = getenv("VS_BRAZIER"); // VS_BRAZIER=1: quello dello stage; VS_BRAZIER=WINDOW: quel tipo Destructible *d = Core_MakeDestructible(strcmp(bt, "1") ? bt : Core.Stage->destructibleType); if (d) d->s.x = Core.Player->s.x + 0x32, d->s.y = Core.Player->s.y + 0x10; } if (getenv("VS_LIGHTS")) Core_debug_destructibles(1); // sviluppo: il cerchio di fonti di luce di Greatest Jubilee if (getenv("VS_LEVEL")) Core.Player->level = atoi(getenv("VS_LEVEL")), Core.Player->xp = Core.currentXPfactor; // sviluppo: VS_LEVEL=79 sale subito all'80 (morph di Cavallo) if (getenv("VS_LUSTATS")) sscanf(getenv("VS_LUSTATS"), "%f,%f,%f", &Core.Player->rerolls, &Core.Player->skips, &Core.Player->banish); // sviluppo: reroll,skip,banish if (getenv("VS_XP")) Core.Player->xp = atof(getenv("VS_XP")); // sviluppo: esperienza iniziale, piu' level-up di fila if (getenv("VS_POS")) { // sviluppo: VS_POS=x,y sposta il giocatore (in fondo a Gallo Tower: VS_POS=900,80000) const char *v = getenv("VS_POS"), *c = strchr(v, ','); Core.Player->s.x = atof(v), Core.Player->s.y = c ? atof(c + 1) : Core.Player->s.y; if (Core.Stage->tilingTileset) TilingTileset_recenter(Core.Stage->tilingTileset); // le copie della mappa attorno al giocatore } if (getenv("VS_SECONDS")) Core.SurvivedSeconds = atoi(getenv("VS_SECONDS")); // sviluppo: VS_SECONDS=59 parte a un passo dal minuto 1 if (getenv("VS_CURSE")) Core.Player->curse += (float)atof(getenv("VS_CURSE")); // sviluppo: 0.5 = Maledizione al massimo nel negozio if (getenv("VS_GAFILL")) { // sviluppo: i tipi di nemico che Green Acres accumula nei minuti saltati con VS_SECONDS static const char *const V[5] = { "FOREST", "LIBRARY", "WAREHOUSE", "TOWER", "CHAPEL" }; for (int i = 0; i < 5; i++) if (!po_has("UnlockedStages", V[i])) po_push("UnlockedStages", V[i]); Stage *st = Core.Stage; cJSON *keep = st->enemies, *it; for (int m = 1; m <= atoi(getenv("VS_GAFILL")); m++) cJSON_ArrayForEach(it, cJSON_GetObjectItem(data_get("stages"), Stage_RandomMinuteStage(st))) if ((int)num(it, "minute", -1) == m) { if (has(it, "enemies")) st->enemies = cJSON_GetObjectItem(it, "enemies"), Stage_updateEnemyPools(st); break; } st->enemies = keep, Stage_updateEnemyPools(st); } const char *opn = getenv("VS_OPEN"); // sviluppo: VS_OPEN=shop|healer|arcana|item= apre subito quella scena if (opn && !strcmp(opn, "shop")) Core.StartShopScene = 1; if (opn && !strcmp(opn, "healer")) Core.StartHealerScene = 1; if (opn && !strcmp(opn, "arcana")) Core.GiveMainArcana = 1; if (opn && !strncmp(opn, "item=", 5)) Core.FoundWeaponQueue[Core.n_FoundWeaponQueue++] = opn + 5; if (getenv("VS_CHEST")) // sviluppo: VS_CHEST=1..3 forziere (dati del minuto 1) sotto il giocatore Core_MakeTreasure(Core.Player->s.x, Core.Player->s.y, cJSON_GetObjectItem(cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("stages"), "FOREST"), 1), "treasure"), atoi(getenv("VS_CHEST"))); Foscari_AfterFullInit(Core.Player); if (getenv("VS_FOSC")) time_addEvent(0xbb8, 0, 0, Foscari_dev, NULL); // sviluppo: VS_FOSC=|breath|revive a 3 s if (Player_is(Core.Player, "SYUUTO")) { // 0xbc52: la Night Sword nascosta spara solo per ritorsione Weapon *ns = Core_GetHiddenWeapon("NIGHTSWORD"); if (ns) W_NightSword_SetAsRetaliatoryOnly(ns), ns->skipAddingEvolution = 1; } LootManager_Init(); // Player.AfterFullInitialization, LootManager.Init + RecalculateLoot LootManager_RecalculateLoot(); BGMan_MakeBackground(Core.Stage->BGTextureName, Core.Stage); Lights.on = 0; if (Core.Stage->hasLights) Lights_Init(Core.Stage->maxDestructibles); if (Core.Stage->fancyBG && Core.Stage->fancyBG->OnInitCompleted) Core.Stage->fancyBG->OnInitCompleted(); MainUI_UpdatePlayerLevel(); // dopo AfterFullInitialization PlayerUI_Update(); G_humbugOn = tflag == 7, G_petOn = Player_is(Core.Player, "TATANKA"), G_hasP = 0, G_humbug.index = G_pet.index = 0; // le combinazioni della MainScene SpellsManager_ActivateSpells(); // in fondo a MainScene.create } static void SceneManager_EnterPause(void); static void CharFoundScene_open(void); static void ShopScene_open(void); static void HealerScene_open(void), DirecterScene_open(void); static void Core_Update(float delta) { int tick = 0; if (Core.updateTick++, Core.updateTick % Core.updateFreq == 0) { Core.updateTick = 0; tick = 1; } if (tick) { game_context_set(Pickup_owner); if (Core.canInterrupt && Core.canPause && Core.enterPause) { Core.enterPause = 0; SceneManager_EnterPause(); } else if (Core.canInterrupt && Core.EnterWeaponSelection) { // dopo enterPause, prima di negozio, arcane e level-up Core.EnterWeaponSelection = 0; WeaponSelectScene_open(); } else if (Core.canInterrupt && Core.StartShopScene) { Core.StartShopScene = 0; ShopScene_open(); // SceneManager.EnterShop } else if (Core.canInterrupt && Core.StartDirecterScene) { Core.StartDirecterScene = 0; DirecterScene_open(); // SceneManager.EnterDirecter } else if (Core.canInterrupt && Core.StartHealerScene) { Core.StartHealerScene = 0; HealerScene_open(); // SceneManager.EnterHealer } else if (Core.canInterrupt && Core.GiveMainArcana) { Core.GiveMainArcana = 0; if (Arcana_unlockedCount() > Arcanas.n) ARC_open(0); } else if (Core.canInterrupt && Core.GiveDraftArcana) { Core.GiveDraftArcana = 0; if (Arcana_unlockedCount() > Arcanas.n) ARC_open(1); } else if (Core.canInterrupt && Players_n > 1 && Slots[1].player->level < Slots[0].player->level) { // l'esperienza e' comune: ognuno sceglie il suo, uno dopo l'altro game_context_set(1); Player_LevelUp(Core.Player); Core_SwapToLevelUpScene(); PlayerUI_Update(); } else if (Core.canInterrupt && (game_context_set(0), Core.Player->xp >= Core.currentXPfactor)) { if (Players_n > 1) Players_reviveAtLevelUp(), game_context_set(0); Player_LevelUp(Core.Player); Core_SwapToLevelUpScene(); LootManager_RecalculateLoot(); LevelUpFactory_CalculateXPfactor(); PlayerUI_Update(); MainUI_UpdatePlayerLevel(); } else if (Core.canInterrupt && Core.n_TreasureQueue > 0) { // TreasureQueue.pop -> StartTreasureScene Core.n_TreasureQueue--; Core.CurrentTreasureLevel = Core.TreasureQueue[Core.n_TreasureQueue].level; Core.CurrentTreasureTypes = Core.TreasureQueue[Core.n_TreasureQueue].types; Core.CurrentFixedTreasures = Core.TreasureQueue[Core.n_TreasureQueue].fixed; TreasureScene_open(); } else if (Core.canInterrupt && Core.n_RelicQueue > 0) { // RelicQueue.pop -> SwapToRelicFoundScene Core.CurrentFoundRelic = Core.RelicQueue[--Core.n_RelicQueue]; RelicFoundScene_open(); } else if (Core.canInterrupt && Core.n_FoundWeaponQueue > 0) { // FoundWeaponQueue.pop Core.CurrentFoundItem = Core.FoundWeaponQueue[--Core.n_FoundWeaponQueue]; ItemFoundScene_open(); } else if (Core.canInterrupt && Core.n_CharQueue > 0) { // CharQueue.pop, poi la coda si svuota Core.CurrentFoundChar = Core.CharQueue[--Core.n_CharQueue]; Core.n_CharQueue = 0; CharFoundScene_open(); } Scene_owner = game_context; game_context_set(0); if (Core.Stage->dayNight) BGMan_DayNightHue(); for (int i = 0; i < Core.PickupGroup.n; i++) { Pickup *pk = Core.PickupGroup.items[i]->owner; game_context_set(Players_n > 1 ? pk->player : 0); Pickup_Update(pk); } game_context_set(0); for (int i = 0; i < Core.explosionPool.nspawned; i++) EnemyExplosion_Update(Core.explosionPool.spawned[i]); } else if (Core.canPause && Core.enterPause) { Core.enterPause = 0; SceneManager_EnterPause(); } for (int i = 0; i < Core.BulletGroup.n; i++) { // BulletGroup.children.entries[i].Update(delta) Bullet *b = Core.BulletGroup.items[i]->owner; if (Players_n > 1 && b->weapon) game_context_set(b->weapon->player); if (b->vt->Update) b->vt->Update(b, delta); } for (int pi = 0; pi < Players_n; pi++) { game_context_set(pi); if (Players_n > 1 && Core.Player->isDead) continue; for (int i = 0; i < Core.n_weapons; i++) Core.Weapons[i]->vt->Update(Core.Weapons[i], delta); for (int i = Core.n_HiddenWeapons - 1; i >= 0; i--) Core.HiddenWeapons[i]->vt->Update(Core.HiddenWeapons[i], delta); Player_Update(Core.Player, delta); Magnet_Update(Core.Magnet); } game_context_set(0); BGMan_Update(); GoldFever_Update(delta); WhiteHand_Update(); // dopo Arcanas.Update Arcanas_Update(delta); GizmoManager_Update(); Enemies_delta = delta; for (int i = 0; i < Core.Enemies.n; i++) { Enemy *e = Core.Enemies.items[i]->owner; if (Players_n > 1) { // ogni nemico insegue il giocatore piu' vicino Sprite *a = &Slots[0].player->s, *b = &Slots[1].player->s; float da = (e->s.x - a->x) * (e->s.x - a->x) + (e->s.y - a->y) * (e->s.y - a->y), db = (e->s.x - b->x) * (e->s.x - b->x) + (e->s.y - b->y) * (e->s.y - b->y); int pick = Slots[1].player->isDead ? 0 : Slots[0].player->isDead ? 1 : db < da; game_context_set(pick); if (e->target == a || e->target == b) e->target = &Core.Player->s; } Enemy_Update(e); } game_context_set(0); if (Lights.on) Lights.lights[0].x = Core.Player->s.x, Lights.lights[0].y = Core.Player->s.y; // Stage.hasLights: lo spotlight segue il giocatore } // ============================================================================ // 0x11c10: UI_levelUpScene + 0x15db6: pannello arma + ParseLevelUpInfo // Gira alla risoluzione da menu (ApplyMenuResolution = initialWidth x initialHeight) // ============================================================================ #define MENU_W 960 #define MENU_H 544 #define SAFE_W 512.0f // SAFEAREA.width = DEFAULT_WIDTH #define DEFAULT_H 580.0f // Vita: le finestre alte 0.8 x DEFAULT_H (464) stanno fra la barra XP e la barra dei tasti // Lang.getLang con un parametro: sostituisce %0 static const char *lang1(const char *key, const char *a0) { static char buf[4][256]; static int k; char *o = buf[k++ & 3]; const char *s = tr(key), *p = strstr(s, "%0"); if (!p) { snprintf(o, 256, "%s", s); return o; } snprintf(o, 256, "%.*s%s%s", (int)(p - s), s, a0, p + 2); return o; } static const char *fix(float v, int d) { // Number.toFixed: a parita' l'intero piu' grande (0.5 -> "1"), printf arrotonda al pari static char b[8][32]; static int k; char *o = b[k++ & 7]; double p = pow(10, d), a = floor(fabs((double)v) * p + 0.5) / p; snprintf(o, 32, "%.*f", d, v < 0 ? -a : a); return o; } // LevelUpPanel.ParseLevelUpInfo static void ParseLevelUpInfo(cJSON *lv, int all, char *out, size_t cap) { out[0] = 0; for (cJSON *it = lv ? lv->child : NULL; it; it = it->next) { const char *k = it->string; float V = (float)it->valuedouble; char add[256] = ""; const char *A = all ? tr("weaponLevelUp_all") : ""; if (!strcmp(k, "power")) snprintf(add, sizeof(add), "%s", all ? lang1("weaponLevelUp_damageAll", fix(100 * V, 0)) : lang1("weaponLevelUp_damage", fix(10 * V, 0))); else if (!strcmp(k, "area")) snprintf(add, sizeof(add), "%s%s", A, lang1("weaponLevelUp_area", fix(100 * V, 0))); else if (!strcmp(k, "speed")) snprintf(add, sizeof(add), "%s%s", A, lang1("weaponLevelUp_speed", fix(100 * V, 0))); else if (!strcmp(k, "amount")) snprintf(add, sizeof(add), "%s%s", A, (int)V > 1 ? lang1("weaponLevelUp_projectiles", fix(V, 0)) : lang1("weaponLevelUp_projectile", fix(V, 0))); else if (!strcmp(k, "penetrating")) snprintf(add, sizeof(add), "%s%s", A, (int)V > 1 ? lang1("weaponLevelUp_enemies", fix(V, 0)) : lang1("weaponLevelUp_enemy", fix(V, 0))); else if (!strcmp(k, "charges")) snprintf(add, sizeof(add), "%s", (int)V > 1 ? lang1("weaponLevelUp_charges", fix(V, 0)) : lang1("weaponLevelUp_charge", fix(V, 0))); else if (!strcmp(k, "duration")) snprintf(add, sizeof(add), "%s", all ? lang1("weaponLevelUp_effectPerc", fix(100 * V, 0)) : lang1("weaponLevelUp_effect", fix(0.001f * V, 1))); else if (!strcmp(k, "cooldown")) snprintf(add, sizeof(add), "%s%s", A, lang1("weaponLevelUp_cooldownPerc", fix(-100 * V, 1))); else if (!strcmp(k, "interval")) snprintf(add, sizeof(add), "%s%s", A, V < 0 ? lang1("weaponLevelUp_cooldown", fix(-0.001f * V, 1)) : lang1("weaponLevelUp_cooldownIncreased", fix(0.001f * V, 1))); else if (!strcmp(k, "maxHp")) snprintf(add, sizeof(add), "%s", lang1("weaponLevelUp_health", fix(100 * V, 0))); else if (!strcmp(k, "growth")) snprintf(add, sizeof(add), "%s", V < 0 ? lang1("weaponLevelUp_xpDecreased", fix(100 * V, 0)) : lang1("weaponLevelUp_xp", fix(100 * V, 0))); else if (!strcmp(k, "moveSpeed")) snprintf(add, sizeof(add), "%s", lang1("weaponLevelUp_movement", fix(100 * V, 0))); else if (!strcmp(k, "magnet")) snprintf(add, sizeof(add), "%s", lang1("weaponLevelUp_range", fix(100 * V, 0))); else if (!strcmp(k, "luck")) snprintf(add, sizeof(add), "%s", lang1("weaponLevelUp_luck", fix(100 * V, 0))); else if (!strcmp(k, "regen")) snprintf(add, sizeof(add), "%s", lang1("weaponLevelUp_recovery", fix(V, 1))); else if (!strcmp(k, "greed")) snprintf(add, sizeof(add), "%s", lang1("weaponLevelUp_value", fix(100 * V, 0))); else if (!strcmp(k, "armor")) snprintf(add, sizeof(add), "%s", lang1("weaponLevelUp_reduceDamage", fix(V, (V == (int)V) ? 0 : 1))); else if (!strcmp(k, "shieldInvulTime")) snprintf(add, sizeof(add), "%s", lang1("weaponLevelUp_shield", fix(0.001f * V, 1))); else if (!strcmp(k, "revivals")) snprintf(add, sizeof(add), "%s", lang1("weaponLevelUp_revivals", fix(V, 0))); else if (!strcmp(k, "curse")) snprintf(add, sizeof(add), "%s", lang1("weaponLevelUp_curse", fix(100 * V, 0))); else if (!strcmp(k, "desc") && cJSON_IsString(it)) snprintf(add, sizeof(add), "%s\n", it->valuestring); else if (!strcmp(k, "override") && cJSON_IsString(it)) { snprintf(out, cap, "%s\n", it->valuestring); continue; } // customDesc / customOverride: armi speciali non ancora tradotte strncat(out, add, cap - strlen(out) - 1); } } static void Player_SetInvulForMilliSecondsNonCumulative(Player *p, float ms) { Player_setIsInvul(p, 1); if (p->invulTime < ms) p->invulTime = ms; } static float text_wrap(const char *s, Vector2 p, float size, float wrap, Color c) { // y dell'ultima riga; c.a 0 = misura e basta char line[256] = ""; float y = p.y; const char *w = s; while (*w) { const char *e = w; while (*e && *e != ' ' && *e != '\n') e++; char cand[256]; snprintf(cand, sizeof(cand), "%s%s%.*s", line, *line ? " " : "", (int)(e - w), w); if (MeasureTextEx(vs_font, cand, size, 1).x > wrap && *line) { if (c.a) DrawTextEx(vs_font, line, (Vector2){ p.x, y }, size, 1, c); y += size * 1.15f; snprintf(line, sizeof(line), "%.*s", (int)(e - w), w); } else { snprintf(line, sizeof(line), "%s", cand); } if (*e == '\n') { if (c.a) DrawTextEx(vs_font, line, (Vector2){ p.x, y }, size, 1, c); y += size * 1.15f; line[0] = 0; } w = *e ? e + 1 : e; } if (*line && c.a) DrawTextEx(vs_font, line, (Vector2){ p.x, y }, size, 1, c); return y; } static void TS_frame(const char *atlas, const char *name, float x, float y, float ox, float oy, float sc, float ang, Color c, int add); // LevelUpWeaponPanel.ParseLimitBreakUpInfo static void ParseLimitBreakUpInfo(cJSON *kv, char *out, size_t cap) { out[0] = 0; for (cJSON *it = kv ? kv->child : NULL; it; it = it->next) { const char *k = it->string; float V = (float)it->valuedouble; char add[256] = ""; if (!strcmp(k, "power")) snprintf(add, sizeof(add), "%s", lang1("limitBreak_might", fix(10 * V, 0))); else if (!strcmp(k, "area")) snprintf(add, sizeof(add), "%s", lang1("limitBreak_area", fix(100 * V, 0))); else if (!strcmp(k, "speed")) snprintf(add, sizeof(add), "%s", lang1("limitBreak_speed", fix(100 * V, 0))); else if (!strcmp(k, "amount")) snprintf(add, sizeof(add), "%s", lang1("limitBreak_amount", fix(V, 0))); else if (!strcmp(k, "penetrating")) snprintf(add, sizeof(add), "%s", lang1("limitBreak_passes", fix(V, 0))); else if (!strcmp(k, "duration")) snprintf(add, sizeof(add), "%s", lang1("limitBreak_duration", fix(V, 0))); else if (!strcmp(k, "cooldown")) snprintf(add, sizeof(add), "%s", lang1("limitBreak_cooldown", fix(-100 * V, 1))); else if (!strcmp(k, "critChance")) snprintf(add, sizeof(add), "%s", lang1("limitBreak_critical", fix(100 * V, 1))); else if (!strcmp(k, "chance")) snprintf(add, sizeof(add), "%s", lang1("limitBreak_chance", fix(100 * V, 1))); else if (!strcmp(k, "desc") && cJSON_IsString(it)) snprintf(add, sizeof(add), "%s\n", it->valuestring); else if (!strcmp(k, "override") && cJSON_IsString(it)) { snprintf(out, cap, "%s\n", it->valuestring); continue; } strncat(out, add, cap - strlen(out) - 1); } } // 0x15db6: il pannello di un'arma (level-up e oggetto trovato); lb: AssignLimitBreakData static float fit_size(const char *s, float size, float maxW); static void ui_arrows(float x, float y, float halfW, float t); static float ui_wrap_text(const char *s, float x, float y, float size, float wrapW, float maxH, Color c, int draw); static void LevelUpPanel_drawEx(const char *type, cJSON *lb, int hideIcon, float px, float py, float pw, float ph) { cJSON *wd = cJSON_GetObjectItem(data_get("weapons"), type), *base = cJSON_GetArrayItem(wd, 0); Color tint = cJSON_IsTrue(cJSON_GetObjectItem(base, "isEvolution")) ? YELLOW : WHITE; nine("frame1_c2.png", 12, (Rectangle){ px, py, pw, ph }, tint); const Frame *ib = frame_get("UI", "frameB.png"); if (ib) DrawTexturePro(*ib->tex, (Rectangle){ ib->x, ib->y, ib->w, ib->h }, (Rectangle){ px + 4, py + 4, ib->w * 2, ib->h * 2 }, (Vector2){ 0, 0 }, 0, WHITE); const Frame *ic = hideIcon ? NULL : frame_get(str(base, "texture"), str(base, "frameName")); if (ic) DrawTexturePro(*ic->tex, (Rectangle){ ic->x, ic->y, ic->w, ic->h }, (Rectangle){ px + 0x1c - ic->sw + 2 * ic->ox, py + 0x1c - ic->sh + 2 * ic->oy, ic->w * 2, ic->h * 2 }, (Vector2){ 0, 0 }, 0, WHITE); const char *name = tr_of("weaponLang", type, "name"); DrawTextEx(vs_font, *name ? name : str(base, "name"), (Vector2){ px + 0x46, py + 6 }, fit_size(*name ? name : str(base, "name"), 24, 0.62f * pw - 0x46), 1, WHITE); // Vita: 24 px Weapon *have = Core_GetWeapon(type); int lvl = have ? have->level : 0; // Core.GetWeaponLevel float evo = 0.7f * pw; // evoIconsOffset char desc[512]; cJSON *into = cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("weapons"), str(base, "evoInto") ? str(base, "evoInto") : ""), 0), *syn; if (!have && into && cJSON_IsTrue(cJSON_GetObjectItem(into, "seen"))) { // evoSynergy: le armi con cui si evolve, se le hai (solo armi nuove) int i = 0, shown = 0; cJSON_ArrayForEach(syn, cJSON_GetObjectItem(base, "evoSynergy")) { cJSON *sd = tbl0("weapons", cJSON_GetStringValue(syn)); if (Core_GetWeapon(cJSON_GetStringValue(syn)) && sd && cJSON_IsTrue(cJSON_GetObjectItem(sd, "seen"))) TS_frame(str(sd, "texture"), str(sd, "frameName"), px + evo + 0x2a + 0x10 * i, py + 0x1c, 0, 0, 1, 0, WHITE, 0), shown = 1; i++; } if (shown) DrawTextEx(vs_font, "evo: ", (Vector2){ px + evo, py + 0x1c }, 16, 1, ORANGE); } if (lb) { DrawTextEx(vs_font, TextFormat("%s%d", tr("weapon_limit_break_"), have->limitBreakLevel + have->level + 1), (Vector2){ px + evo, py + 6 }, 16, 1, WHITE); ParseLimitBreakUpInfo(lb, desc, sizeof(desc)); } else if (lvl > 0) { char nl[64]; snprintf(nl, sizeof(nl), "%s%d", tr("weapon_level_"), lvl + 1); DrawTextEx(vs_font, nl, (Vector2){ px + 0.7f * pw, py + 8 }, 20, 1, WHITE); ParseLevelUpInfo(cJSON_GetArrayItem(wd, lvl), cJSON_IsTrue(cJSON_GetObjectItem(base, "isPowerUp")), desc, sizeof(desc)); } else { DrawTextEx(vs_font, tr("weapon_new"), (Vector2){ px + 0.7f * pw, py + 8 }, 20, 1, YELLOW); const char *d = tr_of("weaponLang", type, "description"); snprintf(desc, sizeof(desc), "%s", *d ? d : str(base, "description")); } ui_wrap_text(desc, px + 0x46, py + 0x24, 20, pw - 0x50, ph - 0x28, WHITE, 1); // Vita: a destra dell'icona, 20 px } static void LevelUpPanel_draw(const char *type, float px, float py, float pw, float ph) { LevelUpPanel_drawEx(type, NULL, 0, px, py, pw, ph); } // ============================================================================ // 0x12a96: UI_treasureScene (+ 0x15b4a PrizeIcon, 0x16120 popup del premio) // Gira alla risoluzione da menu come il level-up, con nastri (0x7c1), rulli (0xda22), bolle (0x15c2c), // fontane di monete, fuochi del livello 3 e salto con ESC/cerchio (EnableQS). Clock e TweenManager della scena: // TS.ev e TS.tw, perche' quelli del gioco sono fermi con la MainScene in pausa. // ============================================================================ typedef struct { const char *prizeType, *prizeEnum; } PrizePair; typedef struct { float t; void (*fn)(int); int arg, used; } TSEvent; // time.addEvent typedef struct { float *v, from, to, t0, dur; int yoyo, used, started; void (*done)(void); } TSTween; // tweens.add typedef struct { // RibbonTrail (0x7c1): una Rope verticale di 32 punti che segue un PathFollower su una Spline Vector2 sp[11], follower, points[32], positions[32]; int nsp, npos, depth, visible, blendAdd, yoyo, following, reel; // reel: -1 = vfx Ribbon1.png, altrimenti la texture di quel rullo float scale, alpha, tStart, delay, dur; Vector2 pos; Rectangle mask; } TSRibbon; typedef struct { Vector2 p; float rot, tStart; int following; } TSFollower; typedef struct { // TreasureReel (0xda22): due follower con la striscia di icone, uno dietro l'altro unsigned color; float cfgAlpha, alpha, scaleX, tFlash; Vector2 start, end; TSFollower s[2]; int stopped; } TSReel; static struct { int active, level, n_prizes, n_weaponPrizes, hasArcana, SkipFullScene; PrizePair prizes[5]; const char *AccumulatedWeaponPrizes[5]; float CoinsAward, AccumulatedCoinPrize, coinsTotal, quickAddedCoins; float t; // ms dall'apertura della scena float tOpen, tStop, tOk; // ms (t) del clic su "Apri", di StartPrizes e di ShowOKButton; -1 = non ancora float tOkInput, tDismiss; int inputEnabled; // seconda passata TSEvent ev[48]; TSTween tw[48]; int hasSkipped, qsEnabled, qsEvent, qsEvent3A, qsEvent3B, qsSecond, coinsStopEv; // handle degli eventi (indice + 1) float QSCounterDelay, QSSeekTrack; const char *QS_SFX; float counterDur, tCounterEnd; const float *stopDelays; float overlay; int overlayHidden; TSRibbon ribbons[8], ribbons2[2]; int n_ribbons, updateTrail, updateTrail2, ribbonsAfterReels; TSReel reels[5]; int n_reels; ParticleManager *coins[4], *fw; const Frame *coinFrame[4]; float fwUntil[5]; int fwStartFrames; struct { int enabled, t1, t2; float count, gAlpha, bgAlpha; unsigned tint; Vector2 c[15]; float r[15]; } bub; // BubbleVFX Rectangle upperMask, upperFreeMask, bgMask; float chestX, chestY; Vector2 TL, BR; } TS; static RenderTexture2D TSReelRT[5]; // TreasureUtils.MakeTexture_*: la striscia di 12 icone di ogni rullo static int TSReelRT_n; static float fit_size(const char *s, float size, float maxW) { // Lang.scaleToMaxFast(text, false, maxW) while (size > 1 && MeasureTextEx(vs_font, s, size, 0).x > maxW) size -= 1; return size; } static float ease_sine_inout(float k) { return -0.5f * (cosf(PI * k) - 1); } // Sine.easeInOut static float lerp01(float t, float t0, float dur) { return t < t0 ? 0 : t >= t0 + dur ? 1 : (t - t0) / dur; } // MakePrizePairFromAvailablePowerUps static PrizePair TS_MakePrizePair(const char *type, const char *fixed, int isLevel3) { const char *e = NULL, *pt = type; if (!strcmp(type, "RANDOM")) type = frand() < 0.5f ? "POWERUP" : "EXISTING_ANY"; // RND.pick if (!strcmp(type, "POWERUP")) { e = LevelUpFactory_PullRemainingPowerUp(), pt = "POWERUP"; if (!e) e = "COINBAG2", pt = "FILLER"; } else if (!strcmp(type, "EXISTING_WEAPON")) { e = LevelUpFactory_PullExistingRemainingWeapon(0), pt = "EXISTING_WEAPON"; if (!e) { e = LevelUpFactory_PullExistingRemainingWeapon(1), pt = "EXISTING_ANY"; if (!e) e = "COINBAG2", pt = "FILLER"; } } else if (!strcmp(type, "EXISTING_ANY")) { e = LevelUpFactory_PullExistingRemainingWeapon(1), pt = "EXISTING_ANY"; if (!e) e = "COINBAG2", pt = "FILLER"; } else if (!strcmp(type, "EVO_ARCANA") && RandomazzoEnabled() && Arcanas.n < Arcanas.MaxArcanasPerRun && Arcanas.n < Arcana_unlockedCount()) { e = "RELIC_RANDOMAZZO", pt = "ARCANA"; // alla fine della scena: GiveDraftArcana TS.hasArcana = 1; } else if (!strcmp(type, "EVOLUTION") || !strcmp(type, "EVO_ARCANA")) { // ARCANA senza Randomazzo, o arcane al completo: EVOLUTION e = LevelUpFactory_PullEvolution(), pt = "EVOLUTION"; if (!e) { e = LevelUpFactory_PullExistingRemainingWeapon(1), pt = "EXISTING_ANY"; if (!e) e = "COINBAG2", pt = "FILLER"; } } else if (!strcmp(type, "FIXED") && fixed) { e = LevelUpFactory_PullExisting(fixed), pt = "FIXED"; if (!e) { cJSON *fd = cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("weapons"), fixed), 0); if (cJSON_IsTrue(cJSON_GetObjectItem(fd, "isEvolution")) && LevelUpFactory_GetSpecialWeapon(fixed)) e = fixed, pt = "FIXED"; if (!e) { e = LevelUpFactory_PullExistingRemainingWeapon(1), pt = "EXISTING_ANY"; if (!e) e = "COINBAG2", pt = "FILLER"; } } } else { // default / FILLER e = "COINBAG2", pt = "FILLER"; } if (!strcmp(pt, "ARCANA")) { } else if (strcmp(pt, "FILLER")) { if (TS.n_weaponPrizes < 5) TS.AccumulatedWeaponPrizes[TS.n_weaponPrizes++] = e; LevelUpFactory_RemoveFromStore(e); } else if (isLevel3 || frand() <= 0.01f * Player_PLuck(Core.Player)) { int inStore = 0, inSpecial = 0, rem1 = 0, rem2 = 0; for (int i = 0; i < LUF.n_store; i++) inStore |= !strcmp(LUF.WeaponStore[i], "CANDYBOX"); for (int i = 0; i < LUF.n_special; i++) inSpecial |= !strcmp(LUF.SpecialWeapons[i], "CANDYBOX2"); for (int i = 0; i < Core.n_RemovedWeapons; i++) rem1 |= !strcmp(Core.RemovedWeapons[i]->bulletType, "CANDYBOX"), rem2 |= !strcmp(Core.RemovedWeapons[i]->bulletType, "CANDYBOX2"); int cb = inStore && !rem1 && po_has("UnlockedWeapons", "CANDYBOX"), cb2 = inSpecial && !rem2 && po_has("UnlockedWeapons", "CANDYBOX"); if (cb || cb2) { e = cb ? "CANDYBOX" : "CANDYBOX2", pt = "EXISTING_WEAPON"; if (TS.n_weaponPrizes < 5) TS.AccumulatedWeaponPrizes[TS.n_weaponPrizes++] = e; LevelUpFactory_RemoveFromStore(e); if (!cb) LevelUpFactory_RemoveFromSpecialWeapons(e); } else TS.AccumulatedCoinPrize += num(cJSON_GetObjectItem(data_get("items"), "COINBAG2"), "value", 0); } else { TS.AccumulatedCoinPrize += num(cJSON_GetObjectItem(data_get("items"), "COINBAG2"), "value", 0); } return (PrizePair){ pt, e }; } static const char *TS_str_at(cJSON *a, int i) { cJSON *v = cJSON_GetArrayItem(a, i); return cJSON_IsString(v) ? v->valuestring : NULL; } static void TS_MakePrize(int level) { TS.n_prizes = 0; int n = level == 3 ? 5 : level == 2 ? 3 : 1; TS.CoinsAward = level == 3 ? floorf(0x1f4 + 0x1f4 * frand()) : level == 2 ? floorf(0x12c + 0x12c * frand()) : floorf(0x64 + 0x64 * frand()); for (int i = 0; i < n; i++) { const char *t = TS_str_at(Core.CurrentTreasureTypes, i); TS.prizes[TS.n_prizes++] = TS_MakePrizePair(t ? t : "FILLER", TS_str_at(Core.CurrentFixedTreasures, i), level == 3); } } static int TS_CanSkipTreasureLevel3(void) { cJSON *it = data_get("items"); return num(cJSON_GetObjectItem(it, "STATS_TREASURE_3"), "pickedupAmount", 0) >= 0x32 || num(cJSON_GetObjectItem(it, "TREASURE"), "pickedupAmount", 0) >= 0xc8 || po_is("HasSeenFinalFireworks"); } static void Player_SetInvulForMilliSecondsNonCumulative(Player *p, float ms); // QuickSceneOver: i premi si applicano davvero solo qui static void TS_QuickSceneOver(float invul) { for (int i = 0; i < TS.n_weaponPrizes; i++) Core_LevelWeaponUp(TS.AccumulatedWeaponPrizes[i], 0); // AccumulatedItemPrizes: sempre vuoto if (TS.hasArcana) Core.GiveDraftArcana = 1; TS.quickAddedCoins = PlayerOptions_AddCoins(TS.CoinsAward + TS.AccumulatedCoinPrize); MainUI_UpdateCoins(); Player_SetInvulForMilliSeconds(Core.Player, invul); } static void TS_create(void); static void TS_cleanup(void); static void TreasureScene_open(void) { // SceneManager.StartTreasureScene + preload if (Arcanas.minTreasureChestLevel > Core.CurrentTreasureLevel) Core.CurrentTreasureLevel = Arcanas.minTreasureChestLevel; // Game Killer TS_cleanup(); memset(&TS, 0, sizeof(TS)); TS.active = 1; TS.tOpen = TS.tStop = TS.tOk = TS.tOkInput = TS.tDismiss = -1; if (Player_is(Core.Player, "DRAGOGION")) { // 0x5afd GetTreasureModifier: EXISTING_WEAPON / EXISTING_ANY -> EVOLUTION (sui dati, sic) cJSON *t; cJSON_ArrayForEach(t, Core.CurrentTreasureTypes) if (cJSON_IsString(t) && (!strcmp(t->valuestring, "EXISTING_WEAPON") || !strcmp(t->valuestring, "EXISTING_ANY"))) cJSON_SetValuestring(t, "EVOLUTION"); } TS.level = Core.CurrentTreasureLevel; TS_MakePrize(TS.level >= 1 && TS.level <= 3 ? TS.level : 1); float greed = Player_PGreed(Core.Player); TS.coinsTotal = ceilf(TS.CoinsAward * GoldMultiplier * greed); // StartCounter Sound_FadeMusic(0, 0x1f4); // StartTreasureScene if (TS.n_weaponPrizes == 0 && TS_CanSkipTreasureLevel3()) { // forziere vuoto gia' visto molte volte: niente scena TS_QuickSceneOver(0x1f4); TS.active = 0; GizmoManager_DisplayIconOverhead("MoneyBagGreen.png", TextFormat("+%d", (int)roundf(TS.quickAddedCoins)), 0xffff00); GizmoManager_DisplayQuickTreasureChestAnimation(); PlayerOptions_Save(); Sound_FadeMusic(0.3f, 0x1f4); // QuickResumeFromTreasureScene return; } TS_create(); Sound_PlaySimple("ThingFound", 0.7f); // create (ClassicMusic: ThingFound, non ThingFoundB) } static const float StopDelays1[] = { 0 }, StopDelays3[] = { 0x258, 0, 0x12c }; static const float StopDelays5_Default[] = { 0x258, 0x12c, 0x12c, 0, 0 }, StopDelays5_QS[] = { 0, 0x12c, 0x12c, 0x258, 0x258 }; static float TS_openDelay(void) { return TS.level == 3 ? 0x640 : 0; } // il livello 3 apre dopo i fuochi // --- Clock e TweenManager della scena --------------------------------------------------------- static int TS_after(float delay, void (*fn)(int), int arg) { // Delay / time.addEvent: restituisce l'handle (indice + 1) for (int i = 0; i < 48; i++) if (!TS.ev[i].used) { TS.ev[i] = (TSEvent){ TS.t + delay, fn, arg, 1 }; return i + 1; } return 0; } static void TS_cancel(int *h) { if (*h) TS.ev[*h - 1].used = 0, *h = 0; } // TimerEvent.destroy static int TS_tween(float *v, float to, float dur, float delay, int yoyo, void (*done)(void)) { // valore iniziale letto all'avvio for (int i = 0; i < 48; i++) if (!TS.tw[i].used) { TS.tw[i] = (TSTween){ v, 0, to, TS.t + delay, dur, yoyo, 1, 0, done }; return i + 1; } return 0; } static void TS_tweenComplete(int h, float *v) { // Tween.complete: salta alla fine if (!h || !TS.tw[h - 1].used || TS.tw[h - 1].v != v) return; TS.tw[h - 1].used = 0; *v = TS.tw[h - 1].to; } static void TS_tweensUpdate(void) { for (int i = 0; i < 48; i++) { TSTween *w = &TS.tw[i]; if (!w->used || TS.t < w->t0) continue; if (!w->started) w->started = 1, w->from = *w->v; float k = w->dur > 0 ? (TS.t - w->t0) / w->dur : 2; int end = k >= (w->yoyo ? 2 : 1); float e = end ? (w->yoyo ? 0 : 1) : k <= 1 ? k : 2 - k; *w->v = w->from + (w->to - w->from) * e; if (end) { w->used = 0; if (w->done) w->done(); } } } // --- 0x15c2c BubbleVFX ------------------------------------------------------------------------ static float Between(float lo, float hi) { return floorf(frand() * (hi - lo + 1)) + lo; } // Phaser.Math.Between static float WrapF(float v, float lo, float hi) { float r = hi - lo; return lo + fmodf(fmodf(v - lo, r) + r, r); } static void TS_bubblesShow(float dur, unsigned color) { TS.bub.enabled = 1; TS.bub.tint = color; TS.bub.t1 = TS_tween(&TS.bub.gAlpha, 1, 0x12c, 0, 0, NULL); TS.bub.t2 = TS_tween(&TS.bub.bgAlpha, 1, dur, 0, 0, NULL); } static void TS_bubblesOff(void) { TS.bub.enabled = 0; } static void TS_bubblesHide(float dur) { TS_tweenComplete(TS.bub.t1, &TS.bub.gAlpha); TS_tweenComplete(TS.bub.t2, &TS.bub.bgAlpha); TS_tween(&TS.bub.gAlpha, 0, 0x12c, 0, 0, NULL); TS_tween(&TS.bub.bgAlpha, 0, dur, 0, 0, TS_bubblesOff); } static void TS_bubblesUpdate(void) { // Update: a ogni frame, non a tempo if (!TS.bub.enabled) return; TS.bub.count += 0.001f; for (int i = 0; i < 15; i++) TS.bub.c[i].y -= 0xa * TS.bub.count + 1 * i; for (int i = 0; i < 15; i++) // Actions.WrapInRectangle(shapes, camera, 72) TS.bub.c[i].x = WrapF(TS.bub.c[i].x, -0x48, MENU_W + 0x48), TS.bub.c[i].y = WrapF(TS.bub.c[i].y, -0x48, MENU_H + 0x48); } // --- 0x7c1 RibbonTrail ------------------------------------------------------------------------ static float CatmullRom(float t, float p0, float p1, float p2, float p3) { float v0 = (p2 - p0) * 0.5f, v1 = (p3 - p1) * 0.5f, t2 = t * t, t3 = t * t2; return (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1; } static Vector2 Spline_getPoint(const Vector2 *p, int n, float t) { // Curves.Spline.getPoint float point = (n - 1) * t, w; int ip = (int)floorf(point); w = point - ip; const Vector2 *p0 = &p[ip == 0 ? ip : ip - 1], *p1 = &p[ip], *p2 = &p[ip > n - 2 ? n - 1 : ip + 1], *p3 = &p[ip > n - 3 ? n - 1 : ip + 2]; return (Vector2){ CatmullRom(w, p0->x, p1->x, p2->x, p3->x), CatmullRom(w, p0->y, p1->y, p2->y, p3->y) }; } static void RotateVectorByDegrees(Vector2 *v, float deg, Vector2 *out) { // TreasureUtils (0x10f8b) float a = deg * (PI / 180); out->x = v->x * cosf(a) - v->y * sinf(a); out->y = v->x * sinf(a) + v->y * cosf(a); // con out == v usa la x gia' ruotata, come l'originale } static float RND_pickf(const float *a, int n) { return a[(int)floorf(frand() * n)]; } // MakeRibbons(n, x, y, duration, _, delay) static void TS_MakeRibbons(int n, float x, float y, float dur, float delay) { static const float SP[20] = { 0, 0, 0, 0, 0x1c, -0x29, -0x17, -0x51, 0x1f, -0x8f, -0x21, -0xbd, -0x60, -0x9e, -0x51, -0x5f, 0x13, -0x49, 0x9d, -0xa9 }; static const float Scales[7] = { 1, 1.1f, 1.2f, 1.3f, 0.9f, 0.8f, 0.7f }, Depths[3] = { 7, 8, 9 }, Rot[2] = { 0xa, -0xa }; TS.n_ribbons = n; for (int i = 0; i < n; i++) { TSRibbon *r = &TS.ribbons[i]; *r = (TSRibbon){ 0 }; r->nsp = 10; for (int k = 0; k < 10; k++) { Vector2 *q = &r->sp[k]; q->x = SP[2 * k], q->y = SP[2 * k + 1]; q->x += 0x18 * (frand() - 0.5f), q->x *= 4, q->y *= 4; } if (i % 2 == 0) for (int k = 0; k < 10; k++) r->sp[k].x *= -1; if (frand() > 0.5f) { for (int k = 0; k < 10; k++) RotateVectorByDegrees(&r->sp[k], RND_pickf(Rot, 2), &r->sp[k]); // un RND.pick per punto } r->dur = dur, r->yoyo = 1, r->delay = delay * i; // followerConfig: yoyo, repeat -1, Sine.easeInOut RND_pickf(Scales, 7); // setScale(RND.pick(...)) poi setScale(0.5) r->depth = (int)RND_pickf(Depths, 3); r->scale = 0.5f, r->alpha = 1, r->blendAdd = 1, r->reel = -1; r->pos = (Vector2){ x, y }; r->mask = TS.upperFreeMask; // resetPoints(0, 0): punti, follower e scia a (0, 0) } } static void TS_MakeRibbonsLevel3(void) { static const float SP[14] = { 0, 0, 0x1c, -0xc, 0xb1, -0x45, 0x39, -0x69, -0x5a, -0x7c, 0x4c, -0xc7, 0x33, -0xf3 }; for (int i = 0; i < 2; i++) { TSRibbon *r = &TS.ribbons2[i]; *r = (TSRibbon){ 0 }; float k = (TS.BR.y - TS.TL.y) / 0xf3 / 2; r->nsp = 8; for (int j = 0; j < 7; j++) r->sp[j] = (Vector2){ SP[2 * j] * k, SP[2 * j + 1] * k }; r->sp[7] = (Vector2){ (TS.chestX - TS.TL.x) / 2, (TS.chestY - TS.BR.y - 0x32) / 2 }; if (i % 2 == 1) for (int j = 0; j < 8; j++) r->sp[j].x *= -1; r->dur = 0x5dc; // Sine.easeInOut, una volta sola r->reel = 3; // TextureNames[6]: la texture del quarto rullo r->depth = 0xd, r->scale = 2, r->alpha = 1; r->pos = (Vector2){ i % 2 == 0 ? TS.TL.x : TS.BR.x, TS.BR.y }; r->mask = TS.bgMask; } } static void TS_StartRibbons(void) { TS.updateTrail = 1; for (int i = 0; i < TS.n_ribbons; i++) TS.ribbons[i].visible = 1, TS.ribbons[i].following = 1, TS.ribbons[i].tStart = TS.t; } static void TS_StopRibbons(void) { float mx = 0; int n = TS.n_prizes == 5 ? 5 : TS.n_prizes == 3 ? 3 : 1; for (int i = 0; i < n; i++) mx = fmaxf(mx, TS.stopDelays[i]); for (int i = 0; i < TS.n_ribbons; i++) TS_tween(&TS.ribbons[i].alpha, 0, 0x64, (float)i / TS.n_ribbons * mx, 0, NULL); } static void TS_ribbonFollow(TSRibbon *r) { // PathFollower.pathUpdate: in attesa (delay) resta fermo float local = TS.t - r->tStart - r->delay; if (!r->following || local < 0) return; float k; if (r->yoyo) { float p = fmodf(local, 2 * r->dur); k = p < r->dur ? p / r->dur : 2 - p / r->dur; } else k = fminf(local / r->dur, 1); r->follower = Spline_getPoint(r->sp, r->nsp, ease_sine_inout(k)); } static void TS_trailUpdate(TSRibbon *r) { // positions.unshift + pop oltre 32, poi i punti della Rope memmove(&r->positions[1], &r->positions[0], 31 * sizeof(Vector2)); r->positions[0] = r->follower; if (r->npos < 32) r->npos++; for (int i = 0; i < r->npos; i++) r->points[i] = r->positions[i]; } // --- 0xda22 TreasureReel + TreasureUtils.MakeTexture_* ---------------------------------------- static void shuffle_str(const char **a, int n) { // Phaser.Utils.Array.Shuffle for (int i = n - 1; i > 0; i--) { int j = (int)floorf(frand() * (i + 1)); const char *t = a[i]; a[i] = a[j]; a[j] = t; } } static int TS_list(const char *prizeType, const char **out) { cJSON *W = data_get("weapons"), *it; int n = 0; if (!strcmp(prizeType, "POWERUP")) { // MakeTexture_PowerUps: LevelUpFactory.GetRemainingWeaponsAndPowerUps, mescolati for (int i = 0; i < LUF.n_store; i++) { const char *w = LUF.WeaponStore[i]; if (strin(LUF.ExcludedWeapons, LUF.n_excl, w) < 0 && strin(out, n, w) < 0 && n < 128) out[n++] = w; } if (n <= 0) cJSON_ArrayForEach(it, W) if (cJSON_IsTrue(cJSON_GetObjectItem(cJSON_GetArrayItem(it, 0), "isPowerUp")) && n < 128) out[n++] = str(cJSON_GetArrayItem(it, 0), "bulletType"); shuffle_str(out, n); } else if (!strcmp(prizeType, "FIXED") || !strcmp(prizeType, "EVOLUTION")) { // MakeTexture_Any cJSON_ArrayForEach(it, W) if (n < 128) out[n++] = str(cJSON_GetArrayItem(it, 0), "bulletType"); shuffle_str(out, n); // sort((a, b) => b.isEvolution ? 1 : -1): comparatore incoerente; l'effetto e' portare avanti le evoluzioni const char *tmp[128]; int m = 0; for (int i = 0; i < n; i++) if (cJSON_IsTrue(cJSON_GetObjectItem(cJSON_GetArrayItem(cJSON_GetObjectItem(W, out[i]), 0), "isEvolution"))) tmp[m++] = out[i]; for (int i = 0; i < n; i++) if (!cJSON_IsTrue(cJSON_GetObjectItem(cJSON_GetArrayItem(cJSON_GetObjectItem(W, out[i]), 0), "isEvolution"))) tmp[m++] = out[i]; memcpy(out, tmp, n * sizeof(*out)); } else { // MakeTexture_ExistingWeapons: GetExistingNotMaxedWeapons scarta ogni arma (cerca nella lista che sta // scorrendo) e torna sempre vuota, quindi si usano tutte le armi dei dati, in ordine cJSON_ArrayForEach(it, W) if (!cJSON_IsTrue(cJSON_GetObjectItem(cJSON_GetArrayItem(it, 0), "isPowerUp")) && n < 128) out[n++] = str(cJSON_GetArrayItem(it, 0), "bulletType"); } return n; } static void TS_MakeTexture(int k, const char *prizeType, unsigned color, float alpha) { // 32 x 32 * 12: fondo colorato e icone a (8, 32 i) const char *list[128]; int n = TS_list(prizeType, list), i; RenderTexture2D rt = LoadRenderTexture(0x20, 0x20 * 0xc); BeginTextureMode(rt); ClearBackground(BLANK); rlSetBlendFactors(1, 0, 0x8006); // GL_ONE, GL_ZERO: il fondo copiato com'e', alpha compreso BeginBlendMode(BLEND_CUSTOM); DrawRectangle(0, 0, 0x20, 0x20 * 0xc, hexc(color, alpha)); EndBlendMode(); rlSetBlendFactorsSeparate(0x0302, 0x0303, 1, 0x0303, 0x8006, 0x8006); // icone sopra: alpha che si somma BeginBlendMode(BLEND_CUSTOM_SEPARATE); cJSON *W = data_get("weapons"); for (i = 0; i < n && i < 0xc; i++) { cJSON *b = cJSON_GetArrayItem(cJSON_GetObjectItem(W, list[i]), 0); const Frame *f = frame_get(str(b, "texture"), str(b, "frameName")); if (f) DrawTexturePro(*f->tex, (Rectangle){ f->x, f->y, f->w, f->h }, (Rectangle){ 8 + f->ox, 0x20 * i + f->oy, f->w, f->h }, (Vector2){ 0, 0 }, 0, WHITE); } const Frame *mb = frame_get("items", "MoneyBagGreen.png"); for (int j = 0; j < 0xc - n && mb; j++) DrawTexturePro(*mb->tex, (Rectangle){ mb->x, mb->y, mb->w, mb->h }, (Rectangle){ 8 + mb->ox, 0x20 * (i + j) + mb->oy, mb->w, mb->h }, (Vector2){ 0, 0 }, 0, WHITE); EndBlendMode(); EndTextureMode(); TSReelRT[k] = rt; if (TSReelRT_n < k + 1) TSReelRT_n = k + 1; } static void TS_MakeReels(int n, const unsigned *colors) { static const float ang[5] = { 0, 0x14, -0x14, 0x28, -0x28 }; Vector2 StripEnd = { 0, -0x600 }; TS.n_reels = n; for (int k = 0; k < n; k++) { TSReel *r = &TS.reels[k]; *r = (TSReel){ .color = colors[k], .cfgAlpha = 0.5f, .alpha = 1, .scaleX = 2 }; r->start = (Vector2){ TS.chestX, TS.chestY - 0xa }; r->end = StripEnd; if (ang[k]) RotateVectorByDegrees(&StripEnd, ang[k], &r->end); r->s[0].p = r->s[1].p = r->start; const char *pt = n == 1 ? TS.prizes[0].prizeType : TS.prizes[k].prizeType; TS_MakeTexture(k, pt, r->color, r->cfgAlpha); } } static void TS_ReelPlay(int k) { // startFollow: la rotazione iniziale usa getPoint(0.1) senza offset, come l'originale TSReel *r = &TS.reels[k]; for (int i = 0; i < 2; i++) { TSFollower *f = &r->s[i]; f->following = 1, f->tStart = TS.t + (i ? 0x3e8 : 0); f->rot = atan2f(0.1f * r->end.y - f->p.y, 0.1f * r->end.x - f->p.x) + 0x5a * (PI / 180); } } static void TS_StartReelEv(int k) { TS_ReelPlay(k); } static void TS_ReelStop(int k) { TS.reels[k].stopped = 1, TS.reels[k].tFlash = TS.t; } static void TS_StopReels(void) { int np = TS.n_prizes ? TS.n_prizes : 1; for (int k = 0; k < TS.n_reels; k++) TS_after(TS.stopDelays[k % np], TS_ReelStop, k); } static void TS_HideReels(void) { for (int k = 0; k < TS.n_reels; k++) TS_tween(&TS.reels[k].alpha, 0, 0x12c, 0, 0, NULL), TS_tween(&TS.reels[k].scaleX, 0, 0x12c, 0, 0, NULL); } static void TS_reelsUpdate(void) { for (int k = 0; k < TS.n_reels; k++) { TSReel *r = &TS.reels[k]; if (r->stopped) continue; // stopFollow for (int i = 0; i < 2; i++) { TSFollower *f = &r->s[i]; float local = TS.t - f->tStart; if (!f->following || local < 0) continue; float v = fmodf(local, 0x7d0) / 0x7d0; // 2 s, repeat -1, Linear Vector2 np = { r->start.x + r->end.x * v, r->start.y + r->end.y * v }; float sx = np.x - f->p.x, sy = np.y - f->p.y; f->p = np; if (sx != 0 || sy != 0) f->rot = atan2f(sy, sx) + 0x5a * (PI / 180); // rotateToPath, rotationOffset 90 } } } // --- MakeCoinsEmitter / StartCoinsEmitters ------------------------------------------------------ static void TS_MakeCoinsEmitter(int level) { static const float F[6] = { 0x64, 0x32, 0x19, 0xc8, 0x64, 0x32 }; level--; for (int k = 0; k < 4; k++) { // coinRT0..1 (oro, dietro, depth 6), coinRT2..3 (argento, davanti, depth 7) ParticleManager *m = TS.coins[k] = particles_add(); children_remove(&m->s); m->scrollFactor0 = 1; ParticleEmitter *e = particles_createEmitter(m, (EmitterConfig){ .frames = { NULL }, .nframes = 0, .frameRef = &TS.coinFrame[k], .lifespan = EOP(0xfa0), .rotate = ERND(0, 0x168), .rotateStep = 5, .angle = ERND(0xe1, 0x13b), .speed = ERND(0x1c2, 0x258), .scale = ERANGE(2 * PixelScale, k < 2 ? PixelScale : 2.1f * PixelScale), .gravityY = 0x1f4, .bounce = 0.9f, .collideLeftRight = 1, .boundsX = 0, .boundsW = MENU_W, .frequency = 2 * F[level + (k < 2 ? 0 : 3)], .on = 0 }); e->x = TS.chestX, e->y = TS.chestY - 0xa - 0x14; } } static void TS_coinsStop(int a) { (void)a; TS.coinsStopEv = 0; for (int k = 0; k < 4; k++) if (TS.coins[k]) emitter_stop(TS.coins[k]->emitters[0]); } static void TS_StartCoinsEmitters(float dur) { for (int k = 0; k < 4; k++) emitter_start(TS.coins[k]->emitters[0]); TS.coinsStopEv = TS_after(dur, TS_coinsStop, 0); // QScoinsEmitterTimer } // --- StartFireworks (livello 3) ------------------------------------------------------------------ static void TS_fwBurst(int i) { // tween yoyo di 30 ms sull'overlay: onUpdate start(), onComplete stop() TS_tween(&TS.overlay, 1, 0x1e, 0, 1, NULL); TS.fwUntil[i] = TS.t + 2 * 0x1e; } static void TS_StartFireworks(void) { static const char *F[4] = { "PfxBlue.png", "PfxPink.png", "PfxPurple.png", "PfxBlue.png" }; static const float D[5] = { 0x64, 0x190, 0x2bc, 0x3e8, 0x514 }; ParticleManager *m = TS.fw = particles_add(); children_remove(&m->s); m->scrollFactor0 = 1; for (int i = 0; i < 5; i++) { const char *fr = F[(int)floorf(frand() * 4)]; float x = TS.chestX + (frand() - 0.5f) * (0.5f * TS.BR.x), y = TS.chestY - 0xe1 - 0x96 * frand() / 2; ParticleEmitter *e = particles_createEmitter(m, (EmitterConfig){ .frames = { frame_get("vfx", fr) }, .nframes = 1, .lifespan = EOP(0xbb8), .rotate = ERND(0, 0x168), .angle = { 0, 0x168, 1 }, .angleSteps = 0x10, .speed = ERND(0x64, 0x96 + i / 5.0f * 0x12c / 2), .quantity = (int)ceilf(0x20 + i / 5.0f * 0x20), // 32 + i * 6.4: il ciclo di emissione arriva all'intero successivo .scale = ERANGE(2 + i / 5.0f * 2, 0), .frequency = 0x40, .blendAdd = 1, .on = 0 }); e->x = x, e->y = y; } m->hasWell = 1; // createGravityWell({ x, y, power: 1, epsilon: 25, gravity: 150 }) m->wellX = TS.chestX, m->wellY = TS.chestY - 0x64, m->wellPower = 1 * 0x96, m->wellEpsilon = 0x19 * 0x19; for (int i = 0; i < 5; i++) TS_after(D[i], TS_fwBurst, i); } static void TS_fwStop(int a) { (void)a; for (int i = 0; i < 5; i++) emitter_stop(TS.fw->emitters[i]); } static void TS_fwRaise(int a) { // StartRibbons2, evento a 0 ms (void)a; TS_tween(&TS.overlay, 0, 0x12c, 0x64, 1, NULL); for (int i = 0; i < 5; i++) TS.fw->emitters[i]->y += 0xc8; TS.fwStartFrames = 5; // delay 1, repeat 4: start() per 5 frame for (int i = 1; i <= 9; i++) TS_after(0x3c * i, TS_fwStop, 0); // delay 60, repeat 8 } static void TS_ribbons2Mask(int a) { (void)a; TS.ribbons2[0].mask = TS.ribbons2[1].mask = TS.upperMask; } static void TS_StartRibbons2(void) { TS.updateTrail2 = 1; for (int i = 0; i < 2; i++) TS.ribbons2[i].visible = 1, TS.ribbons2[i].following = 1, TS.ribbons2[i].tStart = TS.t; TS_after(0, TS_fwRaise, 0); } // --- eventi QS --------------------------------------------------------------------------------- static void TS_QSSecond(int a) { // HideReels, MoveCounter, ShowOKButton (void)a; TS.qsSecond = 0; TS_HideReels(); TS.tOk = TS.t; } static void TS_QSEvent(int a) { (void)a; TS.qsEvent = 0; TS.hasSkipped = 1; if (TS.level >= 2) TS_tween(&TS.overlay, 0, 0x3e8, 0, 0, NULL); TS_StopReels(); TS_StopRibbons(); TS.tStop = TS.t; // StartPrizes TS_bubblesHide(0x3e8); TS.qsSecond = TS_after(0x1770, TS_QSSecond, 0); } static void TS_ev3A(int a) { (void)a; TS.qsEvent3A = 0; TS_StartRibbons2(); TS_after(0x3e8, TS_ribbons2Mask, 0); } static void TS_ev3B(int a) { (void)a; TS.qsEvent3B = 0; TS.hasSkipped = 1; TS_ReelPlay(3); TS_ReelPlay(4); } static void TS_EnableQS(int a) { (void)a; TS.qsEnabled = 1; } static float pickedup(const char *k) { return num(cJSON_GetObjectItem(data_get("items"), k), "pickedupAmount", 0); } static void TS_StartCounter(float dur) { TS.counterDur = dur, TS.tCounterEnd = TS.t + dur; } static void TS_overlayHold(void) { TS_tween(&TS.overlay, 1, 0x1af4, 0, 0, NULL); } static void TS_L3Open(int a) { // livello 3, 1600 ms dopo il clic (void)a; TS_tween(&TS.overlay, 1, 0x1e, 0, 1, TS_overlayHold); TS_StartCounter(0x364c); TS_StartCoinsEmitters(0x3840); TS_StartRibbons(); TS_ReelPlay(0), TS_ReelPlay(1), TS_ReelPlay(2); TS_bubblesShow(0x1450, 0xffff00); TS.qsEvent3A = TS_after(0x1af4, TS_ev3A, 0); TS.qsEvent3B = TS_after(0x1edc, TS_ev3B, 0); TS.qsEvent = TS_after(0x2f44, TS_QSEvent, 0); } static void TS_SkipAnimation(void) { if (TS.hasSkipped || !TS.qsEvent) return; TS.hasSkipped = 1; if (TS.level == 3) { TS_cancel(&TS.qsEvent3A); TS_cancel(&TS.qsEvent3B); TS_ReelPlay(3), TS_ReelPlay(4); TS.stopDelays = StopDelays5_QS; } Sound_StopSound(TS.QS_SFX); Sound_PlaySeek(TS.QS_SFX, 1, TS.QSSeekTrack); TS.tCounterEnd = fminf(TS.tCounterEnd, TS.t + TS.QSCounterDelay); // QScoinsCounterTween.complete(QSCounterDelay) if (TS.coinsStopEv) { TS_cancel(&TS.coinsStopEv); TS_coinsStop(0); } TS_cancel(&TS.qsEvent); TS_QSEvent(0); if (TS.level >= 2) TS.overlayHidden = 1; if (TS.level == 3 && TS.qsSecond) TS.ev[TS.qsSecond - 1].t = TS.t + 0x1770 / 3.0f; // QSSecondEvent.timeScale = 3 } // create: SetupTreasureLevel1/2/3 (dopo i premi) static void TS_create(void) { float cx = 0.5f * MENU_W, cy = 0.5f * MENU_H, bw = 0.8f * SAFE_W / 2, bh = 0.8f * DEFAULT_H / 2; TS.TL = (Vector2){ cx - bw, cy - bh }, TS.BR = (Vector2){ cx + bw, cy + bh }; TS.chestX = cx, TS.chestY = TS.BR.y - 0x6e; TS.stopDelays = TS.n_prizes == 5 ? StopDelays5_Default : TS.n_prizes == 3 ? StopDelays3 : StopDelays1; TS.tCounterEnd = 1e30f; // MakeMasks TS.upperMask = (Rectangle){ TS.TL.x + 0xf, TS.TL.y + 0xf, 2 * bw - 0x1e, TS.chestY - TS.TL.y - 0x46 }; TS.upperFreeMask = (Rectangle){ 0, 0, MENU_W, TS.chestY - 0x32 }; TS.bgMask = (Rectangle){ TS.TL.x + 0xf, TS.TL.y + 0xf, 2 * bw - 0x1e, 2 * bh - 0x1e }; for (int i = 0; i < 15; i++) { // BubbleVFX: 15 cerchi float x = Between(0, MENU_W), y = Between(0, MENU_H); TS.bub.c[i] = (Vector2){ x, y }, TS.bub.r[i] = Between(12.5f, 37.5f); } TS.bub.tint = 0xffff00; if (TS.level == 2) { static const unsigned C[3] = { 0x8800ff, 0xff00ff, 0xff00ff }; TS_MakeRibbons(6, TS.chestX, TS.chestY - 0x32, 0x5dc, 0x64); TS_MakeReels(3, C); TS_MakeCoinsEmitter(2); if (pickedup("STATS_TREASURE_1") >= 3 || pickedup("STATS_TREASURE_3") >= 1 || pickedup("TREASURE") >= 0x32) TS_after(0x708, TS_EnableQS, 0); } else if (TS.level == 3) { static const unsigned C[5] = { 0xff0000, 0xff8800, 0xff8800, 0xffff00, 0xffff00 }; TS_MakeReels(5, C); TS_MakeRibbons(8, TS.chestX, TS.chestY - 0x32, 0x5dc, 0x64); TS_MakeRibbonsLevel3(); TS_MakeCoinsEmitter(3); TS.ribbonsAfterReels = 1; } else { static const unsigned C[1] = { 0xff }; TS_MakeRibbons(2, TS.chestX, TS.chestY - 0x32, 0x5dc, 0x64); TS_MakeReels(1, C); TS_MakeCoinsEmitter(1); } } static void TS_cleanup(void) { for (int k = 0; k < TSReelRT_n; k++) UnloadRenderTexture(TSReelRT[k]); TSReelRT_n = 0; } // openButton pointerdown dei tre livelli static void TS_onOpen(void) { if (TS.level == 3) { TS.QSCounterDelay = 0x708, TS.QSSeekTrack = 0x3584 * 0.001f, TS.QS_SFX = "Treasure3"; TS_StartFireworks(); TS_after(0x640, TS_L3Open, 0); if (pickedup("STATS_TREASURE_3") >= 0x32 || pickedup("TREASURE") >= 0x1f4 || po_is("HasSeenFinalFireworks")) TS_after(0x7d0, TS_EnableQS, 0); } else if (TS.level == 2) { TS_StartCounter(0x2af8); TS_StartCoinsEmitters(0x2af8); TS_StartRibbons(); TS_ReelPlay(2); TS_after(0x50, TS_StartReelEv, 0); TS_after(0xa0, TS_StartReelEv, 1); TS_bubblesShow(0x25e4, 0xcccc00); TS_tween(&TS.overlay, 0.7f, 0x25e4, 0, 0, NULL); TS.QSCounterDelay = 0x514, TS.QSSeekTrack = 9.7f, TS.QS_SFX = "Treasure2"; TS.qsEvent = TS_after(0x25e4, TS_QSEvent, 0); } else { TS_StartCounter(0x1d4c); TS_StartCoinsEmitters(0x189c); TS_StartRibbons(); TS_ReelPlay(0); TS_bubblesShow(0x1770, 0x666600); TS.QSCounterDelay = 0x4b0, TS.QSSeekTrack = 6.3f, TS.QS_SFX = "Treasure1"; TS.qsEvent = TS_after(0x189c, TS_QSEvent, 0); if (pickedup("STATS_TREASURE_1") >= 5 || pickedup("STATS_TREASURE_3") >= 1 || pickedup("TREASURE") >= 0x32) TS_after(0x384, TS_EnableQS, 0); } } // Un frame della scena: Clock, tween, oggetti (particelle, follower), poi update() della scena static void TS_frameUpdate(float delta) { for (int i = 0; i < 48; i++) if (TS.ev[i].used && TS.t >= TS.ev[i].t) { TSEvent e = TS.ev[i]; TS.ev[i].used = 0; e.fn(e.arg); } TS_tweensUpdate(); if (TS.fw) { for (int i = 0; i < 5; i++) if (TS.fwUntil[i] > 0) { if (TS.t < TS.fwUntil[i]) emitter_start(TS.fw->emitters[i]); else emitter_stop(TS.fw->emitters[i]), TS.fwUntil[i] = 0; } if (TS.fwStartFrames > 0) { TS.fwStartFrames--; for (int i = 0; i < 5; i++) emitter_start(TS.fw->emitters[i]); } particles_manager_update(TS.fw, delta); } static const float rate[4] = { 0x1e, 0x14, 0x18, 0xe }; for (int k = 0; k < 4; k++) { // coinRT: lo sprite 'spin' ridisegnato a ogni frame char nm[32]; snprintf(nm, sizeof(nm), "coin-spin-%s_%02d.png", k < 2 ? "gold" : "silver", (int)(TS.t / (1000.0f / rate[k])) % 4 + 1); TS.coinFrame[k] = frame_get("items", nm); if (TS.coins[k]) particles_manager_update(TS.coins[k], delta); } for (int i = 0; i < TS.n_ribbons; i++) TS_ribbonFollow(&TS.ribbons[i]); for (int i = 0; i < 2; i++) TS_ribbonFollow(&TS.ribbons2[i]); TS_reelsUpdate(); TS_bubblesUpdate(); if (TS.updateTrail) for (int i = 0; i < TS.n_ribbons; i++) TS_trailUpdate(&TS.ribbons[i]); if (TS.updateTrail2) for (int i = 0; i < 2; i++) TS_trailUpdate(&TS.ribbons2[i]); } static void TreasureScene_update(float delta) { TS.t += delta; TS_frameUpdate(delta); if (TS.t >= 0x12c && TS.tOpen < 0 && !TS.inputEnabled) TS.inputEnabled = 1; // enableInput dopo 300 ms if (TS.tOpen < 0) { if (TS.inputEnabled && (in_confirm() || getenv("VS_AUTOPICK"))) { // openButton pointerdown TS.tOpen = TS.t; TS.inputEnabled = 0; Sound_StopSound("ThingFound"); Sound_StopSound("ThingFoundB"); Sound_PlaySimple(TS.level == 3 ? "Treasure3" : TS.level == 2 ? "Treasure2" : "Treasure1", TS.level == 3 ? 1.1f : 1); TS_onOpen(); } return; } // EnableQS: ESC, tasto destro del mouse, cerchio del pad (sviluppo: VS_SKIP salta appena puo') if ((TS.qsEnabled || getenv("VS_SKIP")) && !TS.hasSkipped && (in_cancel() || IsMouseButtonPressed(MOUSE_BUTTON_RIGHT) || getenv("VS_SKIP"))) TS_SkipAnimation(); if (TS.tOk >= 0 && TS.tOkInput < 0 && TS.t >= TS.tOk + 0x96) TS.tOkInput = TS.t; if (TS.tOkInput >= 0 && TS.tDismiss < 0 && (in_confirm() || getenv("VS_AUTOPICK"))) TS.tDismiss = TS.t; // DismissScene if (TS.tDismiss >= 0 && TS.t >= TS.tDismiss + 0x1f4) { // OnSceneOver TS_QuickSceneOver(0x3e8); PlayerOptions_Save(); TS.active = 0; // ResumeFromTreasureScene TS_cleanup(); Sound_FadeMusic(0.3f, 0x1f4); } } static void TS_nine(const char *frame, int cw, int ch, float cx, float cy, float w, float h, float sx, float sy, float ang, Color tint) { rlPushMatrix(); rlTranslatef(cx, cy, 0); rlRotatef(ang, 0, 0, 1); rlScalef(sx, sy, 1); nine_wh(frame, cw, ch, (Rectangle){ -w / 2, -h / 2, w, h }, tint); rlPopMatrix(); } static void TS_text(const char *s, float x, float y, float size, float scale, float ang, Color c) { // Text con origin 0.5 if (scale <= 0.001f) return; Vector2 m = MeasureTextEx(vs_font, s, size, 0); rlPushMatrix(); rlTranslatef(x, y, 0); rlRotatef(ang, 0, 0, 1); rlScalef(scale, scale, 1); DrawTextEx(vs_font, s, (Vector2){ -m.x / 2, -m.y / 2 }, size, 0, c); rlPopMatrix(); } static void TS_frame(const char *atlas, const char *name, float x, float y, float ox, float oy, float sc, float ang, Color c, int add) { const Frame *f = frame_get(atlas, name); if (!f || sc <= 0.001f) return; Sprite s; sprite_init(&s, f, x, y); sprite_setOrigin(&s, ox, oy); sprite_setScale(&s, sc); s.angle = ang; s.alpha = c.a / 255.0f; s.tint = (unsigned)c.r << 16 | (unsigned)c.g << 8 | c.b; s.scrollFactor0 = 1; s.blendAdd = add; scene_render_one(&s, (Shader){ 0 }); } // 0x16120: popup del premio (CyclePrizes): uno ogni 5 s, nascosto dopo 4,5 s static void TS_drawPopup(float tShown) { int n = TS.n_weaponPrizes; if (!n || tShown < 0) return; int k = (int)(tShown / 0x1388); float local = tShown - k * 0x1388; if (k >= n) return; // repeat n - 2: l'ultimo resta nascosto dopo il suo turno float sy = local < 0x1194 ? lerp01(local, 0, 0x12c) : 1 - lerp01(local, 0x1194, 0x12c); if (sy <= 0) return; const char *key = TS.AccumulatedWeaponPrizes[k]; int lvl = Core_GetWeapon(key) ? Core_GetWeapon(key)->level : 0; // findWeaponLevel + premi uguali precedenti for (int j = 0; j < k; j++) if (!strcmp(TS.AccumulatedWeaponPrizes[j], key)) lvl++; cJSON *wd = cJSON_GetObjectItem(data_get("weapons"), key), *base = cJSON_GetArrayItem(wd, 0); float W = 0.96f * SAFE_W, H = 0x68, x = 0.5f * MENU_W - 0.5f * W, y = MENU_H - H; rlPushMatrix(); rlTranslatef(x, y, 0); rlScalef(1, sy, 1); nine_wh("frame1_c2.png", 12, 12, (Rectangle){ 0, 0, W, H }, cJSON_IsTrue(cJSON_GetObjectItem(base, "isEvolution")) ? YELLOW : WHITE); TS_frame("UI", "frameB.png", 0x34, 0x34, 0.5f, 0.5f, 2, 0, WHITE, 0); TS_frame(str(base, "texture"), str(base, "frameName"), 0x34, 0x34, 0.5f, 0.5f, 2, 0, WHITE, 0); const char *name = tr_of("weaponLang", key, "name"); name = *name ? name : str(base, "name"); float ns = fit_size(name, 16, 0x12c); Vector2 nm = MeasureTextEx(vs_font, name, ns, 0); DrawTextEx(vs_font, name, (Vector2){ W / 2 - nm.x / 2, 6 }, ns, 0, YELLOW); char lv[48]; if (lvl > 0) snprintf(lv, sizeof(lv), "%s%d", tr("genericPopup_level"), lvl + 1); else snprintf(lv, sizeof(lv), "%s", tr("genericPopup_new")); Vector2 lm = MeasureTextEx(vs_font, lv, 16, 0); DrawTextEx(vs_font, lv, (Vector2){ 0x34 - lm.x / 2, 6 }, 16, 0, WHITE); if (n > 1) { char c[16]; snprintf(c, sizeof(c), "%d/%d", 1 + k, n); Vector2 cm = MeasureTextEx(vs_font, c, 16, 0); DrawTextEx(vs_font, c, (Vector2){ W - 6 - cm.x, 6 }, 16, 0, BLACK); } char desc[512]; if (lvl > 0) ParseLevelUpInfo(cJSON_GetArrayItem(wd, lvl), cJSON_IsTrue(cJSON_GetObjectItem(base, "isPowerUp")), desc, sizeof(desc)); else { const char *d = tr_of("weaponLang", key, "description"); snprintf(desc, sizeof(desc), "%s", *d ? d : str(base, "description")); } float bx = 0.4f * W * 0.5f; text_wrap(desc, (Vector2){ bx, 0x20 }, 16, 3.2f * W * 0.25f, WHITE); if (lvl <= 0) { const char *tip = tr_of("weaponLang", key, "tips"); text_wrap(*tip ? tip : (str(base, "tips") ? str(base, "tips") : ""), (Vector2){ bx, 0x40 }, 16, 3.2f * W * 0.25f, ORANGE); } rlPopMatrix(); } // GeometryMask rettangolari: scissor in pixel di schermo, dentro l'area della scena da menu static void TS_mask(Rectangle r) { float ms = (float)SCREEN_H / MENU_H, ox = (SCREEN_W - MENU_W * ms) / 2; float x0 = fmaxf(ox + r.x * ms, ox), y0 = fmaxf(r.y * ms, 0); float x1 = fminf(ox + (r.x + r.width) * ms, ox + MENU_W * ms), y1 = fminf((r.y + r.height) * ms, SCREEN_H); BeginScissorMode((int)x0, (int)y0, (int)fmaxf(0, x1 - x0), (int)fmaxf(0, y1 - y0)); } static void TS_unmask(void) { float ms = (float)SCREEN_H / MENU_H, mw = MENU_W * ms; BeginScissorMode((int)((SCREEN_W - mw) / 2), 0, (int)mw, SCREEN_H); } // Rope verticale (updateVertices/updateUVs): due vertici per punto, a mezza larghezza del fotogramma, perpendicolari al tratto static void TS_drawRope(const TSRibbon *r) { if (!r->visible || r->alpha <= 0) return; Texture2D tex; Rectangle src; if (r->reel >= 0) { if (r->reel >= TSReelRT_n) return; tex = TSReelRT[r->reel].texture, src = (Rectangle){ 0, 0x20 * 0xc, 0x20, -0x20 * 0xc }; // RenderTexture capovolta } else { const Frame *f = frame_get("vfx", "Ribbon1.png"); if (!f) return; tex = *f->tex, src = (Rectangle){ f->x, f->y, f->w, f->h }; } float half = 0.5f * fabsf(src.width); float u0 = src.x / tex.width, u1 = (src.x + src.width) / tex.width, v0 = src.y / tex.height, v1 = (src.y + src.height) / tex.height; Vector2 a[32], b[32]; int ok[32]; Vector2 last = r->points[0]; for (int i = 0; i < 32; i++) { Vector2 p = r->points[i], nx = i < 31 ? r->points[i + 1] : p; float px = nx.y - last.y, py = -(nx.x - last.x), l = sqrtf(px * px + py * py); ok[i] = l > 0; // lunghezza 0: vertici NaN, WebGL non disegna quei triangoli if (ok[i]) px = px / l * half, py = py / l * half; a[i] = (Vector2){ r->pos.x + r->scale * (p.x + px), r->pos.y + r->scale * (p.y + py) }; b[i] = (Vector2){ r->pos.x + r->scale * (p.x - px), r->pos.y + r->scale * (p.y - py) }; last = p; } TS_mask(r->mask); if (r->blendAdd) BeginBlendMode(BLEND_ADDITIVE); rlDisableBackfaceCulling(); rlCheckRenderBatchLimit(4 * 31); rlSetTexture(tex.id); rlBegin(RL_QUADS); rlColor4ub(255, 255, 255, (unsigned char)(255 * fminf(1, r->alpha))); for (int i = 0; i < 31; i++) { if (!ok[i] || !ok[i + 1]) continue; float va = v0 + i * (v1 - v0) / 31, vb = v0 + (i + 1) * (v1 - v0) / 31; rlTexCoord2f(u1, va), rlVertex2f(a[i].x, a[i].y); rlTexCoord2f(u0, va), rlVertex2f(b[i].x, b[i].y); rlTexCoord2f(u0, vb), rlVertex2f(b[i + 1].x, b[i + 1].y); rlTexCoord2f(u1, vb), rlVertex2f(a[i + 1].x, a[i + 1].y); } rlEnd(); rlSetTexture(0); rlEnableBackfaceCulling(); if (r->blendAdd) EndBlendMode(); TS_unmask(); } static void TS_drawRibbons(int depth) { for (int i = 0; i < TS.n_ribbons; i++) if (TS.ribbons[i].depth == depth) TS_drawRope(&TS.ribbons[i]); } static void TS_drawReels(void) { // depth 8, UpperMask; origine (0.5, 0), scala 2 TS_mask(TS.upperMask); for (int k = 0; k < TS.n_reels; k++) { TSReel *r = &TS.reels[k]; for (int i = 0; i < 2; i++) { TSFollower *f = &r->s[i]; rlPushMatrix(); rlTranslatef(f->p.x, f->p.y, 0); rlRotatef(f->rot * (180 / PI), 0, 0, 1); rlScalef(r->scaleX, 2, 1); Rectangle d = { -0x10, 0, 0x20, 0x20 * 0xc }; if (!r->stopped) { if (k < TSReelRT_n) DrawTexturePro(TSReelRT[k].texture, (Rectangle){ 0, 0, 0x20, -0x20 * 0xc }, d, (Vector2){ 0, 0 }, 0, Fade(WHITE, r->alpha)); } else if (TS.t < r->tFlash + 0x32) { // Stop: setTintFill(0xffffff) e ADD per 50 ms sulla texture _empty BeginBlendMode(BLEND_ADDITIVE); DrawRectangleRec(d, hexc(0xffffff, r->cfgAlpha * r->alpha)); EndBlendMode(); } else { DrawRectangleRec(d, hexc(r->color, r->cfgAlpha * r->alpha)); // texture _empty: solo il fondo } rlPopMatrix(); } } TS_unmask(); } static void TS_drawBubbles(void) { // BubbleVFX: due Gradient2 a tutto schermo e 15 cerchi additivi (graphics in scala 1 x 1.3) const Frame *g = frame_get("vfx", "Gradient2.png"); if (g && TS.bub.bgAlpha > 0) { Rectangle src = { g->x, g->y, g->w, g->h }, dst = { 0, 0, MENU_W, MENU_H }; DrawTexturePro(*g->tex, src, dst, (Vector2){ 0, 0 }, 0, hexc(TS.bub.tint, TS.bub.bgAlpha)); BeginBlendMode(BLEND_ADDITIVE); DrawTexturePro(*g->tex, src, dst, (Vector2){ 0, 0 }, 0, hexc(0xffffff, TS.bub.bgAlpha)); EndBlendMode(); } if (TS.bub.gAlpha > 0) { BeginBlendMode(BLEND_ADDITIVE); for (int i = 0; i < 15; i++) { unsigned c = (i % 0xf) * 0x111100 + (i % 5) * 0x33; // Color(i) DrawEllipse((int)TS.bub.c[i].x, (int)(1.3f * TS.bub.c[i].y), TS.bub.r[i], 1.3f * TS.bub.r[i], hexc(c, 0.5f * TS.bub.gAlpha)); } EndBlendMode(); } } static void TreasureScene_draw(void) { float t = TS.t, cx = 0.5f * MENU_W, cy = 0.5f * MENU_H; float bw = 0.8f * SAFE_W / 2, bh = 0.8f * DEFAULT_H / 2; Vector2 TL = { cx - bw, cy - bh }, BR = { cx + bw, cy + bh }; float chestX = cx, chestY = BR.y - 0x6e; // Ordine di disegno di Phaser: depth, poi ordine di creazione. depth 0: bolle, sfondi, bottone, intestazione, // contatore, fuochi, popup; 5 forziere; 6-7 monete; 7-9 nastri; 8 rulli; 12 ChestFront e anello; 13 icone; 1000 Burst TS_drawBubbles(); // sfondo: OnEnterTween (scala -0.2,-0.1 -> 2, angolo 180 -> 0 in 150 ms); DismissScene lo richiude float k = lerp01(t, 0, 0x96), sx = -0.2f + 2.2f * k, sy = -0.1f + 2.1f * k, ang = 180 * (1 - k), alpha = 1; if (TS.tDismiss >= 0) { float d = lerp01(t, TS.tDismiss, 0x96); sx = 2 + (-0.2f - 2) * d, sy = 2 + (-0.1f - 2) * d, ang = 180 * d, alpha = 1 - d; } TS_nine("frame5_c4.png", 12, 12, cx, cy, bw, bh, fabsf(sx), fabsf(sy), ang, Fade(WHITE, alpha)); // backgroundOverlay (frame5_c4_ad, ADD): livelli 2 e 3, tween della scena; il salto lo nasconde if (!TS.overlayHidden && TS.overlay > 0) { BeginBlendMode(BLEND_ADDITIVE); TS_nine("frame5_c4_ad.png", 12, 12, cx, cy, bw, bh, 2, 2, 0, Fade(WHITE, TS.overlay)); EndBlendMode(); } // bottone 'treasure_open' / 'postGame_done1' (OptionsButton 96x32, scala 2): entra ruotando in 150 ms float bk = 0, bang = 180; const char *bt = tr("treasure_open"); if (TS.tOpen < 0 && t >= 0x12c) bk = lerp01(t, 0x12c, 0x96), bang = 180 * (1 - bk); else if (TS.tOpen >= 0 && TS.tOk < 0) { float d = lerp01(t, TS.tOpen, 0x96); bk = 1 - d, bang = -180 * d; } else if (TS.tOk >= 0) { bt = tr("postGame_done1"); bk = lerp01(t, TS.tOk, 0x96), bang = 180 * (1 - bk); if (TS.tDismiss >= 0) { float d = lerp01(t, TS.tDismiss, 0x96); bk = 1 - d, bang = -180 * d; } } float btx = cx, bty = BR.y - 0x40; if (bk > 0) TS_nine("button_c9_normal.png", 9, 14, btx, bty, 0x60, 0x20, 2 * bk, 2 * bk, bang, WHITE); // intestazione 'treasure_header' (scala 2), HideHeader all'apertura (300 ms) const char *hd = tr("treasure_header"); float hs = fit_size(hd, 16, 0xb4); float hscale = TS.tOpen >= 0 ? 2 * (1 - lerp01(t, TS.tOpen + TS_openDelay(), 0x12c)) : 2; TS_text(hd, cx, TL.y + 0x2d, hs, hscale, 0, WHITE); if (bk > 0) TS_text(bt, btx, bty, fit_size(bt, 16, 0x5a), 2 * bk, bang, WHITE); // contatore delle monete (StartCounter): compare in 300 ms, conta fino al totale, poi giallo e pulsante float tc = TS.tOpen >= 0 ? TS.tOpen + TS_openDelay() : -1; if (tc >= 0 && t >= tc && TS.counterDur > 0) { float bx = cx, by = BR.y - 0x40; int done = t >= TS.tCounterEnd; float v = TS.coinsTotal * lerp01(t, tc, TS.counterDur), sc = 2 * lerp01(t, tc, 0x12c); if (done) { float p = fmodf(t - TS.tCounterEnd, 2 * 0x3e8) / 0x3e8; sc = 2 + 0.2f * (p < 1 ? p : 2 - p); } if (TS.tOk >= 0) { // MoveCounter: si chiude in 250 ms, si sposta sull'intestazione, si riapre in 250 ms float m1 = lerp01(t, TS.tOk, 0xfa), m2 = lerp01(t, TS.tOk + 0xfa, 0xfa); if (m1 < 1) sc *= 1 - m1; else bx = cx, by = TL.y + 0x2d, sc = 2 * m2 + (done ? sc - 2 : 0) * m2; } if (TS.tDismiss >= 0) sc *= 1 - lerp01(t, TS.tDismiss, 0x96); char num_s[32]; snprintf(num_s, sizeof(num_s), "%.2f", done ? TS.coinsTotal : v); TS_text(num_s, bx, by, 16, sc, 0, done ? YELLOW : WHITE); float tw = MeasureTextEx(vs_font, num_s, 16, 0).x * sc; // CoinIcon a destra del contatore TS_frame("items", "coin-spin-gold_01.png", bx + 0.5f * tw + 0x10, by, 0.5f, 0.5f, sc, 0, WHITE, 0); } if (TS.fw) particles_manager_draw(TS.fw); TS_drawPopup(TS.tOk >= 0 ? t - TS.tOk : -1); // forziere: Chest (idle ogni 3 s, 15 fps; open 30 fps) e ChestFront, scala 5, origine (0.5, 1) float chestScale = 5, chestAlpha = 1; if (TS.tDismiss >= 0) { float d = lerp01(t, TS.tDismiss, 0x96); chestScale = 5 * (1 - d); chestAlpha = 1 - d; } char fr[32]; float tChestOpen = TS.tOpen >= 0 ? TS.tOpen + TS_openDelay() : -1; if (tChestOpen >= 0 && t >= tChestOpen) { int f = (int)((t - tChestOpen) / (1000.0f / 30)); snprintf(fr, sizeof(fr), "TreasureOpen_%02d.png", f < 8 ? f + 1 : 8); TS_frame("UI", fr, chestX, chestY, 0.5f, 1, chestScale, 0, Fade(WHITE, chestAlpha), 0); snprintf(fr, sizeof(fr), "TreasureOpenFront_%02d.png", f < 8 ? f + 1 : 8); } else { float it = fmodf(t, 0xbb8); // IdleTimer: 'idle' ripartito ogni 3 s, 8 fotogrammi a 15 fps e poi fermo int f = (int)(it / (1000.0f / 15)); snprintf(fr, sizeof(fr), "TreasureIdle_%02d.png", f < 8 ? f + 1 : 8); TS_frame("UI", fr, chestX, chestY, 0.5f, 1, chestScale, 0, Fade(WHITE, chestAlpha), 0); snprintf(fr, sizeof(fr), "TreasureOpenFront_01.png"); } // monete (depth 6 e 7), nastri (7, 8, 9) e rulli (8) nell'ordine di creazione del livello if (TS.coins[0]) particles_manager_draw(TS.coins[0]), particles_manager_draw(TS.coins[1]); TS_drawRibbons(7); if (TS.coins[2]) particles_manager_draw(TS.coins[2]), particles_manager_draw(TS.coins[3]); if (TS.ribbonsAfterReels) TS_drawReels(), TS_drawRibbons(8); else TS_drawRibbons(8), TS_drawReels(); TS_drawRibbons(9); TS_frame("UI", fr, chestX, chestY, 0.5f, 1, chestScale, 0, Fade(WHITE, chestAlpha), 0); // ChestFront (depth 12) if (t >= TS.tCounterEnd && t < TS.tCounterEnd + 0x64) // counterRing: 8 -> 0 in 100 ms dove nasce il contatore TS_frame("vfx", "sPFX_ring_64.png", cx, BR.y - 0x40, 0.5f, 0.5f, 8 * (1 - lerp01(t, TS.tCounterEnd, 0x64)), 0, Fade(WHITE, 0.5f), 1); TS_drawRope(&TS.ribbons2[0]); // depth 13 (livello 3) TS_drawRope(&TS.ribbons2[1]); // icone dei premi (PrizeIcon, depth 13) davanti al forziere static const float off[5][2] = { { 0, -0xfa }, { -0x73, -0x145 }, { 0x73, -0x145 }, { -0x96, -0xbe }, { 0x96, -0xbe } }; for (int i = 0; TS.tStop >= 0 && i < TS.n_prizes; i++) { float tp = TS.tStop + TS.stopDelays[i]; if (t < tp) continue; float lt = t - tp, x = chestX + off[i][0], y = chestY + off[i][1], a = 1; float sc = 2 * lerp01(lt, 0, 0x32), sst = 2 * lerp01(lt, 0, 0x32); if (TS.tDismiss >= 0) { // Hide: verso (0.5 w, 0) in 150 ms, Sine.easeInOut float d = ease_sine_inout(lerp01(t, TS.tDismiss, 0x96)); x += (0.5f * MENU_W - x) * d, y += (0 - y) * d, sc *= 1 - d, sst *= 1 - d, a = 1 - d; } const char *starF = "HitStarWhite2.png"; if (lt >= 0x32) { // dopo il primo tween: HitStar2, scala 2 <-> 4 in yoyo (500 e 600 ms) starF = "HitStar2.png"; float p1 = fmodf(lt - 0x32, 2 * 0x1f4) / 0x1f4, p2 = fmodf(lt - 0x32, 2 * 0x258) / 0x258; sst = 2 + 2 * (p1 < 1 ? p1 : 2 - p1); float sst2 = 2 + 2 * (p2 < 1 ? p2 : 2 - p2); if (TS.tDismiss >= 0) { float d = ease_sine_inout(lerp01(t, TS.tDismiss, 0x96)); sst *= 1 - d, sst2 *= 1 - d; } TS_frame("vfx", starF, x, y, 0.5f, 0.5f, sst2, 0x195 * fmodf(lt, 0x1b58) / 0x1b58 + 0x2d, Fade(WHITE, 0.7f * a), 1); } else { TS_frame("vfx", starF, x, y, 0.5f, 0.5f, 8 + (2 - 8) * lerp01(lt, 0, 0x32), 0x2d, Fade(WHITE, 0.7f * a), 1); } TS_frame("vfx", starF, x, y, 0.5f, 0.5f, sst, 0x168 * fmodf(lt, 0x2710) / 0x2710, Fade(WHITE, 0.7f * a), 1); TS_frame("vfx", "sPFX_ring_64.png", x, y, 0.5f, 0.5f, 8 * (1 - lerp01(lt, 0, 0x64)), 0, Fade(WHITE, 0.5f), 1); TS_frame("vfx", "PrizeBG.png", x, y, 0.5f, 0.5f, sc, 0, Fade(WHITE, 0.8f * a), 0); const PrizePair *p = &TS.prizes[i]; const char *pf = !strcmp(p->prizeType, "FILLER") || !strcmp(p->prizeType, "ARCANA") ? str(cJSON_GetObjectItem(data_get("items"), p->prizeEnum), "frameName") : str(cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("weapons"), p->prizeEnum), 0), "frameName"); if (pf) TS_frame("items", pf, x, y, 0.5f, 0.5f, sc, 0, Fade(WHITE, a), 0); } // OnEnterAnimation (depth 1000): Burst1..6 a 30 fps, scala 8, giallo, ADD, a (0.5 w, 0.5 w) int bf = (int)(t / (1000.0f / 30)); if (bf < 6) { char nm[16]; snprintf(nm, sizeof(nm), "Burst%d.png", bf + 1); TS_frame("vfx", nm, cx, 0.5f * MENU_W, 0.5f, 0.5f, 8, 0, YELLOW, 1); } // UI_overlayScene (scena sopra): frecce ai lati del bottone selezionato int sel = bk > 0 && ((TS.tOpen < 0 && TS.inputEnabled) || (TS.tOkInput >= 0 && TS.tDismiss < 0)); if (sel) ui_arrows(btx, bty, 0x60, t); // displayWidth / 2 (96 x scala 2) } // ============================================================================ // 0x73c5: UI_newItemFoundScene: un'arma raccolta dalla mappa, Prendi o Scarta // ============================================================================ static struct { int active, sel, inputEnabled; float t; const char *item; ParticleManager *pfx; } IF; static void ItemFoundScene_open(void) { // SwapToItemFoundScene / EnterItemFound memset(&IF, 0, sizeof(IF)); IF.active = 1; IF.item = Core.CurrentFoundItem; Sound_FadeMusic(0.2f, 0x1f4); IF.pfx = particles_add(); // coriandoli che salgono dal fondo children_remove(&IF.pfx->s); IF.pfx->scrollFactor0 = 1; ParticleEmitter *e = particles_createEmitter(IF.pfx, (EmitterConfig){ .frames = { frame_get("vfx", "PfxYellow.png"), frame_get("vfx", "PfxRed.png"), frame_get("vfx", "PfxPink.png"), frame_get("vfx", "PfxColor1.png") }, .nframes = 4, .nonRadial = 1, .speed = EOP(0), .speedY = ERND(-0x12c, -0x258), .lifespan = EOP(0x3e8), .scale = ERANGE(4, 0), .quantity = 8, .blendAdd = 1, .rotate = ERND(0, 0x168), .rotateStep = 5, .xOffset = ERND(0, MENU_W), .flowEveryFrame = 1, .on = 1 }); // semplificazione: 'frames' ne ha 5 (anche PfxColor2), EmitterConfig ne tiene 4 e->x = 0, e->y = MENU_H; Sound_PlaySound("LevelUp", 1.25f, 1, 0x3e8, 0, 0); // PickWeapon } static void ItemFoundScene_update(float delta) { IF.t += delta; particles_manager_update(IF.pfx, delta); if (IF.t >= 0x1f4) IF.inputEnabled = 1; // enablePanelsInput dopo 500 ms if (!IF.inputEnabled) return; int dx, dy; if (in_dir_pressed(&dx, &dy) && dy) IF.sel = dy > 0; // griglia 1 x 2: Prendi, Scarta int ok = in_confirm() || getenv("VS_AUTOPICK"), cancel = in_cancel(); if (!ok && !cancel) return; if (ok && IF.sel == 0) { // OnButtonClicked Core_LevelWeaponUp(IF.item, 1); LevelUpFactory_calculateWeights(); Sound_PlaySound("ClickIn", 0, 1, 0, 0, 0); } else Sound_PlaySound("ClickOut", 0, 1, 0, 0, 0); // OnCancelClicked IF.active = 0; // ResumeFromItemFound -> Core.ExitLevelUpScene Player_SetInvulForMilliSecondsNonCumulative(Core.Player, 0x1f4); Sound_FadeMusic(0.3f, 0x1f4); } static void ItemFoundScene_draw(void) { float W = SAFE_W * 0.8f, H = 0.8f * DEFAULT_H, cx = 0.5f * MENU_W, cy = 0.5f * MENU_H, t = IF.t; particles_manager_draw(IF.pfx); float k = fminf(t / 0x96, 1), sx = -0.2f + 1.2f * k, sy = -0.1f + 1.1f * k, ang = 180 * (1 - k); // OnEnterTween rlPushMatrix(); rlTranslatef(cx, cy, 0); rlRotatef(ang, 0, 0, 1); nine("frame5_c4.png", 12, (Rectangle){ -0.5f * W * fabsf(sx), -0.5f * H * fabsf(sy), W * fabsf(sx), H * fabsf(sy) }, WHITE); rlPopMatrix(); Vector2 TL = { cx - 0.5f * W, cy - 0.5f * H }; const char *hd = tr("newItem_header"); TS_text(hd, cx, TL.y + 0x2d, fit_size(hd, 16, 0xb4), 2, 0, WHITE); float pw = 0.95f * W, ph = 0.2f * H, tx = TL.x + 0.025f * W, kk = fminf(t / 0x96, 1); LevelUpPanel_draw(IF.item, MENU_W + (tx - MENU_W) * kk, TL.y + ph - 0.025f * W, pw, ph); static const char *keys[2] = { "newItem_get", "newItem_discard" }, *frames[2] = { "button_c9_normal.png", "button_c8_normal.png" }; for (int i = 0; i < 2; i++) { // OkButton (OptionsButton) e CancelButton (BackButton), 96 x 32 in scala 2 float by = TL.y + (3 + i) * ph - 0.025f * W; TS_nine(frames[i], 9, 14, cx, by, 0x60, 0x20, 2, 2, 0, WHITE); const char *txt = tr(keys[i]); TS_text(txt, cx, by, fit_size(txt, 16, 0x50), 2, 0, WHITE); if (IF.inputEnabled && IF.sel == i) ui_arrows(cx, by, 0x60, t); } int bf = (int)(t / (1000.0f / 30)); // OnEnterAnimation: Burst1..6, scala 8, ADD if (bf < 6) TS_frame("vfx", TextFormat("Burst%d.png", bf + 1), cx, 0.5f * MENU_W, 0.5f, 0.5f, 8, 0, WHITE, 1); } // ============================================================================ // 0x213b: UI_selectWeaponScene (Candybox): griglia 4 x N di SelectWeaponPanel (0x15c57), l'ultimo e' "salta" // ============================================================================ static void text_at(const char *s, float x, float y, float size, float ox, float oy, Color c); static void ui_arrows(float x, float y, float halfW, float t); static struct { int active, sel, n, inputEnabled; float t, scrollY; const char *types[96]; } WS; static int strin_removed(const char *t) { // Core.RemovedWeapons.find(bulletType === t) for (int i = 0; i < Core.n_RemovedWeapons; i++) if (!strcmp(Core.RemovedWeapons[i]->bulletType, t)) return 1; return 0; } static void WeaponSelectScene_open(void) { // SceneManager.EnterWeaponSelection: pausa, musica giu', scena sopra static const char *const evo[] = { "VAMPIRICA", "HOLY_MISSILE", "THOUSAND", "SCYTHE", "HEAVENSWORD", "VESPERS", "HELLFIRE", "VORTEX", "BORA", "ROCHER", "LOOP", "SIRE", "GUNS3", "STIGRANGATTI", "MANNAGGIA", "TRAPANO2", "SILF3", "VENTO2", "TRIASSO3" }; // getEvolvedWeapons static const struct { const char *dlc, *ach, *w; } evoDlc[] = { { "Moonspell", "MOON03_EvolveSilverWind", "SILVERWIND2" }, { "Moonspell", "MOON05_EvolveFourSeasons", "FOURSEASONS2" }, { "Moonspell", "MOON07_EvolveSummonNight", "SUMMONNIGHT2" }, { "Moonspell", "MOON09_EvolveMirageRobe", "MIRAGEROBE2" }, { "Moonspell", "MOON15_EvolveNightSword", "NIGHTSWORD2" }, { "Moonspell", "MOON17_EvolveBubbles", "BUBBLES2" }, { "Foscari", "FOSC05_UniteSpells", "SPELL_STROM" }, { "Foscari", "FOSC07_EvolveEskizzibur", "SWORD2" }, { "Foscari", "FOSC09_EvolveFlashArrow", "FLASHARROW2" }, { "Foscari", "FOSC14_EvolvePrismatic", "PRISMATICMISS2" }, { "Foscari", "FOSC16_EvolveShadow", "SHADOWSERVANT2" } }; memset(&WS, 0, sizeof(WS)); WS.active = 1; if (Core.WeaponSelectionEvo) { for (size_t i = 0; i < sizeof(evo) / sizeof(evo[0]); i++) if (!Core_GetWeapon(evo[i]) && !strin_removed(evo[i]) && WS.n < 95) WS.types[WS.n++] = evo[i]; for (size_t i = 0; i < sizeof(evoDlc) / sizeof(evoDlc[0]); i++) if (DLC_Has(evoDlc[i].dlc) && achieved(evoDlc[i].ach) && !Core_GetWeapon(evoDlc[i].w) && !strin_removed(evoDlc[i].w) && WS.n < 95) WS.types[WS.n++] = evoDlc[i].w; } else { int n; const char *const *b = Weapon_baseList(&n); // getBaseWeapons for (int i = 0; i < n && WS.n < 95; i++) WS.types[WS.n++] = b[i]; } WS.types[WS.n++] = NULL; // AssignData(): "salta" Sound_FadeMusic(0.2f, 0x1f4); Sound_PlaySound("LevelUp", 1, 1, -0xc8, 0, 0); Sound_PlaySound("LevelUp", 0.5f, 1, -0x5dc, 0, 0); } static void WeaponSelectScene_close(void) { // ResumeFromWeaponSelection WS.active = 0; Sound_FadeMusic(0.3f, 0x1f4); } static void WeaponSelectScene_update(float delta) { WS.t += delta; if (WS.t >= 0x1f4 + 0xc8) WS.inputEnabled = 1; // enablePanelsInput (500 ms) -> MakeUIGrid (200 ms dopo) if (!WS.inputEnabled) return; int dx, dy; if (in_dir_pressed(&dx, &dy)) { // UI_grid 4 x righe int c = WS.sel % 4 + dx, r = WS.sel / 4 + dy, rows = (WS.n + 3) / 4; if (c >= 0 && c < 4 && r >= 0 && r < rows && r * 4 + c < WS.n) WS.sel = r * 4 + c; } float py = 0x60 + 0x40 * (WS.sel / 4); // correctScrollableContainerPosition, passo 64 (TopLeft.y + ... in coordinate di schermo sotto) float top = 0.5f * MENU_H - 0.5f * 0.8f * DEFAULT_H; while (WS.scrollY + top + py + 0x40 > MENU_H - 0x32) WS.scrollY -= 0x40; while (WS.scrollY + top + py < 0x80 && WS.scrollY < 0) WS.scrollY += 0x40; if (!in_confirm() && !getenv("VS_AUTOPICK")) return; // OnCancelCallback: niente const char *t = WS.types[WS.sel]; // OnPanelClicked if (t) { Sound_PlaySound("ClickIn", 0, 1, 0, 0, 0); Core_AddWeapon(t, 1); } else Sound_PlaySound("ClickOut", 0, 1, 0, 0, 0); WeaponSelectScene_close(); } static void SelectWeaponPanel_draw(const char *type, float px, float py) { // 192 x 64, PixelScale 1 cJSON *base = type ? cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("weapons"), type), 0) : NULL; Color tint = !type ? (Color){ 255, 0, 0, 255 } : cJSON_IsTrue(cJSON_GetObjectItem(base, "isEvolution")) ? (Color){ 255, 255, 0x88, 255 } : WHITE; nine("frame1_c2.png", 12, (Rectangle){ px, py, 0xc0, 0x40 }, tint); if (!type) { const char *sk = tr("levelup_skip"); text_at(sk, px + 0x60, py + 0x20, 16, 0.5f, 0.5f, WHITE); return; } TS_frame("UI", "frameB.png", px + 0x20, py + 0x20, 0.5f, 0.5f, 2, 0, WHITE, 0); TS_frame(str(base, "texture"), str(base, "frameName"), px + 0x20, py + 0x20, 0.5f, 0.5f, 2, 0, WHITE, 0); const char *name = tr_of("weaponLang", type, "name"); name = *name ? name : str(base, "name"); Vector2 m = MeasureTextEx(vs_font, name, 16, 1); float lines = m.x > 0x78 ? 2 : 1; // semplificazione: wordWrap 120 stimato a due righe al massimo text_wrap(name, (Vector2){ px + 0x40, py + 0x20 - 0.5f * lines * m.y }, 16, 0x78, WHITE); } static void WeaponSelectScene_draw(void) { float W = 2 * SAFE_W * 0.8f, H = 0.8f * DEFAULT_H, cx = 0.5f * MENU_W, cy = 0.5f * MENU_H, t = WS.t; float k = fminf(t / 0x96, 1), sx = -0.2f + 1.2f * k, sy = -0.1f + 1.1f * k, ang = 180 * (1 - k); // OnEnterTween dello sfondo rlPushMatrix(); rlTranslatef(cx, cy, 0); rlRotatef(ang, 0, 0, 1); nine("frame5_c4.png", 12, (Rectangle){ -0.5f * W * fabsf(sx), -0.5f * H * fabsf(sy), W * fabsf(sx), H * fabsf(sy) }, WHITE); // MenuBackground, alpha 1 <-> 0.95 rlPopMatrix(); Vector2 TL = { cx - 0.5f * W, cy - 0.5f * H }; const char *hd = tr("weaponSelection_header"); if (!strcmp(hd, "weaponSelection_header")) hd = "Weapon Selection"; TS_text(hd, cx, TL.y + 0x2d, fit_size(hd, 16, 0xfa), 2, 0, WHITE); float ms = (float)SCREEN_H / MENU_H, ox = (SCREEN_W - MENU_W * ms) / 2; // la scena e' disegnata scalata: lo scissor vuole pixel dello schermo BeginScissorMode((int)ox, (int)((TL.y + 0x4b) * ms), (int)(MENU_W * ms), (int)((H - 0x64) * ms)); // la maschera del contenitore scorrevole for (int i = 0; i < WS.n; i++) { float tx = TL.x + 0.025f * W + (i % 4) * 0xc0, kk = fminf(t / (0x96 + 8 * i), 1); // OnEnterTween: da destra in 150 + 8 i ms float px = MENU_W + (tx - MENU_W) * kk, py = TL.y + 0x60 + 0x40 * (i / 4) - 0.025f * W + WS.scrollY; SelectWeaponPanel_draw(WS.types[i], px, py); if (WS.inputEnabled && WS.sel == i) ui_arrows(px + 0x60, py + 0x20, 0x60, t); } BeginScissorMode((int)ox, 0, (int)(MENU_W * ms), SCREEN_H); // torna lo scissor della scena (EndScissorMode lo toglierebbe del tutto) int bf = (int)(t / (1000.0f / 30)); // OnEnterAnimation: Burst1..6, scala 8, ADD if (bf < 6) TS_frame("vfx", TextFormat("Burst%d.png", bf + 1), cx, 0.5f * MENU_W, 0.5f, 0.5f, 8, 0, WHITE, 1); } // ============================================================================ // 0x12112: UI_arcanaMainScene (scelta di un'arcana fra le 22 carte) e 0x3b94: UI_arcanaDraftScene (4 carte dal forziere) // Carte 0x6851, anelli di carte 0x1347, pannello CardInformationPanel 0x12fcd, MazzoInGamePanel 0x168b5. // ============================================================================ // Tween e timer della scena: la MainScene e' in pausa (le scene di Phaser hanno ciascuna il proprio TweenManager e Clock) typedef struct { float *t, *t2, from, to; } ARCProp; typedef struct { ARCProp p[6]; int np, repeat, started, used; unsigned gen; float dur, delay, el; float (*ease)(float); Callback onStart, onComplete; void *ctx; } ARCTween; typedef struct { float delay, el; int loop, repeat, used; unsigned gen; Callback cb; void *ctx; } ARCTimer; static ARCTween arc_tw[512]; static ARCTimer arc_tm[256]; static unsigned arc_gen; static TweenRef ARC_tween(TweenConfig c) { for (int i = 0; i < 512; i++) { ARCTween *w = &arc_tw[i]; if (w->used) continue; memset(w, 0, sizeof(*w)); const TweenProp *pr = c.many ? c.many : c.props; int n = c.many ? c.nmany : c.nprops; for (int k = 0; k < n && k < 6; k++) w->p[w->np++] = (ARCProp){ pr[k].t, pr[k].t2, 0, pr[k].end }; w->used = 1, w->gen = ++arc_gen, w->dur = c.duration > 0 ? c.duration : 1, w->delay = c.delay, w->repeat = c.repeat, w->ease = c.ease; w->onStart = c.onStart, w->onComplete = c.onComplete, w->ctx = c.ctx; return (TweenRef){ i, w->gen }; } return TWEEN_NONE; } static void ARC_tweenStop(TweenRef r) { if (r.idx >= 0 && r.idx < 512 && arc_tw[r.idx].gen == r.gen) arc_tw[r.idx].used = 0; } static Timer ARC_timer(float delay, int loop, int repeat, Callback cb, void *ctx) { for (int i = 0; i < 256; i++) if (!arc_tm[i].used) { arc_tm[i] = (ARCTimer){ delay, 0, loop, repeat, 1, ++arc_gen, cb, ctx }; return (Timer){ i, arc_tm[i].gen }; } return (Timer){ -1, 0 }; } static void ARC_timerStop(Timer t) { if (t.idx >= 0 && t.idx < 256 && arc_tm[t.idx].gen == t.gen) arc_tm[t.idx].used = 0; } static void ARC_clock(float delta) { for (int i = 0; i < 256; i++) { ARCTimer *t = &arc_tm[i]; if (!t->used || (t->el += delta) < t->delay) continue; t->el -= t->delay; if (!t->loop && t->repeat == 0) t->used = 0; else if (!t->loop && t->repeat > 0) t->repeat--; if (t->cb) t->cb(t->ctx); } for (int i = 0; i < 512; i++) { ARCTween *w = &arc_tw[i]; if (!w->used || (w->el += delta) < w->delay) continue; if (!w->started) { w->started = 1; if (w->onStart) w->onStart(w->ctx); for (int k = 0; k < w->np; k++) w->p[k].from = *w->p[k].t; // valori di partenza a fine delay, come Phaser } float k = fminf(1, (w->el - w->delay) / w->dur), e = w->ease ? w->ease(k) : k; for (int j = 0; j < w->np; j++) { float v = w->p[j].from + (w->p[j].to - w->p[j].from) * e; *w->p[j].t = v; if (w->p[j].t2) *w->p[j].t2 = v; } if (k < 1) continue; if (w->repeat != 0) { // repeat: riparte dal valore iniziale if (w->repeat > 0) w->repeat--; w->el = w->delay; continue; } w->used = 0; if (w->onComplete) w->onComplete(w->ctx); } } static int Arcana_unlocked(int t) { char b[16]; snprintf(b, sizeof(b), "%d", t); return po_has("UnlockedArcanas", b) || getenv("VS_ARCANA_UNLOCK"); } // PlayerOptions.UnlockedArcanas static int Arcana_hidden(int t) { return cJSON_IsTrue(cJSON_GetObjectItem(cJSON_GetObjectItem(data_get("arcana"), TextFormat("%d", t)), "hidden")); } static int Arcana_major(int t) { return cJSON_IsTrue(cJSON_GetObjectItem(cJSON_GetObjectItem(data_get("arcana"), TextFormat("%d", t)), "major")); } static const char *Arcana_frame(int t) { return str(cJSON_GetObjectItem(data_get("arcana"), TextFormat("%d", t)), "frameName"); } static int Arcana_unlockedCount(void) { int n = 0; for (int t = 0; t < 22; t++) n += Arcana_major(t) && Arcana_unlocked(t) && !Arcana_hidden(t); return n; } static int RandomazzoEnabled(void) { // Core.HasRandomazzoEnabled: RELIC_RANDOMAZZO raccolto e SelectedMazzo (sviluppo: VS_RANDOMAZZO) return (po_has("CollectedItems", "RELIC_RANDOMAZZO") && po_is("SelectedMazzo")) || getenv("VS_RANDOMAZZO"); } typedef struct ArcCard { Sprite s; const char *front; int open, isFlipping, spinTimes, arcana, used; float dur, scl, rx, ry; // rx/ry: posizione dentro l'anello TweenRef flip; } ArcCard; static void ArcCard_init(ArcCard *c, float x, float y, const char *front, int arcana) { memset(c, 0, sizeof(*c)); sprite_init(&c->s, frame_get("randomazzo", "back.png"), x, y); c->s.scrollFactor0 = 1; c->front = front, c->arcana = arcana, c->used = 1; c->flip = TWEEN_NONE; } static void ArcCard_Reveal(ArcCard *c, float dur, float scl); static void ArcCard_flipEnd(void *ctx) { ArcCard *c = ctx; c->isFlipping = 0; if (c->spinTimes > 0) c->spinTimes--, ArcCard_Reveal(c, c->dur, 1); // (sic) il giro successivo torna a scala 1 } static void ArcCard_flipMid(void *ctx) { // ChangeFrame ArcCard *c = ctx; c->open = !c->open; sprite_setFrame(&c->s, frame_get("randomazzo", c->open && c->front ? c->front : "back.png")); c->flip = ARC_tween((TweenConfig){ .props = { { &c->s.scaleX, NULL, c->scl }, { &c->s.scaleY, NULL, c->scl } }, .nprops = 2, .duration = c->dur, .onComplete = ArcCard_flipEnd, .ctx = c }); } static void ArcCard_Reveal(ArcCard *c, float dur, float scl) { if (c->isFlipping) return; c->isFlipping = 1, c->dur = dur, c->scl = scl; sprite_setScale(&c->s, scl); ARC_tweenStop(c->flip); c->flip = ARC_tween((TweenConfig){ .props = { { &c->s.scaleX, NULL, 0 }, { &c->s.scaleY, NULL, 1.2f * scl } }, .nprops = 2, .duration = dur, .onComplete = ArcCard_flipMid, .ctx = c }); } static void ArcCard_Spin(ArcCard *c, float dur, int times) { c->spinTimes = times; ArcCard_Reveal(c, dur, 1); } static const char *ArcCard_randomName(void) { return TextFormat("%02d.png", (int)floorf(frand() * 22)); } // GetRandomArcanaName (TextFormat: buffer a rotazione) #define VUI_GOLD 0xf2c14e // l'oro dei titoli della UI per la Vita static Color rgb(unsigned c, float a); static void vui_prompt_bar(void), vui_prompt_select(void), vui_prompts_clear(void); static Vector2 menu_pointer(void); static int ptr_pressed(void); #define ARC_MAXCARDS 400 #define ARC_PANEL_X 610.0f // Vita: la scheda a destra (CardInformationPanel) e, nella draft, il Mazzo sotto #define ARC_PANEL_W 330.0f #define ARC_MAZZO_Y 318.0f #define ARC_MAZZO_W ARC_PANEL_W static struct { int active, draft, inputEnabled, sel, n_cards, n_majors, n_available, rerollsShown, randomDone, okOnly; float t, cw, ch, pad, offX, offY, bgW, bgH; ArcCard all[ARC_MAXCARDS]; int n_all; ArcCard *cards[24]; // le carte della griglia int majors[22], discarded[22], n_discarded; int highlighted; // arcanaType evidenziato struct { ArcCard *c[32]; int n; float x, y, radius, speed, cs; } rings[8]; int n_rings; ParticleManager *pfx; float blackAlpha, bgScaleX, bgScaleY, bgAngle, infoScale, okScale, mazzoScaleY; float okX, okY, rndX, rndY, skipX, skipY; Timer ringTimers[8]; } ARC; static ArcCard *ARC_card(float x, float y, const char *front, int arcana) { if (ARC.n_all >= ARC_MAXCARDS) return NULL; ArcCard *c = &ARC.all[ARC.n_all++]; ArcCard_init(c, x, y, front, arcana); return c; } static void ARC_ringFlush(void *ctx) { // SpinningRingOfCards.Flush: ogni carta fa un giro, a 100 ms l'una dall'altra int r = (int)(intptr_t)ctx; for (int i = 0; i < ARC.rings[r].n; i++) ArcCard_Spin(ARC.rings[r].c[i], 0xc8, 1); // semplificazione: tutte insieme (l'originale le scagliona di 100 ms) } static void ARC_addRing(float x, float y, int amount, float radius, float speed) { int r = ARC.n_rings++; ARC.rings[r].x = x, ARC.rings[r].y = y, ARC.rings[r].radius = radius, ARC.rings[r].speed = speed, ARC.rings[r].cs = 0; float st = 2 * PI / amount; for (int i = 0; i < amount && i < 32; i++) { ArcCard *c = ARC_card(0, 0, ArcCard_randomName(), -1); if (!c) break; c->rx = cosf(st * i) * radius, c->ry = sinf(st * i) * radius; ARC.rings[r].c[ARC.rings[r].n++] = c; } ARC_ringFlush((void *)(intptr_t)r); ARC.ringTimers[r] = ARC_timer(0x2710, 1, 0, ARC_ringFlush, (void *)(intptr_t)r); // semplificazione: un timer per anello (l'originale ne crea uno per carta) ARC_tween((TweenConfig){ .props = { { &ARC.rings[r].cs, NULL, 1 } }, .nprops = 1, .duration = 0x12c, .ease = Ease_SineInOut }); } static void ARC_stripSpin(void *ctx) { ArcCard_Spin(ctx, 0x32, 0xc); } static void ARC_addStrips(void) { for (int k = 0; k < 3; k++) for (int i = 0; i < 0x16; i++) { float x = MENU_W / 22.0f * (k == 2 ? 0x16 - i : i); ArcCard *c = ARC_card(x, -0x2f, ArcCard_randomName(), -1); if (!c) return; ARC_tween((TweenConfig){ .props = { { &c->s.angle, NULL, 0x168 }, { &c->s.y, NULL, MENU_H + 0x2f } }, .nprops = 2, .duration = 0x1f4 + 0x32 * i, .repeat = 1 }); ARC_timer(0x32 * i, 0, 0, ARC_stripSpin, c); } } static void ARC_cardMoveTo(ArcCard *c, float x, float y, float ms) { ARC_tween((TweenConfig){ .props = { { &c->s.x, NULL, x }, { &c->s.y, NULL, y } }, .nprops = 2, .duration = ms }); } static void ARC_revealLater(void *ctx) { ArcCard *c = ctx; ArcCard_Reveal(c, 0x64, ARC.draft && c->arcana != -2 ? 2 : 1); } // le carte del Mazzo (-2) a scala 1 static int ARC_isActive(int t) { return Arcanas_has(t); } static void ARC_selectCard(ArcCard *c) { if (c && c->arcana >= 0) ARC.highlighted = c->arcana; } // OnCardClicked + OnSelectionChange static void ARC_dealDraft(int fromTop) { // DraftArcanas / Reroll: 4 carte fra quelle sbloccate non ancora attive ARC.n_cards = 0; for (int i = 0; i < 4; i++) { float x = 0.5f * MENU_W, y = fromTop ? 0.5f * -MENU_H : 0.5f * MENU_H; ArcCard *c; if (i < ARC.n_majors) { c = ARC_card(x, y, Arcana_frame(ARC.majors[i]), ARC.majors[i]); if (c) ARC_timer(0x32 * (1 + i % 4), 0, 0, ARC_revealLater, c); } else { ARC.rerollsShown = 0; c = ARC_card(x, y, "back.png", -1); // VOID if (c) sprite_setScale(&c->s, 2); } if (!c) continue; ARC_cardMoveTo(c, ARC.cw + ARC.offX + 2 * ARC.cw * (i % 4) + 2 * ARC.pad * (i % 4), ARC.ch + ARC.offY + ARC.ch * (i / 4) + 2 * ARC.pad * (i / 4.0f), 0xf0); ARC.cards[ARC.n_cards++] = c; } } static void ARC_pickMajors(void) { ARC.n_majors = 0; for (int t = 0; t < 22; t++) { if (!Arcana_major(t) || ARC_isActive(t) || !Arcana_unlocked(t) || Arcana_hidden(t)) continue; int disc = 0; for (int j = 0; j < ARC.n_discarded; j++) disc |= ARC.discarded[j] == t; if (!disc) ARC.majors[ARC.n_majors++] = t; } for (int i = ARC.n_majors - 1; i > 0; i--) { int j = (int)floorf(frand() * (i + 1)), x = ARC.majors[i]; ARC.majors[i] = ARC.majors[j]; ARC.majors[j] = x; } } static void ARC_open(int draft) { // SceneManager.EnterMainArcana / EnterDraftArcana memset(&ARC, 0, sizeof(ARC)); memset(arc_tw, 0, sizeof(arc_tw)), memset(arc_tm, 0, sizeof(arc_tm)); // scena nuova: tween e timer suoi ARC.active = 1, ARC.draft = draft; vui_prompt_select(); Sound_FadeMusic(0.2f, 0x1f4); Sound_PlaySound("LevelUp", 0.4f, 1, -0x1f4, 0, 0); Sound_PlaySound("LevelUp", 0.4f, 1, -0x190, 0, 0); Sound_PlaySound("LevelUp", 0.4f, draft ? 0.75f : 0.7f, -0x190, 0, 0); // InitData ARC.cw = 0x43, ARC.ch = 0x60, ARC.pad = 4; ARC.offX = 24, ARC.offY = 80; // Vita: griglia a sinistra sotto il titolo, scheda a destra (l'originale centra tutto su 1093 x 683) ARC.bgW = 8 * ARC.cw + 9 * ARC.pad, ARC.bgH = 3 * ARC.ch + 3 * ARC.pad; ARC_tween((TweenConfig){ .props = { { &ARC.blackAlpha, NULL, 0.5f } }, .nprops = 1, .duration = 0x3e8 }); // AddBlackFader ARC.pfx = particles_add(); // AddBackParticles: dorsi di carte che cadono e salgono children_remove(&ARC.pfx->s); ARC.pfx->scrollFactor0 = 1; for (int k = 0; k < 2; k++) { ParticleEmitter *e = particles_createEmitter(ARC.pfx, (EmitterConfig){ .frames = { frame_get("randomazzo", "back.png") }, .nframes = 1, .xOffset = ERND(0, MENU_W), .rotate = ERND(0, 0x168), .lifespan = EOP(0xfa0), .nonRadial = 1, .speed = EOP(0), .speedY = k ? ERND(-0x64, -0xc8) : ERND(0x64, 0xc8), .scale = ERANGE(2, 0), .quantity = 1, .tint = 0x444444, .flowEveryFrame = 1, .on = 1 }); e->x = 0, e->y = k ? MENU_H + 0x60 : -0x60; } // AddAllRings ARC_addRing(0, 0, 0x1e, 0xfa, -0.0002f), ARC_addRing(0, 0, 0x1e, 0xc8, 0), ARC_addRing(0, 0, 0x1e, 0x96, -0.0002f), ARC_addRing(0, 0, 0x10, 0x64, 0); ARC_addRing(MENU_W, 0, 0x1e, 0xc8, 0.0002f), ARC_addRing(0, MENU_H, 0x1e, 0xc8, 0.0002f), ARC_addRing(0, MENU_H, 0x11, 0x64, 0.0003f), ARC_addRing(MENU_W, MENU_H, 0x1e, 0x96, 0.0002f); ARC_addStrips(); ARC.bgScaleX = -0.2f, ARC.bgScaleY = -0.1f, ARC.bgAngle = 180; // OnEnterTween dei due sfondi ARC_tween((TweenConfig){ .props = { { &ARC.bgScaleX, NULL, 1 }, { &ARC.bgScaleY, NULL, 1 }, { &ARC.bgAngle, NULL, 0 } }, .nprops = 3, .duration = 0x96 }); ARC.highlighted = 6; // CardInformationPanel parte su T06_SARABANDE if (draft) { ARC.rerollsShown = Core.Player->rerolls > 0; ARC_pickMajors(); ARC_dealDraft(0); ARC.okX = ARC.offX + 1.5f * ARC.cw, ARC.okY = 2.5f * ARC.ch + ARC.offY + 0x14; // Vita: Ok e Reroll sotto le carte, Salta sotto Reroll ARC.rndX = ARC.okX + 3 * ARC.cw, ARC.rndY = ARC.okY; ARC.skipX = ARC.rndX, ARC.skipY = ARC.okY + 1.1f * ARC.ch; ARC.okScale = 2; if (ARC.n_cards && ARC.cards[0]->arcana >= 0) ARC.highlighted = ARC.cards[0]->arcana; ARC_tween((TweenConfig){ .props = { { &ARC.mazzoScaleY, NULL, 1 } }, .nprops = 1, .duration = 0x96 }); // MazzoPanel.Open for (int i = 0; i < Arcanas.n && i < 8; i++) { // MazzoInGamePanel.AssignData: le arcane gia' attive (Vita: in fila sotto la scheda) float pw = ARC_MAZZO_W, x = Arcanas.n <= 3 ? pw / 4 * (1 + i) : pw / (Arcanas.n + 1) * (1 + i); ArcCard *c = ARC_card(ARC_PANEL_X + x, ARC_MAZZO_Y + 0x60, Arcana_frame(Arcanas.order[i]), -2); if (c) ARC_timer(0x32 * i, 0, 0, ARC_revealLater, c); } } else { // AddAllMajorArcanas int first = -1; for (int t = 0, i = 0; t < 22; t++) { if (!Arcana_major(t)) continue; ArcCard *c = ARC_card(0.5f * MENU_W, 0.5f * MENU_H, Arcana_frame(t), t); if (!c) break; if (Arcana_unlocked(t) && !Arcana_hidden(t)) { if (first < 0) first = t; ARC_timer(i % 8 * 0x1e, 0, 0, ARC_revealLater, c); } ARC_cardMoveTo(c, 0.5f * ARC.cw + ARC.offX + ARC.cw * (i % 8) + ARC.pad * (i % 8), 0.5f * ARC.ch + ARC.offY + ARC.ch * (i / 8) + ARC.pad * (i / 8.0f), 0xf0); if (ARC_isActive(t)) c->s.tint = 0x444444; // setTint(0, 0x222222, 0x444444, 0x888888): media dei quattro angoli ARC.cards[ARC.n_cards++] = c; i++; } int i = ARC.n_cards; ARC.rndX = 0.5f * ARC.cw + ARC.offX + ARC.cw * (i % 8) + ARC.pad * (i % 8), ARC.rndY = 0.5f * ARC.ch + ARC.offY + ARC.ch * (i / 8) + ARC.pad * (i / 8.0f); i++; ARC.okX = 0.5f * ARC.cw + ARC.offX + ARC.cw * (i % 8) + ARC.pad * (i % 8), ARC.okY = 0.5f * ARC.ch + ARC.offY + ARC.ch * (i / 8) + ARC.pad * (i / 8.0f); ARC.okScale = 2; ARC.highlighted = first >= 0 ? first : 0; // SelectedArcana (PlayerOptions): 0 in un salvataggio nuovo ARC.sel = 23; // MakeUIGrid: si parte da OkButton (cella 7, 2) } } static void ARC_close(void) { // ResumeFromMainArcana / ResumeFromDraftArcana ARC.active = 0; vui_prompts_clear(); for (int r = 0; r < ARC.n_rings; r++) ARC_timerStop(ARC.ringTimers[r]); Sound_FadeMusic(0.3f, 0x1f4); } static void ARC_confirm(void) { // OnConfirmClicked int t = ARC.highlighted; if (t < 0 || !Arcana_unlocked(t) || Arcana_hidden(t) || ARC_isActive(t)) { Sound_PlaySound("ClickOut", 0, 1, 0, 0, 0); return; } Arcanas_Add(t); Sound_PlaySound("ClickIn", 0, 1, 0, 0, 0); Player_SetInvulForMilliSecondsNonCumulative(Core.Player, 0x1f4); ARC_close(); } static void ARC_randomPicked(void *ctx) { // OnRandomClicked, onComplete del raduno: una carta a caso fra le sbloccate non ottenute (void)ctx; int avail[22], n = 0; for (int i = 0; i < ARC.n_cards; i++) { int t = ARC.cards[i]->arcana; if (t >= 0 && Arcana_unlocked(t) && !Arcana_hidden(t) && !ARC_isActive(t)) avail[n++] = i; } ARC.okX -= 0.5f * ARC.cw; if (!n) { ARC.okOnly = 1; return; } ArcCard *pick = ARC.cards[avail[(int)floorf(frand() * n)]]; ARC.highlighted = pick->arcana; for (int i = 0; i < ARC.n_cards; i++) { // ventaglio: angoli da -66 a passi di 6 ArcCard *c = ARC.cards[i]; if (c == pick) continue; sprite_setOrigin(&c->s, 0.5f, 1), c->s.y += 0.5f * ARC.ch; ARC_tween((TweenConfig){ .props = { { &c->s.angle, NULL, -0x42 + 6 * i } }, .nprops = 1, .duration = 0xc8 }); // semplificazione: stagger lineare (l'originale usa cubic.out) } ArcCard_Reveal(pick, 0x64, 1); ARC_tween((TweenConfig){ .props = { { &pick->s.angle, NULL, 0 }, { &pick->s.y, NULL, pick->s.y - ARC.ch } }, .nprops = 2, .duration = 0xc8, .delay = 0xc8 }); ARC_tween((TweenConfig){ .props = { { &ARC.okScale, NULL, 2 } }, .nprops = 1, .duration = 0xc8 }); ARC.okOnly = 1, ARC.sel = 99; // OkOnlyGrid } static void ARC_randomClicked(void) { ARC.inputEnabled = 0, ARC.randomDone = 1; Sound_PlaySound("ClickIn", 0, 1, 0, 0, 0); ARC_tween((TweenConfig){ .props = { { &ARC.okScale, NULL, 0 } }, .nprops = 1, .duration = 0xc8 }); for (int i = 0; i < ARC.n_cards; i++) { ArcCard *c = ARC.cards[i]; if (c->open) ArcCard_Reveal(c, 0x64, 1); ARC_tween((TweenConfig){ .props = { { &c->s.x, NULL, 0.5f * MENU_W }, { &c->s.y, NULL, 0.5f * MENU_H + 0.5f * ARC.ch } }, .nprops = 2, .duration = 0x64, .delay = 0x14 * i, .onComplete = i == ARC.n_cards - 1 ? ARC_randomPicked : NULL }); } } static void ARC_enableLater(void *ctx) { (void)ctx; ARC.inputEnabled = 1; } static void ARC_reroll(void) { // OnRandomClicked della draft -> Reroll if (Core.Player->rerolls <= 0 || ARC.n_majors <= 4) return; Sound_PlaySound("ClickIn", 0, 1, 0, 0, 0); Core.Player->rerolls--; ARC.inputEnabled = 0; for (int i = 0; i < 4 && i < ARC.n_majors; i++) ARC.discarded[ARC.n_discarded++] = ARC.majors[i]; ARC_pickMajors(); for (int i = 0; i < ARC.n_cards; i++) ARC_tween((TweenConfig){ .props = { { &ARC.cards[i]->s.x, NULL, MENU_W + ARC.cw }, { &ARC.cards[i]->s.y, NULL, MENU_H + ARC.ch }, { &ARC.cards[i]->s.angle, NULL, 0xb4 } }, .nprops = 3, .duration = 0xf0 }); ARC_dealDraft(1); ARC.rerollsShown = Core.Player->rerolls > 0; if (ARC.n_majors <= 4 || !ARC.rerollsShown) ARC.rerollsShown = 0; if (ARC.n_cards) ARC_selectCard(ARC.cards[0]), ARC.sel = 0; ARC_timer(0x1f4, 0, 0, ARC_enableLater, NULL); } static void ARC_skip(void) { Sound_PlaySound("ClickOut", 0, 1, 0, 0, 0); Player_SetInvulForMilliSecondsNonCumulative(Core.Player, 0x1f4); ARC_close(); } // OnSkipClicked static int ARC_hit(Vector2 m, float x, float y, float w, float h) { return fabsf(m.x - x) <= 0.5f * w && fabsf(m.y - y) <= 0.5f * h; } static int ARC_touch(Vector2 m) { // Vita: tocco = la cella del pad; sulla carta gia' evidenziata conferma (come nei potenziamenti) float bw = ARC.draft ? 2 * ARC.cw : ARC.cw, bh = 0.7f * ARC.ch; // i bottoni sono NineSlice a scala 2 if (ARC.okOnly) { if (ARC_hit(m, ARC.okX, ARC.okY, bw, bh)) ARC_confirm(); return 1; } for (int i = 0; i < ARC.n_cards; i++) { ArcCard *c = ARC.cards[i]; if (!ARC_hit(m, c->s.x, c->s.y, ARC.cw * c->s.scaleX, ARC.ch * c->s.scaleY)) continue; ARC.sel = i; // stessa numerazione della griglia (nella draft: la riga 0) if (c->arcana >= 0 && c->arcana == ARC.highlighted) ARC_confirm(); else ARC_selectCard(c); return 1; } if (ARC_hit(m, ARC.okX, ARC.okY, bw, bh)) { ARC_confirm(); return 1; } if (ARC.draft) { if (ARC.rerollsShown && ARC_hit(m, ARC.rndX, ARC.rndY, bw, bh)) { ARC_reroll(); return 1; } if (ARC_hit(m, ARC.skipX, ARC.skipY, bw, bh)) { ARC_skip(); return 1; } } else if (ARC_hit(m, ARC.rndX, ARC.rndY, bw, bh)) { ARC_randomClicked(); return 1; } return 0; } static void ARC_update(float delta) { ARC.t += delta; ARC_clock(delta); particles_manager_update(ARC.pfx, delta); for (int r = 0; r < ARC.n_rings; r++) // RotateAroundDistance(sprites, (0, 0), speed, radius) e angolo verso l'esterno for (int i = 0; i < ARC.rings[r].n; i++) { ArcCard *c = ARC.rings[r].c[i]; float a = atan2f(c->ry, c->rx) + ARC.rings[r].speed; c->rx = cosf(a) * ARC.rings[r].radius, c->ry = sinf(a) * ARC.rings[r].radius; c->s.angle = a * (180 / PI); } if (!ARC.inputEnabled && !ARC.randomDone && ARC.t >= 0x1f4) ARC.inputEnabled = 1; // StartEnableInputEvent: info, cursore, griglia if (ARC.t >= 0x1f4 && ARC.infoScale == 0) ARC_tween((TweenConfig){ .props = { { &ARC.infoScale, NULL, 1 } }, .nprops = 1, .duration = 0xc8 }), ARC.infoScale = 0.0001f; if (ARC.okOnly && ARC.okScale >= 2) ARC.inputEnabled = 1; if (!ARC.inputEnabled) return; if (ptr_pressed() && ARC_touch(menu_pointer())) return; int dx, dy, cols = ARC.draft ? 4 : 8, rows = 3; if (!ARC.okOnly && in_dir_pressed(&dx, &dy)) { // UI_overlayScene.UI_grid int c = ARC.sel % cols + dx, r = ARC.sel / cols + dy; if (c >= 0 && c < cols && r >= 0 && r < rows) ARC.sel = r * cols + c; } if (!in_confirm() && !getenv("VS_AUTOPICK")) return; if (ARC.okOnly) { ARC_confirm(); return; } int c = ARC.sel % cols, r = ARC.sel / cols; if (ARC.draft) { // 4 x 3: carte, Ok (o Reroll in fondo a destra), Skip if (r == 0) { if (c < ARC.n_cards) ARC_selectCard(ARC.cards[c]); if (getenv("VS_AUTOPICK")) ARC_confirm(); } else if (r == 1 && c == 3 && ARC.rerollsShown) ARC_reroll(); else if (r == 1) ARC_confirm(); else ARC_skip(); } else { int i = r * 8 + c; if (getenv("VS_AUTOPICK")) { ARC_confirm(); return; } if (i < ARC.n_cards) ARC_selectCard(ARC.cards[i]); else if (i == 22) ARC_randomClicked(); else ARC_confirm(); } } static void ARC_drawCard(const ArcCard *c, float ox, float oy, float cs) { Sprite s = c->s; s.x = ox + (c->rx ? c->rx * cs : 0) + (c->rx ? 0 : c->s.x), s.y = oy + (c->ry ? c->ry * cs : 0) + (c->ry ? 0 : c->s.y); s.scaleX *= cs, s.scaleY *= cs; scene_render_one(&s, (Shader){ 0 }); } static void ARC_infoPanel(float x, float y, float w, float h, float sc) { // CardInformationPanel: nome, descrizione, armi e oggetti collegati if (sc <= 0) return; int t = ARC.highlighted; rlPushMatrix(); rlTranslatef(x, y, 0); rlScalef(sc, sc, 1); nine("frame_purple.png", 12, (Rectangle){ 0, 0, w, h }, WHITE); int ok = t >= 0 && Arcana_unlocked(t) && !Arcana_hidden(t); char id[8]; snprintf(id, sizeof(id), "%d", t); cJSON *d = cJSON_GetObjectItem(data_get("arcana"), id); const char *nm = tr_of("arcanaLang", id, "name"), *ds = tr_of("arcanaLang", id, "description"); nm = ok ? (*nm ? nm : str(d, "name")) : "???"; ds = ok ? (*ds ? ds : str(d, "description")) : "???"; // Vita: scheda in colonna (carta, nome, descrizione a 20 px, poi le icone su piu' righe) float top = h >= 0x15e ? 0xbc : 0x34; // nella draft (scheda bassa) la carta grande e' gia' a sinistra: niente illustrazione if (top > 0x34) TS_frame("randomazzo", ok ? Arcana_frame(t) : "back.png", 0.5f * w, 0x50, 0.5f, 0.5f, 1.25f, 0, WHITE, 0); text_at(nm, 0.5f * w, top - 0x18, fit_size(nm, 26, w - 0x18), 0.5f, 0.5f, rgb(VUI_GOLD, 1)); float th = ui_wrap_text(ds, 0x10, top, 20, w - 0x20, h - top - 0x48, WHITE, 1); if (ok) { const char *ic[24]; int n = 0; cJSON *it; cJSON_ArrayForEach(it, cJSON_GetObjectItem(d, "weapons")) { cJSON *wd = cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("weapons"), it->valuestring), 0); if (wd && n < 24) ic[n++] = str(wd, "frameName"); } cJSON_ArrayForEach(it, cJSON_GetObjectItem(d, "items")) { cJSON *idd = cJSON_GetObjectItem(data_get("items"), it->valuestring); if (idd && n < 24) ic[n++] = str(idd, "frameName"); } // T10_BEGINNING: evoluzioni dell'arma iniziale; T08_MAD_FOREST: armi della mappa (personaggi e stage: F2 dopo) int per = (int)((w - 0x10) / 0x28); // icone a 0x28 di passo, a capo quando la riga e' piena for (int i = 0; i < n; i++) if (ic[i]) TS_frame("items", ic[i], 0x1c + i % per * 0x28, top + th + 0x18 + i / per * 0x28, 0.5f, 0.5f, 2, 0, WHITE, 0); } rlPopMatrix(); } static void ARC_button(const char *frame, float x, float y, float w, float h, float sc, const char *txt, float tsc) { if (sc <= 0) return; TS_nine(frame, 9, 14, x, y, w, h, sc, sc, 0, WHITE); if (txt) TS_text(txt, x, y, fit_size(txt, 16, 0xc8), tsc * sc / 2, 0, WHITE); } static void ARC_draw(void) { float t = ARC.t; DrawRectangle(0, 0, MENU_W, MENU_H, Fade(BLACK, ARC.blackAlpha)); particles_manager_draw(ARC.pfx); for (int r = 0; r < ARC.n_rings; r++) for (int i = 0; i < ARC.rings[r].n; i++) ARC_drawCard(ARC.rings[r].c[i], ARC.rings[r].x, ARC.rings[r].y, ARC.rings[r].cs); for (int i = 0; i < ARC.n_all; i++) { // strisce e carte del mazzo (fuori dagli anelli e dalla griglia) ArcCard *c = &ARC.all[i]; if (c->rx || c->ry) continue; int inGrid = 0; for (int k = 0; k < ARC.n_cards; k++) inGrid |= ARC.cards[k] == c; if (!inGrid && c->arcana == -1) ARC_drawCard(c, 0, 0, 1); } float cx = ARC.offX - 4 + 0.5f * ARC.bgW, cy = ARC.offY - 2 + 0.5f * ARC.bgH, ty = ARC.offY - 0x22; // Vita: centro della griglia, titolo sopra rlPushMatrix(); // AddTitleBackground + AddBackground (frame_purple) rlTranslatef(cx, ty, 0), rlRotatef(ARC.bgAngle, 0, 0, 1); nine("frame_purple.png", 12, (Rectangle){ -0.5f * (ARC.bgW - 8) * fabsf(ARC.bgScaleX), -0.5f * 0x30 * fabsf(ARC.bgScaleY), (ARC.bgW - 8) * fabsf(ARC.bgScaleX), 0x30 * fabsf(ARC.bgScaleY) }, WHITE); rlPopMatrix(); rlPushMatrix(); rlTranslatef(cx, cy, 0), rlRotatef(ARC.bgAngle, 0, 0, 1); nine("frame_purple.png", 12, (Rectangle){ -0.5f * ARC.bgW * fabsf(ARC.bgScaleX), -0.5f * ARC.bgH * fabsf(ARC.bgScaleY), ARC.bgW * fabsf(ARC.bgScaleX), ARC.bgH * fabsf(ARC.bgScaleY) }, WHITE); rlPopMatrix(); ARC_infoPanel(ARC_PANEL_X, ARC.offY - 0x3a, ARC_PANEL_W, ARC.draft ? ARC_MAZZO_Y - ARC.offY + 0x30 : 0x1b4, ARC.infoScale); const char *hd = tr("randomazzo_title"); // AddHeader text_at(hd, cx, ty, fit_size(hd, 30, 0x150), 0.5f, 0.5f, WHITE); if (!ARC.draft) { int tot = 0; for (int k = 0; k < 22; k++) tot += Arcana_major(k) && !Arcana_hidden(k); text_at(TextFormat("%d/%d", Arcana_unlockedCount(), tot), cx + 0.5f * ARC.bgW - 0x10, ty, 30, 1, 0.5f, WHITE); } TS_frame("items", "Tarots.png", cx - 0.5f * ARC.bgW + 0x10, ty, 0, 0.5f, 2, 0, WHITE, 0); for (int i = 0; i < ARC.n_cards; i++) ARC_drawCard(ARC.cards[i], 0, 0, 1); if (ARC.draft) { if (ARC.mazzoScaleY > 0) { // MazzoInGamePanel: le arcane gia' attive (Vita: in fila sotto la scheda) rlPushMatrix(); rlTranslatef(ARC_PANEL_X, ARC_MAZZO_Y, 0), rlScalef(1, ARC.mazzoScaleY, 1); nine("frame1_c2.png", 12, (Rectangle){ 0, 0, ARC_MAZZO_W, 0xb4 }, Fade(WHITE, 0.75f)); TS_frame("items", "Tarots.png", 0x18, 0x18, 0.5f, 0.5f, 2, 0, WHITE, 0); for (int i = Arcanas.n; i < 3; i++) TS_frame("randomazzo", "deback.png", ARC_MAZZO_W / 4 * (1 + i), 0x60, 0.5f, 0.5f, 1, 0, Fade(WHITE, 0.5f), 0); rlPopMatrix(); for (int i = 0; i < ARC.n_all; i++) if (ARC.all[i].arcana == -2) ARC_drawCard(&ARC.all[i], 0, 0, 1); } ARC_button("button_c5_normal.png", ARC.okX, ARC.okY, ARC.cw, 0.35f * ARC.ch, 2, tr("newItem_get"), 2); if (ARC.rerollsShown) { ARC_button("button_c9_normal.png", ARC.rndX, ARC.rndY, ARC.cw, 0.35f * ARC.ch, 2, NULL, 2); TS_text(tr("levelup_reroll"), ARC.rndX, ARC.rndY - 8, fit_size(tr("levelup_reroll"), 16, 0xc8), 2, 0, WHITE); const char *left = lang1("levelup_Xleft", TextFormat("%d", (int)Core.Player->rerolls)); TS_text(left, ARC.rndX, ARC.rndY + 0xc, fit_size(left, 16, 0xc8), 1, 0, WHITE); } ARC_button("button_c8_normal.png", ARC.skipX, ARC.skipY, ARC.cw, 0.35f * ARC.ch, 2, tr("levelup_skip"), 2); } else { ARC_button("button_c9_normal.png", ARC.rndX, ARC.rndY, 0.5f * ARC.cw, 0.35f * ARC.ch, ARC.okScale, "?", 1.5f); ARC_button("button_c5_normal.png", ARC.okX, ARC.okY, 0.5f * ARC.cw, 0.35f * ARC.ch, ARC.okScale, tr("newItem_get"), 1.5f); } if (ARC.inputEnabled) { // highlightCursor sulla carta evidenziata, frecce della griglia sulla cella selezionata for (int i = 0; i < ARC.n_cards; i++) if (ARC.cards[i]->arcana == ARC.highlighted && ARC.highlighted >= 0) { float w = ARC.draft ? 0x80 : 0x40, h = ARC.draft ? 0xb0 : 0x58; nine("selectionSquare_BG.png", 7, (Rectangle){ ARC.cards[i]->s.x - w / 2, ARC.cards[i]->s.y - h / 2, w, h }, WHITE); } int cols = ARC.draft ? 4 : 8, c = ARC.sel % cols, r = ARC.sel / cols; float ax, ay, hw; if (ARC.okOnly) ax = ARC.okX, ay = ARC.okY, hw = 0.5f * ARC.cw; else if (ARC.draft) { if (r == 0 && c < ARC.n_cards) ax = ARC.cards[c]->s.x, ay = ARC.cards[c]->s.y, hw = ARC.cw; else if (r == 1 && c == 3 && ARC.rerollsShown) ax = ARC.rndX, ay = ARC.rndY, hw = ARC.cw; else if (r == 1) ax = ARC.okX, ay = ARC.okY, hw = ARC.cw; else ax = ARC.skipX, ay = ARC.skipY, hw = ARC.cw; } else { int i = r * 8 + c; if (i < ARC.n_cards) ax = ARC.cards[i]->s.x, ay = ARC.cards[i]->s.y, hw = 0.5f * ARC.cw; else if (i == 22) ax = ARC.rndX, ay = ARC.rndY, hw = 0.5f * ARC.cw; else ax = ARC.okX, ay = ARC.okY, hw = 0.5f * ARC.cw; } ui_arrows(ax, ay, hw, t); } vui_prompt_bar(); } // ============================================================================ // 0xaefd: GameOverScene + 0x15aed: PostGameScene (risoluzione da menu, sopra la partita congelata) // Non ancora tradotti: achievement, PowerUp del negozio, arcane. // ============================================================================ static struct { int active, canSeeReviveButton, buttonsOn, rewardOn, sel; // sel: 0 QuitButton, 1 ReviveButton (UI_grid 1 x 2) float t, tButtons, tQuit, bonusFrom, tReward, tRevive; } GO; static struct { float totalCoins; int awardGivenXTimes; } GOS; // campi del costruttore della scena: restano tra un game over e l'altro static void text_at(const char *s, float x, float y, float size, float ox, float oy, Color c) { // Text con origine (ox, oy) Vector2 m = MeasureTextEx(vs_font, s, size, 0); DrawTextEx(vs_font, s, (Vector2){ roundf(x - ox * m.x), roundf(y - oy * m.y) }, size, 0, c); } static void ui_arrows(float x, float y, float halfW, float t) { // UI_overlayScene: frecce ai lati del selezionato char an[16]; snprintf(an, sizeof(an), "arrow_%02d.png", (int)(t / (1000.0f / 6)) % 8 + 1); TS_frame("UI", an, x - halfW, y, 1, 0.5f, 2, 0, WHITE, 0); const Frame *af = frame_get("UI", an); if (!af) return; Sprite a; sprite_init(&a, af, x + halfW, y); sprite_setOrigin(&a, 0, 0.5f); // flip sul posto: con 0 la freccia sta fuori dal bottone come quella a sinistra sprite_setScale(&a, 2); a.flipX = 1; a.scrollFactor0 = 1; scene_render_one(&a, (Shader){ 0 }); } // ============================================================================ // Menu (F3.1): la parte di gioco fuori dalla partita. Come le altre scene UI gira alla risoluzione da menu // (initialWidth x initialHeight = 1093 x 683, GET_RATIO 1) con le coordinate dell'originale. // ============================================================================ #define MASTER_SCALE 0.5f #define SAFE_L (0.5f * MENU_W - 256) // SAFEAREA: DEFAULT_WIDTH 512 centrato #define SAFE_R (0.5f * MENU_W + 256) #define SAFE_CX (0.5f * MENU_W) #define SAFE_CY (0.5f * MENU_H) #define SAFE_WIDTH 512.0f // NineSlice (phaser3-nineslice) con setScale/setOrigin; con onDown e' un bottone (setInteractive + 'pointerdown') typedef struct UIButton { const char *frame; int cw, ch; float x, y, w, h, sc, ox, oy; int visible, interactive; unsigned tint; void (*onDown)(void *ctx); void *ctx; } UIButton; static const struct { const char *key, *frame; int cw, ch; } UIFrames[] = { // 0xccae { "SelectionHighlightBG", "selectionSquare_BG.png", 7, 7 }, { "ProgressBox", "frameB9.png", 6, 6 }, { "MenuBackground", "frame5_c4.png", 12, 12 }, { "PanelBackgroundBlue", "frame1_c4.png", 12, 12 }, { "PanelBackground", "frame1_c2.png", 12, 12 }, { "PanelBorderOnly", "frame_empty.png", 12, 12 }, { "CardsBackground", "frame_purple.png", 12, 12 }, { "PanelBackgroundAdd", "frame5_c4_ad.png", 12, 12 }, { "GreenButton", "button_c5_normal.png", 9, 14 }, { "BackButton", "button_c8_normal.png", 9, 14 }, { "OptionsButton", "button_c9_normal.png", 9, 14 }, { "OptionsMiniButton", "button_c9_normal_mini.png", 9, 7 }, { "DisabledButton", "button_c9_desaturated.png", 9, 14 }, { "DisabledMiniButton", "button_c9_normal_mini_desaturated.png", 9, 7 }, { "Scrollbar", "sliderrail_c4.png", 4, 8 }, }; static void UIButton_set(UIButton *b, const char *key, float x, float y, float w, float h, float sc, float ox, float oy) { memset(b, 0, sizeof(*b)); for (size_t i = 0; i < sizeof(UIFrames) / sizeof(*UIFrames); i++) if (!strcmp(UIFrames[i].key, key)) b->frame = UIFrames[i].frame, b->cw = UIFrames[i].cw, b->ch = UIFrames[i].ch; b->x = x, b->y = y, b->w = w, b->h = h, b->sc = sc, b->ox = ox, b->oy = oy, b->visible = 1, b->tint = 0xffffff; } static float bW(const UIButton *b) { return b->w * b->sc; } static float bH(const UIButton *b) { return b->h * b->sc; } static float UI_left(const UIButton *b) { return b->x - b->ox * bW(b); } static float UI_top(const UIButton *b) { return b->y - b->oy * bH(b); } static void UIButton_draw(const UIButton *b, float alpha) { if (!b->visible || !b->frame) return; Color c = { (unsigned char)(b->tint >> 16), (unsigned char)(b->tint >> 8), (unsigned char)b->tint, (unsigned char)(255 * alpha) }; TS_nine(b->frame, b->cw, b->ch, UI_left(b) + 0.5f * bW(b), UI_top(b) + 0.5f * bH(b), b->w, b->h, b->sc, b->sc, 0, c); } static void UIButton_on(UIButton *b, void (*fn)(void *), void *ctx) { b->interactive = 1, b->onDown = fn, b->ctx = ctx; } // setInteractive + on('pointerdown') static void UIButton_off(UIButton *b) { b->interactive = 0, b->onDown = NULL; } // removeAllListeners // Text di Phaser (16 px di default) scalato e ridotto da Lang.scaleToMaxFast(text, false, maxW): maxW e' in pixel non scalati static void ui_text(const char *s, float x, float y, float scale, float maxW, float ox, float oy, Color c) { float size = 16 * scale; if (maxW > 0) size = fit_size(s, size, maxW * scale); text_at(s, x, y, size, ox, oy, c); } // Tocco/mouse: coordinate dello schermo -> coordinate del menu static float menu_scale(void) { return (float)SCREEN_H / MENU_H; } // ============================================================================ // UI per la Vita (non e' dell'originale): puntatore unico mouse/touch, cornice di selezione, simboli dei tasti, barra dei tasti // ============================================================================ static Color rgb(unsigned c, float a) { return (Color){ (unsigned char)(c >> 16), (unsigned char)(c >> 8), (unsigned char)c, (unsigned char)(255 * a) }; } // Il porting di raylib per la Vita non genera eventi mouse dal touch: il primo dito del pannello frontale fa da puntatore. static struct { int down, prev; Vector2 pos; } PT; static void ptr_update(void) { // una volta per frame, prima di ogni lettura PT.prev = PT.down; int touch = GetTouchPointCount() > 0; PT.down = touch || IsMouseButtonDown(MOUSE_BUTTON_LEFT); if (touch) PT.pos = GetTouchPosition(0); #ifndef __vita__ else PT.pos = GetMousePosition(); // sulla Vita al rilascio resta l'ultima posizione del dito #endif } static int ptr_pressed(void) { return PT.down && !PT.prev; } static int ptr_down(void) { return PT.down; } static int ptr_released(void) { return !PT.down && PT.prev; } enum { G_CROSS, G_CIRCLE, G_TRIANGLE, G_SQUARE, G_L, G_R, G_START }; typedef struct { int glyph; const char *label; } VPrompt; static VPrompt VUI_prompts[6]; static int VUI_np; // I simboli dei tasti sono di Wolff (WolffsRoom), disegnati per stare nello stile del gioco: pixel netti, scala 2 static Texture2D vui_glyph_tex(int g) { static Texture2D T[G_START + 1]; static const char *const F[G_START + 1] = { [G_CROSS] = "cross_0", [G_CIRCLE] = "circle_0", [G_SQUARE] = "square_0", [G_TRIANGLE] = "triangle_0", [G_L] = "L", [G_R] = "R", [G_START] = "start" }; if (!T[g].id) { T[g] = LoadTexture(vs_asset(TextFormat(g >= G_L && g != G_START ? "glyphs/button_psv_%s.png" : "glyphs/button_ps4_%s.png", F[g]))); SetTextureFilter(T[g], TEXTURE_FILTER_POINT); } return T[g]; } static float vui_glyph_w(int g) { return 2.0f * vui_glyph_tex(g).width; } static double vui_hit_at[G_START + 1]; // ultimo colpo (pad o tocco): l'effetto dura VUI_HIT_S anche se il gioco risponde subito #define VUI_HIT_S 0.18 static float vui_glyph_hit(int g) { // 1 appena premuto -> 0 dopo VUI_HIT_S static const int B[G_START + 1] = { [G_CROSS] = GAMEPAD_BUTTON_RIGHT_FACE_DOWN, [G_CIRCLE] = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT, [G_SQUARE] = GAMEPAD_BUTTON_RIGHT_FACE_LEFT, [G_TRIANGLE] = GAMEPAD_BUTTON_RIGHT_FACE_UP, [G_L] = GAMEPAD_BUTTON_LEFT_TRIGGER_1, [G_R] = GAMEPAD_BUTTON_RIGHT_TRIGGER_1, [G_START] = GAMEPAD_BUTTON_MIDDLE_RIGHT }; if (IsGamepadAvailable(0) && IsGamepadButtonDown(0, B[g])) vui_hit_at[g] = GetTime(); float k = 1 - (float)((GetTime() - vui_hit_at[g]) / VUI_HIT_S); return vui_hit_at[g] > 0 && k > 0 ? k : 0; } static void vui_glyph(int g, float cx, float cy, float r) { (void)r; Texture2D t = vui_glyph_tex(g); float k = vui_glyph_hit(g), s = 2.0f * (1 - 0.12f * k), w = s * t.width, h = s * t.height; unsigned char c = (unsigned char)(255 - (255 - 0x8c) * k); Rectangle src = { 0, 0, t.width, t.height }, dst = { roundf(cx - 0.5f * w), roundf(cy - 0.5f * h), w, h }; DrawTexturePro(t, src, (Rectangle){ dst.x + 2, dst.y + 2, w, h }, (Vector2){ 0, 0 }, 0, Fade(BLACK, 0.7f)); DrawTexturePro(t, src, dst, (Vector2){ 0, 0 }, 0, (Color){ c, c, c, 255 }); } static const char *vui_tr(const char *k) { // le scritte della barra dei tasti (non sono nell'originale): port_lang.h, poi Lang const char *s = port_tr(k); return s != k ? s : tr(k); } static Rectangle VUI_hit[6]; static void vui_set_prompts(const VPrompt *p, int n) { VUI_np = n < 6 ? n : 6; memcpy(VUI_prompts, p, VUI_np * sizeof(*p)); } static void vui_prompt_select(void) { vui_set_prompts((VPrompt[]){ { G_CROSS, "vui_select" } }, 1); } static void vui_prompts_clear(void) { VUI_np = 0; } static void vui_prompt_bar(void) { // i tasti in basso, al centro, con un'ombra al posto della barra if (!VUI_np) return; float total = 0, cy = MENU_H - 22; for (int i = 0; i < VUI_np; i++) total += vui_glyph_w(VUI_prompts[i].glyph) + 8 + MeasureTextEx(vs_font, vui_tr(VUI_prompts[i].label), 22, 0).x + (i ? 30 : 0); float x = 0.5f * (MENU_W - total); for (int i = 0; i < VUI_np; i++) { const char *l = vui_tr(VUI_prompts[i].label); float gw = vui_glyph_w(VUI_prompts[i].glyph), lw = MeasureTextEx(vs_font, l, 22, 0).x; vui_glyph(VUI_prompts[i].glyph, x + 0.5f * gw, cy, 0); text_at(l, x + gw + 10, cy + 2, 22, 0, 0.5f, Fade(BLACK, 0.8f)); text_at(l, x + gw + 8, cy, 22, 0, 0.5f, (Color){ 0xe9, 0xe2, 0xd4, 255 }); VUI_hit[i] = (Rectangle){ x - 6, MENU_H - 44, gw + 8 + lw + 12, 44 }; x += gw + 8 + lw + 30; } } static void nine_wh(const char *frame, int cw, int ch, Rectangle r, Color tint); static void vui_focus(Rectangle r, float t) { // alone oro pulsante + le staffe gialle del cursore di VS attorno al selezionato float a = 0.7f + 0.3f * sinf(t * 0.0063f); DrawRectangleRec(r, rgb(0xfff3b0, 0.12f * a)); // velo chiaro sul selezionato for (int i = 3; i >= 1; i--) DrawRectangleLinesEx((Rectangle){ r.x - 3 - 3 * i, r.y - 3 - 3 * i, r.width + 6 + 6 * i, r.height + 6 + 6 * i }, 3, rgb(0xffd23a, 0.3f * a / i)); Color w = ColorLerp(WHITE, rgb(0xffc21a, 1), 0.5f + 0.5f * sinf(t * 0.0063f)); // dal bianco all'oro: stacca da qualunque bordo dorato DrawRectangleLinesEx((Rectangle){ r.x - 4, r.y - 4, r.width + 8, r.height + 8 }, 4, w); rlPushMatrix(); rlTranslatef(r.x - 8, r.y - 8, 0); rlScalef(2, 2, 1); nine_wh("selectionSquareActive_03.png", 7, 7, (Rectangle){ 0, 0, 0.5f * r.width + 8, 0.5f * r.height + 8 }, WHITE); rlPopMatrix(); } static Vector2 menu_pointer(void) { Vector2 m = PT.pos; float ms = menu_scale(); return (Vector2){ (m.x - (SCREEN_W - MENU_W * ms) / 2) / ms, m.y / ms }; } static int UIButton_hit(const UIButton *b, Vector2 p) { return b->visible && b->interactive && p.x >= UI_left(b) && p.x < UI_left(b) + bW(b) && p.y >= UI_top(b) && p.y < UI_top(b) + bH(b); } static int UIButton_clicked(UIButton *b) { // 'pointerdown' sul bottone: chiama onDown if (!ptr_pressed() || !UIButton_hit(b, menu_pointer())) return 0; if (b->onDown) b->onDown(b->ctx); return 1; } // ============================================================================ // 0xf6b5: UIGrid + 0x17737: UI_overlayScene (navigazione con tastiera e pad, frecce sul selezionato) // ============================================================================ #define GRID_MAX 512 // la Collezione degli achievement: 2 x 151 static struct { struct { UIButton *go; int isLink; } grid[GRID_MAX]; int width, height, wrap, cx, cy, on; UIButton *currentGameObject, *previousGameObject; void (*onLeft)(UIButton *), (*onRight)(UIButton *); } UIGrid; static struct { UIButton *UI_selected; int blockInput, blockWASD, cursorsVisible; void (*OnSubmitCallback)(void), (*OnCancelCallback)(void); void (*OnTriangle)(void), (*OnSquare)(void), (*OnL)(void), (*OnR)(void), (*OnStart)(void); // Vita: triangolo, quadrato, L, R, START float timeDown[10]; // CheckButtonPad: -inputDelayPad all'inizio float keyHeld[8], keyTick[8]; float t; // tempo delle frecce animate } OV = { .timeDown = { -0xc8, -0xc8, -0xc8, -0xc8, -0xc8, -0xc8, -0xc8, -0xc8, -0xc8, -0xc8 } }; static UIButton *UIGrid_GetCurrent(void) { UIGrid.previousGameObject = UIGrid.currentGameObject; int x = UIGrid.cx, y = UIGrid.cy * UIGrid.width; if (x + y < GRID_MAX && UIGrid.grid[x + y].isLink) { UIButton *go = UIGrid.grid[x + y].go; int i = 0; while (i < UIGrid.width * UIGrid.height && !(UIGrid.grid[i].go == go && !UIGrid.grid[i].isLink)) i++; x = i % UIGrid.width, y = i / UIGrid.height; // (sic) Math.floor(i / height), poi usato come riga * width UIGrid.cx = x, UIGrid.cy = y; } UIButton *go = x + y >= 0 && x + y < GRID_MAX ? UIGrid.grid[x + y].go : NULL; UIGrid.currentGameObject = go ? go : UIGrid.currentGameObject; return go; } static void UIGrid_Init(int w, int h) { memset(UIGrid.grid, 0, sizeof(UIGrid.grid)); UIGrid.width = w, UIGrid.height = h, UIGrid.cx = UIGrid.cy = 0; UIGrid.currentGameObject = UIGrid.previousGameObject = NULL; UIGrid.onLeft = UIGrid.onRight = NULL; } static void UIGrid_SetContents(int x, int y, UIButton *go, int isLink) { if (x + y * UIGrid.width >= UIGrid.width * UIGrid.height || x + y * UIGrid.width >= GRID_MAX) { TraceLog(LOG_WARNING, "VS: Invalid UI slot: %d,%d", x, y); return; } UIGrid.grid[x + y * UIGrid.width].go = go, UIGrid.grid[x + y * UIGrid.width].isLink = isLink; } static UIButton *UIGrid_SelectGameObject(UIButton *go) { UIGrid.previousGameObject = UIGrid.currentGameObject; int found = -1; for (int i = 0; i < UIGrid.width * UIGrid.height; i++) if (UIGrid.grid[i].go == go && !UIGrid.grid[i].isLink) found = i; // l'ultimo vince (sic) if (found < 0) { TraceLog(LOG_WARNING, "VS: GameObject not found in UI grid"); return NULL; } UIGrid.cx = found % UIGrid.width, UIGrid.cy = found / UIGrid.width; return UIGrid.currentGameObject = go; } static UIButton *UIGrid_SelectAt(int x, int y) { if (x + y * UIGrid.width >= UIGrid.width * UIGrid.height) return NULL; UIGrid.cx = x, UIGrid.cy = y; return UIGrid_GetCurrent(); } static UIButton *UIGrid_Go(int dx, int dy) { // GoLeft/GoRight/GoUp/GoDown if (dx < 0 && UIGrid.onLeft) UIGrid.onLeft(UIGrid_GetCurrent()); if (dx > 0 && UIGrid.onRight) UIGrid.onRight(UIGrid_GetCurrent()); int *c = dx ? &UIGrid.cx : &UIGrid.cy, n = dx ? UIGrid.width : UIGrid.height, old = *c; *c += dx ? dx : dy; if (*c < 0) *c = UIGrid.wrap ? n - 1 : 0; if (*c > n - 1) *c = UIGrid.wrap ? 0 : n - 1; for (int i = 0; i < n; i++) { // Vita: le celle vuote si scavalcano (menu principale senza Bestiario/Segreti: Credits e CO-OP) UIButton *g = UIGrid_GetCurrent(); if (g) return g; int e = *c + (dx ? dx : dy); if (e < 0 || e > n - 1) { if (!UIGrid.wrap) break; e = e < 0 ? n - 1 : 0; } *c = e; } *c = old; return UIGrid.currentGameObject; } static void Overlay_ToggleCursorsVisibility(int v) { OV.cursorsVisible = v; } static void Overlay_MakeUIGrid(int w, int h, int wrap) { UIGrid_Init(w, h); UIGrid.wrap = wrap, UIGrid.on = 1; OV.UI_selected = NULL; } static void Overlay_DestroyGrid(void) { UIGrid.on = 0, OV.UI_selected = NULL; Overlay_ToggleCursorsVisibility(0); OV.OnSubmitCallback = OV.OnCancelCallback = NULL; OV.OnTriangle = OV.OnSquare = OV.OnL = OV.OnR = OV.OnStart = NULL, VUI_np = 0; } LATER static void Overlay_lock(void) { OV.blockInput = 1; Overlay_ToggleCursorsVisibility(0); } LATER static void Overlay_unlock(void) { OV.blockInput = 0; Overlay_ToggleCursorsVisibility(1); } static void Overlay_OnSubmitPressed(void) { if (OV.UI_selected && OV.UI_selected->onDown) OV.UI_selected->onDown(OV.UI_selected->ctx); // UI_selected._events.pointerdown.fn() if (OV.OnSubmitCallback) OV.OnSubmitCallback(); } static void Overlay_OnCancelPressed(void) { if (OV.OnCancelCallback) OV.OnCancelCallback(); } static int Overlay_checkDown(int key, int i, float delta) { // KeyboardPlugin.checkDown(key, inputDelay 250): subito, poi ogni 250 ms if (!IsKeyDown(key)) { OV.keyHeld[i] = 0, OV.keyTick[i] = -1; return 0; } float s = floorf(OV.keyHeld[i] / 0xfa) * 0xfa; OV.keyHeld[i] += delta; if (s > OV.keyTick[i]) { OV.keyTick[i] = s; return 1; } return 0; } static void Overlay_CheckButtonPad(int i, float delta, int down, int dx, int dy, void (*fn)(void)) { if (down && OV.timeDown[i] >= 0xc8) { if (fn) fn(); else { UIButton *g = UIGrid.on ? UIGrid_Go(dx, dy) : NULL; if (g) OV.UI_selected = g; } OV.timeDown[i] = 0; } OV.timeDown[i] += delta; } static void vui_press(int g) { // un simbolo della barra toccato = quel tasto vui_hit_at[g] = GetTime(); if (g == G_CROSS) Overlay_OnSubmitPressed(); else if (g == G_CIRCLE) Overlay_OnCancelPressed(); else if (g == G_TRIANGLE && OV.OnTriangle) OV.OnTriangle(); else if (g == G_SQUARE && OV.OnSquare) OV.OnSquare(); else if (g == G_L && OV.OnL) OV.OnL(); else if (g == G_R && OV.OnR) OV.OnR(); else if (g == G_START && OV.OnStart) OV.OnStart(); } static int vui_prompt_touch(Vector2 m) { // 1 se il tocco era sulla barra dei tasti if (!VUI_np || m.y < MENU_H - 44) return 0; for (int i = 0; i < VUI_np; i++) if (CheckCollisionPointRec(m, VUI_hit[i])) { vui_press(VUI_prompts[i].glyph); break; } return 1; } static void Overlay_update(float delta) { OV.t += delta; // tasti one-shot: ESC annulla, SPACE e ENTER confermano if (IsKeyPressed(KEY_ESCAPE)) Overlay_OnCancelPressed(); if (IsKeyPressed(KEY_SPACE)) Overlay_OnSubmitPressed(); if (IsKeyPressed(KEY_ENTER) && !IsKeyDown(KEY_LEFT_ALT) && !IsKeyDown(KEY_RIGHT_ALT)) Overlay_OnSubmitPressed(); if (OV.blockInput || !UIGrid.on) return; int pad = IsGamepadAvailable(0); // Vita: triangolo, quadrato, L, R, START (sul desktop F1-F5) if (OV.OnTriangle && (IsKeyPressed(KEY_F1) || (pad && IsGamepadButtonPressed(0, GAMEPAD_BUTTON_RIGHT_FACE_UP)))) OV.OnTriangle(); else if (OV.OnSquare && (IsKeyPressed(KEY_F2) || (pad && IsGamepadButtonPressed(0, GAMEPAD_BUTTON_RIGHT_FACE_LEFT)))) OV.OnSquare(); else if (OV.OnL && (IsKeyPressed(KEY_F3) || (pad && IsGamepadButtonPressed(0, GAMEPAD_BUTTON_LEFT_TRIGGER_1)))) OV.OnL(); else if (OV.OnR && (IsKeyPressed(KEY_F4) || (pad && IsGamepadButtonPressed(0, GAMEPAD_BUTTON_RIGHT_TRIGGER_1)))) OV.OnR(); else if (OV.OnStart && (IsKeyPressed(KEY_F5) || (pad && IsGamepadButtonPressed(0, GAMEPAD_BUTTON_MIDDLE_RIGHT)))) OV.OnStart(); if (OV.blockInput || !UIGrid.on) return; // updateCursors int l = Overlay_checkDown(KEY_LEFT, 0, delta), r = Overlay_checkDown(KEY_RIGHT, 1, delta), a = Overlay_checkDown(KEY_A, 2, delta), d = Overlay_checkDown(KEY_D, 3, delta); if (l) OV.UI_selected = UIGrid_Go(-1, 0); else if (r) OV.UI_selected = UIGrid_Go(1, 0); else if (a) { if (!OV.blockWASD) OV.UI_selected = UIGrid_Go(-1, 0); } else if (d) { if (!OV.blockWASD) OV.UI_selected = UIGrid_Go(1, 0); } int u = Overlay_checkDown(KEY_UP, 4, delta), dn = Overlay_checkDown(KEY_DOWN, 5, delta), w = Overlay_checkDown(KEY_W, 6, delta), s = Overlay_checkDown(KEY_S, 7, delta); if (u) OV.UI_selected = UIGrid_Go(0, -1); else if (dn) OV.UI_selected = UIGrid_Go(0, 1); else if (w) { if (!OV.blockWASD) OV.UI_selected = UIGrid_Go(0, -1); } else if (s) { if (!OV.blockWASD) OV.UI_selected = UIGrid_Go(0, 1); } // updateController if (IsGamepadAvailable(0) && UIGrid.on) { float sx = GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_X), sy = GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_Y); // in coop l'asse arriva dalla rete gia' fuso col D-pad (Player_localMove): contato due volte saltava un'opzione if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_LEFT) || IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_RIGHT) || IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_UP) || IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_DOWN)) sx = sy = 0; Overlay_CheckButtonPad(0, delta, IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_LEFT), -1, 0, NULL); Overlay_CheckButtonPad(1, delta, IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_RIGHT), 1, 0, NULL); Overlay_CheckButtonPad(2, delta, IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_UP), 0, -1, NULL); Overlay_CheckButtonPad(3, delta, IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_DOWN), 0, 1, NULL); Overlay_CheckButtonPad(4, delta, IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_FACE_DOWN), 0, 0, Overlay_OnSubmitPressed); // A (croce) Overlay_CheckButtonPad(5, delta, IsGamepadButtonDown(0, GAMEPAD_BUTTON_RIGHT_FACE_RIGHT), 0, 0, Overlay_OnCancelPressed); // B (cerchio) if (UIGrid.on) Overlay_CheckButtonPad(6, delta, sx < -0.78f, -1, 0, NULL); if (UIGrid.on) Overlay_CheckButtonPad(7, delta, sx > 0.78f, 1, 0, NULL); if (UIGrid.on) Overlay_CheckButtonPad(8, delta, sy < -0.78f, 0, -1, NULL); if (UIGrid.on) Overlay_CheckButtonPad(9, delta, sy > 0.78f, 0, 1, NULL); } } static void Overlay_draw(void) { // HighlightButton if (!OV.UI_selected) return; if (!OV.cursorsVisible || OV.blockInput) return; UIButton *b = OV.UI_selected; if (bW(b) > 500) vui_focus((Rectangle){ UI_left(b), UI_top(b), bW(b), bH(b) }, OV.t); // righe larghe (Opzioni): le frecce uscirebbero dallo schermo else ui_arrows(UI_left(b) + 0.5f * bW(b), UI_top(b) + 0.5f * bH(b), 0.5f * bW(b) + 8, OV.t); } // Testo con a capo (wordWrap.width) ridotto da scaleToMaxFast(text, false, maxW, maxH); restituisce l'altezza static float ui_wrap_text(const char *s, float x, float y, float size, float wrapW, float maxH, Color c, int draw) { char lines[16][256]; int n = 0; const char *p = s; while (*p && n < 16) { // a capo sulle parole, poi sui \n char *L = lines[n]; L[0] = 0; while (*p && *p != '\n') { const char *w = p; while (*w == ' ') w++; const char *e = w; while (*e && *e != ' ' && *e != '\n') e++; char t[256]; snprintf(t, sizeof(t), "%s%.*s", L, (int)(e - p), p); if (*L && MeasureTextEx(vs_font, t, size, 0).x > wrapW) { p = w; break; } snprintf(L, 256, "%s", t); p = e; } if (*p == '\n') p++; n++; } float lh = size * 1.15f, h = n * lh, k = maxH > 0 && h > maxH ? maxH / h : 1; if (draw) for (int i = 0; i < n; i++) text_at(lines[i], x, y + i * lh * k, size * k, 0, 0, c); return h * k; } // Ritaglio (GeometryMask rettangolare) in coordinate del menu static void menu_clip(float x, float y, float w, float h) { float ms = menu_scale(), x0 = (SCREEN_W - MENU_W * ms) / 2; BeginScissorMode((int)(x0 + x * ms), (int)(y * ms), (int)(w * ms), (int)(h * ms)); } static void menu_unclip(void) { float ms = menu_scale(), mw = MENU_W * ms; BeginScissorMode((int)((SCREEN_W - mw) / 2), 0, (int)mw, SCREEN_H); } static void ui_text_lines(const char *s, float x, float y, float size, Color c) { // Text multiriga, align 'center', origine (0.5, 0.5) char b[512]; snprintf(b, sizeof(b), "%s", s); int n = 1; for (char *p = b; *p; p++) n += *p == '\n'; float lh = size * 1.15f, y0 = y - 0.5f * n * lh; char *line = strtok(b, "\n"); for (int i = 0; line; i++, line = strtok(NULL, "\n")) text_at(line, x, y0 + i * lh, size, 0.5f, 0, c); } static const char *char_text(const char *id, const char *field) { // charName/surname/description/prefix localizzati (Lang.localiseObject) const char *s = tr_of("characterLang", id, field); return *s ? s : str(tbl0("characters", id), field) ? str(tbl0("characters", id), field) : ""; } static struct { int active, done, isShowingAchievements; float t, tQuit; UIButton QuitButton, AchiButton; } PG; // this.achievements nasce nel costruttore della scena, che Phaser riusa: (sic) si accumula fra una partita e l'altra static const char *PG_achievements[512]; static int PG_nAch; static float StageTimeLimit(void) { float tl = num(cJSON_GetObjectItem(cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("stages"), Core.Stage->stageType), 0), "mods"), "TimeLimit", 0); return tl ? tl : 0x708; } // Player.Revive (0x869f): la tinta e l'oscillazione lasciate dall'animazione di morte restano come nell'originale static void Player_Revive(Player *p, float k) { p->isDead = 0; p->s.body.enable = 1; sprite_setScale(&p->s, PixelScale); Player_RecoverHp(p, p->maxHp * k, 0, 0); Player_SetInvulForMilliSeconds(p, 0x7d0); p->hasLastBreath = 1; PlayerUI_Update(); if (Player_is(p, "PAVONE")) Core_RosaryDamage(); // 0x14f3e if (Player_is(p, "LUMINAIRE")) Lum_Revive(p); } // ============================================================================ // 0xc450: AchievementManager (achievement e segreti sbloccati a fine partita; i premi: armi, personaggi, stage, // hyper, reliquie, monete, ranghi dei potenziamenti, arcane). CheckAchievements_Moonspell/Foscari: DLC, F5 // ============================================================================ static const char *AM_NewAchievements[160], *AM_NewSecrets[128]; static int AM_nNew, AM_nNewSecrets; static double killed(const char *e) { return num(tbl0("enemies", e), "killedAmount", 0); } static double pickedAmount(const char *i) { return num(cJSON_GetObjectItem(data_get("items"), i), "pickedupAmount", 0); } static int hasItem(const char *i) { return po_has("CollectedItems", i); } static int stageIs(const char *s) { return po_str("SelectedStage") && !strcmp(po_str("SelectedStage"), s); } static int charIs(const char *c) { return Core.Player && !strcmp(Core.Player->characterType, c); } static int weaponLv(const char *t, int lv) { Weapon *w = Core_GetWeapon(t); return w && w->level >= lv; } static void AM_grant(cJSON *a) { // i premi comuni di UnlockAchievement / UnlockSecret const char *w = str(a, "weaponToUnlock"), *c = str(a, "characterToUnlock"), *st = str(a, "stageToUnlock"), *hy = str(a, "hyperToUnlock"), *r = str(a, "relicToUnlock"), *pu = str(a, "powerUpToUnlock"); if (w) { if (!po_has("UnlockedWeapons", w)) po_push("UnlockedWeapons", w); obj_set(tbl0("weapons", w), "isUnlocked", cJSON_CreateTrue()); } if (c) { if (!po_has("UnlockedCharacters", c)) po_push("UnlockedCharacters", c); obj_set(tbl0("characters", c), "hidden", cJSON_CreateFalse()); } if (st) { if (!po_has("UnlockedStages", st)) po_push("UnlockedStages", st); obj_set(tbl0("stages", st), "unlocked", cJSON_CreateTrue()), obj_set(tbl0("stages", st), "hidden", cJSON_CreateFalse()); } if (hy) { if (!po_has("UnlockedHypers", hy)) po_push("UnlockedHypers", hy); obj_set(cJSON_GetObjectItem(tbl0("stages", hy), "hyper"), "unlocked", cJSON_CreateTrue()); } if (r) { if (!hasItem(r)) po_push("CollectedItems", r); obj_set(cJSON_GetObjectItem(data_get("items"), r), "seen", cJSON_CreateTrue()); } if (num(a, "goldPrize", 0)) PlayerOptions_AddCoinsFlat(num(a, "goldPrize", 0)); if (pu) { po_push("UnlockedPowerUpRanks", pu); cJSON *p = tbl0("powerups", pu); obj_set(p, "hidden", cJSON_CreateFalse()), obj_set(p, "unlockedRank", cJSON_CreateNumber(num(p, "unlockedRank", 0) + 1)); } cJSON *ar = cJSON_GetObjectItem(a, "arcanaToUnlock"); if (cJSON_IsNumber(ar) && ar->valuedouble >= 0) { char b[16]; snprintf(b, sizeof(b), "%d", ar->valueint); if (!po_has("UnlockedArcanas", b)) cJSON_AddItemToArray(po("UnlockedArcanas"), cJSON_CreateNumber(ar->valueint)); obj_set(tbl0("arcana", b), "unlocked", cJSON_CreateTrue()); } } static void AchievementManager_UnlockAchievement(const char *k) { cJSON *a = cJSON_GetObjectItem(data_get("achievements"), k); if (!a) { TraceLog(LOG_INFO, "VS: %s", k); return; } if (cJSON_IsTrue(cJSON_GetObjectItem(a, "achieved"))) return; obj_set(a, "achieved", cJSON_CreateTrue()); trophies_unlock(k); AM_grant(a); // (sic) qui le armi restano hidden; UnlockSecret le mostra if (!po_has("Achievements", k)) po_push("Achievements", k); if (AM_nNew < 160) AM_NewAchievements[AM_nNew++] = cJSON_GetObjectItem(data_get("achievements"), k)->string; } static int AchievementManager_UnlockSecret(const char *k) { cJSON *s = cJSON_GetObjectItem(data_get("secrets"), k); if (!s || cJSON_IsTrue(cJSON_GetObjectItem(s, "achieved"))) return 0; obj_set(s, "achieved", cJSON_CreateTrue()); const char *w = str(s, "weaponToUnlock"); AM_grant(s); if (w) obj_set(tbl0("weapons", w), "hidden", cJSON_CreateFalse()); if (!po_has("Secrets", k)) po_push("Secrets", k); if (AM_nNewSecrets < 128) AM_NewSecrets[AM_nNewSecrets++] = s->string; PlayerOptions_Save(); return 1; } LATER static int AchievementManager_HasUnlockedAchievement(const char *k) { return cJSON_IsTrue(cJSON_GetObjectItem(cJSON_GetObjectItem(data_get("achievements"), k), "achieved")); } #define U AchievementManager_UnlockAchievement static int AchievementManager_CheckForStage6Achievement(void) { static const char *const R[] = { "FindGrimoire", "FindMilkyWayMap", "FindGouda", "FindRandomazzo", "FindSorceressTears", "FindGGospel", "BuyGlassMask", "FindMagicBanger", "FindForbiddenScroll" }; int n = 0; for (int i = 0; i < 9 && po_has("Achievements", R[i]); i++) n++; if (n < 9) return 0; U("ObtainAllRelics"); return 1; } static void AchievementManager_RestoreAchievementUnlocks(void) { // all'avvio: i premi degli achievement gia' ottenuti (non monete e ranghi) cJSON *a; cJSON_ArrayForEach(a, data_get("achievements")) if (cJSON_IsTrue(cJSON_GetObjectItem(a, "achieved")) && !num(a, "goldPrize", 0) && !str(a, "powerUpToUnlock")) obj_set(a, "achieved", cJSON_CreateFalse()), U(a->string); } static void AchievementManager_CheckForStartupAchievements(void) { if (hasItem("RELIC_YELLOW")) U("FindYellowSign"); // + Integration.UnlockAchievement (Steam) AchievementManager_CheckForStage6Achievement(); if (hasItem("RELIC_TRUMPET")) U("ObtainSeventhTrumpet"); if (hasItem("RELIC_MIRROR")) U("ObtainGraciasMirror"); if (po_has("Achievements", "See50Items") && !hasItem("RELIC_NOSEGLASSES")) po_push("CollectedItems", "RELIC_NOSEGLASSES"); if (po_has("Achievements", "FindYellowSignS5") && !po_has("UnlockedStages", "CHAPEL")) po_push("UnlockedStages", "CHAPEL"); } static int AchievementManager_CheckSigmaUnlock(void) { static const char *const W[] = { "MAGIC_MISSILE", "HOLY_MISSILE", "WHIP", "VAMPIRICA", "AXE", "SCYTHE", "KNIFE", "THOUSAND", "HOLYWATER", "BORA", "DIAMOND", "ROCHER", "FIREBALL", "HELLFIRE", "HOLYBOOK", "VESPERS", "CROSS", "HEAVENSWORD", "GARLIC", "VORTEX", "LAUREL", "SHROUD", "LIGHTNING", "LOOP", "PENTAGRAM", "SIRE", "SILF", "SILF2", "SILF3", "SILF_COUNTER", "SILF2_COUNTER", "BONE", "LANCET", "CORRIDOR", "SONG", "MANNAGGIA", "CHERRY", "CART2", "GATTI", "GATTI_COUNTER", "STIGRANGATTI", "FLOWER", "LAROBBA", "CANDYBOX", "GUNS", "GUNS2", "GUNS3", "GUNS_COUNTER", "GUNS2_COUNTER", "TRAPANO", "TRAPANO2", "VENTO", "VENTO2", "TRIASSO1", "TRIASSO2", "TRIASSO3", "POWER", "AREA", "SPEED", "COOLDOWN", "DURATION", "AMOUNT", "MAXHEALTH", "ARMOR", "MOVESPEED", "MAGNET", "GROWTH", "LUCK", "GREED", "REVIVAL", "REGEN", "CURSE", "SILVER", "GOLD", "LEFT", "RIGHT", "PANDORA", "JUBILEE" }; static const char *const I[] = { "COINBAG1", "COINBAGMAX", "CLOVER", "GILDED", "ROSARY", "VACUUM", "OROLOGION", "ROAST", "NFT", "TREASURE", "RELIC_BANGER", "RELIC_MAP", "RELIC_TEAR", "RELIC_RANDOMAZZO", "RELIC_GLASSMASK", "RELIC_GOLDENEGG", "RELIC_YELLOW", "RELIC_NOSEGLASSES", "RELIC_GRIMOIRE", "RELIC_SECRETS", "RELIC_GOUDA", "RELIC_GGOSPEL", "RELIC_MIRROR", "RELIC_TRUMPET" }; for (size_t i = 0; i < sizeof(W) / sizeof(*W); i++) { cJSON *w = tbl0("weapons", W[i]); if (w && !cJSON_IsTrue(cJSON_GetObjectItem(w, "seen"))) return 0; } for (size_t i = 0; i < sizeof(I) / sizeof(*I); i++) { cJSON *it = cJSON_GetObjectItem(data_get("items"), I[i]); if (it && !cJSON_IsTrue(cJSON_GetObjectItem(it, "seen"))) return 0; } for (int i = 0; i <= 21; i++) { char b[8]; snprintf(b, sizeof(b), "%d", i); cJSON *a = tbl0("arcana", b); if (a && !cJSON_IsTrue(cJSON_GetObjectItem(a, "unlocked"))) return 0; } return 1; } static int GetValidUnlockedHypers(void) { // Stage.GetValidUnlockedHypers().length static const char *const H[] = { "FOREST", "LIBRARY", "WAREHOUSE", "TOWER", "CHAPEL" }; int n = 0; cJSON *v; cJSON_ArrayForEach(v, po("UnlockedHypers")) for (int i = 0; i < 5; i++) n += cJSON_IsString(v) && !strcmp(v->valuestring, H[i]); return n; } static int AM_isEvolution(Weapon *w) { return cJSON_IsTrue(cJSON_GetObjectItem(tbl0("weapons", w->bulletType), "isEvolution")); } static void AchievementManager_GetNewAchievementsEarnedOnThisRun(void) { AM_nNew = 0; Player *p = Core.Player; int lvl = p->level, secs = Core.SurvivedSeconds; double total = 0; cJSON *e; cJSON_ArrayForEach(e, data_get("enemies")) { double k = num(cJSON_GetArrayItem(e, 0), "killedAmount", 0); if (k > 0) total += k; if (total >= 0x1388) U("Defeat5000Enemies"); if (total >= 0x186a0) { U("Defeat100KEnemies"); break; } } if (killed("SKELETON") >= 0xbb8) U("Defeat3000Skeletons"); if (killed("BUER") >= 0xbb8) U("Defeat3000Buers"); if (killed("MILK") >= 0xbb8) U("Defeat3000Milk"); if (killed("XLDRAGON1") + killed("XLDRAGON1_FLAG") + killed("XLDRAGON2") + killed("XLDRAGON2_FLAG") >= 0xbb8) U("Defeat3000Hydra"); if (killed("STAGEKILLER") + killed("STAGEKILLER2") + po_num("LifetimeSurvived") / 0x708 >= 0x1770) U("Defeat6000StageKillers"); if (killed("BOSS_XLFLOWER") >= 1 && stageIs("FOREST")) U("DefeatBossMadForest"); if (killed("BOSS_COUNT1") >= 1 && stageIs("LIBRARY")) U("DefeatBossLibrary"); if (killed("BOSS_XLARMOR") >= 1 && stageIs("WAREHOUSE")) U("DefeatBossPlant"); if (killed("BOSS_XLCRAB") >= 1 && stageIs("TOWER")) U("DefeatBossTower"); if (killed("BOSS_TRINACRIA") >= 1 && stageIs("CHAPEL")) U("DefeatBossChapel"); if (killed("BOSS_ENDER") >= 1 && stageIs("CHAPEL")) U("DefeatBossChapel2"); static const char *const RA[][2] = { { "RELIC_GRIMOIRE", "FindGrimoire" }, { "RELIC_BANGER", "FindMagicBanger" }, { "RELIC_GOUDA", "FindGouda" }, { "RELIC_MAP", "FindMilkyWayMap" }, { "RELIC_TEAR", "FindSorceressTears" }, { "RELIC_RANDOMAZZO", "FindRandomazzo" }, { "RELIC_GLASSMASK", "BuyGlassMask" }, { "RELIC_YELLOW", "FindYellowSign" }, { "RELIC_SECRETS", "FindForbiddenScroll" }, { "RELIC_GGOSPEL", "FindGGospel" }, { "RELIC_CHARM", "FindApoplexy" }, { "RELIC_TRISECTION", "FindTrisection" }, { "RELIC_MALACHITE", "FindChaosMalachite" }, { "RELIC_ROSALIA", "FindChaosRosalia" }, { "RELIC_MAP_AS", "FindMap_AstralStair" } }; for (size_t i = 0; i < sizeof(RA) / sizeof(*RA); i++) if (hasItem(RA[i][0])) U(RA[i][1]); static const char *const CF[][2] = { { "PUGNALA", "FindCoffinStage1" }, { "GIOVANNA", "FindCoffinStage2" }, { "POPPEA", "FindCoffinStage3" }, { "CONCETTA", "FindCoffinStage4" }, { "ASSUNTA", "FindCoffinStage5" } }; for (int i = 0; i < 5; i++) if (po_has("UnlockedCharacters", CF[i][0])) U(CF[i][1]); double candles = 0; cJSON_ArrayForEach(e, data_get("props")) candles += num(e, "destroyedAmount", 0); if (candles >= 0x14) U("Destroy20Candles"); if (pickedAmount("ROAST") >= 5) U("Eat5PotRoast"); if (pickedAmount("CLOVER") >= 1) U("FindAClover"); if (pickedAmount("ROSARY") >= 1) U("FindARosary"); if (pickedAmount("VACUUM") >= 1) U("FindAVacuum"); if (pickedAmount("OROLOGION") >= 1) U("FindAnOrologion"); if (cJSON_IsTrue(cJSON_GetObjectItem(tbl0("weapons", "GREED"), "seen"))) U("FindAStoneMask"); // seen >= 1 if (weaponLv("FIREBALL", 4) || Core_GetWeapon("HELLFIRE")) U("GetFireWandToLevel4"); if (weaponLv("HOLYBOOK", 4) || Core_GetWeapon("VESPERS")) U("GetHolyBookToLevel4"); if (weaponLv("HOLYWATER", 4) || Core_GetWeapon("BORA")) U("GetHolyWaterToLevel4"); if (weaponLv("MAGIC_MISSILE", 7) || Core_GetWeapon("HOLY_MISSILE")) U("GetMagicMissileToLevel7"); if (weaponLv("LIGHTNING", 4) || Core_GetWeapon("LOOP")) U("GetLightningRingToLevel4"); if (weaponLv("SILF", 7) || Core_GetWeapon("SILF3")) U("GetPeachoneToLevel7"); if (weaponLv("DIAMOND", 7) || Core_GetWeapon("ROCHER")) U("GetRunetracerToLevel7"); if (weaponLv("GARLIC", 7) || Core_GetWeapon("VORTEX")) U("GetGarlicToLevel7"); if (weaponLv("PENTAGRAM", 7) || Core_GetWeapon("SIRE")) U("GetPentagramToLevel7"); if (weaponLv("PANDORA", 9)) U("GetTorroneToLevel9"); if (Core.n_weapons >= 6) U("Have6DifferentWeapons"); int evo = 0; for (int i = 0; i < Core.n_weapons; i++) evo += AM_isEvolution(Core.Weapons[i]); if (evo >= 6) U("Have6Evolutions"); if (po_num("LifetimeHeal") >= 0x3e8) U("Recover1000HP"); if (Core.RunCoins >= 0x1388) U("Earn5000CoinsInASingleRun"); // PlayerOptions.RunCoins if (hasItem("RELIC_RANDOMAZZO")) { U("FindRandomazzo"), U("FindRandomazzoT06"); static const char *const L99[][2] = { { "PUGNALA", "ReachLV99WithPugnala" }, { "DOMMARIO", "ReachLV99WithDommario" }, { "PORTA", "ReachLV99WithPorta" }, { "GIOVANNA", "ReachLV99WithGiovanna" }, { "CROCI", "ReachLV99WithKroci" }, { "GENNARO", "ReachLV99WithGennaro" }, { "GERMANA", "ReachLV99WithClerici" }, { "ANTONIO", "ReachLV99WithAntonio" }, { "IMELDA", "ReachLV99WithImelda" }, { "CRISTINA", "ReachLV99WithChristine" }, { "PASQUALINA", "ReachLV99WithPasqualina" } }; for (int i = 0; i < 11; i++) if (lvl >= 0x32 && charIs(L99[i][0])) U(L99[i][1]); if (secs >= 0x744 && stageIs("FOREST")) U("Survive31MinutesInForest"); if (secs >= 0x744 && stageIs("LIBRARY")) U("Survive31MinutesInLibrary"); if (secs >= 0x744 && stageIs("TOWER")) U("Survive31MinutesInTower"); static const char *const L99b[][2] = { { "LAMA", "ReachLV99WithLama" }, { "POPPEA", "ReachLV99WithPoppea" }, { "CONCETTA", "ReachLV99WithConcetta" }, { "CIRO", "ReachLV99WithArca" } }; for (int i = 0; i < 4; i++) if (lvl >= 0x32 && charIs(L99b[i][0])) U(L99b[i][1]); if (secs >= 0x744 && stageIs("WAREHOUSE")) U("Survive31MinutesInDairyPlant"); if (lvl >= 0x32 && charIs("CAMILLO")) U("ReachLV99WithPoe"); } static const char *const L80[][2] = { { "MORTACCIO", "ReachLV100WithMortaccio" }, { "CAVALLO", "ReachLV100WithCavallo" }, { "MARIA", "ReachLV100WithRamba" }, { "TATANKA", "ReachLV100WithOsole" }, { "AMBROGIO", "ReachLV100WithAmbrojoe" } }; for (int i = 0; i < 5; i++) if (lvl >= 0x50 && charIs(L80[i][0])) U(L80[i][1]); if (lvl >= 0x14 && stageIs("FOREST")) U("ReachLV20InMadForest"); if (lvl >= 0x28 && stageIs("LIBRARY")) U("ReachLV40InLibrary"); if (lvl >= 0x3c && stageIs("WAREHOUSE")) U("ReachLV60InDairyPlant"); if (lvl >= 0x50 && stageIs("TOWER")) U("FindYellowSignS5"); if (lvl >= 0x50 && po_is("SelectedInverse")) { if (stageIs("FOREST")) U("ReachLV80InverseForest"); if (stageIs("LIBRARY")) U("ReachLV80InverseLibrary"); if (stageIs("TOWER")) U("ReachLV80InverseTower"); } if (lvl >= 0xa) U("ReachLV10"); if (lvl >= 5) U("ReachLV5"); if (secs >= 0x3c) U("Survive1Minute"); if (secs >= 0x12c && charIs("PASQUALINA")) U("Survive5MinutesWithDiamond"); if (secs >= 0x12c && charIs("GENNARO")) U("Survive5MinutesWithKnife"); if (secs >= 0x258) U("Survive10Minutes"); if (secs >= 0x258 && charIs("PUGNALA")) U("Survive10MinutesWithGuns"); if (secs >= 0x384 && charIs("PUGNALA")) U("Survive15MinutesWithGuns"); if (secs >= 0x384 && charIs("POPPEA")) U("Survive15MinutesWithSong"); if (secs >= 0x384 && charIs("GIOVANNA")) U("Survive15MinutesWithGatti"); if (secs >= 0x384 && charIs("CONCETTA")) U("Survive15MinutesWithShadow"); if (secs >= 0x384 && charIs("ASSUNTA")) U("Survive15MinutesWithWind"); if (secs >= 0x4b0) U("Survive20Minutes"); if (secs >= 0x4b0 && charIs("CROCI")) U("Survive20MinutesWithCross"); if (secs >= 0x4b0 && p->curse > 1) U("Survive20MinutesWithCurse"); if (secs >= 0x708 && charIs("LAMA")) U("Survive30MinutesWithAxe"); if (secs >= 0x708 && (!strcmp(po_str("SelectedCharacter"), "PINO") || !strcmp(po_str("SelectedCharacter"), "FEBBRA"))) U("GalloDivano"); if (secs >= 0x384 && stageIs("MOLISE")) U("Survive15MinutesInMolise"); if (secs >= 0x384 && stageIs("SINKING")) U("Survive15MinutesInMoongolow"); if (secs >= 0x708 && stageIs("GREENACRES")) U("Survive30MinutesInGreenAcres"); if (secs >= 0x708 && stageIs("BONEZONE")) U("Survive30MinutesInBoneZone"); if (secs >= 0x384 && stageIs("RASH")) U("Survive15MinutesInBossRash"); int seen = 0; // armi viste + oggetti visti + arcane sbloccate (senza i nascosti) cJSON_ArrayForEach(e, data_get("weapons")) { cJSON *w = cJSON_GetArrayItem(e, 0); if (w && !cJSON_IsTrue(cJSON_GetObjectItem(w, "hidden"))) seen += cJSON_IsTrue(cJSON_GetObjectItem(w, "seen")); } cJSON_ArrayForEach(e, data_get("items")) if (!cJSON_IsTrue(cJSON_GetObjectItem(e, "hidden"))) seen += cJSON_IsTrue(cJSON_GetObjectItem(e, "seen")); cJSON_ArrayForEach(e, data_get("arcana")) if (!cJSON_IsTrue(cJSON_GetObjectItem(e, "hidden"))) seen += cJSON_IsTrue(cJSON_GetObjectItem(e, "unlocked")); if (seen >= 0x32) U("See50Items"); if (seen >= 0x3c) U("See60Items"); if (seen >= 0x46) U("See70Items"); if (seen >= 0x50) U("See80Items"); if (seen >= 0x5a) U("See90Items"); if (seen >= 0x64) U("See100Items"); static const char *const EV[][2] = { { "CORRIDOR", "ObtainTheInfiniteCorridor" }, { "SHROUD", "ObtainTheCrimsonShroud" }, { "VAMPIRICA", "EvolveWhip" }, { "HOLY_MISSILE", "EvolveMagicWand" }, { "THOUSAND", "EvolveKnife" }, { "SCYTHE", "EvolveAxe" }, { "BORA", "EvolveSantaWater" }, { "LOOP", "EvolveLightning" }, { "HEAVENSWORD", "EvolveCross" }, { "VESPERS", "EvolveKingBible" }, { "HELLFIRE", "EvolveFireWand" }, { "VORTEX", "EvolveGarlic" }, { "ROCHER", "EvolveRunetracer" }, { "SIRE", "EvolvePentagram" }, { "SILF3", "UniteBirds" }, { "GUNS3", "EvolveGuns" }, { "STIGRANGATTI", "EvolveGatti" }, { "MANNAGGIA", "EvolveSongOfMana" }, { "TRAPANO2", "EvolveShadow" } }; for (size_t i = 0; i < sizeof(EV) / sizeof(*EV); i++) if (Core_GetWeapon(EV[i][0])) U(EV[i][1]); if (Core_GetWeapon("VENTO2")) U("EvolveWind"), U("EvolveWhip"); if (Core_GetWeapon("TRIASSO3")) U("EvolveBracelet"); static const char *const ALL[] = { "EvolveWhip", "EvolveMagicWand", "EvolveKnife", "EvolveAxe", "EvolveSantaWater", "EvolveLightning", "EvolveCross", "EvolveKingBible", "EvolveFireWand", "EvolveGarlic", "EvolveRunetracer", "EvolvePentagram", "UniteBirds", "EvolveGuns", "EvolveGatti", "EvolveSongOfMana", "EvolveShadow", "EvolveWind", "EvolveBracelet" }; int na = 0; for (int i = 0; i < 19 && po_has("Achievements", ALL[i]); i++) na++; if (na >= 19) U("EvolveAll"); AchievementManager_CheckForStage6Achievement(); int hy = GetValidUnlockedHypers(); if (hy >= 1) U("Unlock3Hypers"); // (sic) i nomi sono sfasati di uno if (hy >= 2) U("Unlock2Hypers"); if (hy >= 3) U("Unlock3Hypers_Correct"); if (hy >= 4) U("Unlock4Hypers"); if (hy >= 5) U("Unlock5Hypers"); if (!po_has("Achievements", "CompleteCollection") && AchievementManager_CheckSigmaUnlock()) U("CompleteCollection"); if (Core.kills >= 0x186a0 && !strcmp(po_str("SelectedCharacter"), "SIGMA")) U("Defeat100kWithSigma"); // RunEnemies if (LUF.n_banished >= 0xa) U("Banish10Items"); if (LUF.n_banished >= 0x14) U("Banish20Items"); if (DLC_Has("Foscari")) { // CheckAchievements_Foscari if (po_has("UnlockedCharacters", "ELEANOR")) U("FOSC01_FindCoffin"); if (killed("FS_BOSS_AGAEA") >= 1 && stageIs("FOSCARI")) U("FOSC20_DefeatBossLake"); if (killed("FS_BOSS_JENEVIV") >= 1 && stageIs("FOSCARI2")) U("FOSC21_DefeatBossAbyss"); if (secs >= 0x384 && charIs("ELEANOR")) U("FOSC02_Survive15Eleanor"); if (secs >= 0x384 && charIs("VICTOR")) U("FOSC06_Survive15Viktor"); if (secs >= 0x384 && charIs("KEIRA")) U("FOSC08_Survive15Keira"); if (secs >= 0x384 && charIs("LUMINAIRE")) U("FOSC13_Survive15Luminaire"); if (secs >= 0x384 && charIs("GENEVIEVE")) U("FOSC15_Survive15Genevieve"); Weapon *fw = Core_GetWeapon("SPELL_STREAM"); if (fw && fw->level >= 6) U("FOSC03_GetStreamToLevel6"); fw = Core_GetWeapon("SPELL_STRIKE"); if (fw && fw->level >= 6) U("FOSC04_GetStrikeToLevel6"); if (Core_GetWeapon("SPELL_STROM")) U("FOSC03_GetStreamToLevel6"), U("FOSC04_GetStrikeToLevel6"), U("FOSC05_UniteSpells"); if (Core_GetWeapon("SWORD2")) U("FOSC07_EvolveEskizzibur"); if (Core_GetWeapon("FLASHARROW2")) U("FOSC09_EvolveFlashArrow"); if (Core_GetWeapon("PRISMATICMISS2")) U("FOSC14_EvolvePrismatic"); if (Core_GetWeapon("SHADOWSERVANT2")) U("FOSC16_EvolveShadow"); if (Core.kills >= 0x186a0 && !strcmp(po_str("SelectedCharacter"), "GENEVIEVE")) U("FOSC17_Defeat100kGenevieve"); if (killed("FS_CAKE") >= 0x1770) U("FOSC18_Defeat6kFairy"); if (killed("FS_ROTGHOUL") >= 0x1770) U("FOSC19_Defeat6kHorror"); static const char *const seal[3] = { "FOSCARI_SEAL_1", "FOSCARI_SEAL_2", "FOSCARI_SEAL_3" }, *const sa[3] = { "FOSC10_BreakSeal1", "FOSC11_BreakSeal2", "FOSC12_BreakSeal3" }; for (int k = 0; k < 3; k++) if (num(cJSON_GetObjectItem(data_get("props"), seal[k]), "destroyedAmount", 0) >= 1) U(sa[k]); if (hasItem("RELIC_MAP_FS")) U("FOSC22_FindMap_Foscari"); } if (DLC_Has("Moonspell")) { // CheckAchievements_Moonspell if (po_has("UnlockedCharacters", "MIANG")) U("MOON01_FindCoffin"); if (killed("MS_OROCHIMARIO") >= 1 && stageIs("MOONSPELL")) U("MOON16_DefeatBossRuins"); if (secs >= 0x384 && charIs("MIANG")) U("MOON02_Survive15Miang"); if (secs >= 0x384 && charIs("MENYA")) U("MOON04_Survive15Menya"); if (secs >= 0x384 && charIs("SYUUTO")) U("MOON06_Survive15Syuuto"); if (secs >= 0x384 && charIs("ONNA")) U("MOON08_Survive15BabiOnna"); if (secs >= 0x384 && charIs("MCCOY")) U("MOON10_Survive15McCoy"); if (Core_GetWeapon("SILVERWIND2")) U("MOON03_EvolveSilverWind"); if (Core_GetWeapon("FOURSEASONS2")) U("MOON05_EvolveFourSeasons"); if (Core_GetWeapon("SUMMONNIGHT2")) U("MOON07_EvolveSummonNight"); if (Core_GetWeapon("MIRAGEROBE2")) U("MOON09_EvolveMirageRobe"); if (Core_GetWeapon("NIGHTSWORD2")) U("MOON15_EvolveNightSword"); if (Core_GetWeapon("BUBBLES2")) U("MOON17_EvolveBubbles"); if (Core.kills >= 0x186a0 && !strcmp(po_str("SelectedCharacter"), "MENYA")) U("MOON11_Defeat100kVanya"); // RunEnemies if (Core.kills >= 0x186a0 && !strcmp(po_str("SelectedCharacter"), "SYUUTO")) U("MOON12_Defeat100kVadjouel"); if (killed("MS_KAPPA") >= 0x1770) U("MOON13_Defeat6kWater"); if (cJSON_IsTrue(cJSON_GetObjectItem(tbl0("weapons", "NIGHTSWORD"), "seen"))) U("MOON14_FindNightSword"); if (hasItem("RELIC_MAP_MS")) U("MOON18_FindMap_Moonspell"); } } #undef U static void AchievementManager_GetNewSecretsEarnedOnThisRun(void) { AM_nNewSecrets = 0; int trueWeapons = 0; for (int i = 0; i < Core.n_weapons; i++) trueWeapons += !Core.Weapons[i]->isPowerUp; if (Core.SurvivedSeconds >= 0x384 && stageIs("RASH") && trueWeapons == 1 && AchievementManager_UnlockSecret("BossRashBoss")) Sound_PlaySound("ThingFound", 1, 0.5f, -0x3e8, 0, 0); if (stageIs("SINKING")) { static const char *const M16[] = { "POWER", "SPEED", "DURATION", "AREA", "MAXHEALTH", "REGEN", "ARMOR", "MOVESPEED", "COOLDOWN", "AMOUNT", "REVIVAL", "MAGNET", "LUCK", "GROWTH", "GREED", "CURSE" }; int ok = 0; for (int i = 0; i < 16; i++) { Weapon *w = Core_GetWeapon(M16[i]); if (!w || w->level < cJSON_GetArraySize(cJSON_GetObjectItem(data_get("weapons"), M16[i]))) { ok = 0; break; } // Object.keys(levels).length ok = 1; } if (ok && AchievementManager_UnlockSecret("Master16")) Sound_PlaySound("ThingFound", 1, 0.5f, -0x3e8, 0, 0); } if (frand() < pickedAmount("CLOVER") / 0xffff) { cJSON *c = tbl0("characters", "EXDASH"); obj_set(c, "hidden", cJSON_CreateFalse()), obj_set(c, "isBought", cJSON_CreateTrue()); if (!po_has("UnlockedCharacters", "EXDASH")) po_push("BoughtCharacters", "EXDASH"), po_push("UnlockedCharacters", "EXDASH"), PlayerOptions_Save(); } if (killed("BOSS_XLDEATH") > 0 || killed("BOSS_XLDEATH2") > 0) { obj_set(tbl0("characters", "NOSTRO"), "hidden", cJSON_CreateFalse()); if (!po_has("UnlockedCharacters", "NOSTRO")) po_push("UnlockedCharacters", "NOSTRO"), PlayerOptions_Save(); } } // ============================================================================ // 0x16120: GenericPopupDescriptionPanel (il riquadro con icona, nome, descrizione e suggerimento) // ============================================================================ typedef struct { unsigned bgTint; int iconBG, overlay, nextLevelVisible, tipsVisible; const char *iconBGFrame, *overlayFrame; const char *iconAtlas, *iconFrame; float iconOX; char name[128], nextLevel[48], counter[16], desc[512], tips[256]; } GenericPopup; static const char *lang_text(const char *file, const char *id, const char *field, cJSON *fallback) { const char *s = tr_of(file, id, field); return *s ? s : str(fallback, field) ? str(fallback, field) : ""; } static void GenericPopup_AssignData(GenericPopup *g, const char *key, const char *type, const char *counter, int level) { memset(g, 0, sizeof(*g)); g->bgTint = 0xffffff, g->iconBG = 1, g->iconBGFrame = "frameB.png", g->iconOX = 0.5f, g->tipsVisible = level <= 0; snprintf(g->counter, sizeof(g->counter), "%s", counter); if (!strcmp(type, "Weapon")) { // WeaponData[key][0]: sfondo giallo se evoluzione, "Nuovo!" in giallo al livello 0 cJSON *wd = tbl0("weapons", key); if (!wd) return; if (cJSON_IsTrue(cJSON_GetObjectItem(wd, "isEvolution"))) g->bgTint = 0xffff00; snprintf(g->name, sizeof(g->name), "%s", lang_text("weaponLang", key, "name", wd)); g->iconAtlas = str(wd, "texture"), g->iconFrame = str(wd, "frameName"); snprintf(g->desc, sizeof(g->desc), "%s", lang_text("weaponLang", key, "description", wd)); snprintf(g->tips, sizeof(g->tips), "%s", lang_text("weaponLang", key, "tips", wd)); g->nextLevelVisible = 1; snprintf(g->nextLevel, sizeof(g->nextLevel), "%s", level > 0 ? TextFormat("%s%d", tr("genericPopup_level"), 1 + level) : tr("genericPopup_new")); return; } if (!strcmp(type, "Achievement")) { cJSON *a = cJSON_GetObjectItem(data_get("achievements"), key); if (!a) return; snprintf(g->desc, sizeof(g->desc), "%s", lang_text("achievementLang", key, "description", a)); const char *w = str(a, "weaponToUnlock"), *c = str(a, "characterToUnlock"), *st = str(a, "stageToUnlock"), *hy = str(a, "hyperToUnlock"), *r = str(a, "relicToUnlock"), *pu = str(a, "powerUpToUnlock"); int ach = cJSON_IsTrue(cJSON_GetObjectItem(a, "achieved")); if (w) { cJSON *wd = tbl0("weapons", w); snprintf(g->name, sizeof(g->name), "%s", tr("genericPopup_achievement")); g->iconAtlas = str(wd, "texture"), g->iconFrame = str(wd, "frameName"); snprintf(g->tips, sizeof(g->tips), "%s%s", tr("genericPopup_unlocked"), lang_text("weaponLang", w, "name", wd)); } if (c) { cJSON *cd = tbl0("characters", c); snprintf(g->name, sizeof(g->name), "%s", tr("genericPopup_achievement")); g->iconAtlas = str(cd, "textureName"), g->iconFrame = str(cd, "spriteName"), g->iconBG = 0; snprintf(g->tips, sizeof(g->tips), "%s%s", tr("genericPopup_unlocked"), char_text(c, "charName")); } if (st) { cJSON *sd = tbl0("stages", st); snprintf(g->name, sizeof(g->name), "%s", tr("genericPopup_achievement")); g->iconAtlas = "UI", g->iconFrame = str(sd, "frameNameUnlock") ? str(sd, "frameNameUnlock") : "QuestionMark.png", g->iconBG = 0; snprintf(g->tips, sizeof(g->tips), "%s%s", tr("genericPopup_unlocked"), lang_text("stageLang", st, "stageName", sd)); } if (hy) { cJSON *sd = tbl0("stages", hy); snprintf(g->name, sizeof(g->name), "%s", tr("genericPopup_achievement")); g->iconAtlas = "UI", g->iconFrame = str(sd, "frameName") ? str(sd, "frameName") : "QuestionMark.png", g->iconBG = 0; snprintf(g->tips, sizeof(g->tips), "%s", lang1("genericPopup_unlockedHyper", lang_text("stageLang", hy, "stageName", sd))); } if (r) { cJSON *it = cJSON_GetObjectItem(data_get("items"), r); snprintf(g->name, sizeof(g->name), "%s", tr("genericPopup_achievement")); g->iconAtlas = str(it, "texture"), g->iconFrame = str(it, "frameName"), g->iconBGFrame = "frameF.png"; snprintf(g->tips, sizeof(g->tips), "%s%s", tr(ach ? "genericPopup_unlocked" : "genericPopup_unlocks"), lang_text("itemLang", r, "achievementTips", it)); } if (num(a, "goldPrize", 0) && str(a, "weaponIcon")) { cJSON *wd = tbl0("weapons", str(a, "weaponIcon")); snprintf(g->name, sizeof(g->name), "%s", tr("genericPopup_achievement")); g->iconAtlas = "items", g->iconFrame = str(wd, "frameName"), g->iconOX = 0.75f, g->iconBG = 0, g->overlay = 1, g->overlayFrame = "MoneyBagGreen.png"; snprintf(g->tips, sizeof(g->tips), "%s", lang1(ach ? "genericPopup_obtainedCoin" : "genericPopup_obtainsCoin", TextFormat("%.0f", num(a, "goldPrize", 0)))); } if (pu) { cJSON *pd = tbl0("powerups", pu); g->iconAtlas = "items", g->iconFrame = str(pd, "frameName") ? str(pd, "frameName") : "QuestionMark.png"; snprintf(g->tips, sizeof(g->tips), "%s%s", tr(cJSON_IsTrue(cJSON_GetObjectItem(pd, "achieved")) ? "genericPopup_unlocked" : "genericPopup_unlocks"), lang_text("powerUpLang", pu, "name", pd)); g->iconBGFrame = cJSON_IsTrue(cJSON_GetObjectItem(pd, "specialBG")) ? "frameE.png" : "frameD.png"; } cJSON *ar = cJSON_GetObjectItem(a, "arcanaToUnlock"); if (cJSON_IsNumber(ar) && ar->valuedouble >= 0) { char b[16]; snprintf(b, sizeof(b), "%d", ar->valueint); cJSON *ad = tbl0("arcana", b); g->iconAtlas = "items", g->iconFrame = str(ad, "frameName"), g->iconBGFrame = "frameG.png"; snprintf(g->tips, sizeof(g->tips), "%s%s", tr(ach ? "genericPopup_unlocked" : "genericPopup_unlocks"), lang_text("arcanaLang", b, "name", ad)); } } } static void GenericPopup_AssignAchievement(GenericPopup *g, const char *key, const char *counter) { // la Collezione degli achievement memset(g, 0, sizeof(*g)); g->iconBG = 1, g->iconBGFrame = "frameB.png", g->iconOX = 0.5f, g->tipsVisible = 1; snprintf(g->counter, sizeof(g->counter), "%s", counter); cJSON *a = tbl0("achievements", key); if (!a) return; int ach = cJSON_IsTrue(cJSON_GetObjectItem(a, "achieved")); const char *un = tr(ach ? "genericPopup_unlocked" : "genericPopup_unlocks"); g->bgTint = ach ? 0xffffff : 0x888888; snprintf(g->name, sizeof(g->name), "%s", ach ? tr("genericPopup_obtained") : ""); snprintf(g->desc, sizeof(g->desc), "%s", lang_text("achievementLang", key, "description", a)); const char *w = str(a, "weaponToUnlock"), *c = str(a, "characterToUnlock"), *st = str(a, "stageToUnlock"), *hy = str(a, "hyperToUnlock"), *r = str(a, "relicToUnlock"), *pu = str(a, "powerUpToUnlock"); if (w) { cJSON *wd = tbl0("weapons", w); g->iconAtlas = str(wd, "texture"), g->iconFrame = str(wd, "frameName"), g->iconBG = 1, g->iconBGFrame = "frameB.png"; snprintf(g->tips, sizeof(g->tips), "%s%s", un, lang_text("weaponLang", w, "name", wd)); } if (c) { cJSON *cd = tbl0("characters", c); if (cJSON_IsTrue(cJSON_GetObjectItem(a, "mistery")) && !ach) g->iconAtlas = "items", g->iconFrame = "QuestionMark.png", snprintf(g->tips, sizeof(g->tips), "%s ???", un); else { const char *pre = char_text(c, "prefix"); g->iconAtlas = str(cd, "textureName"), g->iconFrame = str(cd, "spriteName"); snprintf(g->tips, sizeof(g->tips), "%s%s%s%s", un, pre, *pre ? " " : "", char_text(c, "charName")); } g->iconBG = 0; } if (st) { cJSON *sd = tbl0("stages", st); g->iconAtlas = "UI", g->iconFrame = str(sd, "frameNameUnlock") ?: "QuestionMark.png", g->iconBG = 0; snprintf(g->tips, sizeof(g->tips), "%s%s", un, lang_text("stageLang", st, "stageName", sd)); } if (hy) { cJSON *sd = tbl0("stages", hy); g->iconAtlas = "UI", g->iconFrame = str(sd, "frameName") ?: "QuestionMark.png", g->iconBG = 0; snprintf(g->tips, sizeof(g->tips), "%s", lang1(ach ? "genericPopup_unlockedHyper" : "genericPopup_unlocksHyper", lang_text("stageLang", hy, "stageName", sd))); } if (r) { cJSON *it = tbl0("items", r); g->iconAtlas = str(it, "texture"), g->iconFrame = str(it, "frameName"), g->iconBG = 1, g->iconBGFrame = "frameF.png"; snprintf(g->tips, sizeof(g->tips), "%s%s", un, lang_text("itemLang", r, "achievementTips", it)); } if (num(a, "goldPrize", 0) && str(a, "weaponIcon")) { g->iconAtlas = "items", g->iconFrame = str(tbl0("weapons", str(a, "weaponIcon")), "frameName"), g->iconOX = 0.75f, g->iconBG = 0, g->overlay = 1, g->overlayFrame = "MoneyBagGreen.png"; snprintf(g->tips, sizeof(g->tips), "%s", lang1(ach ? "genericPopup_obtainedCoin" : "genericPopup_obtainsCoin", fix(num(a, "goldPrize", 0), 0))); } if (pu) { cJSON *pd = tbl0("powerups", pu); g->iconAtlas = "items", g->iconFrame = str(pd, "frameName") ?: "QuestionMark.png", g->iconBG = 1; g->iconBGFrame = cJSON_IsTrue(cJSON_GetObjectItem(pd, "specialBG")) ? "frameE.png" : "frameD.png"; snprintf(g->tips, sizeof(g->tips), "%s%s", tr(cJSON_IsTrue(cJSON_GetObjectItem(pd, "achieved")) ? "genericPopup_unlocked" : "genericPopup_unlocks"), lang_text("powerUpLang", pu, "name", pd)); // (sic) achieved del potenziamento } cJSON *ar = cJSON_GetObjectItem(a, "arcanaToUnlock"); if (cJSON_IsNumber(ar) && ar->valuedouble >= 0) { const char *b = TextFormat("%d", ar->valueint); cJSON *ad = tbl0("arcana", b); g->iconAtlas = "items", g->iconFrame = str(ad, "frameName"), g->iconBG = 1, g->iconBGFrame = "frameG.png"; snprintf(g->tips, sizeof(g->tips), "%s%s", un, lang_text("arcanaLang", b, "name", ad)); } } static void GenericPopup_draw(const GenericPopup *g, float x, float y, float scaleY) { if (scaleY <= 0) return; float W = 0.96f * SAFE_WIDTH, H = 0x68, half = 0.5f * W, q = 0.25f * W; rlPushMatrix(); rlTranslatef(x, y, 0); rlScalef(PixelScale, scaleY, 1); nine("frame1_c2.png", 12, (Rectangle){ 0, 0, W, H }, rgb(g->bgTint, 1)); if (g->iconBG) TS_frame("UI", g->iconBGFrame, 0x34, 0x34, 0.5f, 0.5f, 2 * PixelScale, 0, WHITE, 0); if (g->iconAtlas && g->iconFrame) TS_frame(g->iconAtlas, g->iconFrame, 0x34, 0x34, g->iconOX, 0.5f, 2 * PixelScale, 0, WHITE, 0); if (g->overlay) TS_frame("UI", g->overlayFrame, 0x34, 0x34, 0.5f, 0.5f, 2 * PixelScale, 0, WHITE, 0); if (g->nextLevelVisible) text_at(g->nextLevel, 0x34, 6, 16, 0.5f, 0, WHITE); text_at(g->name, half, 6, fit_size(g->name, 16, 0x12c), 0.5f, 0, YELLOW); ui_wrap_text(g->desc, 0.4f * half, 0x20, 16, 3.2f * q, 0, WHITE, 1); if (g->tipsVisible) ui_wrap_text(g->tips, 0.4f * half, 0x40, 16, 3.2f * q, 0, ORANGE, 1); text_at(g->counter, 2 * half - 6, 6, 16, 1, 0, BLACK); rlPopMatrix(); } static void PG_onQuit(void *c) { // QuitButton 'pointerdown' -> StartFromPostGame (void)c; if (PG.tQuit >= 0) return; PG.tQuit = PG.t; po_set("Coins", ceil(po_num("Coins"))); Sound_PlaySimple("ClickOut", 0); PlayerOptions_Save(); PG.done = 1; } static void PG_onAchi(void *c) { (void)c; Sound_PlaySimple("ClickIn", 0); PG.isShowingAchievements = !PG.isShowingAchievements; } // ShowAchievements static void PG_cancel(void) {} static void PostGameScene_EnableButtons(void) { UIButton_on(&PG.QuitButton, PG_onQuit, NULL); if (PG_nAch > 0) UIButton_on(&PG.AchiButton, PG_onAchi, NULL); int w = PG_nAch > 0 ? 2 : 1; // MakeUIGrid Overlay_MakeUIGrid(w, 1, 0); if (PG_nAch > 0) UIGrid_SetContents(0, 0, &PG.AchiButton, 0); UIGrid_SetContents(w - 1, 0, &PG.QuitButton, 0); Overlay_ToggleCursorsVisibility(1); UIGrid_SelectGameObject(&PG.QuitButton); OV.UI_selected = &PG.QuitButton; OV.OnCancelCallback = PG_cancel; vui_prompt_select(); } // PostGameScene.create (0x15aed): tempo di carriera, Hurry completati e dati del personaggio per lo stage; poi Save e backup static void PostGameScene_SaveResults(void) { po_add("LifetimeSurvived", Core.SurvivedSeconds); float limit = 0x708; cJSON *mods = cJSON_GetObjectItem(tbl0("stages", po_str("SelectedStage")), "mods"); if (num(mods, "TimeLimit", 0)) limit = num(mods, "TimeLimit", 0); int completed = Core.SurvivedSeconds >= limit; if (po_is("SelectedHurry") && completed) po_add("CompletedHurries", 1), po_add("OwO", 1); cJSON *c = tbl0("characters", po_str("SelectedCharacter")); if (!c) return; if (!cJSON_IsNumber(cJSON_GetObjectItem(c, "enemiesKilled"))) obj_set(c, "enemiesKilled", cJSON_CreateNumber(0)); obj_set(c, "survivedMinutes", cJSON_CreateNumber(num(c, "survivedMinutes", 0) + floorf(Core.SurvivedSeconds / 60.0f))); // undefined + n = NaN: qui 0 obj_set(c, "enemiesKilled", cJSON_CreateNumber(num(c, "enemiesKilled", 0) + Core.kills)); // RunEnemies cJSON *sd = CharacterSaveManager_getCharacterStageData(); obj_set(sd, "survivedMinutes", cJSON_CreateNumber(num(sd, "survivedMinutes", 0) + floorf(Core.SurvivedSeconds / 60.0f))); if (completed) { if (!cJSON_GetObjectItem(c, "completedStages")) obj_set(c, "completedStages", cJSON_CreateArray()); if (arr_indexOf(cJSON_GetObjectItem(c, "completedStages"), po_str("SelectedStage")) < 0) cJSON_AddItemToArray(cJSON_GetObjectItem(c, "completedStages"), cJSON_CreateString(po_str("SelectedStage"))); obj_set(sd, "complete", cJSON_CreateNumber(num(sd, "complete", 0) + 1)); obj_set(sd, "hyper", cJSON_CreateBool(cJSON_IsTrue(cJSON_GetObjectItem(sd, "hyper")) || po_is("SelectedHyper"))); obj_set(sd, "hurry", cJSON_CreateBool(cJSON_IsTrue(cJSON_GetObjectItem(sd, "hurry")) || po_is("SelectedHurry"))); obj_set(sd, "inverse", cJSON_CreateBool(cJSON_IsTrue(cJSON_GetObjectItem(sd, "inverse")) || po_is("SelectedInverse"))); // (sic) stageData contiene gli oggetti per stage, ma qui ci si cerca e ci si spinge il nome dello stage if (arr_indexOf(cJSON_GetObjectItem(c, "stageData"), po_str("SelectedStage")) < 0) cJSON_AddItemToArray(cJSON_GetObjectItem(c, "stageData"), cJSON_CreateString(po_str("SelectedStage"))); } CharacterSaveManager_setCharacterStageData(sd); AchievementManager_GetNewAchievementsEarnedOnThisRun(); AchievementManager_GetNewSecretsEarnedOnThisRun(); for (int i = 0; i < AM_nNew && PG_nAch < 512; i++) PG_achievements[PG_nAch++] = AM_NewAchievements[i]; // Integration.UnlockAchievements (Steam): niente PG.isShowingAchievements = PG_nAch > 0 && !trophies_active(); // con i trofei di sistema l'avviso c'e' gia': il tasto apre comunque l'elenco float cx = 0.5f * (520 + MENU_W - 20), by = 494 - 14; // Vita: in fondo alla colonna destra, sopra la barra dei tasti (PG_R, PG_BOT) UIButton_set(&PG.QuitButton, "OptionsButton", cx, by, 0x60, 0x20, 1.5f, 0.5f, 1); if (PG_nAch > 0) { UIButton_set(&PG.AchiButton, "GreenButton", cx - 0x50, by, 0x60, 0x20, 1.5f, 0.5f, 1); PG.QuitButton.x += 0x50; } PlayerOptions_Save(); PlayerOptions_SaveRunBackup(); PostGameScene_EnableButtons(); } // Core.OnPlayerQuit (uscita dal game over o dalla pausa): CleanUp di armi e armi nascoste, record della Gold Fever, fine di Halloween. // fancyBG.OnDestroy, Arcanas.CleanUp e Player.OnQuit (la musica di Hunger) li copre game_start / Sound_StopMusic. static void Core_OnPlayerQuit(void) { for (int i = 0; i < Core.n_weapons; i++) Weapon_CleanUp(Core.Weapons[i]); for (int i = 0; i < Core.n_HiddenWeapons; i++) Weapon_CleanUp(Core.HiddenWeapons[i]); GoldFever_CheckResults(); IsHalloween = 0; Chapel_OnDestroy(); // fancyBG.OnDestroy Foscari_OnDestroy(); } static void PostGameScene_start(void) { // scene.launch(PostGameScene) memset(&PG, 0, sizeof(PG)); PG.active = 1; PG.tQuit = -1; Chapel_OnDestroy(); // create: fancyBG.OnDestroy Foscari_OnDestroy(); PostGameScene_SaveResults(); } // SceneManager.GameOver: pausa della MainScene, musica a 0, poi GameOverScene static void SceneManager_GameOver(void *ctx) { (void)ctx; Sound_FadeMusic(0, 0x1f4); memset(&GO, 0, sizeof(GO)); GO.active = 1; GO.tButtons = GO.tQuit = GO.tReward = GO.tRevive = -1; GO.canSeeReviveButton = Core.Player->revivals >= 1; GO.sel = GO.canSeeReviveButton; PlayerOptions_SaveGameResults(); Sound_PlaySimple("BGM_GameOver", 1.4f); // ClassicMusic: BGM_GameOver } // 0x16fc0: GameOverinoScene, la morte nella battaglia col Directer (fase 4 e oltre). Sopra la partita, che NON va in pausa: musica, // introBG e 'gameOver' con la camera pixelata 50 -> 1 in 1 s, poi sempre autoRevive: lampo bianco e mani hand_revive_01-07 a 16 fps, // alla fine Player.Revive(0.5) e EraseEnemies(true). Il ramo col ReviveButton (autoRevive falso) non si raggiunge: create lo forza a vero. static struct { int active; float t; Sprite L, R; Animation revive; } GOI; static void GameOverino_ReviveAndBlast(void) { GOI.active = 0; Player_Revive(Core.Player, 0.5f); Core_EraseEnemies(1); } // BackFromFinalGameOver static void SceneManager_FinalStageGameOver(void) { memset(&GOI, 0, sizeof(GOI)); GOI.active = 1; Sound_PlaySimple(po_is("ClassicMusic") ? "BGM_GameOver" : "BGM_GameOverB", 1.4f); make_anim(&GOI.revive, "enemiesM", "hand_revive_", 1, 7, 2, 0x10, 0); for (int k = 0; k < 2; k++) { Sprite *h = k ? &GOI.R : &GOI.L; sprite_init(h, frame_get("enemiesM", "hand_revive_01.png"), 0.5f * MENU_W, 0.5f * MENU_H); sprite_setScale(h, 2 * PixelScale), sprite_setOrigin(h, k ? 0 : 1, 0.5f), h->flipX = k, h->scrollFactor0 = 1, h->visible = 0; } } static void SceneManager_AfterDeath(void *ctx) { // 1,25 s dopo OnDeath: IsInFinalStage ? FinalStageGameOver : GameOver if (Core.Player->IsInFinalStage) SceneManager_FinalStageGameOver(); else SceneManager_GameOver(ctx); } static void GameOverino_update(float delta) { float t0 = GOI.t; GOI.t += delta; if (t0 < 0x3e8 && GOI.t >= 0x3e8) { // OnIntroEnded -> playAutoRevive GOI.L.visible = GOI.R.visible = 1; anims_play(&GOI.L, &GOI.revive, 0), anims_play(&GOI.R, &GOI.revive, 0); } if (!GOI.L.visible) return; sprite_animsUpdate(&GOI.L, delta), sprite_animsUpdate(&GOI.R, delta); if (GOI.t >= 0x3e8 + 7 * 1000.0f / 0x10) GameOverino_ReviveAndBlast(); // LeftHand animationcomplete } static void GameOverino_draw(void) { float t = GOI.t, W = MENU_W, H = MENU_H; static Texture2D bg, title; if (!bg.id) bg = LoadTexture(vs_path("img/introBG.png")), title = LoadTexture(vs_path("img/gameOver.png")); float fill = W / fminf(bg.width, bg.height), k = lerp01(t, 0, 0x320), sc = 5.1f * fill + (fill - 5.1f * fill) * k, ba = 0.4f * k; if (t >= 0x3e8) { float r = (t - 0x3e8) / 0x271; ba *= r < 1 ? 1 - r : r < 2 ? r - 1 : 1; } // Background alpha -> 0 in 625 ms, yoyo if (bg.id) DrawTexturePro(bg, (Rectangle){ 0, 0, bg.width, bg.height }, (Rectangle){ 0.5f * W, 0.5f * H, bg.width * sc, bg.height * sc }, (Vector2){ 0.5f * bg.width * sc, 0.5f * bg.height * sc }, 0, Fade(WHITE, ba)); if (title.id) DrawTexturePro(title, (Rectangle){ 0, 0, title.width, title.height }, (Rectangle){ 0.5f * W, 0.3f * H, title.width, title.height }, (Vector2){ 0.5f * title.width, 0.5f * title.height }, 0, WHITE); scene_render_one(&GOI.L, (Shader){ 0 }), scene_render_one(&GOI.R, (Shader){ 0 }); float f = (t - 0x3e8 - 0x1a9) / 0x64; // screenFade: alpha 1 in 100 ms dopo 425, yoyo if (f > 0 && f < 2) DrawRectangle(0, 0, W, H, Fade(WHITE, f < 1 ? f : 2 - f)); } static void GameOver_EnableButtons(void) { GO.buttonsOn = 1; GO.tButtons = GO.t; } static float GameOver_reviveCashAmount(void) { float c = 0; for (int i = 0; i < (int)floorf(Core.Player->revivals); i++) switch (i + (GOS.awardGivenXTimes - 1)) { case 0: default: c += 0x64; break; case 1: c += 0xc8; break; case 2: c += 0x12c; break; case 3: c += 0x190; break; } return fminf(c, 0xffff); } static void GameOver_EnterStageReward(void) { // il premio parte dopo 500 ms; il contatore va da totalCoins al nuovo totale GOS.awardGivenXTimes++; float a; switch (GOS.awardGivenXTimes) { case 0: case 1: a = 0x1f4; break; case 2: default: a = 0x64; break; case 3: a = 0xc8; break; case 4: a = 0x12c; break; case 5: a = 0x190; break; } GO.rewardOn = 1, GO.tReward = GO.t; GO.bonusFrom = GOS.totalCoins; GOS.totalCoins += a; } static void GameOverScene_update(float delta) { GO.t += delta; int completed = Core.SurvivedSeconds >= StageTimeLimit(); if (!GO.rewardOn && GO.tButtons < 0 && GO.t >= 0x3e8) { // fine del pixelamento: OnIntroEnded if (completed) GameOver_EnterStageReward(); else GameOver_EnableButtons(); } if (GO.rewardOn && GO.tButtons < 0 && GO.t >= GO.tReward + 0x1f4 + 0x5dc) GameOver_EnableButtons(); int quitOn = !(!completed && GO.canSeeReviveButton); if (GO.tRevive >= 0) { // animationcomplete dell'angelo (10 fotogrammi a 16 fps): Revive if (GO.t >= GO.tRevive + 10 * (1000.0f / 0x10)) { GO.active = 0; // SceneManager.BackFromGameOver: MainScene ripresa, musica a 0.3 in 500 ms Sound_FadeMusic(0.3f, 0x1f4); Player_Revive(Core.Player, 0.5f); if (Arcanas_has(4)) Arcanas_TriggerAwake(); // T04_AWAKE } return; } if (!GO.buttonsOn || GO.tQuit >= 0 || GO.t < GO.tButtons + 0x1e) return; int dx, dy; if (quitOn && GO.canSeeReviveButton && in_dir_pressed(&dx, &dy) && dy) GO.sel = dy > 0; // griglia: Quit sopra, Revive sotto if (getenv("VS_AUTORESTART") && quitOn) GO.sel = 0; if (!(in_confirm() || getenv("VS_AUTOPICK") || getenv("VS_AUTORESTART"))) return; if (GO.sel == 1 && GO.canSeeReviveButton) { // ReviveButton pointerdown Sound_PlaySimple("ClickIn", 0); Core.Player->revivals--; if (Core.Player->revivals <= 0 && Core_GetWeapon("REVIVAL")) Core_RemoveWeapon("REVIVAL"); GO.tRevive = GO.t; // HideQuitButton, HideReviveButton, playReviveAnim } else if (quitOn) { // QuitButton pointerdown if (completed) GOS.totalCoins += GameOver_reviveCashAmount(); PlayerOptions_AddCoins(GOS.totalCoins); GOS.totalCoins = 0, GOS.awardGivenXTimes = 0; GO.tQuit = GO.t; Core_OnPlayerQuit(); Sound_StopMusic(); // PostGameFromGameOver: GameOverScene ferma, PostGameScene, musica ferma Sound_PlaySimple("ClickOut", 0); GO.active = 0; PostGameScene_start(); } } static void GameOverScene_draw(void) { float t = GO.t, W = MENU_W, H = MENU_H; // Background 'introBG': scala 5.1 x fill -> fill e alpha 0 -> 0.4 in 800 ms const char *bgPath = vs_path("img/introBG.png"); static Texture2D bg, title, reward; if (!bg.id) { bg = LoadTexture(bgPath); title = LoadTexture(vs_path("img/gameOver.png")); reward = LoadTexture(vs_path("img/stageComplete.png")); } if (bg.id) { float fill = W / fminf(bg.width, bg.height), k = lerp01(t, 0, 0x320), sc = 5.1f * fill + (fill - 5.1f * fill) * k; float ba = 0.4f * k; if (GO.tRevive >= 0) { float r = (GO.t - GO.tRevive) / 0x271; ba *= r < 1 ? 1 - r : r < 2 ? r - 1 : 1; } // playReviveAnim: alpha -> 0 in yoyo DrawTexturePro(bg, (Rectangle){ 0, 0, bg.width, bg.height }, (Rectangle){ 0.5f * W, 0.5f * H, bg.width * sc, bg.height * sc }, (Vector2){ 0.5f * bg.width * sc, 0.5f * bg.height * sc }, 0, Fade(WHITE, ba)); } float titleA = 1, titleS = 1, rewardS = 0; if (GO.rewardOn) { float k = lerp01(t, GO.tReward + 0x1f4, 0xfa); titleA = 1 - k, titleS = 1 - k, rewardS = k; } if (title.id && titleS > 0) DrawTexturePro(title, (Rectangle){ 0, 0, title.width, title.height }, (Rectangle){ 0.5f * W, 0.3f * H, title.width * titleS, title.height * titleS }, (Vector2){ 0.5f * title.width * titleS, 0.5f * title.height * titleS }, 0, Fade(WHITE, titleA)); if (reward.id && rewardS > 0) { DrawTexturePro(reward, (Rectangle){ 0, 0, reward.width, reward.height }, (Rectangle){ 0.5f * W, 0.3f * H, reward.width * rewardS, reward.height * rewardS }, (Vector2){ 0.5f * reward.width * rewardS, 0.5f * reward.height * rewardS }, 0, WHITE); float bonus = GO.bonusFrom + (GOS.totalCoins - GO.bonusFrom) * lerp01(t, GO.tReward + 0x1f4, 0x5dc); TS_frame("UI", "MoneyPile.png", 0.5f * W - 0xaf, 0.3f * H + 0x64, 0.5f, 0.5f, 2 * rewardS, 0, WHITE, 0); TS_text(lang1("gameOver_bonus", TextFormat("%.0f", bonus)), 0.5f * W + 0x19, 0.3f * H + 0x64, fit_size(lang1("gameOver_bonus", "0000"), 16, 0xc8), 2 * rewardS, 0, WHITE); } float hide = GO.tRevive >= 0 ? 1 - lerp01(t, GO.tRevive, 0x64) : 1; // HideQuitButton / HideReviveButton: 100 ms // QuitButton (BackButton 96x32, origine (0.5, 1)) 120 px sopra il ReviveButton (GreenButton, 60 px dal fondo); testi 32 px piu' su int completed = Core.SurvivedSeconds >= StageTimeLimit(); float k = 2 * lerp01(t, GO.tButtons, 0xfa) * hide, bx = 0.5f * W; int arrows = GO.tRevive < 0 && t >= GO.tButtons + 0x1e; if (GO.buttonsOn && !(!completed && GO.canSeeReviveButton) && k > 0) { float by = H - 0x3c - 0x78; rlPushMatrix(); rlTranslatef(bx, by, 0); rlScalef(k, k, 1); nine_wh("button_c8_normal.png", 9, 14, (Rectangle){ -0x30, -0x20, 0x60, 0x20 }, Fade(WHITE, hide)); rlPopMatrix(); const char *q = tr("gameOver_quit"); TS_text(q, bx, by - 0x20, fit_size(q, 16, 0x50), k, 0, Fade(WHITE, hide)); if (GO.canSeeReviveButton) { // reviveCoinsIcon / reviveCoinsText (scala 1): quanto rende rinunciare alle rinascite const char *pay = lang1("gameOver_revivePayout", TextFormat("%.0f", GameOver_reviveCashAmount())); TS_frame("UI", "MoneyPile.png", 0.5f * W - 0xaf, 0.5f * H + 0xaa, 0.5f, 0.5f, k / 2, 0, WHITE, 0); TS_text(pay, 0.5f * W + 0xf, 0.5f * H + 0xaa, fit_size(pay, 16, 0xc8), k / 2, 0, WHITE); } if (arrows && GO.sel == 0) ui_arrows(bx, by - 0x10 * k, 0x30 * k, t); } if (GO.buttonsOn && GO.canSeeReviveButton && k > 0) { float by = H - 0x3c; rlPushMatrix(); rlTranslatef(bx, by, 0); rlScalef(k, k, 1); nine_wh("button_c5_normal.png", 9, 14, (Rectangle){ -0x30, -0x20, 0x60, 0x20 }, Fade(WHITE, hide)); rlPopMatrix(); const char *r = tr("gameOver_revive"); TS_text(r, bx, by - 0x20, fit_size(r, 16, 0x50), k, 0, Fade(WHITE, hide)); if (arrows && GO.sel == 1) ui_arrows(bx, by - 0x10 * k, 0x30 * k, t); } if (GO.tRevive >= 0) { // playReviveAnim: lampo bianco (100 ms in yoyo dopo 425 ms) e angelo (angel1..10, 16 fps, tintFill 0xffffbb) float lt = t - GO.tRevive, fa = lerp01(lt, 0x1a9, 0x64) - lerp01(lt, 0x1a9 + 0x64, 0x64); if (fa > 0) DrawRectangle(0, 0, W, H, Fade(WHITE, fa)); int f = (int)(lt / (1000.0f / 0x10)); char an[16]; snprintf(an, sizeof(an), "angel%d.png", f < 10 ? f + 1 : 10); const Frame *af = frame_get("angel", an); if (af) { Sprite a; sprite_init(&a, af, 0.5f * W, 0.5f * H); sprite_setScale(&a, 2 * PixelScale); sprite_setTintFill(&a, 0xffffbb); a.scrollFactor0 = 1; scene_render_one(&a, fill_shader); } } } // --- PostGameScene ------------------------------------------------------------- static const char *nFormatter(float v, int digits) { // 1 cifra decimale, k/M/G..., zeri finali tolti static char b[4][32]; static int k; char *o = b[k++ & 3]; static const struct { double v; const char *s; } si[] = { { 1e18, "E" }, { 1e15, "P" }, { 1e12, "T" }, { 1e9, "G" }, { 1e6, "M" }, { 1e3, "k" }, { 1, "" } }; for (int i = 0; i < 7; i++) if (v >= si[i].v) { snprintf(o, 32, "%.*f", digits, v / si[i].v); char *dot = strchr(o, '.'); if (dot) { char *e = o + strlen(o) - 1; while (e > dot && *e == '0') *e-- = 0; if (e == dot) *e = 0; } strcat(o, si[i].s); return o; } if (v != 0) snprintf(o, 32, "%.2f", v); else snprintf(o, 32, "0"); return o; } static void PostGameScene_update(float delta) { PG.t += delta; // EnableButtons arriva con OnIntroEnded; qui il bottone e' attivo subito come nell'originale (nessun tween d'ingresso) Overlay_update(delta); UIButton_clicked(&PG.QuitButton) || UIButton_clicked(&PG.AchiButton); if (PG.tQuit < 0 && ((PG.t > 0x96 && getenv("VS_AUTORESTART")) || (PG.t > 0xbb8 && getenv("VS_AUTOPICK")))) PG_onQuit(NULL); // sviluppo if (PG.done) Overlay_DestroyGrid(), vui_prompts_clear(); } // Vita: schermata a tutto schermo 960x544 (l'originale e' una finestra 0.8 x 0.8 con testo a 16: sulla Vita minuscola). // Dati, ordinamenti, colori e tempi delle animazioni restano quelli di PostGameScene; cambiano posizioni e misure. #define PG_L 24.0f // colonna sinistra: statistiche e tabella delle armi #define PG_M 500.0f // divisore #define PG_R 520.0f // colonna destra: personaggio, armi, oggetti #define PG_BOT 494.0f // fondo del pannello, sopra la barra dei tasti static void PostGameScene_draw(void) { float t = PG.t, W = MENU_W; nine("frame5_c4.png", 12, (Rectangle){ 6, 6, W - 12, PG_BOT - 6 }, WHITE); const char *hd = tr("postGame_header"); text_at(hd, 0.5f * W, 16, fit_size(hd, 30, 0x190), 0.5f, 0, WHITE); text_at("1.5.101", W - 16, PG_BOT - 8, 14, 1, 1, rgb(0xb0a890, 1)); // VSVERSION DrawRectangleRec((Rectangle){ PG_M - 1, 64, 2, PG_BOT - 64 - 16 }, Fade(WHITE, 0.6f)); // nome dello stage + modalita' (postGame_normal con GoldMultiplier) const char *sn = tr_of("stageLang", Core.Stage->stageType, "stageName"); if (!*sn) sn = str(cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("stages"), Core.Stage->stageType), 0), "stageName"); char line[160]; snprintf(line, sizeof(line), "%s %s", sn ? sn : "", lang1("postGame_normal", TextFormat("%g", GoldMultiplier))); text_at(line, PG_L, 70, fit_size(line, 20, PG_M - PG_L - 16), 0, 0, YELLOW); // colonna sinistra: tempo, oro, livello, nemici char v[32]; int sec = Core.SurvivedSeconds; snprintf(v, sizeof(v), "%d:%02d", sec / 60, sec % 60); static const char *const rows[4] = { "postGame_survived", "postGame_goldEarned", "postGame_levelReached", "postGame_enemiesDefeated" }; char vals[4][48]; snprintf(vals[0], 48, "%s", sec >= 0x708 ? lang1("postGame_survivedTime", v) : v); snprintf(vals[1], 48, "%.0f", ceilf(Core.RunCoins)); snprintf(vals[2], 48, "%d", Core.Player->level); snprintf(vals[3], 48, "%d", Core.kills); for (int i = 0; i < 4; i++) { const char *lab = tr(rows[i]); float y = 104 + 30 * i, vw = MeasureTextEx(vs_font, vals[i], 22, 0).x; text_at(lab, PG_L, y, fit_size(lab, 22, PG_M - PG_L - vw - 40), 0, 0, WHITE); text_at(vals[i], PG_M - 24, y, 22, 1, 0, i == 0 && sec >= 0x708 ? YELLOW : WHITE); } // colonna destra: personaggio float rc = 0.5f * (PG_R + W - 20); cJSON *cd = cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("characters"), Core.Player->characterType), 0); const char *pre = tr_of("characterLang", Core.Player->characterType, "prefix"), *cn = tr_of("characterLang", Core.Player->characterType, "charName"), *su = tr_of("characterLang", Core.Player->characterType, "surname"); if (!*cn) cn = str(cd, "charName") ? str(cd, "charName") : ""; if (!*su) su = str(cd, "surname") ? str(cd, "surname") : ""; if (!*pre && str(cd, "prefix")) pre = str(cd, "prefix"); snprintf(line, sizeof(line), "%s%s%s %s", pre, *pre ? " " : "", cn, su); TS_frame(str(cd, "textureName"), str(cd, "spriteName"), PG_R + 30, 92, 0.5f, 0.5f, 2, 0, WHITE, 0); text_at(line, PG_R + 64, 92, fit_size(line, 24, W - 20 - PG_R - 64), 0, 0.5f, YELLOW); // icone delle armi: 10 per riga a scala 2, volano dal centro alto del contenitore (250 ms, ritardo i * 1000 / n) int n = Core.n_weapons, cols = n < 10 ? n : 10, wrows = (n + 9) / 10; float cw = n ? 42 * (cols - 1) + 32 : 0, ch = n ? 56 * (wrows - 1) + 50 : 0; float ix0 = rc - 0.5f * cw, iy0 = 136; for (int i = 0; i < n; i++) { Weapon *w = Core.Weapons[i]; cJSON *wd = cJSON_GetObjectItem(data_get("weapons"), w->bulletType), *b = cJSON_GetArrayItem(wd, 0); float tx = 42 * (i % 10), ty = 56 * (i / 10), k = lerp01(t, i * (1000.0f / n), 0xfa); float x = 0.5f * cw + (tx - 0.5f * cw) * k, y = -0x22 + (ty + 0x22) * k; TS_frame(str(b, "texture"), str(b, "frameName"), ix0 + x + 16, iy0 + y, 0.5f, 0, 2 * k, 0, Fade(WHITE, 0.5f + 0.5f * k), 0); float ta = lerp01(t, 0xfa + i * (1000.0f / n), 0xfa); int max = w->level >= cJSON_GetArraySize(wd); text_at(TextFormat("%d", w->level + w->limitBreakLevel), ix0 + tx + 16, iy0 + ty + 34, 18, 0.5f, 0, Fade(max ? YELLOW : WHITE, ta)); } // oggetti raccolti (RunPickups): primo il braciere, poi per quantita'; 10 per riga struct { const char *type, *frame; int amount; } pk[64]; int npk = 0; for (int i = 0; i < Core.n_RunPickups; i++) { const char *ty = Core.RunPickups[i]; if (!strcmp(ty, "TREASURE")) continue; int f = -1; for (int j = 0; j < npk; j++) if (!strcmp(pk[j].type, ty)) f = j; if (f >= 0) pk[f].amount++; else if (npk < 63) pk[npk++] = (typeof(pk[0])){ ty, str(cJSON_GetObjectItem(data_get("items"), ty), "frameName"), 1 }; } if (Core.RunPickups_Coins > 0 && npk < 63) pk[npk++] = (typeof(pk[0])){ "COIN", str(cJSON_GetObjectItem(data_get("items"), "COIN"), "frameName"), Core.RunPickups_Coins }; if (npk > 0) { for (int a = 1; a < npk; a++) // sort per quantita' decrescente (stabile come TimSort) for (int b = a; b > 0 && pk[b].amount > pk[b - 1].amount; b--) { typeof(pk[0]) tmp = pk[b]; pk[b] = pk[b - 1]; pk[b - 1] = tmp; } memmove(&pk[1], &pk[0], npk * sizeof(pk[0])); cJSON *pd = cJSON_GetObjectItem(data_get("props"), Core.Stage->destructibleType); static char brz[48]; snprintf(brz, sizeof(brz), "%s1.png", str(pd, "frameName") ? str(pd, "frameName") : "Brazier"); pk[0] = (typeof(pk[0])){ NULL, brz, 0 }; npk++; int pc = npk < 10 ? npk : 10, prow = (npk + 9) / 10; float pw = 42 * (pc - 1) + 32, ph = 56 * (prow - 1) + 52; float px0 = rc - 0.5f * pw, py0 = iy0 + ch + 16; DrawRectangleRec((Rectangle){ px0 - 8, py0 - 4, pw + 16, ph + 8 }, Fade(BLACK, 0.15f)); // blackDot alpha 0.1 for (int i = 0; i < npk; i++) { float tx = 42 * (i % 10), ty = 56 * (i / 10), k = lerp01(t, i * (1500.0f / npk), 0xfa); float x = 0.5f * pw + (tx - 0.5f * pw) * k, y = -0x22 + (ty + 0x22) * k; TS_frame("items", pk[i].frame, px0 + x + 16, py0 + y, 0.5f, 0, 2 * k, 0, Fade(WHITE, 0.5f + 0.5f * k), 0); if (pk[i].amount) text_at(TextFormat("%d", pk[i].amount), px0 + tx + 16, py0 + ty + 34, 18, 0.5f, 0, Fade(WHITE, lerp01(t, 0xfa + i * (1500.0f / npk), 0xfa))); } } // BuildStats: tabella delle armi (non potenziamenti, senza LAUREL e LANCET), 20 righe; riga piu' bassa se non ci stanno Weapon *ws[32], *all[32]; int nw2 = 0, bestD = -1, bestR = -1, na = 0; for (int i = 0; i < Core.n_RemovedWeapons; i++) all[na++] = Core.RemovedWeapons[i]; // RemovedWeapons.concat(Weapons) for (int i = 0; i < Core.n_weapons; i++) all[na++] = Core.Weapons[i]; for (int i = 0; i < Core.n_HiddenWeapons && na < 32; i++) all[na++] = Core.HiddenWeapons[i]; // .concat(HiddenWeapons) for (int i = 0; i < na; i++) { Weapon *w = all[i]; if (w->isPowerUp || !strcmp(w->bulletType, "LAUREL") || !strcmp(w->bulletType, "LANCET")) continue; ws[nw2++] = w; } float dps[32]; for (int i = 0; i < nw2; i++) { dps[i] = 0xa * (ws[i]->stats_lifetime > 0 ? ws[i]->stats_inflictedDamage / (ws[i]->stats_lifetime / 0x3e8) : 0); if (nw2 > 1 && (bestD < 0 || !(dps[bestD] > dps[i]))) bestD = i; // reduce: a > b ? a : b if (nw2 > 1 && (bestR < 0 || !(ws[bestR]->stats_inflictedDamage > ws[i]->stats_inflictedDamage))) bestR = i; } float sx = PG_L, sy = 234; static const char *hk[5] = { "postGame_weapon", "postGame_level", "postGame_damage", "postGame_time", "postGame_dps" }; static const float hx[5] = { 0, 0xb4, 0x104, 0x14e, 0x198 }, ho[5] = { 0, 0.5f, 1, 1, 1 }, hm[5] = { 0xa0, 0x30, 0x48, 0x40, 0x48 }; // fino a x 432: il popup sta a destra for (int c = 0; c < 5; c++) { const char *h = tr(hk[c]); text_at(h, sx + hx[c], sy, fit_size(h, 18, hm[c]), ho[c], 0, YELLOW); } int nr = nw2 < 0x14 ? nw2 : 0x14; float rh = nr ? fminf(28, (PG_BOT - 24 - (sy + 26)) / nr) : 28, fs = fminf(20, rh - 4), ic = fminf(1.5f, rh / 18); for (int i = 0; i < nr; i++) { Weapon *w = ws[i]; float y = sy + 26 + rh * i; cJSON *b = cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("weapons"), w->bulletType), 0); char name[64]; const char *nm = tr_of("weaponLang", w->bulletType, "name"); snprintf(name, sizeof(name), "%s", *nm ? nm : str(b, "name")); if (strlen(name) > 0xf) { name[0xe] = '.'; name[0xf] = 0; } // substring(0, 14) + '.' TS_frame(str(b, "texture"), str(b, "frameName"), sx + 12, y + 0.5f * fs, 0.5f, 0.5f, ic, 0, WHITE, 0); text_at(name, sx + 30, y, fit_size(name, fs, hx[1] - 30 - 18), 0, 0, WHITE); text_at(TextFormat("%d", w->level), sx + hx[1], y, fs, 0.5f, 0, WHITE); text_at(nFormatter(0xa * w->stats_inflictedDamage, 1), sx + hx[2], y, fs, 1, 0, i == bestR ? YELLOW : WHITE); int ls = (int)floorf(w->stats_lifetime / 0x3e8); text_at(TextFormat("%d:%02d", ls / 60, ls % 60), sx + hx[3], y, fs, 1, 0, WHITE); text_at(nFormatter(dps[i], 1), sx + hx[4], y, fs, 1, 0, i == bestD ? YELLOW : WHITE); } // achievementsPopup: il primo subito, poi ogni 3,5 s si chiude (300 ms) e dopo 500 ms riapre col successivo if (PG_nAch > 0 && PG.isShowingAchievements) { float px = W - 16 - 0.96f * SAFE_WIDTH, py = fmaxf(226, iy0 + ch + 8); // Vita: a destra, sotto statistiche e icone (lascia libera la tabella) int j = (int)(t / 0xdac), k = PG_nAch > 1 ? j : 0; float sy = lerp01(t, 0, 0x12c); if (PG_nAch > 1 && j > 0) { float lt = t - j * 0xdac; if (lt < 0x1f4) k = j - 1, sy = 1 - lerp01(lt, 0, 0x12c); else sy = lerp01(lt, 0x1f4, 0x12c); } static GenericPopup gp; GenericPopup_AssignData(&gp, PG_achievements[k % PG_nAch], "Achievement", PG_nAch > 1 ? TextFormat("%d/%d", 1 + k % PG_nAch, PG_nAch) : "", 0); GenericPopup_draw(&gp, px, py, sy); if (PG_nAch > 1) { // AchiAdGroup: quanti sblocchi float ax = 0.5f * (PG_R + W - 20), ay = py + 0x68 + 0x26, ph = fmodf(t, 2 * 0x640) / 0x640, k2 = ph < 1 ? ph : 2 - ph; // Vita: sotto il popup TS_frame("vfx", "PrizeBG.png", ax, ay, 0.5f, 0.5f, 4 * (1 - 0.1f * ease_sine_inout(k2)), 0, Fade(WHITE, 0.5f), 0); ui_text(TextFormat("%d", PG_nAch), ax, ay - 8, 3, 0, 0.5f, 0.5f, WHITE); ui_text(tr("postGame_unlocks"), ax, ay + 0x18, 1, 0, 0.5f, 0.5f, WHITE); } } // QuitButton (OptionsButton 96x32 scala 2, origine (0.5, 1)) e AchiButton (GreenButton) in fondo alla safe area UIButton_draw(&PG.QuitButton, 1); const char *dn = tr("postGame_done"); ui_text(dn, PG.QuitButton.x, PG.QuitButton.y - 0.5f * bH(&PG.QuitButton), 1.5f, 0x50, 0.5f, 0.5f, WHITE); if (PG_nAch > 0) { UIButton_draw(&PG.AchiButton, 1); const char *at = tr(PG.isShowingAchievements ? "postGame_hideAchievements" : "postGame_showAchievements"); ui_text_lines(at, PG.AchiButton.x, PG.AchiButton.y - 0.5f * bH(&PG.AchiButton), 17, WHITE); } Overlay_draw(); vui_prompt_bar(); } // ============================================================================ // 0x59b5: UI_charFoundScene (il personaggio uscito dalla bara: ombra, lampo, fantasmi; OK; fuochi, raggi e colori; Fatto) // ============================================================================ static struct { int active, okGrid, revealed, doneOn, exiting, swapped; float t, tOk, tClick, tDone, tExit; const char *ch; ParticleManager *pfx, *fw; ParticleEmitter *black, *color, *fwE[7]; float raysX[12], raysT[12]; int nRays; UIButton OkButton; } CF; static void CF_onOk(void *c); static void CF_onDone(void *c); static float CF_bgW(void) { return 0.8f * SAFE_WIDTH; } static float CF_bgH(void) { return 0.8f * DEFAULT_H; } static ParticleEmitter *CF_rain_in(ParticleManager *pm, int add) { // pioggia dal fondo, nera prima della rivelazione e colorata (ADD) dopo EmitterConfig c = { .frames = { frame_get("vfx", "PfxGreen.png"), frame_get("vfx", "PfxHoly.png"), frame_get("vfx", "PfxBlue.png"), frame_get("vfx", "PfxColor1.png"), frame_get("vfx", "PfxColor2.png") }, .nframes = 5, .xOffset = ERND(0, MENU_W), .lifespan = EOP(0x3e8), .nonRadial = 1, .speedY = ERND(-0x258, -0x12c), .speed = EOP(0), .scale = ERANGE(4, 0), .quantity = 8, .on = 1, .flowEveryFrame = 1, .rotate = ERND(0, 0x168), .rotateStep = 5, .blendAdd = add, .tints = { 0 }, .ntints = add ? 0 : 1 }; // tint 0x0: nera (tint 0 da solo vale bianco) ParticleEmitter *e = particles_createEmitter(pm, c); e->x = 0, e->y = MENU_H; return e; } static void CharFoundScene_open(void) { memset(&CF, 0, sizeof(CF)); CF.active = 1; CF.ch = Core.CurrentFoundChar; CF.tOk = CF.tClick = CF.tDone = CF.tExit = -1; CF.pfx = particles_add(), children_remove(&CF.pfx->s), CF.pfx->scrollFactor0 = 1; CF.black = CF_rain_in(CF.pfx, 0); CF.fw = particles_add(), children_remove(&CF.fw->s), CF.fw->scrollFactor0 = 1; static const char *const FW[4] = { "PfxYellow.png", "PfxPink.png", "PfxRed.png", "PfxGreen.png" }; for (int i = 0; i < 7; i++) { // StartFireworks: (createGravityWell verso il centro: non tradotto) CF.fwE[i] = particles_createEmitter(CF.fw, (EmitterConfig){ .frames = { frame_get("vfx", FW[i % 4]) }, .nframes = 1, .lifespan = EOP(0xbb8), .rotate = ERND(0, 0x168), .angle = { 0, 0x168, 0 }, .angleSteps = 0x10, .speed = ERND(0x64, 0x96 + i / 5.0f * 0x12c / 2), .quantity = (int)(0x20 + i / 5.0f * 0x20), .scale = ERANGE(2 + i / 5.0f * 2, 0), .frequency = 0x40, .blendAdd = 1, .on = 0 }); CF.fwE[i]->x = 0.5f * MENU_W + (frand() - 0.5f) * CF_bgW(); CF.fwE[i]->y = 0.5f * MENU_H - 0x7d - 0x96 * frand() / 2; } UIButton_set(&CF.OkButton, "OptionsButton", 0.5f * MENU_W, MENU_H - 0x40, 0x60, 0x20, 0, 0.5f, 0.5f); Sound_FadeMusic(0, 0x1f4); // StartCharScene } static void CF_onOk(void *c) { // OnButtonClicked -> playReveal (void)c; UIButton_off(&CF.OkButton); CF.tClick = CF.t; Sound_PlaySimple("ClickIn", 0); Overlay_ToggleCursorsVisibility(0); if (!strcmp(CF.ch, "CONCETTA")) Sound_PlaySimple("CFF4", 1.2f); else if (!strcmp(CF.ch, "GIOVANNA")) Sound_PlaySimple("CFF2", 1.2f); if (!strcmp(CF.ch, "POPPEA")) Sound_PlaySimple("CFF3", 1.2f); else Sound_PlaySimple("Piano", 1.2f); // (sic) Concetta e Giovanna suonano anche il pianoforte for (int i = 0; i < 12; i++) CF.raysX[i] = 0.5f * MENU_W + 0x40 * (frand() - 0.5f), CF.raysT[i] = CF.t + (i >= 6 ? 0x1f4 : 0); // AddRays ora e dopo 500 ms CF.nRays = 12; } static void CF_onDone(void *c) { (void)c; UIButton_off(&CF.OkButton); Sound_PlaySimple("ClickIn", 0); emitter_stop(CF.color ? CF.color : CF.black); CF.tExit = CF.t; } static void CharFoundScene_update(float delta) { CF.t += delta; float t = CF.t; particles_manager_update(CF.pfx, delta); particles_manager_update(CF.fw, delta); if (CF.tOk < 0 && t >= 0xfa0 + 0x96 + 0xdac) CF.tOk = t; // pannello dentro a 4000 ms, poi 3,5 s: enablePanelsInput if (CF.tOk >= 0 && !CF.okGrid && t >= CF.tOk + 0x96 && CF.tClick < 0) { CF.okGrid = 1; Overlay_MakeUIGrid(1, 1, 1); Overlay_ToggleCursorsVisibility(1); UIGrid_SetContents(0, 0, &CF.OkButton, 0); UIGrid_SelectGameObject(&CF.OkButton); OV.UI_selected = &CF.OkButton; OV.OnCancelCallback = PG_cancel; UIButton_on(&CF.OkButton, CF_onOk, NULL); } if (CF.tClick >= 0) { for (int i = 0; i < 7; i++) { // flash del pannello ADD e fuochi: 30 ms in yoyo a 100, 300, ... 1300 ms float s = CF.tClick + 0x64 + 0xc8 * i; if (t >= s && t < s + 0x3c) emitter_start(CF.fwE[i]); else emitter_stop(CF.fwE[i]); } if (!CF.swapped && t >= CF.tClick + 0xbb8) { // onStart del BGFader -> 0: pioggia colorata, fantasmi via CF.swapped = 1; emitter_stop(CF.black); CF.color = CF_rain_in(CF.pfx, 1); } if (CF.tDone < 0 && t >= CF.tClick + 0xbb8 + 0x1f4 + 0xfa0) { // enableDoneButton CF.tDone = t; } if (CF.tDone >= 0 && !CF.doneOn && t >= CF.tDone + 0x96) { CF.doneOn = 1; Overlay_ToggleCursorsVisibility(1); UIButton_on(&CF.OkButton, CF_onDone, NULL); } } if (CF.tExit >= 0 && t >= CF.tExit + 0x12c) { // OnExitScene: il personaggio si sblocca e si riprende if (!po_has("UnlockedCharacters", CF.ch)) { po_push("UnlockedCharacters", CF.ch); PlayerOptions_Save(); } obj_set(tbl0("characters", CF.ch), "hidden", cJSON_CreateFalse()); CF.active = 0; Overlay_DestroyGrid(); Sound_FadeMusic(0.3f, 0x1f4); // ResumeFromCharScene return; } if (CF.tExit < 0) { Overlay_update(delta); UIButton_clicked(&CF.OkButton); if (getenv("VS_AUTOPICK") && OV.UI_selected && CF.OkButton.onDown && fmodf(t, 0x190) < delta) Overlay_OnSubmitPressed(); } } static void CF_char(const char *frame, float x, float y, float sx, float sy, float alpha, int fill) { cJSON *c = tbl0("characters", CF.ch); const Frame *f = frame_get(str(c, "textureName"), frame); if (!f || alpha <= 0) return; Sprite s; sprite_init(&s, f, x, y); s.scaleX = sx, s.scaleY = sy, s.alpha = alpha, s.scrollFactor0 = 1; if (fill) sprite_setTintFill(&s, 0); scene_render_one(&s, fill ? fill_shader : (Shader){ 0 }); } static void CharFoundScene_draw(void) { float t = CF.t, W = MENU_W, H = MENU_H, bw = CF_bgW(), bh = CF_bgH(), cx = 0.5f * W, cy = 0.5f * H; cJSON *c = tbl0("characters", CF.ch); const char *spr = str(c, "spriteName"); float rev = CF.tClick >= 0 ? lerp01(t, CF.tClick + 0xbb8, 0x1f4) : 0; // la rivelazione (500 ms dopo 3 s dall'OK) DrawRectangle(0, 0, MENU_W, MENU_H, Fade(BLACK, 0.9f * lerp01(t, 0, 0x12c) * (1 - rev))); // BGFader particles_manager_draw(CF.pfx); float ex = CF.tExit >= 0 ? 1 - lerp01(t, CF.tExit, 0x12c) : 1, exA = CF.tExit >= 0 ? -0xb4 * lerp01(t, CF.tExit, 0x12c) : 0; float k = lerp01(t, 0, 0x96), sx = (-0.2f + 1.2f * k) * ex, sy = (-0.1f + 1.1f * k) * ex, ang = 0xb4 * (1 - k) + exA; TS_nine("frame5_c4.png", 12, 12, cx, cy, bw, bh, sx, sy, ang, WHITE); // background (MenuBackground) DrawRectangle((int)(cx - 0.5f * bw), (int)(cy - 0.5f * bh), (int)bw, (int)bh, Fade(BLACK, 0.7f * (1 - rev))); // BGDarkOverlay // raggi colorati, ritagliati al fondo static const unsigned RT[6] = { 0xff0000, 0xff00, 0xff, 0xffff00, 0xff00ff, 0xffff }; menu_clip(cx - 0.5f * bw, cy - 0.5f * bh, bw, bh); for (int i = 0; i < CF.nRays; i++) { if (t < CF.raysT[i]) continue; float lt = t - CF.raysT[i], j = i % 6, sc = 6 * lerp01(lt, 0, 0x3e8) * ex; float pa = fmodf(lt, 2 * (0x1f4 + 0x4b * j)) / (0x1f4 + 0x4b * j), pg = fmodf(lt, 2 * (0xbb8 + 0x96 * j)) / (0xbb8 + 0x96 * j); float alpha = 1 - 0.75f * ease_sine_inout(pa < 1 ? pa : 2 - pa), a = -0x5a + 0x87 * ease_sine_inout(pg < 1 ? pg : 2 - pg); const Frame *f = frame_get("vfx", "rays.png"); if (!f || sc <= 0) continue; Sprite s; sprite_init(&s, f, CF.raysX[i], H + 0x80); sprite_setOrigin(&s, 0, 1); s.scaleX = ((int)j % 2 == 0 ? 6 : -6) * sc / 6, s.scaleY = sc, s.angle = a + exA, s.alpha = alpha, s.blendAdd = 1, s.tint = RT[(int)j], s.scrollFactor0 = 1; scene_render_one(&s, (Shader){ 0 }); } menu_unclip(); if (CF.tClick >= 0) { // backgroundOverlay (PanelBackgroundAdd): lampi a ogni fuoco, se FlashingVFX float fl = 0; for (int i = 0; i < 7; i++) { float s = CF.tClick + 0x64 + 0xc8 * i, d = t - s; if (d >= 0 && d < 0x3c) fl = 0.4f * (d < 0x1e ? d / 0x1e : 2 - d / 0x1e); } if (po_is("FlashingVFXEnabled") && fl > 0) { BeginBlendMode(BLEND_ADDITIVE); TS_nine("frame5_c4_ad.png", 12, 12, cx, cy, 0.5f * bw, 0.5f * bh, 2, 2, 0, Fade(WHITE, fl)); EndBlendMode(); } particles_manager_draw(CF.fw); } // nome: " si unisce!" (scala X da 0 a 1.5 con la rivelazione) char name[160] = ""; const char *pre = char_text(CF.ch, "prefix"), *nm = char_text(CF.ch, "charName"), *sn = char_text(CF.ch, "surname"); snprintf(name, sizeof(name), "%s%s%s%s%s", pre, *pre ? " " : "", nm, *nm ? " " : "", sn); const char *hd = lang1("charFound_joins", name); float hs = fit_size(hd, 16, 0xfa) * 1.5f; if (rev > 0) { rlPushMatrix(); rlTranslatef(cx, cy - 0.5f * bh + 0x2d, 0); rlScalef(rev * ex, (1 + 0.5f * rev) / 1.5f * ex, 1); ui_text_lines(hd, 0, 0, hs, YELLOW); rlPopMatrix(); } // personaggio: ombra che cade (200 ms), fantasmi neri pulsanti, poi a colori float k2 = lerp01(t, 0, 0xc8); CF_char(spr, cx, -0x100 + (cy + 0x100) * k2, 4 - 2 * k2, 8 - 6 * k2, 1 - rev, 1); if (t >= 0xc8 && rev <= 0) { // playGhosts for (int i = 0; i < 4; i++) { float lt = t - 0xc8 - 0x64 * i, d = 0x3e8 + 0xc8 * i; if (lt < 0) continue; float p = fmodf(lt, 2 * d) / d, e2 = ease_sine_inout(p < 1 ? p : 2 - p); CF_char(spr, cx - 4 + 8 * e2, cy, 2 + e2, 2 + e2, 0.3f - 0.2f * e2, 1); } } CF_char(spr, cx, cy, 2 * ex, 2 * ex, rev, 0); // ColorSprite if (t >= 0xc8 && t < 0xc8 + 0xc8 && po_is("FlashingVFXEnabled")) { // OnEnterAnimation: Burst1..6 a 30 fps, scala 8, nera char bf[16]; snprintf(bf, sizeof(bf), "Burst%d.png", 1 + (int)((t - 0xc8) / (1000.0f / 30)) % 6); const Frame *f = frame_get("vfx", bf); if (f) { Sprite s; sprite_init(&s, f, cx, cy); sprite_setScale(&s, 8); sprite_setTintFill(&s, 0); s.scrollFactor0 = 1; scene_render_one(&s, fill_shader); } } // pannello "un altro sopravvissuto": entra da sinistra a 4 s, esce a destra con l'OK float pw = 0.95f * bw, ph = 0.2f * bh, TLx = cx - 0.5f * bw, gx0 = -TLx - 0.025f * bw - pw, gx1 = TLx + 0.025f * bw; float gx = gx0 + (gx1 - gx0) * lerp01(t, 0xfa0, 0x96); if (CF.tClick >= 0) gx = gx1 + (1.5f * W - gx1) * lerp01(t, CF.tClick, 0x96); float py = cy + 0.5f * bh - ph - 0xa; nine("frame1_c2.png", 12, (Rectangle){ gx, py, pw, ph }, WHITE); cJSON *pc = tbl0("characters", Core.Player->characterType); char who[160] = ""; if (pc) { const char *p1 = char_text(Core.Player->characterType, "prefix"), *n1 = char_text(Core.Player->characterType, "charName"), *s1 = char_text(Core.Player->characterType, "surname"); snprintf(who, sizeof(who), "%s%s%s%s%s", p1, *p1 ? " " : "", n1, *n1 ? " " : "", s1); } ui_wrap_text(lang1("charFound_another", who), gx + 0xa, py + 0xa, 16, pw - 0xa, 0, WHITE, 1); // OkButton: entra ruotando (150 ms), esce con l'OK, rientra come "Fatto" float bk = 0, ba = -0x5a; if (CF.tOk >= 0) bk = lerp01(t, CF.tOk, 0x96), ba = -0x5a * (1 - bk); if (CF.tClick >= 0) bk = 1 - lerp01(t, CF.tClick, 0x96), ba = -0xb4 * (1 - bk); if (CF.tDone >= 0) bk = lerp01(t, CF.tDone, 0x96), ba = -0x5a * (1 - bk); if (CF.tExit >= 0) bk = 0; if (bk > 0.001f) { TS_nine("button_c9_normal.png", 9, 14, CF.OkButton.x, CF.OkButton.y, 0x60, 0x20, 2 * PixelScale * bk, 2 * PixelScale * bk, ba, WHITE); const char *ot = tr(CF.tDone >= 0 ? "postGame_done" : "charFound_ok"); TS_text(ot, CF.OkButton.x, CF.OkButton.y, fit_size(ot, 16, 0x50), 2 * PixelScale * bk, ba, WHITE); } CF.OkButton.sc = 2 * PixelScale * (bk > 0.99f); Overlay_draw(); } // ============================================================================ // 0x51a8: UI_merchantScene, con ShopEntryPanel (0x9370) e ScrollableContainer (0x16a35) oltre 6 voci // ============================================================================ #define SH_MAX 16 // ShopEntryPanel (0x9370): un oggetto (o un'arma) con prezzo, "Sold out" e il riflesso dell'acquisto; name/desc: testi sostituiti (guaritore) typedef struct { const char *item, *weapon; double price; float tx, sy, tBuy; int soldOut, all; UIButton hit; const char *name, *desc; } ShopEntry; // lo sfondo comune di negozio, guaritore e directer: finestre nere che si aprono, la maschera che scende, i vetri colorati che salgono typedef struct { ParticleManager *pfx; ParticleEmitter *fire[2]; struct { const char *fr; float x, y; int fx, fy; } win[96]; int nwin; } ShopDecor; static void ShopDecor_setFrames(ShopDecor *d, const char *a, const char *b) { // pfxFire.setFrame({ frames }) for (int k = 0; k < 2; k++) d->fire[k]->c.frames[0] = frame_get("shop", a), d->fire[k]->c.frames[1] = frame_get("shop", b); } static void ShopDecor_init(ShopDecor *d, const char *a, const char *b, float dx, float dy) { int cols = 1 + (int)ceilf(MENU_W / 128.0f), rows = 1 + (int)ceilf(MENU_H / 358.0f); static const char *const WF[3] = { "window2.png", "window4.png", "window5.png" }; d->nwin = 0; for (int i = 0; i < cols; i++) for (int j = 0; j < rows && d->nwin < 96; j++) d->win[d->nwin++] = (typeof(d->win[0])){ WF[RND_between(0, 2)], 0x80 * i + 0x40 + dx, 0x166 * j + dy, frand() >= 0.5f, frand() >= 0.5f }; d->pfx = particles_add(), children_remove(&d->pfx->s), d->pfx->scrollFactor0 = 1; for (int k = 0; k < 2; k++) { d->fire[k] = particles_createEmitter(d->pfx, (EmitterConfig){ .frames = { frame_get("shop", a), frame_get("shop", b) }, .nframes = 2, .xOffset = ERND(0, MENU_W), .lifespan = EOP(0x1388), .nonRadial = 1, .speed = EOP(0), .speedY = ERND(-0x64, -0x12c), .alpha = k ? ERANGE(1, 0) : ERANGE(0.9f, 0.8f), .scale = EOP(1), .scaleY = ERANGE(1, 2), .hasScaleY = 1, .quantity = 1, .frequency = k ? 0x12c : 0, .flowEveryFrame = !k, .blendAdd = k, .on = 1 }); d->fire[k]->x = 0, d->fire[k]->y = MENU_H + 0x150; } } static void ShopDecor_draw(ShopDecor *d, float t, int vMask) { if (vMask) { // vMask: scala da (-0.1, 1) a 1 e y da -128 a 128 float kv = ease_sine_inout(lerp01(t, 0, 0x7d0)); TS_frame("shop", "vMask.png", 0x88, -0x80 + 0x100 * kv, 0.5f, 0.5f, 1, 0, BLACK, 0); } particles_manager_draw(d->pfx); float kw = lerp01(t, 0, 0x3e8); for (int i = 0; i < d->nwin; i++) { const Frame *f = frame_get("shop", d->win[i].fr); if (!f) continue; Sprite s; sprite_init(&s, f, d->win[i].x, d->win[i].y); s.scaleX = -0.1f + 1.1f * kw, s.scaleY = 1, s.alpha = kw, s.flipX = d->win[i].fx, s.flipY = d->win[i].fy, s.tint = 0, s.scrollFactor0 = 1; scene_render_one(&s, (Shader){ 0 }); } } static void ShopCoins_draw(float t, const char *atlas, const char *icon, const char *text) { // CoinsBG, icona e testo: entrano ruotando in 500 ms float cx = 0.5f * MENU_W, kc = lerp01(t, 0, 0x1f4), csx = -0.1f + 2.1f * kc, csy = 0.1f + 1.9f * kc, ca = -0x2d * (1 - kc); TS_nine("frameB9.png", 6, 6, cx, 0x20, 0x60, 0x1c, csx, csy, ca, WHITE); rlPushMatrix(); rlTranslatef(cx, 0x20, 0); rlRotatef(ca, 0, 0, 1); rlScalef(csx / 2, csy / 2, 1); TS_frame(atlas, icon, -0x60 + 6, 0, 0, 0.5f, 2, 0, WHITE, 0); text_at(text, 0x60 - 0xc, 0, 14 * 2, 1, 0.5f, WHITE); rlPopMatrix(); } static struct { int active, n, hasSc, okGrid, eggIdx, scOnDown, dragging, maxN, maxDone; float t, tOk, W, H, pw, ph, TLx, TLy, scY, scH, maxT0, dragOff; ShopEntry p[SH_MAX]; int maxPanel; UIButton Exit; ShopDecor decor; struct { const char *fr; char text[16]; float x, y, t0, sc; unsigned tint; } fx[256]; int nfx; Vector2 downAt; } SH; static const int SH_EggDetune[25] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 13, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21 }; static void SH_add(const char *item, const char *weapon) { if (SH.n >= SH_MAX) return; SH.p[SH.n].item = item, SH.p[SH.n].weapon = weapon; SH.p[SH.n].price = num(cJSON_GetObjectItem(data_get("items"), item), "value", 0); SH.p[SH.n].tBuy = -1; SH.n++; } static void SH_MakeStandardInventory(void) { if (Core.Stage->StageModifiers.EndCycles > 0) SH_add("DUMMY_REVIVAL", NULL); else if (!strcmp(po_str("SelectedCharacter"), "SIGMA")) SH_add("WEAPON", "CANDYBOX"); else SH_add("RELIC_GOLDENEGG", NULL); if (!po_has("CollectedItems", "RELIC_GLASSMASK")) SH_add("RELIC_GLASSMASK", NULL); static const char *const CW[7][2] = { { "MORTACCIO", "BONE" }, { "CAVALLO", "CHERRY" }, { "MARIA", "CART2" }, { "TATANKA", "FLOWER" }, { "AMBROGIO", "LAROBBA" }, { "TONY", "BUBBLES" }, { "GHOUL", "PARTY" } }; for (int i = 0; i < 7; i++) if (po_has("UnlockedCharacters", CW[i][0]) && !Core_GetWeapon(CW[i][1])) SH_add("WEAPON", CW[i][1]); } static void SH_MakeArcanaInventory(void) { if (po_is("SelectedMazzo") && Arcana_unlockedCount() > Arcanas.n) SH_add("DUMMY_ARC", NULL); SH_add("DUMMY_SKIP", NULL), SH_add("DUMMY_BANISH", NULL), SH_add("DUMMY_REROLL", NULL); } static void SH_MakeEggsInventory(void) { if (!strcmp(po_str("SelectedCharacter"), "SIGMA")) { SH_add("WEAPON", "CANDYBOX"); return; } SH_add("RELIC_GOLDENEGG", NULL), SH_add("DUMMY_GOLDENEGG_MAX", NULL); } static void SH_SoldOut(int i) { SH.p[i].soldOut = 1; } static void SH_DisableWeaponPanels(void) { int n = 0; for (int i = 0; i < Core.n_weapons; i++) n += !Core.Weapons[i]->isPowerUp; if (n >= LUF.maxTrueWeapons) for (int i = 0; i < SH.n; i++) if (SH.p[i].weapon) SH_SoldOut(i); } static float SH_px(int i) { return MENU_W + (SH.p[i].tx - MENU_W) * lerp01(SH.t, 0, 0x96 + 0x1e * i); } // OnEnterTween static float SH_ly(int i) { return SH.p[i].sy - (SH.hasSc ? 0.5f * SH.scH : 0); } // y nel contenitore (AddChildren) static float SH_py(int i) { return SH_ly(i) + (SH.hasSc ? SH.scY : 0); } static void SH_fx(const char *fr, const char *text, float x, float y, float sc, unsigned tint) { if (SH.nfx >= 256) return; SH.fx[SH.nfx++] = (typeof(SH.fx[0])){ fr, "", x, y, SH.t, sc, tint }; if (text) snprintf(SH.fx[SH.nfx - 1].text, sizeof(SH.fx[0].text), "%s", text); } static void SH_roast(int delayed) { // tre Roast con il detune che sale a ogni uovo float d = 0x64 * SH_EggDetune[SH.eggIdx++ % 25]; for (int k = 1; k <= 3; k++) Sound_PlaySound("Roast", 0.5f, 1, 0xc8 * k + d, delayed ? 0x133 : 0, delayed ? 5 : 0); } static void SH_resume(void) { // ResumeFromShop SH.active = 0; Overlay_DestroyGrid(); Sound_FadeMusic(0.3f, 0x1f4); } static void SH_cancel(void) { Sound_PlaySimple("ClickOut", 0); SH_resume(); } static void SH_onExit(void *c) { (void)c; UIButton_off(&SH.Exit); PlayerOptions_Save(); Sound_PlaySimple("ClickOut", 0); SH_resume(); } static void SH_pay(int i) { po_add("Coins", -SH.p[i].price), po_add("LifetimeCoins", -SH.p[i].price); } static void SH_OnPanelClicked(int i) { SH_DisableWeaponPanels(); if (!(po_num("Coins") >= SH.p[i].price && !SH.p[i].soldOut)) return; const char *it = SH.p[i].item; if (SH.p[i].weapon) { SH_pay(i), SH_SoldOut(i), SH.p[i].tBuy = SH.t; Sound_PlaySimple("ClickIn", 0); Core_AddWeapon(SH.p[i].weapon, 1); } else if (!strcmp(it, "RELIC_GLASSMASK")) { if (!po_has("CollectedItems", "RELIC_GLASSMASK")) { // Integration.BuyGlassMask dopo 300 ms: solo Steam SH_pay(i); json_inc(cJSON_GetObjectItem(data_get("items"), "RELIC_GLASSMASK"), "pickedupAmount"); po_push("CollectedItems", "RELIC_GLASSMASK"); PlayerOptions_Save(); Sound_PlaySimple("ClickIn", 0), Sound_PlaySimple("ThingFound", 0); SH_SoldOut(i), SH.p[i].tBuy = SH.t; } } else if (!strcmp(it, "RELIC_GOLDENEGG")) { SH_pay(i); int a = EggManager_AddGoldenEgg(); float x = SH_px(i) + 0x40 + 0x40 * frand(), y = SH_ly(i) + 0x20 + 0x40 * frand(); // (sic) coordinate del pannello dentro il contenitore static const unsigned T[3] = { 0xffff00, 0xff00, 0xffff }; char v[16]; snprintf(v, sizeof(v), "%s%g", EggAttr[a].value > 0 ? "+" : "", EggAttr[a].value); SH_fx(EggManager_lookUpFrame(a), v, x, y, 2, T[RND_between(0, 2)]); Sound_PlaySimple("ClickIn", 0); SH.p[i].tBuy = SH.t; SH_roast(0); } else if (!strcmp(it, "DUMMY_GOLDENEGG_MAX")) { int n = (int)floor(po_num("Coins") / 0x2710); Sound_PlaySimple("ClickIn", 0); SH.p[i].tBuy = SH.t, SH_SoldOut(i); po_add("Coins", -0x2710 * n), po_add("LifetimeCoins", -0x2710 * n); for (int k = 0; k < n; k++) EggManager_AddGoldenEgg(); SH.maxN = n + 1, SH.maxDone = 0, SH.maxT0 = SH.t, SH.maxPanel = i; // time.addEvent({ repeat: n, delay: 10 }): n + 1 chiamate } else if (!strcmp(it, "DUMMY_BANISH") || !strcmp(it, "DUMMY_REROLL") || !strcmp(it, "DUMMY_SKIP")) { SH_pay(i), SH.p[i].tBuy = SH.t; Sound_PlaySimple("ClickIn", 0); float *f = !strcmp(it, "DUMMY_BANISH") ? &Core.Player->banish : !strcmp(it, "DUMMY_REROLL") ? &Core.Player->rerolls : &Core.Player->skips; if ((*f += 1) >= 0x14) SH_SoldOut(i); } else if (!strcmp(it, "DUMMY_ARC")) { SH_pay(i), SH.p[i].tBuy = SH.t, SH_SoldOut(i); Sound_PlaySimple("ClickIn", 0); Core.GiveMainArcana = 1, Arcanas.MaxArcanasPerRun++; } else if (!strcmp(it, "DUMMY_REVIVAL")) { SH_pay(i), SH.p[i].tBuy = SH.t, SH_SoldOut(i); Sound_PlaySimple("ClickIn", 0); Core.Player->revivals++; } SH_DisableWeaponPanels(); } static void SH_onPanel(void *c) { SH_OnPanelClicked((int)(intptr_t)c); } static void ShopScene_open(void) { memset(&SH, 0, sizeof(SH)); SH.active = 1, SH.tOk = -1; Sound_FadeMusic(0.2f, 0x1f4); SH.W = 2 * SAFE_WIDTH * 0.8f, SH.H = 0.8f * DEFAULT_H; SH.TLx = 0.5f * MENU_W - 0.5f * SH.W, SH.TLy = 0.5f * MENU_H - 0.5f * SH.H; SH.pw = 0.45f * SH.W, SH.ph = 0.2f * SH.H; ShopDecor_init(&SH.decor, "colours3.png", "colours4.png", 0, 0); if (Core.MerchantInventory == 1) SH_MakeEggsInventory(); else { if (po_is("SelectedInverse")) SH_MakeArcanaInventory(); SH_MakeStandardInventory(); } for (int i = 0; i < SH.n; i++) { SH.p[i].tx = SH.TLx + 0.025f * SH.W + (i % 2 == 1 ? 0.49f * SH.W : 0); SH.p[i].sy = SH.TLy + SH.ph + SH.ph * (i / 2) - 0.025f * SH.W; SH.p[i].all = !strcmp(SH.p[i].item, "DUMMY_GOLDENEGG_MAX"); // SetPriceDisplay('ALL') UIButton_set(&SH.p[i].hit, "", 0, 0, SH.pw, SH.ph, PixelScale, 0, 0); } if (SH.n > 6) { // ScrollableContainer(0, h / 2) con SetSize(1850, h, true, n * ph): MaxY = h / 2, MinY = 0 SH.hasSc = 1; SH.scH = SH.n * SH.ph - 0x226; SH.scY = 0.5f * SH.scH; } UIButton_set(&SH.Exit, "BackButton", 0.5f * MENU_W, SH.TLy + 4.5f * SH.ph - 0.025f * SH.W, 0x60, 0x20, 0, 0.5f, 0.5f); Sound_PlaySound("LevelUp", 1, 1, -0xc8, 0, 0), Sound_PlaySound("LevelUp", 0.5f, 1, -0x5dc, 0, 0); SH_DisableWeaponPanels(); // ShowPanels: input dopo 500 ms } static void SH_correct(int i) { // correctScrollableContainerPosition: passi di 110 float k = 0x6e, y = SH_ly(i); if (SH.scY + y + k > MENU_H - 0x6e) { SH.scY -= k; while (SH.scY + y + k > MENU_H - 0x6e) SH.scY -= k; } else if (SH.scY + y < k) { SH.scY += k; while (SH.scY + y < k) SH.scY += k; } } static void SH_clampSc(void) { if (SH.scY > 0.5f * SH.scH) SH.scY = 0.5f * SH.scH; if (SH.scY < 0) SH.scY = 0; } static void ShopScene_update(float delta) { float prev = SH.t; SH.t += delta; particles_manager_update(SH.decor.pfx, delta); for (int i = 0; i < SH.n; i++) SH.p[i].hit.x = SH_px(i), SH.p[i].hit.y = SH_py(i); if (SH.tOk < 0 && SH.t >= 0x1f4) { // enablePanelsInput SH.tOk = SH.t; SH_DisableWeaponPanels(); for (int i = 0; i < SH.n; i++) UIButton_on(&SH.p[i].hit, SH_onPanel, (void *)(intptr_t)i); } if (SH.tOk >= 0 && !SH.okGrid && SH.t >= SH.tOk + 0x96) { SH.okGrid = 1; int rows = 1 + (SH.n + 1) / 2; Overlay_MakeUIGrid(2, rows, 1); Overlay_ToggleCursorsVisibility(1); for (int i = 0; i < SH.n; i++) UIGrid_SetContents(i % 2, i / 2, &SH.p[i].hit, 0); UIGrid_SetContents(0, rows - 1, &SH.Exit, 0), UIGrid_SetContents(1, rows - 1, &SH.Exit, 0); UIGrid_SelectGameObject(&SH.Exit); OV.UI_selected = &SH.Exit; OV.OnCancelCallback = SH_cancel; vui_set_prompts((VPrompt[]){ { G_CROSS, "vui_buy" }, { G_CIRCLE, "vui_back" } }, 2); UIButton_on(&SH.Exit, SH_onExit, NULL); } while (SH.maxN > SH.maxDone && SH.t >= SH.maxT0 + 0xa * (SH.maxDone + 1)) { // le uova di MAX EGGS, una ogni 10 ms float d = fminf(SH.maxDone / 10.0f, 0x100); float x = SH_px(SH.maxPanel) - d + 0x40 + frand() * (0x80 + d), y = SH_ly(SH.maxPanel) - 0.5f * d + 0x20 + frand() * (0x40 + d); SH.maxDone++; SH_fx(EggManager_lookUpFrame(RND_between(0, 18)), NULL, x, y, 2 + SH.maxDone / 1000.0f, 0); // randomFrame SH_roast(1); } (void)prev; if (SH.hasSc) { // trascinamento del contenitore, rotella, e 'pointerup' che compra di nuovo il pannello (sic: anche il pointerdown del pannello compra) Vector2 m = menu_pointer(); Rectangle mask = { 0, SH.TLy + 0x4b, MENU_W, 0.5f * DEFAULT_H }; if (GetMouseWheelMove()) SH.scY += 0.4f * 100 * GetMouseWheelMove(), SH_clampSc(); if (ptr_pressed()) { SH.scOnDown = 1, SH.downAt = m; if (CheckCollisionPointRec(m, mask)) SH.dragging = 1, SH.dragOff = SH.scY - m.y; } else if (ptr_down() && SH.dragging) SH.scY = m.y + SH.dragOff, SH_clampSc(); else if (ptr_released()) { SH.dragging = 0; if (SH.scOnDown && CheckCollisionPointRec(m, (Rectangle){ SH.TLx, SH.TLy, MENU_W, MENU_H }) && fabsf(SH.downAt.x - m.x) < 5 && fabsf(SH.downAt.y - m.y) < 5) for (int i = 0; i < SH.n; i++) if (CheckCollisionPointRec(m, (Rectangle){ SH.p[i].hit.x, SH.p[i].hit.y, SH.pw, SH.ph })) { SH_OnPanelClicked(i); break; } } } if (OV.UI_selected != UIGrid.previousGameObject) { UIGrid.previousGameObject = OV.UI_selected; for (int i = 0; i < SH.n && SH.hasSc; i++) if (OV.UI_selected == &SH.p[i].hit) SH_correct(i); } Overlay_update(delta); if (!SH.active) return; if (!UIButton_clicked(&SH.Exit)) for (int i = 0; i < SH.n; i++) if (UIButton_clicked(&SH.p[i].hit)) break; if (getenv("VS_AUTOPICK") && OV.UI_selected == &SH.Exit && SH.Exit.onDown && SH.t > SH.tOk + 0x3e8 && fmodf(SH.t, 0x190) < delta) Overlay_OnSubmitPressed(); const char *buy = getenv("VS_SHOPBUY"); // sviluppo: VS_SHOPBUY=i compra il pannello i una volta, appena si puo' static int bought; if (SH.t <= delta) bought = 0; if (buy && SH.okGrid && !bought && atoi(buy) < SH.n) bought = 1, SH_OnPanelClicked(atoi(buy)); } static void ShopEntryPanel_draw(const ShopEntry *e, float x, float y, float w, float h, float now) { const char *it = e->item, *wt = e->weapon; cJSON *id = cJSON_GetObjectItem(data_get("items"), it), *wd = wt ? cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("weapons"), wt), 0) : NULL; nine("frame1_c2.png", 12, (Rectangle){ x, y, w, h }, rgb(0x707080, 1)); // Vita: grigio scurito, il testo chiaro si legge TS_frame("UI", "frameB.png", x + 4, y + 4, 0, 0, 2, 0, WHITE, 0); TS_frame(str(wd ? wd : id, "texture"), str(wd ? wd : id, "frameName"), x + 0x1c, y + 0x1c, 0.5f, 0.5f, 2, 0, WHITE, 0); const char *name = e->name ? e->name : wd ? lang_text("weaponLang", wt, "name", wd) : lang_text("itemLang", it, "name", id); const char *desc = e->desc ? e->desc : wd ? lang_text("weaponLang", wt, "description", wd) : lang_text("itemLang", it, "description", id); char pr[24]; if (e->soldOut) snprintf(pr, sizeof(pr), "Sold out"); else if (e->all) snprintf(pr, sizeof(pr), "ALL"); else snprintf(pr, sizeof(pr), "%g", e->price); float pw = MeasureTextEx(vs_font, pr, 20, 0).x; // Vita: nome a 20 accanto all'icona, prezzo a destra, descrizione a 17 sotto il nome text_at(name, x + 0x40, y + 6, fit_size(name, 20, w - 0x40 - pw - 0x24), 0, 0, WHITE); text_at(pr, x + w - 0x16, y + 6, 20, 1, 0, YELLOW); TS_frame("UI", "CoinGold.png", x + w - 6, y + 8, 1, 0, 1.25f, 0, WHITE, 0); ui_wrap_text(desc, x + 0x40, y + 0x22, 17, w - 0x48, h - 0x26, rgb(0xe8e2d4, 1), 1); if (e->soldOut) DrawRectangle((int)x, (int)y, (int)w, (int)h, Fade(BLACK, 0.5f)); // fader int sf = e->tBuy >= 0 ? (int)fminf(14, (now - e->tBuy) / (1000.0f / 60)) : 0; // sheen: 15 frame a 60 fps con AnimateBuy const Frame *f = frame_get("UI", TextFormat("sheen%02d.png", sf)); if (f) { BeginBlendMode(BLEND_ADDITIVE); DrawTexturePro(*f->tex, (Rectangle){ f->x, f->y, f->w, f->h }, (Rectangle){ x + f->ox * w / 0x82, y + f->oy * h / 0x70, f->w * w / 0x82, f->h * h / 0x70 }, (Vector2){ 0, 0 }, 0, Fade(WHITE, 0.5f)); EndBlendMode(); } } static void ShopScene_draw(void) { float t = SH.t, W = MENU_W, H = MENU_H, cx = 0.5f * W, cy = 0.5f * H; (void)H; ShopDecor_draw(&SH.decor, t, 1); float k = lerp01(t, 0, 0x96), sx = -0.2f + 1.2f * k, sy = -0.1f + 1.1f * k, ang = 0xb4 * (1 - k); float pa = fmodf(t, 0xfa0) / 0x7d0, a = 1 - 0.05f * (pa < 1 ? pa : 2 - pa); // alpha 1 -> 0.95 in yoyo TS_nine("frame5_c4.png", 12, 12, cx, cy, SH.W, SH.H, sx, sy, ang, Fade(WHITE, a)); const char *hd = tr(po_has("CollectedItems", "RELIC_GLASSMASK") ? "shop_header2" : "shop_header1"); TS_text(hd, cx, SH.TLy + 0x2d, fit_size(hd, 16, 0xfa), 2 * PixelScale, 0, WHITE); char co[16]; snprintf(co, sizeof(co), "%.0f", po_num("Coins") < 0x989680 ? po_num("Coins") : 9999999); ShopCoins_draw(t, "UI", "MoneyPile.png", co); if (SH.hasSc) menu_clip(0, SH.TLy + 0x4b, W, 0.5f * DEFAULT_H); for (int i = 0; i < SH.n; i++) ShopEntryPanel_draw(&SH.p[i], SH_px(i), SH_py(i), SH.pw, SH.ph, SH.t); if (SH.hasSc) { menu_unclip(); UIButton sb; UIButton_set(&sb, "Scrollbar", 0x3a7, SH.TLy + 0x4b, 8, 0.5f * DEFAULT_H, PixelScale, 0.5f, 0); UIButton_draw(&sb, 1); const Frame *cur = frame_get("UI", "menu_slider_button_strip3.png"); float v = 1 - SH.scY / (0.5f * SH.scH), ch = cur ? cur->sh * PixelScale : 0; TS_frame("UI", "menu_slider_button_strip3.png", 0x3a7, SH.TLy + 0x4b + fmaxf(0, fminf(v, 1)) * (0.5f * DEFAULT_H * PixelScale - ch), 0.5f, 0, PixelScale, 0, WHITE, 0); } float bk = SH.tOk >= 0 ? lerp01(t, SH.tOk, 0x96) : 0; if (bk > 0.001f) { TS_nine("button_c8_normal.png", 9, 14, SH.Exit.x, SH.Exit.y, 0x60, 0x20, 2 * PixelScale * bk, 2 * PixelScale * bk, -0x5a * (1 - bk), WHITE); const char *et = tr("topBar_back"); TS_text(et, SH.Exit.x, SH.Exit.y, fit_size(et, 16, 0x50), 2 * PixelScale * bk, -0x5a * (1 - bk), WHITE); } SH.Exit.sc = 2 * PixelScale * (bk > 0.99f); for (int i = 0; i < SH.nfx; i++) { // uova comprate: icona (e "+valore") che salgono di 20 px e svaniscono in 2 s float kf = lerp01(t, SH.fx[i].t0, 0x7d0), y = SH.fx[i].y - 0x14 * kf; if (kf >= 1) continue; TS_frame("items", SH.fx[i].fr, SH.fx[i].x, y, 0.5f, 0.5f, SH.fx[i].sc, 0, Fade(WHITE, 1 - kf), 0); if (*SH.fx[i].text) { text_at(SH.fx[i].text, SH.fx[i].x + 0x20 + 2, y + 2, 32, 0, 0.5f, Fade(BLACK, 1 - kf)); text_at(SH.fx[i].text, SH.fx[i].x + 0x20, y, 32, 0, 0.5f, rgb(SH.fx[i].tint, 1 - kf)); } } int bf = (int)(t / (1000.0f / 30)); if (bf < 6 && po_is("FlashingVFXEnabled")) TS_frame("vfx", TextFormat("Burst%d.png", bf + 1), cx, 0.5f * W, 0.5f, 0.5f, 8, 0, WHITE, 1); vui_prompt_bar(); Overlay_draw(); } // ============================================================================ // 0x10419: UI_healerScene, Flames of Moonspell (togli 100 uova a caso) e Lantern of Foscari (tutte quelle di velocita', con 25000 uova) // ============================================================================ static struct { int active, n, okGrid, eggIdx, flipY, calls, purifySold; float t, tOk, TLx, TLy, bw, bh, W, tMusic; ShopEntry p[2]; UIButton Exit; ShopDecor decor; char header[160], name[2][96], desc[2][256]; const char *savedBGM, *savedMod; struct { float x, y, t0; int fx, on; } eggs[0x1f4]; struct { float t0, x, y; int n, done; } rem[8]; int nrem; } HE; static void utf8_shuffle(char *s) { // String.prototype.shuffle: rimescola i caratteri (qui per codepoint, non per unita' UTF-16) int cps[256], n = 0, len = (int)strlen(s); for (int i = 0; i < len && n < 256;) { cps[n++] = i; int c = (unsigned char)s[i]; i += c < 0x80 ? 1 : c < 0xe0 ? 2 : c < 0xf0 ? 3 : 4; } char out[512]; int lens[256]; for (int i = 0; i < n; i++) lens[i] = (i + 1 < n ? cps[i + 1] : len) - cps[i]; for (int i = n - 1; i > 0; i--) { int j = (int)floorf(frand() * (i + 1)), t = cps[i], l = lens[i]; cps[i] = cps[j], lens[i] = lens[j], cps[j] = t, lens[j] = l; } int o = 0; for (int i = 0; i < n && o + lens[i] < (int)sizeof(out); i++) memcpy(out + o, s + cps[i], lens[i]), o += lens[i]; out[o] = 0; memcpy(s, out, o + 1); } static void HE_texts(int real) { // i testi veri, o rimescolati snprintf(HE.header, sizeof(HE.header), "%s", tr("healer_header")); for (int i = 0; i < HE.n; i++) { cJSON *id = cJSON_GetObjectItem(data_get("items"), HE.p[i].item); snprintf(HE.name[i], sizeof(HE.name[i]), "%s", lang_text("itemLang", HE.p[i].item, "name", id)); snprintf(HE.desc[i], sizeof(HE.desc[i]), "%s", lang_text("itemLang", HE.p[i].item, "description", id)); if (!real) utf8_shuffle(HE.name[i]), utf8_shuffle(HE.desc[i]); } if (!real) utf8_shuffle(HE.header); } static void HE_UpdateEggsTotal(void) { cJSON *c = Egg_char(0); if (!c || num(c, "total", 0) > 0 || HE.p[0].soldOut) return; HE.p[0].soldOut = 1; // finite le uova: Purify esaurito, le fiamme tornano azzurre ShopDecor_setFrames(&HE.decor, "colours3.png", "colours4.png"); Sound_PlaySound("LevelUp", 1, 1, -0xc8, 0, 0), Sound_PlaySound("LevelUp", 0.5f, 1, -0x5dc, 0, 0); } static void HE_PlayRemovalAnimation(float x, float y) { int i = HE.eggIdx; HE.eggIdx = (HE.eggIdx + 1) % 0x1f4; float playing = HE.eggs[i].on && HE.t < HE.eggs[i].t0 + 0xfa + 31 * (1000.0f / 30); // 'break': 250 ms di attesa, 31 frame a 30 fps if (playing) return; HE.eggs[i].x = x + 0.5f * HE.bw + 0x200 * (frand() - 0.5f), HE.eggs[i].y = y + 0.5f * HE.bh + 0x80 * (frand() - 0.5f), HE.eggs[i].t0 = HE.t, HE.eggs[i].on = 1; } static void HE_queueRemovals(int n, float x, float y) { if (HE.nrem < 8) HE.rem[HE.nrem++] = (typeof(HE.rem[0])){ HE.t, x, y, n, 0 }; } // n eventi, uno ogni 10 ms static float HE_px(int i) { return MENU_W + (0.5f * MENU_W - 0.5f * HE.bw - MENU_W) * lerp01(HE.t, 0, 0x96 + 0x1e * i); } static float HE_py(int i) { return HE.TLy + HE.bh + HE.bh * (i + 1) - 0.025f * HE.W; } static void HE_OnPanelClicked(int i) { if (HE.p[i].soldOut) return; float x = HE_px(i), y = HE_py(i); if (!strcmp(HE.p[i].item, "PURIFY")) { Sound_PlaySimple("ClickIn", 0); HE.p[i].tBuy = HE.t; cJSON *c = Egg_char(0); // RemoveEggs(100, x, y) if (!c) return; int n = 0; if (num(c, "total", 0) <= 0x64) EggManager_RemoveAllEggs(), HE_UpdateEggsTotal(), n = 0x64; else for (int k = 0; k < 0x64; k++) n += EggManager_RemoveRandomEgg(); HE_queueRemovals(n, x, y); } else { HE.p[i].soldOut = 1; Sound_PlaySimple("ClickIn", 0); HE.p[i].tBuy = HE.t; EggManager_RemoveAllSpecificEggs("moveSpeed"); HE_UpdateEggsTotal(); HE_queueRemovals(0x64, x, y); } } static void HE_onPanel(void *c) { HE_OnPanelClicked((int)(intptr_t)c); } static void HE_cancel(void) {} static void HE_restoreMusic(void *ctx) { (void)ctx; po_sets("SelectedBGM", HE.savedBGM), po_sets("SelectedBGMMod", HE.savedMod), Sound_SetupAndPlayBGM_Banger(1); } static void HE_onExit(void *c) { // OnButtonClicked: salva, la musica di prima dopo 100 ms (orologio della partita), ResumeFromHealer (void)c; UIButton_off(&HE.Exit); PlayerOptions_Save(); Sound_PlaySimple("ClickIn", 0); Sound_FadeMusic(0, 0x64); time_addEvent(0x64, 0, 0, HE_restoreMusic, NULL); HE.active = 0; Overlay_DestroyGrid(); Sound_FadeMusic(0.3f, 0x1f4); } static void HealerScene_open(void) { static char sb[64], sm[32]; memset(&HL, 0, sizeof(HL)); HE.active = 1, HE.tOk = -1, HE.flipY = 1; snprintf(sb, sizeof(sb), "%s", po_str("SelectedBGM") ? po_str("SelectedBGM") : ""), snprintf(sm, sizeof(sm), "%s", po_str("SelectedBGMMod") ? po_str("SelectedBGMMod") : ""); HE.savedBGM = sb, HE.savedMod = sm; Sound_FadeMusic(0, 0x64); // EnterHealer la abbassa a 0.2, create la spegne e dopo 100 ms parte BGM_Machine for (int i = 0; i < 0x1f4; i++) HE.eggs[i].fx = frand() >= 0.5f; ShopDecor_init(&HE.decor, "colours7.png", "colours8.png", 0, 0); HE.W = 2 * SAFE_WIDTH * 0.8f; float bh = 0x48; HE.TLx = 0.5f * MENU_W - 0.5f * 1.1f * SAFE_WIDTH, HE.TLy = 0x80 - 0.5f * bh; HE.bw = 0.45f * HE.W, HE.bh = 0.2f * 0.8f * DEFAULT_H; HE.p[HE.n++] = (ShopEntry){ .item = "PURIFY", .tBuy = -1 }; if (num(Egg_char(0), "total", 0) >= 0x61a8) HE.p[HE.n++] = (ShopEntry){ .item = "PURIFY2", .tBuy = -1 }; for (int i = 0; i < HE.n; i++) { HE.p[i].price = num(cJSON_GetObjectItem(data_get("items"), HE.p[i].item), "value", 0); HE.p[i].name = HE.name[i], HE.p[i].desc = HE.desc[i]; UIButton_set(&HE.p[i].hit, "", 0, 0, HE.bw, HE.bh, PixelScale, 0, 0); } UIButton_set(&HE.Exit, "BackButton", 0.5f * MENU_W, HE.TLy + 4 * HE.bh - 0.025f * HE.W, 0x60, 0x20, 0, 0.5f, 0.5f); // Vita: mezza riga piu' su, sopra la barra dei tasti Sound_PlaySound("LevelUp", 1, 1, -0x4b0, 0, 0), Sound_PlaySound("LevelUp", 0.5f, 1, -0x5dc, 0, 0); HE_texts(0); // header capovolto e testi rimescolati, poi 8 chiamate ogni 400 ms } static void HealerScene_update(float delta) { float prev = HE.t; HE.t += delta; particles_manager_update(HE.decor.pfx, delta); if (prev < 0x64 && HE.t >= 0x64) po_sets("SelectedBGM", "BGM_Machine"), po_sets("SelectedBGMMod", "Normal"), Sound_SetupAndPlayBGM_Banger(1); while (HE.calls < 8 && HE.t >= 0x190 * (HE.calls + 1)) { // repeatCount 7..0: rimescola, poi i testi veri (1), poi il titolo dritto (0) int rc = 7 - HE.calls++; if (rc == 1) HE_texts(1); else if (rc == 0) HE.flipY = 0; else { utf8_shuffle(HE.header); for (int i = 0; i < HE.n; i++) utf8_shuffle(HE.name[i]), utf8_shuffle(HE.desc[i]); } } for (int r = 0; r < HE.nrem; r++) // le animazioni delle uova tolte, una ogni 10 ms while (HE.rem[r].done < HE.rem[r].n && HE.t >= HE.rem[r].t0 + 0xa * HE.rem[r].done) HE.rem[r].done++, HE_UpdateEggsTotal(), HE_PlayRemovalAnimation(HE.rem[r].x, HE.rem[r].y); for (int i = 0; i < HE.n; i++) HE.p[i].hit.x = HE_px(i), HE.p[i].hit.y = HE_py(i); if (HE.tOk < 0 && HE.t >= 0xbb8) { // enablePanelsInput dopo 3 s HE.tOk = HE.t; for (int i = 0; i < HE.n; i++) UIButton_on(&HE.p[i].hit, HE_onPanel, (void *)(intptr_t)i); } if (HE.tOk >= 0 && !HE.okGrid && HE.t >= HE.tOk + 0x96) { HE.okGrid = 1; int rows = 1 + HE.n; Overlay_MakeUIGrid(1, rows, 1); Overlay_ToggleCursorsVisibility(1); for (int i = 0; i < HE.n; i++) UIGrid_SetContents(i, i, &HE.p[i].hit, 0); // (sic) SetContents(i, floor(i)): il secondo finisce sotto l'uscita UIGrid_SetContents(0, rows - 1, &HE.Exit, 0); UIGrid_SelectGameObject(&HE.Exit); OV.UI_selected = &HE.Exit; OV.OnCancelCallback = HE_cancel; // (sic) il cerchio non fa niente: si esce col bottone vui_prompt_select(); UIButton_on(&HE.Exit, HE_onExit, NULL); } Overlay_update(delta); if (!HE.active) return; if (!UIButton_clicked(&HE.Exit)) for (int i = 0; i < HE.n; i++) if (UIButton_clicked(&HE.p[i].hit)) break; const char *buy = getenv("VS_SHOPBUY"); // sviluppo: anche qui compra il pannello i una volta static int bought; if (HE.t <= delta) bought = 0; if (buy && HE.okGrid && !bought && atoi(buy) < HE.n) bought = 1, HE_OnPanelClicked(atoi(buy)); if (getenv("VS_AUTOPICK") && OV.UI_selected == &HE.Exit && HE.Exit.onDown && HE.t > HE.tOk + 0x7d0 && fmodf(HE.t, 0x190) < delta) Overlay_OnSubmitPressed(); } static void HealerScene_draw(void) { float t = HE.t, cx = 0.5f * MENU_W; ShopDecor_draw(&HE.decor, t, 1); float k = lerp01(t, 0, 0x96), sx = -0.2f + 1.2f * k, sy = -0.1f + 1.1f * k, ang = 0xb4 * (1 - k); float pa = fmodf(t, 0xfa0) / 0x7d0, a = 1 - 0.05f * (pa < 1 ? pa : 2 - pa); TS_nine("frame5_c4.png", 12, 12, cx, 0x80 + 9, 1.1f * SAFE_WIDTH, 0x48, sx, sy, ang, Fade(WHITE, a)); float hy = HE.TLy + 0x2d; rlPushMatrix(); // header.flipY rlTranslatef(cx, hy, 0); rlScalef(1, HE.flipY ? -1 : 1, 1); rlDrawRenderBatchActive(), rlDisableBackfaceCulling(); // la scala negativa gira i quad TS_text(HE.header, 0, 0, fit_size(HE.header, 16, 0xfa), 2 * PixelScale, 0, WHITE); rlDrawRenderBatchActive(), rlEnableBackfaceCulling(); rlPopMatrix(); cJSON *c = Egg_char(0); char tot[24] = ""; if (c) snprintf(tot, sizeof(tot), "%g", num(c, "total", 0)); ShopCoins_draw(t, "items", "goldenegg.png", tot); for (int i = 0; i < HE.n; i++) ShopEntryPanel_draw(&HE.p[i], HE_px(i), HE_py(i), HE.bw, HE.bh, HE.t); float bk = HE.tOk >= 0 ? lerp01(t, HE.tOk, 0x96) : 0; if (bk > 0.001f) { TS_nine("button_c8_normal.png", 9, 14, HE.Exit.x, HE.Exit.y, 0x60, 0x20, 2 * PixelScale * bk, 2 * PixelScale * bk, -0x5a * (1 - bk), WHITE); const char *et = tr("topBar_back"); TS_text(et, HE.Exit.x, HE.Exit.y, fit_size(et, 16, 0x50), 2 * PixelScale * bk, -0x5a * (1 - bk), WHITE); } HE.Exit.sc = 2 * PixelScale * (bk > 0.99f); for (int i = 0; i < 0x1f4; i++) { // le uova che si rompono (restano all'ultimo frame) if (!HE.eggs[i].on) continue; float lt = t - HE.eggs[i].t0 - 0xfa; int f = lt < 0 ? 0 : (int)fminf(30, lt / (1000.0f / 30)); const Frame *fr = frame_get("items", TextFormat("eggeye_%d.png", f)); if (!fr) continue; Sprite s; sprite_init(&s, fr, HE.eggs[i].x, HE.eggs[i].y); sprite_setScale(&s, 2), s.flipX = HE.eggs[i].fx, s.scrollFactor0 = 1; scene_render_one(&s, (Shader){ 0 }); } int bf = (int)(t / (1000.0f / 30)); if (bf < 6 && po_is("FlashingVFXEnabled")) TS_frame("vfx", TextFormat("Burst%d.png", bf + 1), cx, 0.5f * MENU_W, 0.5f, 0.5f, 8, 0, WHITE, 1); vui_prompt_bar(); Overlay_draw(); } // ============================================================================ // 0xd1dd: UI_directerScene. Con lo Specchio e la Tromba (3) il testo si rimescola finche' non premi OK, poi il 4: "pronto?", // OK -> la battaglia (DirecterManager.StartPhase0). Con una sola reliquia (2) OK da' l'altra; senza (1) FACILE = Specchio, // DIFFICILE = Tromba. Sopra la MainScene in pausa, alla risoluzione da menu, come il guaritore. // ============================================================================ static struct { int active, flag, okGrid, flipY, shufCalls, shufTotal, shufMode; float t, tBtn, tHide, shufStart, shufPeriod; char header[512]; const char *langKey; ShopDecor decor; UIButton OK, EASY, HARD; } DS; static void DirecterManager_StartPhase0(void); static void DS_cancel(void) {} static void SceneManager_ResumeFromDirecter(void) { // resume MainScene, stop scena, DestroyGrid, RemoveSnapshot, blockInput = false DS.active = 0; Overlay_DestroyGrid(), vui_prompts_clear(); } static void DS_MakeUIGrid(void) { Overlay_MakeUIGrid(DS.flag == 1 ? 2 : 1, 1, 1); Overlay_ToggleCursorsVisibility(1); if (DS.flag == 1) { UIGrid_SetContents(0, 0, &DS.EASY, 0), UIGrid_SetContents(1, 0, &DS.HARD, 0); UIGrid_SelectGameObject(&DS.HARD), OV.UI_selected = &DS.HARD; } else { UIGrid_SetContents(0, 0, &DS.OK, 0); UIGrid_SelectGameObject(&DS.OK), OV.UI_selected = &DS.OK; } OV.OnCancelCallback = DS_cancel; vui_prompt_select(); } static void DS_relic(const char *r) { // Core.CurrentFoundRelic, Save, ClickIn, pannello via, ResumeFromDirecter, EnterRelicFound PlayerOptions_Save(); Sound_PlaySimple("ClickIn", 0); Core.CurrentFoundRelic = r; SceneManager_ResumeFromDirecter(); RelicFoundScene_open(); } static void DS_onEasy(void *c) { (void)c; Core.JustGotMirror = 1; DS_relic("RELIC_MIRROR"); } // OnTooEasyPressed static void DS_onHard(void *c) { (void)c; Core.JustGotTrumpet = 1; DS_relic("RELIC_TRUMPET"); } // OnTooHardPressed static void DS_startShuffle(int mode, float period, int total) { DS.shufMode = mode, DS.shufPeriod = period, DS.shufTotal = total, DS.shufCalls = 0, DS.shufStart = DS.t; } static void DS_onOk(void *c) { // OnButtonClicked (void)c; UIButton_off(&DS.OK), UIButton_off(&DS.EASY), UIButton_off(&DS.HARD); // disablePanelsInput PlayerOptions_Save(); Sound_PlaySimple("ClickIn", 0); if (DS.flag == 2) { const char *r = "RELIC_TRUMPET"; Core.JustGotTrumpet = 1; if (po_has("CollectedItems", "RELIC_TRUMPET")) r = "RELIC_MIRROR", Core.JustGotMirror = 1, Core.JustGotTrumpet = 0; Core.CurrentFoundRelic = r; SceneManager_ResumeFromDirecter(); RelicFoundScene_open(); } else if (DS.flag == 3) { // il 4: "sei pronto?", bottoni via, rimescolamento di 8 passi da 200 ms DS.flag = 4, DS.langKey = "directer_4"; snprintf(DS.header, sizeof(DS.header), "%s", tr(DS.langKey)); DS.tHide = DS.t; Overlay_DestroyGrid(), DS.okGrid = 0; DS_startShuffle(2, 0xc8, 8); } else if (DS.flag == 4) { SceneManager_ResumeFromDirecter(); DirecterManager_StartPhase0(); } } static void DS_enablePanelsInput(void) { DS.tBtn = DS.t, DS.tHide = -1, DS.okGrid = 0; } // bottoni dentro in 150 ms, poi griglia e input static void DirecterScene_open(void) { // SceneManager.EnterDirecter memset(&DS, 0, sizeof(DS)); DS.active = 1, DS.flipY = 1, DS.tBtn = DS.tHide = -1; ShopDecor_init(&DS.decor, "colours3.png", "colours4.png", -0x20, -0xc); int mirror = po_has("CollectedItems", "RELIC_MIRROR"), trumpet = po_has("CollectedItems", "RELIC_TRUMPET"); DS.flag = mirror && trumpet ? 3 : mirror || trumpet ? 2 : 1; DS.langKey = DS.flag == 3 ? "directer_3" : DS.flag == 2 ? "directer_2" : "directer_1"; snprintf(DS.header, sizeof(DS.header), "%s", tr(DS.langKey)); float W2 = 2 * SAFE_WIDTH * 0.8f, TLy = 0x80 - 0.5f * 0x90, bh = 0.2f * 0.8f * DEFAULT_H; float oy = fminf(TLy + 4.5f * bh - 0.025f * W2, MENU_H - 44 - 0x28); // Vita: sopra la barra dei tasti UIButton_set(&DS.OK, "OptionsButton", 0.5f * MENU_W, oy, 0x60, 0x20, 0, 0.5f, 0.5f); UIButton_set(&DS.EASY, "BackButton", 0.5f * MENU_W - 0x90, oy, 0x60, 0x20, 0, 0.5f, 0.5f); UIButton_set(&DS.HARD, "GreenButton", 0.5f * MENU_W + 0x90, oy, 0x60, 0x20, 0, 0.5f, 0.5f); Sound_PlaySound("LevelUp", 1, 1, -0x4b0, 0, 0), Sound_PlaySound("LevelUp", 0.5f, 1, -0x5dc, 0, 0); utf8_shuffle(DS.header); // ShuffleHeader subito, header capovolto if (DS.flag == 3) DS_startShuffle(1, 0xc8, -1); // senza fine (repeat -1: repeatCount non arriva mai a 1, sic) else DS_startShuffle(0, 0x190, 8); } static void DirecterScene_update(float delta) { DS.t += delta; particles_manager_update(DS.decor.pfx, delta); while (DS.shufMode >= 0 && (DS.shufTotal < 0 || DS.shufCalls < DS.shufTotal) && DS.t >= DS.shufStart + DS.shufPeriod * (DS.shufCalls + 1)) { int rc = DS.shufTotal < 0 ? -1 : DS.shufTotal - 1 - DS.shufCalls; DS.shufCalls++; if (DS.shufMode == 1) { // 3: fiamme rosse, testo sempre rimescolato ShopDecor_setFrames(&DS.decor, "colours7.png", "colours8.png"); utf8_shuffle(DS.header); } else if (rc == 1) { if (DS.shufMode == 2) Sound_FadeMusic(0, 0x190); snprintf(DS.header, sizeof(DS.header), "%s", tr(DS.langKey)); } else if (rc == 0) { DS.flipY = 0; if (DS.shufMode == 2) DS_enablePanelsInput(); } else utf8_shuffle(DS.header); } if (DS.tBtn < 0 && DS.flag != 4 && DS.t >= 0xbb8) DS_enablePanelsInput(); // ShowPanels: enablePanelsInput dopo 3 s if (DS.tBtn >= 0 && DS.tHide < 0 && !DS.okGrid && DS.t >= DS.tBtn + 0x96) { DS.okGrid = 1; DS_MakeUIGrid(); if (DS.flag == 1) UIButton_on(&DS.EASY, DS_onEasy, NULL), UIButton_on(&DS.HARD, DS_onHard, NULL); else UIButton_on(&DS.OK, DS_onOk, NULL); } Overlay_update(delta); if (!DS.active) return; if (!UIButton_clicked(&DS.OK) && !UIButton_clicked(&DS.EASY)) UIButton_clicked(&DS.HARD); if (getenv("VS_AUTOPICK") && DS.okGrid && OV.UI_selected && OV.UI_selected->onDown && fmodf(DS.t, 0x190) < delta) Overlay_OnSubmitPressed(); } static void DS_button(UIButton *b, const char *frame, const char *key, float k, float ang) { if (k <= 0.001f) return; TS_nine(frame, 9, 14, b->x, b->y, 0x60, 0x20, 2 * PixelScale * k, 2 * PixelScale * k, ang, WHITE); const char *s = tr(key); TS_text(s, b->x, b->y, fit_size(s, 16, 0x50), 2 * PixelScale * k, ang, WHITE); b->sc = 2 * PixelScale * (k > 0.99f); } static void DirecterScene_draw(void) { float t = DS.t, W = MENU_W, cx = 0.5f * W; float km = ease_sine_inout(lerp01(t, 0, 0x7d0)); // sei maschere nere che scendono e si allargano static const char *const M[6] = { "mask_sun_0.png", "mask_moon_0.png", "mask_city_0.png", "mask_seawind_0.png", "mask_volcano_0.png", "mask_stone_0.png" }; for (int i = 0; i < 6; i++) { const Frame *f = frame_get("enemiesM", M[i]); if (!f) continue; Sprite s; sprite_init(&s, f, (i + 1) * W / 7, -0x80 + (0x110 + 0x80) * km); s.scaleX = -0.1f + 4.1f * km, s.scaleY = 4, s.tint = 0, s.scrollFactor0 = 1; scene_render_one(&s, (Shader){ 0 }); } ShopDecor_draw(&DS.decor, t, 0); float k = lerp01(t, 0, 0x96), sx = -0.2f + 1.2f * k, sy = -0.1f + 1.1f * k, ang = 0xb4 * (1 - k); float pa = fmodf(t, 0xfa0) / 0x7d0, a = 1 - 0.05f * (pa < 1 ? pa : 2 - pa); TS_nine("frame5_c4.png", 12, 12, cx, 0x80 + 0x10, 1.1f * SAFE_WIDTH, 0x90, sx, sy, ang, Fade(WHITE, a)); // header: scala 2, a capo a 250, ridotto a 250 x 90 (qui centrato riga per riga), capovolto finche' flipY float size = 32, wrap = 500; char lines[8][256]; int nl = 0; for (int tries = 0; tries < 6; tries++, size *= 0.85f) { nl = 0; const char *p = DS.header; while (*p && nl < 8) { char line[256] = ""; const char *last = p; for (const char *q = p;; q++) { if (*q == ' ' || *q == 0 || *q == '\n') { char tryl[256]; snprintf(tryl, sizeof(tryl), "%.*s", (int)(q - p), p); if (MeasureTextEx(vs_font, tryl, size, 0).x > wrap && line[0]) break; snprintf(line, sizeof(line), "%s", tryl), last = q; if (*q != ' ') break; } } if (!line[0]) { snprintf(line, sizeof(line), "%.60s", p); last = p + strlen(line); } snprintf(lines[nl++], 256, "%s", line); p = *last ? last + 1 : last; } if (nl * size * 1.2f <= 180) break; } float hy = 0x80 + 0x10; rlPushMatrix(); rlTranslatef(cx, hy, 0); rlScalef(1, DS.flipY ? -1 : 1, 1); rlDrawRenderBatchActive(), rlDisableBackfaceCulling(); for (int i = 0; i < nl; i++) text_at(lines[i], 0, (i - 0.5f * (nl - 1)) * size * 1.2f, size, 0.5f, 0.5f, WHITE); rlDrawRenderBatchActive(), rlEnableBackfaceCulling(); rlPopMatrix(); float kb = DS.tBtn >= 0 ? lerp01(t, DS.tBtn, 0x96) : 0, angb = -0x5a * (1 - kb); // dentro: -90 -> 0; via: scala 0 e -45 if (DS.tHide >= 0) { float d = lerp01(t, DS.tHide, 0x96); kb = 1 - d, angb = -0x2d * d; } if (DS.flag == 1) DS_button(&DS.EASY, "button_c8_normal.png", "directer_easy", kb, angb), DS_button(&DS.HARD, "button_c5_normal.png", "directer_hard", kb, angb); else DS_button(&DS.OK, "button_c9_normal.png", "charFound_ok", kb, angb); int bf = (int)(t / (1000.0f / 30)); if (bf < 6 && po_is("FlashingVFXEnabled")) TS_frame("vfx", TextFormat("Burst%d.png", bf + 1), cx, 0.5f * MENU_W, 0.5f, 0.5f, 8, 0, WHITE, 1); vui_prompt_bar(); Overlay_draw(); } // ============================================================================ // 0xae1e: UI_pianoScene, il pianoforte della Biblioteca (Do, Re, Mi... la melodia e' 2 9 10 7 1 sui 12 tasti). // Gira alla risoluzione di gioco sopra la MainScene in pausa: coordinate di gioco, disegnate scalate nello spazio da menu // (i bottoni stanno in coordinate da menu per la griglia dell'overlay e il puntatore). Ebony Wings e Peachone, se li hai, // volano sui tasti giusti; keysPushed resta tra una visita e l'altra (sta nel costruttore della scena, sic). // ============================================================================ static void Library_BigSpoop(void); static struct { int active, hintCounter, hasEbony, hasPeachone; Sprite fader, piano, pianoOverlay, ebony, peachone; Animation ebonyIdle, peachoneIdle; UIButton Back, keys[12]; Vector2 keyPos[12]; // in coordinate di gioco TweenRef ebonyX, ebonyY, ebonyA, peachoneX, peachoneY, peachoneA; } PN; static const int PN_keysToPush[5] = { 2, 9, 10, 7, 1 }; static int PN_keysPushed[5], PN_nPushed; static float PN_k(void) { return (float)MENU_H / game_height; } // da gioco a menu static float PN_ox(void) { return 0.5f * (MENU_W - game_width * PN_k()); } static void PN_flyInNext(void *ctx); static void PN_birdOut(void *ctx) { // flyOutEbony / flyOutPeachone Sprite *b = ctx; TweenRef *a = b == &PN.ebony ? &PN.ebonyA : &PN.peachoneA; *a = ARC_tween((TweenConfig){ .props = { { &b->alpha, NULL, 0 } }, .nprops = 1, .delay = 0x1f4, .duration = 0x1f4 }); } static void PN_flyIn(int ebony, int k) { // flyInEbony / flyInPeachone Sprite *b = ebony ? &PN.ebony : &PN.peachone; TweenRef *tx = ebony ? &PN.ebonyX : &PN.peachoneX, *ty = ebony ? &PN.ebonyY : &PN.peachoneY, *ta = ebony ? &PN.ebonyA : &PN.peachoneA; ARC_tweenStop(*tx), ARC_tweenStop(*ty), ARC_tweenStop(*ta); anims_play(b, ebony ? &PN.ebonyIdle : &PN.peachoneIdle, 0); b->alpha = 0; if (frand() < 0.5f) b->x = SAFE_R, b->flipX = 1; else b->x = 0, b->flipX = 0; b->y = 0x64 + 0x64 * frand(); *ta = ARC_tween((TweenConfig){ .props = { { &b->alpha, NULL, (ebony ? PN.hasEbony : PN.hasPeachone) ? 1 : 0 } }, .nprops = 1, .duration = 0x1f4 }); *tx = ARC_tween((TweenConfig){ .props = { { &b->x, NULL, PN.keyPos[k].x } }, .nprops = 1, .duration = 0xbb8 }); // birdSpeedMS *ty = ARC_tween((TweenConfig){ .props = { { &b->y, NULL, PN.keyPos[k].y + (ebony ? 0 : 0x14) } }, .nprops = 1, .duration = 0xbb8, .ease = Ease_SineOut, .onComplete = PN_birdOut, .ctx = b }); } static void PN_flyInNext(void *ctx) { (void)ctx; if (!PN.active) return; int k = PN_keysToPush[PN.hintCounter]; PN_flyIn(k == 1 || k == 3 || k == 6 || k == 8 || k == 0xa, k); if (++PN.hintCounter == 5) PN.hintCounter = 0; ARC_timer(0xfa0 + 0x7d0 * frand(), 0, 0, PN_flyInNext, NULL); } static void SceneManager_ExitPianoScene(void) { Overlay_DestroyGrid(); PN.active = 0; } // resume(MainScene), stop(UI_pianoScene) static void PN_exitDone(void *ctx) { (void)ctx; SceneManager_ExitPianoScene(); } static void PN_successDone(void *ctx) { // DoTheBigSpoop: fancyBG.BigSpoop (solo la Biblioteca ce l'ha) (void)ctx; if (Core.Stage && Core.Stage->fancyBG == &FB_Library) Library_BigSpoop(); SceneManager_ExitPianoScene(); } static void PN_leave(int success) { // Exit / ExitSuccessfully ARC_tweenStop(PN.ebonyX), ARC_tweenStop(PN.ebonyY), ARC_tweenStop(PN.ebonyA), ARC_tweenStop(PN.peachoneX), ARC_tweenStop(PN.peachoneY), ARC_tweenStop(PN.peachoneA); PN.peachoneA = ARC_tween((TweenConfig){ .props = { { &PN.ebony.alpha, NULL, 0 }, { &PN.peachone.alpha, NULL, 0 } }, .nprops = 2, .duration = 0x1f4 }); ARC_tween((TweenConfig){ .props = { { &PN.fader.alpha, NULL, 0 }, { &PN.pianoOverlay.alpha, NULL, 0 } }, .nprops = 2, .duration = 0x1f4 }); ARC_tween((TweenConfig){ .props = { { &PN.piano.scaleX, &PN.piano.scaleY, 0 }, { &PN.pianoOverlay.scaleX, &PN.pianoOverlay.scaleY, 0 } }, .nprops = 2, .duration = 0x1f4, .onComplete = success ? PN_successDone : PN_exitDone }); } static void PN_Exit(void) { PN_leave(0); } static void PN_onBack(void *c) { (void)c; Sound_PlaySimple("ClickOut", 0); PN_leave(0); } static void PN_pushKey(int k) { static const char *const S[12] = { "KeyWrong", "Key5", "Key1", "KeyWrong", "KeyWrong", "KeyWrong", "KeyWrong", "Key4", "KeyWrong", "Key2", "Key3", "KeyWrong" }; Sound_PlaySimple(S[k], 1.5f); if (PN_nPushed < 5 && PN_keysToPush[PN_nPushed] == k) PN_keysPushed[PN_nPushed++] = k; else PN_nPushed = 0; // keysToPush[5] e' undefined: dopo la melodia completa il primo tasto azzera if (PN_nPushed == 5) PN_leave(1); } static void PN_onKey(void *c) { PN_pushKey((int)(intptr_t)c); } static void PN_EnableInput(void *ctx) { (void)ctx; UIButton_on(&PN.Back, PN_onBack, NULL); for (int i = 0; i < 12; i++) UIButton_on(&PN.keys[i], PN_onKey, (void *)(intptr_t)i); PN_flyInNext(NULL); Overlay_MakeUIGrid(12, 2, 1); // MakeUIGrid for (int i = 0; i < 12; i++) UIGrid_SetContents(i, 0, &PN.Back, 0), UIGrid_SetContents(i, 1, &PN.keys[i], 0); UIGrid_SelectGameObject(&PN.Back); OV.UI_selected = &PN.Back; Overlay_ToggleCursorsVisibility(1); OV.OnCancelCallback = PN_Exit; } static void PN_sprite(Sprite *s, const char *atlas, const char *frame, float x, float y) { sprite_init(s, frame_get(atlas, frame), x, y); s->scrollFactor0 = 1; } static void SceneManager_EnterPianoScene(void) { // pause(MainScene), start(UI_pianoScene), launch(UI_overlayScene) memset(arc_tw, 0, sizeof(arc_tw)), memset(arc_tm, 0, sizeof(arc_tm)); // Clock e TweenManager della scena memset(&PN, 0, sizeof(PN)); PN.active = 1; float W = game_width, H = game_height, k = PN_k(), ox = PN_ox(); PN_sprite(&PN.fader, "items", "blackDot.png", -0xa, -0xa); sprite_setOrigin(&PN.fader, 0, 0), PN.fader.scaleX = W + 0x14, PN.fader.scaleY = H + 0x14, PN.fader.alpha = 0; PN_sprite(&PN.piano, "items", "Larobba02.png", 0.5f * W, 0.5f * H), sprite_setScale(&PN.piano, 8); PN_sprite(&PN.pianoOverlay, "items", "Overlay.png", 0.5f * W, 0.5f * H), sprite_setScale(&PN.pianoOverlay, 8), PN.pianoOverlay.alpha = 0; ARC_tween((TweenConfig){ .props = { { &PN.fader.alpha, NULL, 0.65f } }, .nprops = 1, .duration = 0x1f4 }); ARC_tween((TweenConfig){ .props = { { &PN.pianoOverlay.alpha, NULL, 1 } }, .nprops = 1, .duration = 0x1f4, .onComplete = PN_EnableInput }); // BackButton: NineSlice 48x30 a (SAFEAREA.right - 100, 3), scala 4 * MASTER_SCALE, origine (1, 0) UIButton_set(&PN.Back, "BackButton", ((SAFE_R - 0x64) * k) + ox, 3 * k, 0x30, 0x1e, 4 * MASTER_SCALE * k, 1, 0); // i tasti: rettangoli invisibili (WhiteDot 1x1 scalato, alpha 0.00001), bianchi in basso e neri 12 px piu' su float x1 = PN.piano.x - 0x74, y1 = PN.piano.y + 0x58, y2 = y1 - 0xc; static const float KX[12] = { 0, 8, 0x14, 0x20, 0x28, 0x37, 0x40, 0x4c, 0x58, 0x64, 0x70, 0x78 }, KW[12] = { 0x10, 0x10, 0x18, 0x10, 0x10, 0xf, 0x10, 0x18, 0x10, 0x18, 0x10, 0x10 }; static const int SHARP[12] = { 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0 }; for (int i = 0; i < 12; i++) { PN.keyPos[i] = (Vector2){ x1 + KX[i], SHARP[i] ? y2 : y1 }; float h = SHARP[i] ? 0x28 : 0x40; UIButton_set(&PN.keys[i], "", PN.keyPos[i].x * k + ox, PN.keyPos[i].y * k, KW[i], h, k, 0.5f, 0.5f); } make_anim(&PN.ebonyIdle, "vfx", "ProjectileBird", 4, 5, 0, 6, -1); make_anim(&PN.peachoneIdle, "vfx", "ProjectileBird", 1, 2, 0, 6, -1); PN_sprite(&PN.ebony, "vfx", "ProjectileBird4.png", PN.keyPos[1].x, PN.keyPos[1].y), anims_play(&PN.ebony, &PN.ebonyIdle, 0), sprite_setScale(&PN.ebony, 2), PN.ebony.alpha = 0; PN_sprite(&PN.peachone, "vfx", "ProjectileBird2.png", PN.keyPos[1].x, PN.keyPos[1].y), anims_play(&PN.peachone, &PN.peachoneIdle, 0), sprite_setScale(&PN.peachone, 2), PN.peachone.alpha = 0; for (int i = 0; i < Core.n_weapons; i++) { if (!strcmp(Core.Weapons[i]->bulletType, "SILF")) PN.hasPeachone = 1; if (!strcmp(Core.Weapons[i]->bulletType, "SILF2")) PN.hasEbony = 1; } for (int i = 0; i < Core.n_HiddenWeapons; i++) { if (!strcmp(Core.HiddenWeapons[i]->bulletType, "SILF")) PN.hasPeachone = 1; if (!strcmp(Core.HiddenWeapons[i]->bulletType, "SILF2")) PN.hasEbony = 1; } } static void PianoScene_update(float delta) { ARC_clock(delta); sprite_animsUpdate(&PN.ebony, delta), sprite_animsUpdate(&PN.peachone, delta); Overlay_update(delta); if (!PN.active) return; if (!UIButton_clicked(&PN.Back)) for (int i = 0; i < 12; i++) if (UIButton_clicked(&PN.keys[i])) break; const char *seq = getenv("VS_PIANOKEYS"); // sviluppo: VS_PIANOKEYS=2,9,10,7,1 suona i tasti uno ogni 400 ms appena c'e' l'input static float tk; static int ik; if (seq && PN.Back.interactive) { if ((tk += delta) >= 0x190) { tk = 0; const char *p = seq; for (int i = 0; i < ik && p; i++) p = strchr(p, ','), p = p ? p + 1 : NULL; if (p) ik++, PN_pushKey(atoi(p)); } } else tk = 0, ik = 0; } static void PianoScene_draw(void) { float k = PN_k(); rlPushMatrix(); rlTranslatef(PN_ox(), 0, 0); rlScalef(k, k, 1); scene_render_one(&PN.fader, (Shader){ 0 }); scene_render_one(&PN.piano, (Shader){ 0 }); scene_render_one(&PN.pianoOverlay, (Shader){ 0 }); float bx = SAFE_R - 0x64 - 0x30 * 4 * MASTER_SCALE * 0.5f, by = 3 + 0x1e * 4 * MASTER_SCALE * 0.5f; // centro del bottone TS_nine("button_c8_normal.png", 9, 14, bx, by, 0x30, 0x1e, 4 * MASTER_SCALE, 4 * MASTER_SCALE, 0, WHITE); const char *bt = tr("topBar_back"); TS_text(bt, bx, by, fit_size(bt, 16 * 2 * MASTER_SCALE, 0x5a), 1, 0, WHITE); scene_render_one(&PN.ebony, (Shader){ 0 }); scene_render_one(&PN.peachone, (Shader){ 0 }); rlPopMatrix(); Overlay_draw(); } // ============================================================================ // 0x6435: UI_relicFoundScene, con YellowSignManager (0x13c49) e GospelManager (0x15bc0) // ============================================================================ static int SM_reset; // SceneManager.Reset: la partita finisce e si torna all'Intro (PreloadSceneX) static void SceneManager_Reset(void) { Sound_StopMusic(); SM_reset = 1; } enum { RF_NORMAL, RF_YELLOW, RF_GOSPEL, RF_FADE }; static struct { int active, okGrid, mode, zoomIndex, claps, clapOn, gospelDone; float t, tOk, tClick, tClap, tZoomEnd, tGospelEnd, zoom, camX, camY; const char *relic; ParticleManager *pfx, *fw; ParticleEmitter *rain, *fwE[7]; UIButton OkButton; } RF; static float RF_bgW(void) { return 0.8f * SAFE_WIDTH; } static float RF_bgH(void) { return 0.8f * DEFAULT_H; } static void RF_onOk(void *c); static void RelicFoundScene_open(void) { // SwapToRelicFoundScene: EnterRelicFound + musica giu' memset(&RF, 0, sizeof(RF)); RF.active = 1; RF.relic = Core.CurrentFoundRelic; RF.tOk = RF.tClick = RF.tClap = RF.tZoomEnd = RF.tGospelEnd = -1; RF.zoom = 1, RF.camX = 0.5f * MENU_W, RF.camY = 0.5f * MENU_H; Sound_FadeMusic(0.2f, 0x1f4); RF.pfx = particles_add(), children_remove(&RF.pfx->s), RF.pfx->scrollFactor0 = 1; RF.rain = CF_rain_in(RF.pfx, 1); UIButton_set(&RF.OkButton, "OptionsButton", 0.5f * MENU_W, 0.5f * MENU_H - 0.5f * RF_bgH() + 3 * 0.2f * RF_bgH() - 0.025f * RF_bgW(), 0x60, 0x20, 0, 0.5f, 0.5f); if (!strcmp(RF.relic, "RELIC_GGOSPEL")) { // new GospelManager: il battimani resta a clap01 sul fondo dall'inizio RF.mode = RF_GOSPEL, RF.clapOn = 1; RF.fw = particles_add(), children_remove(&RF.fw->s), RF.fw->scrollFactor0 = 1; static const char *const FW[4] = { "PfxYellow.png", "PfxPink.png", "PfxRed.png", "PfxGreen.png" }; RF.fw->hasWell = 1; // createGravityWell({ x: W/2, y: H/2, power: 1, epsilon: 25, gravity: 150 }) RF.fw->wellX = 0.5f * MENU_W, RF.fw->wellY = 0.5f * MENU_H, RF.fw->wellPower = 0x96, RF.fw->wellEpsilon = 0x19 * 0x19; for (int i = 0; i < 7; i++) { // StartFireworks RF.fwE[i] = particles_createEmitter(RF.fw, (EmitterConfig){ .frames = { frame_get("vfx", FW[i % 4]) }, .nframes = 1, .lifespan = EOP(0xbb8), .rotate = ERND(0, 0x168), .angle = { 0, 0x168, 0 }, .angleSteps = 0x10, .speed = ERND(0x64, 0x96 + i / 5.0f * 0x12c / 2), .quantity = (int)(0x20 + i / 5.0f * 0x20), .scale = ERANGE(2 + i / 5.0f * 2, 0), .frequency = 0x40, .blendAdd = 1, .on = 0 }); RF.fwE[i]->x = 0.5f * MENU_W + (frand() - 0.5f) * SAFE_WIDTH; RF.fwE[i]->y = 0.5f * MENU_H - 0x7d - 0x96 * frand() / 2; } } Sound_PlaySound("LevelUp", 1.25f, 1, 0x3e8, 0, 0); // PickItem } static void RF_resume(void) { // ResumeFromRelicFound -> Core.ExitLevelUpScene RF.active = 0; Overlay_DestroyGrid(); Sound_FadeMusic(0.3f, 0x1f4); } static void RF_AddRelicNotFromPickup(const char *r) { if (po_has("CollectedItems", r)) return; obj_set(cJSON_GetObjectItem(data_get("items"), r), "seen", cJSON_CreateTrue()); po_push("CollectedItems", r); } static void YellowSign_UnlockWeapons(void) { static const char *const W[4] = { "GOLD", "SILVER", "LEFT", "RIGHT" }; for (int i = 0; i < 4; i++) if (!po_has("UnlockedWeapons", W[i])) po_push("UnlockedWeapons", W[i]); for (int i = 0; i < 4; i++) obj_set(tbl0("weapons", W[i]), "isUnlocked", cJSON_CreateTrue()); AchievementManager_GetNewSecretsEarnedOnThisRun(); AchievementManager_GetNewAchievementsEarnedOnThisRun(); PlayerOptions_Save(); // Integration: FindYellowSign / FindYellowSignS5 di Steam dopo 30 s } static void RF_onOk(void *c) { // OnButtonClicked (void)c; UIButton_off(&RF.OkButton); const char *r = RF.relic; if (!strcmp(r, "RELIC_RANDOMAZZO")) { obj_set(tbl0("arcana", "6"), "unlocked", cJSON_CreateTrue()); // T06_SARABANDE Core.GiveMainArcana = 1; if (!po_has("UnlockedArcanas", "6")) cJSON_AddItemToArray(po("UnlockedArcanas"), cJSON_CreateNumber(6)); PlayerOptions_Save(); } else if (!strcmp(r, "RELIC_YELLOW")) { // new YellowSignManager + Start RF.mode = RF_YELLOW, RF.tClick = RF.t; Sound_PlaySimple("ClickIn", 0); Sound_StopMusic(); Overlay_DestroyGrid(); YellowSign_UnlockWeapons(); Sound_StopSound("Wind"); return; } else if (!strcmp(r, "RELIC_GGOSPEL")) { RF.tClick = RF.t; RF.rain->c.quantity = 0x20, RF.rain->c.lifespan = EOP(0x5dc); Sound_PlaySimple("ClickIn", 0); Sound_StopMusic(); // GospelManager.Start Sound_PlaySimple("Piano", 0.5f); Sound_PlaySimple("CFFX", 0.5f); Overlay_DestroyGrid(); return; } else if (!strcmp(r, "RELIC_TRUMPET") || !strcmp(r, "RELIC_MIRROR")) { // dal directer: si torna alla Foresta RF_AddRelicNotFromPickup(r); PlayerOptions_Save(); AchievementManager_UnlockAchievement(!strcmp(r, "RELIC_TRUMPET") ? "ObtainSeventhTrumpet" : "ObtainGraciasMirror"); RF.mode = RF_FADE, RF.tClick = RF.t; Sound_PlaySimple("ClickIn", 0); Overlay_DestroyGrid(); Sound_StopMusic(); return; } RF_resume(); } static void YellowSign_Zoom(void) { // ClapSound -> Zoom: la camera della scena entra nel pannello switch (RF.zoomIndex) { case 0: RF.zoom += 0.5f; Sound_PlaySound("Clap", 2, 1, 0, 0, 0); break; case 1: RF.zoom += 0.5f, RF.camX = 0x1ae, RF.camY = 0xf0; Sound_PlaySound("Clap", 2, 1, -0x64, 0, 0), Sound_PlaySound("Clap", 2, 0.9f, -0xc8, 0, 0); break; case 2: RF.zoom += 1, RF.camX = 0x17c, RF.camY = 0xbe; Sound_PlaySound("Clap", 2, 1, -0xc8, 0, 0), Sound_PlaySound("Clap", 2, 0.9f, -0x12c, 0, 0); break; case 3: RF.zoom += 4, RF.camX = 0x17c, RF.camY = 0xbe; Sound_PlaySound("Clap", 2, 1, -0x1f4, 0, 0), Sound_PlaySound("Clap", 2, 0.9f, -0x320, 0, 0); break; case 4: RF.zoom += 0x28, RF.camX = 0x17c, RF.camY = 0xbe; Sound_PlaySound("Clap", 2, 1, -0x514, 0, 0), Sound_PlaySound("Clap", 2, 1, -0x834, 0, 0); RF.tZoomEnd = RF.t; break; } RF.zoomIndex++; } static void RelicFoundScene_update(float delta) { float prev = RF.t; RF.t += delta; float t = RF.t; particles_manager_update(RF.pfx, delta); if (RF.fw) particles_manager_update(RF.fw, delta); if (RF.tOk < 0 && t >= 0xbb8) RF.tOk = t; // enablePanelsInput dopo 3 s if (RF.tOk >= 0 && !RF.okGrid && t >= RF.tOk + 0x96) { // MakeUIGrid a fine tween del bottone RF.okGrid = 1; Overlay_MakeUIGrid(1, 1, 1); Overlay_ToggleCursorsVisibility(1); UIGrid_SetContents(0, 0, &RF.OkButton, 0); UIGrid_SelectGameObject(&RF.OkButton); OV.UI_selected = &RF.OkButton; OV.OnCancelCallback = PG_cancel; UIButton_on(&RF.OkButton, RF_onOk, NULL); } if (RF.mode == RF_YELLOW && RF.tClick >= 0) { // Clap a 0, 1, 2, 3, 4 s: clapIn (6 frame a 24 fps), a fine animazione Zoom RF.clapOn = 1; for (int i = 0; i < 5; i++) { float s = RF.tClick + 0x3e8 * i; if (prev < s && t >= s) RF.tClap = s; if (prev < s + 0xfa && t >= s + 0xfa) YellowSign_Zoom(); } if (RF.tZoomEnd >= 0 && t >= RF.tZoomEnd + 0x1b58) { po_sets("SelectedStage", "FOREST"); RF.active = 0; SceneManager_Reset(); } return; } if (RF.mode == RF_GOSPEL && RF.tClick >= 0) { // 7 battiti: clapIn e clapOut a 60 fps (100 ms l'uno), poi 3 s e si riprende float lt = t - RF.tClick; RF.claps = (int)(lt / 0xc8); RF.clapOn = RF.claps < 7; for (int i = 0; i < 7 && RF.claps <= 7; i++) { float s = RF.tClick + 0xc8 * i + 0x64; if (prev < s && t >= s) Sound_PlaySound("Clap", 2, 1, 0x64 * frand(), 0, 0); } for (int i = 0; i < 7; i++) { // fuochi: tween di 30 ms in yoyo a 100, 300, ... 1300 ms float s = RF.tClick + 0x64 + 0xc8 * i; if (t >= s && t < s + 0x3c) emitter_start(RF.fwE[i]); else emitter_stop(RF.fwE[i]); } if (t >= RF.tClick + 0x578 + 0xbb8) RF_resume(); return; } if (RF.mode == RF_FADE && RF.tClick >= 0) { // nero in 1 s, 1 s di attesa, Foresta e Reset if (t >= RF.tClick + 0x7d0) { po_sets("SelectedStage", "FOREST"); RF.active = 0; SceneManager_Reset(); } return; } Overlay_update(delta); UIButton_clicked(&RF.OkButton); if (getenv("VS_AUTOPICK") && OV.UI_selected && RF.OkButton.onDown && fmodf(t, 0x190) < delta) Overlay_OnSubmitPressed(); } // 0x15db6.AssignItemData: nome, descrizione e icona dell'oggetto, niente livello; giallo se isSpecialOption static void RelicPanel_draw(const char *type, float px, float py, float pw, float ph) { cJSON *it = cJSON_GetObjectItem(data_get("items"), type); int special = cJSON_IsTrue(cJSON_GetObjectItem(it, "isSpecialOption")); const char *name = tr_of("itemLang", type, "name"), *d = tr_of("itemLang", type, "description"); char desc[512]; snprintf(desc, sizeof(desc), "%s", *d ? d : str(it, "description") ? str(it, "description") : ""); if (special) { const char *tp = tr_of("itemLang", type, "tips"); snprintf(desc + strlen(desc), sizeof(desc) - strlen(desc), " %s", *tp ? tp : str(it, "tips") ? str(it, "tips") : ""); } // Vita: 0.2 x sfondo bastava a 720 di altezza; le descrizioni lunghe (Grimorio, IT) uscivano sotto il riquadro ph = fmaxf(ph, text_wrap(desc, (Vector2){ px + 0xa, py + 0x3c }, 16, 0.9f * pw, BLANK) + 16 * 1.15f + 6 - py); nine("frame1_c2.png", 12, (Rectangle){ px, py, pw, ph }, special ? YELLOW : WHITE); const Frame *ib = frame_get("UI", "frameB.png"); if (ib) DrawTexturePro(*ib->tex, (Rectangle){ ib->x, ib->y, ib->w, ib->h }, (Rectangle){ px + 4, py + 4, ib->w * 2, ib->h * 2 }, (Vector2){ 0, 0 }, 0, WHITE); const Frame *ic = frame_get(str(it, "texture"), str(it, "frameName")); if (ic) DrawTexturePro(*ic->tex, (Rectangle){ ic->x, ic->y, ic->w, ic->h }, (Rectangle){ px + 0x1c - ic->sw + 2 * ic->ox, py + 0x1c - ic->sh + 2 * ic->oy, ic->w * 2, ic->h * 2 }, (Vector2){ 0, 0 }, 0, WHITE); DrawTextEx(vs_font, *name ? name : str(it, "name"), (Vector2){ px + 0x50, py + 6 }, 16, 1, WHITE); text_wrap(desc, (Vector2){ px + 0xa, py + 0x3c }, 16, 0.9f * pw, WHITE); } // ============================================================================ // 0x11c10: UI_levelUpScene: armi, Limit Break (Great Gospel) o oggetti a scelte finite; Reroll/Skip/Banish // e il pannello delle bandite (0x3d3). Gira alla risoluzione da menu; clock della scena = LU.ev (time.addEvent), // i tween d'entrata sono tempi di partenza (restart = nuovo tempo). // ============================================================================ enum { LU_POWERUPS, LU_LIMITBREAK, LU_ITEMS }; typedef struct { int visible, iconHidden; const char *weaponType; WeightedLimitBreak lb; UIButton hit; float tEnter; } LUPanel; typedef struct { UIButton b; int textVis, remVis; const char *label; char rem[96]; } LUButton; // NineSlice + testo + "X left" (o la seconda riga del Limit Break) static struct { int active, mode, CurrentAmountOfPanels, HasRerolls, HasSkips, HasBanish, isaDoingaLimitaBreaka, banishing, footer, burstHidden; float t, tEnter, tButtons, tBurst, tBanished, value, burstX, burstY; unsigned burstTint; LUPanel panels[4]; const char *pickedWeapons[8]; int n_picked; LUButton Reroll, Skip, Banish, LBOnce, LBAlways; struct { float at; void (*fn)(void); int used; } ev[8]; ParticleManager *gems; ParticleEmitter *pfxEmitter; } LU; static float LU_W(void) { return 0.8f * SAFE_W; } static float LU_H(void) { return 0.8f * DEFAULT_H; } static float LU_TLx(void) { return 0.5f * MENU_W - 0.5f * LU_W(); } static float LU_TLy(void) { return 0.5f * MENU_H - 0.5f * LU_H(); } static float LU_ph(void) { return 0.2f * LU_H(); } static void LU_after(float ms, void (*fn)(void)) { for (int i = 0; i < 8; i++) if (!LU.ev[i].used) { LU.ev[i].at = LU.t + ms, LU.ev[i].fn = fn, LU.ev[i].used = 1; return; } } static void LU_noop(void) {} static void LU_Validate(void) { // ValidateSkipsAndRerolls int store = LevelUpFactory_HasPowerupsInStore(); LU.HasRerolls = store && LUF.n_weighted > 4 && Core.Player->rerolls > 0; LU.HasSkips = store && Core.Player->skips > 0; LU.HasBanish = store && Core.Player->banish > 0; } static void LU_setRem(LUButton *b, float v) { snprintf(b->rem, sizeof(b->rem), "%s", lang1("levelup_Xleft", TextFormat("%d", (int)v))); } static void LU_show(LUButton *b, int v) { b->b.visible = b->textVis = b->remVis = v; } static void LU_resume(void) { // SceneManager.ResumeFromLevelUp -> Core.ExitLevelUpScene LU.active = 0; Overlay_DestroyGrid(); Sound_FadeMusic(0.3f, 0x1f4); } static void LU_DisablePanelsInput(void) { for (int i = 0; i < 4; i++) UIButton_off(&LU.panels[i].hit); } static void LU_playEnter(void) { // OnEnterAnimation (Burst al centro) + OnEnterTween dello sfondo if (po_is("FlashingVFXEnabled")) LU.tBurst = LU.t, LU.burstX = 0.5f * MENU_W, LU.burstY = 0.5f * MENU_W; else LU.burstHidden = 1; LU.tEnter = LU.t; } static void LU_sound(void) { Sound_PlaySimple(po_is("ClassicMusic") ? "LevelUp" : "LevelUpB", 1.25f); } static void LU_fill(int i, const char *type) { // un pannello: visibile se c'e' qualcosa, OnEnterTween.restart LUPanel *p = &LU.panels[i]; UIButton_off(&p->hit); // Background.removeAllListeners p->visible = p->hit.visible = type != NULL, p->weaponType = type, p->iconHidden = 0, p->tEnter = LU.t; } static void vui_click(UIButton *b) { if (b->visible && b->interactive && b->onDown) b->onDown(b->ctx); } static void LU_keyReroll(void) { vui_click(&LU.Reroll.b); } static void LU_keySkip(void) { vui_click(&LU.Skip.b); } static void LU_keyBanish(void) { vui_click(&LU.Banish.b); } static void LU_MakeUIGrid(UIButton *sel) { int cols = LU.HasRerolls || LU.HasSkips || LU.HasBanish ? 2 : 1; // (sic) prima di ValidateSkipsAndRerolls LU_Validate(); UIButton *b[6]; int nb = 0; if (LU.HasRerolls) b[nb++] = &LU.Reroll.b; if (LU.HasSkips) b[nb++] = &LU.Skip.b; if (LU.HasBanish) b[nb++] = &LU.Banish.b; if (LU.isaDoingaLimitaBreaka) b[nb++] = &LU.LBOnce.b, b[nb++] = &LU.LBAlways.b, b[nb++] = &LU.LBAlways.b, cols = 2; // (sic) due volte Overlay_MakeUIGrid(cols, nb > 4 ? nb : 4, 0); for (int i = 0; i < 4; i++) if (LU.panels[i].visible) { UIGrid_SetContents(0, i, &LU.panels[i].hit, 0); if (nb > 0) UIGrid_SetContents(1, i, b[nb - 1], 0); } for (int j = 0; j < nb; j++) UIGrid_SetContents(1, j, b[j], 0); if (!sel) sel = &LU.panels[0].hit; Overlay_ToggleCursorsVisibility(1); UIGrid_SelectGameObject(sel); OV.UI_selected = sel; OV.OnCancelCallback = LU_noop; VPrompt P[4]; // Vita: quadrato rilancia, triangolo salta, R esilia int np = 0; if (LU.HasRerolls) P[np++] = (VPrompt){ G_SQUARE, "levelup_reroll" }, OV.OnSquare = LU_keyReroll; if (LU.HasSkips) P[np++] = (VPrompt){ G_TRIANGLE, "levelup_skip" }, OV.OnTriangle = LU_keySkip; if (LU.HasBanish) P[np++] = (VPrompt){ G_R, "levelup_banish" }, OV.OnR = LU_keyBanish; P[np++] = (VPrompt){ G_CROSS, "vui_select" }; vui_set_prompts(P, np); } static void LU_OnButtonClicked(void *c) { LU_DisablePanelsInput(); Core_LevelWeaponUp(LU.panels[(intptr_t)c].weaponType, 1); Sound_PlaySimple("ClickIn", 0); Player_SetInvulForMilliSecondsNonCumulative(Core.Player, 0x1f4); LU_resume(); } static void LU_OnLimitBreakClicked(const WeightedLimitBreak *lb) { LU_DisablePanelsInput(); Core_LimitBreakWeaponUp(lb); Sound_PlaySimple("ClickIn", 0); Player_SetInvulForMilliSecondsNonCumulative(Core.Player, 0x1f4); LU_resume(); } static void LU_onLimitBreakPanel(void *c) { LU_OnLimitBreakClicked(&LU.panels[(intptr_t)c].lb); } static void LU_OnItemButtonClicked(void *c) { LU_DisablePanelsInput(); Core_MakeAndActivatePickup(LU.panels[(intptr_t)c].weaponType); Sound_PlaySimple("ClickIn", 0); Player_SetInvulForMilliSecondsNonCumulative(Core.Player, 0x1f4); LU_resume(); } static void LU_panelsOn(void (*fn)(void *)) { for (intptr_t i = 0; i < 4; i++) UIButton_on(&LU.panels[i].hit, fn, (void *)i); } static void LU_EnablePanelsInputSel(UIButton *sel) { LU_MakeUIGrid(sel); LU_panelsOn(LU_OnButtonClicked); LU.footer = LU.CurrentAmountOfPanels < 4; } static void LU_EnablePanelsInput(void) { LU_EnablePanelsInputSel(NULL); } static void LU_EnablePanelsLimitBreakInput(void) { LU_MakeUIGrid(NULL); LU_panelsOn(LU_onLimitBreakPanel); LU.footer = LU.CurrentAmountOfPanels < 4; } static void LU_EnableItemPanelsInput(void) { LU_MakeUIGrid(NULL); LU_panelsOn(LU_OnItemButtonClicked); LU.footer = 0; } static void LU_PickRandomLevelUps(int reroll) { const char *o[8]; int n; if (reroll) n = LevelUpFactory_RerollLevelUpPowerups(LU.pickedWeapons, LU.n_picked, o), LU.n_picked = 0; else n = LevelUpFactory_GetLevelUpPowerups(o); for (int i = 0; i < n && LU.n_picked < 8; i++) LU.pickedWeapons[LU.n_picked++] = o[i]; if (strin(o, n, "GATTI") >= 0) { // pioggia di gatti static const char *const C[3] = { "cat_i01.png", "cat3_i01.png", "cat2_i01.png" }; for (int i = 0; i < 3; i++) LU.pfxEmitter->c.frames[i] = frame_get("items", C[i]); } LU.CurrentAmountOfPanels = n, LU.footer = 0; for (int i = 0; i < 4; i++) LU_fill(i, n > 0 ? o[--n] : NULL); // pop() LU_playEnter(); LU_after(0x190, LU_EnablePanelsInput); LU_sound(); if (LUF.n_banished > 0) LU.tBanished = LU.t; // new BanishedPanel + Open (anche a ogni reroll) } static void LU_PickRandomLimitBreak(void) { WeightedLimitBreak b[8]; int n = LimitBreakManager_GetLimitBreakBonuses(b); LU.CurrentAmountOfPanels = n, LU.footer = 0; for (int i = 0; i < 4; i++) { LU_fill(i, n > 0 ? b[n - 1].weaponType : NULL); if (n > 0) LU.panels[i].lb = b[--n]; } LU_playEnter(); LU_after(0x190, LU_EnablePanelsLimitBreakInput); LU_sound(); } static void LU_PickItemLevelUps(void) { const char *o[4]; int n = LevelUpFactory_GetLevelUpItems(o); LU.CurrentAmountOfPanels = n, LU.footer = 0; for (int i = 0; i < 4; i++) LU_fill(i, n > 0 ? o[--n] : NULL); LU_playEnter(); LU_after(0x12c, LU_EnableItemPanelsInput); LU_sound(); } static void LU_OnReroll(void *c); static void LU_OnSkip(void *c); static void LU_OnBanish(void *c); static void LU_EnableButtonsInput(void) { LU_Validate(); if (LU.HasRerolls) UIButton_on(&LU.Reroll.b, LU_OnReroll, NULL); else LU.Reroll.b.visible = LU.Reroll.textVis = 0; if (LU.HasSkips) UIButton_on(&LU.Skip.b, LU_OnSkip, NULL); else LU.Skip.b.visible = LU.Skip.textVis = 0; if (LU.HasBanish) UIButton_off(&LU.Banish.b), UIButton_on(&LU.Banish.b, LU_OnBanish, NULL); else LU.Banish.b.visible = LU.Banish.textVis = 0; } static void LU_showRerollSkip(void) { // dopo un reroll o un banish annullato LU_Validate(); LU_show(&LU.Reroll, LU.HasRerolls), LU_setRem(&LU.Reroll, Core.Player->rerolls); LU_show(&LU.Skip, LU.HasSkips), LU_setRem(&LU.Skip, Core.Player->skips); } static void LU_OnSkip(void *c) { (void)c; UIButton_off(&LU.Skip.b); LU_DisablePanelsInput(); if (Core.Player->skips > 0) { // Core.OnLevelUpSkipped: il 20% dell'esperienza che manca Core.Player->skips--; Player_AddXP(Core.Player, 0.2f * (Core.currentXPfactor - Core.Player->xp)); } Sound_PlaySimple("ClickOut", 0); Player_SetInvulForMilliSecondsNonCumulative(Core.Player, 0x1f4); LU_resume(); } static void LU_OnReroll(void *c) { (void)c; UIButton_off(&LU.Skip.b), UIButton_off(&LU.Reroll.b); LU_DisablePanelsInput(); LU_PickRandomLevelUps(1); if (Core.Player->rerolls > 0) Core.Player->rerolls--; // Core.OnRerollLevelUp Sound_PlaySimple("ClickIn", 0); LU_after(0x190, LU_EnableButtonsInput); LU.tButtons = LU.t; // OnEnterTween2/3.restart: i bottoni rientrano ruotando LU_showRerollSkip(); } static void LU_OnCancelBanish(void); static void LU_cancelBanishCb(void *c) { (void)c; LU_OnCancelBanish(); } static void LU_OnConfirmBanish(const char *type) { LevelUpFactory_Banish(type); if (Core.Player->banish > 0) Core.Player->banish--; // Core.OnLevelUpBanish Sound_PlaySimple("ClickOut", 0); Sound_PlaySimple("Banish", 1.7f); Player_SetInvulForMilliSecondsNonCumulative(Core.Player, 0x1f4); LU_DisablePanelsInput(); UIButton_off(&LU.Skip.b), UIButton_off(&LU.Reroll.b), UIButton_off(&LU.Banish.b); LU.burstTint = 0xff0000; if (po_is("FlashingVFXEnabled")) LU.tBurst = LU.t; else LU.burstHidden = 1; LU_after(0xc8, LU_resume); } static void LU_onBanishPanel(void *c) { LUPanel *p = &LU.panels[(intptr_t)c]; p->iconHidden = 1; LU.burstX = p->hit.x, LU.burstY = p->hit.y; // OnEnterAnimation.setPosition(panel.x, panel.y): l'angolo del pannello LU_OnConfirmBanish(p->weaponType); } static void LU_banishReady(void) { UIButton_on(&LU.Banish.b, LU_cancelBanishCb, NULL); for (int i = 0; i < 4; i++) UIButton_off(&LU.panels[i].hit); LU_panelsOn(LU_onBanishPanel); } static void LU_MakeUIGridBanish(void) { Overlay_MakeUIGrid(2, 4, 0); for (int i = 0; i < 4; i++) if (LU.panels[i].visible) UIGrid_SetContents(0, i, &LU.panels[i].hit, 0), UIGrid_SetContents(1, i, &LU.Banish.b, 0); Overlay_ToggleCursorsVisibility(1); UIGrid_SelectGameObject(&LU.Banish.b); OV.UI_selected = &LU.Banish.b; OV.OnCancelCallback = LU_OnCancelBanish; } static void LU_OnBanish(void *c) { (void)c; LU_DisablePanelsInput(); UIButton_off(&LU.Skip.b), UIButton_off(&LU.Reroll.b), UIButton_off(&LU.Banish.b); emitter_stop(LU.pfxEmitter); LU.banishing = 1; // DramaSprite rosso, header 'levelup_header_ban' LU.footer = 0; LU_show(&LU.Reroll, 0), LU_show(&LU.Skip, 0); LU.Banish.label = "levelup_cancel", LU.Banish.remVis = 0; LU_MakeUIGridBanish(); Sound_PlaySimple("ClickOut", 0); LU_after(0xc8, LU_banishReady); } static void LU_cancelReady(void) { LU_EnableButtonsInput(); LU_EnablePanelsInputSel(&LU.Banish.b); } static void LU_OnCancelBanish(void) { LU_DisablePanelsInput(); UIButton_off(&LU.Banish.b); emitter_start(LU.pfxEmitter); LU.banishing = 0; LU.footer = 1; LU.Banish.label = "levelup_banish", LU.Banish.remVis = 1; LU_after(0x190, LU_cancelReady); LU_showRerollSkip(); } static void LU_ChooseRandomLimitBreak(void) { int vis[4], n = 0; for (int i = 0; i < 4; i++) if (LU.panels[i].visible) vis[n++] = i; if (!n) return; LUPanel *p = &LU.panels[vis[(int)floorf(frand() * n)]]; // RND.pick WeightedLimitBreak lb = p->lb; LU_OnLimitBreakClicked(&lb); char d[256]; ParseLimitBreakUpInfo(lb.keyValues, d, sizeof(d)); GizmoManager_DisplayIconOverhead(str(tbl0("weapons", lb.weaponType), "frameName"), d, 0); } static void LU_onLBOnce(void *c) { (void)c; UIButton_off(&LU.LBOnce.b); LU_ChooseRandomLimitBreak(); } static void LU_onLBAlways(void *c) { (void)c; UIButton_off(&LU.LBAlways.b); Core.AlwaysRandomLimitBreak = 1; LU_ChooseRandomLimitBreak(); } static void LU_EnableLimitBreakButtonsInput(void) { if (!LU.isaDoingaLimitaBreaka) { LU.LBOnce.b.visible = LU.LBAlways.b.visible = 0; return; } LU_show(&LU.LBOnce, 1), LU_show(&LU.LBAlways, 1); UIButton_on(&LU.LBAlways.b, LU_onLBAlways, NULL); UIButton_on(&LU.LBOnce.b, LU_onLBOnce, NULL); } static void LevelUpScene_open(void) { memset(LU.ev, 0, sizeof(LU.ev)); LU.active = 1; LU.t = LU.tEnter = LU.tButtons = LU.value = 0; LU.tBurst = -1e9f, LU.tBanished = -1, LU.burstTint = 0xffffff, LU.burstHidden = 0; LU.banishing = LU.isaDoingaLimitaBreaka = LU.n_picked = 0; LU.footer = 1; // EnterLevelUp lancia anche PauseStatsScene (0x135fd): disegnata da game_draw sopra la scena if (!LU.gems) { // ParticlesManager 'items': pioggia di gemme LU.gems = particles_add(); children_remove(&LU.gems->s); LU.gems->scrollFactor0 = 1; // la scena UI ha la sua camera ferma LU.pfxEmitter = particles_createEmitter(LU.gems, (EmitterConfig){ .frames = { frame_get("items", "GemRed.png"), frame_get("items", "GemBlue.png"), frame_get("items", "GemGreen.png") }, .nframes = 3, .xOffset = ERND(0, MENU_W), .rotate = ERND(0, 0x168), .lifespan = EOP(0xfa0), .nonRadial = 1, .speedY = ERND(0x64, 0xc8), .scale = ERANGE(2, 0), .quantity = 4, .on = 1, .flowEveryFrame = 1 }); } static const char *const G[3] = { "GemRed.png", "GemBlue.png", "GemGreen.png" }; // ogni create ha il suo emettitore: di nuovo le gemme for (int i = 0; i < 3; i++) LU.pfxEmitter->c.frames[i] = frame_get("items", G[i]); LU.pfxEmitter->n = 0, LU.pfxEmitter->x = LU.pfxEmitter->y = 0; emitter_start(LU.pfxEmitter); float pw = 0.95f * LU_W(), ph = LU_ph(); for (int i = 0; i < 4; i++) UIButton_set(&LU.panels[i].hit, "", MENU_W, 0, pw, ph, PixelScale, 0, 0), LU.panels[i].visible = 0; float bx = 0.5f * MENU_W + 0.5f * LU_W() + 0.25f * (MENU_W - LU_W()), by = LU_TLy() - 0.025f * LU_W(); struct { LUButton *b; const char *frame, *label; float row; } B[5] = { { &LU.Reroll, "OptionsButton", "levelup_reroll", 1.5f }, { &LU.Skip, "BackButton", "levelup_skip", 2.5f }, { &LU.Banish, "BackButton", "levelup_banish", 3.5f }, { &LU.LBOnce, "OptionsButton", "limitBreak_random", 1.5f }, { &LU.LBAlways, "OptionsButton", "limitBreak_random", 2.5f } }; for (int i = 0; i < 5; i++) { UIButton_set(&B[i].b->b, B[i].frame, bx, by + B[i].row * ph, 0x60, 0x20, 0, 0.5f, 0.5f); LU_show(B[i].b, 0); B[i].b->label = B[i].label; } snprintf(LU.LBOnce.rem, sizeof(LU.LBOnce.rem), "%s", tr("limitBreak_once")); snprintf(LU.LBAlways.rem, sizeof(LU.LBAlways.rem), "%s", tr("limitBreak_always")); LevelUpFactory_calculateWeights(); int gospel = po_has("CollectedItems", "RELIC_GGOSPEL") && po_is("SelectedLimitBreak"); if (LevelUpFactory_HasPowerupsInStore()) LU.mode = LU_POWERUPS, LU_PickRandomLevelUps(0); else if (gospel && LimitBreakManager_hasLimitBreaks()) { LU.mode = LU_LIMITBREAK, LU.isaDoingaLimitaBreaka = 1; LU_PickRandomLimitBreak(); LU_after(0x1f4, LU_EnableLimitBreakButtonsInput); } else LU.mode = LU_ITEMS, LU_PickItemLevelUps(); LU_Validate(); if (LU.HasRerolls || LU.HasSkips || LU.HasBanish) { if (LU.HasRerolls) LU_show(&LU.Reroll, 1), LU_setRem(&LU.Reroll, Core.Player->rerolls); if (LU.HasSkips) LU_show(&LU.Skip, 1), LU_setRem(&LU.Skip, Core.Player->skips); if (LU.HasBanish) LU_show(&LU.Banish, 1), LU_setRem(&LU.Banish, Core.Player->banish); LU_after(0x1f4, LU_EnableButtonsInput); } } // Posizioni: i pannelli entrano da destra (OnEnterTween), i bottoni crescono ruotando (OnEnterTween2: -0.2 -> 2, 180 -> 0) static float LU_panelX(int i) { float tx = LU_TLx() + 0.025f * LU_W(); return MENU_W + (tx - MENU_W) * lerp01(LU.t, LU.panels[i].tEnter, 0x96 + 0x1e * i); } static float LU_btnK(void) { return lerp01(LU.t, LU.tButtons, 0x96); } static void LU_layout(void) { for (int i = 0; i < 4; i++) LU.panels[i].hit.x = LU_panelX(i), LU.panels[i].hit.y = LU_TLy() + LU_ph() * i + LU_ph() - 0.025f * LU_W(); float sc = fabsf(-0.2f + 2.2f * LU_btnK()) * PixelScale; LUButton *B[5] = { &LU.Reroll, &LU.Skip, &LU.Banish, &LU.LBOnce, &LU.LBAlways }; for (int i = 0; i < 5; i++) B[i]->b.sc = sc; } static void LevelUpScene_update(float delta) { LU.t += delta; LU.value += 0.1f; // update -> playerUI_levelUp.Update, una volta per frame particles_manager_update(LU.gems, delta); for (int i = 0; i < 8 && LU.active; i++) if (LU.ev[i].used && LU.t >= LU.ev[i].at) LU.ev[i].used = 0, LU.ev[i].fn(); if (!LU.active) return; LU_layout(); Overlay_update(delta); if (!LU.active) return; LUButton *B[5] = { &LU.Reroll, &LU.Skip, &LU.Banish, &LU.LBOnce, &LU.LBAlways }; int hit = 0; for (int i = 0; i < 5 && !hit && LU.active; i++) hit = UIButton_clicked(&B[i]->b); for (int i = 0; i < 4 && !hit && LU.active; i++) hit = UIButton_clicked(&LU.panels[i].hit); // sviluppo: VS_AUTOPICK sceglie il pannello selezionato; VS_LUPICK=reroll|skip|banish|once|always prima preme quel bottone if (!LU.active || !getenv("VS_AUTOPICK") || fmodf(LU.t, 0x190) >= delta) return; const char *want = getenv("VS_LUPICK"); static int used; if (LU.t <= 0x190) used = 0; UIButton *b = !want || used ? NULL : !strcmp(want, "reroll") ? &LU.Reroll.b : !strcmp(want, "skip") ? &LU.Skip.b : !strcmp(want, "banish") ? &LU.Banish.b : !strcmp(want, "once") ? &LU.LBOnce.b : !strcmp(want, "always") ? &LU.LBAlways.b : want[0] == 'p' && want[1] >= '0' && want[1] <= '3' ? &LU.panels[want[1] - '0'].hit : NULL; // p0..p3: quel pannello if (b) { if (b->onDown) used = 1, OV.UI_selected = b, Overlay_OnSubmitPressed(); return; } // aspetta che il bottone sia attivo if (LU.banishing && LU.panels[0].hit.onDown) { OV.UI_selected = &LU.panels[0].hit; Overlay_OnSubmitPressed(); return; } if (OV.UI_selected && OV.UI_selected->onDown && OV.UI_selected != &LU.Banish.b) Overlay_OnSubmitPressed(); } static void LU_drawBanishedPanel(void) { // 0x3d3: icone delle armi bandite con le croci che pulsano, sotto lo sfondo int n = LUF.n_banished; float W = LU_W(), sp = 0x23, w = n * sp + 0x14, crosses = n, h = 0x32; if (w > W) w = W, sp = (W - 0x14) / n, crosses = (W - 0x14) / 0x23 - 1; float k = lerp01(LU.t, LU.tBanished, 0xc8), cx = 0.5f * MENU_W, cy = 0.5f * MENU_H + 0.5f * LU_H() + 0.5f * h + 3; if (k <= 0.001f) return; rlPushMatrix(); rlTranslatef(cx, cy, 0); rlScalef(k, k, 1); nine_wh("frame1_c5.png", 12, 12, (Rectangle){ -0.5f * w, -0.5f * h, w, h }, Fade(WHITE, 0.75f)); for (int i = 0; i < n; i++) { cJSON *d = tbl0("weapons", LUF.BanishedWeapons[i]); float x = -0.5f * w + 0.5f * sp + 0xa + sp * i; if (d) TS_frame(str(d, "texture"), str(d, "frameName"), x, 0, 0.5f, 0.5f, 2 * PixelScale, 0, WHITE, 0); else TS_frame("items", "QuestionMark.png", x, 0, 0.5f, 0.5f, PixelScale, 0, WHITE, 0); } if (n <= 0xb) for (int i = 0; i < crosses; i++) { // alpha 0.6 -> 0.25, 1200 ms, yoyo, ritardo 200 ms * i float lt = LU.t - LU.tBanished - 0xc8 * i, p = lt < 0 ? 0 : fmodf(lt, 0x960) / 0x4b0; TS_frame("UI", "no16.png", -0.5f * w + 17.5f + 0xa + 0x23 * i, 0, 0.5f, 0.5f, 2 * PixelScale, 0, Fade(WHITE, 0.6f - 0.35f * (p < 1 ? p : 2 - p)), 0); } rlPopMatrix(); } static void LU_drawButton(const LUButton *b, const char *frame) { if (!b->b.visible && !b->textVis && !b->remVis) return; float k = LU_btnK(), sc = (-0.2f + 2.2f * k) * PixelScale, ang = 0xb4 * (1 - k); if (sc < 0) sc = -sc, ang += 0xb4; // scala negativa = mezzo giro in piu' if (b->b.visible) TS_nine(frame, 9, 14, b->b.x, b->b.y, 0x60, 0x20, sc, sc, ang, WHITE); const char *s = tr(b->label); if (b->textVis) TS_text(s, b->b.x, b->b.y - 0xa, fit_size(s, 16, 0x5a), sc, ang, WHITE); if (b->remVis) TS_text(b->rem, b->b.x, b->b.y + 0xa, 16, k * PixelScale, 0, WHITE); // OnEnterTween3: 0 -> 1 } static void LevelUpScene_draw(void) { float W = LU_W(), H = LU_H(), cx = 0.5f * MENU_W, cy = 0.5f * MENU_H, TLy = LU_TLy(); if (LU.banishing) { // DramaSprite: WhiteDot rosso a schermo intero, alpha 0.5 <-> 0.3 ogni 500 ms float p = fmodf(LU.t, 0x3e8) / 0x1f4; DrawRectangle(0, 0, MENU_W, MENU_H, Fade(RED, 0.5f - 0.2f * (p < 1 ? p : 2 - p))); } particles_manager_draw(LU.gems); // creato prima dello sfondo: sta sotto i pannelli float k = lerp01(LU.t, LU.tEnter, 0x96); // OnEnterTween dello sfondo: scala -0.2 -> 1, angolo 180 -> 0 in 150 ms TS_nine("frame5_c4.png", 12, 12, cx, cy, W, H, -0.2f + 1.2f * k, -0.1f + 1.1f * k, 0xb4 * (1 - k), WHITE); const char *hd = tr(LU.banishing ? "levelup_header_ban" : "levelup_header"); TS_text(hd, cx, TLy + 0x2d, fit_size(hd, 16, 0xb4), 2 * PixelScale, 0, WHITE); float pw = 0.95f * W, ph = LU_ph(); if (LU.footer) { // 'levelup_footer' centrato, riga per riga const char *ft = tr("levelup_footer"); int lines = 1; for (const char *c = ft; *c; c++) lines += *c == '\n'; float y = TLy + 4.25f * ph - 0.5f * lines * 16 * 1.15f; for (const char *s = ft; ; ) { const char *e = strchr(s, '\n'); char ln[160]; snprintf(ln, sizeof(ln), "%.*s", e ? (int)(e - s) : (int)strlen(s), s); DrawTextEx(vs_font, ln, (Vector2){ cx - MeasureTextEx(vs_font, ln, 16, 1).x / 2, y }, 16, 1, WHITE); y += 16 * 1.15f; if (!e) break; s = e + 1; } } for (int i = 0; i < 4; i++) { LUPanel *p = &LU.panels[i]; if (!p->visible) continue; float px = LU_panelX(i), py = TLy + ph * i + ph - 0.025f * W; if (LU.mode == LU_ITEMS) RelicPanel_draw(p->weaponType, px, py, pw, ph); else LevelUpPanel_drawEx(p->weaponType, LU.mode == LU_LIMITBREAK ? p->lb.keyValues : NULL, p->iconHidden, px, py, pw, ph); } if (LU.tBanished >= 0) LU_drawBanishedPanel(); // playerUI_levelUp (0x4ea3): barra XP piena che cambia colore, scaleY = GET_RATIO * DEFAULT_HEIGHT / GAMEPLAY_PIXEL_HEIGHT float scY = 1.0f * (DEFAULT_H / 0x1c8); nine("frameB9.png", 6, (Rectangle){ 0, 0, MENU_W, 0x12 * scY }, WHITE); Color rc = { (unsigned char)(0xff * fabsf(sinf(LU.value))), (unsigned char)(0xff * fabsf(cosf(0.5f * LU.value))), (unsigned char)(0xc8 + 0x37 * fabsf(cosf(LU.value))), 255 }; DrawRectangleRec((Rectangle){ 4, 4 * scY, MENU_W - 8, 0xa * scY }, rc); // PfxDot.png con setTintFill (FlashingVFXEnabled di default) LU_drawButton(&LU.Reroll, "button_c9_normal.png"); LU_drawButton(&LU.Skip, "button_c8_normal.png"); LU_drawButton(&LU.Banish, "button_c8_normal.png"); LU_drawButton(&LU.LBOnce, "button_c9_normal.png"); LU_drawButton(&LU.LBAlways, "button_c9_normal.png"); // OnEnterAnimation: Burst1..6 a 30 fps, scala 8, ADD (rosso sul pannello bandito) int bf = (int)((LU.t - LU.tBurst) / (1000.0f / 30)); if (!LU.burstHidden && bf >= 0 && bf < 6) TS_frame("vfx", TextFormat("Burst%d.png", bf + 1), LU.burstX, LU.burstY, 0.5f, 0.5f, 8, 0, hexc(LU.burstTint, 1), 1); vui_prompt_bar(); Overlay_draw(); } static void RF_clap(float W, float H) { // backgroundX clapNN, origine (0.5, 1) in fondo al centro, scala 1.5 if (!RF.clapOn) return; int f = 1; if (RF.mode == RF_YELLOW && RF.tClap >= 0) f = 1 + (int)fminf(5, (RF.t - RF.tClap) / (1000.0f / 24)); if (RF.mode == RF_GOSPEL && RF.tClick >= 0) { float in = fmodf(RF.t - RF.tClick, 0xc8); f = in < 0x64 ? 1 + (int)fminf(5, in / (1000.0f / 60)) : 6 + (int)fminf(5, (in - 0x64) / (1000.0f / 60)); } if (RF.mode == RF_YELLOW && RF.tClap < 0) return; // il battimani del Yellow Sign compare col primo battito char fr[16]; snprintf(fr, sizeof(fr), "clap%02d.png", f); TS_frame("backgroundX", fr, 0.5f * W, H, 0.5f, 1, 1.5f, 0, WHITE, 0); } static void RelicFoundScene_draw(void) { float t = RF.t, W = MENU_W, H = MENU_H, bw = RF_bgW(), bh = RF_bgH(), cx = 0.5f * W, cy = 0.5f * H; rlPushMatrix(); // la camera della scena: zoom attorno al centro, centerOn rlTranslatef(0.5f * W, 0.5f * H, 0); rlScalef(RF.zoom, RF.zoom, 1); rlTranslatef(-RF.camX, -RF.camY, 0); particles_manager_draw(RF.pfx); float k = lerp01(t, 0, 0x96), sx = -0.2f + 1.2f * k, sy = -0.1f + 1.1f * k, ang = 0xb4 * (1 - k); // OnEnterTween dello sfondo TS_nine("frame5_c4.png", 12, 12, cx, cy, bw, bh, sx, sy, ang, WHITE); float TLx = cx - 0.5f * bw, TLy = cy - 0.5f * bh; const char *hd = tr("relicFound"); TS_text(hd, cx, TLy + 0x2d, fit_size(hd, 16, 0xfa), 2 * PixelScale, 0, WHITE); float pw = 0.95f * bw, ph = 0.2f * bh, tx = TLx + 0.025f * bw; RelicPanel_draw(RF.relic, W + (tx - W) * lerp01(t, 0, 0x96), TLy + ph - 0.025f * bw, pw, ph); float bk = 0, ba = -0x5a; // OkButton: entra con enablePanelsInput, esce ruotando col click if (RF.tOk >= 0) bk = lerp01(t, RF.tOk, 0x96), ba = -0x5a * (1 - bk); if (RF.tClick >= 0) bk = 1 - lerp01(t, RF.tClick, 0x96), ba = -0xb4 * (1 - bk); if (bk > 0.001f) { TS_nine("button_c9_normal.png", 9, 14, RF.OkButton.x, RF.OkButton.y, 0x60, 0x20, 2 * PixelScale * bk, 2 * PixelScale * bk, ba, WHITE); const char *ot = tr("newItem_get"); TS_text(ot, RF.OkButton.x, RF.OkButton.y, fit_size(ot, 16, 0x50), 2 * PixelScale * bk, ba, WHITE); } RF.OkButton.sc = 2 * PixelScale * (bk > 0.99f && RF.tClick < 0); if (RF.fw) particles_manager_draw(RF.fw); int bf = (int)(t / (1000.0f / 30)); // OnEnterAnimation: Burst1..6, scala 8, ADD, profondita' 1000 if (bf < 6 && po_is("FlashingVFXEnabled")) TS_frame("vfx", TextFormat("Burst%d.png", bf + 1), cx, 0.5f * W, 0.5f, 0.5f, 8, 0, WHITE, 1); rlPopMatrix(); rlPushMatrix(); // il battimani ha scrollFactor 0: zoom attorno al centro, senza centerOn rlTranslatef(0.5f * W, 0.5f * H, 0); rlScalef(RF.zoom, RF.zoom, 1); rlTranslatef(-0.5f * W, -0.5f * H, 0); RF_clap(W, H); rlPopMatrix(); if (RF.mode == RF_FADE && RF.tClick >= 0) DrawRectangle(0, 0, (int)W, (int)H, Fade(BLACK, ease_sine_inout(lerp01(t, RF.tClick, 0x3e8)))); Overlay_draw(); } // ============================================================================ // 0x1a27: scena di gioco (create + update) // ============================================================================ #define PLAYERS_LEASH_X 500 // la vista e' larga 730 #define PLAYERS_LEASH_Y 320 static void DespawnIfOutside(ContainmentRect *r) { // 0x12c8a.DespawnIfOutside SpriteList *l = &Core.Enemies; if (!l->n) { r->index++; return; } Enemy *e = l->items[r->index % l->n]->owner; r->index++; if (!e->isCullable && !e->isTeleportOnCull) return; if (rect_contains(r, e->s.x, e->s.y)) return; if (e->isTeleportOnCull) { Vector2 p = Stage_GetBossyPosition(Core.Stage); e->s.x = p.x, e->s.y = p.y; return; } // OnTeleportOnCull Enemy_DeSpawn(e); } static void CheckAllAndDespawnIfOutside(ContainmentRect *r) { // proiettili r->x = Core.Player->s.x - r->halfWidth; r->y = Core.Player->s.y - r->halfHeight; for (int i = 0; i < Core.BulletGroup.n; i++) { Bullet *b = Core.BulletGroup.items[i]->owner; if ((b->isCullable || b->isTeleportOnCull) && !rect_contains(r, b->s.x, b->s.y)) { Bullet_DeSpawn(b); i--; } } } static Sprite pauseButton; // 'pause.png' in alto a destra (tocco) static int MainScene_enterPause; static float View_zoom(void); static struct { int on; float x, y; } TapMove; // Opzioni: tocca un punto e il personaggio ci va (proposta di Wolff) // Gli input di questa console: tasti, pad, tocco, agganci di sviluppo. Velocita' in px/s, 0 = fermo static Vector2 Player_localMove(Player *p, float maxSpeed) { Vector2 cv = { 0, 0 }; int moved = 0; // updateCursors if (IsKeyDown(KEY_LEFT) || IsKeyDown(KEY_A)) { cv.x = -1; moved = 1; } else if (IsKeyDown(KEY_RIGHT) || IsKeyDown(KEY_D)) { cv.x = 1; moved = 1; } if (IsKeyDown(KEY_UP) || IsKeyDown(KEY_W)) { cv.y = -1; moved = 1; } else if (IsKeyDown(KEY_DOWN) || IsKeyDown(KEY_S)) { cv.y = 1; moved = 1; } if (getenv("VS_DETWALK")) { // VS_DET: input a script, una direzione ogni 2 s; il valore sfasa le due console static const signed char D[8][2] = { {1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1} }; int k = (det_frame / 120 + atoi(getenv("VS_DETWALK")) - 1) % 8; cv.x = D[k][0], cv.y = D[k][1]; } const char *walk = getenv("VS_WALK"); // sviluppo: VS_WALK="1,0[,secondi]" cammina da solo in quella direzione (e si ferma) static double walk_t0 = -1; float wx, wy, wsec = 0; if (walk && sscanf(walk, "%f,%f,%f", &wx, &wy, &wsec) >= 2) { if (walk_t0 < 0) walk_t0 = GetTime(); if (wsec <= 0 || GetTime() - walk_t0 < wsec) cv.x = wx, cv.y = wy, moved = 1; } if (cv.x != 0 || cv.y != 0) { float l = sqrtf(cv.x * cv.x + cv.y * cv.y); cv.x = cv.x / l * maxSpeed; cv.y = cv.y / l * maxSpeed; moved = 1; } // updateController if (!moved && IsGamepadAvailable(0)) { if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_LEFT)) { cv.x = -1; moved = 1; } else if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_RIGHT)) { cv.x = 1; moved = 1; } if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_UP)) { cv.y = -1; moved = 1; } else if (IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_DOWN)) { cv.y = 1; moved = 1; } if (cv.x != 0 || cv.y != 0) { float l = sqrtf(cv.x * cv.x + cv.y * cv.y); cv.x = cv.x / l * maxSpeed; cv.y = cv.y / l * maxSpeed; } else { float sx = GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_X), sy = GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_Y); if (fabsf(sx) > 0.3f) { cv.x = sx * maxSpeed; moved = 1; } if (fabsf(sy) > 0.3f) { cv.y = sy * maxSpeed; moved = 1; } } } static int devTap; // sviluppo: VS_TAP=dx,dy un tocco a partita iniziata (distanza dal giocatore in pixel di mondo) if (getenv("VS_TAP") && !devTap) { float dx = 0, dy = 0; sscanf(getenv("VS_TAP"), "%f,%f", &dx, &dy); devTap = 1, TapMove.on = 1, TapMove.x = p->s.x + dx, TapMove.y = p->s.y + dy; } if (moved) TapMove.on = 0; // i tasti vincono sul tocco else if (TapMove.on) { float dx = TapMove.x - p->s.x, dy = TapMove.y - p->s.y, d = sqrtf(dx * dx + dy * dy); if (d < 4 || !(po_is("TouchMove") || getenv("VS_TAP"))) TapMove.on = 0; else cv.x = dx / d * maxSpeed, cv.y = dy / d * maxSpeed, moved = 1; } return cv; } static void scene_update(float delta) { game_context_set(0); Player *p = Core.Player; // escKey 'down': niente pausa con un forziere in coda o un level-up pronto; Start del pad (bottone 9) con 100 ms di blocco static double padPauseAt; if (IsKeyPressed(KEY_ESCAPE) && !(Core.n_TreasureQueue > 0 || p->xp >= Core.currentXPfactor)) MainScene_enterPause = 1; if (net_on) { // Start di uno dei due: la pausa la guida lui for (int i = 0; i < Players_n; i++) if (net_player_pressed(i, GAMEPAD_BUTTON_MIDDLE_RIGHT)) MainScene_enterPause = 1, Pickup_owner = i; } else if (IsGamepadAvailable(0) && IsGamepadButtonPressed(0, GAMEPAD_BUTTON_MIDDLE_RIGHT) && GetTime() >= padPauseAt) padPauseAt = GetTime() + 0.1, MainScene_enterPause = 1; if (ptr_pressed()) { // pauseButton 'pointerdown' -> Core.enterPause float sc = (float)SCREEN_H / game_height, gx = (PT.pos.x - (SCREEN_W - game_width * sc) / 2) / sc, gy = PT.pos.y / sc; // Vita: anche col tocco float w = pauseButton.width * pauseButton.scaleX, h = pauseButton.height * pauseButton.scaleY; if (gx >= pauseButton.x - w && gx < pauseButton.x && gy >= pauseButton.y && gy < pauseButton.y + h) Core.enterPause = 1; else if (po_is("TouchMove")) TapMove.on = 1, TapMove.x = p->s.x + (gx - 0.5f * game_width) / View_zoom(), TapMove.y = p->s.y + (gy - 0.5f * game_height) / View_zoom(); } float maxSpeed = PlayerPxSpeed * p->moveSpeed * p->slowMultiplier; for (int pi = 0; pi < Players_n; pi++) { game_context_set(pi); p = Core.Player; maxSpeed = PlayerPxSpeed * p->moveSpeed * p->slowMultiplier; p->lastFacedDirection = Slots[pi].lastVelocity; p->s.body.velocity = (Vector2){ 0, 0 }; Vector2 cv; if (net_on) { // lockstep: l'input arriva dalla rete, anche il proprio NetMove m = net_move(pi, det_frame); cv = (Vector2){ m.x / 127.0f * maxSpeed, m.y / 127.0f * maxSpeed }; if (p->isDead) cv = (Vector2){ 0, 0 }; if (Players_n > 1) { // non ci si allontana oltre la vista: stage ed eventi girano attorno al primo giocatore Sprite *o = &Slots[!pi].player->s; float dx = p->s.x - o->x, dy = p->s.y - o->y; if ((fabsf(dx) > PLAYERS_LEASH_X && dx * cv.x > 0)) cv.x = 0; if ((fabsf(dy) > PLAYERS_LEASH_Y && dy * cv.y > 0)) cv.y = 0; } } else cv = Player_localMove(p, maxSpeed); int moved = cv.x != 0 || cv.y != 0; if (moved) { sprite_setVelocity(&p->s, cv.x, cv.y); Slots[pi].lastVelocity = p->s.body.velocity; p->frameWalk = sqrtf(cv.x * cv.x + cv.y * cv.y); p->walked += p->frameWalk; } else { p->lastFacedDirection = Slots[pi].lastVelocity; p->s.body.velocity = (Vector2){ 0, 0 }; p->frameWalk = p->walked = 0; } } game_context_set(0); p = Core.Player; ContainmentRect_AdjustPosition(&Core.containmentRect_Enemies); for (int i = 0; i < 0x14; i++) DespawnIfOutside(&Core.containmentRect_Enemies); CheckAllAndDespawnIfOutside(&Core.containmentRect_Bullets); Core_Update(delta); if (Core.Stage->tilingTileset) TilingTileset_update(Core.Stage->tilingTileset); // Stage.Update if (MainScene_enterPause) MainScene_enterPause = 0, Core.enterPause = 1; Core.Stage->pizzaDelay -= delta; if (Core.Stage->fancyBG && Core.Stage->fancyBG->Update) Core.Stage->fancyBG->Update(delta); ShootingStars_Update(delta); // StageEventManager.Update PlayDiamond_Update(); if (HasHardBounds) { Sprite *p = &Core.Player->s; if (p->x < HardBounds.x) p->x = HardBounds.x; else if (p->x > HardBounds.width) p->x = HardBounds.width; if (p->y < HardBounds.y) p->y = HardBounds.y; else if (p->y > HardBounds.height) p->y = HardBounds.height; } } // ============================================================================ // Ciclo di Phaser (Game.step -> Systems.step) e interfaccia con main.c // ============================================================================ static float run_ms; // ============================================================================ // 0x11363: UI_topBar (monete, Indietro / Opzioni / Esci) // ============================================================================ static struct { int visible; UIButton BackButton, OptionsButton, ExitButton, CoinsBG; int backOn, optionsOn, exitOn; char CoinsText[16]; } TB; static int menu_quit; // Integration.closeGame static void TopBar_UpdateCoins(void) { double c = po_num("Coins"); if (c < 0x989680) snprintf(TB.CoinsText, sizeof(TB.CoinsText), "%.0f", c); else snprintf(TB.CoinsText, sizeof(TB.CoinsText), "9999999"); } static void TopBar_DisableBack(void) { TB.BackButton.visible = 0; TB.backOn = 0; UIButton_off(&TB.BackButton); } static void TopBar_DisableOptions(void) { TB.OptionsButton.visible = 0, TB.optionsOn = 0; UIButton_off(&TB.OptionsButton); TB.ExitButton.visible = 0, TB.exitOn = 0; UIButton_off(&TB.ExitButton); } static void (*TB_backCb)(void), (*TB_optionsCb)(void); static void TB_onBack(void *ctx) { (void)ctx; void (*cb)(void) = TB_backCb; UIButton_off(&TB.BackButton); if (cb) cb(); Sound_PlaySimple("ClickOut", 0); PlayerOptions_Save(); } static void TB_onOptions(void *ctx) { (void)ctx; void (*cb)(void) = TB_optionsCb; UIButton_off(&TB.OptionsButton); if (cb) cb(); Sound_PlaySimple("ClickOut", 0); } static void TB_onExit(void *ctx) { (void)ctx; Sound_PlaySimple("ClickOut", 0); menu_quit = 1; } static void TopBar_EnableBack(void (*cb)(void)) { TB.BackButton.visible = 1, TB.backOn = 1, TB_backCb = cb; UIButton_on(&TB.BackButton, TB_onBack, NULL); TopBar_DisableOptions(); } static void TopBar_EnableOptions(void (*cb)(void)) { TB.OptionsButton.visible = 1, TB.optionsOn = 1, TB_optionsCb = cb; UIButton_on(&TB.OptionsButton, TB_onOptions, NULL); TopBar_DisableBack(); TB.ExitButton.visible = 1, TB.exitOn = 1; // Integration.isDesktop(): anche sulla Vita si esce dal gioco UIButton_on(&TB.ExitButton, TB_onExit, NULL); } static void SceneManager_OptionsFromMainMenu(void); static const char *TB_title; // Vita: il titolo della schermata nella barra in alto (NULL nel menu principale) static void TopBar_create(void) { // Vita: barra alta 52 px, Indietro o Opzioni a sinistra, monete a destra memset(&TB, 0, sizeof(TB)); UIButton_set(&TB.BackButton, "BackButton", 12, 8, 150, 36, 1, 0, 0); UIButton_set(&TB.OptionsButton, "OptionsButton", 12, 8, 150, 36, 1, 0, 0); UIButton_set(&TB.ExitButton, "BackButton", 12, 8, 150, 36, 1, 0, 0); TB.ExitButton.visible = 0; // sulla Vita si esce col tasto PS UIButton_set(&TB.CoinsBG, "ProgressBox", MENU_W - 16, 8, 170, 36, 1, 1, 0); TopBar_UpdateCoins(); TB.visible = 0; // Hide TB_title = NULL; TopBar_DisableBack(); } static void TopBar_Show(void) { TB.visible = 1; TopBar_EnableOptions(SceneManager_OptionsFromMainMenu); } static void TopBar_update(void) { if (!TB.visible) return; UIButton *B[3] = { &TB.BackButton, &TB.OptionsButton, &TB.ExitButton }; for (int i = 0; i < 3; i++) if (UIButton_clicked(B[i])) break; } static void TopBar_draw(void) { if (!TB.visible) return; DrawRectangle(0, 0, MENU_W, 52, (Color){ 12, 6, 10, 200 }); DrawRectangle(0, 50, MENU_W, 2, rgb(0x8a6a2a, 1)); TB.ExitButton.visible = 0; UIButton *b = TB.BackButton.visible ? &TB.BackButton : TB.OptionsButton.visible ? &TB.OptionsButton : NULL; if (b) { UIButton_draw(b, 1); vui_glyph(b == &TB.BackButton ? G_CIRCLE : G_TRIANGLE, b->x + 20, b->y + 18, 11); text_at(tr(b == &TB.BackButton ? "topBar_back" : "topBar_options"), b->x + 38, b->y + 18, fit_size(tr("topBar_back"), 22, 104), 0, 0.5f, WHITE); } if (TB_title) text_at(TB_title, 206, 26, fit_size(TB_title, 32, 534), 0, 0.5f, rgb(VUI_GOLD, 1)); // dopo la freccia del cursore su Indietro UIButton_draw(&TB.CoinsBG, 1); float L = UI_left(&TB.CoinsBG); TS_frame("UI", "MoneyPile.png", L + 8, 26, 0, 0.5f, 1.5f, 0, WHITE, 0); text_at(TB.CoinsText, L + bW(&TB.CoinsBG) - 12, 26, 26, 1, 0.5f, WHITE); } // ============================================================================ // 0x16ebb: UI_mainMenu (Inizia, Potenziamenti, Collezione, Sblocchi, Riconoscimenti, Bestiario, Segreti, Avvio rapido) // SceneContainer in (0, renderer.height): le y sono negative, dal fondo // ============================================================================ static struct { int visible, awake, hasBestiaryGuide, hasSecretsGuide, hasQuickStart, doShadowGag; UIButton JukeboxButton; // del port: dal primo vinile trovato int hasJukebox; UIButton CoopButton, ResolutionButton, CreditsButton, CollectionButton, AchievementButton, BestiaryButton, SecretsButton, PowerupButton, StartButton, QuickStartButton; } MM; static void SceneManager_StartFromMainMenu(void), SceneManager_QuickStartFromMainMenu(void), SceneManager_PowerUpFromMainMenu(void), SceneManager_CollectionFromMainMenu(void), SceneManager_AchievementsFromMainMenu(void), SceneManager_Credits_FromMainMenu(void), SceneManager_BestiaryFromMainMenu(void), SceneManager_SecretsFromMainMenu(void); static void MM_click(void (*fn)(void)) { fn(); Sound_PlaySimple("ClickIn", 0); } static void MM_onStart(void *c) { (void)c; MM_click(SceneManager_StartFromMainMenu); } static void MM_onQuick(void *c) { (void)c; MM_click(SceneManager_QuickStartFromMainMenu); } static void MM_onPowerup(void *c) { (void)c; MM_click(SceneManager_PowerUpFromMainMenu); } static void MM_onCollection(void *c) { (void)c; MM_click(SceneManager_CollectionFromMainMenu); } static void MM_onAchievement(void *c) { (void)c; MM_click(SceneManager_AchievementsFromMainMenu); } static void MM_onCredits(void *c) { (void)c; MM_click(SceneManager_Credits_FromMainMenu); } static void MM_onBestiary(void *c) { (void)c; MM_click(SceneManager_BestiaryFromMainMenu); } static void MM_onSecrets(void *c) { (void)c; MM_click(SceneManager_SecretsFromMainMenu); MM.SecretsButton.tint = 0xffffff; } static void Lobby_open(void); static void MM_onCoop(void *c) { (void)c; Sound_PlaySimple("ClickIn", 0); Lobby_open(); } static void SceneManager_Jukebox_FromMainMenu(void); static int Jukebox_vinyls(void); static void MM_onJukebox(void *c) { (void)c; MM_click(SceneManager_Jukebox_FromMainMenu); } static void MainMenu_create(void) { // Vita: colonna di bottoni a destra, in coordinate dello schermo memset(&MM, 0, sizeof(MM)); // preload: JustGotJubilee -> doShadowGag (con le reliquie, F3.3) float x = 572, w = 340, hw = 164; UIButton_set(&MM.StartButton, "OptionsButton", x, 72, w, 72, 1, 0, 0); UIButton_set(&MM.PowerupButton, "GreenButton", x, 158, w, 56, 1, 0, 0); UIButton_set(&MM.CollectionButton, "OptionsButton", x, 228, hw, 52, 1, 0, 0); UIButton_set(&MM.AchievementButton, "OptionsButton", x + w - hw, 228, hw, 52, 1, 0, 0); MM.hasBestiaryGuide = po_has("CollectedItems", "RELIC_GOUDA"); UIButton_set(&MM.BestiaryButton, "OptionsButton", x, 292, hw, 52, 1, 0, 0); MM.BestiaryButton.visible = MM.hasBestiaryGuide; MM.hasSecretsGuide = po_has("CollectedItems", "RELIC_SECRETS"); UIButton_set(&MM.SecretsButton, "OptionsButton", x + w - hw, 292, hw, 52, 1, 0, 0); MM.SecretsButton.visible = 0; UIButton_set(&MM.CreditsButton, "OptionsMiniButton", x, 358, hw, 40, 1, 0, 0); UIButton_set(&MM.CoopButton, "OptionsMiniButton", x + w - hw, 358, hw, 40, 1, 0, 0); MM.hasJukebox = Jukebox_vinyls() > 0; // col Jukebox: CO-OP | Jukebox, poi Riconoscimenti largo sotto; senza, come prima UIButton_set(&MM.JukeboxButton, "OptionsMiniButton", x + w - hw, 358, hw, 40, 1, 0, 0); MM.JukeboxButton.visible = MM.hasJukebox; if (MM.hasJukebox) { UIButton_set(&MM.CoopButton, "OptionsMiniButton", x, 358, hw, 40, 1, 0, 0); UIButton_set(&MM.CreditsButton, "OptionsMiniButton", x, 406, w, 40, 1, 0, 0); } MM.hasQuickStart = cJSON_GetArraySize(po("UnlockedStages")) >= 5; UIButton_set(&MM.QuickStartButton, "OptionsMiniButton", 0, 0, 0, 0, 1, 0, 0); // Vita: niente bottone, e' START MM.QuickStartButton.visible = 0; MM.ResolutionButton.visible = 0; // UI_resolutionScene: solo su PC if (MM.hasSecretsGuide) { MM.SecretsButton.visible = 1; if (MM.doShadowGag) MM.SecretsButton.tint = 0; } // showSecretButton MM.visible = 0, MM.awake = 1; // Hide } static void MainMenu_EnableButtons(void) { UIButton_on(&MM.StartButton, MM_onStart, NULL); if (MM.hasQuickStart) UIButton_on(&MM.QuickStartButton, MM_onQuick, NULL); UIButton_on(&MM.PowerupButton, MM_onPowerup, NULL); UIButton_on(&MM.CollectionButton, MM_onCollection, NULL); UIButton_on(&MM.AchievementButton, MM_onAchievement, NULL); UIButton_on(&MM.CreditsButton, MM_onCredits, NULL); UIButton_on(&MM.CoopButton, MM_onCoop, NULL); if (MM.hasJukebox) UIButton_on(&MM.JukeboxButton, MM_onJukebox, NULL); if (MM.hasBestiaryGuide) UIButton_on(&MM.BestiaryButton, MM_onBestiary, NULL); if (MM.hasSecretsGuide) UIButton_on(&MM.SecretsButton, MM_onSecrets, NULL); } static void MainMenu_Show(void) { MM.visible = 1; MainMenu_EnableButtons(); } static UIButton *MM_buttons(int i) { UIButton *B[] = { &MM.StartButton, &MM.QuickStartButton, &MM.PowerupButton, &MM.CollectionButton, &MM.AchievementButton, &MM.CreditsButton, &MM.BestiaryButton, &MM.SecretsButton }; return i < 8 ? B[i] : NULL; } static void MainMenu_update(void) { if (!MM.visible || !MM.awake) return; for (int i = 0; i < 8; i++) if (UIButton_clicked(MM_buttons(i))) break; UIButton_clicked(&MM.CoopButton); if (MM.hasJukebox) UIButton_clicked(&MM.JukeboxButton); } static const char *MM_upper(const char *s) { // UTF-8 in maiuscolo come gli altri bottoni: ASCII, Latin-1, Latin Ext-A (pl, tr), cirillico; CJK invariato static char out[128]; size_t o = 0; for (const unsigned char *p = (const unsigned char *)s; *p && o + 3 < sizeof(out);) { unsigned c = *p; if (c < 0x80) { out[o++] = (char)(c >= 'a' && c <= 'z' ? c - 32 : c); p++; continue; } if (c < 0xc0 || c >= 0xe0 || (p[1] & 0xc0) != 0x80) { out[o++] = (char)*p++; continue; } // 3-4 byte (CJK) e il resto: com'e' c = ((c & 0x1f) << 6) | (p[1] & 0x3f); if (c == 0x131) { out[o++] = 'I', p += 2; continue; } // turco: ı senza puntino -> I if (c >= 0xe0 && c <= 0xfe && c != 0xf7) c -= 0x20; // à..þ else if ((c >= 0x100 && c <= 0x137) || (c >= 0x14a && c <= 0x177)) c &= ~1u; // Latin Ext-A: maiuscola pari else if (((c >= 0x139 && c <= 0x148) || (c >= 0x179 && c <= 0x17e)) && !(c & 1)) c -= 1; // qui maiuscola dispari (ł ń ż) else if (c >= 0x430 && c <= 0x44f) c -= 0x20; // а..я else if (c >= 0x450 && c <= 0x45f) c -= 0x50; // ё ђ ... out[o++] = (char)(0xc0 | (c >> 6)), out[o++] = (char)(0x80 | (c & 0x3f)), p += 2; } out[o] = 0; return out; } static void MM_label(UIButton *b, const char *s, float px) { if (!b->visible) return; text_at(s, b->x + 0.5f * bW(b), b->y + 0.5f * bH(b), fit_size(s, px, bW(b) - 20), 0.5f, 0.5f, WHITE); } static void MainMenu_draw(void) { if (!MM.visible) return; DrawRectangleRounded((Rectangle){ 552, 60, 380, MM.hasJukebox ? 400 : 352 }, 0.06f, 6, (Color){ 12, 6, 10, 130 }); // Vita: velo dietro la colonna UIButton *B[] = { &MM.StartButton, &MM.PowerupButton, &MM.CollectionButton, &MM.AchievementButton, &MM.BestiaryButton, &MM.SecretsButton, &MM.CreditsButton }; for (size_t i = 0; i < sizeof(B) / sizeof(*B); i++) UIButton_draw(B[i], 1); MM_label(&MM.StartButton, tr("menu_start"), 40); MM_label(&MM.PowerupButton, tr("menu_power_up"), 30); MM_label(&MM.CollectionButton, tr("menu_collection"), 24); MM_label(&MM.AchievementButton, tr("menu_unlocks"), 24); MM_label(&MM.BestiaryButton, tr("menu_bestiary"), 24); MM_label(&MM.SecretsButton, tr("menu_secrets"), 24); MM_label(&MM.CreditsButton, MM_upper(tr("menu_credit")), 22); UIButton_draw(&MM.CoopButton, 1), MM_label(&MM.CoopButton, "CO-OP", 22); if (MM.hasJukebox) UIButton_draw(&MM.JukeboxButton, 1), MM_label(&MM.JukeboxButton, MM_upper(port_tr("menu_jukebox")), 22); } // ============================================================================ // 0x11ecf: IntroScene (sfondo, illustrazioni, titolo; "premi un tasto"; poi barra e menu) // ============================================================================ static struct { float t; // ms dal create int introEnded, isInitialized, anyHeld; float firstInputAt, blinkAt; // OnFirstInput / OnIntroEnded int touchVisible, gridMade; UIButton *gridSelect; } IN; static void MM_onQuickKey(void) { if (MM.hasQuickStart) MM_onQuick(NULL); } static void MM_onOptionsKey(void) { if (TB.OptionsButton.onDown) TB.OptionsButton.onDown(TB.OptionsButton.ctx); } static void IntroScene_MakeUIGrid(UIButton *sel) { // Vita: due colonne, i bottoni larghi occupano entrambe if (!sel) sel = &MM.StartButton; Overlay_DestroyGrid(); Overlay_MakeUIGrid(2, MM.hasJukebox ? 7 : 6, 0); for (int c = 0; c < 2; c++) { UIGrid_SetContents(c, 0, &TB.OptionsButton, 0); UIGrid_SetContents(c, 1, &MM.StartButton, 0); UIGrid_SetContents(c, 2, &MM.PowerupButton, 0); if (MM.hasJukebox) UIGrid_SetContents(c, 6, &MM.CreditsButton, 0); } UIGrid_SetContents(0, 5, MM.hasJukebox ? &MM.CoopButton : &MM.CreditsButton, 0); UIGrid_SetContents(1, 5, MM.hasJukebox ? &MM.JukeboxButton : &MM.CoopButton, 0); UIGrid_SetContents(0, 3, &MM.CollectionButton, 0); UIGrid_SetContents(1, 3, &MM.AchievementButton, 0); if (MM.hasBestiaryGuide) UIGrid_SetContents(0, 4, &MM.BestiaryButton, 0); if (MM.hasSecretsGuide) UIGrid_SetContents(1, 4, &MM.SecretsButton, 0); Overlay_ToggleCursorsVisibility(1); OV.OnCancelCallback = NULL; // () => UI_grid.SelectGameObject(StartButton): sotto, in IntroScene_cancel OV.OnTriangle = MM_onOptionsKey; if (MM.hasQuickStart) OV.OnStart = MM_onQuickKey; VPrompt P[] = { { G_TRIANGLE, "vui_options" }, { G_START, "vui_quick" }, { G_CROSS, "vui_select" } }; if (MM.hasQuickStart) vui_set_prompts(P, 3); else vui_set_prompts((VPrompt[]){ P[0], P[2] }, 2); TB_title = NULL; UIGrid_SelectGameObject(sel); OV.UI_selected = sel; } static void IntroScene_cancel(void) { UIGrid_SelectGameObject(&MM.StartButton); } // (sic) sposta la griglia, non UI_selected static void IntroScene_create(void) { memset(&IN, 0, sizeof(IN)); // preload: ApplyMenuResolution, StopMusic, gag di specchio e tromba (F3.3) Sound_StopMusic(); TopBar_create(); MainMenu_create(); Overlay_DestroyGrid(); // LaunchUIOverlay // combinazioni da tastiera (codici segreti e Konami): con i segreti, F3.4 } static void IntroScene_OnFirstInput(void) { if (IN.isInitialized) return; IN.isInitialized = 1; IN.touchVisible = 0; TopBar_Show(); MainMenu_Show(); Sound_PlaySimple("ClickIn", 0); IN.firstInputAt = IN.t; // dopo 30 ms: MakeUIGrid() } // La home animata e' di Wolff (WolffsRoom): gira sul decoder del video come i video del finale, che usano la partita e mai il menu static VsVideo *HomeVideo; static void HomeVideo_close(void) { vs_video_close(HomeVideo), HomeVideo = NULL; } static void IntroScene_update(float delta) { IN.t += delta; vs_video_update(HomeVideo, delta); if (!IN.introEnded && IN.t >= 0x3e8) { // pixelation 50 -> 1 in 1000 ms, poi OnIntroEnded IN.introEnded = 1, IN.blinkAt = IN.t, IN.touchVisible = 1; } if (IN.introEnded && !IN.isInitialized) { while (IN.t - IN.blinkAt >= 0x1f4) IN.blinkAt += 0x1f4, IN.touchVisible = !IN.touchVisible; // blinkTimer // CheckFirstInput: pointerdown sullo sfondo, keyup, 'up' del pad int held = nKeyQ > 0; for (int k = 0; k < 512 && !held; k++) held = IsKeyDown(k); for (int b = 1; b <= 17 && !held && IsGamepadAvailable(0); b++) held = IsGamepadButtonDown(0, b); if (ptr_pressed()) IntroScene_OnFirstInput(); else if (IN.anyHeld && !held) IntroScene_OnFirstInput(); IN.anyHeld = held; } if (IN.isInitialized && !IN.gridMade && IN.t - IN.firstInputAt >= 0x1e) { IN.gridMade = 1; IntroScene_MakeUIGrid(NULL); OV.OnCancelCallback = IntroScene_cancel; } } static Texture2D IN_bg, IN_title; static void IntroScene_drawScene(void) { if (!HomeVideo) { HomeVideo = vs_video_open(vs_asset("home.mp4"), MENU_W, MENU_H); vs_video_loop(HomeVideo); } if (!IN_bg.id) IN_bg = LoadTexture(vs_path("img/introBG.png")), IN_title = LoadTexture(vs_path("img/title.png")); float W = MENU_W, H = MENU_H, t = IN.t; if (IN_bg.id) { float fill = W / fminf(IN_bg.width, IN_bg.height), k = lerp01(t, 0, 0x44c), sc = 5.1f * fill + (1.1f * fill - 5.1f * fill) * k; DrawTexturePro(IN_bg, (Rectangle){ 0, 0, IN_bg.width, IN_bg.height }, (Rectangle){ 0.5f * W, 0.5f * H, IN_bg.width * sc, IN_bg.height * sc }, (Vector2){ 0.5f * IN_bg.width * sc, 0.5f * IN_bg.height * sc }, 0, WHITE); } if (vs_video_ready(HomeVideo)) { Texture2D v = vs_video_texture(HomeVideo); DrawTexturePro(v, (Rectangle){ 0, 0, v.width, v.height }, (Rectangle){ 0, 0, W, H }, (Vector2){ 0, 0 }, 0, WHITE); } else if (!strcmp(po_str("MainMenuBG") ? po_str("MainMenuBG") : "", "CLASSIC")) { TS_frame("illustrations", "villain.png", -0x40, 0x40, 0, 0, 3, 0, Fade(WHITE, 0.5f * lerp01(t, 0x2ee, 0x2ee)), 0); const Frame *im = frame_get("illustrations", "imelda.png"); if (im) { // setOrigin(1, 0.5).setScale(2).setFlipX(true): il ribaltamento non sposta l'origine float sc = 2, L = W - im->sw * sc, Tp = SAFE_CY - 0.5f * im->sh * sc; Rectangle src = { im->x, im->y, -(float)im->w, im->h }; Rectangle dst = { L + (im->sw - im->ox - im->w) * sc, Tp + im->oy * sc, im->w * sc, im->h * sc }; DrawTexturePro(*im->tex, src, dst, (Vector2){ 0, 0 }, 0, Fade(WHITE, 0.75f * lerp01(t, 0x3e8, 0x2ee))); } TS_frame("illustrations", "antonio.png", SAFE_CX, MENU_H, 0.5f, 1, 2, 0, Fade(WHITE, lerp01(t, 0x3e8, 0x1f4)), 0); } if (IN_title.id) { float sc = 3 * MASTER_SCALE * SAFE_WIDTH / SAFE_R; float tx = 0.5f * W + (0.29f * W - 0.5f * W) * (MM.visible ? lerp01(IN.t, IN.firstInputAt, 0x190) : 0); // Vita: a sinistra col menu DrawTexturePro(IN_title, (Rectangle){ 0, 0, IN_title.width, IN_title.height }, (Rectangle){ tx, 0.3f * H, IN_title.width * sc, IN_title.height * sc }, (Vector2){ 0.5f * IN_title.width * sc, 0.5f * IN_title.height * sc }, 0, WHITE); } if (IN.touchVisible) ui_text(tr("intro_start"), 0.5f * W, 0.75f * H, 4 * MASTER_SCALE, 0, 0.5f, 0.5f, WHITE); } // rexPixelationPipeline sulla camera: disegna in una texture e la ricampiona a blocchi px x px static void menu_pixelate(void (*draw)(void), float px, float x0, float w, float h) { static RenderTexture2D full, small; if (!full.id) { full = LoadRenderTexture(MENU_W, MENU_H); SetTextureFilter(full.texture, TEXTURE_FILTER_POINT); } BeginTextureMode(full); ClearBackground(BLANK); draw(); EndTextureMode(); Texture2D src = full.texture; int sw = MENU_W, sh = MENU_H; if (px > 1.01f) { sw = (int)ceilf(MENU_W / px), sh = (int)ceilf(MENU_H / px); if (!small.id) { small = LoadRenderTexture(MENU_W, MENU_H); SetTextureFilter(small.texture, TEXTURE_FILTER_POINT); } BeginTextureMode(small); ClearBackground(BLANK); DrawTexturePro(full.texture, (Rectangle){ 0, 0, MENU_W, -MENU_H }, (Rectangle){ 0, 0, sw, sh }, (Vector2){ 0, 0 }, 0, WHITE); EndTextureMode(); src = small.texture; } Rectangle sr = src.id == full.texture.id ? (Rectangle){ 0, 0, MENU_W, -MENU_H } : (Rectangle){ 0, MENU_H - sh, sw, -sh }; DrawTexturePro(src, sr, (Rectangle){ x0, 0, w, h }, (Vector2){ 0, 0 }, 0, WHITE); } static void char_sprite(const char *id, const char **tex, const char **spr) { // textureName/spriteName, o quelli della skin scelta cJSON *c = tbl0("characters", id), *s; *tex = str(c, "textureName"), *spr = str(c, "spriteName"); int cur = (int)num(c, "currentSkinIndex", 0); cJSON_ArrayForEach(s, cJSON_GetObjectItem(c, "skins")) if ((int)num(s, "id", -1) == cur) { *tex = str(s, "textureName"), *spr = str(s, "spriteName"); break; } } static float Core_CharMarkup(void) { // get CharMarkup: 1 + 0.1 * (personaggi comprati - 1) int n = 0; cJSON *c; cJSON_ArrayForEach(c, data_get("characters")) n += cJSON_IsTrue(cJSON_GetObjectItem(cJSON_GetArrayItem(c, 0), "isBought")); return 1 + 0.1f * (n - 1); } // ============================================================================ // 0x50e4: CharSelectionScene + 0x56c5 CharSelectionPanel + 0x9241 CharConfirmationPanel + 0xe199 CharStatsPanel // + 0x11ac CharLevelPanel + 0x16a35 ScrollableContainer. CharStatsEggPanel (0x3de) e CharDetailsPanel (0x16cf2) // compaiono con l'uovo d'oro o gli occhiali (Mindbender: numero massimo di armi e skin) // ============================================================================ #define CS_MAX 96 typedef struct { struct { const char *name, *powerupType, *type; int omni; float value; int tinted; } s[23]; } CharStatsPanel; // 0xe199 typedef struct { const char *ch; float x, y; unsigned bgTint; UIButton hit; } CharPanel; static struct { int active, n, Columns, Rows, ShowScrollbar, isReadyToStart, isStartingGameMode, hasGoldenEggs, hasNoseglasses; int gridBottom, gridLast, hcVisible, statsVisible, levelVisible, moveButtonsAcross, statsOpen; // statsOpen: Vita, quadrato const char *Highlighted; CharPanel panels[CS_MAX], *HighlightedPanel, *currentlyHighlightedPanel; float scY, scMaxY, scMinY, scH, y0; // ScrollableContainer (y, MaxY, MinY, trueHeight) e SceneContainer.y float scrollTopY, scrollHeight, hcX, hcY, t, openAt; float cpX, cpY, cpW, buttonX, buttonW, descW; // CharConfirmationPanel UIButton bg, ScrollBar, Button; UIButton WEAPONS_box, EGGS_box, myIcon; // CharDetailsPanel e l'icona del personaggio (cambio skin) char buyText[64]; unsigned cpTint; int dragging, downOnSc; Vector2 downAt; float dragOff; CharStatsPanel stats; int nLevel; const char *levelStages[32]; int levelTick[32]; } CS; static const struct { const char *name, *powerupType, *type; int omni; float value; } CS_LIST[23] = { { "maxHp", "MAXHEALTH", "health", 0, 100 }, { "regen", "REGEN", "percentagePerSecond", 0, 0 }, { "armor", "ARMOR", "flat", 0, 0 }, { "moveSpeed", "MOVESPEED", "percentage1", 0, 1 }, { NULL, NULL, "newLine", 0, 0 }, { "power", "POWER", "percentage1", 1, 1 }, { "speed", "SPEED", "percentage1", 1, 1 }, { "duration", "DURATION", "percentage1", 1, 1 }, { "area", "AREA", "percentage1", 1, 1 }, { NULL, NULL, "newLine", 0, 0 }, { "cooldown", "COOLDOWN", "percentage1", 0, 1 }, { "amount", "AMOUNT", "flat", 0, 0 }, { "revivals", "REVIVAL", "flat", 0, 0 }, { "magnet", "MAGNET", "percentagePlusOne", 0, 0 }, { NULL, NULL, "newLine", 0, 0 }, { "luck", "LUCK", "percentage1", 0, 1 }, { "growth", "GROWTH", "percentage1", 0, 1 }, { "greed", "GREED", "percentage1", 0, 1 }, { "curse", "CURSE", "percentage1", 0, 1 }, { NULL, NULL, "newLine", 0, 0 }, { "rerolls", "REROLL", "flat", 0, 0 }, { "skips", "SKIP", "flat", 0, 0 }, { "banish", "BANISH", "flat", 0, 0 }, }; static void SceneManager_StartFromCharSelection(void); static void CS_OnSelectionChange(int moveCursor, int tint, const char *ch); static void CS_UpdateUIGridBottomRow(void); static CharPanel *CS_panelOf(UIButton *b) { return b && b >= &CS.panels[0].hit && b <= &CS.panels[CS_MAX - 1].hit ? (CharPanel *)((char *)b - offsetof(CharPanel, hit)) : NULL; } // CharStatsPanel.AssignData: statistiche del personaggio + potenziamenti comprati (+ Pandora sulle omni) static int CharStatsPanel_CheckForOmni(CharStatsPanel *sp, int i) { int r = 0; cJSON *pd = cJSON_GetObjectItem(data_get("powerups"), "PANDORA"), *p0 = cJSON_GetArrayItem(pd, 0); if (pd && cJSON_IsTrue(cJSON_GetObjectItem(p0, "active"))) for (int k = 0; k < (int)num(p0, "level", 0); k++) { cJSON *lv = cJSON_GetArrayItem(pd, k); if (!lv) return 0; if (has(lv, sp->s[i].name)) sp->s[i].value += num(lv, sp->s[i].name, 0), r = 1; } return r; } static void CharStatsPanel_AssignData(CharStatsPanel *sp, const char *ch) { cJSON *c = tbl0("characters", ch); if (!c) return; cJSON *egg = cJSON_GetObjectItem(po("EggData"), ch); for (int i = 0; i < 23; i++) { if (!sp->s[i].name || !has(c, sp->s[i].name)) continue; sp->s[i].value = num(c, sp->s[i].name, 0); if (egg && po_is("SelectedGoldenEggs") && has(egg, sp->s[i].name)) // le uova del personaggio (il magnete in trentesimi) sp->s[i].value += !strcmp(sp->s[i].name, "magnet") ? num(egg, "magnet", 0) / 0x1e : num(egg, sp->s[i].name, 0); int tinted = sp->s[i].omni ? CharStatsPanel_CheckForOmni(sp, i) : 0; cJSON *pu = cJSON_GetObjectItem(data_get("powerups"), sp->s[i].powerupType), *p0 = cJSON_GetArrayItem(pu, 0); if (pu) for (int k = 0; k < (int)num(p0, "level", 0); k++) { cJSON *lv = cJSON_GetArrayItem(pu, k); if (!lv || !cJSON_IsTrue(cJSON_GetObjectItem(p0, "active")) || !has(lv, sp->s[i].name)) continue; if (!strcmp(sp->s[i].powerupType, "MAXHEALTH")) sp->s[i].value += num(c, sp->s[i].name, 0) * num(lv, sp->s[i].name, 0); else sp->s[i].value += num(lv, sp->s[i].name, 0); tinted = 1; } sp->s[i].tinted = tinted; } } static const char *CharStatsPanel_GetStatDisplayTextValue(CharStatsPanel *sp, int i) { static char b[32]; float v = sp->s[i].value; const char *t = sp->s[i].type; if (!strcmp(t, "health")) snprintf(b, sizeof(b), "%.0f", v); else if (!strcmp(t, "flat")) { snprintf(b, sizeof(b), "%s%d", v >= 0 ? "+" : "", (int)floorf(v)); if (!strcmp(b, "+0")) return "-"; } else if (!strcmp(t, "percentagePerSecond")) { snprintf(b, sizeof(b), "%.1f", v); if (!strcmp(b, "0.0")) return "-"; } else if (!strcmp(t, "percentage1")) { snprintf(b, sizeof(b), "%s%d%%", v >= 1 ? "+" : "", (int)roundf(100 * (v - 1))); if (!strcmp(b, "+0%")) return "-"; } else if (!strcmp(t, "percentagePlusOne")) { snprintf(b, sizeof(b), "%s%d%%", v + 1 >= 1 ? "+" : "", (int)roundf(100 * v)); if (!strcmp(b, "+0%")) return "-"; } else return ""; return b; } static void CharStatsPanel_draw(CharStatsPanel *sp, float x, float y, float open, float bgAlpha) { rlPushMatrix(); rlTranslatef(x, y, 0); rlScalef(1, open, 1); // Open: scaleY 0 -> 1 in 150 ms nine("frame1_c2.png", 12, (Rectangle){ 0, 0, 0xc8, 0x20 + 0x10 * 22 }, Fade(WHITE, bgAlpha)); for (int i = 0; i < 23; i++) { if (!sp->s[i].name) continue; cJSON *p0 = tbl0("powerups", sp->s[i].powerupType); if (!p0) continue; float ry = 0x10 + 0x10 * i; TS_frame(str(p0, "texture"), str(p0, "frameName"), 6, ry, 0, 0.5f, PixelScale, 0, WHITE, 0); const char *nm = tr_of("powerUpLang", sp->s[i].powerupType, "name"); ui_text(*nm ? nm : str(p0, "name"), 0x18, ry, PixelScale, 0x78, 0, 0.5f, WHITE); text_at(CharStatsPanel_GetStatDisplayTextValue(sp, i), 0xba, ry, 16 * PixelScale, 1, 0.5f, sp->s[i].tinted ? YELLOW : WHITE); } rlPopMatrix(); } static void CharStatsPanel_init(CharStatsPanel *sp) { for (int i = 0; i < 23; i++) sp->s[i].name = CS_LIST[i].name, sp->s[i].powerupType = CS_LIST[i].powerupType, sp->s[i].type = CS_LIST[i].type, sp->s[i].omni = CS_LIST[i].omni, sp->s[i].value = CS_LIST[i].value; } static void CharStatsPanel_AssignPlayer(CharStatsPanel *sp, Player *p) { // in partita: i valori del giocatore (+ arcane silenziose) for (int i = 0; i < 23; i++) { if (!sp->s[i].name) continue; float *f = Player_field(p, sp->s[i].name); if (f) { sp->s[i].value = *f; if (!strcmp(sp->s[i].name, "cooldown")) sp->s[i].value += Arcanas.silentCooldown; if (!strcmp(sp->s[i].name, "power")) sp->s[i].value = sp->s[i].value + Arcanas.silentMight + Arcanas.bloodlineDamage; sp->s[i].tinted = 0; } } } // CharLevelPanel: gli stage validi con la spunta di quelli completati dal personaggio static void CharLevelPanel_build(void) { CS.nLevel = 0; cJSON *st; cJSON_ArrayForEach(st, data_get("stages")) { cJSON *s0 = cJSON_GetArrayItem(st, 0); if (!s0 || cJSON_IsTrue(cJSON_GetObjectItem(s0, "hidden")) || !cJSON_IsTrue(cJSON_GetObjectItem(s0, "unlocked")) || !cJSON_IsTrue(cJSON_GetObjectItem(s0, "validForCharcaterData"))) continue; if (CS.nLevel < 32) CS.levelStages[CS.nLevel++] = st->string; } } static void CharLevelPanel_AssignData(const char *ch) { cJSON *c = tbl0("characters", ch); for (int i = 0; i < CS.nLevel; i++) CS.levelTick[i] = c && arr_indexOf(cJSON_GetObjectItem(c, "completedStages"), CS.levelStages[i]) > -1; } // CharConfirmationPanel.AssignData / TurnToStart static void CharConfirmationPanel_AssignData(const char *ch) { cJSON *c = tbl0("characters", ch) ? tbl0("characters", ch) : tbl0("characters", "ANTONIO"); CS.cpTint = 0xffffff; snprintf(CS.buyText, sizeof(CS.buyText), "%s", tr(cJSON_IsTrue(cJSON_GetObjectItem(c, "isBought")) ? "charConfirm_confirm" : "charConfirm_unlock")); } static void CharConfirmationPanel_TurnToStart(void) { CS.cpTint = 0xffff00; snprintf(CS.buyText, sizeof(CS.buyText), "%s", tr("charConfirm_start")); } static void CS_OnPanelClicked(const char *ch) { if (CS.isStartingGameMode) return; CS.Highlighted = ch; CharConfirmationPanel_AssignData(ch); CharStatsPanel_AssignData(&CS.stats, ch); CharLevelPanel_AssignData(ch); CS_UpdateUIGridBottomRow(); CS.isReadyToStart = 0; CS_OnSelectionChange(1, 0, ch); } static void CS_OnConfirmClicked(void *ctx) { (void)ctx; cJSON *c = tbl0("characters", CS.Highlighted); float price = num(c, "price", 0) * Core_CharMarkup(); int bought = cJSON_IsTrue(cJSON_GetObjectItem(c, "isBought")); if (bought && !CS.isReadyToStart) { po_sets("SelectedCharacter", CS.Highlighted); CS_OnSelectionChange(1, 1, po_str("SelectedCharacter")); CharConfirmationPanel_TurnToStart(); CS.isReadyToStart = 1; Sound_PlaySound("ClickIn", 0, 1, 0x64, 0, 0); Core_SetSeenWeapon(str(c, "startingWeapon")); UIGrid_SelectAt(CS.gridLast, CS.gridBottom); OV.UI_selected = &CS.Button; } else if (bought && CS.isReadyToStart) { Overlay_DestroyGrid(); SceneManager_StartFromCharSelection(); Sound_PlaySound("ClickIn", 0, 1, 0xc8, 0, 0); CS.isStartingGameMode = 1; } else if (!bought && po_num("Coins") >= price) { po_add("Coins", -price), po_add("LifetimeCoins", -price); TopBar_UpdateCoins(); obj_set(c, "isBought", cJSON_CreateTrue()); CharConfirmationPanel_AssignData(CS.Highlighted); CS_UpdateUIGridBottomRow(); po_push("BoughtCharacters", CS.Highlighted); // Core.OnCharacterBought (SaveBought: solo Storage del web) po_sets("SelectedCharacter", CS.Highlighted); CS_OnSelectionChange(1, 1, po_str("SelectedCharacter")); CS.isReadyToStart = 0; Sound_PlaySound("ClickOut", 0, 1, -0x190, 0, 0); } } static void CS_OnSelectionChange(int moveCursor, int tint, const char *ch) { for (int i = 0; i < CS.n; i++) CS.panels[i].bgTint = 0xffffff; CharPanel *p = NULL; for (int i = 0; i < CS.n && !p; i++) if (!strcmp(CS.panels[i].ch, ch)) p = &CS.panels[i]; if (p) { if (moveCursor) CS.hcX = p->x - 9, CS.hcY = p->y - 9; if (tint) p->bgTint = 0xffff00; CS.HighlightedPanel = p; if (UIGrid.on) UIGrid_SelectGameObject(&p->hit); OV.UI_selected = &p->hit; CS.currentlyHighlightedPanel = p; } CS_UpdateUIGridBottomRow(); } static void CS_UpdateUIGridBottomRow(void) { // uova d'oro e occhiali: le caselle di CharDetailsPanel e l'icona del personaggio if (!UIGrid.on) return; int e = CS.hasGoldenEggs, g = CS.hasNoseglasses; UIGrid_SetContents(0, CS.gridBottom, e && g ? &CS.WEAPONS_box : NULL, 0); UIGrid_SetContents(1, CS.gridBottom, e && g ? &CS.EGGS_box : !e && g ? &CS.WEAPONS_box : NULL, 0); UIGrid_SetContents(2, CS.gridBottom, g ? &CS.myIcon : e ? &CS.EGGS_box : NULL, 0); UIGrid_SetContents(3, CS.gridBottom, &CS.Button, 0); } static void CS_OnCharImageClicked(void *c) { // con gli occhiali: la skin successiva fra quelle sbloccate (void)c; cJSON *ch = tbl0("characters", CS.Highlighted), *skins = cJSON_GetObjectItem(ch, "skins"), *s; if (!cJSON_IsTrue(cJSON_GetObjectItem(ch, "isBought")) || !skins) return; cJSON *un[32]; int n = 0, k = 0; cJSON_ArrayForEach(s, skins) if (cJSON_IsTrue(cJSON_GetObjectItem(s, "unlocked")) && n < 32) un[n++] = s; if (!n) return; for (int i = 0; i < n; i++) if (num(un[i], "id", -1) == num(ch, "currentSkinIndex", 0)) k = i; if (++k >= n) k = 0; obj_set(ch, "currentSkinIndex", cJSON_CreateNumber(num(un[k], "id", 0))); Sound_PlaySimple("ClickIn", 0); } static void CS_OnEggsBoxClicked(void *c) { (void)c; cJSON_ReplaceItemInObject(PlayerOptions, "SelectedGoldenEggs", cJSON_CreateBool(!po_is("SelectedGoldenEggs"))); Sound_PlaySimple("ClickIn", 0); PlayerOptions_Save(); // SaveOptions CharStatsPanel_AssignData(&CS.stats, CS.Highlighted); CharLevelPanel_AssignData(CS.Highlighted); CS_UpdateUIGridBottomRow(); } static void CS_OnWeaponsBoxClicked(void *c) { (void)c; double m = po_num("SelectedMaxWeapons") + 1; po_set("SelectedMaxWeapons", m > 6 ? 1 : m); Sound_PlaySimple("ClickIn", 0); PlayerOptions_Save(); } static void CS_cancel(void) { if (TB.BackButton.onDown) TB.BackButton.onDown(TB.BackButton.ctx); } // BackButton._events.pointerdown.fn() static void CS_MakeUIGrid(void) { CS.gridBottom = CS.Rows + 1; Overlay_MakeUIGrid(CS.Columns, CS.Rows + 2, 1); for (int i = 0; i < CS.Columns; i++) UIGrid_SetContents(i, 0, &TB.BackButton, 0); for (int i = 0; i < CS.n; i++) UIGrid_SetContents(i % CS.Columns, 1 + i / CS.Columns, &CS.panels[i].hit, 0); CS_UpdateUIGridBottomRow(); CS.gridLast = 3; Overlay_ToggleCursorsVisibility(0); OV.OnCancelCallback = CS_cancel; } // Vita: griglia in coordinate dello schermo, CS.scY = scorrimento verso il basso (0..scMaxY) #define CS_CELL 106 #define CS_GX 25 #define CS_GY 72 static float CS_wx(float x) { return x; } static float CS_wy(float y) { return y - CS.scY; } static void CS_panelHit(CharPanel *p) { p->hit.x = CS_wx(p->x), p->hit.y = CS_wy(p->y); p->hit.w = p->hit.h = CS_CELL, p->hit.sc = 1; } static void CS_onStatsKey(void) { if (CS.statsVisible) CS.statsOpen = !CS.statsOpen, Sound_PlaySimple("ClickIn", 0); } static int CS_spamOn, SS_spamOn; static KeyCombo CS_spam, SS_spam; static void CharSelectionScene_create(void) { CS_spamOn = tflag > 0, CS_spam.index = 0; // createCombo spam: il listener solo con la catena di Smith gia' partita memset(&CS, 0, sizeof(CS)); CS.active = 1; CS.Columns = 4, CS.scrollTopY = 0x40; if (!tbl0("characters", po_str("SelectedCharacter"))) po_sets("SelectedCharacter", "ANTONIO"); // preload: Veranda dopo Leda, setupRNJ (Arengijus), setupMIS (Fino): sblocchi e segreti, F3.2/F3.4 if (num(tbl0("enemies", "BOSS_XLLEDA"), "killedAmount", 0) >= 1) { obj_set(tbl0("characters", "VERANDA"), "hidden", cJSON_CreateFalse()); if (!po_has("UnlockedCharacters", "VERANDA")) po_push("UnlockedCharacters", "VERANDA"); } Arengijus_setupRNJ(); CS.hasGoldenEggs = po_has("CollectedItems", "RELIC_GOLDENEGG"); CS.hasNoseglasses = po_has("CollectedItems", "RELIC_NOSEGLASSES"); CS.Highlighted = po_str("SelectedCharacter"); UIButton_set(&CS.bg, "MenuBackground", 20, 62, 452, 428, 1, 0, 0); // Vita: griglia a sinistra, scheda a destra int anyCompleted = 0; cJSON *c; cJSON_ArrayForEach(c, data_get("characters")) { cJSON *c0 = cJSON_GetArrayItem(c, 0); if (cJSON_IsTrue(cJSON_GetObjectItem(c0, "hidden")) || CS.n >= CS_MAX) continue; CharPanel *p = &CS.panels[CS.n++]; p->ch = c->string, p->bgTint = 0xffffff; UIButton_set(&p->hit, "", 0, 0, 0x6e, 0x6e, PixelScale, 0, 0); UIButton_on(&p->hit, CS_OnConfirmClicked, NULL); // panel.OnClick = OnConfirmClicked cJSON *v; if (!anyCompleted) cJSON_ArrayForEach(v, cJSON_GetObjectItem(c0, "completedStages")) if (cJSON_IsString(v) && cJSON_IsTrue(cJSON_GetObjectItem(tbl0("stages", v->valuestring), "validForCharcaterData"))) anyCompleted = 1; } CS.ShowScrollbar = CS.n > 0xc; for (int i = 0; i < CS.n; i++) CS.panels[i].x = CS_GX + i % CS.Columns * (CS_CELL + 4), CS.panels[i].y = CS_GY + i / CS.Columns * (CS_CELL + 4); CS.Rows = (CS.n + CS.Columns - 1) / CS.Columns; CS.scMaxY = fmaxf(0, CS.Rows * (CS_CELL + 4) + 6 - 420), CS.scMinY = 0, CS.scY = 0; // CharConfirmationPanel (x, y; poi y -= displayHeight) CS.moveButtonsAcross = cJSON_GetArraySize(po("UnlockedStages")) > 1 || cJSON_GetArraySize(po("UnlockedHypers")) > 0; CS.cpX = 488, CS.cpY = 62, CS.cpW = 452; // la scheda del personaggio UIButton_set(&CS.Button, "GreenButton", 506, 424, 416, 54, 1, 0, 0); UIButton_on(&CS.Button, CS_OnConfirmClicked, NULL); CharConfirmationPanel_AssignData(CS.Highlighted); CS.y0 = 0; UIButton_set(&CS.WEAPONS_box, "OptionsButton", 506, 370, 204, 44, 1, 0, 0); UIButton_set(&CS.EGGS_box, "OptionsButton", 718, 370, 204, 44, 1, 0, 0); CS.WEAPONS_box.visible = CS.hasNoseglasses, CS.EGGS_box.visible = CS.hasGoldenEggs; UIButton_set(&CS.myIcon, "", 506, 80, 128, 128, 1, 0, 0); if (CS.hasGoldenEggs) UIButton_on(&CS.EGGS_box, CS_OnEggsBoxClicked, NULL); if (CS.hasNoseglasses) UIButton_on(&CS.WEAPONS_box, CS_OnWeaponsBoxClicked, NULL), UIButton_on(&CS.myIcon, CS_OnCharImageClicked, NULL); CharStatsPanel_init(&CS.stats); CharStatsPanel_AssignData(&CS.stats, CS.Highlighted); CharLevelPanel_build(); CharLevelPanel_AssignData(CS.Highlighted); CS.levelVisible = anyCompleted && !po_is("HideProgress"); CS.statsVisible = cJSON_GetArraySize(po("UnlockedCharacters")) > 1; CS_MakeUIGrid(); CS_OnPanelClicked(CS.Highlighted); CS.openAt = 0; TB_title = tr("character_header"); OV.OnSquare = CS_onStatsKey; CS.statsOpen = getenv("VS_CSSTATS") != NULL; // sviluppo: statistiche aperte VPrompt P[] = { { G_SQUARE, "vui_stats" }, { G_CROSS, "vui_confirm" }, { G_CIRCLE, "vui_back" } }; if (CS.statsVisible) vui_set_prompts(P, 3); else vui_set_prompts(P + 1, 2); } static void CS_correctScrollableContainerPosition(void) { // Vita: il selezionato sempre tutto dentro il riquadro CharPanel *p = CS.currentlyHighlightedPanel; if (!p) return; if (p->y - CS.scY < 68) CS.scY = p->y - 72; if (p->y + CS_CELL - CS.scY > 484) CS.scY = p->y + CS_CELL - 480; CS.scY = fminf(fmaxf(CS.scY, 0), CS.scMaxY); } static void CS_ScrollBy(float d) { CS.scY += d; if (CS.scY > CS.scMaxY) CS.scY = CS.scMaxY; if (CS.scY < CS.scMinY) CS.scY = CS.scMinY; } static void CharSelectionScene_update(float delta) { CS.t += delta; for (int i = 0; i < CS.n; i++) CS_panelHit(&CS.panels[i]); // HandleInput: rotella, trascinamento e tocco sui pannelli (pointerup entro 5 px) Rectangle bounds = { 20, 62, 452, 428 }; Vector2 m = menu_pointer(); if (GetMouseWheelMove()) CS_ScrollBy(-0.4f * 100 * GetMouseWheelMove()); if (ptr_pressed()) { CS.downOnSc = CheckCollisionPointRec(m, bounds), CS.downAt = m, CS.dragOff = CS.scY + m.y; UIButton_clicked(&CS.Button) || UIButton_clicked(&CS.WEAPONS_box) || UIButton_clicked(&CS.EGGS_box) || UIButton_clicked(&CS.myIcon); } else if (ptr_down() && CS.downOnSc) { CS.scY = fminf(fmaxf(CS.dragOff - m.y, 0), CS.scMaxY); } else if (ptr_released() && CS.downOnSc) { CS.downOnSc = 0; if (CheckCollisionPointRec(m, bounds) && fabsf(CS.downAt.x - m.x) < 8 && fabsf(CS.downAt.y - m.y) < 8) for (int i = 0; i < CS.n; i++) { CharPanel *p = &CS.panels[i]; if (CheckCollisionPointRec(m, (Rectangle){ p->hit.x, p->hit.y, CS_CELL, CS_CELL })) { if (!strcmp(p->ch, CS.Highlighted)) CS_OnConfirmClicked(NULL); // Vita: secondo tocco sullo stesso = conferma else CS_OnPanelClicked(p->ch); break; } } } // update(): il selezionato della griglia cambia -> pannello (cursore giallo) o bottone (frecce) if (OV.UI_selected != UIGrid.previousGameObject) { CharPanel *p = CS_panelOf(OV.UI_selected); if (p) { CS_OnPanelClicked(p->ch); Overlay_ToggleCursorsVisibility(0); CS.hcVisible = 1; CS_correctScrollableContainerPosition(); } else { Overlay_ToggleCursorsVisibility(1); CS.hcVisible = 0; } } for (int i = 0; i < CS.n; i++) CS_panelHit(&CS.panels[i]); } static void CharSelectionPanel_draw(CharPanel *p) { cJSON *c = tbl0("characters", p->ch), *w = tbl0("weapons", str(c, "startingWeapon")); if (!w) w = tbl0("weapons", "WHIP"); int bought = cJSON_IsTrue(cJSON_GetObjectItem(c, "isBought")), isVoid = str(c, "startingWeapon") && !strcmp(str(c, "startingWeapon"), "VOID"); float x = 0, y = 0; // Vita: disegno da 110 px scalato nella cella rlPushMatrix(); rlTranslatef(CS_wx(p->x), CS_wy(p->y), 0); rlScalef(CS_CELL / 110.0f, CS_CELL / 110.0f, 1); Color bt = { (unsigned char)(p->bgTint >> 16), (unsigned char)(p->bgTint >> 8), (unsigned char)p->bgTint, 255 }; nine("frame1_c2.png", 12, (Rectangle){ x, y, 0x6e, 0x6e }, bt); int showW = !isVoid, rnj = !strcmp(p->ch, "ARENGIJUS"); const char *tex, *spr; char_sprite(p->ch, &tex, &spr); if (rnj && po_num("PlayedRNJ") <= 0) showW = 0, spr = "random_00.png"; else if (rnj) spr = "random_99.png"; if (showW) { // myIconBG: l'icona dell'arma riempita di 0x111111, sotto quella vera const Frame *f = frame_get(str(w, "texture"), str(w, "frameName")); if (f) { Sprite s; sprite_init(&s, f, x + 0x6e - 9, y + 0x6e - 9); sprite_setOrigin(&s, 1, 1); sprite_setScale(&s, 2 * PixelScale); s.tint = 0x111111, s.scrollFactor0 = 1; scene_render_one(&s, fill_shader); } TS_frame(str(w, "texture"), str(w, "frameName"), x + 0x6e - 0xc, y + 0x6e - 0xc, 1, 1, 2 * PixelScale, 0, WHITE, 0); } const Frame *cf = frame_get(tex, spr); if (cf) { Sprite s; sprite_init(&s, cf, x + 6, y + 0x6e - 5); sprite_setOrigin(&s, 0, 1); sprite_setScale(&s, 2 * PixelScale); s.tint = bought ? 0xffffff : 0, s.scrollFactor0 = 1; scene_render_one(&s, bought ? (Shader){ 0 } : fill_shader); // setTint(0): nero pieno } ui_text(char_text(p->ch, "charName"), x + 6, y + 5, 1.25f, 0x50, 0, 0, bought ? WHITE : (Color){ 0x44, 0x44, 0x44, 255 }); rlPopMatrix(); } static void CharConfirmationPanel_draw(void) { // Vita: la scheda a destra (ritratto, nome, arma, descrizione, statistiche, conferma) float x = CS.cpX, y = CS.cpY; cJSON *c = tbl0("characters", CS.Highlighted) ? tbl0("characters", CS.Highlighted) : tbl0("characters", "ANTONIO"); cJSON *w = tbl0("weapons", str(c, "startingWeapon")); if (!w) w = tbl0("weapons", "WHIP"); int bought = cJSON_IsTrue(cJSON_GetObjectItem(c, "isBought")), isVoid = str(c, "startingWeapon") && !strcmp(str(c, "startingWeapon"), "VOID"); Color bt = { (unsigned char)(CS.cpTint >> 16), (unsigned char)(CS.cpTint >> 8), (unsigned char)CS.cpTint, 255 }; nine("frame5_c4.png", 12, (Rectangle){ x, y, CS.cpW, 428 }, bt); nine("frame1_c2.png", 12, (Rectangle){ x + 18, y + 18, 128, 128 }, WHITE); int showW = !isVoid, rnj = !strcmp(CS.Highlighted, "ARENGIJUS"); const char *tex, *spr; char_sprite(CS.Highlighted, &tex, &spr); if (rnj && po_num("PlayedRNJ") <= 0) showW = 0, spr = "random_00.png"; else if (rnj) spr = "random_99.png"; const Frame *cf = frame_get(tex, spr); if (cf) { Sprite sp; sprite_init(&sp, cf, x + 82, y + 82); sprite_setScale(&sp, fminf(3, 100.0f / fmaxf(cf->sw, cf->sh))); sp.tint = bought ? 0xffffff : 0, sp.scrollFactor0 = 1; scene_render_one(&sp, bought ? (Shader){ 0 } : fill_shader); } cJSON *skins = cJSON_GetObjectItem(c, "skins"), *sk; // UpdateSkinIndexIndicator: con gli occhiali e piu' di una skin sbloccata int ns = 0; cJSON_ArrayForEach(sk, skins) ns += cJSON_IsTrue(cJSON_GetObjectItem(sk, "unlocked")); if (CS.hasNoseglasses && ns > 1) { float ix = x + 82 - 0.5f * ns * 10; int k = 0; cJSON_ArrayForEach(sk, skins) { if (!cJSON_IsTrue(cJSON_GetObjectItem(sk, "unlocked"))) continue; TS_frame("UI", num(sk, "id", -1) == num(c, "currentSkinIndex", 0) ? "weaponLevelFull.png" : "weaponLevelEmpty.png", ix + 10 * k++, y + 136, 0, 0.5f, 1.25f, 0, WHITE, 0); } } const char *pre = char_text(CS.Highlighted, "prefix"); char name[128]; snprintf(name, sizeof(name), "%s%s%s", pre, *pre ? " " : "", char_text(CS.Highlighted, "charName")); text_at(name, x + 162, y + 22, fit_size(name, 36, 270), 0, 0, rgb(VUI_GOLD, 1)); text_at(char_text(CS.Highlighted, "surname"), x + 162, y + 62, fit_size(char_text(CS.Highlighted, "surname"), 22, 270), 0, 0, (Color){ 0xcf, 0xc6, 0xb6, 255 }); if (showW) { TS_frame("UI", "frameB.png", x + 162, y + 96, 0, 0, 1.5f, 0, WHITE, 0); TS_frame(str(w, "texture"), str(w, "frameName"), x + 180, y + 114, 0.5f, 0.5f, 1.5f, 0, WHITE, 0); const char *wn = lang_text("weaponLang", str(c, "startingWeapon") ? str(c, "startingWeapon") : "WHIP", "name", w); text_at(wn, x + 208, y + 114, fit_size(wn, 22, 220), 0, 0.5f, WHITE); } ui_wrap_text(char_text(CS.Highlighted, "description"), x + 18, y + 162, 22, 412, 66, WHITE, 1); if (CS.statsVisible) { // quattro statistiche chiave (tutte col quadrato) static const int K[4] = { 0, 2, 3, 5 }; for (int i = 0; i < 4; i++) { float sx = x + 18 + (i % 2) * 210, sy = y + 248 + (i / 2) * 26; cJSON *p0 = tbl0("powerups", CS.stats.s[K[i]].powerupType); TS_frame(str(p0, "texture"), str(p0, "frameName"), sx, sy, 0, 0.5f, 1, 0, WHITE, 0); const char *nm = tr_of("powerUpLang", CS.stats.s[K[i]].powerupType, "name"); text_at(*nm ? nm : str(p0, "name"), sx + 22, sy, fit_size(*nm ? nm : str(p0, "name"), 20, 120), 0, 0.5f, (Color){ 0xcf, 0xc6, 0xb6, 255 }); text_at(CharStatsPanel_GetStatDisplayTextValue(&CS.stats, K[i]), sx + 196, sy, 20, 1, 0.5f, CS.stats.s[K[i]].tinted ? YELLOW : WHITE); } } if (CS.WEAPONS_box.visible) { UIButton_draw(&CS.WEAPONS_box, 1); const char *t = TextFormat("Max armi: %d", (int)po_num("SelectedMaxWeapons")); text_at(t, CS.WEAPONS_box.x + 102, CS.WEAPONS_box.y + 22, fit_size(t, 22, 180), 0.5f, 0.5f, WHITE); } if (CS.EGGS_box.visible) { UIButton_draw(&CS.EGGS_box, 1); cJSON *it = cJSON_GetObjectItem(data_get("items"), "RELIC_GOLDENEGG"); TS_frame("UI", "menu_checkbox_24_bg.png", CS.EGGS_box.x + 26, CS.EGGS_box.y + 22, 0.5f, 0.5f, 1, 0, WHITE, 0); if (po_is("SelectedGoldenEggs")) TS_frame("UI", "yes16.png", CS.EGGS_box.x + 26, CS.EGGS_box.y + 22, 0.5f, 0.5f, 1, 0, WHITE, 0); const char *t = lang_text("itemLang", "RELIC_GOLDENEGG", "name", it); text_at(t, CS.EGGS_box.x + 46, CS.EGGS_box.y + 22, fit_size(t, 22, 150), 0, 0.5f, WHITE); } UIButton_draw(&CS.Button, 1); char lab[96]; if (!bought) snprintf(lab, sizeof(lab), "%s %.0f", CS.buyText, num(c, "price", 0) * Core_CharMarkup()); else snprintf(lab, sizeof(lab), "%s", CS.buyText); float lw = MeasureTextEx(vs_font, lab, 30, 0).x, cx = CS.Button.x + 0.5f * bW(&CS.Button), cy = CS.Button.y + 0.5f * bH(&CS.Button); text_at(lab, cx, cy, 30, 0.5f, 0.5f, WHITE); if (!bought) TS_frame("UI", "CoinGold.png", cx + 0.5f * lw + 6, cy, 0, 0.5f, 2, 0, WHITE, 0); } static void CS_statsOverlay(void) { // Vita: tutte le statistiche (quadrato), sopra la scheda float x = CS.cpX + 10, y = CS.cpY + 10; nine("frame1_c4.png", 12, (Rectangle){ x, y, CS.cpW - 20, 408 }, WHITE); int k = 0; for (int i = 0; i < 23; i++) { if (!CS.stats.s[i].name) continue; cJSON *p0 = tbl0("powerups", CS.stats.s[i].powerupType); if (!p0) continue; float sx = x + 14 + (k % 2) * 212, sy = y + 22 + (k / 2) * 25; k++; TS_frame(str(p0, "texture"), str(p0, "frameName"), sx, sy, 0, 0.5f, 1, 0, WHITE, 0); const char *nm = tr_of("powerUpLang", CS.stats.s[i].powerupType, "name"); text_at(*nm ? nm : str(p0, "name"), sx + 22, sy, fit_size(*nm ? nm : str(p0, "name"), 20, 120), 0, 0.5f, (Color){ 0xcf, 0xc6, 0xb6, 255 }); text_at(CharStatsPanel_GetStatDisplayTextValue(&CS.stats, i), sx + 198, sy, 20, 1, 0.5f, CS.stats.s[i].tinted ? YELLOW : WHITE); } float ly = y + 22 + ((k + 1) / 2) * 25 + 8; if (CS.hasGoldenEggs) { cJSON *it = cJSON_GetObjectItem(data_get("items"), "RELIC_GOLDENEGG"); TS_frame(str(it, "texture"), str(it, "frameName"), x + 14, ly, 0, 0.5f, 1, 0, WHITE, 0); text_at(TextFormat("%s: %.0f", lang_text("itemLang", "RELIC_GOLDENEGG", "name", it), num(cJSON_GetObjectItem(po("EggData"), CS.Highlighted), "total", 0)), x + 36, ly, 20, 0, 0.5f, WHITE); ly += 26; } if (CS.levelVisible) for (int i = 0; i < CS.nLevel && ly < y + 396; i++) { float sx = x + 14 + (i % 2) * 212, sy = ly + (i / 2) * 24; TS_frame("UI", "menu_checkbox_16_bg.png", sx + 8, sy, 0.5f, 0.5f, 1, 0, WHITE, 0); if (CS.levelTick[i]) TS_frame("UI", "menu_checkbox_16_checkmark.png", sx + 8, sy, 0.5f, 0.5f, 1, 0, WHITE, 0); const char *nm = tr_of("stageLang", CS.levelStages[i], "stageName"); if (!*nm) nm = str(tbl0("stages", CS.levelStages[i]), "stageName"); text_at(nm, sx + 22, sy, fit_size(nm, 20, 180), 0, 0.5f, WHITE); } } static void CharSelectionScene_draw(void) { UIButton_draw(&CS.bg, 1); menu_clip(24, 66, 444, 420); for (int i = 0; i < CS.n; i++) { float y = CS_wy(CS.panels[i].y); if (y > -CS_CELL && y < MENU_H) CharSelectionPanel_draw(&CS.panels[i]); } menu_unclip(); CharPanel *p = CS_panelOf(OV.UI_selected); if (p) vui_focus((Rectangle){ CS_wx(p->x), CS_wy(p->y), CS_CELL, CS_CELL }, CS.t); if (CS.scMaxY > 0) { // barra di scorrimento sottile float h = 420 * 420 / (420 + CS.scMaxY); DrawRectangleRounded((Rectangle){ 462, 66 + (420 - h) * CS.scY / CS.scMaxY, 5, h }, 1, 4, rgb(VUI_GOLD, 0.7f)); } CharConfirmationPanel_draw(); if (CS.statsOpen) CS_statsOverlay(); } // Number.toString di JS per i numeri delle schede (la rappresentazione piu' corta che torna uguale) static const char *js_num(double v) { static char b[4][32]; static int k; char *o = b[k++ & 3]; if (isnan(v)) return "NaN"; int p = 0; while (++p < 17 && (snprintf(o, 32, "%.*g", p, v), strtod(o, NULL) != v)) {} if (p == 17) snprintf(o, 32, "%.17g", v); double a = fabs(v); if (strchr(o, 'e') && a >= 1e-6 && a < 1e21) { // JS scrive in notazione fissa fra 1e-6 e 1e21: 140, non 1.4e+02 int d = p - 1 - (int)floor(log10(a)); snprintf(o, 32, "%.*f", d > 0 ? d : 0, v); } return o; } static const char *stage_text(const char *id, const char *field) { // stageName/description/hyperTips localizzati, se no i dati const char *s = tr_of("stageLang", id, field); return *s ? s : str(tbl0("stages", id), field) ? str(tbl0("stages", id), field) : ""; } // ============================================================================ // 0xce7d: StageSelectionScene + 0xebf6 StageSelectionPanel + 0x848a StageConfirmationPanel + 0x94cf StageStatsPanel // + 0xabae StageRelicsPanel + StageMusicPanel (0x4275, Magic Banger) + StageRandomPanel (0x11cb2, Trisection) // ============================================================================ #define SS_MAX 32 typedef struct { const char *power; float x, y; int order, highlight; UIButton hit; } StagePanel; typedef struct { const char *key, *label, *po; float x; UIButton box; int visible; } StageToggle; static struct { int active, n, isStartingGameMode, isReadyToStart, hasGoldenEggs, hasBanger, hasRandomOptions; int hasWitchTear, hasRandomazzo, hasGreatGospel, hasInverse, hasReapers, hasRandomEvents, hasAnyButton; int gridBottom, gridLast, hlVisible, buttonVisible, musicOpen; // musicOpen: Vita, il pannello della musica su triangolo const char *Highlighted; StagePanel panels[SS_MAX], *HighlightedPanel; UIButton *previousLevel, *previousToggle, hidden1, hidden2; // hiddenGUIDHelper / hiddenGUIDHelper2 float scY, scMaxY, scMinY, scH, y0, scrollbarOffset, scrollbarInitialHeight, scrollTopY, scrollHeight, hlX, hlY, t; float cpX, cpY, cpW; unsigned cpTint; UIButton bg, ScrollBar, myButton1; StageToggle toggles[6]; // Hyper, Hurry, Mazzo, LimitBreak, Inverse, Reapers struct { const char *name, *display, *type, *icon; unsigned tint; cJSON *def; char nameText[512], valueText[32]; unsigned nameTint, valueTint; } stats[14]; int downOnSc; Vector2 downAt; float dragOff; // StageRandomPanel (Trisection) int rpExists, rpVisible; unsigned rpTint; UIButton rpBox; // StageMusicPanel (Magic Banger) const char *bgmTypes[64], *bgmType, *selectedSpeed, *charBGM; int nBgm, changed, musicVisible, musicInput; UIButton arrowButtonL, arrowButtonR, speedSelectionL, speedSelectionR, lockSelected_Box, *musicHL; float mpX, mpY; } SS; static const struct { const char *name, *display, *def, *type, *icon; unsigned tint; } SS_LIST[14] = { { "TimeLimit", "stageSelection_TimeLimit", "1", "time", "TimeToken.png", 0xffffff }, { "ClockSpeed", "stageSelection_ClockSpeed", "\"x1\"", "fixed", "TimeToken2.png", 0xffffff }, { "PlayerPxSpeed", "stageSelection_PlayerPxSpeed", "1", "percentage1", "Wing.png", 0xffffff }, { NULL, NULL, NULL, "newLine", NULL, 0 }, { "GoldMultiplier", "stageSelection_GoldMultiplier", "1", "percentage1", "CoinGold.png", 0xffff00 }, { "LuckBonus", "stageSelection_LuckBonus", "0", "percentage", "Clover2.png", 0xffff00 }, { "XPBonus", "stageSelection_XPBonus", "\"--\"", "fixed", "GemBlue.png", 0xffff00 }, { NULL, NULL, NULL, "newLine", NULL, 0 }, { "EnemyHealthMultiplier", "stageSelection_EnemyHealth", "1", "percentage1", "HeartMini.png", 0x992200 }, { NULL, NULL, NULL, "newLine", NULL, 0 }, { NULL, NULL, NULL, "newLine", NULL, 0 }, { "tips", "--", "\"--\"", "text", "SkullToken.png", 0xffffff }, { NULL, NULL, NULL, "newLine", NULL, 0 }, { NULL, NULL, NULL, "newLine", NULL, 0 }, }; static const char *const ValidCharacters[] = { "ANTONIO", "IMELDA", "PASQUALINA", "GENNARO", "CAMILLO", "CIRO", "PORTA", "LAMA", "CROCI", "CRISTINA", "DOMMARIO", "GERMANA", "MORTACCIO", "CAVALLO", "TATANKA", "MARIA", "PUGNALA", "CONCETTA", "POPPEA", "GIOVANNA" }; static int GetValidCharacter(const char *c) { for (size_t i = 0; i < sizeof(ValidCharacters) / sizeof(*ValidCharacters); i++) if (c && !strcmp(c, ValidCharacters[i])) return 1; return 0; } static void SceneManager_StartFromStageSelection(void); static void SS_OnSelectionChange(void); static StagePanel *SS_panelOf(UIButton *b) { return b && b >= &SS.panels[0].hit && b <= &SS.panels[SS_MAX - 1].hit ? (StagePanel *)((char *)b - offsetof(StagePanel, hit)) : NULL; } static cJSON *SS_stage(const char *id) { return tbl0("stages", id); } // StageStatsPanel.AssignData: mods dello stage (+ hyper, + inverse) con le differenze dal default static void StageStatsPanel_AssignData(const char *id) { cJSON *s = SS_stage(id); if (!s) return; int hyper = po_is("SelectedHyper") && cJSON_IsTrue(cJSON_GetObjectItem(cJSON_GetObjectItem(s, "hyper"), "unlocked")), unlocked = cJSON_IsTrue(cJSON_GetObjectItem(s, "unlocked")); cJSON *mods = cJSON_Duplicate(cJSON_GetObjectItem(s, "mods"), 1), *m; if (!mods) mods = cJSON_CreateObject(); const char *ex[2] = { hyper ? "hyper" : NULL, po_is("SelectedInverse") ? "inverse" : NULL }; for (int e = 0; e < 2; e++) { cJSON *add = ex[e] ? cJSON_GetObjectItem(s, ex[e]) : NULL; if (!add) continue; for (int i = 0; i < 14; i++) { if (!SS.stats[i].name || !strcmp(SS.stats[i].name, "TimeLimit") || !(m = cJSON_GetObjectItem(add, SS.stats[i].name))) continue; cJSON *cur = cJSON_GetObjectItem(mods, SS.stats[i].name); if (cur && cJSON_IsNumber(cur) && cJSON_IsNumber(m)) cJSON_SetNumberValue(cur, cur->valuedouble + m->valuedouble); else obj_set(mods, SS.stats[i].name, cJSON_Duplicate(m, 1)); } } obj_copy(mods, "tips", cJSON_GetObjectItem(s, "tips")); int shown = 0; for (int i = 0; i < 14; i++) { if (!SS.stats[i].name) continue; if (!(m = cJSON_GetObjectItem(mods, SS.stats[i].name))) { snprintf(SS.stats[i].nameText, sizeof(SS.stats[i].nameText), "--"); continue; } // i DLC non hanno tips cJSON *d = SS.stats[i].def; int same = (cJSON_IsNumber(m) && cJSON_IsNumber(d) && m->valuedouble == d->valuedouble) || (cJSON_IsString(m) && cJSON_IsString(d) && !strcmp(m->valuestring, d->valuestring)) || (cJSON_IsNull(m) && cJSON_IsNull(d)); // value == default if (same || !unlocked) { snprintf(SS.stats[i].nameText, sizeof(SS.stats[i].nameText), "%s", tr(SS.stats[i].display)); snprintf(SS.stats[i].valueText, sizeof(SS.stats[i].valueText), "--"); SS.stats[i].nameTint = SS.stats[i].valueTint = 0xffffff; continue; } char val[32] = ""; double v = cJSON_IsNumber(m) ? m->valuedouble : 0; const char *t = SS.stats[i].type; unsigned tint = SS.stats[i].tint; if (!strcmp(SS.stats[i].name, "ClockSpeed")) t = "fixed", snprintf(val, sizeof(val), "%s", po_is("SelectedHurry") ? "x2" : "x1"), tint = SS.stats[i].tint = po_is("SelectedHurry") ? 0xffff : 0xffffff; else if (!strcmp(SS.stats[i].name, "XPBonus")) { double x = v + (po_is("SelectedHurry") ? 0.25 : 0); snprintf(val, sizeof(val), "--"); if (x < 1) snprintf(val, sizeof(val), "-%s%%", js_num(100 * (1 - x))); else if (x > 1) snprintf(val, sizeof(val), "+%s%%", js_num(100 * (x - 1))); tint = SS.stats[i].tint = po_is("SelectedHurry") ? 0xffff : 0xffffff; t = "fixed"; } else if (!strcmp(t, "fixed")) snprintf(val, sizeof(val), "%s", cJSON_IsString(m) ? m->valuestring : js_num(v)); shown++; snprintf(SS.stats[i].nameText, sizeof(SS.stats[i].nameText), "%s", tr(SS.stats[i].display)); SS.stats[i].nameTint = SS.stats[i].valueTint = tint; // GetStatDisplayTextValue if (!strcmp(t, "percentage1")) { snprintf(val, sizeof(val), "%s%d%%", v >= 1 ? "+" : "", (int)round(100 * (v - 1))); if (!strcmp(val, "+0%")) snprintf(val, sizeof(val), "-"); } else if (!strcmp(t, "percentage")) { snprintf(val, sizeof(val), "%s%d%%", v >= 0 ? "+" : "", (int)round(100 * v)); if (!strcmp(val, "+0%")) snprintf(val, sizeof(val), "-"); } else if (!strcmp(t, "time")) snprintf(val, sizeof(val), "%d:%02d", (int)v / 60, (int)v % 60); else if (!strcmp(t, "text")) val[0] = 0, snprintf(SS.stats[i].nameText, sizeof(SS.stats[i].nameText), "%s", cJSON_IsString(m) && *m->valuestring ? m->valuestring : "--"); snprintf(SS.stats[i].valueText, sizeof(SS.stats[i].valueText), "%s", val); } if (!shown) snprintf(SS.stats[0].nameText, sizeof(SS.stats[0].nameText), "%s", unlocked ? "No modifiers" : "???"), SS.stats[0].nameTint = 0xffffff; cJSON_Delete(mods); } static Color SS_tint(unsigned t) { return rgb(t == 0x992200 ? 0xff8a6a : t, 1); } // Vita: il rosso della salute nemici leggibile sul viola static float StageStatsPanel_draw(float x, float y) { // Vita: due colonne, poi i suggerimenti se ci sono; restituisce l'altezza int k = 0; for (int i = 0; i < 14; i++) { if (!SS.stats[i].name || !strcmp(SS.stats[i].name, "tips")) continue; float sx = x + (k % 2) * 262, sy = y + (k / 2) * 24 + 10; k++; TS_frame("items", SS.stats[i].icon, sx, sy, 0, 0.5f, 1, 0, WHITE, 0); text_at(SS.stats[i].nameText, sx + 22, sy, fit_size(SS.stats[i].nameText, 20, 160), 0, 0.5f, SS_tint(SS.stats[i].nameTint)); text_at(SS.stats[i].valueText, sx + 248, sy, 20, 1, 0.5f, SS_tint(SS.stats[i].valueTint)); } float h = ((k + 1) / 2) * 24; for (int i = 0; i < 14; i++) { if (!SS.stats[i].name || strcmp(SS.stats[i].name, "tips") || !strcmp(SS.stats[i].nameText, "--")) continue; TS_frame("items", SS.stats[i].icon, x, y + h + 10, 0, 0.5f, 1, 0, WHITE, 0); h += ui_wrap_text(SS.stats[i].nameText, x + 22, y + h, 20, 486, 44, SS_tint(SS.stats[i].nameTint), 1) + 2; } return h; } static void StageRelicsPanel_draw(float x, float y, const char *id) { // Vita: una riga con le reliquie da trovare cJSON *s = SS_stage(id), *rel = cJSON_GetObjectItem(s, "relics"), *yel = cJSON_GetObjectItem(s, "yellowRelics"); if (!s || !cJSON_IsTrue(cJSON_GetObjectItem(s, "unlocked")) || !(cJSON_GetArraySize(rel) > 0 || cJSON_GetArraySize(yel) > 0)) return; const char *t = tr("stageSelection_relicsToFind"); float tw = MeasureTextEx(vs_font, t, 20, 0).x; text_at(t, x, y, 20, 0, 0.5f, (Color){ 0xcf, 0xc6, 0xb6, 255 }); float rx = x + tw + 18; cJSON *r; for (int pass = 0; pass < 2; pass++) { if (pass && !po_has("CollectedItems", "RELIC_YELLOW")) break; cJSON_ArrayForEach(r, (pass ? yel : rel)) { int got = cJSON_IsString(r) && po_has("CollectedItems", r->valuestring); cJSON *it = cJSON_IsString(r) ? cJSON_GetObjectItem(data_get("items"), r->valuestring) : NULL; if (it) TS_frame(str(it, "texture"), str(it, "frameName"), rx, y, 0.5f, 0.5f, 1.25f, 0, Fade(WHITE, got ? 0.5f : 1), 0); else TS_frame("items", "QuestionMark.png", rx, y, 0.5f, 0.5f, 1, 0, WHITE, 0); if (got) TS_frame("UI", "yes16.png", rx, y, 0.5f, 0.5f, 1.25f, 0, WHITE, 0); rx += 28; } } } // StageConfirmationPanel static void SS_toggleClick(void *ctx) { StageToggle *g = ctx; po_setb(g->po, !po_is(g->po)); Sound_PlaySimple(po_is(g->po) ? "ClickIn" : "ClickOut", 0); StageStatsPanel_AssignData(SS.Highlighted); // Hyper/Hurry/Mazzo/Inverse_BoxCallback (LimitBreak e Reapers: niente) } static void StageConfirmationPanel_AssignStage(const char *id) { cJSON *s = SS_stage(id); if (!s) { TraceLog(LOG_WARNING, "VS: %s not found", id); return; } int unlocked = cJSON_IsTrue(cJSON_GetObjectItem(s, "unlocked")), hyper = cJSON_IsTrue(cJSON_GetObjectItem(cJSON_GetObjectItem(s, "hyper"), "unlocked")); SS.cpTint = 0xffffff; SS.buttonVisible = unlocked; SS.myButton1.visible = unlocked; int vis[6] = { hyper, SS.hasWitchTear && unlocked, SS.hasRandomazzo && unlocked, SS.hasGreatGospel && unlocked, SS.hasInverse && unlocked, SS.hasReapers && unlocked }; for (int i = 0; i < 6; i++) SS.toggles[i].visible = vis[i], SS.toggles[i].box.visible = vis[i]; if (unlocked) { if (!hyper) po_setb("SelectedHyper", 0); int has[6] = { hyper, SS.hasWitchTear, SS.hasRandomazzo, SS.hasGreatGospel, SS.hasInverse, SS.hasReapers }; for (int i = 0; i < 6; i++) if (has[i]) UIButton_on(&SS.toggles[i].box, SS_toggleClick, &SS.toggles[i]); } } static int StageConfirmationPanel_hasAnyButton(void) { cJSON *st; cJSON_ArrayForEach(st, data_get("stages")) { cJSON *s = cJSON_GetArrayItem(st, 0); if (s && cJSON_IsTrue(cJSON_GetObjectItem(cJSON_GetObjectItem(s, "hyper"), "unlocked")) && cJSON_IsTrue(cJSON_GetObjectItem(s, "unlocked")) && !cJSON_IsTrue(cJSON_GetObjectItem(s, "hidden"))) return 1; } return SS.hasWitchTear || SS.hasRandomazzo || SS.hasGreatGospel || SS.hasInverse || SS.hasReapers || SS.hasRandomEvents; } // --- StageRandomPanel (0x11cb2): la casella degli eventi casuali di Trisection, a sinistra del pannello di conferma --- static void SS_rpClick(void *c) { (void)c; cJSON_ReplaceItemInObject(PlayerOptions, "SelectedRandomEvents", cJSON_CreateBool(!po_is("SelectedRandomEvents"))); Sound_PlaySimple(po_is("SelectedRandomEvents") ? "ClickIn" : "ClickOut", 0); } static void StageRandomPanel_AssignStage(const char *id) { cJSON *s = SS_stage(id); if (!SS.rpExists || !s) return; int unlocked = cJSON_IsTrue(cJSON_GetObjectItem(s, "unlocked")); SS.rpTint = 0xffffff; SS.rpVisible = SS.rpBox.visible = SS.hasRandomEvents && unlocked; // isTwitchOn: mai if (unlocked && SS.hasRandomEvents) UIButton_on(&SS.rpBox, SS_rpClick, NULL); } // --- StageMusicPanel (0x4275): brano e velocita' della musica, e "blocca la scelta" --- static void Music_AssignData(const char *t) { // t puo' essere po_str("SelectedBGM"): la chiave stabile e' quella di music.json static char unknown[64]; cJSON *m = t ? cJSON_GetObjectItem(data_get("music"), t) : NULL; if (m) SS.bgmType = m->string; else snprintf(unknown, sizeof(unknown), "%s", t ? t : ""), SS.bgmType = unknown; po_sets("SelectedBGM", SS.bgmType); SS.musicVisible = m != NULL; // brano sconosciuto: il pannello sparisce } static const char *const SpeedTypes[3]; static void Music_AssignSpeed(const char *s) { const char *k = "Normal"; for (int i = 0; i < 3; i++) if (s && !strcmp(s, SpeedTypes[i])) k = SpeedTypes[i]; if (s && !strcmp(k, "Normal") && strcmp(s, "Normal")) TraceLog(LOG_WARNING, "VS: velocita' della musica sconosciuta: %s", s); SS.selectedSpeed = k; po_sets("SelectedBGMMod", k); } static void Music_AssignStage(const char *id) { if (!SS.hasBanger || SS.changed || SS.charBGM) return; if (po_is("SelectedBGMSave")) { Music_AssignData(po_str("SelectedBGM")), Music_AssignSpeed(po_str("SelectedBGMMod")); return; } cJSON *s = SS_stage(id); const char *bgm = str(s, "BGM"); char b[64]; snprintf(b, sizeof(b), "%s_B", bgm ? bgm : ""); int bi = -1; for (int i = 0; i < SS.nBgm; i++) if (!strcmp(SS.bgmTypes[i], b)) bi = i; if (cJSON_GetObjectItem(data_get("music"), b) && po_is("SelectedInverse") && bi > 0) po_sets("SelectedBGM", cJSON_GetObjectItem(data_get("music"), b)->string); else if (bgm) po_sets("SelectedBGM", bgm); Music_AssignData(po_str("SelectedBGM")); if (str(s, "BGMMOD")) Music_AssignSpeed(str(s, "BGMMOD")); else Music_AssignSpeed(po_is("SelectedHyper") ? "Hyper" : "Normal"); } static int Music_index(void) { for (int i = 0; i < SS.nBgm; i++) if (!strcmp(SS.bgmTypes[i], SS.bgmType)) return i; return -1; } static const char *const SpeedTypes[3] = { "Normal", "Hyper", "Forsaken" }; // MusicMod (0xe648) static int Speed_index(void) { for (int i = 0; i < 3; i++) if (SS.selectedSpeed && !strcmp(SpeedTypes[i], SS.selectedSpeed)) return i; return -1; } static void Music_L(void *c) { (void)c; int i = Music_index() - 1; if (i < 0) i = SS.nBgm - 1; if (SS.nBgm) Music_AssignData(SS.bgmTypes[i % SS.nBgm]); SS.changed = 1, Sound_SetupAndPlayBGM_Banger(1); } static void Music_R(void *c) { (void)c; if (SS.nBgm) Music_AssignData(SS.bgmTypes[(Music_index() + 1) % SS.nBgm]); SS.changed = 1, Sound_SetupAndPlayBGM_Banger(1); } static void Speed_L(void *c) { (void)c; int i = Speed_index() - 1; if (i < 0) i = 2; Music_AssignSpeed(SpeedTypes[i % 3]); SS.changed = 1, Sound_SetupAndPlayBGM_Banger(1); } static void Speed_R(void *c) { (void)c; Music_AssignSpeed(SpeedTypes[(Speed_index() + 1) % 3]); SS.changed = 1, Sound_SetupAndPlayBGM_Banger(1); } static void Music_lock(void *c) { (void)c; cJSON_ReplaceItemInObject(PlayerOptions, "SelectedBGMSave", cJSON_CreateBool(!po_is("SelectedBGMSave"))); Sound_PlaySimple(po_is("SelectedBGMSave") ? "ClickIn" : "ClickOut", 0); } static void StageMusicPanel_create(void) { float w = 0xc8, h = 0x112; SS.nBgm = 0; cJSON *m; cJSON_ArrayForEach(m, data_get("music")) { // i brani sbloccati da stage, personaggi, oggetti o armi const char *bs = str(m, "unlockedByStage"), *bc = str(m, "unlockedByCharacter"), *bi = str(m, "unlockedByItem"), *bw = str(m, "unlockedByWeapon"); if (bs ? po_has("UnlockedStages", bs) : bc ? po_has("UnlockedCharacters", bc) : bi ? po_has("CollectedItems", bi) : bw ? po_has("CollectedWeapons", bw) : 0) obj_set(m, "isUnlocked", cJSON_CreateTrue()); if (cJSON_IsTrue(cJSON_GetObjectItem(m, "isUnlocked")) && SS.nBgm < 64) SS.bgmTypes[SS.nBgm++] = m->string; } (void)w, (void)h; SS.mpX = 406, SS.mpY = 72; // Vita: finestra larga 524 sopra la scheda dello stage UIButton_set(&SS.arrowButtonL, "", SS.mpX + 50, SS.mpY + 150, 0x10, 0x10, 3, 0.5f, 0.5f); UIButton_set(&SS.arrowButtonR, "", SS.mpX + 474, SS.mpY + 150, 0x10, 0x10, 3, 0.5f, 0.5f); UIButton_set(&SS.speedSelectionL, "", SS.mpX + 50, SS.mpY + 230, 0x10, 0x10, 3, 0.5f, 0.5f); UIButton_set(&SS.speedSelectionR, "", SS.mpX + 474, SS.mpY + 230, 0x10, 0x10, 3, 0.5f, 0.5f); UIButton_set(&SS.lockSelected_Box, "", SS.mpX + 150, SS.mpY + 320, 0x18, 0x18, 1.5f, 0, 0.5f); SS.charBGM = str(tbl0("characters", po_str("SelectedCharacter")), "bgm"); if (po_is("SelectedBGMSave")) Music_AssignData(po_str("SelectedBGM")), Music_AssignSpeed(po_str("SelectedBGMMod")); else Music_AssignData("BGM_Forest"), Music_AssignSpeed("Normal"); SS.changed = 0; } static void StageMusicPanel_EnableInput(void) { // a fine Open (150 ms) UIButton_on(&SS.lockSelected_Box, Music_lock, NULL); UIButton_on(&SS.arrowButtonL, Music_L, NULL), UIButton_on(&SS.arrowButtonR, Music_R, NULL); UIButton_on(&SS.speedSelectionL, Speed_L, NULL), UIButton_on(&SS.speedSelectionR, Speed_R, NULL); SS.musicInput = 1; } static int SS_isMusicArrow(UIButton *b) { return SS.hasBanger && (b == &SS.arrowButtonL || b == &SS.arrowButtonR || b == &SS.speedSelectionL || b == &SS.speedSelectionR); } static void StageMusicPanel_draw(void) { // Vita: finestra sopra la scheda, su triangolo if (!SS.hasBanger || !SS.musicVisible || !SS.musicOpen) return; float w = 524, h = 408; rlPushMatrix(); rlTranslatef(SS.mpX, SS.mpY, 0); nine("frame5_c4.png", 12, (Rectangle){ 0, 0, w, h }, WHITE); text_at(tr("stageSelection_musicSelection"), 0.5f * w, 24, 30, 0.5f, 0.5f, rgb(VUI_GOLD, 1)); cJSON *m = cJSON_GetObjectItem(data_get("music"), SS.bgmType); char title[160]; snprintf(title, sizeof(title), "\"%s\"", str(m, "title") ? str(m, "title") : ""); text_at(title, 0.5f * w, 72, fit_size(title, 24, w - 40), 0.5f, 0.5f, WHITE); if (str(m, "icon")) TS_frame("UI", str(m, "icon"), 0.5f * w, 150, 0.5f, 0.5f, 3, 0, WHITE, 0); const Frame *af = frame_get("UI", "arrow_01.png"); float AX[2] = { 50, 474 }, AY[2] = { 150, 230 }; for (int r = 0; r < 2; r++) for (int k = 0; k < 2 && af; k++) { Sprite a; sprite_init(&a, af, AX[k], AY[r]); sprite_setScale(&a, 3), a.flipX = k == 0, a.scrollFactor0 = 1; scene_render_one(&a, (Shader){ 0 }); } const char *sp = tr(TextFormat("musicMod_%s", SS.selectedSpeed && !strcmp(SS.selectedSpeed, "Hyper") ? "hyper" : SS.selectedSpeed && !strcmp(SS.selectedSpeed, "Forsaken") ? "forsaken" : "normal")); text_at(sp, 0.5f * w, 230, 26, 0.5f, 0.5f, WHITE); TS_frame("UI", "menu_checkbox_24_bg.png", 150, 320, 0, 0.5f, 1.5f, 0, WHITE, 0); if (po_is("SelectedBGMSave")) TS_frame("UI", "yes16.png", 158, 320, 0, 0.5f, 1.5f, 0, WHITE, 0); text_at(tr("stageConfirm_lockSelected"), 196, 320, fit_size(tr("stageConfirm_lockSelected"), 22, 300), 0, 0.5f, WHITE); rlPopMatrix(); if (SS.musicHL) vui_focus((Rectangle){ UI_left(SS.musicHL), UI_top(SS.musicHL), bW(SS.musicHL), bH(SS.musicHL) }, SS.t); } static void StageSelectionScene_Stage6Checks(void) { cJSON *m = SS_stage("MACHINE"); if (!m || !po_has("Achievements", "ObtainAllRelics")) return; int trumpet = po_has("CollectedItems", "RELIC_TRUMPET"), mirror = po_has("CollectedItems", "RELIC_MIRROR"); obj_set(m, "order", cJSON_CreateNumber(po_is("HasSeenFinalFireworks") ? 0x3e8 : 0)); if (!trumpet && !mirror) obj_set(m, "hidden", cJSON_CreateFalse()); if (trumpet && !po_is("HasUsedTrumpet")) return; if (mirror && !po_is("HasUsedMirror")) return; obj_set(m, "hidden", cJSON_CreateFalse()); } static void SS_OnConfirmClicked(void *ctx) { (void)ctx; if (!cJSON_IsTrue(cJSON_GetObjectItem(SS_stage(SS.Highlighted), "unlocked"))) { Sound_PlaySimple("ClickOut", 0); return; } if (!SS.isReadyToStart) { po_sets("SelectedStage", SS.Highlighted); SS_OnSelectionChange(); SS.cpTint = 0xffff00, SS.rpTint = 0xffff00; // TurnToStart SS.isReadyToStart = 1; Sound_PlaySound("ClickIn", 0, 1, 0xe1, 0, 0); UIGrid_SelectAt(SS.gridLast, SS.gridBottom); OV.UI_selected = &SS.myButton1; } else { Overlay_DestroyGrid(); SceneManager_StartFromStageSelection(); Sound_PlaySound("ClickIn", 0, 1, 0xfa, 0, 0); SS.isStartingGameMode = 1; } } static void SS_ToggleButtonsAvailability(void) { cJSON *s = SS_stage(SS.Highlighted); int unlocked = cJSON_IsTrue(cJSON_GetObjectItem(s, "unlocked")), hyper = cJSON_IsTrue(cJSON_GetObjectItem(cJSON_GetObjectItem(s, "hyper"), "unlocked")); int c = 0; if (SS.rpExists && SS.hasRandomEvents) UIGrid_SetContents(c++, SS.gridBottom, NULL, 0); for (int i = 0; i < 5; i++) UIGrid_SetContents(c++, SS.gridBottom, NULL, 0); if (SS.hasBanger) UIGrid_SetContents(c++, SS.gridBottom, NULL, 0), UIGrid_SetContents(c, SS.gridBottom, NULL, 0); if (!unlocked) return; UIButton *row[9]; int n = 0; if (SS.rpExists && SS.hasRandomEvents) row[n++] = &SS.rpBox; if (hyper) row[n++] = &SS.toggles[0].box; if (SS.hasWitchTear) row[n++] = &SS.toggles[1].box; if (SS.hasRandomazzo) row[n++] = &SS.toggles[2].box; if (SS.hasGreatGospel) row[n++] = &SS.toggles[3].box; if (SS.hasInverse) row[n++] = &SS.toggles[4].box; if (SS.hasReapers) row[n++] = &SS.toggles[5].box; row[n++] = &SS.myButton1; for (int i = 0; i < n; i++) UIGrid_SetContents(i, SS.gridBottom, row[i], 0); SS.gridLast = n - 1, SS.previousToggle = row[0]; } #define SS_ROW 84 static void SS_correctScrollableContainerPosition(void) { // Vita: la riga scelta sempre dentro la lista StagePanel *p = SS.HighlightedPanel; if (!p) return; if (p->y - SS.scY < 66) SS.scY = p->y - 70; if (p->y + 76 - SS.scY > 486) SS.scY = p->y + 76 - 482; SS.scY = fminf(fmaxf(SS.scY, 0), SS.scMaxY); } static void SS_OnSelectionChange(void) { StagePanel *p = NULL; for (int i = 0; i < SS.n; i++) { SS.panels[i].highlight = 0; if (!strcmp(SS.panels[i].power, SS.Highlighted)) p = &SS.panels[i]; } if (p) SS.hlX = p->x + 0xe, SS.hlY = p->y + 0xe, p->highlight = 1; SS.HighlightedPanel = p; if (UIGrid.on && p) UIGrid_SelectGameObject(&p->hit); OV.UI_selected = p ? &p->hit : NULL; if (UIGrid.on) SS_ToggleButtonsAvailability(); SS.isReadyToStart = 0; StageConfirmationPanel_AssignStage(SS.Highlighted); StageRandomPanel_AssignStage(SS.Highlighted); StageStatsPanel_AssignData(SS.Highlighted); Music_AssignStage(SS.Highlighted); } static void SS_OnPanelClicked(const char *id) { if (SS.isStartingGameMode) return; SS.Highlighted = id; StageConfirmationPanel_AssignStage(id); StageRandomPanel_AssignStage(id); StageStatsPanel_AssignData(id); Music_AssignStage(id); SS.isReadyToStart = 0; SS_OnSelectionChange(); } static float SS_wx(float x) { return x; } static float SS_wy(float y) { return y - SS.scY; } static void SS_onMusicKey(void) { if (!SS.hasBanger || !SS.musicVisible) return; SS.musicOpen = !SS.musicOpen; Sound_PlaySimple("ClickIn", 0); UIButton *b = SS.musicOpen ? &SS.arrowButtonL : SS.HighlightedPanel ? &SS.HighlightedPanel->hit : &SS.myButton1; OV.UI_selected = b; if (UIGrid.on) UIGrid_SelectGameObject(b); } static void SS_layoutChips(void) { // Vita: le opzioni della partita come interruttori, 4 per riga UIButton *row[7]; int n = 0; if (SS.rpExists && SS.rpVisible) row[n++] = &SS.rpBox; for (int i = 0; i < 6; i++) if (SS.toggles[i].visible) row[n++] = &SS.toggles[i].box; float y0 = n > 4 ? 362 : 400; for (int i = 0; i < n; i++) row[i]->x = 414 + i % 4 * 127, row[i]->y = y0 + i / 4 * 38, row[i]->w = 122, row[i]->h = 34, row[i]->sc = 1, row[i]->ox = row[i]->oy = 0; } static void SS_MakeUIGrid_ScrollView(void) { int h = SS.n + 4, w = 5 + (SS.hasBanger ? 2 : 0) + (SS.rpExists ? 2 : 0); Overlay_MakeUIGrid(w, h, 0); for (int i = 0; i < SS.n; i++) UIGrid_SetContents(0, 2 + i, &SS.panels[i].hit, 0), UIGrid_SetContents(1, 2 + i, &SS.hidden1, 0); SS.gridBottom = h - 1; for (int i = 0; i < w; i++) UIGrid_SetContents(i, 0, &TB.BackButton, 0), UIGrid_SetContents(i, 1, &SS.hidden2, 0), UIGrid_SetContents(i, SS.gridBottom - 1, &SS.hidden2, 0); int c = 0; if (SS.rpExists && SS.hasRandomEvents) UIGrid_SetContents(c++, SS.gridBottom, &SS.rpBox, 0); // (hasRandomLevels: mai) UIGrid_SetContents(c++, SS.gridBottom, &SS.toggles[0].box, 0); UIGrid_SetContents(c++, SS.gridBottom, &SS.toggles[1].box, 0); UIGrid_SetContents(c++, SS.gridBottom, &SS.toggles[2].box, 0); UIGrid_SetContents(c++, SS.gridBottom, &SS.toggles[3].box, 0); if (SS.hasInverse) UIGrid_SetContents(c++, SS.gridBottom, &SS.toggles[4].box, 0); if (SS.hasReapers) UIGrid_SetContents(c++, SS.gridBottom, &SS.toggles[5].box, 0); UIGrid_SetContents(c, SS.gridBottom, &SS.myButton1, 0); if (SS.hasBanger) { UIButton *R[2][4] = { { &SS.arrowButtonL, &SS.speedSelectionL, &SS.lockSelected_Box, &SS.hidden2 }, { &SS.arrowButtonR, &SS.speedSelectionR, &SS.lockSelected_Box, &SS.hidden2 } }; for (int k = 0; k < 2; k++) for (int r = 0; r < 4; r++) UIGrid_SetContents(2 + k, 2 + r, R[k][r], 0); } SS.gridLast = c; Overlay_ToggleCursorsVisibility(0); SS.previousLevel = SS.n ? &SS.panels[0].hit : NULL; OV.OnCancelCallback = CS_cancel; // BackButton._events.pointerdown.fn() } static int cmp_order(const void *a, const void *b) { return ((const StagePanel *)a)->order - ((const StagePanel *)b)->order; } static void StageSelectionScene_create(void) { SS_spamOn = tflag == 3, SS_spam.index = 0; for (int i = 0; i < 14; i++) cJSON_Delete(SS.stats[i].def); memset(&SS, 0, sizeof(SS)); SS.active = 1; SS.scrollbarOffset = 0xbe, SS.scrollbarInitialHeight = 0x348, SS.scrollTopY = 0x40; // preload: SelectedBGM senza musica -> BGM_Forest_B; MACHINE nascosto; Stage6Checks if (!po_str("SelectedBGM") || !cJSON_GetObjectItem(data_get("music"), po_str("SelectedBGM"))) po_sets("SelectedBGM", "BGM_Forest_B"); if (SS_stage("MACHINE")) obj_set(SS_stage("MACHINE"), "hidden", cJSON_CreateTrue()); StageSelectionScene_Stage6Checks(); SS.hasGoldenEggs = po_has("CollectedItems", "RELIC_GOLDENEGG"); SS.hasBanger = po_has("CollectedItems", "RELIC_BANGER"); SS.hasRandomOptions = po_has("CollectedItems", "RELIC_TRISECTION"); static int stageOnce; if (getenv("VS_STAGE") && !stageOnce++) po_sets("SelectedStage", getenv("VS_STAGE")); // sviluppo; una volta sola: il primo sigillo cambia stage SS.Highlighted = po_str("SelectedStage"); if (!SS_stage(SS.Highlighted)) TraceLog(LOG_INFO, "VS: %s not found, defaulting to Forest", SS.Highlighted), SS.Highlighted = "FOREST"; UIButton_set(&SS.bg, "MenuBackground", 20, 62, 360, 428, 1, 0, 0); // Vita: lista a sinistra, scheda a destra // StageConfirmationPanel SS.hasWitchTear = po_has("CollectedItems", "RELIC_TEAR"), SS.hasRandomazzo = po_has("CollectedItems", "RELIC_RANDOMAZZO"); SS.hasGreatGospel = po_has("CollectedItems", "RELIC_GGOSPEL"), SS.hasInverse = po_has("CollectedItems", "RELIC_MIRROR"); SS.hasReapers = po_has("CollectedItems", "RELIC_TRUMPET"), SS.hasRandomEvents = po_has("CollectedItems", "RELIC_TRISECTION"); SS.cpW = 0.24f * SAFE_WIDTH * 4; SS.hasAnyButton = StageConfirmationPanel_hasAnyButton(); if (!SS.hasAnyButton) SS.scrollbarOffset = 0x50, SS.scrollbarInitialHeight = 0x44c; if (SS.hasRandomOptions) { // randomizationPanel: 200 x 104 in (0x2c, y del pannello di conferma) SS.rpExists = 1; const Frame *rb = frame_get("UI", "menu_checkbox_24_bg.png"); UIButton_set(&SS.rpBox, "", 0, 0, rb ? rb->sw : 24, rb ? rb->sh : 24, 2, 0, 0.5f); } if (SS.hasBanger) { StageMusicPanel_create(); if (!po_is("SelectedBGMSave")) { // senza "blocca": la musica del personaggio, o quella dello stage scelto const char *cb = str(tbl0("characters", po_str("SelectedCharacter")), "bgm"); if (cb) po_sets("SelectedBGM", cb); else if (str(SS_stage(po_str("SelectedStage")), "BGM")) po_sets("SelectedBGM", str(SS_stage(po_str("SelectedStage")), "BGM")); } Music_AssignData(po_str("SelectedBGM")); } static const char *const TK[6] = { "stageConfirm_hyper", "stageConfirm_hurry", "stageConfirm_mazzo", "stageConfirm_limitbreak", "stageConfirm_inverse", "stageConfirm_reapers" }; static const char *const TP[6] = { "SelectedHyper", "SelectedHurry", "SelectedMazzo", "SelectedLimitBreak", "SelectedInverse", "SelectedReapers" }; const Frame *cb = frame_get("UI", "menu_checkbox_24_bg.png"); for (int i = 0; i < 6; i++) { StageToggle *g = &SS.toggles[i]; g->label = TK[i], g->po = TP[i], g->x = 0x10 + 0x50 * i; UIButton_set(&g->box, "", 0, 0, cb ? cb->sw : 24, cb ? cb->sh : 24, 2, 0, 0.5f); } UIButton_set(&SS.myButton1, "GreenButton", 414, 444, 508, 42, 1, 0, 0); UIButton_on(&SS.myButton1, SS_OnConfirmClicked, NULL); // pannelli: STAGEX solo se sbloccato, senza il Segno Giallo e con un personaggio valido; gli altri se non nascosti cJSON *st; cJSON_ArrayForEach(st, data_get("stages")) { cJSON *s0 = cJSON_GetArrayItem(st, 0); if (!strcmp(st->string, "STAGEX")) { if (po_has("CollectedItems", "RELIC_YELLOW") || !cJSON_IsTrue(cJSON_GetObjectItem(s0, "unlocked")) || !GetValidCharacter(po_str("SelectedCharacter"))) { if (!strcmp(po_str("SelectedStage"), "STAGEX")) po_sets("SelectedStage", "FOREST"), SS.Highlighted = po_str("SelectedStage"); continue; } } else if (cJSON_IsTrue(cJSON_GetObjectItem(s0, "hidden"))) continue; if (SS.n >= SS_MAX) break; StagePanel *p = &SS.panels[SS.n++]; p->power = st->string, p->order = (int)num(s0, "order", 0); UIButton_set(&p->hit, "", 0, 0, 344, 76, 1, 0, 0); UIButton_on(&p->hit, SS_OnConfirmClicked, NULL); } qsort(SS.panels, SS.n, sizeof(*SS.panels), cmp_order); // sort per order (stabile come quello di V8 per pochi elementi: qui qsort) for (int i = 0; i < SS.n; i++) SS.panels[i].x = 28, SS.panels[i].y = 70 + SS_ROW * i; SS.cpX = 396, SS.cpY = 62, SS.y0 = 0; for (int i = 0; i < 14; i++) { SS.stats[i].name = SS_LIST[i].name, SS.stats[i].display = SS_LIST[i].display, SS.stats[i].type = SS_LIST[i].type; SS.stats[i].icon = SS_LIST[i].icon, SS.stats[i].tint = SS_LIST[i].tint; SS.stats[i].def = SS_LIST[i].def ? cJSON_Parse(SS_LIST[i].def) : NULL; } UIButton_set(&SS.hidden1, "", -0x3e8, -0x3e8, 1, 1, 1, 0, 0), SS.hidden1.visible = 0; UIButton_set(&SS.hidden2, "", -0x3e8, -0x3e8, 1, 1, 1, 0, 0), SS.hidden2.visible = 0; SS.scY = 0, SS.scMinY = 0, SS.scMaxY = fmaxf(0, SS.n * SS_ROW - 4 - 420); SS_MakeUIGrid_ScrollView(); TB_title = tr("stageSelection_header"); VPrompt P[] = { { G_TRIANGLE, "stageSelection_musicSelection" }, { G_CROSS, "vui_start" }, { G_CIRCLE, "vui_back" } }; if (SS.hasBanger) OV.OnTriangle = SS_onMusicKey, vui_set_prompts(P, 3); else vui_set_prompts(P + 1, 2); StageConfirmationPanel_AssignStage(SS.Highlighted); StageRandomPanel_AssignStage(SS.Highlighted); SS.isReadyToStart = 0; SS_OnSelectionChange(); } static void SS_Select(UIButton *b) { OV.UI_selected = b; if (UIGrid.on && b) UIGrid_SelectGameObject(b); } static void StageSelectionScene_update(float delta) { SS.t += delta; for (int i = 0; i < SS.n; i++) SS.panels[i].hit.x = SS_wx(SS.panels[i].x), SS.panels[i].hit.y = SS_wy(SS.panels[i].y); SS_layoutChips(); if (SS.hasBanger && !SS.musicInput && SS.t >= 0x96) StageMusicPanel_EnableInput(); if (SS.isStartingGameMode) return; // HandleInput: rotella, trascinamento, tocco su un pannello Rectangle bounds = { 20, 62, 360, 428 }; Vector2 m = menu_pointer(); if (GetMouseWheelMove()) SS.scY = fminf(fmaxf(SS.scY - 40 * GetMouseWheelMove(), 0), SS.scMaxY); if (ptr_pressed()) { SS.downOnSc = CheckCollisionPointRec(m, bounds), SS.downAt = m, SS.dragOff = SS.scY + m.y; if (SS.musicOpen) { UIButton *M[5] = { &SS.arrowButtonL, &SS.arrowButtonR, &SS.speedSelectionL, &SS.speedSelectionR, &SS.lockSelected_Box }; for (int i = 0; i < 5; i++) if (UIButton_clicked(M[i])) break; } else { UIButton_clicked(&SS.myButton1); for (int i = 0; i < 6; i++) UIButton_clicked(&SS.toggles[i].box); if (SS.rpBox.visible) UIButton_clicked(&SS.rpBox); } if (0) { UIButton *M[5] = { &SS.arrowButtonL, &SS.arrowButtonR, &SS.speedSelectionL, &SS.speedSelectionR, &SS.lockSelected_Box }; for (int i = 0; i < 5; i++) if (UIButton_clicked(M[i])) break; } } else if (ptr_down() && SS.downOnSc) { SS.scY = fminf(fmaxf(SS.dragOff - m.y, 0), SS.scMaxY); } else if (ptr_released() && SS.downOnSc) { SS.downOnSc = 0; if (CheckCollisionPointRec(m, bounds) && fabsf(SS.downAt.x - m.x) < 8 && fabsf(SS.downAt.y - m.y) < 8) for (int i = 0; i < SS.n; i++) if (CheckCollisionPointRec(m, (Rectangle){ SS.panels[i].hit.x, SS.panels[i].hit.y, 344, 76 })) { if (!strcmp(SS.panels[i].power, SS.Highlighted)) SS_OnConfirmClicked(NULL); // Vita: secondo tocco sullo stesso = conferma else SS_OnPanelClicked(SS.panels[i].power); break; } } UIButton *sel = OV.UI_selected, *prev = UIGrid.previousGameObject, *p0 = SS.n ? &SS.panels[0].hit : NULL; if (sel != prev) { if (sel == &SS.hidden1) { if (prev == &TB.BackButton) SS_Select(p0); else if (SS_panelOf(prev)) { SS.previousLevel = prev; if (SS.hasBanger && SS.musicOpen) SS_Select(&SS.arrowButtonL); else if (SS.myButton1.visible) SS_Select(&SS.myButton1); else SS_Select(prev); } else SS_Select(SS.previousLevel); } else if (sel == &SS.hidden2) { if (SS.hasBanger && prev == &SS.lockSelected_Box) SS_Select(SS.myButton1.visible ? &SS.myButton1 : &SS.lockSelected_Box); else if (SS.hasBanger && (prev == &SS.arrowButtonL || prev == &SS.arrowButtonR)) SS_Select(&TB.BackButton); else if (SS.hasBanger && prev == &SS.myButton1) SS_Select(&SS.lockSelected_Box); else if (prev == &TB.BackButton) SS_Select(p0); else if (SS_panelOf(prev)) { SS.previousLevel = prev; if (prev == p0) SS_Select(&TB.BackButton); else if (SS.previousToggle && SS.previousToggle->visible) SS_Select(SS.previousToggle); else SS_Select(prev); } else SS_Select(SS.previousLevel); } StagePanel *p = SS_panelOf(OV.UI_selected); if (p) { SS.Highlighted = p->power; SS_OnSelectionChange(); StageConfirmationPanel_AssignStage(SS.Highlighted); StageRandomPanel_AssignStage(SS.Highlighted); Overlay_ToggleCursorsVisibility(0); SS.hlVisible = 1; SS_correctScrollableContainerPosition(); SS.musicHL = NULL; } else if (SS_isMusicArrow(OV.UI_selected)) { Overlay_ToggleCursorsVisibility(0); SS.musicHL = OV.UI_selected; } else { Overlay_ToggleCursorsVisibility(1); SS.hlVisible = 0; SS.musicHL = NULL; } if (UIGrid.on) UIGrid.previousGameObject = OV.UI_selected; } for (int i = 0; i < SS.n; i++) SS.panels[i].hit.x = SS_wx(SS.panels[i].x), SS.panels[i].hit.y = SS_wy(SS.panels[i].y); } static void StageSelectionPanel_draw(StagePanel *p) { // Vita: riga con miniatura e nome cJSON *s = SS_stage(p->power); if (!s) return; int unlocked = cJSON_IsTrue(cJSON_GetObjectItem(s, "unlocked")); float x = SS_wx(p->x), y = SS_wy(p->y); DrawRectangleRounded((Rectangle){ x, y, 344, 76 }, 0.12f, 6, p->highlight ? (Color){ 0x4a, 0x47, 0x78, 255 } : (Color){ 0x2f, 0x2c, 0x50, 255 }); TS_frame(str(s, "uiTexture"), str(s, "uiFrame"), x + 5, y + 4, 0, 0, 0.71f, 0, WHITE, 0); // SpecialAnimationForStageX / ForMoongolow: con i finali (F3.6) const char *name = unlocked ? stage_text(p->power, "stageName") : tr("stageSelectionPanel_?"); ui_wrap_text(name, x + 124, y + 10, fit_size(name, 24, 420), 210, 56, p->highlight ? rgb(VUI_GOLD, 1) : WHITE, 1); if (unlocked && str(s, "stageNumber")) { BMFont_load(&FontTitle, "titleFont-export"); BMFont_draw(&FontTitle, str(s, "stageNumber"), x + 5 + 108, y + 4 + 68, 1, 1, 0.7f, 1, WHITE); } cJSON *rel = cJSON_GetObjectItem(s, "relics"), *yel = cJSON_GetObjectItem(s, "yellowRelics"), *r; // punto esclamativo: reliquie ancora da trovare int missing = 0; if (unlocked && (rel || yel)) { cJSON_ArrayForEach(r, rel) if (cJSON_IsString(r) && !po_has("CollectedItems", r->valuestring)) { missing = 1; break; } if (po_has("CollectedItems", "RELIC_YELLOW")) cJSON_ArrayForEach(r, yel) if (cJSON_IsString(r) && !po_has("CollectedItems", r->valuestring)) { missing = 1; break; } } if (missing) { TS_frame("vfx", "PrizeBG.png", x + 326, y + 20, 0.5f, 0.5f, 1, 0, WHITE, 0); TS_frame("UI", "ExclamationMark.png", x + 326, y + 20, 0.5f, 0.5f, 0.5f, 0, WHITE, 0); } } static void SS_chip(UIButton *b, const char *label, int on) { if (!b->visible) return; Rectangle r = { b->x, b->y, b->w, b->h }; DrawRectangleRounded(r, 0.2f, 6, (Color){ 0x1b, 0x18, 0x30, 255 }); DrawRectangleRoundedLinesEx(r, 0.2f, 6, 2, on ? rgb(0xb88a34, 1) : (Color){ 0x4a, 0x45, 0x70, 255 }); TS_frame("UI", "menu_checkbox_24_bg.png", r.x + 6, r.y + 17, 0, 0.5f, 1, 0, WHITE, 0); if (on) TS_frame("UI", "yes16.png", r.x + 10, r.y + 17, 0, 0.5f, 1, 0, WHITE, 0); text_at(label, r.x + 36, r.y + 17, fit_size(label, 20, b->w - 42), 0, 0.5f, WHITE); } static void StageConfirmationPanel_draw(void) { // Vita: la scheda dello stage a destra float x = SS.cpX, y = SS.cpY; nine("frame5_c4.png", 12, (Rectangle){ x, y, 544, 428 }, rgb(SS.cpTint, 1)); cJSON *s = SS_stage(SS.Highlighted); int unlocked = cJSON_IsTrue(cJSON_GetObjectItem(s, "unlocked")); TS_frame(str(s, "uiTexture"), str(s, "uiFrame"), x + 18, y + 16, 0, 0, 0.75f, 0, WHITE, 0); const char *name = unlocked ? stage_text(SS.Highlighted, "stageName") : tr("stageSelectionPanel_?"); text_at(name, x + 148, y + 40, fit_size(name, 32, 376), 0, 0.5f, rgb(VUI_GOLD, 1)); // a flusso: descrizione a tutta larghezza, statistiche, reliquie; le opzioni e Inizia stanno in fondo int nchips = (SS.rpExists && SS.rpVisible); for (int i = 0; i < 6; i++) nchips += SS.toggles[i].visible; float bottom = nchips ? (nchips > 4 ? 362 : 400) : 440, cy = y + 16 + 72 + 8; cy += ui_wrap_text(unlocked ? stage_text(SS.Highlighted, "description") : tr("stageSelectionPanel_hidden"), x + 18, cy, 20, 508, 92, WHITE, 1) + 6; cy += StageStatsPanel_draw(x + 18, cy) + 4; if (cy + 12 < bottom) StageRelicsPanel_draw(x + 18, cy + 12, SS.Highlighted); if (SS.rpExists) SS_chip(&SS.rpBox, tr("stageConfirm_randomEvents"), po_is("SelectedRandomEvents")); for (int i = 0; i < 6; i++) if (SS.toggles[i].visible) SS_chip(&SS.toggles[i].box, tr(SS.toggles[i].label), po_is(SS.toggles[i].po)); if (SS.myButton1.visible) { UIButton_draw(&SS.myButton1, 1); if (SS.cpTint != 0xffffff) DrawRectangleRoundedLinesEx((Rectangle){ SS.myButton1.x, SS.myButton1.y, SS.myButton1.w, SS.myButton1.h }, 0.3f, 6, 3, rgb(VUI_GOLD, 1)); text_at(tr("stageConfirm_start"), SS.myButton1.x + 0.5f * SS.myButton1.w, SS.myButton1.y + 0.5f * SS.myButton1.h, 30, 0.5f, 0.5f, WHITE); } } static void StageSelectionScene_draw(void) { UIButton_draw(&SS.bg, 1); menu_clip(24, 66, 352, 420); for (int i = 0; i < SS.n; i++) { float y = SS_wy(SS.panels[i].y); if (y > -80 && y < MENU_H) StageSelectionPanel_draw(&SS.panels[i]); } menu_unclip(); StagePanel *hp = SS_panelOf(OV.UI_selected); if (hp) vui_focus((Rectangle){ hp->hit.x, hp->hit.y, 344, 76 }, SS.t); if (SS.scMaxY > 0) { float h = 420 * 420 / (420 + SS.scMaxY); DrawRectangleRounded((Rectangle){ 374, 66 + (420 - h) * SS.scY / SS.scMaxY, 5, h }, 1, 4, rgb(VUI_GOLD, 0.7f)); } StageConfirmationPanel_draw(); StageMusicPanel_draw(); } // ============================================================================ // 0x94c5: PowerUpScene (il negozio dei potenziamenti) + 0xb026 PowerUpSelectionPanel + 0xdff7 PowerUpConfirmationPanel // ============================================================================ #define PU_MAX 32 typedef struct { const char *power; float x, y; UIButton hit; } PowerPanel; static struct { int active, n, Columns, Rows; const char *Highlighted; PowerPanel panels[PU_MAX], *HighlightedPanel; float scY, scMaxY, scMinY, scH, y0, scrollTopY, scrollHeight, hlX, hlY, cpX, cpY, refundY; int hlVisible, downOnSc; Vector2 downAt; float dragOff; UIButton bg, ScrollBar, Button, RefundButton, activeBox; } PU; static void SceneManager_BackFromPowerUpSelectionScene(void); static PowerPanel *PU_panelOf(UIButton *b) { return b && b >= &PU.panels[0].hit && b <= &PU.panels[PU_MAX - 1].hit ? (PowerPanel *)((char *)b - offsetof(PowerPanel, hit)) : NULL; } static float Core_PowerUpMarkup(void) { // get PowerUpMarkup: floor(20 * 1.1^ranghi comprati), 0 senza ranghi double n = 0; cJSON *p; cJSON_ArrayForEach(p, data_get("powerups")) n += num(cJSON_GetArrayItem(p, 0), "level", 0); return n == 0 ? 0 : floorf(0x14 * powf(1.1f, (float)n)); } static cJSON *PU_data(const char **power) { // powerups[power][0], se no MIGHT cJSON *d = tbl0("powerups", *power); if (!d) *power = "POWER", d = tbl0("powerups", "POWER"); return d; } static float PU_price(const char *power) { cJSON *d = tbl0("powerups", power); return (1 + num(d, "level", 0)) * num(d, "price", 0) + Core_PowerUpMarkup(); } static int PU_isMaxedOnly(const char *p) { return !strcmp(p, "SKIP") || !strcmp(p, "BANISH") || !strcmp(p, "REROLL") || !strcmp(p, "SEAL") || !strcmp(p, "SEAL2"); } static void Core_OnPowerUpActivated(const char *p) { int i = arr_indexOf(po("DisabledPowerups"), p); if (i != -1) cJSON_DeleteItemFromArray(po("DisabledPowerups"), i); } static void Core_OnPowerUpDisabled(const char *p) { if (!po_has("DisabledPowerups", p)) po_push("DisabledPowerups", p); } static void PowerUpConfirmationPanel_toggleActivePowerUp(void) { if (!PU.activeBox.visible) return; const char *p = PU.Highlighted; cJSON *d = PU_data(&p); int act = !cJSON_IsTrue(cJSON_GetObjectItem(d, "active")); obj_set(d, "active", cJSON_CreateBool(act)); if (act) Core_OnPowerUpActivated(p); else Core_OnPowerUpDisabled(p); Sound_PlaySimple("ClickIn", 0); } static void PowerUpConfirmationPanel_AssignData(const char *power) { // la visibilita' di bottone e casella: il resto si calcola al disegno PU.Highlighted = power; cJSON *d = PU_data(&PU.Highlighted); int lv = (int)num(d, "level", 0), buy = lv < num(d, "unlockedRank", 0); PU.Button.visible = buy; PU.activeBox.visible = !buy && !PU_isMaxedOnly(PU.Highlighted); } static void PU_OnSelectionChange(void) { PowerPanel *p = NULL; for (int i = 0; i < PU.n && !p; i++) if (!strcmp(PU.panels[i].power, PU.Highlighted)) p = &PU.panels[i]; if (p) { PU.hlX = p->x - 9, PU.hlY = p->y - 9, PU.HighlightedPanel = p; if (UIGrid.on) UIGrid_SelectGameObject(&p->hit); OV.UI_selected = &p->hit; } } static void PU_OnPanelClicked(const char *power) { PU.Highlighted = power; PowerUpConfirmationPanel_AssignData(power); PU_OnSelectionChange(); } static void PU_OnConfirmClicked(void *c) { (void)c; cJSON *d = tbl0("powerups", PU.Highlighted); int lv = (int)num(d, "level", 0); float price = (1 + lv) * num(d, "price", 0) + Core_PowerUpMarkup(); po_set("Coins", ceil(po_num("Coins"))); if (lv < num(d, "unlockedRank", 0) && po_num("Coins") >= price) { po_add("Coins", -price); TopBar_UpdateCoins(); obj_set(d, "level", cJSON_CreateNumber(lv + 1)); po_push("BoughtPowerups", PU.Highlighted); // Core.OnPowerUpBought (SaveBought: solo Storage del web) PowerUpConfirmationPanel_AssignData(PU.Highlighted); Sound_PlaySimple("ClickIn", 0); } else { Sound_PlaySimple("ClickIn", 0); PowerUpConfirmationPanel_toggleActivePowerUp(); } } static void PU_OnActiveToggleClicked(void *c) { (void)c; Sound_PlaySimple("ClickIn", 0); PowerUpConfirmationPanel_toggleActivePowerUp(); } static void PU_onRefund(void *c) { (void)c; Sound_PlaySimple("ClickOut", 0); PlayerOptions_RefundAll(); TopBar_UpdateCoins(); cJSON *p; cJSON_ArrayForEach(p, data_get("powerups")) { cJSON *d = cJSON_GetArrayItem(p, 0); if (!cJSON_IsTrue(cJSON_GetObjectItem(d, "hidden"))) obj_set(d, "active", cJSON_CreateTrue()); } // resetActivePowerUp if (PU.Highlighted) PowerUpConfirmationPanel_AssignData(PU.Highlighted); } #define PU_CELL 106 static float PU_wx(float x) { return x; } // Vita: coordinate dello schermo, PU.scY = scorrimento verso il basso static float PU_wy(float y) { return y - PU.scY; } static void PU_onRefundKey(void) { vui_click(&PU.RefundButton); } static void PowerUpScene_MakeUIGrid(void) { Overlay_MakeUIGrid(PU.Columns, PU.Rows + 2, 1); for (int i = 0; i < PU.Columns; i++) UIGrid_SetContents(i, 0, &TB.BackButton, 0), UIGrid_SetContents(i, 1, &PU.RefundButton, 0); for (int i = 0; i < PU.n; i++) UIGrid_SetContents(i % PU.Columns, 2 + i / PU.Columns, &PU.panels[i].hit, 0); Overlay_ToggleCursorsVisibility(0); OV.OnCancelCallback = CS_cancel; // BackButton._events.pointerdown.fn() OV.OnTriangle = PU_onRefundKey; VPrompt P[] = { { G_TRIANGLE, "vui_refund" }, { G_CROSS, "vui_buy" }, { G_CIRCLE, "vui_back" } }; vui_set_prompts(P, 3); TB_title = tr("powerup_header"); } static void PowerUpScene_create(void) { memset(&PU, 0, sizeof(PU)); PU.active = 1, PU.Columns = 4, PU.scrollTopY = 0x40; PlayerOptions_RestoreUnlockablePowerUps(); // preload PU.Highlighted = "POWER"; // MIGHT UIButton_set(&PU.bg, "MenuBackground", 20, 62, 452, 428, 1, 0, 0); // Vita: griglia a sinistra, scheda a destra cJSON *p; cJSON_ArrayForEach(p, data_get("powerups")) { if (cJSON_IsTrue(cJSON_GetObjectItem(cJSON_GetArrayItem(p, 0), "hidden")) || PU.n >= PU_MAX) continue; PowerPanel *q = &PU.panels[PU.n++]; q->power = p->string; UIButton_set(&q->hit, "", 0, 0, PU_CELL, PU_CELL, 1, 0, 0); UIButton_on(&q->hit, PU_OnConfirmClicked, NULL); // panel.OnClick = OnConfirmClicked } for (int i = 0; i < PU.n; i++) PU.panels[i].x = 25 + i % PU.Columns * (PU_CELL + 4), PU.panels[i].y = 72 + i / PU.Columns * (PU_CELL + 4); PU.Rows = (int)ceilf((float)PU.n / PU.Columns); PU.scY = 0, PU.scMinY = 0, PU.scMaxY = fmaxf(0, PU.Rows * (PU_CELL + 4) + 6 - 420); PU.cpX = 488, PU.cpY = 62, PU.y0 = 0; UIButton_set(&PU.Button, "GreenButton", 506, 424, 416, 54, 1, 0, 0); UIButton_on(&PU.Button, PU_OnConfirmClicked, NULL); UIButton_set(&PU.activeBox, "OptionsButton", 506, 370, 204, 44, 1, 0, 0); UIButton_on(&PU.activeBox, PU_OnActiveToggleClicked, NULL); UIButton_set(&PU.RefundButton, "OptionsButton", 718, 370, 204, 44, 1, 0, 0); UIButton_on(&PU.RefundButton, PU_onRefund, NULL); PowerUpScene_MakeUIGrid(); PU_OnPanelClicked(PU.Highlighted); } static void PU_correctScrollableContainerPosition(float y) { // Vita: la cella scelta sempre dentro il riquadro (void)y; PowerPanel *p = PU.HighlightedPanel; if (!p) return; if (p->y - PU.scY < 68) PU.scY = p->y - 72; if (p->y + PU_CELL - PU.scY > 484) PU.scY = p->y + PU_CELL - 480; PU.scY = fminf(fmaxf(PU.scY, 0), PU.scMaxY); } static void PU_layout(void) { for (int i = 0; i < PU.n; i++) PU.panels[i].hit.x = PU_wx(PU.panels[i].x), PU.panels[i].hit.y = PU_wy(PU.panels[i].y); } static void PowerUpScene_update(float delta) { (void)delta; PU_layout(); Rectangle bounds = { 20, 62, 452, 428 }; Vector2 m = menu_pointer(); if (GetMouseWheelMove()) PU.scY = fminf(fmaxf(PU.scY - 40 * GetMouseWheelMove(), 0), PU.scMaxY); if (ptr_pressed()) { PU.downOnSc = CheckCollisionPointRec(m, bounds), PU.downAt = m, PU.dragOff = PU.scY + m.y; if (!UIButton_clicked(&PU.Button) && !UIButton_clicked(&PU.activeBox)) UIButton_clicked(&PU.RefundButton); } else if (ptr_down() && PU.downOnSc) { PU.scY = fminf(fmaxf(PU.dragOff - m.y, 0), PU.scMaxY); } else if (ptr_released() && PU.downOnSc) { PU.downOnSc = 0; if (CheckCollisionPointRec(m, bounds) && fabsf(PU.downAt.x - m.x) < 8 && fabsf(PU.downAt.y - m.y) < 8) for (int i = 0; i < PU.n; i++) if (CheckCollisionPointRec(m, (Rectangle){ PU.panels[i].hit.x, PU.panels[i].hit.y, PU_CELL, PU_CELL })) { if (!strcmp(PU.panels[i].power, PU.Highlighted)) PU_OnConfirmClicked(NULL); // Vita: secondo tocco = compra else PU_OnPanelClicked(PU.panels[i].power); break; } } if (OV.UI_selected != UIGrid.previousGameObject) { PowerPanel *p = PU_panelOf(OV.UI_selected); if (p) { PU_OnPanelClicked(p->power); Overlay_ToggleCursorsVisibility(0); PU.hlVisible = 1; PU_correctScrollableContainerPosition(PU.hlY); } else { Overlay_ToggleCursorsVisibility(1), PU.hlVisible = 0; } } PU_layout(); } static void PowerUpSelectionPanel_draw(PowerPanel *q) { const char *power = q->power; cJSON *d = PU_data(&power); int lv = (int)num(d, "level", 0), rank = (int)num(d, "unlockedRank", 0); float x = 0, y = 0, c = 0.5f * 0x6e; // Vita: disegno da 110 px scalato nella cella rlPushMatrix(); rlTranslatef(PU_wx(q->x), PU_wy(q->y), 0); rlScalef(PU_CELL / 110.0f, PU_CELL / 110.0f, 1); unsigned bt = lv < rank ? 0xffffff : cJSON_IsTrue(cJSON_GetObjectItem(d, "active")) ? 0xcccc88 : 0x888888; nine("frame1_c2.png", 12, (Rectangle){ x, y, 0x6e, 0x6e }, rgb(bt, 1)); TS_frame("UI", cJSON_IsTrue(cJSON_GetObjectItem(d, "specialBG")) ? "frameE.png" : "frameD.png", x + c, y + c, 0.5f, 0.5f, 2 * PixelScale, 0, WHITE, 0); TS_frame(str(d, "texture"), str(d, "frameName"), x + c, y + c, 0.5f, 0.5f, 2 * PixelScale, 0, WHITE, 0); ui_text(lang_text("powerUpLang", power, "name", d), x + c, y + 6, PixelScale, 0x64, 0.5f, 0, lv > 0 ? WHITE : (Color){ 0x44, 0x44, 0x44, 255 }); int small = rank > 5; float bx = c - (small ? 1.75f : 8) * (rank - 1); for (int i = 0; i < rank; i++) { float cx = small ? 8 * i % (8 * 5) : 0x10 * i, cy = small ? c + 0x26 + 8 * (i / 5) - 2 : c + 0x26, sc = small ? 0.5f : PixelScale; TS_frame("UI", "menu_checkbox_16_bg.png", x + bx + cx, y + cy, 0.5f, 0.5f, sc, 0, WHITE, 0); if (i < lv) TS_frame("UI", "menu_checkbox_16_checkmark.png", x + bx + cx, y + cy, 0.5f, 0.5f, sc, 0, WHITE, 0); } rlPopMatrix(); } static void PowerUpConfirmationPanel_draw(void) { // Vita: la scheda a destra float x = PU.cpX, y = PU.cpY; const char *power = PU.Highlighted; cJSON *d = PU_data(&power); int lv = (int)num(d, "level", 0), rank = (int)num(d, "unlockedRank", 0), buy = lv < rank, act = cJSON_IsTrue(cJSON_GetObjectItem(d, "active")); nine("frame5_c4.png", 12, (Rectangle){ x, y, 452, 428 }, WHITE); unsigned itint = !buy && !PU_isMaxedOnly(power) && !act ? 0x888888 : 0xffffff; TS_frame("UI", cJSON_IsTrue(cJSON_GetObjectItem(d, "specialBG")) ? "frameE.png" : "frameD.png", x + 82, y + 82, 0.5f, 0.5f, 3, 0, rgb(itint, 1), 0); TS_frame(str(d, "texture"), str(d, "frameName"), x + 82, y + 82, 0.5f, 0.5f, 3, 0, rgb(itint, 1), 0); const char *nm = lang_text("powerUpLang", power, "name", d); text_at(nm, x + 162, y + 30, fit_size(nm, 34, 270), 0, 0, rgb(VUI_GOLD, 1)); for (int i = 0; i < rank; i++) { // ranghi comprati float rx = x + 172 + i % 10 * 26, ry = y + 96 + i / 10 * 26; TS_frame("UI", "menu_checkbox_16_bg.png", rx, ry, 0.5f, 0.5f, 1.25f, 0, WHITE, 0); if (i < lv) TS_frame("UI", "menu_checkbox_16_checkmark.png", rx, ry, 0.5f, 0.5f, 1.25f, 0, WHITE, 0); } ui_wrap_text(lang_text("powerUpLang", power, "description", d), x + 18, y + 170, 22, 412, 140, WHITE, 1); if (PU.activeBox.visible) { UIButton_draw(&PU.activeBox, 1); TS_frame("UI", "menu_checkbox_24_bg.png", PU.activeBox.x + 26, PU.activeBox.y + 22, 0.5f, 0.5f, 1, 0, WHITE, 0); if (act) TS_frame("UI", "yes16.png", PU.activeBox.x + 26, PU.activeBox.y + 22, 0.5f, 0.5f, 1, 0, WHITE, 0); text_at(tr("active"), PU.activeBox.x + 46, PU.activeBox.y + 22, fit_size(tr("active"), 22, 150), 0, 0.5f, WHITE); } UIButton_draw(&PU.RefundButton, 1); text_at(tr("powerup_refund"), PU.RefundButton.x + 102, PU.RefundButton.y + 22, fit_size(tr("powerup_refund"), 22, 186), 0.5f, 0.5f, WHITE); if (buy) { UIButton_draw(&PU.Button, 1); char lab[96]; snprintf(lab, sizeof(lab), "%s %.0f", tr("powerupConfirm_buy"), PU_price(power)); float lw = MeasureTextEx(vs_font, lab, 30, 0).x, cx = PU.Button.x + 0.5f * bW(&PU.Button), cy = PU.Button.y + 0.5f * bH(&PU.Button); text_at(lab, cx, cy, 30, 0.5f, 0.5f, WHITE); TS_frame("UI", "CoinGold.png", cx + 0.5f * lw + 6, cy, 0, 0.5f, 2, 0, WHITE, 0); } else if (PU_isMaxedOnly(power) || !PU.activeBox.visible) text_at(tr("powerupConfirm_maxed"), x + 226, y + 451, 28, 0.5f, 0.5f, rgb(VUI_GOLD, 1)); } static void PowerUpScene_draw(void) { UIButton_draw(&PU.bg, 1); menu_clip(24, 66, 444, 420); for (int i = 0; i < PU.n; i++) { float y = PU_wy(PU.panels[i].y); if (y > -PU_CELL && y < MENU_H) PowerUpSelectionPanel_draw(&PU.panels[i]); } menu_unclip(); PowerPanel *hp = PU_panelOf(OV.UI_selected); if (hp) vui_focus((Rectangle){ hp->hit.x, hp->hit.y, PU_CELL, PU_CELL }, OV.t); if (PU.scMaxY > 0) { float h = 420 * 420 / (420 + PU.scMaxY); DrawRectangleRounded((Rectangle){ 462, 66 + (420 - h) * PU.scY / PU.scMaxY, 5, h }, 1, 4, rgb(VUI_GOLD, 0.7f)); } PowerUpConfirmationPanel_draw(); } // ============================================================================ // 0xd0b2: CollectionWeaponScene (Collezione) + 0xd007 CollectionWeaponPanel, 0x852d CollectionItemPanel, 0x17069 CollectionArcanaPanel, // 0x173ce CollectionWeaponDescPanel, 0xb24b SealPanel (i sigilli: SealedWeapons/SealedItems fino a Seals), 0x9bfc CollectionWeaponMagician // ============================================================================ #define CW_MAX 192 enum { CW_WEAPON, CW_ITEM, CW_ARCANA }; typedef struct { const char *power; int type, sealed; float x, y, bgAlpha, bgScale, iconScale; const char *bgFrame, *iconAtlas, *iconFrame; UIButton hit; // myIconBG (24x24 scala 2 in (0x20, 0x20)): pointerdown e _events.pointerdown della griglia } CollPanel; static struct { int active, n, Columns, Rows, yellowClickCounter, hlVisible, downOnSc, HighlightedType, obtained, count; const char *Highlighted; CollPanel panels[CW_MAX]; float t, scY, scMaxY, scMinY, scH, scrollTopY, scrollHeight, hlX, hlY, cpX, cpY, sealX, dragOff; float warnT, popT, popHideT, popX, popY, yellowUntil; // tween e timer della scena (-1 = spenti) Vector2 downAt, yellowPts[17]; int yellowPanel, popOn; UIButton bg, ScrollBar; char title[96]; // Vita: il conteggio nel titolo della barra in alto } CW; static void SceneManager_BackFromCollection(void); static const char *lang2(const char *key, const char *a0, const char *a1) { // getLang con due parametri (%0 e %1) static char o[256]; const char *s = lang1(key, a0), *p = strstr(s, "%1"); if (!p) return s; snprintf(o, sizeof(o), "%.*s%s%s", (int)(p - s), s, a1, p + 2); return o; } static cJSON *CW_data(const char *power, int type) { return type == CW_WEAPON ? tbl0("weapons", power) : cJSON_GetObjectItem(data_get(type == CW_ITEM ? "items" : "arcana"), power); } static int CW_is(cJSON *d, const char *k) { return cJSON_IsTrue(cJSON_GetObjectItem(d, k)); } static void CW_AssignData(CollPanel *p) { // AssignData dei tre pannelli cJSON *d = CW_data(p->power, p->type); int seen = CW_is(d, p->type == CW_ARCANA ? "unlocked" : "seen"); p->bgFrame = p->type == CW_WEAPON ? "frameB.png" : p->type == CW_ARCANA ? "frameG.png" : CW_is(d, "isRelic") ? "frameF.png" : "frameC.png"; p->iconAtlas = seen ? p->type == CW_ARCANA ? "items" : str(d, "texture") : "items", p->iconFrame = seen ? str(d, "frameName") : "QuestionMark.png"; p->iconScale = seen ? 2 * PixelScale : PixelScale, p->bgAlpha = seen ? 1 : 0.5f, p->bgScale = seen ? 2 * PixelScale : 1.6f * PixelScale; if (p->type != CW_ARCANA && str(d, "collectionFrame")) p->bgFrame = str(d, "collectionFrame"); } static void CW_Seal(CollPanel *p) { p->bgAlpha = 0.1f, p->sealed = 1; } static void CW_Unseal(CollPanel *p) { p->bgAlpha = 1, p->sealed = 0; } static void CW_count(void) { // il conteggio di create (lo stesso di CountCollection) cJSON *v; CW.obtained = CW.count = 0; cJSON_ArrayForEach(v, data_get("weapons")) { cJSON *w = cJSON_GetArrayItem(v, 0); if (w && !CW_is(w, "hidden") && !CW_is(w, "alwaysHidden")) CW.obtained += CW_is(w, "seen"), CW.count++; } cJSON_ArrayForEach(v, data_get("items")) { if (CW_is(v, "hidden") || CW_is(v, "alwaysHidden") || (str(v, "requiresDLC") && !DLC_Has(str(v, "requiresDLC"))) || (str(v, "requiresItem") && !po_has("CollectedItems", str(v, "requiresItem")))) continue; CW.obtained += CW_is(v, "seen"), CW.count++; } cJSON_ArrayForEach(v, data_get("arcana")) if (!CW_is(v, "hidden") && !CW_is(v, "alwaysHidden")) CW.obtained += CW_is(v, "unlocked"), CW.count++; } static void SealPanel_ShowWarning(void) { CW.warnT = CW.t; } static int CW_sealsUsed(void) { return cJSON_GetArraySize(po("SealedItems")) + cJSON_GetArraySize(po("SealedWeapons")); } static void CW_onSealToggle(void *c) { // OnWeaponClicked / OnItemClicked CollPanel *p = c; const char *list = p->type == CW_WEAPON ? "SealedWeapons" : "SealedItems"; int i = arr_indexOf(po(list), p->power); if (i > -1) Sound_PlaySimple("ClickIn", 0), cJSON_DeleteItemFromArray(po(list), i), CW_Unseal(p); else { if (CW_sealsUsed() >= po_num("Seals")) { Sound_PlaySimple("ClickOut", 0); return; } Sound_PlaySimple("Banish", 0), po_push(list, p->power), CW_Seal(p); } } static void CW_onUnsealable(void *c) { (void)c; SealPanel_ShowWarning(); Sound_PlaySimple("ClickOut", 0); } static CollPanel *CW_panelOf(UIButton *b) { return b && b >= &CW.panels[0].hit && b <= &CW.panels[CW_MAX - 1].hit ? (CollPanel *)((char *)b - offsetof(CollPanel, hit)) : NULL; } static void CW_yellowRelicClicked(void) { CW.yellowClickCounter += 1; if (CW.yellowClickCounter == 8 && !MM.hasSecretsGuide) { // "sei un mago": il bottone dei Segreti senza la reliquia CW.popOn = 1, CW.popX = CW.cpX + 12, CW.popY = CW.cpY + 160, CW.popT = CW.t, CW.popHideT = CW.t + 0xdac; // Vita: dentro la scheda MM.hasSecretsGuide = 1, MM.SecretsButton.visible = 1; // showSecretButton + enableSecretButton UIButton_on(&MM.SecretsButton, MM_onSecrets, NULL); } } static void CW_OnSelectionChange(void) { CollPanel *p = NULL; for (int i = 0; i < CW.n && !p; i++) if (!strcmp(CW.panels[i].power, CW.Highlighted)) p = &CW.panels[i]; if (p) { CW.hlX = p->x + 5, CW.hlY = p->y + 5; if (UIGrid.on) UIGrid_SelectGameObject(&p->hit); OV.UI_selected = &p->hit; } } static void CW_OnPanelClicked(const char *power, int type) { CW.Highlighted = power, CW.HighlightedType = type; // confirmationPanel.AssignData: il pannello si disegna da qui CW_OnSelectionChange(); if (!strcmp(power, "RELIC_YELLOW")) CW_yellowRelicClicked(); else CW.yellowClickCounter = 0; } static void CollectionWeaponScene_MakeUIGrid(void) { Overlay_MakeUIGrid(CW.Columns, CW.Rows + 1, 1); for (int i = 0; i < CW.Columns; i++) UIGrid_SetContents(i, 0, &TB.BackButton, 0); for (int i = 0; i < CW.n; i++) UIGrid_SetContents(i % CW.Columns, 1 + i / CW.Columns, &CW.panels[i].hit, 0); UIGrid_SelectAt(0, 0), OV.UI_selected = &TB.BackButton; OV.OnCancelCallback = CS_cancel; } static void CW_yellowGag(CollPanel *p) { // AssignData del Yellow Sign: una volta su 65536, un tracciato giallo per 9 s if (frand() > 1.0f / 0xffff) return; for (int i = 0; i < 0x11; i++) { float a = i * (PI / 0x11), r = 8 + 0x10 * sinf(fmodf(2 * a, PI)); CW.yellowPts[i] = (Vector2){ 0x10 + cosf(frand() * a) * r, 0x10 + sinf(frand() * a) * r }; } CW.yellowPanel = (int)(p - CW.panels), CW.yellowUntil = CW.t + 0x2328; } static CollPanel *CW_add(const char *power, int type) { if (CW.n >= CW_MAX) return NULL; CollPanel *p = &CW.panels[CW.n++]; memset(p, 0, sizeof(*p)); p->power = power, p->type = type; CW_AssignData(p); if (!strcmp(power, "RELIC_YELLOW")) CW_yellowGag(p); UIButton_set(&p->hit, "", 0, 0, 0x18, 0x18, 2 * PixelScale, 0.5f, 0.5f); if (type == CW_ARCANA) return p; cJSON *d = CW_data(power, type); if (CW_is(d, "sealable")) { UIButton_on(&p->hit, CW_onSealToggle, p); if (po_has(type == CW_WEAPON ? "SealedWeapons" : "SealedItems", power)) CW_Seal(p); } else UIButton_on(&p->hit, CW_onUnsealable, p); return p; } static void CollectionWeaponScene_create(void) { memset(&CW, 0, sizeof(CW)); CW.active = 1, CW.Columns = 8, CW.scrollTopY = 0x40, CW.Highlighted = "WHIP", CW.HighlightedType = CW_WEAPON; CW.warnT = CW.popT = CW.popHideT = CW.yellowUntil = -1, CW.yellowPanel = -1; PlayerOptions_CheckSeals(); // preload UIButton_set(&CW.bg, "MenuBackground", 20, 62, 520, 428, 1, 0, 0); // Vita: griglia a sinistra, scheda a destra CW_count(); cJSON *v; cJSON_ArrayForEach(v, data_get("weapons")) { cJSON *w = cJSON_GetArrayItem(v, 0); if (!CW_is(w, "hidden") && !CW_is(w, "alwaysHidden")) CW_add(v->string, CW_WEAPON); } // (sic) requiresDLC e requiresItem letti sulla tabella e non sull'oggetto: qui passano tutti cJSON_ArrayForEach(v, data_get("items")) if (!CW_is(v, "hidden") && !CW_is(v, "alwaysHidden")) CW_add(v->string, CW_ITEM); // semplificazione: on('pointerdown', yellowRelicClicked) sul container del Yellow Sign non scatta (container senza area): basta OnPanelClicked cJSON_ArrayForEach(v, data_get("arcana")) if (!CW_is(v, "hidden") && CW_is(v, "major")) CW_add(v->string, CW_ARCANA); for (int i = 0; i < CW.n; i++) { int c = i % CW.Columns, r = i / CW.Columns; CW.panels[i].x = 34 + c * 0x3b, CW.panels[i].y = 70 + r * 0x3b; } CW.Rows = (int)ceilf((float)CW.n / CW.Columns); CW.cpX = 556, CW.cpY = 62; CW.scY = 0, CW.scMinY = 0, CW.scMaxY = fmaxf(0, CW.Rows * 0x3b + 12 - 420); CollectionWeaponScene_MakeUIGrid(); CW_OnPanelClicked(CW.Highlighted, CW.HighlightedType); snprintf(CW.title, sizeof(CW.title), "%s", lang2("weapon_header", TextFormat("%d", CW.obtained), TextFormat("%d", CW.count))); TB_title = CW.title; VPrompt P[] = { { G_CROSS, "vui_seal" }, { G_CIRCLE, "vui_back" } }; vui_set_prompts(P, 2); } static float CW_wx(float x) { return x; } // Vita: coordinate dello schermo, CW.scY = scorrimento verso il basso static float CW_wy(float y) { return y - CW.scY; } static void CW_correctScrollableContainerPosition(float y) { // Vita: la cella scelta sempre dentro il riquadro float top = y - 5; if (top - CW.scY < 68) CW.scY = top - 70; if (top + 0x3b - CW.scY > 484) CW.scY = top + 0x3b - 480; CW.scY = fminf(fmaxf(CW.scY, 0), CW.scMaxY); } static void CW_layout(void) { for (int i = 0; i < CW.n; i++) CW.panels[i].hit.x = CW_wx(CW.panels[i].x + 0x20), CW.panels[i].hit.y = CW_wy(CW.panels[i].y + 0x20); } static void CollectionWeaponScene_update(float delta) { CW.t += delta; static float clk; // sviluppo: VS_COLLSEL= clicca quel pannello ogni 200 ms (Yellow Sign: 8 clic, il mago) if (getenv("VS_COLLSEL") && (clk += delta) > 0xc8) for (int i = 0; i < CW.n; i++) if (!strcmp(CW.panels[i].power, getenv("VS_COLLSEL"))) { clk = 0, CW_OnPanelClicked(CW.panels[i].power, CW.panels[i].type); break; } if (CW.popHideT >= 0 && CW.t >= CW.popHideT) CW.popHideT = -1, CW.popT = -CW.t; // Hide, poi time.removeAllEvents if (CW.yellowUntil >= 0 && CW.t >= CW.yellowUntil) CW.yellowUntil = -1, CW.yellowPanel = -1; CW_layout(); Rectangle bounds = { 20, 62, 520, 428 }; Vector2 m = menu_pointer(); if (GetMouseWheelMove()) CW.scY = fminf(fmaxf(CW.scY - 40 * GetMouseWheelMove(), 0), CW.scMaxY); if (ptr_pressed()) { CW.downOnSc = CheckCollisionPointRec(m, bounds), CW.downAt = m, CW.dragOff = CW.scY + m.y; if (CW.downOnSc) for (int i = 0; i < CW.n; i++) if (UIButton_clicked(&CW.panels[i].hit)) break; } else if (ptr_down() && CW.downOnSc) { CW.scY = fminf(fmaxf(CW.dragOff - m.y, 0), CW.scMaxY); } else if (ptr_released() && CW.downOnSc) { CW.downOnSc = 0; if (CheckCollisionPointRec(m, bounds) && fabsf(CW.downAt.x - m.x) < 5 && fabsf(CW.downAt.y - m.y) < 5) for (int i = 0; i < CW.n; i++) { CollPanel *p = &CW.panels[i]; if (CheckCollisionPointRec(m, (Rectangle){ CW_wx(p->x + 8), CW_wy(p->y + 8), 0x30, 0x30 })) { CW_OnPanelClicked(p->power, p->type); break; } } } if (OV.UI_selected != UIGrid.previousGameObject) { CollPanel *p = CW_panelOf(OV.UI_selected); if (p) { CW_OnPanelClicked(p->power, p->type); Overlay_ToggleCursorsVisibility(0); CW.hlVisible = 1; CW_correctScrollableContainerPosition(CW.hlY); } else Overlay_ToggleCursorsVisibility(1), CW.hlVisible = 0; } CW_layout(); } static void CollectionWeaponPanel_draw(CollPanel *p) { float x = CW_wx(p->x), y = CW_wy(p->y); TS_frame("UI", p->bgFrame, x + 0x20, y + 0x20, 0.5f, 0.5f, p->bgScale, 0, Fade(WHITE, p->bgAlpha), 0); TS_frame(p->iconAtlas, p->iconFrame, x + 0x20, y + 0x20, 0.5f, 0.5f, p->iconScale, 0, WHITE, 0); if (p->sealed) TS_frame("UI", "no16.png", x + 0x20, y + 0x20, 0.5f, 0.5f, 2 * PixelScale, 0, Fade(WHITE, 0.65f), 0); if (CW.yellowPanel == p - CW.panels) for (int i = 1; i < 0x11; i++) DrawLineEx((Vector2){ x + CW.yellowPts[i - 1].x, y + CW.yellowPts[i - 1].y }, (Vector2){ x + CW.yellowPts[i].x, y + CW.yellowPts[i].y }, 2, (Color){ 0xdd, 0xdd, 0, 255 }); } static void CollectionWeaponDescPanel_draw(void) { // Vita: la scheda a destra float x = CW.cpX, y = CW.cpY, W = 384; int type = CW.HighlightedType; const char *k = CW.Highlighted, *lf = type == CW_WEAPON ? "weaponLang" : type == CW_ITEM ? "itemLang" : "arcanaLang"; cJSON *d = CW_data(k, type); int seen = CW_is(d, type == CW_ARCANA ? "unlocked" : "seen"); nine("frame5_c4.png", 12, (Rectangle){ x, y, W, 428 }, rgb(seen ? 0xffffff : 0xaaaaaa, 1)); TS_frame("UI", "frameB.png", x + 60, y + 60, 0.5f, 0.5f, 3, 0, WHITE, 0); TS_frame(seen ? type == CW_ARCANA ? "items" : str(d, "texture") : "items", seen ? str(d, "frameName") : "QuestionMark.png", x + 60, y + 60, 0.5f, 0.5f, 3, 0, WHITE, 0); const char *nm = seen ? lang_text(lf, k, "name", d) : "???"; ui_wrap_text(nm, x + 118, y + 26, fit_size(nm, 30, 480), 250, 72, rgb(VUI_GOLD, 1), 1); const char *desc = seen ? lang_text(lf, k, "description", d) : tr("weaponCollectionPanel_notFound"), *tips = seen ? lang_text(lf, k, "tips", d) : ""; float dh = ui_wrap_text(desc, x + 18, y + 120, 22, W - 36, 150, WHITE, 1); if (*tips) ui_wrap_text(tips, x + 18, y + 128 + dh, 20, W - 36, 90, (Color){ 255, 165, 0, 255 }, 1); } static void SealPanel_draw(void) { // Vita: i sigilli in fondo alla scheda float s = po_num("Seals"), x = CW.cpX, y = CW.cpY + 428 - 54; if (s == 0) return; // UpdateValues: setVisible(false) senza sigilli DrawRectangle((int)x + 12, (int)y, 384 - 24, 2, rgb(0x8a6a2a, 1)); text_at(TextFormat("%s %d/%d", tr("seal_header"), CW_sealsUsed(), (int)s), x + 18, y + 26, 24, 0, 0.5f, WHITE); if (CW.warnT >= 0) { // tween alpha 1 -> 0 in 1000 ms, Quint.easeIn float k = lerp01(CW.t, CW.warnT, 0x3e8), a = 1 - k * k * k * k * k; text_at(tr("seal_cannot"), x + 366, y + 26, fit_size(tr("seal_cannot"), 20, 170), 1, 0.5f, Fade((Color){ 255, 90, 90, 255 }, a)); } } static void CollectionWeaponMagician_draw(void) { if (!CW.popOn) return; float k = CW.popT >= 0 ? lerp01(CW.t, CW.popT, 0x12c) : 1 - lerp01(CW.t, -CW.popT, 0x12c), W = 360; // scaleY 0 -> 1 -> 0 in 300 ms if (k <= 0) return; rlPushMatrix(); rlTranslatef(CW.popX, CW.popY, 0); rlScalef(1, k, 1); nine("frame1_c2.png", 12, (Rectangle){ 0, 0, W, 0x68 }, WHITE); ui_text(tr("youramagician"), 0.5f * W, 0x34, PixelScale, 0x12c, 0.5f, 0.5f, (Color){ 255, 255, 0, 255 }); rlPopMatrix(); } static void CollectionWeaponScene_draw(void) { UIButton_draw(&CW.bg, 1); menu_clip(24, 66, 512, 420); for (int i = 0; i < CW.n; i++) { float y = CW_wy(CW.panels[i].y); if (y > -0x40 && y < MENU_H) CollectionWeaponPanel_draw(&CW.panels[i]); } menu_unclip(); if (CW.hlVisible) vui_focus((Rectangle){ CW_wx(CW.hlX), CW_wy(CW.hlY), 0x36, 0x36 }, CW.t); if (CW.scMaxY > 0) { float h = 420 * 420 / (420 + CW.scMaxY); DrawRectangleRounded((Rectangle){ 530, 66 + (420 - h) * CW.scY / CW.scMaxY, 5, h }, 1, 4, rgb(VUI_GOLD, 0.7f)); } CollectionWeaponDescPanel_draw(); SealPanel_draw(); CollectionWeaponMagician_draw(); } // ============================================================================ // 0x478b: CollectionAchievementsScene (Sblocchi) + 0x145f0 CollectionAchievementPanel; il dettaglio e' GenericPopup.AssignAchievement // ============================================================================ #define CA_MAX 192 typedef struct { const char *power; float x, y, iconOX; int iconBG, overlay; const char *iconAtlas, *iconFrame, *iconBGFrame; float iconBGScale; UIButton hit; // il pannello nella griglia (niente _events: la conferma non fa nulla) } AchPanel; static struct { int active, n, Columns, Rows, unachievedCount, hlVisible, downOnSc, obtained, count; const char *Highlighted; AchPanel panels[CA_MAX]; GenericPopup cp; float scY, scMaxY, scMinY, scrollTopY, scrollHeight, hlX, hlY, cpX, cpY, optX, dragOff, alphaMod, barAlpha; Vector2 downAt; UIButton bg, ScrollBar, hideComplete_box; char title[96]; } CA; static void SceneManager_BackFromAchievements(void); static cJSON *CA_data(const char *k) { return tbl0("achievements", k); } static int CA_visible(cJSON *a, int forCount) { // i filtri di create (conteggio) e di createList if (!forCount && CW_is(a, "hidden")) return 0; cJSON *ar = cJSON_GetObjectItem(a, "arcanaToUnlock"); if (cJSON_IsNumber(ar) && ar->valuedouble >= 0 && !po_has("CollectedItems", "RELIC_RANDOMAZZO")) return 0; if (!forCount && CA.unachievedCount > 0 && po_is("HideCompletedAchievements") && CW_is(a, "achieved")) return 0; if (str(a, "requiresChar") && !po_has("UnlockedCharacters", str(a, "requiresChar"))) return 0; if (str(a, "requiresItem") && !po_has("CollectedItems", str(a, "requiresItem"))) return 0; return !str(a, "requiresStage") || po_has("UnlockedStages", str(a, "requiresStage")); } static void CollectionAchievementPanel_AssignData(AchPanel *p) { cJSON *a = CA_data(p->power); p->iconBG = 1, p->iconBGFrame = "frameB.png", p->iconBGScale = 1, p->overlay = 0, p->iconOX = 0.5f, p->iconAtlas = p->iconFrame = NULL; const char *w = str(a, "weaponToUnlock"), *c = str(a, "characterToUnlock"), *st = str(a, "stageToUnlock"), *hy = str(a, "hyperToUnlock"), *r = str(a, "relicToUnlock"), *pu = str(a, "powerUpToUnlock"); if (w) p->iconAtlas = str(tbl0("weapons", w), "texture"), p->iconFrame = str(tbl0("weapons", w), "frameName"), p->iconBG = 0; if (c) p->iconAtlas = "UI", p->iconFrame = str(tbl0("characters", c), "portraitName") ?: "QuestionMark.png", p->iconBG = 0; if (st) p->iconAtlas = "UI", p->iconFrame = str(tbl0("stages", st), "frameNameUnlock") ?: "QuestionMark.png", p->iconBG = 0; if (hy) p->iconAtlas = "UI", p->iconFrame = str(tbl0("stages", hy), "frameName") ?: "QuestionMark.png", p->iconBG = 0; if (r) p->iconAtlas = str(tbl0("items", r), "texture"), p->iconFrame = str(tbl0("items", r), "frameName"), p->iconBG = 0; if (num(a, "goldPrize", 0) && str(a, "weaponIcon")) p->iconAtlas = "items", p->iconFrame = str(tbl0("weapons", str(a, "weaponIcon")), "frameName"), p->iconOX = 0.75f, p->iconBG = 0, p->overlay = 1; if (pu) p->iconAtlas = "items", p->iconFrame = str(tbl0("powerups", pu), "frameName"), p->iconBG = 0; cJSON *ar = cJSON_GetObjectItem(a, "arcanaToUnlock"); if (cJSON_IsNumber(ar) && ar->valuedouble >= 0) p->iconAtlas = "items", p->iconFrame = str(tbl0("arcana", TextFormat("%d", ar->valueint)), "frameName"), p->iconBG = 1, p->iconBGFrame = "frameG.png", p->iconBGScale = 2; } static void CA_OnSelectionChange(void) { AchPanel *p = NULL; for (int i = 0; i < CA.n && !p; i++) if (!strcmp(CA.panels[i].power, CA.Highlighted)) p = &CA.panels[i]; if (p) { CA.hlX = p->x + 0xe, CA.hlY = p->y + 0xe; UIGrid_SelectGameObject(&p->hit); OV.UI_selected = &p->hit; } } static void CA_OnPanelClicked(const char *power) { CA.Highlighted = power; GenericPopup_AssignAchievement(&CA.cp, power, ""); CA_OnSelectionChange(); } static AchPanel *CA_panelOf(UIButton *b) { return b && b >= &CA.panels[0].hit && b <= &CA.panels[CA_MAX - 1].hit ? (AchPanel *)((char *)b - offsetof(AchPanel, hit)) : NULL; } static void CA_onHideKey(void) { vui_click(&CA.hideComplete_box); } static void CollectionAchievementsScene_MakeUIGrid(void) { CA.Columns = CA.unachievedCount > 0 ? 2 : 1; Overlay_DestroyGrid(); Overlay_MakeUIGrid(CA.Columns, CA.Rows + 1, 1); for (int i = 0; i < CA.Columns; i++) UIGrid_SetContents(i, 0, &TB.BackButton, 0); for (int i = 0; i < CA.n; i++) { UIGrid_SetContents(0, 1 + i, &CA.panels[i].hit, 0); if (CA.unachievedCount > 0) UIGrid_SetContents(1, 1 + i, &CA.hideComplete_box, 0); } UIGrid_SelectAt(0, 0), OV.UI_selected = &TB.BackButton; OV.OnCancelCallback = CS_cancel; if (CA.unachievedCount > 0) OV.OnTriangle = CA_onHideKey; VPrompt P[] = { { G_TRIANGLE, "vui_hide" }, { G_CIRCLE, "vui_back" } }; if (CA.unachievedCount > 0) vui_set_prompts(P, 2); else vui_set_prompts(P + 1, 1); } static void CA_createList(void) { CA.n = 0; cJSON *v; cJSON_ArrayForEach(v, data_get("achievements")) { if (!CA_visible(CA_data(v->string), 0) || CA.n >= CA_MAX) continue; AchPanel *p = &CA.panels[CA.n++]; memset(p, 0, sizeof(*p)); p->power = v->string; CollectionAchievementPanel_AssignData(p); UIButton_set(&p->hit, "", 0, 0, 0x1be, 0x30, PixelScale, 0, 0); } CA.Rows = CA.n; for (int i = 0; i < CA.Rows; i++) CA.panels[i].x = 26, CA.panels[i].y = 70 + 0x2c * i; // Vita: coordinate dello schermo CA.scY = 0, CA.scMinY = 0, CA.scMaxY = fmaxf(0, CA.Rows * 0x2c + 8 + 14 - 420); CA.Highlighted = CA.panels[0].power; CollectionAchievementsScene_MakeUIGrid(); CA_OnPanelClicked(CA.Highlighted); } static void CA_onHideCompleted(void *c) { (void)c; po_setb("HideCompletedAchievements", !po_is("HideCompletedAchievements")); CA_createList(); Sound_PlaySimple("ClickIn", 0); } static void CollectionAchievementsScene_create(void) { memset(&CA, 0, sizeof(CA)); CA.active = 1, CA.scrollTopY = 0x40, CA.alphaMod = -0.02f, CA.barAlpha = 1; UIButton_set(&CA.bg, "MenuBackground", 20, 62, 560, 428, 1, 0, 0); // Vita: lista a sinistra, scheda a destra cJSON *v; cJSON_ArrayForEach(v, data_get("achievements")) { cJSON *a = CA_data(v->string); if (CA_visible(a, 1)) CA.obtained += CW_is(a, "achieved"), CA.count++; CA.unachievedCount += !CW_is(a, "achieved"); } CA.cpX = 596, CA.cpY = 62; UIButton_set(&CA.hideComplete_box, "OptionsButton", 610, 436, 316, 42, 1, 0, 0); CA.hideComplete_box.visible = CA.unachievedCount > 0; if (CA.unachievedCount == 0) po_setb("HideCompletedAchievements", 0); CA_createList(); if (CA.unachievedCount > 0) UIButton_on(&CA.hideComplete_box, CA_onHideCompleted, NULL); // HandleInput snprintf(CA.title, sizeof(CA.title), "%s", lang2("achievements_header", TextFormat("%d", CA.obtained), TextFormat("%d", CA.count))); TB_title = CA.title; } static float CA_wx(float x) { return x; } // Vita: coordinate dello schermo static float CA_wy(float y) { return y - CA.scY; } static void CA_correctScrollableContainerPosition(void) { // Vita: la riga scelta sempre dentro la lista const float margin = 14; // la cornice della riga sporge di 12 px float row = CA_wy(CA.hlY) + CA.scY; if (row - margin - CA.scY < 66) CA.scY = row - margin - 66; if (row + 0x24 + margin - CA.scY > 486) CA.scY = row + 0x24 + margin - 486; CA.scY = fminf(fmaxf(CA.scY, 0), CA.scMaxY); } static void CA_layout(void) { for (int i = 0; i < CA.n; i++) CA.panels[i].hit.x = CA_wx(CA.panels[i].x + 0xa), CA.panels[i].hit.y = CA_wy(CA.panels[i].y + 8); } static void CollectionAchievementsScene_update(float delta) { static float clk; // sviluppo: VS_COLLSEL=hideCompleted conferma la casella dalla griglia dopo mezzo secondo if (getenv("VS_COLLSEL") && !strcmp(getenv("VS_COLLSEL"), "hideCompleted") && clk < 0x1f4 && (clk += delta) >= 0x1f4) UIGrid_SelectGameObject(&CA.hideComplete_box), OV.UI_selected = &CA.hideComplete_box, Overlay_OnSubmitPressed(); CA_layout(); Rectangle bounds = { 20, 62, 560, 428 }; Vector2 m = menu_pointer(); if (GetMouseWheelMove()) CA.scY = fminf(fmaxf(CA.scY - 40 * GetMouseWheelMove(), 0), CA.scMaxY), CA.alphaMod = 0.1f; if (ptr_pressed()) { CA.alphaMod = 0.1f, CA.downOnSc = CheckCollisionPointRec(m, bounds), CA.downAt = m, CA.dragOff = CA.scY + m.y; UIButton_clicked(&CA.hideComplete_box); } else if (ptr_down() && CA.downOnSc) { CA.scY = fminf(fmaxf(CA.dragOff - m.y, 0), CA.scMaxY); } else if (ptr_released()) { CA.alphaMod = -0.1f; if (CA.downOnSc && CheckCollisionPointRec(m, bounds) && fabsf(CA.downAt.x - m.x) < 5 && fabsf(CA.downAt.y - m.y) < 5) for (int i = 0; i < CA.n; i++) if (CheckCollisionPointRec(m, (Rectangle){ CA.panels[i].hit.x, CA.panels[i].hit.y, 0x1be, 0x30 })) { CA_OnPanelClicked(CA.panels[i].power); break; } CA.downOnSc = 0; } if (OV.UI_selected != UIGrid.previousGameObject) { AchPanel *p = CA_panelOf(OV.UI_selected); if (p) { CA_OnPanelClicked(p->power); Overlay_ToggleCursorsVisibility(0); CA.hlVisible = 1; CA_correctScrollableContainerPosition(); CA.alphaMod = 1; } else Overlay_ToggleCursorsVisibility(1), CA.hlVisible = 0; } CA.barAlpha = fminf(1, fmaxf(0, CA.barAlpha + CA.alphaMod)); // ScrollCursor.alpha += alphaMod (a ogni frame) CA_layout(); } static void CollectionAchievementPanel_draw(AchPanel *p) { float x = CA_wx(p->x), y = CA_wy(p->y); cJSON *a = CA_data(p->power); TS_frame("UI", "menu_checkbox_24_bg.png", x + 0x20, y + 0x20, 0.5f, 0.5f, PixelScale, 0, WHITE, 0); if (CW_is(a, "achieved")) TS_frame("UI", "menu_checkbox_24_checkmark.png", x + 0x20, y + 0x20, 0.5f, 0.5f, PixelScale, 0, WHITE, 0); const char *d = lang_text("achievementLang", p->power, "description", a); float h = ui_wrap_text(d, 0, 0, 19, 0x168, 0, WHITE, 0), sz = 19; // Vita: 19 px, al massimo due righe nei 44 px if (h > 44) sz = 19 * 44 / h; h = ui_wrap_text(d, 0, 0, sz, 0x168, 0, WHITE, 0); ui_wrap_text(d, x + 0x36, y + 0x20 - 0.5f * h, sz, 0x168, 0, WHITE, 1); if (p->iconBG) TS_frame("UI", p->iconBGFrame, x + 0x1b0, y + 0x20, 0.5f, 0.5f, p->iconBGScale, 0, WHITE, 0); if (p->iconAtlas && p->iconFrame) TS_frame(p->iconAtlas, p->iconFrame, x + 0x1b0, y + 0x20, p->iconOX, 0.5f, 2 * PixelScale, 0, WHITE, 0); if (p->overlay) TS_frame("UI", "MoneyBagGreen.png", x + 0x1b0, y + 0x20, 0.5f, 0.5f, 2 * PixelScale, 0, WHITE, 0); } static void GenericPopup_drawCard(const GenericPopup *g, float x, float y, float W) { // Vita: il GenericPopup come scheda verticale nine("frame5_c4.png", 12, (Rectangle){ x, y, W, 428 }, rgb(g->bgTint, 1)); if (g->iconBG) TS_frame("UI", g->iconBGFrame, x + W / 2, y + 66, 0.5f, 0.5f, 3, 0, WHITE, 0); if (g->iconAtlas && g->iconFrame) TS_frame(g->iconAtlas, g->iconFrame, x + W / 2, y + 66, g->iconOX, 0.5f, 3, 0, WHITE, 0); if (g->overlay) TS_frame("UI", g->overlayFrame, x + W / 2, y + 66, 0.5f, 0.5f, 3, 0, WHITE, 0); if (*g->name) text_at(g->name, x + W / 2, y + 128, fit_size(g->name, 26, W - 30), 0.5f, 0, YELLOW); float dh = ui_wrap_text(g->desc, x + 16, y + 164, 22, W - 32, 140, WHITE, 1); if (g->tipsVisible) ui_wrap_text(g->tips, x + 16, y + 172 + dh, 22, W - 32, 90, ORANGE, 1); } static void CollectionAchievementsScene_draw(void) { UIButton_draw(&CA.bg, 1); menu_clip(24, 66, 552, 420); for (int i = 0; i < CA.n; i++) { float y = CA_wy(CA.panels[i].y); if (y > -0x40 && y < MENU_H) CollectionAchievementPanel_draw(&CA.panels[i]); } menu_unclip(); menu_clip(24, 66, 552, 420); if (CA.hlVisible) vui_focus((Rectangle){ CA_wx(CA.hlX), CA_wy(CA.hlY), 0x1b8, 0x24 }, OV.t); menu_unclip(); if (CA.scMaxY > 0) { float h = 420 * 420 / (420 + CA.scMaxY); DrawRectangleRounded((Rectangle){ 570, 66 + (420 - h) * CA.scY / CA.scMaxY, 5, h }, 1, 4, rgb(VUI_GOLD, CA.barAlpha * 0.7f + 0.3f)); } GenericPopup_drawCard(&CA.cp, CA.cpX, CA.cpY, 344); if (CA.unachievedCount > 0) { UIButton *b = &CA.hideComplete_box; UIButton_draw(b, 1); TS_frame("UI", "menu_checkbox_24_bg.png", b->x + 26, b->y + 21, 0.5f, 0.5f, 1, 0, WHITE, 0); if (po_is("HideCompletedAchievements")) TS_frame("UI", "yes16.png", b->x + 26, b->y + 21, 0.5f, 0.5f, 1, 0, WHITE, 0); text_at(tr("achievements_hideCompleted"), b->x + 46, b->y + 21, fit_size(tr("achievements_hideCompleted"), 22, 260), 0, 0.5f, WHITE); } } // ============================================================================ // 0x1712b: CollectionBestiaryScene (Bestiario, con la Guida di Gouda) + 0xd386 CollectionBestiaryPanel + 0x297e CollectionBestiaryDescPanel // ============================================================================ #define BE_MAX 192 #define BE_SPR 24 #define BE_SKETA 120 typedef struct { // un oggetto di sprites: createEnemyAnimation e i create* lo modificano e le modifiche restano (come in JS) const char *textureName, *frameName; int endFrameCount, startFrameCount, zeroPad, frameRate; // -1 / 0 = undefined unsigned tint; float scale, alpha; char prefix[64]; } BestSprite; typedef struct { const char *key; cJSON *d; double killed; // displayKilledAmount char hp[48], power[48], speed[48]; // displayHp/Power/Speed, "" = falsy BestSprite spr[BE_SPR]; int nspr, nres; const char *res[8]; float x, y; // il CollectionBestiaryPanel nello ScrollableContainer UIButton hit; } BestEntry; typedef struct { Sprite s; Animation a; int ignoreAngle; } BestAnim; static const float BE_POS[16][3][16][2] = { // enemyPositions: positions1..16, varianti, punti (x, y); 9..15 vuote { { { 0, 0 } } }, { { { -1, -1 }, { 1, 1 } }, { { -1, 1 }, { 1, -1 } }, { { -1, 0 }, { 1, 0 } } }, { { { -1, -1 }, { 0, 0 }, { 1, 1 } }, { { -1, 1 }, { 0, 0 }, { 1, -1 } }, { { -1, 0 }, { 0, 0 }, { 1, 0 } } }, { { { -1, -1 }, { 1, -1 }, { 1, 1 }, { -1, 1 } }, { { -1, 0 }, { -0.33f, 0 }, { 0.33f, 0 }, { 1, 0 } } }, { { { -1, -1 }, { 1, -1 }, { 0, 0 }, { 1, 1 }, { -1, 1 } }, { { -1, 0 }, { -0.5f, 0 }, { 0, 0 }, { 0.5f, 0 }, { 1, 0 } } }, { { { -1, -1 }, { 0, -1 }, { 1, -1 }, { -1, 1 }, { 0, 1 }, { 1, 1 } }, { { -1, 0 }, { -0.6f, 0 }, { -0.2f, 0 }, { 0.2f, 0 }, { 0.6f, 0 }, { 1, 0 } } }, { { { -1, -1 }, { 0, -1 }, { 1, -1 }, { -1, 1 }, { 0, 1 }, { 1, 1 }, { 0, 0 } }, { { -0.75f, 0 }, { -0.5f, 0 }, { -0.25f, 0 }, { 0, 0 }, { 0.25f, 0 }, { 0.5f, 0 }, { 0.75f, 0 } } }, { { { -1, -1 }, { -0.33f, -1 }, { 0.33f, -1 }, { 1, -1 }, { -1, 1 }, { -0.33f, 1 }, { 0.33f, 1 }, { 1, 1 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { 0 } } }, { { { -1, -1 }, { -0.33f, -1 }, { 0.33f, -1 }, { 1, -1 }, { -1, -0.33f }, { -0.33f, -0.33f }, { 0.33f, -0.33f }, { 1, -0.33f }, { -1, 0.33f }, { -0.33f, 0.33f }, { 0.33f, 0.33f }, { 1, 0.33f }, { -1, 1 }, { -0.33f, 1 }, { 0.33f, 1 }, { 1, 1 } } }, }; static const int BE_NPOS[16] = { 1, 3, 3, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 1 }; // varianti per riga static struct { int active, n, Rows, currentSelectedNum, hlVisible, downOnSc, obtained, count, moveTweenIndex, sel; BestEntry e[BE_MAX]; float t, scY, scMaxY, scMinY, dragOff, hlX, hlY; Vector2 downAt; UIButton bg, ScrollBar, ScrollBtnUp, ScrollBtnDown; char title[64]; // CollectionBestiaryDescPanel char defeats[64], hpT[64], powerT[64], speedT[64], resT[160], skillsT[160], locT[256]; const char *desc, *bgAtlas, *bgFrame; float descX, descY, descOX, descWrap; int descScaled, unknownVisible; BestAnim A[16]; Vector2 necks[8][6]; // createOROCHIMARIO const Frame *neckFrame; int nNecks; Sprite sk[BE_SKETA]; Animation skA[BE_SKETA]; int nSk, skOn, nEyes, trinaOn, rbOn, rbBlue, rb[6], nRb; float skScale0, skT0, skAngle, trinaT0, trinaA0, rbNext; Sprite eyes[3]; // scene.add.image: fuori dal SceneContainer e senza maschera (sic) } BE; static void SceneManager_BackFromBestiary(void); #define BE_W SAFE_WIDTH #define BE_FX 708 // Vita: myFrame (0x12c x 0xb4) nella scheda a destra, coordinate dello schermo #define BE_FY 186 #define BE_ROW 30 static const char *intl_num(double v) { // new Intl.NumberFormat().format: en-US, migliaia con la virgola static char o[32]; char d[32]; snprintf(d, sizeof(d), "%.0f", v); int n = (int)strlen(d), j = 0, neg = d[0] == '-'; for (int i = 0; i < n; i++) { o[j++] = d[i]; int r = n - 1 - i; if (r > 0 && r % 3 == 0 && !(neg && i == 0)) o[j++] = ','; } o[j] = 0; return o; } static void BE_addSprites(BestEntry *e, cJSON *d) { cJSON *f; cJSON_ArrayForEach(f, cJSON_GetObjectItem(d, "frameNames")) { const char *fn = cJSON_GetStringValue(f), *tn = str(d, "textureName"); int dup = 0; for (int i = 0; i < e->nspr && !dup; i++) dup = !strcmp(e->spr[i].frameName, fn) && ((!tn && !e->spr[i].textureName) || (tn && e->spr[i].textureName && !strcmp(tn, e->spr[i].textureName))); if (dup || e->nspr >= BE_SPR) continue; BestSprite *s = &e->spr[e->nspr++]; memset(s, 0, sizeof(*s)); s->textureName = tn, s->frameName = fn, s->endFrameCount = has(d, "idleFrameCount") ? (int)num(d, "idleFrameCount", 0) : -1; s->tint = num(d, "tint", 0) ? (unsigned)num(d, "tint", 0) : 0xffffff, s->scale = num(d, "scale", 0) ?: 1, s->alpha = num(d, "alpha", 0) ?: 1; } cJSON *k; for (k = d->child; k; k = k->next) { // for (k in o) k.startsWith('res_') if (strncmp(k->string, "res_", 4) || e->nres >= 8) continue; int dup = 0; for (int i = 0; i < e->nres; i++) dup |= !strcmp(e->res[i], k->string); if (!dup) e->res[e->nres++] = k->string; } } static void BE_mergeList(cJSON *into, cJSON *from) { // bPlaces / skills della variante nei dati del nemico base (sic: restano per la partita) cJSON *v; cJSON_ArrayForEach(v, from) { int dup = 0; cJSON *w; cJSON_ArrayForEach(w, into) dup |= cJSON_Compare(v, w, 1); if (!dup) cJSON_AddItemToArray(into, cJSON_Duplicate(v, 1)); } } static double BE_dn(cJSON *d, const char *k) { cJSON *n = cJSON_GetObjectItem(d, k); return cJSON_IsNumber(n) ? n->valuedouble : NAN; } // undefined = NaN static void BE_range(char *out, double lo, double hi) { // a != b ? a + " - " + b : a, e un numero 0 e' falsy ('?') if (lo != hi) snprintf(out, 48, "%s - %s", js_num(lo), js_num(hi)); else if (lo) snprintf(out, 48, "%s", js_num(lo)); else *out = 0; } static void BE_buildData(void) { // il BESTIARY_DATA di create BE.n = BE.obtained = BE.count = 0; cJSON *v; cJSON_ArrayForEach(v, data_get("enemies")) { cJSON *d = cJSON_GetArrayItem(v, 0); if (!d || !CW_is(d, "bInclude") || BE.n >= BE_MAX) continue; BestEntry *e = &BE.e[BE.n++]; memset(e, 0, sizeof(*e)); e->key = v->string, e->d = d, e->killed = num(d, "killedAmount", 0); // + ShowAllValidEntries (0) // displayHp = maxHP (sic, il campo e' maxHp): undefined, quindi '?' if (BE_dn(d, "power") == BE_dn(d, "power") && BE_dn(d, "power")) snprintf(e->power, 48, "%s", js_num(BE_dn(d, "power"))); // undefined e 0: '?' if (BE_dn(d, "speed") == BE_dn(d, "speed") && BE_dn(d, "speed")) snprintf(e->speed, 48, "%s", js_num(BE_dn(d, "speed"))); if (!cJSON_GetObjectItem(d, "skills")) cJSON_AddItemToObject(d, "skills", cJSON_CreateArray()); BE_addSprites(e, d); cJSON *vars = cJSON_GetObjectItem(d, "bVariants"), *var; if (!vars) continue; double hp0 = BE_dn(d, "maxHp"), h[2] = { hp0, hp0 }, p[2] = { BE_dn(d, "power"), BE_dn(d, "power") }, s[2] = { BE_dn(d, "speed"), BE_dn(d, "speed") }; cJSON_ArrayForEach(var, vars) { const char *vk = cJSON_GetStringValue(var); cJSON *vd = vk && strcmp(vk, e->key) ? tbl0("enemies", vk) : NULL; if (!vd) continue; e->killed += num(vd, "killedAmount", 0); double vh = BE_dn(vd, "maxHp"), vp = BE_dn(vd, "power"), vs = BE_dn(vd, "speed"); h[0] = isnan(h[0]) || isnan(vh) ? NAN : fmin(h[0], vh), h[1] = isnan(h[1]) || isnan(vh) ? NAN : fmax(h[1], vh); // Math.min con un NaN e' NaN p[0] = isnan(p[0]) || isnan(vp) ? NAN : fmin(p[0], vp), p[1] = isnan(p[1]) || isnan(vp) ? NAN : fmax(p[1], vp); s[0] = isnan(s[0]) || isnan(vs) ? NAN : fmin(s[0], vs), s[1] = isnan(s[1]) || isnan(vs) ? NAN : fmax(s[1], vs); BE_addSprites(e, vd); if (cJSON_GetObjectItem(d, "bPlaces")) BE_mergeList(cJSON_GetObjectItem(d, "bPlaces"), cJSON_GetObjectItem(vd, "bPlaces")); // semplificazione: in JS senza bPlaces del base e' un TypeError BE_mergeList(cJSON_GetObjectItem(d, "skills"), cJSON_GetObjectItem(vd, "skills")); } BE_range(e->hp, 10 * h[0], 10 * h[1]), BE_range(e->power, p[0], p[1]), BE_range(e->speed, s[0], s[1]); } for (int i = 0; i < BE.n; i++) BE.obtained += BE.e[i].killed > 0, BE.count++; } // --- CollectionBestiaryDescPanel --- static void BE_AssignData(BestEntry *e) { int unknown = e->killed == 0 || CW_is(e->d, "bIgnore"); snprintf(BE.defeats, sizeof(BE.defeats), "%s %s", tr("bestiary_defeated"), unknown ? js_num(e->killed) : intl_num(e->killed)); BE.descX = BE_FX, BE.descOX = 0.5f, BE.desc = "???", BE.descScaled = 0; // y e larghezza restano quelle di prima (sic) snprintf(BE.hpT, sizeof(BE.hpT), "?"), snprintf(BE.powerT, sizeof(BE.powerT), "?"), snprintf(BE.speedT, sizeof(BE.speedT), "?"); snprintf(BE.resT, sizeof(BE.resT), "?"), snprintf(BE.skillsT, sizeof(BE.skillsT), "?"), snprintf(BE.locT, sizeof(BE.locT), "?"); if (unknown) return; BE.unknownVisible = 0; const char *bd = lang_text("enemiesLang", e->key, "bDesc", e->d); if (*bd) BE.descWrap = 436, BE.descX = 490, BE.descY = 286, BE.descOX = 0, BE.desc = bd, BE.descScaled = 1; // Vita snprintf(BE.hpT, sizeof(BE.hpT), "%s", *e->hp ? e->hp : "?"); snprintf(BE.powerT, sizeof(BE.powerT), "%s", *e->power ? e->power : "?"); snprintf(BE.speedT, sizeof(BE.speedT), "%s", *e->speed ? e->speed : "?"); char *o = BE.resT; *o = 0; for (int i = 0; i < e->nres; i++) snprintf(o + strlen(o), sizeof(BE.resT) - strlen(o), "%s%s", i ? ", " : "", tr(e->res[i])); if (!e->nres) snprintf(o, sizeof(BE.resT), "-"); static const char *const SK[4] = { "HPxLevel", "FixedDirection", "SelfDestruct", "Medusa" }; cJSON *sk = cJSON_GetObjectItem(e->d, "skills"), *x; o = BE.skillsT, *o = 0; int i = 0; cJSON_ArrayForEach(x, sk) { int s = (int)cJSON_GetNumberValue(x); snprintf(o + strlen(o), sizeof(BE.skillsT) - strlen(o), "%s%s", i++ ? ", " : "", s >= 0 && s < 4 ? tr(SK[s]) : ""); } if (!i) snprintf(o, sizeof(BE.skillsT), "-"); cJSON *pl = cJSON_GetObjectItem(e->d, "bPlaces"); int np = cJSON_GetArraySize(pl); o = BE.locT, *o = 0; for (i = 0; i < np && i < 3; i++) { const char *st = cJSON_GetStringValue(cJSON_GetArrayItem(pl, i)); cJSON *sd = st ? tbl0("stages", st) : NULL; snprintf(o + strlen(o), sizeof(BE.locT) - strlen(o), "%s%s", i ? ", " : "", sd ? lang_text("stageLang", st, "stageName", sd) : ""); } if (np > 2) snprintf(o + strlen(o), sizeof(BE.locT) - strlen(o), ", %s", tr("bestiary_others")); if (!np) snprintf(o, sizeof(BE.locT), "-"); } static Sprite *BE_createEnemyAnimation(BestAnim *A, BestSprite *s, float px, float py) { int anim = s->endFrameCount != -1, start = s->startFrameCount ?: 1, end = s->endFrameCount > 0 ? s->endFrameCount : 1; make_anim(&A->a, s->textureName ?: "enemies", s->prefix, start, end, s->zeroPad ?: 2, s->frameRate ?: 8, -1); if (anim) anims_play(&A->s, &A->a, (int)ceilf(frand() * (0.5f * end))); else if (A->a.n) anims_stop(&A->s), sprite_setFrame(&A->s, A->a.frames[0]); float sc = PixelScale * s->scale * 2; A->s.scaleX = A->s.scaleY = sc, A->s.x = BE_FX + 0x5a * px, A->s.y = BE_FY + 0x28 * py + 0.5f * A->s.height * sc; sprite_setTint(&A->s, s->tint), A->s.alpha = s->alpha, A->s.visible = 1, sprite_setOrigin(&A->s, 0.5f, 1); A->ignoreAngle = 0, A->s.flipX = A->s.flipY = 0; return &A->s; } static void BE_prefixI(BestSprite *s) { snprintf(s->prefix, sizeof(s->prefix), "%.*si", (int)(strstr(s->frameName, "0.png") ? strstr(s->frameName, "0.png") - s->frameName : (long)strlen(s->frameName)), s->frameName); } static void BE_prefixStatic(BestSprite *s) { BE_prefixI(s), s->prefix[strlen(s->prefix) - 1] = 0, s->zeroPad = 1; } static void BE_generic(BestSprite *s, int i, float px, float py) { // il ramo di assignEnemyImageAnim per ogni sprite if (s->endFrameCount > 0) BE_prefixI(s); else BE_prefixStatic(s); BE_createEnemyAnimation(&BE.A[i], s, px, py); } static int BE_pickPos(int n) { return RND_between(0, BE_NPOS[n - 1] - 1); } // RND.pick(enemyPositions[n - 1]) static void BE_createSKETAMARI(void) { static const char *const L[10] = { "SKELETON", "SKELETON2", "SKELETON3", "SKELETON4", "SKULLINO", "SKELEPANTHER", "SKELETONE", "SKELEWING_ZONE", "SKULLNOAURA", "SKULLNOAURA" }; static const float R[3][4] = { { 0x3c, 0.75f, 1, 0.5f }, { 0x23, 0.5f, 0.75f, 0.75f }, { 0x19, 0, 0.5f, 1 } }; BE.nSk = 0; for (int r = 0; r < 3; r++) for (int i = 0; i < R[r][0]; i++) { cJSON *d = tbl0("enemies", L[RND_between(0, 9)]); if (!d || BE.nSk >= BE_SKETA) continue; const char *fn = cJSON_GetStringValue(cJSON_GetArrayItem(cJSON_GetObjectItem(d, "frameNames"), 0)), *tn = str(d, "textureName"); float a = 2 * PI * i / R[r][0], x = 0x32 * ((R[r][2] - R[r][1]) * frand() + R[r][1]) * cosf(a), y = 0x32 * ((R[r][2] - R[r][1]) * frand() + R[r][1]) * sinf(a); Sprite *s = &BE.sk[BE.nSk]; sprite_init(s, frame_get(tn, fn), x, y); s->flipX = frand() >= 0.5f, s->angle = 0xb4 * frand() + a * RAD2DEG, s->scaleX = s->scaleY = 1 + frand() * R[r][3]; Animation *an = &BE.skA[BE.nSk++]; an->n = 0; if (num(d, "idleFrameCount", 0)) { // 'die' (0..end) si crea ma non parte char pre[64]; snprintf(pre, sizeof(pre), "%.*si", (int)(strstr(fn, "0.png") ? strstr(fn, "0.png") - fn : (long)strlen(fn)), fn); make_anim(an, tn, pre, 1, (int)num(d, "idleFrameCount", 0), 2, 8, -1); anims_play(s, an, 0); } } BE.skOn = 1, BE.skT0 = BE.t, BE.skAngle = 0; // scala 0.5 -> 4 in 60 s } static void BE_createTRINACRIA(BestEntry *e) { BestSprite *s = &e->spr[0]; BE_prefixI(s); Sprite *a3 = BE_createEnemyAnimation(&BE.A[3], s, 0, 0); s->endFrameCount = 4, s->frameRate = 0xa, snprintf(s->prefix, sizeof(s->prefix), "trinaW_"); BE_createEnemyAnimation(&BE.A[0], s, 0, 0); snprintf(s->prefix, sizeof(s->prefix), "trinaL_"); Sprite *a1 = BE_createEnemyAnimation(&BE.A[1], s, 0, 0); snprintf(s->prefix, sizeof(s->prefix), "trinaS_"); BE_createEnemyAnimation(&BE.A[2], s, 0, 0); sprite_setOrigin(a1, 0.5f, 0.5f), a1->y = a3->y - 0x19; BE.trinaOn = 1, BE.trinaT0 = BE.t, BE.trinaA0 = a1->angle; // customTween: angle -> 359 in 1 s, all'infinito for (int i = 0; i < 4; i++) BE.A[i].ignoreAngle = 1; } static void BE_createCosmicEgg(BestEntry *e) { int blue = frand() >= 0.5f; BestSprite *s = &e->spr[0]; s->frameRate = 8, snprintf(s->prefix, sizeof(s->prefix), blue ? "CEgg_i" : "CEggRed_i"); BE_createEnemyAnimation(&BE.A[2], s, 0, 0); s->endFrameCount = 5, snprintf(s->prefix, sizeof(s->prefix), blue ? "CEye_i" : "CEyeRed_i"); BE_createEnemyAnimation(&BE.A[3], s, 0, 0); s->endFrameCount = 4, snprintf(s->prefix, sizeof(s->prefix), "Wing_i"); BE_createEnemyAnimation(&BE.A[1], s, 0, 0); BE_createEnemyAnimation(&BE.A[0], s, 0, 0); for (int i = 0; i < 4; i++) BE.A[i].ignoreAngle = 1, BE.A[i].s.angle = 0; BE.A[1].s.x += 0x36, BE.A[0].s.x -= 0x36, BE.A[0].s.scaleX = -2, BE.A[0].s.scaleY = 2; } static void BE_createRedBlue(BestEntry *e) { int n = 6, v = BE_pickPos(n); BE.nRb = 0; for (int i = 0; i < n && i < e->nspr; i++) { // semplificazione: sprites[i] mancante in JS e' un TypeError BE_generic(&e->spr[i], i, BE_POS[n - 1][v][i][0], BE_POS[n - 1][v][i][1]); static const unsigned T[3] = { 0x888866, 0x886666, 0x888844 }; sprite_setTint(&BE.A[i].s, T[RND_between(0, 2)]), BE.rb[BE.nRb++] = i; } BE.rbOn = 1, BE.rbBlue = 1, BE.rbNext = BE.t + 0x7d0; } static void BE_createUndeadStars(BestEntry *e) { int n = 3, v = BE_pickPos(n); for (int i = 0; i < n && i < e->nspr; i++) { BE_generic(&e->spr[i], i, BE_POS[n - 1][v][i][0], BE_POS[n - 1][v][i][1]); static const unsigned T[3] = { 0x888866, 0x886666, 0x888844 }; sprite_setTint(&BE.A[i].s, T[RND_between(0, 2)]), BE.A[i].ignoreAngle = 1, BE.A[i].s.angle = 0; } static const char *const EA[3] = { "enemiesM", "enemies2", "enemies2" }, *const EF[3] = { "Mud_eyes.png", "Head_eyes.png", "Red_eyes.png" }; static const float EY[3] = { 0x3e - 0x40, 0, 0 }; // Vita: senza SceneContainer (0x40) gli occhi stanno dove li vede l'originale for (int i = 0; i < 3; i++) { sprite_init(&BE.eyes[i], frame_get(EA[i], EF[i]), BE.A[i].s.x, BE.A[i].s.y + EY[i]); sprite_setOrigin(&BE.eyes[i], 0.5f, 1), sprite_setScale(&BE.eyes[i], 2); } BE.nEyes = 3; } static void BE_createDIRECTER(BestEntry *e) { BE_prefixI(&e->spr[0]); Sprite *s = BE_createEnemyAnimation(&BE.A[0], &e->spr[0], 0, 0); sprite_setScale(s, 0x64), sprite_setOrigin(s, 0.5f, 0.5f), BE.A[0].ignoreAngle = 1; } static void BE_createCRABBINO(BestEntry *e) { BestSprite *s = &e->spr[0]; BE_prefixI(s); BE_createEnemyAnimation(&BE.A[0], s, 0, 0); snprintf(s->prefix, sizeof(s->prefix), "XLPincer_i"); Sprite *p1 = BE_createEnemyAnimation(&BE.A[1], s, 0, 0); p1->x += 0x1b * p1->scaleX, p1->y += -0x1c * p1->scaleY, p1->flipX = 1; Sprite *p2 = BE_createEnemyAnimation(&BE.A[2], s, 0, 0); p2->x += -0x1b * p2->scaleX, p2->y += -0x1c * p2->scaleY; for (int i = 0; i < 3; i++) BE.A[i].s.y += 0xf * BE.A[i].s.scaleX; } static void BE_createGASHADOKURO(BestEntry *e) { BestSprite *s = &e->spr[0]; BE_prefixI(s); s->scale = 1, s->tint = 0xffffff, s->alpha = 1; Sprite *body = BE_createEnemyAnimation(&BE.A[1], s, 0, 0); body->x = BE_FX + 0x28; BestSprite part = { .textureName = "moonspellChars", .startFrameCount = 1, .endFrameCount = 5, .zeroPad = 2, .frameRate = 8, .tint = 0xffffff, .scale = 1, .alpha = 1 }; snprintf(part.prefix, sizeof(part.prefix), "Gash_arm_i"); Sprite *a3 = BE_createEnemyAnimation(&BE.A[3], &part, 0, 0), *a0 = BE_createEnemyAnimation(&BE.A[0], &part, 0, 0); sprite_setOrigin(a3, 0.85f, 13.0f / 60), a3->x = BE_FX - 0x1a + 0x28, a3->y = BE_FY - 0x1c; a0->x = BE_FX - 0x96 + 0x28, a0->y = BE_FY - 0x14; snprintf(part.prefix, sizeof(part.prefix), "Gash_head_i"); Sprite *h = BE_createEnemyAnimation(&BE.A[2], &part, 0, 0); sprite_setOrigin(a0, 0, 0); // (sic) l'origine di testa vale sul braccio h->x = BE_FX - 0x52 + 0x28, h->y = BE_FY + 0x13; BE.A[0].ignoreAngle = BE.A[1].ignoreAngle = BE.A[2].ignoreAngle = BE.A[3].ignoreAngle = 1; } static void BE_createOROCHIMARIO(BestEntry *e) { BestAnim *body = &BE.A[0]; char f[64]; snprintf(f, sizeof(f), "%s", e->spr[0].frameName); char *z = strstr(f, "0.png"); if (z) snprintf(z, sizeof(f) - (z - f), "i01.png"); anims_stop(&body->s); sprite_setFrame(&body->s, frame_get(e->spr[0].textureName, f)); sprite_setScale(&body->s, 2), sprite_setOrigin(&body->s, 0.5f, 0.5f), sprite_setTint(&body->s, 0xffffff); body->s.x = BE_FX, body->s.y = BE_FY + 0x2d, body->s.alpha = 1, body->s.visible = 1, body->s.flipX = body->s.flipY = 0, body->ignoreAngle = 1; cJSON *d = tbl0("enemies", "MS_OROCHIHEAD"); const char *n0 = cJSON_GetStringValue(cJSON_GetArrayItem(cJSON_GetObjectItem(d, "frameNames"), 0)); BestSprite hd = { .textureName = str(d, "textureName"), .frameName = n0, .startFrameCount = 1, .endFrameCount = (int)num(d, "idleFrameCount", 1), .zeroPad = 2, .frameRate = 8, .tint = 0xffffff, .scale = 1, .alpha = 1 }; BE_prefixI(&hd); BE.neckFrame = frame_get(str(d, "textureName"), str(d, "flagName")); Vector2 neck = { body->s.x + 0xa, body->s.y - 0x1e }; for (int i = 0; i < 8; i++) { Sprite *s = BE_createEnemyAnimation(&BE.A[i + 1], &hd, 0, 0); s->x = BE_FX - 0x50 + 0xa0 * frand(), s->y = BE_FY - 0x28 + 0x32 * frand(); Vector2 p0 = { s->x, s->y - 0x14 }; // rotate_point di angolo 0 modifica lo stesso vettore: controllo = inizio for (int k = 0; k < 6; k++) { float t = k / 5.0f, u = 1 - t; BE.necks[i][k] = (Vector2){ (u * u + 2 * u * t) * p0.x + t * t * neck.x, (u * u + 2 * u * t) * p0.y + t * t * neck.y }; } } BE.nNecks = 8; } static void BE_createMASK(BestEntry *e, const char *maskKey, int a, int b, float px, float py) { BestSprite *s = &e->spr[0]; BE_prefixI(s); Sprite *m = BE_createEnemyAnimation(&BE.A[a], s, px, py), *o = &BE.A[b].s; static const struct { const char *k, *f; float oy; } MK[] = { { "MOON_MASK1", "mask1.png", 2.75f }, { "MASK_GOLD", "mask1.png", 2.75f }, { "MOON_MASK2", "mask2.png", 3.15f }, { "MASK_SILVER", "mask2.png", 3.15f }, { "MOON_MASK3", "mask3.png", 3.25f }, { "MOON_MASK4", "mask4.png", 3.25f }, { "MASK_LEFT", "mask4.png", 3.25f }, { "MOON_MASK5", "mask5.png", 3.75f }, { "MASK_RIGHT", "mask5.png", 3.75f }, }; const char *f = ""; float oy = 1; for (size_t i = 0; i < sizeof(MK) / sizeof(*MK); i++) if (!strcmp(MK[i].k, maskKey)) f = MK[i].f, oy = MK[i].oy; anims_stop(o), sprite_setFrame(o, frame_get("enemies2", f)); sprite_setScale(o, PixelScale * s->scale * 2), o->x = m->x, o->y = m->y, sprite_setTint(o, s->tint), o->alpha = s->alpha, o->visible = 1; sprite_setOrigin(o, 0.5f, oy), o->flipX = o->flipY = 0, BE.A[a].ignoreAngle = BE.A[b].ignoreAngle = 0; } static void BE_assignEnemyImageAnim(BestEntry *e) { BE.nNecks = 0; // orochimarioContainer.removeAll BE.trinaOn = BE.rbOn = 0, BE.nEyes = 0; // customTween.stop, removeEvent(RedBlueTimer), eyeSprites.destroy for (int i = 0; i < 16; i++) BE.A[i].s.visible = 0, anims_stop(&BE.A[i].s); BE.skOn = 0; const char *place = "FOREST"; cJSON *pl = cJSON_GetObjectItem(e->d, "bPlaces"); if (pl && e->killed > 0 && cJSON_GetArraySize(pl)) place = cJSON_GetStringValue(cJSON_GetArrayItem(pl, RND_between(0, cJSON_GetArraySize(pl) - 1))); cJSON *sd = place ? tbl0("stages", place) : NULL; if (sd && str(sd, "bestiaryBG")) BE.bgAtlas = str(sd, "uiTexture"), BE.bgFrame = str(sd, "bestiaryBG"); if (e->killed == 0 || CW_is(e->d, "bIgnore")) { BE.unknownVisible = 1; return; } BE.unknownVisible = 0; const char *k = e->key; if (!strcmp(k, "SKETAMARI")) { BE_createSKETAMARI(); return; } if (!strcmp(k, "DIRECTER")) { BE_createDIRECTER(e); return; } if (!strcmp(k, "TRINACRIA")) { BE_createTRINACRIA(e); return; } if (!strcmp(k, "MS_GOSHADOKURO")) { BE_createGASHADOKURO(e); return; } if (!strcmp(k, "MS_OROCHIMARIO")) { BE_createOROCHIMARIO(e); return; } if (!strcmp(k, "MOON_CRABBINO") || !strcmp(k, "MOON_BOSS_CRABBINO") || !strcmp(k, "BOSS_XLCRAB")) { BE_createCRABBINO(e); return; } if (!strcmp(k, "MOON_MASK3")) { int v = BE_pickPos(5); static const char *const M[5] = { "MOON_MASK2", "MOON_MASK3", "MOON_MASK4", "MOON_MASK5", "MOON_MASK1" }; for (int i = 0; i < 5; i++) BE_createMASK(e, M[i], 2 * i, 2 * i + 1, BE_POS[4][v][i][0], BE_POS[4][v][i][1]); return; } static const char *const MS[] = { "MASK_GOLD", "MASK_SILVER", "MASK_LEFT", "MASK_RIGHT", "MOON_MASK1", "MOON_MASK2", "MOON_MASK4", "MOON_MASK5" }; for (size_t i = 0; i < sizeof(MS) / sizeof(*MS); i++) if (!strcmp(k, MS[i])) { BE_createMASK(e, k, 0, 1, 0, 0); return; } // createALIAS (MOON_BAT, FANGEL, TRAINEE_Y...): nessuno nel bestiario del gioco base if (!strcmp(k, "COSMIC_EGG")) { BE_createCosmicEgg(e); return; } if (!strcmp(k, "STARDUST_ELEMENTAL")) { BE_createRedBlue(e); return; } if (!strcmp(k, "STARDUST_MUD")) { BE_createUndeadStars(e); return; } int n = e->nspr < 16 ? e->nspr : 16; if (!n || !BE_NPOS[n - 1]) return; // semplificazione: RND.pick([]) e' undefined e in JS si rompe; con 9-15 sprite non c'e' nessun nemico int v = BE_pickPos(n); for (int i = 0; i < n; i++) BE_generic(&e->spr[i], i, BE_POS[n - 1][v][i][0], BE_POS[n - 1][v][i][1]); } static void BE_onSelection(BestEntry *e) { BE_AssignData(e); BE_assignEnemyImageAnim(e); } // --- la scena --- static BestEntry *BE_entryOf(UIButton *b) { return b && b >= &BE.e[0].hit && b <= &BE.e[BE_MAX - 1].hit ? (BestEntry *)((char *)b - offsetof(BestEntry, hit)) : NULL; } static void BE_OnSelectionChange(void) { BestEntry *p = &BE.e[BE.sel]; BE.hlX = p->x, BE.hlY = p->y; // il pannello selected(true), gli altri false UIGrid_SelectGameObject(&p->hit); OV.UI_selected = &p->hit; } static void BE_OnPanelClicked(int i, int num) { BE.currentSelectedNum = num, BE.sel = i; BE_onSelection(&BE.e[i]); BE_OnSelectionChange(); } static void BE_onScrollUp(void *c) { (void)c; int i = BE.currentSelectedNum - 0xa > 0 ? BE.currentSelectedNum - 0xa : 0; BE_OnPanelClicked(i, i + 1); } // (sic) num come indice static void BE_onScrollDown(void *c) { (void)c; int i = BE.currentSelectedNum + 0xa < BE.n - 1 ? BE.currentSelectedNum + 0xa : BE.n - 1; BE_OnPanelClicked(i, i + 1); } static void BE_onKeyUp(void) { BE_onScrollUp(NULL); } static void BE_onKeyDown(void) { BE_onScrollDown(NULL); } static void CollectionBestiaryScene_MakeUIGrid(void) { Overlay_DestroyGrid(); Overlay_MakeUIGrid(2, BE.Rows + 1, 1); for (int i = 0; i < 2; i++) UIGrid_SetContents(i, 0, &TB.BackButton, 0); for (int i = 0; i < BE.n; i++) UIGrid_SetContents(0, 1 + i, &BE.e[i].hit, 0); UIGrid_SelectAt(0, 0), OV.UI_selected = &TB.BackButton; OV.OnCancelCallback = CS_cancel; } static void CollectionBestiaryScene_create(void) { memset(&BE, 0, sizeof(BE)); BE.active = 1; char bgm[64], mod[32]; // la musica del bestiario con Banger, poi SelectedBGM come prima snprintf(bgm, sizeof(bgm), "%s", po_str("SelectedBGM") ?: ""), snprintf(mod, sizeof(mod), "%s", po_str("SelectedBGMMod") ?: ""); po_sets("SelectedBGM", "BGM_Bestiary"), po_sets("SelectedBGMMod", "Normal"); Sound_SetupAndPlayBGM_Banger(1); po_sets("SelectedBGM", bgm), po_sets("SelectedBGMMod", mod); UIButton_set(&BE.bg, "MenuBackground", 20, 62, 440, 428, 1, 0, 0); // Vita: lista a sinistra, scheda a destra UIButton_set(&BE.ScrollBtnUp, "", -100, -100, 1, 1, 1, 0, 0), BE.ScrollBtnUp.visible = 0; // Vita: L e R al posto delle frecce UIButton_set(&BE.ScrollBtnDown, "", -100, -100, 1, 1, 1, 0, 0), BE.ScrollBtnDown.visible = 0; BE_buildData(); BE.moveTweenIndex = (int)floorf(frand() * 0xa), BE.bgAtlas = "UI", BE.bgFrame = str(tbl0("stages", "FOREST"), "bestiaryBG"), BE.descY = 296, BE.descWrap = 436; for (int i = 0; i < 16; i++) sprite_init(&BE.A[i].s, NULL, 0, 0), BE.A[i].s.visible = 0; if (BE.n) BE_onSelection(&BE.e[0]); // il costruttore del pannello (BAT1) BE.Rows = BE.n; // createList for (int i = 0; i < BE.n; i++) { BE.e[i].x = 26, BE.e[i].y = 70 + BE_ROW * i; UIButton_set(&BE.e[i].hit, "", 0, 0, 424, BE_ROW, 1, 0, 0); } BE.scY = 0, BE.scMinY = 0, BE.scMaxY = fmaxf(0, BE.n * BE_ROW + 8 - 420); CollectionBestiaryScene_MakeUIGrid(); if (BE.n) BE_OnPanelClicked(0, 0); if (getenv("VS_BESEL")) for (int i = 0; i < BE.n; i++) if (!strcmp(BE.e[i].key, getenv("VS_BESEL"))) BE.e[i].killed = 1, BE_OnPanelClicked(i, i + 1); // sviluppo: mostra una voce snprintf(BE.title, sizeof(BE.title), "%s", lang2("bestiary_header", TextFormat("%d", BE.obtained), TextFormat("%d", BE.count))); TB_title = BE.title; OV.OnL = BE_onKeyUp, OV.OnR = BE_onKeyDown; VPrompt P[] = { { G_L, "vui_skip10" }, { G_R, "vui_skip10" }, { G_CIRCLE, "vui_back" } }; vui_set_prompts(P, 3); } static float BE_wx(float x) { return x; } // Vita: coordinate dello schermo static float BE_wy(float y) { return y - BE.scY; } static void BE_correctScrollableContainerPosition(void) { // Vita: la riga scelta sempre dentro la lista float top = BE.e[BE.sel].y; if (top - BE.scY < 66) BE.scY = top - 70; if (top + BE_ROW - BE.scY > 486) BE.scY = top + BE_ROW - 482; BE.scY = fminf(fmaxf(BE.scY, 0), BE.scMaxY); } static void BE_layout(void) { for (int i = 0; i < BE.n; i++) BE.e[i].hit.x = BE_wx(BE.e[i].x), BE.e[i].hit.y = BE_wy(BE.e[i].y); } static float BE_wobble(void) { // TweenAngles[moveTweenIndex]: -5 -> 5 in 500 ms, yoyo, dopo 45 ms per indice float tt = BE.t - 0x2d * BE.moveTweenIndex; if (tt < 0) return -5; float ph = fmodf(tt, 0x3e8); return ph < 0x1f4 ? -5 + 10 * ph / 0x1f4 : 5 - 10 * (ph - 0x1f4) / 0x1f4; } static void CollectionBestiaryScene_update(float delta) { BE.t += delta; static int picked; // sviluppo: VS_COLLSEL= lo seleziona dalla griglia al primo aggiornamento if (getenv("VS_COLLSEL") && !picked && (picked = 1)) for (int i = 0; i < BE.n; i++) if (!strcmp(BE.e[i].key, getenv("VS_COLLSEL"))) UIGrid_SelectGameObject(&BE.e[i].hit), OV.UI_selected = &BE.e[i].hit; BE_layout(); Rectangle bounds = { 20, 62, 440, 428 }; Vector2 m = menu_pointer(); if (GetMouseWheelMove()) BE.scY = fminf(fmaxf(BE.scY - 40 * GetMouseWheelMove(), 0), BE.scMaxY); if (ptr_pressed()) { BE.downOnSc = CheckCollisionPointRec(m, bounds), BE.downAt = m, BE.dragOff = BE.scY + m.y; if (!UIButton_clicked(&BE.ScrollBtnUp)) UIButton_clicked(&BE.ScrollBtnDown); } else if (ptr_down() && BE.downOnSc) { BE.scY = fminf(fmaxf(BE.dragOff - m.y, 0), BE.scMaxY); } else if (ptr_released() && BE.downOnSc) { BE.downOnSc = 0; if (CheckCollisionPointRec(m, bounds) && fabsf(BE.downAt.x - m.x) < 5 && fabsf(BE.downAt.y - m.y) < 5) for (int i = 0; i < BE.n; i++) if (CheckCollisionPointRec(m, (Rectangle){ BE.e[i].hit.x, BE.e[i].hit.y, 424, BE_ROW })) { BE_OnPanelClicked(i, i + 1); break; } } if (OV.UI_selected != UIGrid.previousGameObject) { BestEntry *p = BE_entryOf(OV.UI_selected); if (p) { int i = (int)(p - BE.e); BE_OnPanelClicked(i, i + 1); Overlay_ToggleCursorsVisibility(0); BE.hlVisible = 1; BE_correctScrollableContainerPosition(); } else Overlay_ToggleCursorsVisibility(1), BE.hlVisible = 0; } // descriptionPanel.update + i tween e il timer della scena float w = BE_wobble(); for (int i = 0; i < 16; i++) { if (!BE.A[i].s.visible) continue; sprite_animsUpdate(&BE.A[i].s, delta); if (!BE.A[i].ignoreAngle) BE.A[i].s.angle = w; } if (BE.trinaOn) BE.A[1].s.angle = BE.trinaA0 + (0x167 - BE.trinaA0) * fmodf(BE.t - BE.trinaT0, 0x3e8) / 0x3e8; if (BE.rbOn && BE.t >= BE.rbNext) { for (int i = 0; i < BE.nRb; i++) sprite_setTint(&BE.A[BE.rb[i]].s, BE.rbBlue ? 0x8888ff : 0xff8888); BE.rbBlue = !BE.rbBlue, BE.rbNext += 0x7d0; } if (BE.skOn) { BE.skAngle += 0.5f; for (int i = 0; i < BE.nSk; i++) sprite_animsUpdate(&BE.sk[i], delta); } BE_layout(); } static void BE_drawSprite(const Sprite *s, float dy) { // uno sprite del pannello: Container (0, 0) dentro il SceneContainer (0, dy) Sprite c = *s; c.y += dy, c.scrollFactor0 = 1; scene_render_one(&c, (Shader){ 0 }); } static void CollectionBestiaryDescPanel_draw(void) { // Vita: scheda a destra, tutto dentro i 544 px float dy = 0; nine("frame5_c4.png", 12, (Rectangle){ 476, 62, 464, 428 }, WHITE); nine("frame1_c2.png", 12, (Rectangle){ BE_FX - 0.5f * 0x12c, dy + BE_FY - 0.5f * 0xb4, 0x12c, 0xb4 }, WHITE); text_at(BE.defeats, BE_FX, 80, 20, 0.5f, 0.5f, WHITE); if (BE.bgFrame) TS_frame(BE.bgAtlas, BE.bgFrame, BE_FX, dy + BE_FY, 0.5f, 0.5f, 0.967f, 0, WHITE, 0); // semplificazione: setScale(0.967, 0.96), qui uniforme if (BE.unknownVisible) text_at("?", BE_FX, dy + BE_FY, 40, 0.5f, 0.5f, WHITE); if (BE.descScaled) ui_wrap_text(BE.desc, BE.descX, BE.descY, 18, BE.descWrap, 134, WHITE, 1); // scaleToMaxFast(myDesc, false, 0x1ae, 0x78) else text_at(BE.desc, BE.descX, BE.descY, 20, BE.descOX, 0, WHITE); float tx = 490, ty = 436; // Vita: due colonne da tre righe const char *lab[6] = { "bestiary_hp", "bestiary_power", "bestiary_speed", "bestiary_resistances", "bestiary_skills", "bestiary_foundIn" }, *val[6] = { BE.hpT, BE.powerT, BE.speedT, BE.resT, BE.skillsT, BE.locT }; static const char *const IC[3] = { "HeartBlack.png", "Leaf.png", "Wing.png" }; for (int i = 0; i < 6; i++) { float y = ty + i % 3 * 19, cx = i < 3 ? tx : tx + 160, cw = i < 3 ? 150 : 276; if (i < 3) TS_frame("items", IC[i], cx + 6, y, 0.5f, 0.5f, 1, 0, WHITE, 0); const char *l = TextFormat("%s ", tr(lab[i])); float lx = i < 3 ? cx + 18 : cx, ls = fit_size(l, 18, 0.5f * cw), lw = MeasureTextEx(vs_font, l, ls, 0).x; text_at(l, lx, y, ls, 0, 0.5f, i < 3 ? WHITE : YELLOW); text_at(val[i], lx + lw, y, fit_size(val[i], 18, cw - (lx - cx) - lw), 0, 0.5f, WHITE); } menu_clip(BE_FX - 0.5f * 0x12c + 4, BE_FY - 0.5f * 0xb4 + 4, 0x12c - 8, 0xb4 - 8); // myMask if (BE.nNecks) BE_drawSprite(&BE.A[0].s, dy); // orochimarioContainer: corpo e colli sotto le teste for (int i = 0; i < BE.nNecks; i++) { Vector2 p[6]; // Rope_drawH toglie la camera: qui sono coordinate dello schermo for (int k = 0; k < 6; k++) p[k] = (Vector2){ BE.necks[i][k].x + camera_scrollX, BE.necks[i][k].y + camera_scrollY + dy }; Rope_drawH(p, 6, BE.neckFrame, 1, 1, 0, 0); } for (int i = BE.nNecks ? 1 : 0; i < 16; i++) BE_drawSprite(&BE.A[i].s, dy); if (BE.skOn) { // sketamariContainer in (myFrame.x, myFrame.y), scala 0.5 -> 4 in 60 s, angle += 0.5 a ogni frame float k = lerp01(BE.t, BE.skT0, 0xea60), sc = 0.5f + 3.5f * k, a = BE.skAngle * DEG2RAD; for (int i = 0; i < BE.nSk; i++) { Sprite c = BE.sk[i]; c.x = BE_FX + sc * (BE.sk[i].x * cosf(a) - BE.sk[i].y * sinf(a)), c.y = BE_FY + sc * (BE.sk[i].x * sinf(a) + BE.sk[i].y * cosf(a)); c.scaleX *= sc, c.scaleY *= sc, c.angle += BE.skAngle; BE_drawSprite(&c, dy); } } menu_unclip(); } static void CollectionBestiaryScene_draw(void) { UIButton_draw(&BE.bg, 1); menu_clip(24, 66, 432, 420); for (int i = 0; i < BE.n; i++) { BestEntry *e = &BE.e[i]; float x = BE_wx(e->x), y = BE_wy(e->y); if (y < 30 || y > MENU_H) continue; if (i == BE.sel) DrawRectangleRec((Rectangle){ x, y + 2, 424, BE_ROW - 4 }, rgb(0xa5a64c, 0.5f)); // myOverlay text_at(TextFormat("%03d", i + 1), x + 26, y + 0.5f * BE_ROW, 20, 0, 0.5f, WHITE); const char *nm = "-------------------"; int known = e->killed != 0 && !CW_is(e->d, "bIgnore"); if (known) nm = *lang_text("enemiesLang", e->key, "bName", e->d) ? lang_text("enemiesLang", e->key, "bName", e->d) : e->key; text_at(nm, x + 76, y + 0.5f * BE_ROW, fit_size(nm, 20, 340), 0, 0.5f, known && CW_is(e->d, "bHighlight") ? YELLOW : WHITE); } if (BE.hlVisible) TS_frame("UI", "arrow_01.png", BE_wx(BE.e[BE.sel].x) + 2, BE_wy(BE.e[BE.sel].y) + 0.5f * BE_ROW, 0, 0.5f, 1.5f, 0, WHITE, 0); menu_unclip(); CollectionBestiaryDescPanel_draw(); for (int i = 0; i < BE.nEyes; i++) BE_drawSprite(&BE.eyes[i], 0); } // ============================================================================ // 0x1266e: PauseScene (Opzioni / Riprendi) con le reliquie: TreasureMapPanel (0x4156, RELIC_MAP), EvolutionPanel (0x16d39, // il grimorio RELIC_GRIMOIRE) e MazzoInGamePanel (0x168b5, Randomazzo). Le pagine delle opzioni arrivano con F3.5. // PauseStatsScene (0x135fd): armi e statistiche solo con piu' di 5 armi sbloccate, con gli sblocchi (F3.2) // ============================================================================ typedef struct { float from, to, t0, dur; } PSAnim; // un tween lineare su una sola scala static float PSAnim_v(const PSAnim *a, float t) { return a->from + (a->to - a->from) * lerp01(t, a->t0, a->dur); } // le voci del grimorio: un'evoluzione e le armi che servono typedef struct { const char *weapon; cJSON *evolvesFrom, *requires; } EvoItem; typedef struct { int kind; float x; const char *atlas, *frame; float sc, alpha; } EvoEl; // kind: 0 immagine, 1 cerchio, 2 rettangolo #define EVO_MAX 160 static struct { int active, enabled, hasRelicMap, hasEvolutionGuide, hasRandomazzo, pending, optionsOpen; float t, pendingAt, butX, butY; UIButton OptionsButton, ResumeButton, OpenGrimoireButton, OpenMapFromGrimoireButton, ShowPickupsButton, ShowGuidesButton; // TreasureMapPanel int mapExists, mapOpen; PSAnim mapSY; // EvolutionPanel int evoExists, evoOpen, pagesCurrent, pagesAmount, nEvo, availW, availP, hlLeft, hlRight; float evoY, evoH, rowHeight; PSAnim evoSX; EvoItem evo[EVO_MAX]; UIButton UI_left, UI_right; // MazzoInGamePanel PSAnim mazzoSY; ArcCard cards[22]; int nCards; } PS; static void SceneManager_ResumeFromPause(void); static void PS_onResume(void *c) { (void)c; SceneManager_ResumeFromPause(); } static void PauseOptions_open(void), Options_update(float delta), Options_draw(void); static int PS_simple(void) { return !PS.hasRelicMap && !PS.hasEvolutionGuide; } static void PS_onOptions(void *c) { (void)c; PauseOptions_open(); } // OpenOptions static void PS_cancel(void) { if (PS.ResumeButton.onDown) PS.ResumeButton.onDown(PS.ResumeButton.ctx); } static void PauseScene_MakeUIGrid(int grimoire) { Overlay_DestroyGrid(); if (PS_simple()) { // Vita: colonna Riprendi / Opzioni Overlay_MakeUIGrid(1, 2, 1); vui_set_prompts((VPrompt[]){ { G_CROSS, "vui_select" }, { G_CIRCLE, "pause_resume" } }, 2); UIGrid_SetContents(0, 0, &PS.ResumeButton, 0), UIGrid_SetContents(0, 1, &PS.OptionsButton, 0); Overlay_ToggleCursorsVisibility(1); UIGrid_SelectGameObject(&PS.ResumeButton); OV.UI_selected = &PS.ResumeButton; OV.OnCancelCallback = PS_cancel; return; } int w = 2 + PS.hasEvolutionGuide + 2 * PS.hasRelicMap, x = 1; Overlay_MakeUIGrid(w, 1, 1); vui_set_prompts((VPrompt[]){ { G_CROSS, "vui_select" }, { G_CIRCLE, "pause_resume" } }, 2); UIGrid_SetContents(0, 0, &PS.OptionsButton, 0); if (PS.hasRelicMap) UIGrid_SetContents(x++, 0, &PS.ShowPickupsButton, 0), UIGrid_SetContents(x++, 0, &PS.ShowGuidesButton, 0); if (PS.hasEvolutionGuide && PS.hasRelicMap) UIGrid_SetContents(x++, 0, &PS.OpenGrimoireButton, 0); UIGrid_SetContents(x, 0, &PS.ResumeButton, 0); Overlay_ToggleCursorsVisibility(1); UIButton *sel = grimoire && PS.hasEvolutionGuide && PS.hasRelicMap ? &PS.OpenGrimoireButton : &PS.ResumeButton; UIGrid_SelectGameObject(sel); OV.UI_selected = sel; OV.OnCancelCallback = PS_cancel; } static void PauseScene_MakeUIGrid_Grimoire(void) { Overlay_DestroyGrid(); int x = 1; Overlay_MakeUIGrid(2 + PS.hasRelicMap, 2, 1); UIGrid_SetContents(0, 1, &PS.OptionsButton, 0); if (PS.hasRelicMap) UIGrid_SetContents(x++, 1, &PS.OpenMapFromGrimoireButton, 0); UIGrid_SetContents(x, 1, &PS.ResumeButton, 0); if (PS.pagesAmount > 0) UIGrid_SetContents(0, 0, &PS.UI_left, 0), UIGrid_SetContents(1, 0, &PS.UI_right, 0); Overlay_ToggleCursorsVisibility(1); UIButton *sel = PS.hasRelicMap ? &PS.OpenMapFromGrimoireButton : &PS.ResumeButton; UIGrid_SelectGameObject(sel); OV.UI_selected = sel; OV.OnCancelCallback = PS_cancel; } // --- EvolutionPanel --- static cJSON *PS_w0(const char *w) { return cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("weapons"), w), 0); } static int PS_flag(const char *w, const char *k) { return cJSON_IsTrue(cJSON_GetObjectItem(PS_w0(w), k)); } static int PS_owns(const char *w) { return Core_GetWeapon(w) != NULL; } static int PS_inStage(const char *w) { for (int i = 0; i < Core.n_StagePickups; i++) if (Core.StagePickups[i]->weaponType && !strcmp(Core.StagePickups[i]->weaponType, w)) return 1; return 0; } static int PS_required(const EvoItem *e, const char **out) { // createRequiredWeaponList: evolvesFrom poi requires, senza doppioni int n = 0; cJSON *lists[2] = { e->evolvesFrom, e->requires }, *v; for (int l = 0; l < 2; l++) cJSON_ArrayForEach(v, lists[l]) { if (!cJSON_IsString(v)) continue; int dup = 0; for (int i = 0; i < n; i++) dup |= !strcmp(out[i], v->valuestring); if (!dup && n < 16) out[n++] = v->valuestring; } return n; } static int PS_seenSpecial(const char *w) { // seen, o le quattro evoluzioni sempre visibili (le altre dell'elenco sono DLC) static const char *const S[] = { "VAMPIRICA", "HOLY_MISSILE", "THOUSAND", "SCYTHE", "SILVERWIND2", "FOURSEASONS2", "SUMMONNIGHT2", "MIRAGEROBE2", "BUBBLES2" }; if (PS_flag(w, "seen")) return 1; for (size_t i = 0; i < sizeof(S) / sizeof(*S); i++) if (!strcmp(w, S[i])) return 1; return 0; } static int PS_visibleItem(const EvoItem *e) { if (PS_owns(e->weapon)) return 1; const char *req[16]; int n = PS_required(e, req); if (!n || !PS_w0(req[0])) return 0; return PS_seenSpecial(e->weapon) || (PS_flag(req[0], "isUnlocked") && !PS_flag(req[0], "isPowerUp")); } static int PS_disabledItem(const EvoItem *e) { if (PS_owns(e->weapon)) return 0; const char *req[16]; int n = PS_required(e, req), w = 0, p = 0; for (int i = 0; i < n; i++) { if (!PS_w0(req[i]) || PS_owns(req[i])) continue; if (!PS_flag(req[i], "isUnlocked") && !PS_inStage(req[i])) return 1; if (PS_flag(req[i], "isPowerUp")) p++; else w++; if (PS.availW < w || PS.availP < p) return 1; } return 0; } static int PS_requiresYellowSign(const EvoItem *e) { if (po_has("CollectedItems", "RELIC_YELLOW")) return 0; cJSON *v; cJSON_ArrayForEach(v, e->requires) if (cJSON_IsString(v) && PS_w0(v->valuestring) && !PS_owns(v->valuestring) && PS_flag(v->valuestring, "isSpecialOnly") && !PS_flag(v->valuestring, "isUnlocked")) return 1; return 0; } static void EvolutionPanel_create(float y, float h) { PS.evoExists = 1, PS.evoY = y, PS.evoH = h, PS.nEvo = 0, PS.pagesCurrent = 0; cJSON *w; cJSON_ArrayForEach(w, data_get("weapons")) { // createEvolutionList (le evoluzioni dei DLC non installati non sono nei dati) cJSON *b = cJSON_GetArrayItem(w, 0); if (!b || !strcmp(w->string, "BONE2") || !cJSON_GetObjectItem(b, "evolvesFrom")) continue; EvoItem e = { w->string, cJSON_GetObjectItem(b, "evolvesFrom"), cJSON_GetObjectItem(b, "requires") }; if (PS_requiresYellowSign(&e) || !strcmp(e.weapon, "TRIASSO3") || !PS_visibleItem(&e) || PS.nEvo >= EVO_MAX) continue; PS.evo[PS.nEvo++] = e; } int nw = 0, np = 0; // calculateAvailbleSlots for (int i = 0; i < Core.n_weapons; i++) Core.Weapons[i]->isPowerUp ? np++ : nw++; PS.availW = LUF.maxTrueWeapons - nw, PS.availP = LUF.maxPowerUpWeapons - np; PS.pagesAmount = (PS.nEvo - 1) / 0x15; PS.rowHeight = PS.pagesAmount > 0 ? 0x2f : 0x32; UIButton_set(&PS.UI_left, "", 0, 0, 0x10, 0x10, 2, 1, 0.5f), UIButton_set(&PS.UI_right, "", 0, 0, 0x10, 0x10, 2, 0, 0.5f); } static int Evo_icon(EvoEl *el, int n, float x, const char *w) { // createWeaponIcon (o il punto di domanda) cJSON *b = PS_w0(w); el[n] = b ? (EvoEl){ 0, x, str(b, "texture"), str(b, "frameName"), 2, 1 } : (EvoEl){ 0, x, "items", "QuestionMark.png", 1, 1 }; return n + 1; } static int Evo_unknown(EvoEl *el, int n, float x) { // frameB a meta' e il punto di domanda el[n++] = (EvoEl){ 0, x, "UI", "frameB.png", 1.5f, 0.5f }; el[n++] = (EvoEl){ 0, x, "items", "QuestionMark.png", 1, 1 }; return n; } static float Evo_bounds(const EvoEl *el, int n, float *x0) { // Container.getBounds: solo le immagini (la Graphics non ha bounds) float a = 1e9f, b = -1e9f; for (int i = 0; i < n; i++) { if (el[i].kind) continue; const Frame *f = frame_get(el[i].atlas, el[i].frame); float hw = 0.5f * (f ? f->sw : 0) * el[i].sc; if (el[i].x - hw < a) a = el[i].x - hw; if (el[i].x + hw > b) b = el[i].x + hw; } *x0 = a; return b - a; } static int Evo_build(const EvoItem *e, EvoEl *el) { // createWeaponContainer / createTRIASSOContainer int n = 0; float x = 0; if (!strcmp(e->weapon, "TRIASSO2")) { int seen = PS_flag("TRIASSO1", "seen"), ok = seen || PS_flag("TRIASSO1", "isUnlocked"); static const char *const T[3] = { "TRIASSO1", "TRIASSO2", "TRIASSO3" }; for (int i = 0; i < 3; i++) { if (ok) { if (PS_owns(T[i])) el[n++] = (EvoEl){ 1, x }; n = Evo_icon(el, n, x, T[i]); } else n = Evo_unknown(el, n, x); x += 0x23; if (i < 2) el[n++] = (EvoEl){ 0, x, "items", "icon_equals.png", 1, 1 }, x += 0x23; } if (seen && PS_owns("TRIASSO1")) el[n++] = (EvoEl){ 2, 0 }; return n; } const char *req[16]; int nr = PS_required(e, req), seen = PS_flag(e->weapon, "seen"), special = PS_seenSpecial(e->weapon); for (int i = 0; i < nr; i++) { if (!PS_w0(req[i])) continue; if (i > 0 && strcmp(req[i], "RIGHT") && strcmp(req[i], "GOLD")) el[n++] = (EvoEl){ 0, x, "items", "icon_plus.png", 1, 1 }, x += 0x23; if (special || (PS_flag(req[i], "isUnlocked") && !PS_flag(req[i], "isPowerUp"))) { if (PS_owns(req[i])) el[n++] = (EvoEl){ 1, x }; n = Evo_icon(el, n, x, req[i]); } else n = Evo_unknown(el, n, x); x += strcmp(req[i], "RIGHT") && strcmp(req[i], "SILVER") ? 0x20 : 0x23; } el[n++] = (EvoEl){ 0, x, "items", "icon_equals.png", 1, 1 }, x += 0x23; if (seen) { n = Evo_icon(el, n, x, e->weapon), x += 0x23; if (PS_owns(e->weapon)) el[n++] = (EvoEl){ 2, 0 }; } else n = Evo_unknown(el, n, x), x += 0x23; return n; } // Vita: il pannello (742 x 453, pensato per 720 di altezza) usciva in fondo, copriva le statistiche (x 8..208) e // finiva sopra i bottoni (da y 432): scalato uniforme nello spazio libero x 216..952, y 6..426 #define EVO_K 0.927f #define EVO_CX 584.0f #define EVO_Y 6.0f static void EvolutionPanel_draw(void) { float sx = PSAnim_v(&PS.evoSX, PS.t); if (sx <= 0.001f) return; float w = SAFE_WIDTH + 0xe6, h = PS.evoH; rlPushMatrix(); rlTranslatef(EVO_CX, EVO_Y, 0); rlScalef(sx * EVO_K, EVO_K, 1); nine("frame1_c4.png", 12, (Rectangle){ -0.5f * w, 0, w, h }, rgb(0xffffcc, 0.75f)); // PanelBackgroundBlue const char *hd = tr("grimoire_header"); TS_text(hd, 0, 0x21, fit_size(hd, 16, 0xfa), 2 * PixelScale, 0, WHITE); int first = PS.pagesCurrent * 0x15 < PS.nEvo ? PS.pagesCurrent * 0x15 : PS.nEvo, last = first + 0x15 < PS.nEvo ? first + 0x15 : PS.nEvo, k = 0; for (int i = first; i < last; i++) { // createEvolutionDisplayList: 3 colonne da 7 EvoEl el[48]; int n = Evo_build(&PS.evo[i], el); float x0, bw = Evo_bounds(el, n, &x0), cx = (k / 7) * 0xf0 - 0xe6 - 0.5f * bw, cy = (k % 7) * PS.rowHeight + 0x55; float a = PS_disabledItem(&PS.evo[i]) ? 0.5f : 1; for (int pass = 0; pass < 2; pass++) // le evidenziazioni (addAt 0) sotto le icone for (int j = 0; j < n; j++) { if ((el[j].kind != 0) != (pass == 0)) continue; if (el[j].kind == 1) DrawCircle((int)(cx + el[j].x), (int)cy, 0x16, rgb(0xa5a64c, a)); else if (el[j].kind == 2) DrawRectangle((int)(cx + x0 - 0xf), (int)(cy - 0x10 - 5), (int)(bw + 0x1e), 0x20 + 0xa, rgb(0xa5a64c, a)); else TS_frame(el[j].atlas, el[j].frame, cx + el[j].x, cy, 0.5f, 0.5f, el[j].sc, 0, Fade(WHITE, el[j].alpha * a), 0); } k++; } if (PS.pagesAmount > 0) { // pageText: createEvolutionDisplayList riscrive subito il '1 / ' + pagesAmount + 1 del costruttore char pt[32]; snprintf(pt, sizeof(pt), "%d / %d", PS.pagesCurrent + 1, PS.pagesAmount + 1); TS_text(pt, 0, 0x1a4, 16, 1.5f * PixelScale, 0, WHITE); char an[16]; snprintf(an, sizeof(an), "arrow_%02d.png", (int)(PS.t / (1000.0f / 6)) % 8 + 1); const Frame *af = frame_get("UI", an); if (af) { Sprite a; sprite_init(&a, af, -0x32, 0x1a4); sprite_setOrigin(&a, 1, 0.5f), sprite_setScale(&a, 2), a.flipX = 1, a.scrollFactor0 = 1; scene_render_one(&a, (Shader){ 0 }); } TS_frame("UI", an, 0x32, 0x1a4, 0, 0.5f, 2, 0, WHITE, 0); if (PS.hlLeft) TS_nine("selectionSquareActive_03.png", 7, 7, -0x32 + 0xa - 0.5f * 0x24 * 1.5f, 0x1a4, 0x24, 0x24, 1.5f * PixelScale, 1.5f * PixelScale, 0, WHITE); if (PS.hlRight) TS_nine("selectionSquareActive_03.png", 7, 7, 0x32 - 0xa + 0.5f * 0x24 * 1.5f, 0x1a4, 0x24, 0x24, 1.5f * PixelScale, 1.5f * PixelScale, 0, WHITE); } rlPopMatrix(); } static void Evo_highlight(int left) { // highlightLeft / highlightRight PS.hlLeft = left, PS.hlRight = !left; UIButton *b = left ? &PS.UI_left : &PS.UI_right; UIGrid_SelectGameObject(b); OV.UI_selected = b; } static void Evo_prev(void *c) { (void)c; if (PS.pagesCurrent > 0) PS.pagesCurrent--; Evo_highlight(1); } static void Evo_next(void *c) { (void)c; if (PS.pagesCurrent < PS.pagesAmount) PS.pagesCurrent++; Evo_highlight(0); } // --- TreasureMapPanel: 440 x 440, zoom dello stage (0.5 se non c'e'); con la reliquia della mappa dello stage (Astral Stair) la mappa dettagliata static float Map_zoom(void) { return num(cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("stages"), Core.Stage->stageType), 0), "zoom", 0.5); } static void Map_xy(float wx, float wy, float w, float *x, float *y) { float z = Map_zoom(); *x = fmaxf(0, fminf(w, 0.5f * w - 3 * (Core.Player->s.x - wx) / (w * z))); *y = fmaxf(0, fminf(w, 0.5f * w - 3 * (Core.Player->s.y - wy) / (w * z))); } static void MapPanel_details(float X, float Y, float w) { // ShowDetailedMap: l'immagine dello stage, alpha 0.65, scala 1 - zoom, mascherata al riquadro cJSON *ts = cJSON_GetObjectItem(cJSON_GetArrayItem(cJSON_GetObjectItem(data_get("stages"), Core.Stage->stageType), 0), "tileset"); const char *relic = str(ts, "mapRelic"), *tex = str(ts, "detailsTexture"); if (!relic || !tex || !po_has("CollectedItems", relic)) return; static Texture2D t; static char key[64]; if (strcmp(key, tex)) { // load.image(detailsTexture, detailsPath): img/ if (t.id) UnloadTexture(t); t = LoadTexture(vs_path(TextFormat("img/%s", tex))); snprintf(key, sizeof(key), "%s", tex); } if (!t.id) return; float z = Map_zoom(), sc = 1 - z, u = Core.Player->s.x / num(ts, "SizeX", 1), v = Core.Player->s.y / num(ts, "SizeY", 1), ang = 0; if (po_is("SelectedInverse") && po_is("VisuallyInvertStages")) ang = 0xb4, u = 1 - u, v = 1 - v; // setAngle(180), origine (1 - x, 1 - y) float ox = u * t.width, oy = v * t.height; rlDrawRenderBatchActive(); BeginScissorMode((int)((X + 4) * GetScreenHeight() / (float)MENU_H + 0.5f * (GetScreenWidth() - MENU_W * GetScreenHeight() / (float)MENU_H)), (int)((Y + 4) * GetScreenHeight() / (float)MENU_H), (int)((w - 8) * GetScreenHeight() / (float)MENU_H), (int)((w - 8) * GetScreenHeight() / (float)MENU_H)); DrawTexturePro(t, (Rectangle){ 0, 0, t.width, t.height }, (Rectangle){ 0.5f * w, 0.5f * w, t.width * sc, t.height * sc }, (Vector2){ ox * sc, oy * sc }, ang, Fade(WHITE, 0.65f)); rlDrawRenderBatchActive(); EndScissorMode(); BeginScissorMode((int)(0.5f * (GetScreenWidth() - MENU_W * GetScreenHeight() / (float)MENU_H)), 0, (int)(MENU_W * GetScreenHeight() / (float)MENU_H), GetScreenHeight()); // il ritaglio della scena } static void MapPanel_draw(void) { float sy = PSAnim_v(&PS.mapSY, PS.t), w = 0x1b8, X = SAFE_CX - 0.5f * w, Y = 0x6e, z = Map_zoom(); if (sy <= 0.001f) return; rlPushMatrix(); rlTranslatef(X, Y, 0); rlScalef(PixelScale, sy * PixelScale, 1); nine("frame1_c2.png", 12, (Rectangle){ 0, 0, w, w }, rgb(0xffffcc, 0.75f)); if (sy >= 0.999f) MapPanel_details(X, Y, w); float S = Core.Stage->tilingTileset ? Core.Stage->tilingTileset->_SIZEX : 0x800; for (int i = -9; i < 9; i++) { // la griglia delle copie della mappa (senza maschera: le righe escono dal pannello) float gx = 0.5f * w - (Core.Player->s.x - S * i) / (w * z) * 3, gy = 0.5f * w - (Core.Player->s.y - S * i) / (w * z) * 3; DrawRectangle((int)gx, 8, 1, (int)(w - 8), Fade(BLACK, 0.1f)); DrawRectangle(8, (int)gy, (int)(w - 8), 1, Fade(BLACK, 0.1f)); } static const char *const SMALL[8] = { "VACUUM", "ROSARY", "OROLOGION", "NFT", "ROAST", "CLOVER", "GILDED", "GOLDFINGER" }; int si = 0; for (int i = 0; i < Core.PickupGroup.n; i++) { // gli oggetti, lampeggianti a sfasamento di 500 ms (ShowSmallMapIcons) Pickup *p = Core.PickupGroup.items[i]->owner; int small = 0; for (int k = 0; k < 8; k++) small |= !strcmp(p->itemType, SMALL[k]); if (!small) continue; cJSON *it = cJSON_GetObjectItem(data_get("items"), p->itemType); float x, y, d = 0x1f4 * si++, ph = PS.t < d ? 0 : fmodf(PS.t - d, 0x7d0) / 0x3e8; if (!it || !po_is("ShowSmallMapIcons")) continue; Map_xy(p->s.x, p->s.y, w, &x, &y); TS_frame(str(it, "texture"), str(it, "frameName"), x, y, 0.5f, 0.5f, 1, 0, Fade(WHITE, 1 - 0.8f * (ph < 1 ? ph : 2 - ph)), 0); } for (int i = 0; i < Core.PickupGroup.n; i++) { // i forzieri (quello dell'arcana col suo riquadro) Pickup *p = Core.PickupGroup.items[i]->owner; if (strcmp(p->itemType, "TREASURE")) continue; cJSON *it = cJSON_GetObjectItem(data_get("items"), "TREASURE"); float x, y; Map_xy(p->s.x, p->s.y, w, &x, &y); TS_frame(str(it, "texture"), p->hasArcana ? "BoxArcana.png" : str(it, "frameName"), x, y, 0.5f, 0.5f, 1, 0, WHITE, 0); } for (int i = 0; i < Core.n_StagePickups; i++) { // armi, reliquie e uova dello stage, scala 2 Pickup *p = Core.StagePickups[i]; cJSON *d = p->weaponType ? PS_w0(p->weaponType) : cJSON_GetObjectItem(data_get("items"), p->itemType); if (!d) continue; // (nell'originale: TypeError su un tipo senza dati) float x, y; Map_xy(p->s.x, p->s.y, w, &x, &y); TS_frame(str(d, "texture"), str(d, "frameName"), x, y, 0.5f, 0.5f, 2, 0, WHITE, 0); } TS_frame("UI", "mapCursor.png", 0.5f * w, 0.5f * w, 0.5f, 0.5f, 2, 0, WHITE, 0); rlPopMatrix(); } // --- MazzoInGamePanel --- static void PS_revealCard(void *ctx) { ArcCard_Reveal(ctx, 0x64, 1); } static void MazzoPanel_create(void) { float w = 0x78, h = 0x1b8; PS.mazzoSY = (PSAnim){ 0, 1, 0, 0x96 }; PS.nCards = 0; float step = Arcanas.n <= 3 ? h / 4 : h / (Arcanas.n + 1); for (int i = 0; i < Arcanas.n && i < 22; i++) { ArcCard *c = &PS.cards[PS.nCards++]; ArcCard_init(c, 0.5f * w, 0x10 + step * (1 + i), Arcana_frame(Arcanas.order[i]), Arcanas.order[i]); c->s.scrollFactor0 = 1; if (i == 0) PS_revealCard(c); else ARC_timer(0x32 * i, 0, 0, PS_revealCard, c); } } static void MazzoPanel_draw(void) { float sy = PSAnim_v(&PS.mazzoSY, PS.t), w = 0x78, h = 0x1b8; if (sy <= 0.001f) return; rlPushMatrix(); rlTranslatef(MENU_W - 0x7e, 0x6e, 0); rlScalef(PixelScale, sy * PixelScale, 1); nine("frame1_c2.png", 12, (Rectangle){ 0, 0, w, h }, Fade(WHITE, 0.75f)); TS_frame("items", "Tarots.png", 0.5f * w, 0x20, 0.5f, 0.5f, 2, 0, WHITE, 0); for (int i = 0; i < PS.nCards; i++) ARC_drawCard(&PS.cards[i], 0, 0, 1); if (Arcanas.n <= 3) for (int i = Arcanas.n; i < 3; i++) TS_frame("randomazzo", "deback.png", 0.5f * w, 0x10 + h / 4 * (1 + i), 0.5f, 0.5f, 1, 0, Fade(WHITE, 0.5f), 0); rlPopMatrix(); } // --- la scena --- static void PS_showMapButtons(int v) { PS.ShowPickupsButton.visible = PS.ShowGuidesButton.visible = v; if (PS.hasEvolutionGuide && v) PS.OpenGrimoireButton.visible = 1; } static void PS_OpenMap(void); static void PS_OpenGrimoire(void); enum { PS_PEND_NONE, PS_PEND_MAP, PS_PEND_GRIMOIRE }; static void PS_OpenMap(void) { if (PS.evoExists && PS.evoOpen) { // chiude il grimorio e apre la mappa dopo 200 ms PS.evoOpen = 0, PS.evoSX = (PSAnim){ PSAnim_v(&PS.evoSX, PS.t), 0, PS.t, 0xc8 }; PS.OpenMapFromGrimoireButton.visible = 0; PS.pending = PS_PEND_MAP, PS.pendingAt = PS.t + 0xc8; } else { PS.mapOpen = 1, PS.mapSY = (PSAnim){ 0, 1, PS.t, 0xc8 }; PS_showMapButtons(1); } PauseScene_MakeUIGrid(1); } static void PS_OpenGrimoire(void) { PS.OpenGrimoireButton.visible = 0; if (PS.mapExists && PS.mapOpen) { // chiude la mappa (100 ms) e apre il grimorio dopo 200 ms, un po' piu' in alto PS.ShowPickupsButton.visible = PS.ShowGuidesButton.visible = 0; PS.mapOpen = 0, PS.mapSY = (PSAnim){ PSAnim_v(&PS.mapSY, PS.t), 0, PS.t, 0x64 }; PS.pending = PS_PEND_GRIMOIRE, PS.pendingAt = PS.t + 0xc8; return; } if (!PS.evoExists) EvolutionPanel_create(0x6e, 0x1b8); PS.evoOpen = 1, PS.evoSX = (PSAnim){ 0, 1, PS.t, 0xc8 }; PauseScene_MakeUIGrid_Grimoire(); } static void PS_onOpenGrimoire(void *c) { (void)c; if (PS.OpenGrimoireButton.visible) PS_OpenGrimoire(); } static void PS_onOpenMap(void *c) { (void)c; if (PS.OpenMapFromGrimoireButton.visible) PS_OpenMap(); } static void PS_onShowPickups(void *c) { // mostra/nasconde gli oggetti piccoli sulla mappa (void)c; if (!PS.ShowPickupsButton.visible) return; cJSON_ReplaceItemInObject(PlayerOptions, "ShowSmallMapIcons", cJSON_CreateBool(!po_is("ShowSmallMapIcons"))); } static void PS_onShowGuides(void *c) { // le frecce verso i pickup (ShowPickups), poi riprende (void)c; if (!PS.ShowGuidesButton.visible) return; cJSON_ReplaceItemInObject(PlayerOptions, "ShowPickups", cJSON_CreateBool(!po_is("ShowPickups"))); SceneManager_ResumeFromPause(); } static void PauseScene_create(void) { memset(&PS, 0, sizeof(PS)); PS.active = 1; PS.hasRelicMap = Collected("RELIC_MAP"), PS.hasEvolutionGuide = Collected("RELIC_GRIMOIRE"), PS.hasRandomazzo = RandomazzoEnabled(); float bx = PS.butX = 0.5f * MENU_W, by = PS.butY = MENU_H - 44 - 0x24; // Vita: sopra la barra dei tasti (l'originale MENU_H - 64) UIButton_set(&PS.OptionsButton, "OptionsButton", bx - 0x78, by, 0x60, 0x20, 2 * PixelScale, 0.5f, 0.5f); UIButton_set(&PS.ResumeButton, "OptionsButton", bx + 0x78, by, 0x60, 0x20, 2 * PixelScale, 0.5f, 0.5f); if (PS_simple()) { // Vita: senza mappa ne' grimorio, Riprendi al centro sotto il personaggio e Opzioni sotto, in colonna PS.ResumeButton.x = bx, PS.ResumeButton.y = 0.64f * MENU_H; PS.OptionsButton.x = bx, PS.OptionsButton.y = 0.64f * MENU_H + 0x50, PS.OptionsButton.sc = 1.5f * PixelScale; } if (PS.hasRelicMap) { PS.OptionsButton.x = bx - 0xfa, PS.OptionsButton.y = by + 0xa, PS.OptionsButton.sc = 1.5f * PixelScale; PS.ResumeButton.x = bx + 0x190, PS.ResumeButton.y = by + 0xa; } if (PS.hasEvolutionGuide) { UIButton_set(&PS.OpenGrimoireButton, "OptionsButton", bx + 0xc8, by + 0xa, 0x60, 0x20, 1.5f * PixelScale, 0.5f, 0.5f); UIButton_set(&PS.OpenMapFromGrimoireButton, "OptionsButton", bx + 0xc8, by + 0xa, 0x60, 0x20, 1.5f * PixelScale, 0.5f, 0.5f); PS.OpenMapFromGrimoireButton.visible = 0; if (!PS.hasRelicMap) PS_OpenGrimoire(); } if (PS.hasRelicMap) { PS.mapExists = 1; UIButton_set(&PS.ShowPickupsButton, "OptionsButton", bx - 0x64, by + 0xa, 0x60, 0x20, 1.5f * PixelScale, 0.5f, 0.5f); UIButton_set(&PS.ShowGuidesButton, "OptionsButton", bx + 0x32, by + 0xa, 0x60, 0x20, 1.5f * PixelScale, 0.5f, 0.5f); PS_OpenMap(); } if (PS.hasRandomazzo) MazzoPanel_create(); } static void PauseScene_EnableButtons(void) { UIButton_on(&PS.OptionsButton, PS_onOptions, NULL); UIButton_on(&PS.ResumeButton, PS_onResume, NULL); if (PS.hasEvolutionGuide) UIButton_on(&PS.OpenGrimoireButton, PS_onOpenGrimoire, NULL), UIButton_on(&PS.OpenMapFromGrimoireButton, PS_onOpenMap, NULL); if (PS.hasRelicMap) UIButton_on(&PS.ShowPickupsButton, PS_onShowPickups, NULL), UIButton_on(&PS.ShowGuidesButton, PS_onShowGuides, NULL); PauseScene_MakeUIGrid(0); // (sic) anche col grimorio gia' aperto: la griglia diventa quella della mappa if (getenv("VS_PAUSEOPT")) PauseOptions_open(); // sviluppo: le opzioni della pausa aperte subito } static void PauseScene_update(float delta) { PS.t += delta; ARC_clock(delta); // il clock e i tween della scena (le carte del Mazzo) if (!PS.enabled && PS.t >= 0x64) PS.enabled = 1, PauseScene_EnableButtons(); // EnableButtons dopo 100 ms if (PS.pending && PS.t >= PS.pendingAt) { int p = PS.pending; PS.pending = 0; if (p == PS_PEND_MAP) PS.mapOpen = 1, PS.mapSY = (PSAnim){ 0, 1, PS.t, 0xc8 }, PS_showMapButtons(1); else { if (!PS.evoExists) EvolutionPanel_create(0x61, 0x1b8 + 0xd); PS.evoOpen = 1, PS.evoSX = (PSAnim){ 0, 1, PS.t, 0xc8 }; PS.OpenMapFromGrimoireButton.visible = 1; PauseScene_MakeUIGrid_Grimoire(); } } if (PS.optionsOpen) { // le pagine delle opzioni al posto dei bottoni della pausa Sound_Update(delta); Overlay_update(delta); Options_update(delta); return; } if (PS.evoExists && PS.pagesAmount > 0) { // le frecce delle pagine, dentro il pannello (centro in SAFE_CX + 40) float ex = EVO_CX, ey = EVO_Y + 0x1a4 * EVO_K, sx = PSAnim_v(&PS.evoSX, PS.t) * EVO_K; PS.UI_left.x = ex - 0x32 * sx, PS.UI_left.y = ey, PS.UI_right.x = ex + 0x32 * sx, PS.UI_right.y = ey; if (!PS.UI_left.interactive) UIButton_on(&PS.UI_left, Evo_prev, NULL), UIButton_on(&PS.UI_right, Evo_next, NULL); if (OV.UI_selected != UIGrid.previousGameObject) { if (OV.UI_selected == &PS.UI_left) PS.hlLeft = 1, PS.hlRight = 0, Overlay_ToggleCursorsVisibility(0); else if (OV.UI_selected == &PS.UI_right) PS.hlLeft = 0, PS.hlRight = 1, Overlay_ToggleCursorsVisibility(0); else PS.hlLeft = PS.hlRight = 0, Overlay_ToggleCursorsVisibility(1); UIGrid.previousGameObject = OV.UI_selected; } } Sound_Update(delta); Overlay_update(delta); if (!PS.active) return; UIButton *B[] = { &PS.OptionsButton, &PS.ResumeButton, &PS.OpenGrimoireButton, &PS.OpenMapFromGrimoireButton, &PS.ShowPickupsButton, &PS.ShowGuidesButton, &PS.UI_left, &PS.UI_right }; for (int i = 0; i < 8; i++) if (B[i]->interactive && UIButton_clicked(B[i])) break; } static void PS_button(UIButton *b, const char *key, float tsc, float maxW) { if (!b->visible || !b->frame) return; UIButton_draw(b, 1); ui_text(tr(key), b->x, b->y, tsc, maxW, 0.5f, 0.5f, WHITE); } static void PauseScene_draw(void) { DrawRectangle(0, 0, MENU_W, MENU_H, Fade(BLACK, 0.5f)); // blackDot 1.1 x renderer, alpha 0.5 if (PS.optionsOpen) { DrawRectangle(0, 0, MENU_W, MENU_H, Fade(BLACK, 0.3f)); // Vita: il gioco sotto un po' piu' scuro, per leggere la lista Options_draw(); vui_prompt_bar(); Overlay_draw(); return; } PS_button(&PS.OptionsButton, "topBar_options", (PS.hasRelicMap || PS_simple() ? 1.5f : 2) * PixelScale, 0x5a); PS_button(&PS.ResumeButton, "pause_resume", 2 * PixelScale, 0x5a); if (PS.hasEvolutionGuide) { PS_button(&PS.OpenGrimoireButton, "pause_openGrimoire", PixelScale, 0x8c); PS_button(&PS.OpenMapFromGrimoireButton, "pause_openMap", PixelScale, 0x8c); } if (PS.hasRelicMap) { MapPanel_draw(); PS_button(&PS.ShowPickupsButton, po_is("ShowSmallMapIcons") ? "pause_hidePickups" : "pause_showPickups", PixelScale, 0x8c); PS_button(&PS.ShowGuidesButton, po_is("ShowPickups") ? "pause_hideGuides" : "pause_showGuides", PixelScale, 0x8c); } if (PS.evoExists) EvolutionPanel_draw(); if (PS.hasRandomazzo) MazzoPanel_draw(); vui_prompt_bar(); Overlay_draw(); } // ============================================================================ // 0x135fd: PauseStatsScene (con piu' di 5 armi sbloccate): CharWeaponsPanel (0xe109) e CharStatsPanel.AssignPlayer. // La lanciano la pausa, il level-up e il draft delle arcane; a ogni ripresa si ricrea (qui: si ricalcola a ogni disegno) // ============================================================================ static float CharWeaponsPanel_row(Weapon **list, int n, float y0, int passive) { for (int i = 0; i < n; i++) { Weapon *w = list[i]; cJSON *wd = cJSON_GetObjectItem(data_get("weapons"), w->bulletType), *b = cJSON_GetArrayItem(wd, 0); int lv = cJSON_GetArraySize(wd), banished = 0; for (int k = 0; k < LUF.n_banished; k++) banished |= !strcmp(LUF.BanishedWeapons[k], w->bulletType); float x = 0x14 + i % 6 * 0x20, y = y0 + 0x40 * (i / 6); TS_frame("UI", passive ? "passiveBG.png" : "weaponBG.png", x, y, 0.5f, 0.5f, 2, 0, w->level >= lv ? YELLOW : WHITE, 0); TS_frame(str(b, "texture"), str(b, "frameName"), x, y, 0.5f, 0.5f, 2, 0, WHITE, 0); Weapon *own = Core_GetWeapon(w->bulletType); if (own && own->limitBreakLevel > 0) { // Limit Break: il numero del livello al posto dei pallini, ombra 2,2 e tinta 0xfaff95 const char *s = TextFormat("%d", own->level + own->limitBreakLevel); float sz = fit_size(s, 16, 0x18); text_at(s, x + 2, y + 0x1c + 2, sz, 0.5f, 0.5f, BLACK); text_at(s, x, y + 0x1c, sz, 0.5f, 0.5f, hexc(0xfaff95, 1)); } else for (int j = 0; j < lv; j++) { const char *f = w->level <= j ? (banished ? "weaponLevelBanished.png" : "weaponLevelEmpty.png") : "weaponLevelFull.png"; TS_frame("UI", f, x - 8 + j % 3 * 8, y + 0x14 + 8 * (j / 3), 0.5f, 0.5f, 1, 0, WHITE, 0); } } return y0 + 0x40 * ceilf(n / 6.0f); } static void PauseStatsScene_draw(float t) { if (cJSON_GetArraySize(po("UnlockedWeapons")) <= 5) return; Weapon *wl[16], *pl[24]; int nw = 0, np = 0; for (int i = 0; i < Core.n_weapons; i++) { if (Core.Weapons[i]->isPowerUp) { if (np < 22) pl[np++] = Core.Weapons[i]; } else if (nw < 16) wl[nw++] = Core.Weapons[i]; } Weapon *so = Core_GetHiddenWeapon("SOLES"), *ju = Core_GetHiddenWeapon("JUBILEE"); if (so) pl[np++] = so; if (ju) pl[np++] = ju; int li = -1, ri = -1; // LEFT e RIGHT in testa for (int i = 0; i < np; i++) { if (!strcmp(pl[i]->bulletType, "LEFT")) li = i; if (!strcmp(pl[i]->bulletType, "RIGHT")) ri = i; } if (li >= 0 && ri >= 0) { Weapon *r = pl[ri]; memmove(&pl[1], &pl[0], ri * sizeof(*pl)), pl[0] = r; for (int i = 0; i < np; i++) if (!strcmp(pl[i]->bulletType, "LEFT")) li = i; Weapon *l = pl[li]; memmove(&pl[1], &pl[0], li * sizeof(*pl)), pl[0] = l; } float wh = 0x40 * ceilf(nw / 6.0f) + 0x40 * ceilf(np / 6.0f), sc = lerp01(t, 0, 0xc8); rlPushMatrix(); rlTranslatef(8, 0x20, 0); rlScalef(sc, sc, 1); // WeaponsPanel.Open: scala 0 -> 1 in 200 ms nine("frame1_c2.png", 12, (Rectangle){ 0, 0, 0xc8, wh }, Fade(WHITE, 0.75f)); float y = CharWeaponsPanel_row(wl, nw, 0x14, 0); CharWeaponsPanel_row(pl, np, y, 1); rlPopMatrix(); static CharStatsPanel sp; CharStatsPanel_init(&sp); CharStatsPanel_AssignData(&sp, Core.Player->characterType); // costruttore CharStatsPanel_AssignPlayer(&sp, Core.Player); CharStatsPanel_draw(&sp, 8, 0x20 + wh, lerp01(t, 0, 0x96), 0.75f); } static void SceneManager_EnterPause(void) { PauseScene_create(); } // pausa della MainScene, FreezeSnapshot, launch PauseScene + PauseStatsScene // ============================================================================ // 0x886d: OptionsScene (dal menu; pagine 0x8833 e 0xbb60) e le opzioni della pausa (dentro la PauseScene 0x1266e: pagine 0x38f1 e // 0xdad8 sulla OptionPage 0x85be, con Riprendi ed Esci). Cursori 0x14183 (sinistra/destra a passi di 0.1, trascinamento: il valore // si applica al rilascio), levette 0x36e3, lingue 0x4103 (Lang.langCodeList / langNameList). // Vita: le due pagine in una sola lista a sinistra; a destra le lingue (menu) o Riprendi ed Esci (pausa). // Saltati (solo PC o mobile): schermo intero, joystick visibile, Twitch, Ctrl+F2 x7 (azzera il salvataggio). // ============================================================================ enum { OPT_SLIDER, OPT_TOGGLE, OPT_TEXT, OPT_BG, OPT_LANG, OPT_ZOOM, OPT_PROFILE }; static const float OPT_ZOOMS[] = { 0.85f, 1, 1.15f, 1.3f, 1.5f }; typedef struct { int kind; const char *label, *key; float value; UIButton box; } OptRow; #define OPT_MAX 16 // menu principale: fino a 15 righe (occhiali 3D + Specchio) #define OPT_ROW_H 46 #define OPT_SX0 330.0f // il cursore: bounds da 330 a 490 #define OPT_SW 160.0f static struct { int active, pause, n, gridMade, drag; float t; OptRow rows[OPT_MAX]; UIButton bg, QuitButton, ResumeButton, langs[16], RestoreBackupButton; int nLangs, restoreState; // 0 Recupero dati, 1 Conferma (in attesa 500 ms), 2 Conferma attivo float restoreAt; float langAt; // Vita: font e salvataggio della lingua 350 ms dopo l'ultimo passo (scorrere le lingue era lento) } OP; static void SceneManager_RecoveryFromOptions(void); static void Opt_onRestore(void *c) { // ChangeRestoreButtonToConfirm, poi RecoveryConfirmed (void)c; Sound_PlaySimple("ClickIn", 0); SceneManager_RecoveryFromOptions(); // Vita: la conferma a due tocchi resta solo sulle azioni che cancellano } static void SceneManager_ResumeFromPause(void); static void SceneManager_QuitFromPauseMenu(void); static void Opt_save(void) { PlayerOptions_Save(); } // PlayerOptions.SaveOptions static void Opt_apply(OptRow *r) { // le change* delle pagine if (r->kind == OPT_SLIDER) { po_set(r->key, r->value); if (!strcmp(r->key, "SoundsVolume")) SoundsVolume = r->value; else { // changeBGM: Sound.UpdateMusicVolume(CurrentBGM, value) MusicVolume = r->value; if (BGM.playing) BGM.volume = BGM.currentVolume * MusicVolume, BGM.fadeDur = 0, au_music_volume(&BGM.music, BGM.volume); } } else if (r->kind == OPT_BG) { // changeDISABLEBG: disableMovingBackground rimette sempre disableMovingBG a true (sic) FB_disableMovingBG = r->value != 0; if (Core.Stage->fancyBG->DisableMovingBackground) Core.Stage->fancyBG->DisableMovingBackground(); r->value = FB_disableMovingBG; // toggle.setFrame(disableMovingBG) return; // niente suono ne' salvataggio } else { po_setb(r->key, r->value != 0); Sound_PlaySimple("ClickIn", 0); } Opt_save(); } static void Opt_flushLang(void) { if (OP.langAt) OP.langAt = 0, Lang_setLangCode(Lang_getLangCode()), vs_load_font(); } // anche uscendo prima dei 350 ms static void Opt_setLang(const char *code) { // closeLangDropDown: lingua diversa -> Language, ClickIn, SaveOptions, UpdateOptionLang if (!code || !strcmp(code, Lang_getLangCode())) return; Sound_PlaySimple("ClickIn", 0); lang_load(code); // i testi cambiano subito; Lang_setLangCode (salva) e vs_load_font in Options_update OP.langAt = OP.t + 0x15e; if (!OP.pause) TB_title = tr("options_header"); // i testi si ridisegnano gia' nella lingua nuova if (OP.RestoreBackupButton.visible) OP.restoreState = 0, UIButton_on(&OP.RestoreBackupButton, Opt_onRestore, NULL); // ChangeRestoreButtonToRecovery } static int Opt_langIndex(void) { for (int i = 0; Lang_codeAt(i); i++) if (!strcmp(Lang_codeAt(i), Lang_getLangCode())) return i; return 0; } static void Opt_langStep(int d) { int n = 0; while (Lang_codeAt(n)) n++; if (n) Opt_setLang(Lang_codeAt((Opt_langIndex() + d + n) % n)); } static void Opt_zoomStep(OptRow *r, int d) { int n = sizeof(OPT_ZOOMS) / sizeof(*OPT_ZOOMS), i = 0; while (i < n - 1 && OPT_ZOOMS[i] < r->value - 0.01f) i++; r->value = OPT_ZOOMS[(i + d + n) % n]; po_set(r->key, r->value); Sound_PlaySimple("ClickIn", 0); Opt_save(); } static void Opt_onZoomNext(void *c) { Opt_zoomStep(c, 1); } static void Opt_onToggle(void *c) { OptRow *r = c; r->value = !r->value; Opt_apply(r); } // OptionToggle.onToggle static void Opt_onLangNext(void *c) { (void)c; Opt_langStep(1); } static void Opt_onLangPick(void *c) { Opt_setLang(Lang_codeAt((int)(intptr_t)c)); } static OptRow *Opt_rowOf(UIButton *b) { for (int i = 0; i < OP.n; i++) if (&OP.rows[i].box == b) return &OP.rows[i]; return NULL; } static void Opt_zoomStep(OptRow *r, int d); static void Opt_step(UIButton *b, int d) { // onLeft / onRight: manualLeft / manualRight dei cursori (Vita: anche la lingua) OptRow *r = Opt_rowOf(b); if (!r) return; if (r->kind == OPT_LANG) { Opt_langStep(d); return; } if (r->kind == OPT_ZOOM) { Opt_zoomStep(r, d); return; } if (r->kind == OPT_PROFILE) { Opt_onToggle(r); return; } // due valori: sinistra e destra cambiano if (r->kind != OPT_SLIDER) return; r->value = d < 0 ? fmaxf(r->value - 0.1f, 0) : fminf(r->value + 0.1f, 1); Opt_apply(r); } static void Opt_onLeft(UIButton *b) { Opt_step(b, -1); } static void Opt_onRight(UIButton *b) { Opt_step(b, 1); } static void Opt_onResume(void *c) { (void)c; SceneManager_ResumeFromPause(); } // resumeClicked static void Opt_onQuit(void *c) { // quitClicked (void)c; Core_OnPlayerQuit(); SceneManager_QuitFromPauseMenu(); po_setb("ShowQuitDescription", 0); Sound_PlaySimple("ClickOut", 0); Opt_save(); } static void Opt_cancelMenu(void) { if (TB.BackButton.onDown) TB.BackButton.onDown(TB.BackButton.ctx); } // BackButton._events.pointerdown.fn() static void Opt_cancelPause(void) { Opt_onResume(NULL); } // ResumeButton._events.pointerdown.fn() static void Opt_add(int kind, const char *label, const char *key, float value) { if (OP.n >= OPT_MAX) return; // oltre si scriveva su bg e pulsanti: crash aprendo le Opzioni OptRow *r = &OP.rows[OP.n]; r->kind = kind, r->label = label, r->key = key, r->value = value; UIButton_set(&r->box, "", 24, 72 + OP.n * OPT_ROW_H, 552, OPT_ROW_H - 4, 1, 0, 0); if (kind == OPT_TOGGLE || kind == OPT_TEXT || kind == OPT_BG || kind == OPT_PROFILE) UIButton_on(&r->box, Opt_onToggle, r); else if (kind == OPT_ZOOM) UIButton_on(&r->box, Opt_onZoomNext, r); else if (kind == OPT_LANG) UIButton_on(&r->box, Opt_onLangNext, NULL); // Vita: niente tendina, croce = lingua seguente else r->box.interactive = 1; // il cursore si trascina, la croce non fa nulla OP.n++; } static void Opt_layout(void) { // le righe si stringono per stare nel riquadro float h = fminf(OPT_ROW_H, 414.0f / OP.n); for (int i = 0; i < OP.n; i++) OP.rows[i].box.y = 72 + i * h, OP.rows[i].box.h = h - 4; } static void Options_MakeUIGrid(void) { // MakeUIGrid (menu: Indietro in cima) / MakeUIGrid_Options (pausa: Esci e Riprendi in fondo) Overlay_DestroyGrid(); Opt_layout(); int top = !OP.pause, rb = OP.RestoreBackupButton.visible, h = OP.n + top + OP.pause + rb; Overlay_MakeUIGrid(2, h, OP.pause); for (int c = 0; c < 2; c++) { if (top) UIGrid_SetContents(c, 0, &TB.BackButton, 0); for (int i = 0; i < OP.n; i++) UIGrid_SetContents(c, top + i, &OP.rows[i].box, 0); if (rb) UIGrid_SetContents(c, h - 1, &OP.RestoreBackupButton, 0); // (nell'originale fuori dalla griglia: col pad non si raggiungeva) } UIButton *sel = &OP.rows[0].box; // (l'originale parte da Indietro: sulla Vita la freccia coprirebbe il titolo) if (getenv("VS_OPTSEL") && atoi(getenv("VS_OPTSEL")) < OP.n) sel = &OP.rows[atoi(getenv("VS_OPTSEL"))].box; // sviluppo: la riga scelta if (OP.pause) UIGrid_SetContents(0, OP.n, &OP.QuitButton, 0), UIGrid_SetContents(1, OP.n, &OP.ResumeButton, 0), sel = &OP.ResumeButton; Overlay_ToggleCursorsVisibility(1); UIGrid_SelectGameObject(sel); OV.UI_selected = sel; UIGrid.onLeft = Opt_onLeft, UIGrid.onRight = Opt_onRight; OV.OnCancelCallback = OP.pause ? Opt_cancelPause : Opt_cancelMenu; if (OP.pause) vui_set_prompts((VPrompt[]){ { G_CROSS, "vui_select" }, { G_CIRCLE, "pause_resume" } }, 2); else vui_set_prompts((VPrompt[]){ { G_CROSS, "vui_select" }, { G_CIRCLE, "vui_back" } }, 2); OP.gridMade = 1; } static void Options_create(int pause) { memset(&OP, 0, sizeof(OP)); OP.active = 1, OP.pause = pause, OP.drag = -1; UIButton_set(&OP.bg, "MenuBackground", 20, 62, 560, 428, 1, 0, 0); Opt_add(OPT_SLIDER, "options_sounds", "SoundsVolume", (float)po_num("SoundsVolume")); Opt_add(OPT_SLIDER, "options_music", "MusicVolume", (float)po_num("MusicVolume")); Opt_add(OPT_TOGGLE, "options_flashing_VFX", "FlashingVFXEnabled", po_is("FlashingVFXEnabled")); Opt_add(OPT_ZOOM, "vui_zoom", "ViewZoom", View_zoom()); Opt_add(OPT_TOGGLE, "vui_touchmove", "TouchMove", po_is("TouchMove")); Opt_add(OPT_TOGGLE, "vui_sidehud", "SideHUD", po_is("SideHUD")); Opt_add(OPT_TOGGLE, "vui_fullscreen", "FullScreenView", po_is("FullScreenView")); // vale dalla partita successiva Opt_add(OPT_PROFILE, "vui_profile", "QualityMode", po_is("QualityMode")); // Performance (fps alti) / Grafica (attesa GPU, niente lampi) if (Collected("RELIC_3DGLASSES")) Opt_add(OPT_PROFILE, "vui_view", "View3D", po_is("View3D")); // Vista 2D | 3D (beta): dopo gli occhiali buffi if (pause) { // 0x38f1 + 0xdad8 Opt_add(OPT_TOGGLE, "options_damageNumbers", "DamageNumbersEnabled", po_is("DamageNumbersEnabled")); const FancyBG *fb = Core.Stage->fancyBG; if (fb && fb->HasMovingBG && fb->HasMovingBG()) Opt_add(OPT_BG, "disableMovingBackground", NULL, po_is("JoystickVisible")); // (sic) parte da JoystickVisible Opt_add(OPT_TOGGLE, "options_screenShake", "ScreenShakeEnabled", po_is("ScreenShakeEnabled")); UIButton_set(&OP.ResumeButton, "GreenButton", 612, 300, 316, 66, 1, 0, 0); UIButton_set(&OP.QuitButton, "BackButton", 612, 384, 316, 52, 1, 0, 0); UIButton_on(&OP.ResumeButton, Opt_onResume, NULL), UIButton_on(&OP.QuitButton, Opt_onQuit, NULL); } else { // 0x8833 + 0xbb60 (isProgressVisible: sempre vero, sic) Opt_add(OPT_TOGGLE, "options_reducephysics", "ReducePhysics", po_is("ReducePhysics")); Opt_add(OPT_TEXT, "options_classicmusic", "ClassicMusic", po_is("ClassicMusic")); Opt_add(OPT_TOGGLE, "options_damageNumbers", "DamageNumbersEnabled", po_is("DamageNumbersEnabled")); Opt_add(OPT_TOGGLE, "options_hideProgress", "HideProgress", po_is("HideProgress")); if (po_has("CollectedItems", "RELIC_MIRROR")) Opt_add(OPT_TOGGLE, "options_invertStages", "VisuallyInvertStages", po_is("VisuallyInvertStages")); Opt_add(OPT_LANG, "options_language", NULL, 0); for (OP.nLangs = 0; Lang_codeAt(OP.nLangs) && OP.nLangs < 16; OP.nLangs++) { // la scheda delle lingue: due colonne UIButton_set(&OP.langs[OP.nLangs], "OptionsButton", 612 + OP.nLangs % 2 * 162, 116 + OP.nLangs / 2 * 50, 154, 44, 1, 0, 0); UIButton_on(&OP.langs[OP.nLangs], Opt_onLangPick, (void *)(intptr_t)OP.nLangs); } UIButton_set(&OP.RestoreBackupButton, "BackButton", 612, 428, 316, 50, 1, 0, 0); OP.RestoreBackupButton.visible = 1; // Vita: da qui si importa anche il salvataggio del PC if (OP.RestoreBackupButton.visible) UIButton_on(&OP.RestoreBackupButton, Opt_onRestore, NULL); TB_title = tr("options_header"); } } static float Opt_sliderValue(float mx) { return fminf(fmaxf((mx - OPT_SX0) / OPT_SW, 0), 1); } // onDrag: x dentro i bounds static void Options_update(float delta) { if (!OP.active) return; OP.t += delta; if (!OP.gridMade && OP.t >= 0x64) Options_MakeUIGrid(); // EnableOptionButtons dopo 100 ms if (!OP.gridMade) return; const char *dev = getenv("VS_PAUSEOPT"); // sviluppo: VS_PAUSEOPT=quit esce dalla partita dopo 1 s if (OP.pause && dev && !strcmp(dev, "quit") && OP.t >= 0x3e8) { Opt_onQuit(NULL); return; } if (OP.langAt && OP.t >= OP.langAt) Opt_flushLang(); // Lang.FONTFAMILY e i glifi della lingua nuova if (OP.restoreState == 1 && OP.t >= OP.restoreAt) OP.restoreState = 2, UIButton_on(&OP.RestoreBackupButton, Opt_onRestore, NULL); Vector2 m = menu_pointer(); if (ptr_pressed()) { for (int i = 0; i < OP.n; i++) { OptRow *r = &OP.rows[i]; if (!UIButton_hit(&r->box, m)) continue; UIGrid_SelectGameObject(&r->box), OV.UI_selected = &r->box; if (r->kind == OPT_SLIDER) { if (m.x >= OPT_SX0 - 16) OP.drag = i, r->value = Opt_sliderValue(m.x); } else if (r->kind == OPT_LANG) { if (m.x >= OPT_SX0 - 16) Opt_langStep(m.x < 0.5f * (OPT_SX0 + 562) ? -1 : 1); } // le due frecce else r->box.onDown(r->box.ctx); return; } if (OP.pause) { if (!UIButton_clicked(&OP.ResumeButton)) UIButton_clicked(&OP.QuitButton); } else if (!UIButton_clicked(&OP.RestoreBackupButton)) for (int i = 0; i < OP.nLangs; i++) if (UIButton_clicked(&OP.langs[i])) break; } else if (OP.drag >= 0 && ptr_down()) OP.rows[OP.drag].value = Opt_sliderValue(m.x); else if (OP.drag >= 0) Opt_apply(&OP.rows[OP.drag]), OP.drag = -1; // onDrop: callback(value) } static void Options_draw(void) { if (!OP.active) return; if (OP.pause) text_at(tr("options_header"), 24, 34, 32, 0, 0.5f, rgb(VUI_GOLD, 1)); // nella pausa non c'e' la barra in alto UIButton_draw(&OP.bg, 1); for (int i = 0; i < OP.n; i++) { OptRow *r = &OP.rows[i]; float y = r->box.y, cy = y + 0.5f * bH(&r->box); if (i) DrawRectangle(36, (int)y - 3, 528, 1, rgb(0x8a6a2a, 0.5f)); const char *l = vui_tr(r->label); text_at(l, 36, cy, fit_size(l, 24, r->kind == OPT_SLIDER ? 280 : 300), 0, 0.5f, WHITE); if (r->kind == OPT_SLIDER) { DrawRectangle((int)OPT_SX0, (int)cy - 3, (int)OPT_SW, 6, rgb(0x1a1020, 1)); DrawRectangle((int)OPT_SX0, (int)cy - 3, (int)(OPT_SW * r->value), 6, rgb(VUI_GOLD, 1)); TS_frame("UI", "menu_square_flat_24.png", OPT_SX0 + OPT_SW * r->value, cy, 0.5f, 0.5f, 1.25f, 0, WHITE, 0); text_at(TextFormat("%d%%", (int)roundf(100 * r->value)), 562, cy, 22, 1, 0.5f, WHITE); } else if (r->kind == OPT_ZOOM) { float cx = 0.5f * (OPT_SX0 + 562); text_at("<", OPT_SX0, cy, 26, 0, 0.5f, rgb(VUI_GOLD, 1)), text_at(">", 562, cy, 26, 1, 0.5f, rgb(VUI_GOLD, 1)); text_at(TextFormat("%d%%", (int)roundf(100 * r->value)), cx, cy, 24, 0.5f, 0.5f, WHITE); } else if (r->kind == OPT_LANG) { const char *n = Lang_native(Lang_getLangCode()); float cx = 0.5f * (OPT_SX0 + 562); text_at("<", OPT_SX0, cy, 26, 0, 0.5f, rgb(VUI_GOLD, 1)), text_at(">", 562, cy, 26, 1, 0.5f, rgb(VUI_GOLD, 1)); text_at(n, cx, cy, fit_size(n, 24, 190), 0.5f, 0.5f, WHITE); } else if (r->kind == OPT_PROFILE) { int view = !strcmp(r->key, "View3D"); // lo stesso selettore a due valori per Vista 2D | 3D const char *v = vui_tr(view ? (r->value ? "vui_view_3d" : "vui_view_2d") : r->value ? "vui_profile_gfx" : "vui_profile_perf"); float cx = 0.5f * (OPT_SX0 + 562); text_at("<", OPT_SX0, cy, 26, 0, 0.5f, rgb(VUI_GOLD, 1)), text_at(">", 562, cy, 26, 1, 0.5f, rgb(VUI_GOLD, 1)); text_at(v, cx, cy, fit_size(v, 24, 190), 0.5f, 0.5f, WHITE); } else if (r->kind == OPT_TEXT) { // createTextToggle: Classico / Elaborazione Blast const char *v = tr(r->value ? "options_SFX_classic" : "options_SFX_blast"); text_at(v, 562, cy, fit_size(v, 22, 200), 1, 0.5f, rgb(VUI_GOLD, 1)); } else { TS_frame("UI", "menu_checkbox_24_bg.png", 544, cy, 0.5f, 0.5f, 1.5f, 0, WHITE, 0); TS_frame("UI", r->value ? "yes16.png" : "no16.png", 544, cy, 0.5f, 0.5f, 1.5f, 0, WHITE, 0); } } nine("frame5_c4.png", 12, (Rectangle){ 596, 62, 344, 428 }, WHITE); // la scheda a destra if (OP.pause) { UIButton_draw(&OP.ResumeButton, 1), UIButton_draw(&OP.QuitButton, 1); text_at(tr("pause_resume"), OP.ResumeButton.x + 158, OP.ResumeButton.y + 33, fit_size(tr("pause_resume"), 34, 280), 0.5f, 0.5f, WHITE); text_at(tr("pause_quit"), OP.QuitButton.x + 158, OP.QuitButton.y + 26, fit_size(tr("pause_quit"), 28, 280), 0.5f, 0.5f, WHITE); if (po_is("ShowQuitDescription")) ui_wrap_text(tr("quit_description"), 616, 446, 20, 308, 40, rgb(0xd0c8b8, 1), 1); // QuitDescriptionText } else { const char *h = tr("options_language"); text_at(h, 768, 88, fit_size(h, 26, 300), 0.5f, 0.5f, rgb(VUI_GOLD, 1)); for (int i = 0; i < OP.nLangs; i++) { UIButton *b = &OP.langs[i]; int cur = !strcmp(Lang_codeAt(i), Lang_getLangCode()); UIButton_draw(b, cur ? 1 : 0.6f); const char *n = Lang_native(Lang_codeAt(i)); text_at(n, b->x + 77, b->y + 22, fit_size(n, 22, 136), 0.5f, 0.5f, cur ? rgb(VUI_GOLD, 1) : WHITE); } UIButton *rb = &OP.RestoreBackupButton; if (rb->visible) { const char *s = tr(OP.restoreState ? "charConfirm_confirm" : "options_dataRecovery"); UIButton_draw(rb, 1); text_at(s, rb->x + 158, rb->y + 25, fit_size(s, 24, 280), 0.5f, 0.5f, WHITE); } } } static void OptionsScene_create(void) { Options_create(0); } static void PauseOptions_open(void) { // PauseScene.OpenOptions: nasconde grimorio, mappa e bottoni della pausa (Vita: anche Mazzo e statistiche) PS.optionsOpen = 1; Overlay_DestroyGrid(); Options_create(1); } static void SceneManager_ResumeFromPause(void) { PS.active = 0, Opt_flushLang(), OP.active = 0; Overlay_DestroyGrid(); } static void SceneManager_QuitFromPauseMenu(void) { // pausa, statistiche, game over e MainScene fermi; PostGameScene; musica ferma Overlay_DestroyGrid(); PS.active = 0, Opt_flushLang(), OP.active = 0; PostGameScene_start(); Sound_StopMusic(); } // ============================================================================ // 0xa2e1: UI_optionsRecoveryScene (Recupero dati). Qui come su Steam: niente backup locali ne' database vecchio // (LocalBackups sempre vuota, DisplayRecoveryForLocalDB(false)); resta "Carica ultima partita" se c'e' LastRunBackup, // con la conferma a due tocchi (500 ms), poi SaveSystem.RestoreBackup e il gioco riparte. // Vita: il bottone entra nella griglia del pad (l'originale ci mette solo Indietro) e sotto c'e' la spiegazione. // ============================================================================ static struct { int active, confirm, hasLastRun, imState, delArmed; float t, armAt, delAt; UIButton LastRunButton, ImportButton, DelSaveButton, DelAllButton; char *imText; char imInfo[96]; } RC; enum { IM_OFF, IM_WAIT, IM_READY, IM_BAD, IM_NONET }; static void RC_cancel(void) { if (TB.BackButton.onDown) TB.BackButton.onDown(TB.BackButton.ctx); } static void RC_onLastRun(void *c) { // ChangeLastRunButtonToConfirm, poi DisableAll + RestoreBackup (void)c; Sound_PlaySimple("ClickIn", 0); if (RC.confirm == 2) { Overlay_DestroyGrid(); UIButton_off(&RC.LastRunButton), UIButton_off(&TB.BackButton); SaveSystem_RestoreBackup(); return; } RC.confirm = 1, RC.armAt = RC.t + 0x1f4; UIButton_off(&RC.LastRunButton); } // Vita: importazione del salvataggio del PC (saveimport.c): il browser carica il file, qui si controlla e si conferma. static void RC_onImport(void *c); static void RC_grid(UIButton *sel) { Overlay_DestroyGrid(); int last = RC.hasLastRun && RC.imState == IM_OFF, imp = RC.imState == IM_OFF || RC.imState == IM_READY, del = RC.imState == IM_OFF ? 2 : 0, r = 1; Overlay_MakeUIGrid(1, 1 + last + imp + del, 0); UIGrid_SetContents(0, 0, &TB.BackButton, 0); if (last) UIGrid_SetContents(0, r++, &RC.LastRunButton, 0); if (imp) UIGrid_SetContents(0, r++, &RC.ImportButton, 0); if (del) UIGrid_SetContents(0, r++, &RC.DelSaveButton, 0), UIGrid_SetContents(0, r++, &RC.DelAllButton, 0); Overlay_ToggleCursorsVisibility(1); UIGrid_SelectGameObject(sel); OV.UI_selected = sel; OV.OnCancelCallback = RC_cancel; } static void RC_importStop(void) { saveimport_stop(); if (RC.imText) saveimport_free(RC.imText); RC.imText = NULL; } static void RC_importReceived(char *txt) { if (RC.imText) saveimport_free(RC.imText); RC.imText = NULL; cJSON *j = SaveSystem_IsChecksumValid(txt) ? cJSON_Parse(txt) : NULL; if (!j) { saveimport_free(txt); RC.imState = IM_BAD; UIButton_off(&RC.ImportButton); RC_grid(&TB.BackButton); return; } snprintf(RC.imInfo, sizeof(RC.imInfo), port_tr("rc_info"), (int)cJSON_GetNumberValue(cJSON_GetObjectItem(j, "Coins")), cJSON_GetArraySize(cJSON_GetObjectItem(j, "Achievements"))); cJSON_Delete(j); RC.imText = txt, RC.imState = IM_READY; UIButton_on(&RC.ImportButton, RC_onImport, NULL); RC_grid(&RC.ImportButton); } static void RC_onImport(void *c) { (void)c; Sound_PlaySimple("ClickIn", 0); if (RC.imState == IM_READY) { // il salvataggio attuale resta in SaveData.preimport const char *name = SaveSystem_GetSaveName(SAVE_DEFAULT); char *cur = vs_read_text(name); if (cur) vs_write_text("SaveData.preimport", cur), vs_free(cur); if (!vs_write_text(name, RC.imText)) { RC.imState = IM_BAD; UIButton_off(&RC.ImportButton); RC_grid(&TB.BackButton); return; } Overlay_DestroyGrid(); UIButton_off(&RC.ImportButton), UIButton_off(&TB.BackButton); RC_importStop(); vs_reload(); return; } RC.imState = saveimport_start() ? IM_WAIT : IM_NONET; UIButton_off(&RC.ImportButton), UIButton_off(&RC.LastRunButton), UIButton_off(&RC.DelSaveButton), UIButton_off(&RC.DelAllButton); RC_grid(&TB.BackButton); } // Vita: cancellare dalla console. Due pressioni (la seconda dopo 500 ms): si esce dall'attesa cambiando riga. static void RC_deleteNow(int which) { Overlay_DestroyGrid(); UIButton_off(&RC.DelSaveButton), UIButton_off(&RC.DelAllButton), UIButton_off(&TB.BackButton); if (which == 1) { static const char *const names[] = { "SaveData", "LastRunBackup", "SaveDataStash", "SaveData.preimport", "save.json" }; for (int i = 0; i < 5; i++) remove(vs_path(names[i])); vs_reload(); return; } if (BGM.idx >= 0) Music_close(&BGM.music), BGM.idx = -1; // i file aperti non si possono cancellare if (SeekSfx.on) Music_close(&SeekSfx.m), SeekSfx.on = 0; if (LoopSfx.on) Music_close(&LoopSfx.m), LoopSfx.on = 0; vs_delete_all_and_exit(); } static void RC_onDelete(void *c) { int which = c == &RC.DelSaveButton ? 1 : 2; Sound_PlaySimple("ClickIn", 0); if (RC.delArmed == which && RC.t >= RC.delAt) { RC_deleteNow(which); return; } if (RC.delArmed != which) RC.delArmed = which, RC.delAt = RC.t + 0x1f4; } static void RC_row(UIButton *b, const char *label) { UIButton_draw(b, 1); text_at(label, b->x + 230, b->y + 26, fit_size(label, 26, 430), 0.5f, 0.5f, WHITE); } static void RecoveryScene_create(void) { memset(&RC, 0, sizeof(RC)); RC.active = 1; RC.hasLastRun = SaveSystem_HasBackup(); // DisplayRecoveryForLastRun int ry = 76; #define RC_NEXT() (ry += 64, ry - 64) if (RC.hasLastRun) UIButton_set(&RC.LastRunButton, "GreenButton", 250, RC_NEXT(), 460, 52, 1, 0, 0); else RC.LastRunButton = (UIButton){ 0 }; RC.LastRunButton.visible = RC.hasLastRun; if (RC.hasLastRun) UIButton_on(&RC.LastRunButton, RC_onLastRun, NULL); UIButton_set(&RC.ImportButton, "GreenButton", 250, RC_NEXT(), 460, 52, 1, 0, 0); UIButton_on(&RC.ImportButton, RC_onImport, NULL); UIButton_set(&RC.DelSaveButton, "BackButton", 250, RC_NEXT(), 460, 52, 1, 0, 0); UIButton_on(&RC.DelSaveButton, RC_onDelete, &RC.DelSaveButton); UIButton_set(&RC.DelAllButton, "BackButton", 250, RC_NEXT(), 460, 52, 1, 0, 0); UIButton_on(&RC.DelAllButton, RC_onDelete, &RC.DelAllButton); #undef RC_NEXT RC_grid(RC.hasLastRun ? &RC.LastRunButton : &RC.ImportButton); vui_set_prompts((VPrompt[]){ { G_CROSS, "vui_select" }, { G_CIRCLE, "vui_back" } }, 2); TB_title = tr("options_dataRecovery"); if (getenv("VS_IMPORT")) RC_onImport(NULL); // sviluppo: apre subito l'importazione } static void RecoveryScene_update(float delta) { RC.t += delta; if (RC.confirm == 1 && RC.t >= RC.armAt) RC.confirm = 2, UIButton_on(&RC.LastRunButton, RC_onLastRun, NULL); UIButton_clicked(&RC.LastRunButton); UIButton_clicked(&RC.ImportButton); if (RC.imState == IM_OFF) { UIButton_clicked(&RC.DelSaveButton), UIButton_clicked(&RC.DelAllButton); if ((RC.delArmed == 1 && OV.UI_selected != &RC.DelSaveButton) || (RC.delArmed == 2 && OV.UI_selected != &RC.DelAllButton)) RC.delArmed = 0; if (getenv("VS_RCSEL")) OV.UI_selected = getenv("VS_RCSEL")[0] == 'a' ? &RC.DelAllButton : &RC.DelSaveButton; // sviluppo: save|all, solo selezionato const char *dt = getenv("VS_RCDEL"); // sviluppo: save|all, cancella subito if (dt && RC.t > 0x7d0) RC_deleteNow(!strcmp(dt, "save") ? 1 : 2); } if (RC.imState == IM_WAIT || RC.imState == IM_BAD || RC.imState == IM_READY) { saveimport_poll(); char *txt = saveimport_take(); if (txt) RC_importReceived(txt); } if (RC.imState == IM_READY && getenv("VS_IMPORT") && !strcmp(getenv("VS_IMPORT"), "confirm")) RC_onImport(NULL); } static void RecoveryScene_draw(void) { if (RC.imState != IM_OFF) { nine("frame5_c4.png", 12, (Rectangle){ 120, 90, 720, 300 }, WHITE); if (RC.imState == IM_NONET) { ui_wrap_text(port_tr("rc_nowifi"), 150, 180, 26, 660, 120, WHITE, 1); return; } text_at(port_tr("rc_open"), 480, 130, 24, 0.5f, 0.5f, WHITE); text_at(saveimport_address(), 480, 182, 36, 0.5f, 0.5f, rgb(0xffcd50, 1)); const char *msg = RC.imState == IM_BAD ? port_tr("rc_bad") : RC.imState == IM_READY ? port_tr("rc_ready") : port_tr("rc_send"); ui_wrap_text(msg, 150, 232, 22, 660, 100, RC.imState == IM_BAD ? rgb(0xff8070, 1) : rgb(0xd0c8b8, 1), 1); if (RC.imState == IM_READY) { text_at(RC.imInfo, 480, 352, 24, 0.5f, 0.5f, rgb(0xffcd50, 1)); UIButton_draw(&RC.ImportButton, 1); text_at(port_tr("rc_importthis"), RC.ImportButton.x + 230, RC.ImportButton.y + 28, 28, 0.5f, 0.5f, WHITE); } return; } if (RC.hasLastRun) RC_row(&RC.LastRunButton, tr(RC.confirm ? "charConfirm_confirm" : "options_lastRun")); RC_row(&RC.ImportButton, port_tr("rc_import")); RC_row(&RC.DelSaveButton, RC.delArmed == 1 ? port_tr("rc_again") : port_tr("rc_delsave")); RC_row(&RC.DelAllButton, RC.delArmed == 2 ? port_tr("rc_again") : port_tr("rc_delall")); UIButton *sel = OV.UI_selected; const char *about = sel == &RC.LastRunButton ? tr("options_restoreDescription") : sel == &RC.ImportButton ? port_tr("rc_about_import") : sel == &RC.DelSaveButton ? port_tr("rc_about_delsave") : sel == &RC.DelAllButton ? port_tr("rc_about_delall") : NULL; if (about) { nine("frame5_c4.png", 12, (Rectangle){ 180, 340, 600, 150 }, WHITE); ui_wrap_text(about, 205, 360, 22, 550, 115, rgb(0xd0c8b8, 1), 1); } } // ============================================================================ // 0x17f61: SceneManager (il flusso fra le scene del menu) // ============================================================================ // ============================================================================ // 0x10194: CollectionSecretScene (dal menu, con la reliquia Forbidden Scroll). La lista dei misteri (0x71a7), la spell // da digitare (0xa85f: un KeyCombo 0x118dd per ogni segreto con spell, a schermo rune a caso), la tastiera a schermo // (0xf676: col pad, anche sulla Vita), le rune (0x22ba), l'effetto di sblocco (0x15675) e i riquadri del premio // (0x16120 AssignMultipleSecret/AssignSecret). Coordinate da menu 1093x683; SceneContainer.y = 683 - 619 = 64. // ============================================================================ static int SecretsManager_checkIfSecretAchieved(const char *k) { // 0x1435a cJSON *s = cJSON_GetObjectItem(data_get("secrets"), k); if (!s) return 0; if (cJSON_IsTrue(cJSON_GetObjectItem(s, "achieved"))) return 1; int n = 0, ok = 0; const char *w = str(s, "weaponToUnlock"), *c = str(s, "characterToUnlock"), *st = str(s, "stageToUnlock"), *hy = str(s, "hyperToUnlock"), *r = str(s, "relicToUnlock"), *pu = str(s, "powerUpToUnlock"); #define T(o, f) cJSON_IsTrue(cJSON_GetObjectItem(o, f)) if (w) n++, ok += T(tbl0("weapons", w), "isUnlocked"); if (c) { cJSON *d = tbl0("characters", c); n++, ok += !(T(d, "hidden") && !T(d, "isBought")); } if (st) n++, ok += T(tbl0("stages", st), "unlocked"); if (hy) n++, ok += T(tbl0("stages", hy), "unlocked"); // (sic) unlocked dello stage, non dell'hyper if (r) n++, ok += po_has("CollectedItems", r); if (num(s, "goldPrize", 0) && str(s, "weaponIcon")) n++, ok += T(tbl0("weapons", str(s, "weaponIcon")), "unlocked"); // (sic) campo che le armi non hanno if (pu) { cJSON *d = tbl0("powerups", pu); n++, ok += !(!T(d, "seen") && T(d, "hidden")); } cJSON *ar = cJSON_GetObjectItem(s, "arcanaToUnlock"); if (cJSON_IsNumber(ar) && ar->valuedouble >= 0) n++, ok += T(tbl0("arcana", TextFormat("%d", ar->valueint)), "unlocked"); #undef T return ok == n; } typedef struct { // GenericPopupDescriptionPanel con AssignSecret / AssignMultipleSecret unsigned bgTint; char name[96], tips[256]; const char *iconAtlas, *iconFrame, *iconBGFrame, *overlayFrame, *icon2Atlas, *icon2Frame, *icon2BGFrame; float iconOX, nameX, tipsX; int iconHidden; } SecretPopup; static const char *SP_un(cJSON *s) { return tr(cJSON_IsTrue(cJSON_GetObjectItem(s, "achieved")) ? "genericPopup_unlocked" : "genericPopup_unlocks"); } static void SecretPopup_AssignSecretByType(SecretPopup *g, const char *k, const char *type) { cJSON *s = cJSON_GetObjectItem(data_get("secrets"), k); int ach = cJSON_IsTrue(cJSON_GetObjectItem(s, "achieved")); g->iconOX = 0.5f, g->overlayFrame = NULL; if (!strcmp(type, "weaponToUnlock")) { const char *w = str(s, type); cJSON *d = tbl0("weapons", w); g->iconAtlas = str(d, "texture"), g->iconFrame = str(d, "frameName"), g->iconBGFrame = "frameB.png"; snprintf(g->tips, sizeof(g->tips), "%s%s", SP_un(s), lang_text("weaponLang", w, "name", d)); } else if (!strcmp(type, "characterToUnlock")) { const char *c = str(s, type); cJSON *d = tbl0("characters", c); g->iconBGFrame = NULL; if (cJSON_IsTrue(cJSON_GetObjectItem(s, "mistery")) && !ach) { g->iconAtlas = "items", g->iconFrame = "QuestionMark.png"; snprintf(g->tips, sizeof(g->tips), "%s ???", SP_un(s)); } else { const char *pre = char_text(c, "prefix"); g->iconAtlas = "characters", g->iconFrame = str(d, "spriteName"); snprintf(g->tips, sizeof(g->tips), "%s%s%s%s", SP_un(s), pre, *pre ? " " : "", char_text(c, "charName")); } } else if (!strcmp(type, "stageToUnlock") || !strcmp(type, "hyperToUnlock")) { int hyper = !strcmp(type, "hyperToUnlock"); const char *st = str(s, type); cJSON *d = tbl0("stages", st); const char *f = str(d, hyper ? "frameName" : "frameNameUnlock"); g->iconAtlas = "UI", g->iconFrame = f ? f : "QuestionMark.png", g->iconBGFrame = NULL; const char *nm = lang_text("stageLang", st, "stageName", d); if (hyper) snprintf(g->tips, sizeof(g->tips), "%s", lang1(ach ? "genericPopup_unlockedHyper" : "genericPopup_unlocksHyper", nm)); else snprintf(g->tips, sizeof(g->tips), "%s%s", SP_un(s), nm); } else if (!strcmp(type, "relicToUnlock")) { const char *r = str(s, type); cJSON *it = cJSON_GetObjectItem(data_get("items"), r); g->iconAtlas = str(it, "texture"), g->iconFrame = str(it, "frameName"), g->iconBGFrame = "frameF.png"; snprintf(g->tips, sizeof(g->tips), "%s%s", SP_un(s), lang_text("itemLang", r, "achievementTips", it)); } else if (!strcmp(type, "goldPrize")) { g->iconAtlas = "items", g->iconFrame = str(tbl0("weapons", str(s, "weaponIcon")), "frameName"), g->iconOX = 0.75f, g->iconBGFrame = NULL, g->overlayFrame = "MoneyBagGreen.png"; snprintf(g->tips, sizeof(g->tips), "%s", lang1(ach ? "genericPopup_obtainedCoin" : "genericPopup_obtainsCoin", fix(num(s, "goldPrize", 0), 0))); } else if (!strcmp(type, "powerUpToUnlock")) { const char *pu = str(s, type); cJSON *d = tbl0("powerups", pu); g->iconAtlas = "items", g->iconFrame = str(d, "frameName") ? str(d, "frameName") : "QuestionMark.png"; g->iconBGFrame = cJSON_IsTrue(cJSON_GetObjectItem(d, "specialBG")) ? "frameE.png" : "frameD.png"; snprintf(g->tips, sizeof(g->tips), "%s%s", tr(cJSON_IsTrue(cJSON_GetObjectItem(d, "achieved")) ? "genericPopup_unlocked" : "genericPopup_unlocks"), lang_text("powerUpLang", pu, "name", d)); } else if (!strcmp(type, "arcanaToUnlock")) { const char *b = TextFormat("%d", (int)num(s, type, 0)); static char bb[16]; snprintf(bb, sizeof(bb), "%s", b); cJSON *d = tbl0("arcana", bb); g->iconAtlas = "items", g->iconFrame = str(d, "frameName"), g->iconBGFrame = "frameG.png"; snprintf(g->tips, sizeof(g->tips), "%s%s", SP_un(s), lang_text("arcanaLang", bb, "name", d)); } else if (!strcmp(type, "Everything") || !strcmp(type, "Everywhere")) { g->nameX = g->tipsX = 0.82f * SAFE_WIDTH * 0.5f; snprintf(g->tips, sizeof(g->tips), "%s", lang_text("secretLang", k, "description", s)); g->iconBGFrame = NULL, g->iconHidden = 1; } } static void SecretPopup_head(SecretPopup *g, const char *k) { // la parte comune di AssignSecret e AssignMultipleSecret cJSON *s = cJSON_GetObjectItem(data_get("secrets"), k); int ach = cJSON_IsTrue(cJSON_GetObjectItem(s, "achieved")); memset(g, 0, sizeof(*g)); g->nameX = g->tipsX = 0.5f * 0.82f * SAFE_WIDTH + 0x1e; g->bgTint = ach ? 0xffffff : 0x888888; snprintf(g->name, sizeof(g->name), "%s", ach ? tr("genericPopup_obtained") : ""); } static const char *const SECRET_TYPES[8] = { "characterToUnlock", "stageToUnlock", "hyperToUnlock", "weaponToUnlock", "relicToUnlock", "goldPrize", "powerUpToUnlock", "arcanaToUnlock" }; static int Secret_has(cJSON *s, const char *type) { if (!strcmp(type, "goldPrize")) return num(s, "goldPrize", 0) && str(s, "weaponIcon"); if (!strcmp(type, "arcanaToUnlock")) return cJSON_IsNumber(cJSON_GetObjectItem(s, type)) && num(s, type, -1) >= 0; return str(s, type) != NULL; } static void SecretPopup_AssignSecret(SecretPopup *g, const char *k, const char *type) { SecretPopup_head(g, k); SecretPopup_AssignSecretByType(g, k, type); // il tipo c'e' sempre (onAchievementsUnlocked) } static void SecretPopup_AssignMultipleSecret(SecretPopup *g, const char *k) { SecretPopup_head(g, k); cJSON *s = cJSON_GetObjectItem(data_get("secrets"), k); int ach = cJSON_IsTrue(cJSON_GetObjectItem(s, "achieved")), first = 1; for (int i = 0; i < 8; i++) { if (!Secret_has(s, SECRET_TYPES[i])) continue; if (first) { first = 0; SecretPopup_AssignSecretByType(g, k, SECRET_TYPES[i]); continue; } if (!ach) continue; // il secondo premio compare a destra solo a segreto ottenuto const char *v = str(s, SECRET_TYPES[i]); cJSON *d = NULL; switch (i) { case 0: d = tbl0("characters", v); g->icon2Atlas = "characters", g->icon2Frame = str(d, "spriteName"); break; case 1: d = tbl0("stages", v); g->icon2Atlas = "UI", g->icon2Frame = str(d, "frameNameUnlock") ? str(d, "frameNameUnlock") : "QuestionMark.png"; break; case 2: d = tbl0("stages", v); g->icon2Atlas = "UI", g->icon2Frame = str(d, "frameName") ? str(d, "frameName") : "QuestionMark.png"; break; case 3: d = tbl0("weapons", v); g->icon2Atlas = str(d, "texture"), g->icon2Frame = str(d, "frameName"), g->icon2BGFrame = "frameG.png"; break; case 4: d = cJSON_GetObjectItem(data_get("items"), v); g->icon2Atlas = str(d, "texture"), g->icon2Frame = str(d, "frameName"), g->icon2BGFrame = "frameG.png"; break; case 5: d = tbl0("weapons", str(s, "weaponIcon")); g->icon2Atlas = "items", g->icon2Frame = str(d, "frameName"); break; // origine (0.75, 0.5) case 6: d = tbl0("powerups", v); g->icon2Atlas = "items", g->icon2Frame = str(d, "frameName") ? str(d, "frameName") : "QuestionMark.png", g->icon2BGFrame = "frameG.png"; break; case 7: d = tbl0("arcana", TextFormat("%d", (int)num(s, "arcanaToUnlock", 0))); g->icon2Atlas = "items", g->icon2Frame = str(d, "frameName"), g->icon2BGFrame = "frameG.png"; break; } if (d) g->nameX -= 0x14, g->tipsX -= 0x14; // (sic) a ogni premio in piu' } } static void SecretPopup_draw(const SecretPopup *g, float x, float y, float scaleY) { if (scaleY <= 0.001f) return; float W = 0.82f * SAFE_WIDTH, H = 0x68; rlPushMatrix(); rlTranslatef(x, y, 0); rlScalef(PixelScale, scaleY, 1); nine("frame1_c2.png", 12, (Rectangle){ 0, 0, W, H }, rgb(g->bgTint, 1)); if (g->iconBGFrame) TS_frame("UI", g->iconBGFrame, 0x34, 0x34, 0.5f, 0.5f, 2 * PixelScale, 0, WHITE, 0); if (g->icon2BGFrame && g->icon2Frame) TS_frame("UI", g->icon2BGFrame, 0x17c, 0x34, 0.5f, 0.5f, 2 * PixelScale, 0, WHITE, 0); if (!g->iconHidden && g->iconAtlas && g->iconFrame) TS_frame(g->iconAtlas, g->iconFrame, 0x34, 0x34, g->iconOX, 0.5f, 2 * PixelScale, 0, WHITE, 0); if (g->icon2Atlas && g->icon2Frame) TS_frame(g->icon2Atlas, g->icon2Frame, 0x17c, 0x34, 0.5f, 0.5f, 2 * PixelScale, 0, WHITE, 0); if (g->overlayFrame) TS_frame("UI", g->overlayFrame, 0x34, 0x34, 0.5f, 0.5f, 2 * PixelScale, 0, WHITE, 0); text_at(g->name, g->nameX, 0xa, fit_size(g->name, 16, 0xfa), 0.5f, 0, YELLOW); text_at(g->tips, g->tipsX, 0x32, fit_size(g->tips, 16, 0xfa), 0.5f, 0, ORANGE); rlPopMatrix(); } // BitmapText con origine: i glifi stanno a (x - ox * larghezza + posizione), le dimensioni sono quelle dei glifi static void BMFont_bounds(BMFont *f, const char *text, float s, float *minx, float *miny, float *maxx, float *maxy) { float ax = 0, ay = 0; *minx = *miny = 1e9f, *maxx = *maxy = -1e9f; for (const char *ch = text; *ch; ch++) { if (*ch == '\n') { ax = 0, ay += f->lineHeight; continue; } Glyph g = f->g[(unsigned char)*ch]; float gx = (ax + g.xo) * s, gy = (ay + g.yo) * s; *minx = fminf(*minx, gx), *miny = fminf(*miny, gy), *maxx = fmaxf(*maxx, gx + g.w * s), *maxy = fmaxf(*maxy, gy + g.h * s); ax += g.adv; } if (*minx > *maxx) *minx = *miny = *maxx = *maxy = 0; } static void BMFont_drawOrigin(BMFont *f, const char *text, float x, float y, float ox, float oy, float s, Color c) { if (!f->tex.id || c.a == 0) return; float minx, miny, maxx, maxy, ax = 0, ay = 0; BMFont_bounds(f, text, s, &minx, &miny, &maxx, &maxy); float x0 = x - ox * (maxx - minx), y0 = y - oy * (maxy - miny); for (const char *ch = text; *ch; ch++) { if (*ch == '\n') { ax = 0, ay += f->lineHeight; continue; } Glyph g = f->g[(unsigned char)*ch]; DrawTexturePro(f->tex, (Rectangle){ g.x, g.y, g.w, g.h }, (Rectangle){ x0 + (ax + g.xo) * s, y0 + (ay + g.yo) * s, g.w * s, g.h * s }, (Vector2){ 0, 0 }, 0, c); ax += g.adv; } } #define SC_MAX 24 #define SC_Y 64.0f // SceneContainer.y #define SC_ROWS 0x37 // un pannello ogni 55 px #define SC_KEYS 28 static BMFont FontRune; // 'runeFont' typedef struct { UIButton hit; const char *secret; int num; } SecretPanel; typedef struct { const char *type; int codes[48], n, index; float tLast; } SecretCombo; static struct { int active, n, currentSelectedNum, inputFocused, inputEnabled, keyboardEnabled, highlightVisible, wasDown; const char *Highlighted, *prevBGM, *prevMod; SecretPanel p[SC_MAX]; UIButton keys[SC_KEYS], inputBackground, keyboardIcon, hiddenKeyHelper, hiddenKeyBlocker; char keyChar[SC_KEYS]; float keyX[SC_KEYS], keyY[SC_KEYS], keyFrom[SC_KEYS], keyTo, keyT0, keyDur, keyStagger; float t, scY, MaxY, MinY, h, blockX, blockY, blockA, blockFrom, blockTo, blockT0, iconA; float shakeT0, spinT0, spinTo, wellUntil; char value[64], shown[160]; SecretCombo combo[112]; int ncombo; ParticleManager *pfx, *runes; ParticleEmitter *pfxEmitter, *runeEmitter; SecretPopup conf, pop; // CollectionSecretUnlockEffect float bgFrom, bgTo, bgT0, bgDur, popFrom, popTo, popT0, popNextAt, adT0; unsigned sheenTint; const char *popSecret, *popTypes[10]; int popN, popI, popOn, popStep, adOn; // popStep: 0 nascondere al prossimo scatto, 1 rimostrare } SC; static void SceneManager_BackFromSecrets(void); static void SpellsManager_StartSpell(const char *type); static float SC_ease(float from, float to, float t0, float dur) { return from + (to - from) * lerp01(SC.t, t0, dur); } static float SC_bgAlpha(void) { return SC_ease(SC.bgFrom, SC.bgTo, SC.bgT0, SC.bgDur); } static float SC_popScale(void) { return SC_ease(SC.popFrom, SC.popTo, SC.popT0, 0x12c); } static float SC_panelX(void) { return 0x136 - 0.5f * (SAFE_WIDTH - 0x64); } // sc.x - trueWidth / 2 static float SC_panelY(int i) { return SC_Y + SC.scY - 0.5f * SC.h + 0x3c + SC_ROWS * i; } // --- CollectionSecretInput (0xa85f) ------------------------------------------------------- static void SC_formatInputText(const char *v, char *out, size_t cap) { char s[64]; snprintf(s, sizeof(s), "%s", v); for (size_t n = strlen(s); n < 8; n++) s[n] = '-', s[n + 1] = 0; size_t o = 0, len = strlen(s); for (size_t i = 0; i < len && o + 4 < cap; i++) { out[o++] = s[i]; if (i < len - 1) out[o++] = ' '; if (i != 0 && i % 20 == 0) out[o++] = '\n'; // MAX_CHARACTER / 2 } out[o] = 0; } static float SC_textScale(void) { // scaleToMaxFast(inputBitmapText, true, 330): solo in giu' float minx, miny, maxx, maxy; BMFont_bounds(&FontRune, SC.shown, 1.5f, &minx, &miny, &maxx, &maxy); float w = maxx - minx; return w > 0x14a ? 0x14a / w : 1; } static float SC_textY(void) { return 0x15e - 3 - 0x50 * SC_textScale(); } // inputBitmapTextY + inputBitmapTextScaleOffsetY * scale static void SC_refreshText(void) { SC_formatInputText(SC.value, SC.shown, sizeof(SC.shown)); } static void SC_shake(void) { SC.shakeT0 = SC.t; } // cameras.main.shake(150, 0.005) static void SC_addToInputText(char c) { if (strlen(SC.value) > 0x28) SC.value[0] = 0; size_t n = strlen(SC.value); SC.value[n] = c, SC.value[n + 1] = 0; SC_refreshText(); int idx = (int)n, k = 0; // la x della runa appena scritta (characters[2 * idx] del testo con gli spazi) float k0 = SC_textScale(), s = 1.5f * k0, minx, miny, maxx, maxy, ax = 0; BMFont_bounds(&FontRune, SC.shown, s, &minx, &miny, &maxx, &maxy); for (const char *ch = SC.shown; *ch && k < 2 * idx; ch++) { if (*ch == '\n') { ax = 0; continue; } ax += FontRune.g[(unsigned char)*ch].adv, k++; } float x = 0x2f8 - 0.5f * (maxx - minx) + ax * s + 0xa; emitter_emitParticleAt(SC.runeEmitter, x, 0x172, 0xa); // pfxEmitter[idx].explode(10, x, 370): tutti uguali, qui uno solo SC.pfx->hasWell = 1, SC.pfx->wellX = x, SC.pfx->wellY = SC_textY(), SC.wellUntil = SC.t + 0x64; // activateGravityWell SC_shake(); } static void SC_removeFromInputText(void) { size_t n = strlen(SC.value); if (n > 0) SC.value[n - 1] = 0; SC_refreshText(); SC_shake(); } static void SC_clearInputText(void) { SC.value[0] = 0; SC_refreshText(); } static void SC_onInputFocued(void) { SC.inputFocused = 1; UIGrid_SelectAt(2, 1); OV.UI_selected = &SC.inputBackground; Overlay_ToggleCursorsVisibility(0); OV.blockWASD = 1; } static void SC_onInputBlured(void) { SC.inputFocused = 0; } static void SC_onCheatActivated(const char *type); // keyPress + i KeyCombo (CustomProcessKeyCombo): code = keyCode di JS (lettere e cifre come raylib, '-' = 189; -1 = undefined) static void SC_keyDown(int code, int printable, int erase, int nav) { if ((SC.inputFocused || SC.keyboardEnabled) && SC.inputEnabled) { if (erase) SC_removeFromInputText(); if (printable) SC_addToInputText("ABCDEFGHIJKLMNOPQRSTUVWXYZ"[(int)floorf(frand() * 26)]); Sound_PlaySound("LittleHit", 0.5f, 1, 0x64 * (frand() - 0.5f), 0x96, 3); } if (nav) return; // Enter e frecce: i combo restano dove sono for (int i = 0; i < SC.ncombo; i++) { SecretCombo *c = &SC.combo[i]; int keyMatched = 0, matched = 0; if (code == c->codes[c->index] && !(c->index > 0 && SC.t > c->tLast + 0x7530)) { // maxKeyDelay 30 s keyMatched = 1, c->index++, c->tLast = SC.t; matched = c->index >= c->n; } if (!keyMatched) c->index = 0; // resetOnWrongKey if (!matched) continue; c->index = 0; // resetOnMatch if (!((SC.inputFocused || SC.keyboardEnabled) && SC.inputEnabled)) continue; if (!strcmp(c->type, "MaybeImAStallion") && cJSON_IsTrue(cJSON_GetObjectItem(tbl0("characters", "PANINI"), "hidden"))) continue; if (!strcmp(c->type, "Tramezzini") && cJSON_IsTrue(cJSON_GetObjectItem(tbl0("characters", "EXDASH"), "hidden"))) continue; if (AchievementManager_UnlockSecret(c->type) || cJSON_IsTrue(cJSON_GetObjectItem(cJSON_GetObjectItem(data_get("secrets"), c->type), "isModifier"))) SC_clearInputText(), SC_onCheatActivated(c->type); } } static void SC_HandleCheats(void) { SC.ncombo = 0; cJSON *s; cJSON_ArrayForEach(s, data_get("secrets")) { const char *sp = str(s, "spell"); if (!sp || SC.ncombo >= 112) continue; SecretCombo *c = &SC.combo[SC.ncombo++]; *c = (SecretCombo){ .type = s->string }; for (const char *p = sp; *p && c->n < 48; p++) { int ch = *p >= 'A' && *p <= 'Z' ? *p + 32 : *p; // toLowerCase().replace(/\s/g, '') if (ch == ' ' || ch == '\t' || ch == '\n') continue; c->codes[c->n++] = ch >= 'a' && ch <= 'z' ? ch - 32 : ch >= '0' && ch <= '9' ? ch : ch == '-' ? 189 : -2; } } } // --- CollectionSecretKeyboard (0xf676) --------------------------------------------------- static const char SC_CHARS[SC_KEYS + 1] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ-1"; static float SC_keyAlpha(int i) { float t0 = SC.keyT0 + SC.keyStagger * i; return SC_ease(SC.keyFrom[i], SC.keyTo, t0, SC.keyDur); } static void SC_keysTween(float to, float dur, float stagger) { for (int i = 0; i < SC_KEYS; i++) SC.keyFrom[i] = SC_keyAlpha(i); SC.keyTo = to, SC.keyT0 = SC.t, SC.keyDur = dur, SC.keyStagger = stagger; } static void SC_blockTween(float to) { SC.blockFrom = SC_ease(SC.blockFrom, SC.blockTo, SC.blockT0, 0x64), SC.blockTo = to, SC.blockT0 = SC.t; } static void SC_hideKeyboard(void) { if (!SC.keyboardEnabled) return; SC_blockTween(0); SC_keysTween(0, 0x64, 0); SC.keyboardEnabled = 0, SC.iconA = 1; } static void SC_showKeyboard(void) { if (SC.keyboardEnabled) return; for (int i = 0; i < SC_KEYS; i++) SC.keyFrom[i] = 0; // il tween di prima si ferma: alpha 0 SC.keyTo = 1, SC.keyT0 = SC.t, SC.keyDur = 0xc8, SC.keyStagger = 0x14; SC.keyboardEnabled = 1; SC.blockFrom = SC.blockTo = 0, SC.iconA = 0; UIGrid_SelectAt(2, 4); OV.UI_selected = &SC.keys[0]; OV.blockWASD = 1; } static void SC_moveBlock(int i) { if (!SC.keyboardEnabled) return; Glyph g = FontTitle.g[(unsigned char)SC.keyChar[i]]; float s = 130.0f / 80; SC.blockX = SC.keyX[i] + g.xo * s + 0.5f * g.w + 5, SC.blockY = SC.keyY[i] + g.yo * s + 0.5f * g.h + 5; // _bounds.global + characters[0] + glyph / 2 + 5 SC.blockFrom = SC.blockTo = 1; UIGrid_SelectAt(2 + i % 7, 4 + i / 7); OV.UI_selected = &SC.keys[i]; } static void SC_keyClicked(void *c) { int i = (int)(intptr_t)c; if (!SC.keyboardEnabled) return; SC_moveBlock(i); char ch = SC.keyChar[i]; SC_keyDown(ch >= 'A' && ch <= 'Z' ? ch : -1, 1, 0, 0); // KeyCodes['-'] e KeyCodes['1'] non esistono: undefined } static void SC_onKeyboardIcon(void *c) { (void)c; SC_showKeyboard(); } // --- CollectionSecretScene ---------------------------------------------------------------- static void SC_correctScrollableContainerPosition(void) { float hy = 0x3c + SC_ROWS * SC.currentSelectedNum - 0.5f * SC.h + 0x16, step = 0x32; // highlight.y nel contenitore if (SC.scY + hy + step > MENU_H - 0x96) { SC.scY -= step; while (SC.scY + hy + step > MENU_H - 0x96) SC.scY -= step; } else if (SC.scY + hy < step) { SC.scY += step; while (SC.scY + hy < step) SC.scY += step; } } static void SC_OnPanelClicked(int i) { SC.currentSelectedNum = i, SC.Highlighted = SC.p[i].secret; UIGrid_SelectGameObject(&SC.p[i].hit), OV.UI_selected = &SC.p[i].hit; // OnSelectionChange SecretPopup_AssignMultipleSecret(&SC.conf, SC.Highlighted); } static void SC_cancel(void) { if (SC.keyboardEnabled) { UIGrid_SelectAt(0, 1); OV.UI_selected = &SC.p[0].hit; SC_OnPanelClicked(0); Overlay_ToggleCursorsVisibility(0), SC.highlightVisible = 1; SC_correctScrollableContainerPosition(); SC_hideKeyboard(); } else if (TB.BackButton.onDown) TB.BackButton.onDown(TB.BackButton.ctx); } static void SC_MakeUIGrid(void) { Overlay_DestroyGrid(); Overlay_MakeUIGrid(10, SC.n + 1, 1); for (int c = 0; c < 10; c++) UIGrid_SetContents(c, 0, &TB.BackButton, 0); for (int i = 0; i < SC.n; i++) { UIGrid_SetContents(0, 1 + i, &SC.p[i].hit, 0); UIGrid_SetContents(1, 1 + i, &SC.hiddenKeyHelper, 0), UIGrid_SetContents(9, 1 + i, &SC.hiddenKeyHelper, 0); } for (int i = 0; i < SC_KEYS; i++) UIGrid_SetContents(2 + i % 7, 4 + i / 7, &SC.keys[i], 0); for (int c = 2; c <= 8; c++) { UIGrid_SetContents(c, 0, &TB.BackButton, 0), UIGrid_SetContents(c, 1, &SC.inputBackground, 0); UIGrid_SetContents(c, 2, &SC.keyboardIcon, 0), UIGrid_SetContents(c, 3, &SC.hiddenKeyBlocker, 0); } UIGrid_SelectAt(0, 0); OV.UI_selected = &TB.BackButton; OV.OnCancelCallback = SC_cancel; } static void SC_counts(int *ach, int *tot) { *ach = *tot = 0; cJSON *s; cJSON_ArrayForEach(s, data_get("secrets")) if (!cJSON_IsTrue(cJSON_GetObjectItem(s, "hidden"))) *ach += cJSON_IsTrue(cJSON_GetObjectItem(s, "achieved")), ++*tot; } static void SC_playBGAmin(void) { SC.bgFrom = SC_bgAlpha(), SC.bgTo = 0.8f, SC.bgT0 = SC.t, SC.bgDur = 0x3e8; Sound_PlaySound("Secret", 0.5f, 1, 0x1f4 * (frand() - 0.5f), 0x96, 3); static const unsigned T[6] = { 0xff8888, 0xff88ff, 0xffffff, 0x440000, 0x440044, 0x2222222 }; SC.sheenTint = T[(int)floorf(frand() * 6)] & 0xffffff; // 0x2222222: setTint lo tronca a 24 bit } static void SC_stopBGAnim(void) { SC.bgFrom = SC_bgAlpha(), SC.bgTo = 0, SC.bgT0 = SC.t, SC.bgDur = 0x7d0; } static void SC_popShow(int show) { SC.popFrom = SC_popScale(), SC.popTo = show ? PixelScale : 0, SC.popT0 = SC.t; } static void SC_onAchievementsUnlocked(const char *k) { SC.popNextAt = -1, SC.adOn = 0; // popupTimer.destroy + removeAllEvents, AchiAdGroup.destroy SC.popFrom = SC.popTo = 0; // spellSuccessPopup.QuickHide cJSON *s = cJSON_GetObjectItem(data_get("secrets"), k); SC.popN = 0; for (int i = 0; i < 8; i++) if (Secret_has(s, SECRET_TYPES[i])) SC.popTypes[SC.popN++] = SECRET_TYPES[i]; if (!strcmp(k, "Everything") || !strcmp(k, "Everywhere")) SC.popTypes[SC.popN++] = k; if (!SC.popN) return; SC_playBGAmin(); SC.popSecret = k, SC.popI = 0, SC.popOn = 1; SecretPopup_AssignSecret(&SC.pop, k, SC.popTypes[0]); SC_popShow(1); SC.popNextAt = SC.t + 0xdac, SC.popStep = 0; if (SC.popN > 1) SC.adOn = 1, SC.adT0 = SC.t; } static void SC_popUpdate(void) { // i timer del popup: 3,5 s mostrato, 0,5 s nascosto, finche' ci sono premi if (SC.popNextAt < 0 || SC.t < SC.popNextAt) return; if (SC.popN == 1) { SC_popShow(0); SC.popNextAt = -1; SC_stopBGAnim(); return; } if (SC.popStep == 0) { SC_popShow(0); if (SC.popI < SC.popN - 1) SC.popStep = 1, SC.popNextAt += 0x1f4; else SC.popNextAt = -1, SC.adOn = 0, SC_stopBGAnim(); } else { SC.popI++; SecretPopup_AssignSecret(&SC.pop, SC.popSecret, SC.popTypes[SC.popI % SC.popN]); SC_popShow(1); SC.popStep = 0, SC.popNextAt += 0xdac - 0x1f4; // il timer ripete ogni 3,5 s dall'inizio } } static void SC_everything(void) { cJSON *w; cJSON_ArrayForEach(w, data_get("weapons")) po_push("UnlockedWeapons", w->string); // (sic) anche i doppioni PlayerOptions_Save(); cJSON_ArrayForEach(w, po("UnlockedWeapons")) { cJSON *d = tbl0("weapons", cJSON_GetStringValue(w)); if (d) obj_set(d, "isUnlocked", cJSON_CreateTrue()); } } static void SC_everywhere(void) { static const char *const H[] = { "FOREST", "LIBRARY", "WAREHOUSE", "TOWER", "CHAPEL" }, *const S[] = { "LIBRARY", "WAREHOUSE", "TOWER", "CHAPEL" }; for (int i = 0; i < 5; i++) po_push("UnlockedHypers", H[i]); for (int i = 0; i < 4; i++) po_push("UnlockedStages", S[i]); PlayerOptions_Save(); cJSON *v; cJSON_ArrayForEach(v, po("UnlockedStages")) { cJSON *d = tbl0("stages", cJSON_GetStringValue(v)); if (d) obj_set(d, "unlocked", cJSON_CreateTrue()), obj_set(d, "hidden", cJSON_CreateFalse()); } cJSON_ArrayForEach(v, po("UnlockedHypers")) { cJSON *d = tbl0("stages", cJSON_GetStringValue(v)); if (d) obj_set(cJSON_GetObjectItem(d, "hyper"), "unlocked", cJSON_CreateTrue()); } } static void SC_spinScreen(void) { // la camera della scena fa due giri in 2 s (e l'IntroScene uno: qui gira solo la scena) SC.inputEnabled = 0; SC.spinT0 = SC.t, SC.spinTo = 2 * (frand() >= 0.5f ? 6.28319f : -6.28319f); } static void SC_onCheatActivated(const char *type) { if (!strcmp(type, "Spinnn")) SC_spinScreen(); if (!strcmp(type, "Everything")) SC_everything(); if (!strcmp(type, "Everywhere")) SC_everywhere(); if (cJSON_IsTrue(cJSON_GetObjectItem(cJSON_GetObjectItem(data_get("secrets"), type), "isModifier"))) { SpellsManager_StartSpell(type); return; } for (int i = 0; i < SC.n; i++) if (SecretsManager_checkIfSecretAchieved(SC.p[i].secret)) obj_set(cJSON_GetObjectItem(data_get("secrets"), SC.p[i].secret), "achieved", cJSON_CreateTrue()); SecretPopup_AssignMultipleSecret(&SC.conf, SC.Highlighted); SC_onAchievementsUnlocked(type); } static void CollectionSecretScene_create(void) { memset(&SC, 0, sizeof(SC)); SC.active = 1, SC.inputEnabled = 1, SC.iconA = 1, SC.shakeT0 = SC.spinT0 = -1e9f, SC.popNextAt = -1; BMFont_load(&FontRune, "runeFont-export"), BMFont_load(&FontTitle, "titleFont-export"); if (po_has("CollectedItems", "RELIC_MIRROR") && po_has("CollectedItems", "RELIC_TRUMPET") && po_has("UnlockedWeapons", "JUBILEE") && po_is("HasSeenFinalFireworks")) obj_set(cJSON_GetObjectItem(data_get("secrets"), "MaFaiPianooo"), "hidden", cJSON_CreateFalse()); // preload static char bgm[64], mod[32]; // la musica dei segreti, poi la scelta di prima resta salvata snprintf(bgm, sizeof(bgm), "%s", po_str("SelectedBGM") ? po_str("SelectedBGM") : ""), snprintf(mod, sizeof(mod), "%s", po_str("SelectedBGMMod") ? po_str("SelectedBGMMod") : ""); po_sets("SelectedBGM", "BGM_Secret"), po_sets("SelectedBGMMod", "Normal"); Sound_SetupAndPlayBGM_Banger(1); po_sets("SelectedBGM", bgm), po_sets("SelectedBGMMod", mod); cJSON *s; cJSON_ArrayForEach(s, data_get("secrets")) { // achieved = checkIfSecretAchieved anche per quelli nascosti obj_set(s, "achieved", SecretsManager_checkIfSecretAchieved(s->string) ? cJSON_CreateTrue() : cJSON_CreateFalse()); if (cJSON_IsTrue(cJSON_GetObjectItem(s, "hidden")) || SC.n >= SC_MAX) continue; SecretPanel *p = &SC.p[SC.n]; p->secret = s->string, p->num = SC.n; // num resta undefined nell'originale: qui l'indice UIButton_set(&p->hit, "", 0, 0, 0x1a4, 0x28, 1, 0, 0); SC.n++; } SC.h = SC_ROWS * SC.n; SC.scY = SC.MaxY = 0.5f * SC.h, SC.MinY = 0; // SetSize: MaxY = y, MinY = y - h / 2 UIButton_set(&SC.inputBackground, "", 0x2f8, 0x15e, 0x15e, 0x32, 1, 0.5f, 0.5f); const Frame *kf = frame_get("UI", "openKeyboardButton.png"); UIButton_set(&SC.keyboardIcon, "", 0x2f8, 0x1f4, kf ? kf->sw : 32, kf ? kf->sh : 32, 1, 0.5f, 0.5f); UIButton_on(&SC.keyboardIcon, SC_onKeyboardIcon, NULL); UIButton_set(&SC.hiddenKeyHelper, "", -0x3e8, -0x3e8, 1, 1, 1, 0.5f, 0.5f); UIButton_set(&SC.hiddenKeyBlocker, "", -0x3e8, -0x3e8, 1, 1, 1, 0.5f, 0.5f); for (int i = 0; i < SC_KEYS; i++) { SC.keyChar[i] = SC_CHARS[i], SC.keyX[i] = 0x24a + 0x35 * (i % 7), SC.keyY[i] = 0x140 + 0x3f * (i / 7); UIButton_set(&SC.keys[i], "", SC.keyX[i] - 0xf, SC.keyY[i] + 0x50, 0x32, 0x37, 1, 0, 0); // il rettangolo di pointerClicked UIButton_on(&SC.keys[i], SC_keyClicked, (void *)(intptr_t)i); } SC.pfx = particles_add(), children_remove(&SC.pfx->s), SC.pfx->scrollFactor0 = 1; const Frame *R[5]; for (int i = 0; i < 5; i++) R[i] = frame_get("vfx", TextFormat("_runes_0%d.png", i + 2)); SC.pfxEmitter = particles_createEmitter(SC.pfx, (EmitterConfig){ .frames = { R[0], R[1], R[2], R[3], R[4] }, .nframes = 5, .lifespan = EOP(0xbb8), .rotate = ERND(0, 0x168), .angle = ERND(0xf0, 0x136), .speed = ERND(0x64, 0xe6), .quantity = 1, .scale = ERANGE(1, 3), .alpha = ERANGE(1, 0), .frequency = 0xb4, .hasZoneRect = 1, .zoneRect = { 0x258, MENU_H, 0x15e, 0x32 }, .on = 1 }); SC.pfx->wellPower = 0xa * 0xc8, SC.pfx->wellEpsilon = 0xc8 * 0xc8, SC.pfx->hasWell = 0; // createGravityWell, inattivo SC.runes = particles_add(), children_remove(&SC.runes->s), SC.runes->scrollFactor0 = 1; SC.runeEmitter = particles_createEmitter(SC.runes, (EmitterConfig){ .frames = { R[0], R[1], R[2], R[3], R[4] }, .nframes = 5, .lifespan = EOP(0x1f4), .rotate = ERND(0, 0x168), .angle = ERND(0xf0, 0x136), .speed = ERND(0x32, 0x96), .quantity = 1, .scale = ERANGE(0.5f, 1), .alpha = ERANGE(1, 0), .on = 0 }); SC_refreshText(); SC_HandleCheats(); SC.Highlighted = SC.n ? SC.p[0].secret : "BossRashBoss"; SC_MakeUIGrid(); if (SC.n) SC_OnPanelClicked(0); } static void SC_pointer(void) { // HandleInput: pointerdown (casella, tastiera, tasti), pointerup sui pannelli, rotellina; pointermove sui tasti Vector2 m = menu_pointer(); if (SC.keyboardEnabled && (GetMouseDelta().x || GetMouseDelta().y)) for (int i = 0; i < SC_KEYS; i++) if (CheckCollisionPointRec(m, (Rectangle){ SC.keyX[i] - 0xf, SC.keyY[i] + 0x50, 0x32, 0x37 })) { SC_moveBlock(i); break; } if (ptr_pressed()) { SC.wasDown = 1; if (CheckCollisionPointRec(m, (Rectangle){ UI_left(&SC.inputBackground), UI_top(&SC.inputBackground), 0x15e, 0x32 })) SC_onInputFocued(); if (CheckCollisionPointRec(m, (Rectangle){ UI_left(&SC.keyboardIcon), UI_top(&SC.keyboardIcon), bW(&SC.keyboardIcon), bH(&SC.keyboardIcon) })) SC_showKeyboard(); if (SC.keyboardEnabled) for (int i = 0; i < SC_KEYS; i++) if (CheckCollisionPointRec(m, (Rectangle){ SC.keyX[i] - 0xf, SC.keyY[i] + 0x50, 0x32, 0x37 })) { SC_keyClicked((void *)(intptr_t)i); break; } } if (ptr_released() && SC.wasDown && CheckCollisionPointRec(m, (Rectangle){ 0, 0x8c, SAFE_WIDTH, MENU_H - 0x40 - 0xc8 })) for (int i = 0; i < SC.n; i++) if (CheckCollisionPointRec(m, (Rectangle){ SC.p[i].hit.x, SC.p[i].hit.y, 0x1a4, 0x28 })) { SC_OnPanelClicked(i); break; } float wh = GetMouseWheelMove(); // ScrollBy(0.4 * deltaY): ~100 per scatto if (wh) SC.scY = fmaxf(SC.MinY, fminf(SC.MaxY, SC.scY + 0.4f * 0x64 * wh)); // semplificazione: il trascinamento della lista (setDraggable) non c'e': rotellina, pad e frecce bastano } static int SC_isKey(UIButton *b) { return b >= &SC.keys[0] && b <= &SC.keys[SC_KEYS - 1]; } static int SC_isPanel(UIButton *b) { return SC.n && b >= &SC.p[0].hit && b <= &SC.p[SC.n - 1].hit; } static void SC_selectPanel(int i) { SC_OnPanelClicked(i), Overlay_ToggleCursorsVisibility(0), SC.highlightVisible = 1; SC_correctScrollableContainerPosition(); SC_hideKeyboard(); } static void CollectionSecretScene_update(float delta) { SC.t += delta; particles_manager_update(SC.pfx, delta); particles_manager_update(SC.runes, delta); if (SC.pfx->hasWell && SC.t >= SC.wellUntil) SC.pfx->hasWell = 0; if (SC.spinT0 > -1e8f && SC.t >= SC.spinT0 + 0x7d0) SC.inputEnabled = 1, SC.spinT0 = -1e9f; SC_popUpdate(); for (int i = 0; i < SC.n; i++) SC.p[i].hit.x = SC_panelX() + 0xa, SC.p[i].hit.y = SC_panelY(i) + 0x14; // myInteractable a (10, 20) for (int i = SC_KEYS; i-- > 0;) SC.keys[i].visible = SC.keyboardEnabled; // tastiera fisica: keydown di Phaser (le lettere, le cifre e '-' sono anche i codici dei combo) for (int q = 0; q < nKeyQ; q++) { int k = KeyQ[q]; int nav = k == KEY_ENTER || k == KEY_KP_ENTER || (k >= KEY_RIGHT && k <= KEY_UP); int code = (k >= KEY_A && k <= KEY_Z) || (k >= KEY_ZERO && k <= KEY_NINE) ? k : k == KEY_MINUS ? 189 : 1000 + k; int printable = (k >= KEY_SPACE && k <= KEY_GRAVE) || (k >= KEY_KP_0 && k <= KEY_KP_EQUAL); SC_keyDown(code, printable, k == KEY_BACKSPACE || k == KEY_DELETE, nav); } const char *spell = getenv("VS_SPELL"); // sviluppo: digita la spell (una lettera ogni 100 ms dopo 1 s) nella casella static int typed; if (SC.t <= delta) typed = 0; if (spell && SC.t > 0x3e8 && typed <= (int)strlen(spell)) { if (!typed) { if (getenv("VS_SECRETKBD")) SC_showKeyboard(); else SC_onInputFocued(); typed = 1; } // VS_SECRETKBD: con la tastiera a schermo else if (SC.t > 0x3e8 + 0x64 * typed && getenv("VS_SECRETKBD")) { int c = spell[typed - 1] >= 'a' ? spell[typed - 1] - 'a' : 26; SC_keyClicked((void *)(intptr_t)c), typed++; } else if (SC.t > 0x3e8 + 0x64 * typed) { int c = spell[typed - 1] >= 'a' && spell[typed - 1] <= 'z' ? spell[typed - 1] - 32 : spell[typed - 1]; SC_keyDown(c == '-' ? 189 : c, 1, 0, 0), typed++; } } // update(): reagisce al cambio di selezione della griglia UIButton *sel = OV.UI_selected, *prev = UIGrid.previousGameObject; if (UIGrid.on && sel != prev) { SC_onInputBlured(); OV.blockWASD = 0; if (SC_isPanel(sel)) SC_selectPanel((int)((SecretPanel *)(void *)sel - SC.p)); else if (SC_isKey(sel)) SC_moveBlock((int)(sel - SC.keys)), OV.blockWASD = 1; else { Overlay_ToggleCursorsVisibility(1), SC.highlightVisible = 0; if (sel == &SC.hiddenKeyHelper) { // ai bordi della tastiera si salta da un lato all'altro della riga int j = SC_isKey(prev) ? (int)(prev - SC.keys) : -1, to = -1; static const int E[8][2] = { { 0, 6 }, { 6, 0 }, { 7, 13 }, { 13, 7 }, { 14, 20 }, { 20, 14 }, { 21, 27 }, { 27, 21 } }; for (int e = 0; e < 8 && j >= 0; e++) if (E[e][0] == j) to = E[e][1]; if (to >= 0) UIGrid_SelectAt(2 + to % 7, 4 + to / 7), OV.UI_selected = &SC.keys[to]; else if (prev == &SC.inputBackground || prev == &SC.keyboardIcon) UIGrid_SelectAt(0, 1), OV.UI_selected = &SC.p[0].hit, SC_selectPanel(0); else SC_onInputFocued(); } else if (sel == &SC.hiddenKeyBlocker) { if (prev == &SC.keyboardIcon) UIGrid_SelectAt(2, 2), OV.UI_selected = &SC.keyboardIcon; else UIGrid_SelectAt(2, 1), OV.UI_selected = &SC.inputBackground, SC_onInputFocued(), SC_hideKeyboard(); } else if (sel == &SC.inputBackground) SC_onInputFocued(), SC_hideKeyboard(); else if (sel == &TB.BackButton) SC_hideKeyboard(), UIGrid_SelectAt(0, 0); } } SC_pointer(); } static void SC_frame2(const char *atlas, const char *name, float x, float y, float sx, float sy, float ang, Color c) { // sprite con scala diversa sui due assi, origine 0.5 const Frame *f = frame_get(atlas, name); if (!f) return; rlPushMatrix(); rlTranslatef(x, y, 0); rlRotatef(ang, 0, 0, 1); rlScalef(sx, sy, 1); DrawTexturePro(*f->tex, (Rectangle){ f->x, f->y, f->w, f->h }, (Rectangle){ -0.5f * f->sw + f->ox, -0.5f * f->sh + f->oy, f->w, f->h }, (Vector2){ 0, 0 }, 0, c); rlPopMatrix(); } static float SC_yoyo(float t, float dur, float (*ease)(float)) { float p = fmodf(fmaxf(t, 0), 2 * dur) / dur; return ease(p < 1 ? p : 2 - p); } static float SC_linear(float k) { return k; } static float SC_quadInOut(float k) { return k < 0.5f ? 2 * k * k : 1 - 2 * (1 - k) * (1 - k); } static void SC_drawUnlockEffect(void) { // 128 contenitori con le stesse 4 strisce, ruotati e stirati in ritardo di 128 ms l'uno float a = SC_bgAlpha(); if (a <= 0.001f) return; float t = SC.t, y1 = 0x64 - 0x12c * SC_yoyo(t, 0x7d0, Ease_SineInOut), x2 = -0x64 + 0x12c * SC_yoyo(t, 0xfa0, Ease_SineInOut); float y3 = -0x64 + 0x12c * SC_yoyo(t, 0x7d0, Ease_SineInOut), x4 = 0x64 - 0x12c * SC_yoyo(t, 0xfa0, Ease_SineInOut); Color c = rgb(SC.sheenTint, a); for (int i = 0; i < 0x80; i++) { float lt = t - 0x80 * i, ang = lt < 0 ? 0 : 0x168 * fmodf(lt, 0x1770) / 0x1770, k = lt < 0 ? 0 : SC_yoyo(lt, 0x1770, SC_quadInOut); rlPushMatrix(); rlTranslatef(0.5f * MENU_W, 0.5f * MENU_H + 0x32, 0); rlRotatef(ang, 0, 0, 1); rlScalef(1 + k, 1 + 3.5f * k, 1); SC_frame2("UI", "sheen04.png", 0, y1, 0xa, 0.1f, 0, c); SC_frame2("UI", "sheen05.png", x2, 0, 0xa, 0.1f, 0x5a, c); SC_frame2("UI", "sheen06.png", 0, y3, 0xa, 0.1f, 0xb4, c); SC_frame2("UI", "sheen07.png", x4, 0, 0xa, 0.1f, 0x10e, c); rlPopMatrix(); } } static void SC_drawPanel(int i) { // CollectionSecretPanel (0x71a7) const char *k = SC.p[i].secret; cJSON *s = cJSON_GetObjectItem(data_get("secrets"), k); float x = SC_panelX(), y = SC_panelY(i); int ach = cJSON_IsTrue(cJSON_GetObjectItem(s, "achieved")); TS_frame("UI", "menu_checkbox_24_bg.png", x + 0x20, y + 0x28, 0.5f, 0.5f, PixelScale, 0, WHITE, 0); if (ach) TS_frame("UI", "menu_checkbox_24_checkmark.png", x + 0x20, y + 0x28, 0.5f, 0.5f, PixelScale, 0, WHITE, 0); const char *d = lang_text("secretLang", k, "description", s); float h = ui_wrap_text(d, 0, 0, 16, 0x136, 0, WHITE, 0); ui_wrap_text(d, x + 0x36, y + 0x28 - 0.5f * h, 16, 0x136, 0, WHITE, 1); float ix = x + 0x177, iy = y + 0x28; if (!ach) { TS_frame("UI", "QuestionMark.png", ix, iy, 0.5f, 0.5f, 2 * PixelScale, 0, WHITE, 0); return; } const char *atlas = NULL, *fr = NULL, *bg = NULL, *ov = NULL, *v; float ox = 0.5f; if ((v = str(s, "weaponToUnlock"))) atlas = str(tbl0("weapons", v), "texture"), fr = str(tbl0("weapons", v), "frameName"); if ((v = str(s, "characterToUnlock"))) atlas = "UI", fr = str(tbl0("characters", v), "portraitName") ? str(tbl0("characters", v), "portraitName") : "QuestionMark.png"; if ((v = str(s, "stageToUnlock"))) atlas = "UI", fr = str(tbl0("stages", v), "frameNameUnlock") ? str(tbl0("stages", v), "frameNameUnlock") : "QuestionMark.png"; if ((v = str(s, "hyperToUnlock"))) atlas = "UI", fr = str(tbl0("stages", v), "frameName") ? str(tbl0("stages", v), "frameName") : "QuestionMark.png"; if ((v = str(s, "relicToUnlock"))) { cJSON *it = cJSON_GetObjectItem(data_get("items"), v); atlas = str(it, "texture"), fr = str(it, "frameName"); } if (Secret_has(s, "goldPrize")) atlas = "items", fr = str(tbl0("weapons", str(s, "weaponIcon")), "frameName"), ox = 0.75f, ov = "MoneyBagGreen.png"; if ((v = str(s, "powerUpToUnlock"))) atlas = "items", fr = str(tbl0("powerups", v), "frameName"), ov = NULL; if (Secret_has(s, "arcanaToUnlock")) atlas = "items", fr = str(tbl0("arcana", TextFormat("%d", (int)num(s, "arcanaToUnlock", 0))), "frameName"), bg = "frameG.png", ov = NULL; if (bg) TS_frame("UI", bg, ix, iy, 0.5f, 0.5f, 2, 0, WHITE, 0); if (atlas && fr) TS_frame(atlas, fr, ix, iy, ox, 0.5f, 2 * PixelScale, 0, WHITE, 0); if (ov) TS_frame("UI", ov, ix, iy, 0.5f, 0.5f, 2 * PixelScale, 0, WHITE, 0); } static void CollectionSecretScene_draw(void) { rlPushMatrix(); // camera della scena: scossone e giro (spinScreen) float sh = SC.t < SC.shakeT0 + 0x96 ? 1 : 0; rlTranslatef(sh * (frand() * 2 - 1) * 0.005f * MENU_W, sh * (frand() * 2 - 1) * 0.005f * MENU_H, 0); if (SC.spinT0 > -1e8f) { rlTranslatef(0.5f * MENU_W, 0.5f * MENU_H, 0); rlRotatef(SC.spinTo * lerp01(SC.t, SC.spinT0, 0x7d0) * RAD2DEG, 0, 0, 1); rlTranslatef(-0.5f * MENU_W, -0.5f * MENU_H, 0); } TS_nine("frame5_c4.png", 12, 12, SAFE_CX, SC_Y + 0.5f * (MENU_H - 0x40), 1.75f * SAFE_WIDTH, MENU_H - 0x40, PixelScale, PixelScale, 0, WHITE); DrawLineEx((Vector2){ SAFE_WIDTH + 0x14, SC_Y + 0x3c }, (Vector2){ SAFE_WIDTH + 0x14, SC_Y + MENU_H - 0x6e }, 1, WHITE); menu_clip(0, 0x8c - 5, SAFE_WIDTH, MENU_H - 0x40 - 0xc8 + 5); // la maschera della lista for (int i = 0; i < SC.n; i++) SC_drawPanel(i); if (SC.highlightVisible && SC.n) { int i = SC.currentSelectedNum; nine_wh("selectionSquareActive_03.png", 7, 7, (Rectangle){ SC_panelX() + 0xd, SC_panelY(i) + 0x16, 0x17c, 0x23 }, WHITE); } menu_unclip(); SecretPopup_draw(&SC.conf, SAFE_L - 0xb6, MENU_H - 0x40 - 0x32, PixelScale); menu_clip(0x217, 0x78, 0x1c2, 0x22b); // CollectionSecretParticles: la loro maschera particles_manager_draw(SC.pfx); menu_unclip(); DrawRectangleRec((Rectangle){ 0x2f8 - 0.5f * 0x15e, 0x15e - 0.5f * 0x32, 0x15e, 0x32 }, GetColor(0x2c3055ff)); particles_manager_draw(SC.runes); BMFont_drawOrigin(&FontRune, SC.shown, 0x2f8, SC_textY(), 0.5f, 0.5f, 1.5f * SC_textScale(), WHITE); for (int i = 0; i < SC_KEYS; i++) { float a = SC_keyAlpha(i); char ch[2] = { SC.keyChar[i], 0 }; if (a > 0.001f) BMFont_drawOrigin(&FontTitle, ch, SC.keyX[i], SC.keyY[i], 0, 0, 130.0f / 80, Fade(WHITE, a)); } if (SC.iconA > 0) TS_frame("UI", "openKeyboardButton.png", 0x2f8, 0x1f4, 0.5f, 0.5f, 1, 0, Fade(WHITE, SC.iconA), 0); float ba = SC_ease(SC.blockFrom, SC.blockTo, SC.blockT0, 0x64); if (ba > 0.001f) nine_wh("selectionSquareActive_03.png", 7, 7, (Rectangle){ SC.blockX - 0x14, SC.blockY - 0x14, 0x28, 0x28 }, Fade(WHITE, ba)); if (SC.inputFocused) nine_wh("selectionSquareActive_03.png", 7, 7, (Rectangle){ 0x2f8 - 0xb4, 0x15e - 0x1e, 0x168, 0x3c }, WHITE); int ach, tot; SC_counts(&ach, &tot); const char *hd = lang1("secrets_header", TextFormat("%d", ach)), *p1 = strstr(hd, "%1"); char hb[160]; // due parametri: %0 e %1 if (p1) snprintf(hb, sizeof(hb), "%.*s%d%s", (int)(p1 - hd), hd, tot, p1 + 2), hd = hb; TS_text(hd, 0x15e, 0x5f, fit_size(hd, 16, 0xfa), 2 * PixelScale, 0, WHITE); const char *cs = tr("secrets_castspell"); TS_text(cs, 0x2f8, 0x5f, fit_size(cs, 16, 0xfa), 2 * PixelScale, 0, WHITE); UIButton sb; // ScrollBar e cursore UIButton_set(&sb, "Scrollbar", 0x208, 0x8c, 8, MENU_H - 0x40 - 0xc8, PixelScale, 0.5f, 0); UIButton_draw(&sb, 1); const Frame *cur = frame_get("UI", "menu_slider_button_strip3.png"); float v = SC.MaxY > 0 ? 1 - SC.scY / SC.MaxY : 0, ch = cur ? cur->sh * PixelScale : 0; TS_frame("UI", "menu_slider_button_strip3.png", 0x208, 0x8c + fmaxf(0, fminf(v, 1)) * ((MENU_H - 0x40 - 0xc8) * PixelScale - ch), 0.5f, 0, PixelScale, 0, WHITE, 0); SC_drawUnlockEffect(); float px = 0.5f * MENU_W - 0.5f * 0.96f * SAFE_WIDTH + 0x28, py = 0.5f * MENU_H; // displayHeight = 0 (scaleY 0) if (SC.popOn) SecretPopup_draw(&SC.pop, px, py, SC_popScale()); if (SC.adOn) { // AchiAdGroup: quanti premi float ax = px + 0.96f * SAFE_WIDTH + 0x40, ay = py + 0x34, k = 1 - 0.1f * SC_yoyo(SC.t - SC.adT0, 0x640, SC_linear); TS_frame("vfx", "PrizeBG.png", ax, ay, 0.5f, 0.5f, 4 * k, 0, Fade(WHITE, 0.5f), 0); TS_text(TextFormat("%d", SC.popN), ax, ay - 8, 16, 3, 0, WHITE); TS_text(tr("postGame_unlocks"), ax, ay + 0x18, 16, 1, 0, WHITE); } rlPopMatrix(); } // ============================================================================ // 0x9240: SpellsManager e le spell modificatrici dei segreti: ognuna lancia subito una partita (Start) e la cambia // alla fine della MainScene.create (ActivateSpells, una volta sola) // ============================================================================ static void SceneManager_LaunchMainScene(void); static struct { const char *type[8]; int n; char saveStage[32], saveCharacter[32], saveBGM[64], saveBGMMod[32]; } Spells; static void SC_stop(void) { Sound_StopMusic(); SC.active = 0; Overlay_DestroyGrid(); OV.blockWASD = 0; } // StopMusic(BGM_Secret), scene.stop(CollectionSecretScene) static void Spells_save(void) { snprintf(Spells.saveStage, 32, "%s", po_str("SelectedStage") ?: ""), snprintf(Spells.saveCharacter, 32, "%s", po_str("SelectedCharacter") ?: ""); snprintf(Spells.saveBGM, 64, "%s", po_str("SelectedBGM") ?: ""), snprintf(Spells.saveBGMMod, 32, "%s", po_str("SelectedBGMMod") ?: ""); } static void Spells_restore(void) { po_sets("SelectedStage", Spells.saveStage), po_sets("SelectedCharacter", Spells.saveCharacter); po_sets("SelectedBGMMod", Spells.saveBGMMod), po_sets("SelectedBGM", Spells.saveBGM); } static void SpellsManager_StartSpell(const char *t) { static const char *const K[6] = { "PopTheCorn", "IWantToSeeItAgain", "Festival", "Jupiter", "Mars", "Halloween" }; int k = -1; for (int i = 0; i < 6; i++) if (!strcmp(t, K[i])) k = i; if (k < 0) return; // Spinnn, Everything, Everywhere: solo nella schermata if (Spells.n < 8) Spells.type[Spells.n++] = K[k]; // AddSpell if (k == 5) IsHalloween = 1; if (k == 5 || k == 2) Spells_save(); SC_stop(); if (k == 5) { // 0x15a9e: Bone Zone col brano B, uno dei quattro personaggi con la skin di Halloween static const char *const C[4] = { "MORTACCIO", "CAVALLO", "MARIA", "TATANKA" }; po_sets("SelectedStage", "BONEZONE"), po_sets("SelectedBGM", str(tbl0("stages", "BONEZONE"), "sideBBGM") ?: ""); po_sets("SelectedCharacter", C[(int)floorf(frand() * 4)]); } else if (k == 2) { // 0x157e2 Kamiki: Tatanka col brano dei gatti in Hyper po_sets("SelectedBGM", "BGM_Gatti"), po_sets("SelectedBGMMod", "Hyper"), po_sets("SelectedCharacter", "TATANKA"); } else if (k == 0) { // 0x5e76: Green Acres po_sets("SelectedStage", "GREENACRES"), po_sets("SelectedBGM", str(tbl0("stages", "GREENACRES"), "BGM") ?: ""); } else if (k == 1) { // 0xc243: Moongolow, con un personaggio valido o Antonio po_sets("SelectedStage", "STAGEX"); if (!Moon_validCharacter()) po_sets("SelectedCharacter", "ANTONIO"); } SceneManager_LaunchMainScene(); } static void Clover_go(void *ctx) { ((Pickup *)ctx)->time = 1; } // tween di 'time' a 1 in 16 ms static void SpellsManager_ActivateSpells(void) { for (int s = 0; s < Spells.n; s++) { const char *t = Spells.type[s]; Player *p = Core.Player; if (!strcmp(t, "Halloween")) { Spells_restore(); static const char *const C[4] = { "MORTACCIO", "CAVALLO", "TATANKA", "MARIA" }; for (int i = 0; i < 4; i++) PlayerOptions_UnlockSkin(C[i], 4); // HALLOWS } else if (!strcmp(t, "Jupiter") || !strcmp(t, "Mars")) { // 0x32c0 / 0x14553 world_gravityY = !strcmp(t, "Jupiter") ? 0x64 : -0x64; p->speed -= 0.4f, p->moveSpeed += 0.25f; Core.Magnet->radius += Core.Magnet->radius; Magnet_RefreshSize(Core.Magnet); Core.Magnet->percentage += 1; } else if (!strcmp(t, "Festival")) { Core_AddWeapon("JUBILEE", 1), Core_AddWeapon("CHERRY", 1), Core_AddWeapon("LUCK", 1); Core_debug_destructibles(1); Spells_restore(); float step = 2 * PI / (0xa / 3.0f), r = 0.5f * game_width; for (int i = 0; i < 0xa; i++) { // dieci quadrifogli in cerchio che arrivano uno ogni 100 ms Pickup *c = Core_MakePickup(p->s.x + sinf(step * i) * r, p->s.y + cosf(step * i) * r, "CLOVER"); if (c) c->goToPlayer = 1, time_addEvent(0x64 * i + 0x10, 0, 0, Clover_go, c); } } else if (!strcmp(t, "PopTheCorn")) { float step = 2 * PI / 0x24; static const float R[3] = { 0x7d, 0xaf, 0xe1 }; for (int i = 0; i < 0x24; i++) for (int j = 0; j < 3; j++) { Pickup *c = Core_MakePickup(p->s.x + R[j] * sinf(step * i), p->s.y + R[j] * cosf(step * i), "ROAST"); if (c) sprite_setFrame(&c->s, frame_get("items", "corn.png")); } } } Spells.n = 0; } static struct { int active, launch; } SM; static const char *menu_skip; static void SceneManager_BackFromCharSelectionScene(void), SceneManager_BackFromStageSelectionScene(void); // launch: LaunchMainScene richiesta static void SceneManager_LaunchMainScene(void) { SM.launch = 1; } // stop di UI_topBar, IntroScene, UI_mainMenu; launch MainScene static void SceneManager_StartFromMainMenu(void) { Overlay_DestroyGrid(); MM.visible = 0, MM.awake = 0; CharSelectionScene_create(); TopBar_EnableBack(SceneManager_BackFromCharSelectionScene); } static void SceneManager_BackFromCharSelectionScene(void) { Overlay_DestroyGrid(); CS.active = 0; MM.visible = 1, MM.awake = 1; TopBar_EnableOptions(SceneManager_OptionsFromMainMenu); TopBar_DisableBack(); IntroScene_MakeUIGrid(&MM.StartButton); OV.OnCancelCallback = IntroScene_cancel; } static const char *const QuickStages[] = { "FOREST", "LIBRARY", "WAREHOUSE", "TOWER", "CHAPEL", "GREENACRES", "BONEZONE" }; // GetValidQuickStages static void SceneManager_QuickStartFromMainMenu(void) { Overlay_DestroyGrid(); const char *ch = "ANTONIO", *valid[16]; int n = cJSON_GetArraySize(po("BoughtCharacters")), nv = 0; if (n > 0) ch = cJSON_GetStringValue(cJSON_GetArrayItem(po("BoughtCharacters"), RND_between(0, n - 1))); po_sets("SelectedCharacter", ch); cJSON *v; cJSON_ArrayForEach(v, po("UnlockedStages")) for (int i = 0; i < 7; i++) if (cJSON_IsString(v) && !strcmp(v->valuestring, QuickStages[i]) && nv < 16) valid[nv++] = v->valuestring; if (nv) po_sets("SelectedStage", valid[RND_between(0, nv - 1)]); // RND.pick([]) = undefined: qui resta lo stage di prima cJSON *c = tbl0("characters", po_str("SelectedCharacter")); if (str(c, "bgm")) po_sets("SelectedBGM", str(c, "bgm")), po_sets("SelectedBGMMod", "Normal"); else if (tbl0("stages", po_str("SelectedStage"))) po_sets("SelectedBGM", str(tbl0("stages", po_str("SelectedStage")), "BGM") ?: "BGM_Forest"), po_sets("SelectedBGMMod", "Normal"); SceneManager_LaunchMainScene(); } static void SceneManager_ExitOptions(void) { // IntroScene ripresa, griglia sul bottone Opzioni Overlay_DestroyGrid(); Opt_flushLang(), OP.active = 0; MM.visible = 1, MM.awake = 1; TopBar_EnableOptions(SceneManager_OptionsFromMainMenu); TopBar_DisableBack(); IntroScene_MakeUIGrid(&TB.OptionsButton); OV.OnCancelCallback = IntroScene_cancel; } static void SceneManager_ExitRecovery(void) { // (sic) si torna al menu principale, non alle Opzioni Overlay_DestroyGrid(); RC_importStop(); RC.active = 0; MM.visible = 1, MM.awake = 1; TopBar_EnableOptions(SceneManager_OptionsFromMainMenu); TopBar_DisableBack(); IntroScene_MakeUIGrid(&TB.OptionsButton); OV.OnCancelCallback = IntroScene_cancel; } static void SceneManager_RecoveryFromOptions(void) { // launch(RecoveryScene), stop(OptionsScene), Indietro -> ExitRecovery Overlay_DestroyGrid(); Opt_flushLang(), OP.active = 0; TopBar_EnableBack(SceneManager_ExitRecovery); RecoveryScene_create(); } static void SceneManager_OptionsFromMainMenu(void) { // launch(OptionsScene), pause(IntroScene), Indietro -> ExitOptions Overlay_DestroyGrid(); MM.visible = 0, MM.awake = 0; OptionsScene_create(); TopBar_EnableBack(SceneManager_ExitOptions); } static void SceneManager_PowerUpFromMainMenu(void) { Overlay_DestroyGrid(); MM.visible = 0, MM.awake = 0; PowerUpScene_create(); TopBar_EnableBack(SceneManager_BackFromPowerUpSelectionScene); } static void SceneManager_BackFromPowerUpSelectionScene(void) { Overlay_DestroyGrid(); PU.active = 0; MM.visible = 1, MM.awake = 1; TopBar_EnableOptions(SceneManager_OptionsFromMainMenu); TopBar_DisableBack(); IntroScene_MakeUIGrid(&MM.PowerupButton); OV.OnCancelCallback = IntroScene_cancel; } static void SceneManager_CollectionFromMainMenu(void) { Overlay_DestroyGrid(); MM.visible = 0, MM.awake = 0; CollectionWeaponScene_create(); TopBar_EnableBack(SceneManager_BackFromCollection); } static void SceneManager_BackFromCollection(void) { Overlay_DestroyGrid(); CW.active = 0; MM.visible = 1, MM.awake = 1; TopBar_EnableOptions(SceneManager_OptionsFromMainMenu); TopBar_DisableBack(); IntroScene_MakeUIGrid(&MM.CollectionButton); OV.OnCancelCallback = IntroScene_cancel; } static void SceneManager_AchievementsFromMainMenu(void) { Overlay_DestroyGrid(); MM.visible = 0, MM.awake = 0; CollectionAchievementsScene_create(); TopBar_EnableBack(SceneManager_BackFromAchievements); } static void SceneManager_BackFromAchievements(void) { Overlay_DestroyGrid(); CA.active = 0; MM.visible = 1, MM.awake = 1; TopBar_EnableOptions(SceneManager_OptionsFromMainMenu); TopBar_DisableBack(); IntroScene_MakeUIGrid(&MM.AchievementButton); OV.OnCancelCallback = IntroScene_cancel; } static void CreditsScene_create(void), SceneManager_BackFromCredits(void); static void SceneManager_Credits_FromMainMenu(void) { Overlay_DestroyGrid(); MM.visible = 0, MM.awake = 0; CreditsScene_create(); TopBar_EnableBack(SceneManager_BackFromCredits); } static void SceneManager_BestiaryFromMainMenu(void) { Overlay_DestroyGrid(); MM.visible = 0, MM.awake = 0; CollectionBestiaryScene_create(); TopBar_EnableBack(SceneManager_BackFromBestiary); } static void SceneManager_BackFromBestiary(void) { Overlay_DestroyGrid(); BE.active = 0; Sound_StopMusic(); // StopMusic(BGM_Bestiary) MM.visible = 1, MM.awake = 1; TopBar_EnableOptions(SceneManager_OptionsFromMainMenu); TopBar_DisableBack(); IntroScene_MakeUIGrid(&MM.BestiaryButton); OV.OnCancelCallback = IntroScene_cancel; } static void SceneManager_SecretsFromMainMenu(void) { Overlay_DestroyGrid(); MM.visible = 0, MM.awake = 0; CollectionSecretScene_create(); TopBar_EnableBack(SceneManager_BackFromSecrets); } static void SceneManager_BackFromSecrets(void) { Overlay_DestroyGrid(); SC.active = 0; OV.blockWASD = 0; // CollectionSecretInput.destroy Sound_StopMusic(); // StopMusic(BGM_Secret) MM.visible = 1, MM.awake = 1; TopBar_EnableOptions(SceneManager_OptionsFromMainMenu); TopBar_DisableBack(); IntroScene_MakeUIGrid(&MM.SecretsButton); OV.OnCancelCallback = IntroScene_cancel; } static void SceneManager_StartFromCharSelection(void) { Overlay_DestroyGrid(); if (cJSON_GetArraySize(po("UnlockedStages")) <= 1 && cJSON_GetArraySize(po("UnlockedHypers")) <= 0) { CS.active = 0; SceneManager_LaunchMainScene(); return; } CS.active = 0; StageSelectionScene_create(); TopBar_EnableBack(SceneManager_BackFromStageSelectionScene); } static void SceneManager_BackFromStageSelectionScene(void) { Overlay_DestroyGrid(); SS.active = 0; Sound_StopMusic(); MM.visible = 1, MM.awake = 1; TopBar_EnableOptions(SceneManager_OptionsFromMainMenu); TopBar_DisableBack(); IntroScene_MakeUIGrid(&MM.StartButton); OV.OnCancelCallback = IntroScene_cancel; } static void SceneManager_StartFromStageSelection(void) { SS.active = 0; SceneManager_LaunchMainScene(); } // Avvio del menu: all'accensione e da StartFromPostGame / ExitCreditEndingScene (scene.start(IntroScene)) // ============================================================================ // Finali: UI_finalFireworksScene (0x1049c), UI_creditsEndingScene (0x8b19), UI_creditsScene (0x7e6c). // Le prime due partono a partita chiusa (SceneManager.EnterGameEndScene / EnterCreditEndingScene): menu_start le // avvia al posto dell'IntroScene quando pending_ending e' impostato; finiti i crediti si torna all'IntroScene. // ============================================================================ static int pending_ending; // 1 = EnterGameEndScene (fuochi, poi crediti), 2 = EnterCreditEndingScene (solo crediti) static char **Credits_lines(const char *which, int *n) { // data/credits.json (tools/extract_data.js): le chiavi fra \1 e \2 nella lingua corrente static cJSON *cj; if (!cj) { char *t = LoadFileText(vs_path("data/credits.json")); cj = t ? cJSON_Parse(t) : NULL; if (t) UnloadFileText(t); static const char *const PORT[] = { // dopo il marchio, in tutte e due le liste; gli stessi nomi dei Credits del README "", "", "PS VITA PORT", "• RaZorGaToR", "", "SPECIAL THANKS", "• Wolff (WolffsRoom): LiveArea art,", " animated menu, button glyphs,", " interface ideas, trophies", "• Marcin (DrakonPL): performance work", " behind v1.1", "• Richard Davey / Photon Storm: Phaser", "• Rex: phaser3-rex-plugins", "• ironwallaby: delaunay-fast", "• Rinnegatamante: vitaGL, raylib Vita port,", " ShaRKBR33D", "• Ramon Santamaria (raysan5): raylib", "• Northfear: SDL2 Vita port", "• Dave Gamble and contributors: cJSON", "• The VitaSDK team", "• TheFloW: VitaShell", "• Fabrice Bellard and Charlie Gordon: QuickJS", "• PetterS: QuickJS Python bindings", "• FFmpeg, imageio-ffmpeg, PyInstaller" }; for (cJSON *a = cj ? cj->child : NULL; a; a = a->next) for (int i = (int)(sizeof(PORT) / sizeof(*PORT)) - 1; i >= 0 && cJSON_GetArraySize(a) > 3; i--) cJSON_InsertItemInArray(a, 3, cJSON_CreateString(PORT[i])); } cJSON *a = cJSON_GetObjectItem(cj, which); int m = cJSON_GetArraySize(a); char **out = calloc(m + 1, sizeof(char *)); for (int i = 0; i < m; i++) { const char *s = cJSON_GetStringValue(cJSON_GetArrayItem(a, i)); char b[512]; size_t o = 0; for (const char *p = s ? s : ""; *p && o < sizeof(b) - 64;) { if (*p == 1) { // \1chiave\2 -> Lang.getLang(chiave) const char *e = strchr(p, 2); if (!e) break; char k[64]; snprintf(k, sizeof(k), "%.*s", (int)(e - p - 1), p + 1); o += snprintf(b + o, sizeof(b) - o, "%s", tr(k)); p = e + 1; } else if (*p == '\t') o += snprintf(b + o, sizeof(b) - o, " "), p++; // \t nel canvas: spazio largo else b[o++] = *p++; } b[o < sizeof(b) ? o : sizeof(b) - 1] = 0; size_t len = strlen(b) + 1; out[i] = malloc(len); // gmem, non strdup: Credits_free libera con gmem_free memcpy(out[i], b, len); } *n = m; return out; } static void Credits_free(char **l, int n) { for (int i = 0; i < n; i++) free(l[i]); free(l); } static float Credits_draw(char **l, int n, float cx, float y, float size, float alpha, float clipTop, float clipBottom) { // Text con setText(array): righe unite da \n (anche quelle con \n dentro), allineate a sinistra, blocco con origine (0.5, 0) float lh = size * 1.25f, w = 0; for (int i = 0; i < n; i++) for (const char *p = l[i], *q; *p || p == l[i]; p = *q ? q + 1 : q) { q = strchr(p, '\n'); if (!q) q = p + strlen(p); char b[512]; snprintf(b, sizeof(b), "%.*s", (int)(q - p), p); w = fmaxf(w, MeasureTextEx(vs_font, b, size, 0).x); if (!*q) break; } float x = cx - 0.5f * w, yy = y; for (int i = 0; i < n; i++) { const char *p = l[i]; do { const char *q = strchr(p, '\n'); if (!q) q = p + strlen(p); if (yy + lh > clipTop && yy < clipBottom && alpha > 0) { char b[512]; snprintf(b, sizeof(b), "%.*s", (int)(q - p), p); text_at(b, x, yy, size, 0, 0, Fade(WHITE, alpha)); } yy += lh; p = *q ? q + 1 : q; } while (*p); } return yy - y; // displayHeight } // --- UI_finalFireworksScene (0x1049c): pannello "directer_5", OK, fuochi e raggi, achievement e JUBILEE, Fatto ------ static struct { int active, okGrid, doneOn, swapped, itemShown; float t, tOk, tClick, tDone, tExit; ParticleManager *pfx, *fw; ParticleEmitter *black, *color, *fwE[7]; float raysX[12], raysT[12]; int nRays; UIButton OkButton; GenericPopup gp; float tItem; } FE; static int JustGotJubilee; // Core.JustGotJubilee (lo legge il menu principale) static void CreditsEndingScene_start(void); static void FE_onOk(void *c); static void FE_onDone(void *c); static float FE_fixedW(void) { return 0.8f * SAFE_WIDTH; } static void FinalFireworksScene_start(void) { memset(&FE, 0, sizeof(FE)); FE.active = 1; FE.tOk = FE.tClick = FE.tDone = FE.tExit = FE.tItem = -1; tweens_reset(), time_reset(), children_reset(); // partita chiusa: niente della MainScene resta in giro FE.pfx = particles_add(), children_remove(&FE.pfx->s), FE.pfx->scrollFactor0 = 1; FE.black = CF_rain_in(FE.pfx, 0); // stessa pioggia della CharFound: tint 0, NORMAL FE.fw = particles_add(), children_remove(&FE.fw->s), FE.fw->scrollFactor0 = 1; static const char *const FW[4] = { "PfxYellow.png", "PfxPink.png", "PfxRed.png", "PfxGreen.png" }; for (int i = 0; i < 7; i++) { // StartFireworks (creati al clic; qui spenti fino ad allora) FE.fwE[i] = particles_createEmitter(FE.fw, (EmitterConfig){ .frames = { frame_get("vfx", FW[i % 4]) }, .nframes = 1, .lifespan = EOP(0xbb8), .rotate = ERND(0, 0x168), .angle = { 0, 0x168, 0 }, .angleSteps = 0x10, .speed = ERND(0x64, 0x96 + i / 5.0f * 0x12c / 2), .quantity = (int)(0x20 + i / 5.0f * 0x20), .scale = ERANGE(2 + i / 5.0f * 2, 0), .frequency = 0x40, .blendAdd = 1, .on = 0 }); FE.fwE[i]->x = 0.5f * MENU_W + (frand() - 0.5f) * FE_fixedW(); FE.fwE[i]->y = 0.5f * MENU_H - 0x7d - 0x96 * frand() / 2; } FE.fw->hasWell = 1, FE.fw->wellX = 0.5f * MENU_W, FE.fw->wellY = 0.5f * MENU_H, FE.fw->wellPower = 1 * 0x96, FE.fw->wellEpsilon = 0x19 * 0x19; // createGravityWell UIButton_set(&FE.OkButton, "OptionsButton", 0.5f * MENU_W, MENU_H - 0x40, 0x60, 0x20, 0, 0.5f, 0.5f); } static void FE_onOk(void *c) { // OnButtonClicked -> playReveal (void)c; UIButton_off(&FE.OkButton); FE.tClick = FE.t; Sound_PlaySimple("ClickIn", 0); Overlay_ToggleCursorsVisibility(0); Sound_PlaySimple("Piano", 1.2f); for (int i = 0; i < 12; i++) FE.raysX[i] = 0.5f * MENU_W + 0x40 * (frand() - 0.5f), FE.raysT[i] = FE.t + (i >= 6 ? 0x1f4 : 0); // AddRays ora e dopo 500 ms FE.nRays = 12; } static void FE_AddItemPanel(void) { AchievementManager_UnlockAchievement("GreatestJubilee"); po_setb("HasSeenFinalFireworks", 1); PlayerOptions_Save(); JustGotJubilee = 1; GenericPopup_AssignData(&FE.gp, "JUBILEE", "Weapon", "", 0); FE.itemShown = 1, FE.tItem = FE.t; } static void FE_onDone(void *c) { // OnDoneClicked (void)c; UIButton_off(&FE.OkButton); Sound_PlaySimple("ClickIn", 0); emitter_stop(FE.color ? FE.color : FE.black); FE.tExit = FE.t; } static void FinalFireworksScene_update(float delta) { FE.t += delta; float t = FE.t; particles_manager_update(FE.pfx, delta); particles_manager_update(FE.fw, delta); if (FE.tOk < 0 && t >= 0xfa0 + 0x96 + 0xdac) FE.tOk = t; // pannello dentro a 4 s, poi 3,5 s: enablePanelsInput if (FE.tOk >= 0 && !FE.okGrid && t >= FE.tOk + 0x96 && FE.tClick < 0) { // MakeUIGrid FE.okGrid = 1; Overlay_MakeUIGrid(1, 1, 1); Overlay_ToggleCursorsVisibility(1); UIGrid_SetContents(0, 0, &FE.OkButton, 0); UIGrid_SelectGameObject(&FE.OkButton); OV.UI_selected = &FE.OkButton; OV.OnCancelCallback = PG_cancel; UIButton_on(&FE.OkButton, FE_onOk, NULL); vui_prompt_select(); } if (FE.tClick >= 0) { for (int i = 0; i < 7; i++) { // fwCounter 0 -> 0.4 in 30 ms yoyo a 100, 300, ... 1300 ms: emettitore acceso solo nel tween float s = FE.tClick + 0x64 + 0xc8 * i; if (t >= s && t < s + 0x3c) emitter_start(FE.fwE[i]); else emitter_stop(FE.fwE[i]); } if (!FE.swapped && t >= FE.tClick + 0xbb8) { // BGFader (alpha 2, sic: resta nero) onStart: pioggia colorata ADD e AddItemPanel FE.swapped = 1; emitter_stop(FE.black); FE.color = CF_rain_in(FE.pfx, 1); FE_AddItemPanel(); } if (FE.tDone < 0 && t >= FE.tClick + 0xbb8 + 0x1f4 + 0xfa0) FE.tDone = t; // onComplete + 4 s: enableDoneButton if (FE.tDone >= 0 && !FE.doneOn && t >= FE.tDone + 0x96) { FE.doneOn = 1; Overlay_ToggleCursorsVisibility(1); UIButton_on(&FE.OkButton, FE_onDone, NULL); } } if (FE.tExit >= 0 && t >= FE.tExit + 0x12c + 0x1f4) { // nero a 300 + 500 ms: OnExitScene -> ExitGameEndScene FE.active = 0; Overlay_DestroyGrid(); vui_prompts_clear(); Sound_StopMusic(); CreditsEndingScene_start(); return; } if (FE.tExit < 0) { Overlay_update(delta); UIButton_clicked(&FE.OkButton); if (getenv("VS_AUTOPICK") && OV.UI_selected && FE.OkButton.onDown && fmodf(t, 0x190) < delta) Overlay_OnSubmitPressed(); } } static void FinalFireworksScene_draw(void) { float t = FE.t, W = MENU_W, H = MENU_H; DrawRectangle(0, 0, MENU_W, MENU_H, BLACK); // BGFader (alpha 1, poi 2) float zoom = FE.tExit >= 0 ? 1 - 0.85f * lerp01(t, FE.tExit + 0x12c, 0x1f4) : 1; // cameras.main.zoom -> 0.15 rlPushMatrix(); rlTranslatef(0.5f * W, 0.5f * H, 0), rlScalef(zoom, zoom, 1), rlTranslatef(-0.5f * W, -0.5f * H, 0); particles_manager_draw(FE.pfx); static const unsigned RT[6] = { 0xff0000, 0xff00, 0xff, 0xffff00, 0xff00ff, 0xffff }; float shrink = FE.tExit >= 0 ? 1 - lerp01(t, FE.tExit, 0xc8) : 1; // rays scaleX -> 0 in 200 ms for (int i = 0; i < FE.nRays; i++) { if (t < FE.raysT[i]) continue; float lt = t - FE.raysT[i], j = i % 6, sc = 6 * lerp01(lt, 0, 0x3e8); float pa = fmodf(lt, 2 * (0x1f4 + 0x4b * j)) / (0x1f4 + 0x4b * j), pg = fmodf(lt, 2 * (0xbb8 + 0x96 * j)) / (0xbb8 + 0x96 * j); float alpha = 1 - 0.75f * ease_sine_inout(pa < 1 ? pa : 2 - pa), a = -0x5a + 0x87 * ease_sine_inout(pg < 1 ? pg : 2 - pg); const Frame *f = frame_get("vfx", "rays.png"); if (!f || sc <= 0) continue; Sprite s; sprite_init(&s, f, FE.raysX[i], H + 0x80); sprite_setOrigin(&s, 0, 1); s.scaleX = ((int)j % 2 == 0 ? 1 : -1) * sc * shrink, s.scaleY = sc, s.angle = a, s.alpha = alpha, s.blendAdd = 1, s.tint = RT[(int)j], s.scrollFactor0 = 1; scene_render_one(&s, (Shader){ 0 }); } if (FE.tClick >= 0) particles_manager_draw(FE.fw); if (FE.itemShown) GenericPopup_draw(&FE.gp, 0.5f * W - 0.5f * 0.96f * SAFE_WIDTH, 0x80, lerp01(t, FE.tItem, 0x12c)); // achievementsPopup.Show // pannello: entra da sinistra a 4 s (150 ms), esce a destra con l'OK. Vita: testo a 20 float fw = FE_fixedW(), pw = 0.95f * fw, ph = 0.2f * 0.8f * DEFAULT_H, TLx = 0.5f * W - 0.5f * fw; float gx0 = -TLx - 0.025f * fw - pw, gx1 = TLx + 0.025f * fw, gx = gx0 + (gx1 - gx0) * lerp01(t, 0xfa0, 0x96); if (FE.tClick >= 0) gx = gx1 + (1.5f * W - gx1) * lerp01(t, FE.tClick, 0x96); float py = 0.5f * (H - ph); // Vita: centrato (l'originale lo tiene in basso, 0.5*H + 0.4*DEFAULT_H - ph - 10) if (FE.tClick < 0 || t < FE.tClick + 0x96) { nine("frame1_c2.png", 12, (Rectangle){ gx, py, pw, ph }, WHITE); char who[160] = ""; const char *ct = Core.Player ? Core.Player->characterType : "ANTONIO"; cJSON *pc = tbl0("characters", ct); if (pc) { // prefix + ' ' + charName + ' ' + surname (dai dati, come l'originale) const char *p1 = str(pc, "prefix"), *n1 = str(pc, "charName"), *s1 = str(pc, "surname"); snprintf(who, sizeof(who), "%s%s%s%s%s", p1 ? p1 : "", p1 ? " " : "", n1 ? n1 : "", n1 ? " " : "", s1 ? s1 : ""); } ui_wrap_text(lang1("directer_5", who), gx + 0xa, py + 0xa, 20, pw - 0x14, ph - 0x14, WHITE, 1); } // OkButton: entra ruotando da -90 (150 ms), esce con l'OK (-180), rientra come "Fatto" float k = 0, ang = 0; if (FE.tOk >= 0 && FE.tClick < 0) k = lerp01(t, FE.tOk, 0x96), ang = -0x5a * (1 - k); else if (FE.tClick >= 0 && FE.tDone < 0) { float d = lerp01(t, FE.tClick, 0x96); k = 1 - d, ang = -0xb4 * d; } else if (FE.tDone >= 0) k = lerp01(t, FE.tDone, 0x96), ang = -0x5a * (1 - k); if (FE.tExit >= 0) k *= 1; // il bottone resta (OnDoneClicked non lo nasconde) if (k > 0) { const char *bt = tr(FE.tDone >= 0 ? "postGame_done" : "charFound_ok"); TS_nine("button_c9_normal.png", 9, 14, 0.5f * W, H - 0x40, 0x60, 0x20, 2 * k, 2 * k, ang, WHITE); TS_text(bt, 0.5f * W, H - 0x40, fit_size(bt, 16, 0x50), 2 * k, ang, WHITE); FE.OkButton.sc = 2 * k; } rlPopMatrix(); if (FE.tExit >= 0) DrawRectangle(0, 0, MENU_W, MENU_H, Fade(BLACK, lerp01(t, FE.tExit + 0x12c, 0x1f4))); if (FE.tExit < 0) { vui_prompt_bar(); Overlay_draw(); } } // --- UI_creditsEndingScene (0x8b19): testo che scorre, conga di 300 personaggi e nemici, cosce che piovono, Indietro ----- #define CE_CONGA 0x12c typedef struct { Sprite s; Animation a; float fps; } CongaSpr; typedef struct { float x, y, vx, vy; } Roast; static struct { int active, carry, switchCount, switchcount, enemyCount, characterCount, rain, bigButton; float t, congaSpeed, widthCounter, textY, textH; int moveTweenIndex; char **lines, **enemyList, **characterList; int nlines, nEnemies, nCharacters, npool; CongaSpr *pool; Roast roast[0x1f4]; UIButton Skip; float skipSc, textSc; int switches; } CE; static void CE_shuffle(char **a, int n) { // shuffleArray (Fisher-Yates con Math.random) for (int i = n - 1; i > 0; i--) { int j = (int)floorf(frand() * (i + 1)); char *t = a[i]; a[i] = a[j], a[j] = t; } } static int CE_in(const char *k, const char *const *l) { for (; *l; l++) if (!strcmp(*l, k)) return 1; return 0; } static void CE_createEnemyList(void) { static const char *const OUT[] = { "HEMO", "HEMO2", "REDUSA", "RELLYFISH", "RELLYFISH_SWARM", "BOSS_XLBLINDER", "FS_ANFORA_HP", "TRINACRIA", "FANGEL1", "FANGEL2", "FANGEL3", "TRAINEE_Y", "ARMOR1", "BULLET_W", "SHADEBLUE", "MS_GOSHADOKURO", "MS_OROCHIMARIO", NULL }; static const char *const SUB[] = { "MOLISANO", "MOON", "BULLET", "MASK", "BOSS", "D_", "test", "_FLAG", NULL }; cJSON *en = data_get("enemies"); CE.enemyList = calloc(cJSON_GetArraySize(en) + 1, sizeof(char *)), CE.nEnemies = 0; for (cJSON *e = en ? en->child : NULL; e; e = e->next) { cJSON *d = cJSON_GetArrayItem(e, 0); if (!d || CE_in(e->string, OUT)) continue; int bad = 0; for (const char *const *s = SUB; *s; s++) if (strstr(e->string, *s)) bad = 1; if (!bad && cJSON_GetArraySize(cJSON_GetObjectItem(d, "frameNames")) > 0) CE.enemyList[CE.nEnemies++] = e->string; } CE_shuffle(CE.enemyList, CE.nEnemies); // semplificazione: l'originale rimescola a ogni push; un rimescolamento finale da' la stessa distribuzione } static void CE_createCharacterList(void) { static const char *const OUT[] = { "FINO", "CONCETTA", "POPPEA", "ARENGIJUS", NULL }; // quelli dei DLC non installati non sono nei dati cJSON *ch = data_get("characters"); CE.characterList = calloc(cJSON_GetArraySize(ch) + 1, sizeof(char *)), CE.nCharacters = 0; for (cJSON *c = ch ? ch->child : NULL; c; c = c->next) if (cJSON_GetArrayItem(c, 0) && !CE_in(c->string, OUT)) CE.characterList[CE.nCharacters++] = c->string; CE_shuffle(CE.characterList, CE.nCharacters); } static void CE_place(CongaSpr *p, cJSON *d, float fps) { // setScale(PixelScale * (scale || 1) * 2), setPosition(w, SAFEAREA.height), tint, alpha, origine (0.5, 1) p->fps = fps; anims_play(&p->s, &p->a, 0); sprite_setScale(&p->s, PixelScale * num(d, "scale", 1) * 2); p->s.x = MENU_W, p->s.y = MENU_H - 48; // Vita: SAFEAREA.height -> sopra la barra dei tasti p->s.tint = (unsigned)num(d, "tint", 0xffffff), p->s.alpha = num(d, "alpha", 1); if (p->s.alpha == 0) p->s.alpha = 1; // alpha || 1 p->s.visible = 1, p->s.scrollFactor0 = 1; sprite_setOrigin(&p->s, 0.5f, 1); } static CongaSpr *CE_getNextCharacter(void) { CongaSpr *p = &CE.pool[CE.npool++]; sprite_init(&p->s, NULL, 0, 0); if (frand() < 0.5f && CE.nEnemies) { // createEnemyAnimation const char *k = CE.enemyList[CE.enemyCount]; cJSON *d = tbl0("enemies", k), *fn = cJSON_GetObjectItem(d, "frameNames"); int v = (int)floorf(frand() * cJSON_GetArraySize(fn)); CE.enemyCount = CE.enemyCount + 1 >= CE.nEnemies ? 0 : CE.enemyCount + 1; char pre[96]; snprintf(pre, sizeof(pre), "%s", cJSON_GetStringValue(cJSON_GetArrayItem(fn, v)) ?: ""); char *z = strstr(pre, "0.png"); if (z) *z = 0; strcat(pre, "i"); // frameNames[i].replace('0.png', '') + 'i' const char *tex = str(d, "textureName") ?: "enemies"; make_anim(&p->a, tex, pre, (int)num(d, "startFrameCount", 1), (int)num(d, "idleFrameCount", 4), (int)num(d, "zeroPad", 2), num(d, "frameRate", 8), -1); CE_place(p, d, num(d, "frameRate", 8)); } else if (CE.nCharacters) { // createCharacterAnimation const char *k = CE.characterList[CE.characterCount]; cJSON *d = tbl0("characters", k), *sk = cJSON_GetObjectItem(d, "skins"); int skin = sk ? (int)floorf(frand() * cJSON_GetArraySize(sk)) : 0; CE.characterCount = CE.characterCount + 1 >= CE.nCharacters ? 0 : CE.characterCount + 1; const char *tex = str(d, "textureName") ?: "characters", *spr = str(d, "spriteName") ?: ""; int walk = (int)num(d, "walkingFrames", 1); if (sk) { cJSON *s = cJSON_GetArrayItem(sk, skin); tex = str(s, "textureName") ?: tex, spr = str(s, "spriteName") ?: spr, walk = (int)num(s, "walkingFrames", 1); } char pre[96]; snprintf(pre, sizeof(pre), "%s", spr); char *u = strchr(pre, '_'); if (u) *u = 0; strcat(pre, strstr(spr, "_i") ? "_i" : "_"); // spriteName.split('_')[0] + ('_i' | '_') char suf[16]; snprintf(suf, sizeof(suf), "%s", str(d, "suffix") ?: ".png"); make_anim(&p->a, tex, pre, (int)num(d, "startFrameCount", 1), walk, (int)num(d, "zeroPad", 2), num(d, "frameRate", 8), -1); CE_place(p, d, num(d, "frameRate", 8)); p->s.flipX = 1; } return p; } static void CE_congaSwitch(void) { CE.congaSpeed *= -1.25f; for (int i = 0; i < CE.npool; i++) if (CE.pool[i].s.visible) CE.pool[i].s.flipX = !CE.pool[i].s.flipX; CE.switchcount++; if (BGM.playing) SetMusicPitch(BGM.music, 1 + 0.1f * CE.switchcount); // currentBGMObj.rate (BGM_Pizza) for (int i = 0; i < CE.npool; i++) { // anims.play({ key: 'idle', frameRate: 8 + switchcount }) CongaSpr *p = &CE.pool[i]; if (!p->s.visible) continue; p->a.frameRate = 8 + CE.switchcount, p->a.msPerFrame = 1000.0f / p->a.frameRate; anims_play(&p->s, &p->a, 0); } } static void CE_exit(void) { // il bottone portato dalla conga: ExitCreditEndingScene -> IntroScene UIButton_off(&CE.Skip); Sound_PlaySimple("ClickOut", 0); PlayerOptions_Save(); Sound_StopMusic(); CE.active = 0; Overlay_DestroyGrid(), vui_prompts_clear(); Credits_free(CE.lines, CE.nlines); free(CE.pool), free(CE.enemyList), free(CE.characterList); menu_start(); } static void CE_onSkip(void *c) { // enableButtons: due inversioni della conga, poi carryButton (void)c; if (CE.switchCount < 2) CE_congaSwitch(); else if (CE.switchCount == 2) { // carryButton CE.Skip.x = CE.congaSpeed > 0 ? MENU_W + 0x64 : 0; CE.carry = 1; UIButton_on(&CE.Skip, (void (*)(void *))CE_exit, NULL); } CE.switchCount++; } static void CreditsEndingScene_start(void) { memset(&CE, 0, sizeof(CE)); CE.active = 1; tweens_reset(), time_reset(), children_reset(); CE.lines = Credits_lines("ending", &CE.nlines); CE.textY = 0.5f * MENU_H; // SAFEAREA.centerY Sound_StopMusic(); Sound_PlayMusic("BGM_Pizza", 0.3f, 1); CE.congaSpeed = 1; CE.moveTweenIndex = (int)floorf(frand() * 10); CE_createEnemyList(), CE_createCharacterList(); CE.pool = calloc(CE_CONGA + 4, sizeof(CongaSpr)); for (int i = 0; i < CE_CONGA; i++) { // createConga CongaSpr *p = CE_getNextCharacter(); p->s.visible = 1; p->s.x += CE.widthCounter + 2 * p->s.width; CE.widthCounter += 2 * p->s.width; } CE.skipSc = 2; // Vita: BackButton 48x30 in alto a destra (l'originale scala 4 x MASTER_SCALE, piu' piccolo sullo schermo) UIButton_set(&CE.Skip, "BackButton", MENU_W - 0x50, 0x48, 0x30, 0x1e, CE.skipSc, 0.5f, 1); UIButton_on(&CE.Skip, CE_onSkip, NULL); Overlay_MakeUIGrid(1, 1, 0); UIGrid_SetContents(0, 0, &CE.Skip, 0); Overlay_ToggleCursorsVisibility(1); UIGrid_SelectGameObject(&CE.Skip), OV.UI_selected = &CE.Skip; OV.OnCancelCallback = CS_cancel; // il cerchio = premere il bottone vui_set_prompts((VPrompt[]){ { G_CROSS, "vui_select" } }, 1); } static float CE_wobble(void) { // TweenAngles[moveTweenIndex]: -5 -> 5 in 500 ms, yoyo, dopo 5 ms per indice float tt = CE.t - 5 * CE.moveTweenIndex; if (tt < 0) return -5; float ph = fmodf(tt, 0x3e8); return ph < 0x1f4 ? -5 + 10 * ph / 0x1f4 : 5 - 10 * (ph - 0x1f4) / 0x1f4; } static void CreditsEndingScene_update(float delta) { float t0 = CE.t; CE.t += delta; float t = CE.t; static const float SW[4] = { 0x249f0, 0x2bf20, 0x33450, 0x3a980 }; // switchTimes for (int i = 0; i < 4; i++) if (t0 < SW[i] && t >= SW[i]) CE_congaSwitch(); if (t0 < 0x41eb0 && t >= 0x41eb0) { // chickenTime: MakeItRain, 500 cosce nei bordi del mondo CE.rain = 1; for (int i = 0; i < 0x1f4; i++) { // Rectangle.Inflate(bounds, -48, -48100) (sic: altezza negativa) -> Rectangle.Random Roast *r = &CE.roast[i]; r->x = 0x30 + frand() * (MENU_W - 0x60), r->y = 0xbbe4 + frand() * (MENU_H - 2 * 0xbbe4); r->vx = 0xc8 + floorf(frand() * 0xc9), r->vy = 0xc8 + floorf(frand() * 0xc9); // Between(200, 400) if (frand() > 0.5f) r->vx *= -1; if (frand() > 0.5f) r->vy *= -1; } } if (t0 < 0x50910 && t >= 0x50910) CE.bigButton = 1, CE.skipSc = 6; // buttonTime: il bottone enorme (Vita: meta' dell'originale) if (CE.rain) { // Arcade: setBounce(1.01) + collideWorldBounds; velocita' * -1.01 a ogni urto, passo fisso di 60 Hz const Frame *f = frame_get("items", "Roast.png"); float w = f ? 2 * f->sw : 16, h = f ? 2 * f->sh : 16; for (int i = 0; i < 0x1f4; i++) { Roast *r = &CE.roast[i]; r->x += r->vx / 60, r->y += r->vy / 60; float l = r->x - 0.5f * w, tp = r->y - 0.5f * h; if (l < 0) r->x = 0.5f * w, r->vx *= -1.01f; else if (l + w > MENU_W) r->x = MENU_W - 0.5f * w, r->vx *= -1.01f; if (tp < 0) r->y = 0.5f * h, r->vy *= -1.01f; else if (tp + h > MENU_H) r->y = MENU_H - 0.5f * h, r->vy *= -1.01f; } } // testo: compare in 1 s, scorre in 90 s fino a -altezza + centro, sparisce 60 s dopo (1 s) if (t >= 0x3e8 + 0x3e8) CE.textY = 0.5f * MENU_H + (-CE.textH) * lerp01(t, 0x3e8 + 0x3e8, 0x15f90); for (int i = 0; i < CE.npool; i++) { // update: angolo comune, x -= congaSpeed a ogni frame (sic), giro della fila CongaSpr *p = &CE.pool[i]; if (!p->s.visible) continue; sprite_animsUpdate(&p->s, delta); p->s.angle = CE_wobble(); p->s.x -= CE.congaSpeed; if (CE.congaSpeed > 0 && p->s.x < -CE.widthCounter + MENU_W) p->s.x += CE.widthCounter; } if (CE.carry) { CE.Skip.x -= CE.congaSpeed; if (CE.Skip.x < -0x64) CE.Skip.x = MENU_W + 0x64; else if (CE.Skip.x > MENU_W + 0xc8) CE.Skip.x = 0; CE.Skip.y = MENU_H - 48 - 0x32; // SAFEAREA.height - 50 } CE.Skip.sc = CE.skipSc; Overlay_update(delta); UIButton_clicked(&CE.Skip); } static void CreditsEndingScene_draw(void) { float t = CE.t, W = MENU_W, H = MENU_H; DrawRectangle(0, 0, MENU_W, MENU_H, BLACK); if (CE.rain) { const Frame *f = frame_get("items", "Roast.png"); for (int i = 0; i < 0x1f4 && f; i++) { Sprite s; sprite_init(&s, f, CE.roast[i].x, CE.roast[i].y); sprite_setScale(&s, 2), s.scrollFactor0 = 1; scene_render_one(&s, (Shader){ 0 }); } } float a = lerp01(t, 0, 0x3e8) * (1 - lerp01(t, 0x3e8 + 0x3e8 + 0x15f90 + 0xea60, 0x3e8)); text_at(tr("credits_header"), 0.5f * W, 0x21, 30, 0.5f, 0.5f, Fade(WHITE, a)); menu_clip(0, 0x50, W, H - 0x78 - 0x50); // maschera fillRect(0, 100, w, h - 200); Vita: finisce sopra la conga CE.textH = Credits_draw(CE.lines, CE.nlines, 0.5f * W, CE.textY, 22, a, 0x50, H - 0x78); menu_unclip(); for (int i = 0; i < CE.npool; i++) if (CE.pool[i].s.visible && CE.pool[i].s.x > -64 && CE.pool[i].s.x < W + 64) scene_render_one(&CE.pool[i].s, (Shader){ 0 }); // BackButton: in alto a destra, poi portato dalla conga (ruota con lei) float ang = CE.carry ? CE_wobble() : 0, bx = CE.Skip.x, by = CE.Skip.y, sc = CE.skipSc; TS_nine("button_c8_normal.png", 9, 14, bx, by - 0.5f * 0x1e * sc, 0x30, 0x1e, sc, sc, ang, WHITE); const char *bk = tr("topBar_back"); TS_text(bk, bx, by - 0.6f * 0x1e * sc, fit_size(bk, 16, 0x46 * sc / 2), sc / 2 * 1.2f, ang, WHITE); vui_prompt_bar(); Overlay_draw(); } // --- UI_creditsScene (0x7e6c): i crediti dal menu principale, in un contenitore che scorre ---------------------------- // Vita: pannello quasi a tutto schermo sotto la barra in alto, rotella / trascinamento / su-giu' del pad, barra a destra. static struct { int active, down; float t, scY, scMax, dragOff, textH; char **lines; int n; } CR; static void SceneManager_BackFromCredits(void); static void CreditsScene_create(void) { memset(&CR, 0, sizeof(CR)); CR.active = 1; CR.lines = Credits_lines("menu", &CR.n); TB_title = tr("credits_header"); Overlay_DestroyGrid(); Overlay_MakeUIGrid(1, 1, 0); UIGrid_SetContents(0, 0, &TB.BackButton, 0); Overlay_ToggleCursorsVisibility(1); UIGrid_SelectGameObject(&TB.BackButton), OV.UI_selected = &TB.BackButton; OV.OnCancelCallback = CS_cancel; vui_set_prompts((VPrompt[]){ { G_CIRCLE, "vui_back" } }, 1); } static void CreditsScene_update(float delta) { CR.t += delta; Rectangle box = { 20, 62, MENU_W - 40, MENU_H - 62 - 52 }; Vector2 m = menu_pointer(); if (GetMouseWheelMove()) CR.scY -= 40 * GetMouseWheelMove(); if (ptr_pressed() && CheckCollisionPointRec(m, box)) CR.down = 1, CR.dragOff = CR.scY + m.y; else if (ptr_down() && CR.down) CR.scY = CR.dragOff - m.y; else if (!ptr_down()) CR.down = 0; float ay = GetGamepadAxisMovement(0, 1); // su/giu' tenuti: scorrimento continuo int up = IsKeyDown(KEY_UP) || IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_UP) || ay < -0.4f, dn = IsKeyDown(KEY_DOWN) || IsGamepadButtonDown(0, GAMEPAD_BUTTON_LEFT_FACE_DOWN) || ay > 0.4f; CR.scY += (dn - up) * 0.5f * delta; CR.scMax = fmaxf(0, CR.textH + 48 - box.height); CR.scY = fminf(fmaxf(CR.scY, 0), CR.scMax); if (getenv("VS_CREDSCROLL")) CR.scY = fminf(atof(getenv("VS_CREDSCROLL")), CR.scMax); // sviluppo } static void CreditsScene_draw(void) { Rectangle box = { 20, 62, MENU_W - 40, MENU_H - 62 - 52 }; nine("frame5_c4.png", 12, box, WHITE); // MenuBackground menu_clip(box.x + 8, box.y + 8, box.width - 16, box.height - 16); CR.textH = Credits_draw(CR.lines, CR.n, 0.5f * MENU_W - 12, box.y + 24 - CR.scY, 22, 1, box.y, box.y + box.height); menu_unclip(); if (CR.scMax > 0) { // ScrollBar + ScrollCursor float bx = box.x + box.width - 16, by = box.y + 12, bh = box.height - 24, ch = fmaxf(24, bh * box.height / (CR.textH + 48)); DrawRectangleRec((Rectangle){ bx - 3, by, 6, bh }, Fade(BLACK, 0.5f)); DrawRectangleRec((Rectangle){ bx - 5, by + (bh - ch) * CR.scY / CR.scMax, 10, ch }, rgb(0xd8b45a, 1)); } } static void SceneManager_BackFromCredits(void) { Overlay_DestroyGrid(); CR.active = 0; Credits_free(CR.lines, CR.n); MM.visible = 1, MM.awake = 1; TopBar_EnableOptions(SceneManager_OptionsFromMainMenu); TopBar_DisableBack(); IntroScene_MakeUIGrid(&MM.CreditsButton); } // --- Jukebox (del port): i brani di music.json; quelli di uno stage si sbloccano col suo vinile (RELIC_VINYL_), quelli // di un personaggio comprandolo, gli altri ci sono subito. Su/giu' sceglie, croce suona, cerchio torna al menu. #define JB_MAX 96 static struct { int active, n, sel, top, playing; const char *key[JB_MAX]; int open[JB_MAX]; } JB; static int Jukebox_vinyls(void) { // vinili trovati: il bottone del menu compare dal primo int n = 0; cJSON *v; cJSON_ArrayForEach(v, po("CollectedItems")) n += cJSON_IsString(v) && !strncmp(v->valuestring, "RELIC_VINYL_", 12); return n + (getenv("VS_RELICS") && strstr(getenv("VS_RELICS"), "RELIC_VINYL_")); // sviluppo: VS_RELICS come le altre reliquie } static void SceneManager_BackFromJukebox(void); static void JB_play(void) { if (!JB.n || !JB.open[JB.sel]) { Sound_PlaySimple("ClickOut", 0); return; } Sound_StopMusic(); Sound_PlayMusic(JB.key[JB.sel], 0.5f, 1); JB.playing = JB.sel; } static void JB_cancel(void) { SceneManager_BackFromJukebox(); } static void JukeboxScene_create(void) { memset(&JB, 0, sizeof(JB)); JB.active = 1, JB.playing = -1; cJSON *m; cJSON_ArrayForEach(m, data_get("music")) { if (JB.n >= JB_MAX || !str(m, "title")) continue; const char *st = str(m, "unlockedByStage"), *ch = str(m, "unlockedByCharacter"); JB.key[JB.n] = m->string; JB.open[JB.n++] = st ? Collected(TextFormat("RELIC_VINYL_%s", st)) : ch ? po_has("BoughtCharacters", ch) : 1; } TB_title = port_tr("menu_jukebox"); Overlay_DestroyGrid(); Overlay_MakeUIGrid(1, 1, 0); // vuota: le direzioni le legge la scena, la croce suona (OnSubmitCallback) Overlay_ToggleCursorsVisibility(0); OV.OnSubmitCallback = JB_play, OV.OnCancelCallback = JB_cancel; vui_set_prompts((VPrompt[]){ { G_CROSS, "vui_select" }, { G_CIRCLE, "vui_back" } }, 2); } #define JB_ROWS 9 static void JukeboxScene_update(float delta) { (void)delta; int dx = 0, dy = 0; in_dir_pressed(&dx, &dy); if (JB.n && (dy || dx)) JB.sel = (JB.sel + dy + JB_ROWS * dx + JB.n) % JB.n, Sound_PlaySimple("ClickIn", 0); // sinistra/destra: una pagina if (JB.sel < JB.top) JB.top = JB.sel; if (JB.sel >= JB.top + JB_ROWS) JB.top = JB.sel - JB_ROWS + 1; } static void JukeboxScene_draw(void) { Rectangle box = { 20, 62, MENU_W - 40, MENU_H - 62 - 52 }; nine("frame5_c4.png", 12, box, WHITE); for (int r = 0; r < JB_ROWS && JB.top + r < JB.n; r++) { int i = JB.top + r; float y = box.y + 22 + r * 44; cJSON *m = cJSON_GetObjectItem(data_get("music"), JB.key[i]); if (i == JB.sel) DrawRectangleRounded((Rectangle){ box.x + 12, y - 4, box.width - 24, 40 }, 0.3f, 4, Fade(rgb(VUI_GOLD, 1), 0.25f)); Color c = JB.open[i] ? (i == JB.sel ? YELLOW : WHITE) : rgb(0x8a8494, 1); text_at(i == JB.playing ? ">" : TextFormat("%02d", i + 1), box.x + 40, y + 16, 20, 0.5f, 0.5f, i == JB.playing ? YELLOW : rgb(0xb8b0a4, 1)); const char *t = JB.open[i] ? str(m, "title") : "???", *s = JB.open[i] ? TextFormat("%s - %s", str(m, "source") ? str(m, "source") : "", str(m, "author") ? str(m, "author") : "") : port_tr("jb_locked"); text_at(t, box.x + 70, y + 8, fit_size(t, 22, 400), 0, 0.5f, c); text_at(s, box.x + box.width - 24, y + 22, fit_size(s, 16, 420), 1, 0.5f, rgb(0xb8b0a4, 1)); } if (JB.n > JB_ROWS) text_at(TextFormat("%d / %d", JB.sel + 1, JB.n), 0.5f * MENU_W, box.y + box.height - 14, 16, 0.5f, 0.5f, rgb(0xb8b0a4, 1)); } static void SceneManager_Jukebox_FromMainMenu(void) { Overlay_DestroyGrid(); MM.visible = 0, MM.awake = 0; JukeboxScene_create(); TopBar_EnableBack(SceneManager_BackFromJukebox); } static void SceneManager_BackFromJukebox(void) { Overlay_DestroyGrid(); JB.active = 0; Sound_StopMusic(); MM.visible = 1, MM.awake = 1; TopBar_EnableOptions(SceneManager_OptionsFromMainMenu); TopBar_DisableBack(); IntroScene_MakeUIGrid(&MM.JukeboxButton); } static struct { int active; float t; } Warn; // Avvio animato (frame di Wolff): il primo fotogramma e' sce_sys/pic0.png, quello che la Vita mostra durante il caricamento, // e da li' il volto sfuma nel nero; poi l'avviso. Finche' il decoder non ha il primo fotogramma resta il pic0: nessuno stacco. static struct { int active; VsVideo *v; Texture2D pic; float t; } BV; static void BootVid_stop(void) { vs_video_close(BV.v); if (BV.pic.id) UnloadTexture(BV.pic); memset(&BV, 0, sizeof(BV)); Warn.active = 1; } static void BootVid_start(void) { BV.v = vs_video_open(vs_asset("boot.mp4"), MENU_W, MENU_H); BV.pic = LoadTexture(vs_boot_pic()); BV.active = 1; if (!BV.v) BootVid_stop(); } static void BootVid_update(float delta) { BV.t += delta; if (!vs_video_update(BV.v, delta)) { BootVid_stop(); return; } int any = ptr_pressed() || GetKeyPressed(); for (int b = 1; b <= 17 && !any && IsGamepadAvailable(0); b++) any = IsGamepadButtonPressed(0, b); if (any) BootVid_stop(); } static void BootVid_draw(void) { Texture2D v = vs_video_ready(BV.v) ? vs_video_texture(BV.v) : BV.pic; if (v.id) DrawTexturePro(v, (Rectangle){ 0, 0, v.width, v.height }, (Rectangle){ 0, 0, MENU_W, MENU_H }, (Vector2){ 0, 0 }, 0, WHITE); } void menu_start(void) { memset(&SM, 0, sizeof(SM)); SM.active = 1; CS.active = SS.active = PU.active = SC.active = CW.active = CA.active = BE.active = OP.active = RC.active = 0; IsHalloween = 0; // Core.CleanUp a fine partita SFXVolumeFactor = 1; // GreenAcres.OnDestroy Library_OnDestroy(); Machine_OnDestroy(); Chapel_OnDestroy(); static int devEnding; // sviluppo: VS_ENDING=1 (fuochi e crediti) | 2 (solo crediti), una volta if (getenv("VS_ENDING") && !devEnding) devEnding = 1, pending_ending = atoi(getenv("VS_ENDING")); if (pending_ending) { // SceneManager.EnterGameEndScene / EnterCreditEndingScene int e = pending_ending; pending_ending = 0; TB_title = NULL; if (e == 1) FinalFireworksScene_start(); else CreditsEndingScene_start(); return; } IntroScene_create(); static int warned; if (!warned && !getenv("VS_MENU")) BootVid_start(); warned = 1; static int skipped; // sviluppo: VS_MENU=main|chars|stages salta l'intro (una volta) if (getenv("VS_NETPEER")) BootVid_stop(), Warn.active = 0, IN.t = 0x3e8, IN.introEnded = 1, Lobby_open(); // sviluppo: subito in lobby if (getenv("VS_MENU") && !skipped) skipped = 1, IN.t = 0x3e8, IN.introEnded = 1, IntroScene_OnFirstInput(), IN.firstInputAt -= 0x1e, menu_skip = getenv("VS_MENU"); } // 1 quando parte la partita (game_start gia' fatto), -1 per uscire dal gioco // --- Le combinazioni da tastiera (KeyCombo di Phaser): IntroScene per tutto il menu, CharSelection, StageSelection, MainScene --- static const int KC_KONAMI[] = { 38, 38, 40, 40, 37, 39, 37, 39, 27, 13 }, KC_XX1[] = { 'X', 189, 'X', '1', 'V', 'I', 'I', 'Q' }, KC_XX2[] = { 'X', 109, 'X', '1', 'V', 'I', 'I', 'Q' }, KC_XX3[] = { 'X', 173, 'X', '1', 'V', 'I', 'I', 'Q' }, KC_RANDOMAZZAMI[] = { 'R', 'A', 'N', 'D', 'O', 'M', 'A', 'Z', 'Z', 'A', 'M', 'I' }, KC_SPAM[] = { 'S', 'P', 'A', 'M' }, KC_AINT[] = { 'A', 'I', 'N', 'T', 'N', 'O', 'B', 'O', 'D', 'Y', 'G', 'O', 'T', 'T', 'I', 'M', 'E', 'F', 'O', 'R', 'T', 'H', 'A', 'T' }, KC_HUMBUG[] = { 'H', 'U', 'M', 'B', 'U', 'G' }, KC_PET[] = { 'P', 'E', 'T' }; #define KC(a, d) { a, sizeof(a) / sizeof(*a), 0, 0, d } static KeyCombo IntroCombos[7] = { KC(KC_KONAMI, 0x7d0), KC(KC_XX1, 0x7d0), KC(KC_XX2, 0x7d0), KC(KC_XX3, 0x7d0), KC(KC_RANDOMAZZAMI, 0x7d0), KC(KC_SPAM, 0x7d0), KC(KC_AINT, 0x7d0) }; static KeyCombo CS_spam = KC(KC_SPAM, 0x7d0), SS_spam = KC(KC_SPAM, 0x7d0); // definizioni (dichiarate prima) static KeyCombo G_humbug = KC(KC_HUMBUG, 0x7d0), G_pet = KC(KC_PET, 0x1f4); #undef KC static void Arcana_grant(int a) { // UnlockedArcanas.push + arcana.unlocked (la combinazione lunga non controlla i doppioni) cJSON_AddItemToArray(po("UnlockedArcanas"), cJSON_CreateNumber(a)); obj_set(tbl0("arcana", TextFormat("%d", a)), "unlocked", cJSON_CreateTrue()); } static void IntroScene_onCombo(int i) { if (i == 4) { // randomazzami: Randomazzo e Sarabande if (po_has("CollectedItems", "RELIC_RANDOMAZZO")) return; json_inc(cJSON_GetObjectItem(data_get("items"), "RELIC_RANDOMAZZO"), "pickedupAmount"); po_push("CollectedItems", "RELIC_RANDOMAZZO"); obj_set(tbl0("arcana", "6"), "unlocked", cJSON_CreateTrue()); if (!po_has("UnlockedArcanas", "6")) cJSON_AddItemToArray(po("UnlockedArcanas"), cJSON_CreateNumber(6)); PlayerOptions_Save(); Sound_PlaySimple("ClickIn", 0), Sound_PlaySimple("ThingFound", 0); } else if (i == 5) { // spam: la catena di Smith parte con Exdash e Panini sbloccati, per 30 s if (tflag == 0 && po_has("UnlockedCharacters", "EXDASH") && po_has("UnlockedCharacters", "PANINI")) tflag = 1, tflagUntil = now_ms() + 0x7530; } else if (i == 6) { // aintnobodygottimeforthat: cinque arcane, con Randomazzo if (!po_has("CollectedItems", "RELIC_RANDOMAZZO")) return; static const int A[5] = { 0, 8, 12, 15, 20 }; for (int k = 0; k < 5; k++) Arcana_grant(A[k]); Sound_PlaySimple("ClickIn", 0), Sound_PlaySimple("ThingFound", 0); } int size = IntroCombos[i].n; if (size == 10) { // Konami (frecce, Esc, Invio): Mortaccio e 2800 monete, una volta if (po_is("CheatCodeUsed")) return; if (!po_has("UnlockedCharacters", "MORTACCIO")) po_push("UnlockedCharacters", "MORTACCIO"), obj_set(tbl0("characters", "MORTACCIO"), "hidden", cJSON_CreateFalse()); po_put("CheatCodeUsed", cJSON_CreateTrue()); Sound_PlaySimple("ClickIn", 0), Sound_PlaySimple("ThingFound", 0); PlayerOptions_AddCoins(0xaf0); PlayerOptions_Save(); TopBar_UpdateCoins(); } else if (size == 8 && !po_has("UnlockedCharacters", "EXDASH")) { // x-x1viiq: Exdash po_push("UnlockedCharacters", "EXDASH"); cJSON *d = tbl0("characters", "EXDASH"); obj_set(d, "hidden", cJSON_CreateFalse()), obj_set(d, "isBought", cJSON_CreateTrue()); po_push("BoughtCharacters", "EXDASH"); PlayerOptions_Save(); Sound_PlaySimple("ClickIn", 0), Sound_PlaySound("ThingFound", 0, 0.5f, -0x3e8, 0, 0); } } static void IntroScene_combos(void) { float t = now_ms(); if (tflag && t >= tflagUntil && tflagUntil > 0) tflag = 0, tflagUntil = 0; // OmniScene.time: dopo 30 s si azzera for (int q = 0; q < nKeyQ; q++) { int code = js_keyCode(KeyQ[q]); for (int i = 0; i < 7; i++) if (KeyCombo_process(&IntroCombos[i], code, t)) IntroScene_onCombo(i); if (CS.active && KeyCombo_process(&CS_spam, code, t) && CS_spamOn && tflag > 0) tflag += 2; if (SS.active && KeyCombo_process(&SS_spam, code, t) && SS_spamOn && tflag == 3) tflag += 4; } } static void MainScene_combos(void) { float t = now_ms(); if (tflag && t >= tflagUntil && tflagUntil > 0) tflag = 0, tflagUntil = 0; for (int q = 0; q < nKeyQ; q++) { int code = js_keyCode(KeyQ[q]); if (KeyCombo_process(&G_pet, code, t) && G_petOn && !G_hasP) { G_hasP = 1; if (Player_is(Core.Player, "TATANKA")) Core_DoPraise(0x6c); } if (KeyCombo_process(&G_humbug, code, t) && G_humbugOn && tflag == 7) { // humbug: Smith cJSON *d = tbl0("characters", "SMITH"); obj_set(d, "hidden", cJSON_CreateFalse()), obj_set(d, "isBought", cJSON_CreateTrue()); if (!po_has("UnlockedCharacters", "SMITH")) { po_push("BoughtCharacters", "SMITH"), po_push("UnlockedCharacters", "SMITH"); PlayerOptions_Save(); Sound_PlaySound("ThingFound", 0, 0.5f, -0x3e8, 0, 0); } } } } const char *menu_dbg(void) { // sviluppo: lo stato dell'input del menu per pad.txt (VS_PADLOG) int kd = -1; for (int k = 0; k < 512 && kd < 0; k++) if (IsKeyDown(k)) kd = k; return TextFormat("nKeyQ=%d keydown=%d intro=%d/%d/%d grid=%d/%d blk=%d sel=%p cur=%d,%d td4=%.0f", nKeyQ, kd, IN.introEnded, IN.isInitialized, IN.anyHeld, UIGrid.on, IN.gridMade, OV.blockInput, (void *)OV.UI_selected, UIGrid.cx, UIGrid.cy, OV.timeDown[4]); } // Intro anime dopo l'avviso, a ogni avvio (Federico, 2026-11-05). Nel VPK: video muto senza logo + musica originale (ElevenLabs, // intro.ogg, gia' a tempo col video: vs_video non suona). Il logo viene dalla copia dell'utente, come il resto del gioco. // Tempi dal montaggio (trailer/intro_src/edit3.py). Qualsiasi tasto o tocco la salta. Chiude il decoder prima che la home apra il suo. #define INTRO_LOGO_AT 19.413f #define INTRO_LEN 20.945f static struct { int active, music; VsVideo *v; Music m; float t, vt; } IV; static void IntroVid_stop(void) { if (IV.music == 1) au_music_stop(&IV.m), Music_close(&IV.m); vs_video_close(IV.v); memset(&IV, 0, sizeof(IV)); } static void IntroVid_start(void) { IV.v = vs_video_open(vs_asset("intro.mp4"), MENU_W, MENU_H); IV.active = IV.v != NULL; } static void IntroVid_update(float delta) { IV.t += delta; if (!vs_video_update(IV.v, delta)) { IntroVid_stop(); return; } if (vs_video_ready(IV.v)) IV.vt += delta / 1000; if (!IV.music && vs_video_ready(IV.v) && IsAudioDeviceReady()) { IV.music = -1; // un tentativo solo Music_open(&IV.m, vs_asset("intro.ogg")); if (IV.m.frameCount) IV.m.looping = 0, au_music_volume(&IV.m, MusicVolume), PlayMusicStream(IV.m), au_music_add(&IV.m), IV.music = 1; } if (IV.music == 1 && IV.vt > INTRO_LEN - 1.2f) au_music_volume(&IV.m, MusicVolume * fmaxf(0, (INTRO_LEN - IV.vt) / 1.2f)); if (IV.t < 300) return; // la pressione che ha chiuso l'avviso non salta anche l'intro int any = ptr_pressed() || GetKeyPressed(); for (int b = 1; b <= 17 && !any && IsGamepadAvailable(0); b++) any = IsGamepadButtonPressed(0, b); if (any) IntroVid_stop(); } static void IntroVid_draw(void) { if (!vs_video_ready(IV.v)) return; Texture2D v = vs_video_texture(IV.v); DrawTexturePro(v, (Rectangle){ 0, 0, v.width, v.height }, (Rectangle){ 0, 0, MENU_W, MENU_H }, (Vector2){ 0, 0 }, 0, WHITE); if (IV.vt < INTRO_LOGO_AT) return; if (!IN_title.id) IN_title = LoadTexture(vs_path("img/title.png")); if (!IN_title.id) return; float k = 1 + 0.6f * fmaxf(0, 1 - (IV.vt - INTRO_LOGO_AT) / 0.18f), w = 570 * k, h = w * IN_title.height / IN_title.width; // sbatte e si posa in 0,18 s float a = fminf(1, (INTRO_LEN - IV.vt) / 0.6f); DrawTexturePro(IN_title, (Rectangle){ 0, 0, IN_title.width, IN_title.height }, (Rectangle){ 0.5f * (MENU_W - w), 0.5f * (MENU_H - h) - 22, w, h }, (Vector2){ 0, 0 }, 0, Fade(WHITE, fmaxf(0, a))); } // Avviso di fotosensibilita' all'accensione, come nelle altre versioni del gioco (proposta di Wolff), con i crediti del port static void Warn_update(float delta) { Warn.t += delta; if (Warn.t < 400) return; int any = ptr_pressed() || GetKeyPressed() || getenv("VS_AUTOPICK"); for (int b = 1; b <= 17 && !any && IsGamepadAvailable(0); b++) any = IsGamepadButtonPressed(0, b); if (any) Warn.active = 0, IntroVid_start(); } static void Warn_draw(void) { float W = MENU_W, x = 90, w = W - 2 * x; const char *title = tr("preload_warning_title"); text_at(title, 0.5f * W, 96, fit_size(title, 36, w), 0.5f, 0.5f, rgb(0xff3b3b, 1)); ui_wrap_text(tr("preload_warning_text"), x, 160, 22, w, 210, WHITE, 1); if (fmodf(Warn.t, 1000) < 650) text_at(tr("intro_start"), 0.5f * W, 420, fit_size(tr("intro_start"), 26, w), 0.5f, 0.5f, WHITE); } // --- Lobby del gioco a due: chi ospita sceglie personaggio e stage come sempre, chi si unisce sceglie il suo personaggio e aspetta enum { LB_CHOOSE, LB_HOST_WAIT, LB_JOIN_FIND, LB_JOIN_READY, LB_FAILED }; static struct { int active, mode, sel, hosting; float t; double goAt; char hello[1024], peer[1200]; const char *failed; } LB; static void Lobby_hello(void) { // personaggio e potenziamenti di questa console cJSON *h = cJSON_CreateObject(), *levels = cJSON_AddObjectToObject(h, "levels"), *pw; cJSON_AddStringToObject(h, "char", po_str("SelectedCharacter")); cJSON_ArrayForEach(pw, data_get("powerups")) cJSON_AddNumberToObject(levels, pw->string, num(cJSON_GetArrayItem(pw, 0), "level", 0)); char *t = cJSON_PrintUnformatted(h); snprintf(LB.hello, sizeof(LB.hello), "%s", t); cJSON_free(t), cJSON_Delete(h); } static void Lobby_open(void) { memset(&LB, 0, sizeof(LB)); LB.active = 1; } static void Lobby_close(void) { net_close(); LB.active = 0, LB.hosting = 0; } static void Lobby_join_cycleCharacter(int d); static void Lobby_begin(int host) { if (!net_lobby_start(host)) { LB.mode = LB_FAILED, LB.failed = port_tr("lb_nonet"); return; } LB.mode = host ? LB_HOST_WAIT : LB_JOIN_FIND; if (!host) Lobby_join_cycleCharacter(0); // un SelectedCharacter mai comprato (solo evidenziato) diventa il primo giocabile Lobby_hello(); } static void Lobby_join_cycleCharacter(int d) { // i personaggi giocabili come nella CharSelectionScene: isBought nei dati (iniziali + comprati) const char *u[256]; // UnlockedCharacters sono solo quelli trovati: con un salvataggio nuovo e' vuoto e non si sceglieva niente int n = 0, at = 0; cJSON *c; cJSON_ArrayForEach(c, data_get("characters")) if (n < 256 && cJSON_IsTrue(cJSON_GetObjectItem(cJSON_GetArrayItem(c, 0), "isBought"))) u[n++] = c->string; if (n < 1) return; for (int i = 0; i < n; i++) if (po_str("SelectedCharacter") && !strcmp(u[i], po_str("SelectedCharacter"))) at = i; po_sets("SelectedCharacter", u[(at + d + n) % n]); Lobby_hello(); } static void Lobby_startAsClient(unsigned seed, char *hostSave) { // la partita usa il salvataggio dell'ospite; i volumi e la lingua restano i propri double sv = po_num("SoundsVolume"), mv = po_num("MusicVolume"); char lang[16]; snprintf(lang, sizeof(lang), "%s", po_str("Language") ? po_str("Language") : ""); cJSON_Delete(Net_second); char *sep = strchr(hostSave, '\x01'); // "\x01": le due console usano lo stesso if (sep) *sep = 0; Net_second = cJSON_Parse(sep ? hostSave : LB.hello); if (sep) memmove(hostSave, sep + 1, strlen(sep + 1) + 1); SaveSystem_ApplyLoadedSave(hostSave); vs_free(hostSave); // viene da net.c: non e' memoria di partita po_set("SoundsVolume", sv), po_set("MusicVolume", mv); if (*lang) po_sets("Language", lang); det_begin(seed); net_begin(); LB.active = 0; SM.launch = 1; } static void Lobby_update(float delta) { LB.t += delta; int dx = 0, dy = 0; in_dir_pressed(&dx, &dy); if (getenv("VS_NETPEER") && LB.mode == LB_CHOOSE) Lobby_begin(getenv("VS_NETHOST") != NULL); // sviluppo if (LB.mode == LB_CHOOSE) { if (dy) LB.sel = !LB.sel; if (in_confirm()) Lobby_begin(LB.sel == 0); else if (in_cancel()) LB.active = 0; } else if (LB.mode == LB_HOST_WAIT) { if (net_lobby_poll(LB.hello, LB.peer, sizeof(LB.peer))) { cJSON_Delete(Net_second); Net_second = cJSON_Parse(LB.peer); LB.active = 0, LB.hosting = 1; if (getenv("VS_NETHOST")) LB.goAt = GetTime() + atof(getenv("VS_NETHOST")); // sviluppo: senza scelte, il via dopo N secondi else MM_onStart(NULL); // personaggio e stage come sempre; il via parte con SM.launch return; } if (in_cancel()) Lobby_close(); } else { if (LB.mode == LB_JOIN_FIND && net_lobby_poll(LB.hello, LB.peer, sizeof(LB.peer))) LB.mode = LB_JOIN_READY; if (LB.mode == LB_JOIN_READY) { static int devCycled; // sviluppo: VS_LBCYCLE=n scorre il personaggio di n appena collegato if (getenv("VS_LBCYCLE") && !devCycled) devCycled = 1, dx = atoi(getenv("VS_LBCYCLE")); if (dx) Lobby_join_cycleCharacter(dx); static int rs; if (dx || ++rs % 15 == 0) net_lobby_resend(LB.hello); // l'ospite tiene l'ultimo e lo rimanda col via unsigned seed; char *save; if (net_lobby_wait_go(&seed, &save)) { Lobby_startAsClient(seed, save); return; } } if (in_cancel()) Lobby_close(); } if (LB.mode == LB_FAILED && (in_cancel() || in_confirm())) LB.mode = LB_CHOOSE; } static void Lobby_draw(void) { DrawRectangle(0, 0, MENU_W, MENU_H, (Color){ 10, 4, 8, 200 }); float cx = 0.5f * MENU_W; text_at("CO-OP", cx, 60, 44, 0.5f, 0.5f, rgb(VUI_GOLD, 1)); if (LB.mode == LB_CHOOSE) { const char *o[2] = { port_tr("lb_host"), port_tr("lb_join") }; for (int i = 0; i < 2; i++) { text_at(o[i], cx, 220 + i * 60, 30, 0.5f, 0.5f, LB.sel == i ? YELLOW : WHITE); if (LB.sel == i) ui_arrows(cx, 220 + i * 60, 0.5f * MeasureTextEx(vs_font, o[i], 30, 0).x + 12, LB.t); } text_at(port_tr("lb_wifi"), cx, 390, 20, 0.5f, 0.5f, rgb(0xb8b0a4, 1)); } else if (LB.mode == LB_HOST_WAIT) { text_at(port_tr("lb_waiting"), cx, 250, 30, 0.5f, 0.5f, WHITE); } else if (LB.mode == LB_JOIN_FIND) { text_at(port_tr("lb_looking"), cx, 250, 30, 0.5f, 0.5f, WHITE); } else if (LB.mode == LB_JOIN_READY) { text_at(port_tr("lb_yourchar"), cx, 210, 26, 0.5f, 0.5f, rgb(VUI_GOLD, 1)); text_at(TextFormat("< %s >", char_text(po_str("SelectedCharacter"), "charName")), cx, 260, 32, 0.5f, 0.5f, WHITE); text_at(port_tr("lb_hoststage"), cx, 330, 22, 0.5f, 0.5f, rgb(0xb8b0a4, 1)); } else text_at(LB.failed, cx, 250, 28, 0.5f, 0.5f, rgb(0xff6b6b, 1)); } // Fine partita a due: chi si e' unito torna al proprio salvataggio e tiene le monete guadagnate void game_net_end(void) { double coins = Core.RunCoins; int joined = net_role == 1; net_close(); det_end(); if (joined) { SaveSystem_Load(); po_add("Coins", coins), po_add("LifetimeCoins", coins), po_add("TotalCoins", coins); PlayerOptions_Save(); } } int menu_update(float dt) { float delta = dt * 1000; ptr_update(); if (BV.active) { BootVid_update(delta); return 0; } if (Warn.active) { Warn_update(delta); return 0; } if (IV.active) { IntroVid_update(delta); return 0; } if (LB.active) { KeyQ_poll(); Sound_Update(delta); Lobby_update(delta); if (!SM.launch) return 0; } if (ptr_pressed() && vui_prompt_touch(menu_pointer())) PT.prev = PT.down; // il tocco sulla barra dei tasti non arriva alla scena KeyQ_poll(); Sound_Update(delta); if (FE.active) { FinalFireworksScene_update(delta); return 0; } // finali: niente menu sotto if (CE.active) { CreditsEndingScene_update(delta); return 0; } IntroScene_combos(); if (menu_quit) return -1; IntroScene_update(delta); if (menu_skip && IN.gridMade) { if (!strcmp(menu_skip, "powerup")) MM_onPowerup(NULL); else if (!strcmp(menu_skip, "secrets")) SceneManager_SecretsFromMainMenu(); else if (!strcmp(menu_skip, "collection")) MM_onCollection(NULL); else if (!strcmp(menu_skip, "achievements")) MM_onAchievement(NULL); else if (!strcmp(menu_skip, "bestiary")) SceneManager_BestiaryFromMainMenu(); else if (!strcmp(menu_skip, "jukebox")) SceneManager_Jukebox_FromMainMenu(); else if (!strcmp(menu_skip, "options")) MM_onOptionsKey(); else if (!strcmp(menu_skip, "recovery")) MM_onOptionsKey(), SceneManager_RecoveryFromOptions(); else if (!strcmp(menu_skip, "credits")) MM_onCredits(NULL); else if (strcmp(menu_skip, "main") && strcmp(menu_skip, "credits")) MM_onStart(NULL); if (!strcmp(menu_skip, "stages")) SceneManager_StartFromCharSelection(); menu_skip = NULL; } Overlay_update(delta); if (getenv("VS_AUTOPICK")) { // sviluppo: primo input e "conferma" sul selezionato ogni 400 ms static float acc; if (IN.introEnded && !IN.isInitialized) IntroScene_OnFirstInput(); if ((acc += delta) > 0x190 && UIGrid.on && OV.UI_selected) acc = 0, Overlay_OnSubmitPressed(); } if (CS.active) CharSelectionScene_update(delta); else if (SS.active) StageSelectionScene_update(delta); else if (PU.active) PowerUpScene_update(delta); else if (SC.active) CollectionSecretScene_update(delta); else if (CW.active) CollectionWeaponScene_update(delta); else if (CA.active) CollectionAchievementsScene_update(delta); else if (BE.active) CollectionBestiaryScene_update(delta); else if (OP.active) Options_update(delta); else if (RC.active) RecoveryScene_update(delta); else if (CR.active) CreditsScene_update(delta); else if (JB.active) JukeboxScene_update(delta); MainMenu_update(); TopBar_update(); if (menu_quit) return -1; if (LB.goAt > 0 && GetTime() >= LB.goAt) LB.goAt = 0, SM.launch = 1; if (SM.launch) { SM.launch = 0, SM.active = 0; Overlay_DestroyGrid(); if (LB.hosting) { // chi ospita da' il via: seme e salvataggio all'altra console unsigned seed = (unsigned)time(NULL); SaveSystem_UpdateChecksum(); net_lobby_poll(LB.hello, LB.peer, sizeof(LB.peer)); // l'ultima scelta di chi si e' unito (la rimanda ogni 15 frame) cJSON_Delete(Net_second); Net_second = cJSON_Parse(LB.peer); const char *pc = cJSON_GetStringValue(cJSON_GetObjectItem(Net_second, "char")); if (Net_second && (!pc || !tbl0("characters", pc))) { // un CUSTOM che qui non c'e': Antonio, e lo sa anche l'altra console cJSON_DeleteItemFromObject(Net_second, "char"); cJSON_AddStringToObject(Net_second, "char", "ANTONIO"); char *t = cJSON_PrintUnformatted(Net_second); snprintf(LB.peer, sizeof(LB.peer), "%s", t); cJSON_free(t); } char *save = cJSON_PrintUnformatted(PlayerOptions); size_t gn = strlen(LB.peer) + strlen(save) + 2; char *go = malloc(gn); snprintf(go, gn, "%s\x01%s", LB.peer, save); int ok = net_lobby_send_go(seed, go); cJSON_free(save), free(go); LB.hosting = 0; if (ok) det_begin(seed), net_begin(); else net_close(); // l'altra console e' sparita: si gioca da soli } menu_launching = 1; game_start(po_str("SelectedCharacter")); menu_launching = 0; return 1; } return 0; } static void menu_draw_all(void) { IntroScene_drawScene(); MainMenu_draw(); if (CS.active) CharSelectionScene_draw(); if (SS.active) StageSelectionScene_draw(); if (PU.active) PowerUpScene_draw(); if (SC.active) CollectionSecretScene_draw(); if (CW.active) CollectionWeaponScene_draw(); if (CA.active) CollectionAchievementsScene_draw(); if (BE.active) CollectionBestiaryScene_draw(); if (OP.active) Options_draw(); if (RC.active) RecoveryScene_draw(); if (CR.active) CreditsScene_draw(); if (JB.active) JukeboxScene_draw(); TopBar_draw(); vui_prompt_bar(); Overlay_draw(); } void menu_draw(void) { float ms = menu_scale(), mw = MENU_W * ms, x0 = (SCREEN_W - mw) / 2; ClearBackground(BLACK); if (BV.active) { rlPushMatrix(); rlTranslatef(x0, 0, 0); rlScalef(ms, ms, 1); BootVid_draw(); rlPopMatrix(); return; } if (Warn.active) { rlPushMatrix(); rlTranslatef(x0, 0, 0); rlScalef(ms, ms, 1); Warn_draw(); rlPopMatrix(); return; } if (IV.active) { rlPushMatrix(); rlTranslatef(x0, 0, 0); rlScalef(ms, ms, 1); IntroVid_draw(); rlPopMatrix(); return; } if (FE.active || CE.active) { // finali a tutto schermo BeginScissorMode((int)x0, 0, (int)mw, SCREEN_H); rlPushMatrix(); rlTranslatef(x0, 0, 0); rlScalef(ms, ms, 1); if (FE.active) FinalFireworksScene_draw(); else CreditsEndingScene_draw(); rlPopMatrix(); EndScissorMode(); return; } if (!IN.introEnded) { // la pixelation riguarda la sola IntroScene: barra e menu sono ancora nascosti menu_pixelate(IntroScene_drawScene, 0x32 + (1 - 0x32) * lerp01(IN.t, 0, 0x3e8), x0, mw, SCREEN_H); return; } BeginScissorMode((int)x0, 0, (int)mw, SCREEN_H); rlPushMatrix(); rlTranslatef(x0, 0, 0); rlScalef(ms, ms, 1); menu_draw_all(); if (LB.active) Lobby_draw(); rlPopMatrix(); EndScissorMode(); } void game_start(const char *character) { HomeVideo_close(); // un solo decoder: la partita puo' averne bisogno TapMove.on = 0; char chbuf[64]; // spesso e' po_str("SelectedCharacter"): il po_sets qui sotto libererebbe la stringa snprintf(chbuf, sizeof(chbuf), "%s", character); character = chbuf; TowerBake_on = 0; if (getenv("VS_HURRY")) po_setb("SelectedHurry", 1); // sviluppo game_width = (po_is("FullScreenView") || getenv("VS_FULLSCREEN")) && !net_on ? 805 : 730; // 456 * 960 / 544: niente bande nere; in coop le due console devono vedere lo stesso mondo memset(&WhiteHand, 0, sizeof(WhiteHand)), camera_zoom = 1, HasHardBounds = 0, memset(&CamPan, 0, sizeof(CamPan)), WE.made = 0, Enemy_beatMode = 0; GOI.active = 0; FB_disableMovingBG = 0; camera_followOffsetX = 0, FrameFreeze_ms = 0; Lights.on = 0, Lights.n = 0; // le luci di candela si assegnano solo dopo Lights_Init dello stage nuovo FishEye.on = 0, FishEye.intensity = 0; if (LoopSfx.on) Music_close(&LoopSfx.m), LoopSfx.on = 0; // fancyBG.OnDestroy: StopSound(Wind) time_reset(); tweens_reset(); physics_reset(); children_reset(); memset(hitvfx, 0, sizeof(hitvfx)); n_CollisionLayers = 0; PaniniOwner = NULL, PaniniSpr.visible = 0; // children_reset l'ha tolto dalla lista LU.active = 0; TS.active = 0; GO.active = PG.active = 0; PS.active = 0; DS.active = 0; CF.active = 0; IF.active = 0; WS.active = 0; ARC.active = 0; PN.active = 0; Library_OnDestroy(); // VS_AUTORESTART: la partita nuova senza passare dal menu Machine_OnDestroy(); gmem_reset(); // dopo i reset di timer, tween, fisica e lista di disegno: nessuno punta piu' alla partita vecchia LU.gems = NULL; // il ParticleManager del level-up era della partita precedente memset(&DamagePool, 0, sizeof(DamagePool)); // i numeri vivono nella scena: si ricreano a ogni partita memset(LUF_of, 0, sizeof(LUF_of)); memset(laurel_of, 0, sizeof(laurel_of)); n_TweenAngles = 0; EnemyBlock = calloc(ENEMY_BLOCK, sizeof(Enemy)), EnemyBlock_used = 0; // dopo gmem_reset: valgono per questa partita memset(EnemyData_table, 0, sizeof(EnemyData_table)); run_ms = 0; // CharacterSelection: SelectedCharacter e l'arma di partenza vista (la scelta dello stage arriva con F3.1; sviluppo: VS_STAGE=LIBRARY) po_sets("SelectedCharacter", character); if (getenv("VS_STAGE")) po_sets("SelectedStage", getenv("VS_STAGE")); if (getenv("VS_INVERSE")) po_setb("SelectedInverse", atoi(getenv("VS_INVERSE")) != 0), po_setb("VisuallyInvertStages", atoi(getenv("VS_INVERSE")) != 2); // sviluppo: 0 spenta, 2 senza capovolgere if (po_is("SelectedReapers")) po_setb("HasUsedTrumpet", 1); // Core constructor if (po_is("SelectedInverse")) po_setb("HasUsedMirror", 1); Core_SetSeenWeapon(str(tbl0("characters", character), "startingWeapon")); po_set("RunFever", 0), po_set("RunHunger", 0); // Core.InitGame (RunCoins/RunEnemies/RunPickups: in Core) Core_InitGame(character); add_image(&pauseButton, game_width, 0x60 * MASTER_SCALE, "UI", "pause.png"); // MainScene.create sprite_setScale(&pauseButton, 2.5f); // Vita: in basso a destra, piu' grande e piu' visibile sprite_setOrigin(&pauseButton, 1, 0); pauseButton.x = game_width - 6, pauseButton.y = game_height - 6 - pauseButton.height * 2.5f; pauseButton.alpha = 0.55f; MainScene_enterPause = 0; GoldFever_init(); GizmoManager_init(); ContainmentRect_init(&Core.containmentRect_Enemies, 1.4f, 1.6f); ContainmentRect_init(&Core.containmentRect_Bullets, 1.2f, 1.3f); Core.Player->s.draw = Player_draw; memset(&last_result, 0, sizeof(last_result)); snprintf(last_result.character, sizeof(last_result.character), "%s", Core.Player->characterType); if (!fill_shader.id) { // u >= 2: riempimento (scene_render_one sposta u di 4), altrimenti come lo shader di default. Lo spostamento si toglie // nel vertex shader: nel fragment la lettura della texture diventava "dipendente" (coordinate calcolate prima di // texture2D), cara su ogni pixel della GPU della Vita (~6 ms a frame con 300 nemici, misurato 2026-11-01). // highp sulla coordinata: in mediump gli atlanti da 2048 perdono i texel. static const char *FILL_VS = #ifdef __vita__ "#version 100\nattribute vec3 vertexPosition;\nattribute vec2 vertexTexCoord;\nattribute vec4 vertexColor;\nuniform mat4 mvp;\n" "varying highp vec2 fragTexCoord;\nvarying lowp vec4 fragColor;\nvarying lowp float fillF;\n" "void main() { float f = step(2.0, vertexTexCoord.x); fragTexCoord = vec2(vertexTexCoord.x - 4.0 * f, vertexTexCoord.y);\n" " fillF = f; fragColor = vertexColor; gl_Position = mvp * vec4(vertexPosition, 1.0); }\n"; #else "#version 330\nin vec3 vertexPosition;\nin vec2 vertexTexCoord;\nin vec4 vertexColor;\nuniform mat4 mvp;\n" "out vec2 fragTexCoord;\nout vec4 fragColor;\nout float fillF;\n" "void main() { float f = step(2.0, vertexTexCoord.x); fragTexCoord = vec2(vertexTexCoord.x - 4.0 * f, vertexTexCoord.y);\n" " fillF = f; fragColor = vertexColor; gl_Position = mvp * vec4(vertexPosition, 1.0); }\n"; #endif static const char *FILL_FS = #ifdef __vita__ "#version 100\nprecision mediump float;\nvarying highp vec2 fragTexCoord;\nvarying lowp vec4 fragColor;\nvarying lowp float fillF;\n" "uniform sampler2D texture0;\n" "void main() { lowp vec4 t = texture2D(texture0, fragTexCoord);\n" " gl_FragColor = mix(t * fragColor, vec4(fragColor.rgb, t.a * fragColor.a), fillF); }\n"; #else "#version 330\nin vec2 fragTexCoord;\nin vec4 fragColor;\nin float fillF;\nuniform sampler2D texture0;\nout vec4 finalColor;\n" "void main() { vec4 t = texture(texture0, fragTexCoord);\n" " finalColor = mix(t * fragColor, vec4(fragColor.rgb, t.a * fragColor.a), fillF); }\n"; #endif fill_shader = LoadShaderFromMemory(FILL_VS, FILL_FS); } if (net_on) Players_addSecond(character); PlayerOptions_Save(); // MainScene.create } // Opzioni > HUD laterale (idea e mockup di Wolff): armi, potenziamenti e barra dell'esperienza nelle bande nere ai lati della vista static int SideHUD_on(void) { return game_width == 730 && (getenv("VS_SIDEHUD") || po_is("SideHUD")); } // a schermo intero non ci sono bande static void SideHUD_sync(void) { // gli elementi classici restano nella scena: spenti finche' l'opzione e' attiva int on = SideHUD_on(); MainUI.WeaponSlots.visible = PlayerUI.progressBox.visible = PlayerUI.progressBar.visible = MainUI.PlayerLevelText.s.visible = !on; for (int i = 0; i < 5; i++) MainUI.BlockedWeaponSlots[i].alpha = on ? 0 : 0.5f; for (int i = 0; i < MainUI.n_icons; i++) MainUI.icons[i].image.alpha = on ? 0 : 1; } static void SideHUD_slot(float x, float y, float sz, const Sprite *icon) { DrawRectangleRec((Rectangle){ x, y, sz, sz }, (Color){ 0x14, 0x14, 0x22, 255 }); DrawRectangleLinesEx((Rectangle){ x, y, sz, sz }, 2, (Color){ 0xc8, 0xa0, 0x30, 255 }); if (!icon || !icon->frame) return; const Frame *f = icon->frame; float k = (sz - 6) / fmaxf(f->w, f->h), w = f->w * k, h = f->h * k; DrawTexturePro(*f->tex, (Rectangle){ f->x, f->y, f->w, f->h }, (Rectangle){ x + 0.5f * (sz - w), y + 0.5f * (sz - h), w, h }, (Vector2){ 0, 0 }, 0, WHITE); } static void SideHUD_draw(float band) { if (!SideHUD_on() || band < 30) return; const float sz = 30, step = 34, x = 0.5f * (band - sz); for (int i = 0; i < 6; i++) { // armi dall'alto const Sprite *ic = i < MainUI.n_WeaponIcons ? &MainUI.WeaponIcons[i]->image : i > 0 && MainUI.BlockedWeaponSlots[5 - i].visible ? &MainUI.BlockedWeaponSlots[5 - i] : NULL; SideHUD_slot(x, 6 + step * i, sz, ic); } int np = MainUI.n_PowerUpIcons, nx = MainUI.n_ExtraIcons, rows = np + nx < 6 ? 6 : np + nx > 10 ? 10 : np + nx; for (int i = 0; i < rows; i++) { // potenziamenti dal basso, poi arcane e armi nascoste const Sprite *ic = i < np ? &MainUI.PowerUpIcons[i]->image : i - np < nx ? &MainUI.ExtraIcons[i - np]->image : NULL; SideHUD_slot(x, SCREEN_H - 6 - sz - step * i, sz, ic); } float rx = SCREEN_W - band, bx = rx + 0.5f * (band - 22), by = 30, bh = SCREEN_H - by - 6, full = game_width - 8; ui_text(MainUI.PlayerLevelText.text, rx + 0.5f * band, 15, 1, band - 4, 0.5f, 0.5f, WHITE); float v = full > 0 ? fminf(PlayerUI.progressW / full, 1) : 0; DrawRectangleRec((Rectangle){ bx, by, 22, bh }, (Color){ 0x14, 0x14, 0x22, 255 }); DrawRectangleRec((Rectangle){ bx, by + bh * (1 - v), 22, bh * v }, (Color){ 0x22, 0x66, 0xdd, 255 }); DrawRectangleLinesEx((Rectangle){ bx, by, 22, bh }, 2, (Color){ 0xc8, 0xa0, 0x30, 255 }); } const char *game_prof(void) { static char b[240]; snprintf(b, sizeof(b), "oggetti %d fuori %d custom %d tile %d interruzioni %d nemici %d proiettili %d gemme %d particelle %d tween %d lv %d tipi %d sec %d", prof_children, prof_offscreen, prof_custom, prof_tiles, prof_breaks, Core.Enemies.n, Core.BulletGroup.n, Core.PickupGroup.n, particles_alive(), tweens_used(), Core.Player ? Core.Player->level : 0, Core.Stage ? Core.Stage->n_pools : 0, Core.SurvivedSeconds); return b; } int game_update(float dt) { if (Players_n > 1) game_context_set(Scene_owner), net_input_player = Scene_owner; // una scena aperta (level-up, forziere) lavora per chi ci e' entrato ptr_update(); KeyQ_poll(); MainScene_combos(); Sound_Update(dt * 1000); float delta = dt * 1000; // ms, come il TimeStep di Phaser if (PS.active) { PauseScene_update(delta); return 0; } // PauseScene sopra la MainScene in pausa if (SM_restart) { SM_restart = 0; Sound_StopMusic(); game_start(po_str("SelectedCharacter")); return 0; } // SceneManager.RestartMainScene (il primo sigillo) if (SM_reset) { SM_reset = 0; return 1; } // SceneManager.Reset: niente risultati, si torna all'Intro if (CF.active) { CharFoundScene_update(delta); return 0; } // UI_charFoundScene if (RF.active) { RelicFoundScene_update(delta); return 0; } // UI_relicFoundScene if (SH.active) { ShopScene_update(delta); return 0; } // UI_merchantScene if (HE.active) { HealerScene_update(delta); return 0; } // UI_healerScene if (DS.active) { DirecterScene_update(delta); return 0; } // UI_directerScene if (PN.active) { PianoScene_update(delta); return 0; } // UI_pianoScene if (LU.active) { LevelUpScene_update(delta); return 0; } if (IF.active) { ItemFoundScene_update(delta); return 0; } if (WS.active) { WeaponSelectScene_update(delta); return 0; } // UI_selectWeaponScene if (ARC.active) { ARC_update(delta); return 0; } // UI_arcanaMainScene / UI_arcanaDraftScene // UI_newItemFoundScene // MainScene in pausa: si aggiorna solo la scena del level-up if (TS.active) { TreasureScene_update(delta); return 0; } // idem con UI_treasureScene if (GO.active) { GameOverScene_update(delta); return 0; } // GameOverScene sopra la MainScene in pausa if (GOI.active) GameOverino_update(delta); // GameOverinoScene: la MainScene continua sotto if (FrameFreeze_ms > 0) { FrameFreeze_ms -= delta; return 0; } // SceneManager.FrameFreeze: MainScene in pausa per 120 ms if (PG.active) { PostGameScene_update(delta); if (!PG.done) return 0; PG.active = 0; last_result = (Result){ Core.SurvivedSeconds, Core.kills, Core.Player->level, "" }; snprintf(last_result.character, sizeof(last_result.character), "%s", Core.Player->characterType); if (getenv("VS_AUTORESTART")) { game_start(last_result.character); return 0; } // prova automatica di piu' partite return 1; // StartFromPostGame -> IntroScene } run_ms += delta; if (getenv("VS_CFF") && run_ms == 0 && Core.n_CharQueue < 8) Core.CharQueue[Core.n_CharQueue++] = getenv("VS_CFF"); // sviluppo: la scena della bara con quel personaggio if (getenv("VS_RELIC") && run_ms == 0 && Core.n_RelicQueue < 16) Core.RelicQueue[Core.n_RelicQueue++] = getenv("VS_RELIC"); // sviluppo: la scena della reliquia trovata if (getenv("VS_EGG") && run_ms == 0) // sviluppo: VS_EGG=n uova d'oro in fila a destra del giocatore for (int i = 0; i < atoi(getenv("VS_EGG")); i++) Core_MakeStagePickup(Core.Player->s.x + 0x18 * i, Core.Player->s.y, "RELIC_GOLDENEGG", NULL); static int pausedOnce; // sviluppo: VS_PAUSE=2 chiede la pausa a 2 s (una volta per partita) if (run_ms == 0) pausedOnce = 0; if (getenv("VS_PAUSE") && !pausedOnce && run_ms >= atof(getenv("VS_PAUSE")) * 1000) pausedOnce = 1, MainScene_enterPause = 1; const char *die = getenv("VS_DIE"); // sviluppo: VS_DIE=2 il giocatore muore a 2 s (una volta) static int died; // una volta per partita: dopo una resurrezione (GameOverino, Rinascita) il giocatore resta vivo if (run_ms == 0) died = 0; if (die && !died && run_ms >= atof(die) * 1000 && !Core.Player->isDead) { died = 1; Core.Player->hp = 0; Player_Die(Core.Player); } // VS_LOGPROF=1: tempo medio di ogni sezione ogni 300 frame (Vita: /logprof.txt, desktop: stderr) static int lp = -1, lpn; static double lt[8]; if (lp < 0) lp = getenv("VS_LOGPROF") != NULL; double t0 = lp ? GetTime() : 0, t1; #define LP(i) if (lp) t1 = GetTime(), lt[i] += t1 - t0, t0 = t1 // Systems.step: PRE_UPDATE clock_preUpdate(); tweens_preUpdate(); LP(0); // UPDATE: UpdateList, Clock, Tweens, World scene_update_list(delta); LP(1); particles_update_all(delta); LP(2); clock_update(delta); LP(3); tweens_update(delta); LP(4); world_update(delta); LP(5); // scena.update scene_update(delta); LP(6); // POST_UPDATE world_postUpdate(); LP(7); #undef LP if (lp && ++lpn == 300) { #ifdef __vita__ FILE *o = fopen(vs_path("logprof.txt"), "a"); #else FILE *o = stderr; #endif static const char *const N[8] = { "pre", "updateList", "particelle", "clock", "tween", "fisica", "scena", "post" }; if (o) { extern int phys_runs; fprintf(o, "LOGPROF fps %d 3d %d nemici %d gemme %d tween %d passi/frame %.2f fisica/passo %.2f ms |", GetFPS(), scene_view3d, Core.Enemies.n, Core.PickupGroup.n, tweens_used(), (double)phys_runs / lpn, phys_runs ? lt[5] * 1000 / phys_runs : 0); phys_runs = 0; for (int i = 0; i < 8; i++) fprintf(o, " %s %.2f", N[i], lt[i] * 1000 / lpn); extern double draw_prof[8]; double *d = draw_prof, k = 1000.0 / lpn; fprintf(o, " ms | disegno: ordina %.2f tessere %.2f particelle %.2f custom %.2f sprite %.2f resto %.2f tot %.2f ms", d[0] * k, d[1] * k, d[2] * k, d[3] * k, d[4] * k, (d[6] - d[0] - d[1] - d[2] - d[3] - d[4]) * k, d[6] * k); fprintf(o, " | sprite %d custom %d interruzioni %d\n", prof_children - prof_custom, prof_custom, prof_breaks); memset(draw_prof, 0, sizeof(draw_prof)); if (o != stderr) fclose(o); } memset(lt, 0, sizeof(lt)), lpn = 0; } return 0; } static void Player_draw(Sprite *s) { Player *p = s->owner; int saved = s->visible; // rtGhosts: copie del giocatore nelle ultime posizioni, alpha (0.1 - 0.1 i) * ghostAlpha, tinta 0xe0e0ff float a = s->alpha; unsigned t = s->tint; float sx = s->x, sy = s->y; for (int i = 0; i <= p->maxHistory && !p->ghostsHidden; i++) { Vector2 h = p->posHistory[(i + p->historyIndex) % p->maxHistory]; float al = (0.1f - 0.1f * i) * p->ghostAlpha; if (al <= 0) continue; s->x = sx + h.x - s->body.position.x; s->y = sy + h.y - s->body.position.y; s->alpha = al; s->tint = 0xe0e0ff; s->draw = NULL; scene_render_one(s, fill_shader); s->draw = Player_draw; } s->x = sx; s->y = sy; s->alpha = a; s->tint = t; s->visible = saved; s->draw = NULL; scene_render_one(s, fill_shader); s->draw = Player_draw; } double draw_prof[8]; // VS_LOGPROF: 0 ordinamento, 1 tessere, 2 particelle, 3 custom, 4 sprite (scene_render), 6 tutto game_draw static float View_zoom(void) { float z = getenv("VS_ZOOM") ? (float)atof(getenv("VS_ZOOM")) : (float)po_num("ViewZoom"); return z > 0 ? z : 1; } // Opzioni: avvicina o allontana il mondo, il HUD resta fermo void game_draw(void) { double gd_t0 = GetTime(); // Camera.preRender (startFollow): la camera segue la posizione dello sprite dopo la fisica if (Players_n > 1) PlayerUI_Update(); // l'esperienza cresce anche con le gemme dell'altro camera_follow(Players_n > 1 && net_role == 1 ? &Slots[1].player->s : CamPan_target()); // il giocatore, o la camera verso l'Ender che muore // Una vista di gioco sola, mostrata nel frame in cui e' disegnata. Dal 2026-11-01 all'11-11 la Vita ne alternava quattro e // mostrava quella di due frame prima per i lampi neri: la causa era il vsync spento (vedi main), il ritardo costava 33 ms. static RenderTexture2D view; RenderTexture2D *rtp = &view; if (rtp->id && rtp->texture.width != game_width) UnloadRenderTexture(*rtp), rtp->id = 0; // Schermo intero cambiato fra una partita e l'altra if (!rtp->id) { *rtp = LoadRenderTexture(game_width, game_height); SetTextureFilter(rtp->texture, TEXTURE_FILTER_POINT); } RenderTexture2D rt = *rtp; SideHUD_sync(); TowerBake_render(); BeginTextureMode(rt); ClearBackground(BLACK); static int nofill = -1; // VS_NOFILL=1: tintFill senza shader (diagnosi dei quad bianchi sulla Vita) if (nofill < 0) nofill = getenv("VS_NOFILL") != NULL; int zoomOut = camera_zoom < 1; // zoom indietro (fase 5 della Machine): tutta la scena scalata attorno al centro, HUD compreso come in Phaser if (zoomOut) rlPushMatrix(), rlTranslatef(0.5f * game_width, 0.5f * game_height, 0), rlScalef(camera_zoom, camera_zoom, 1), rlTranslatef(-0.5f * game_width, -0.5f * game_height, 0); scene_world_zoom = View_zoom(), scene_ui_depth = ZInGameUI - 0x10, scene_zoom_out = camera_zoom; static int devGlasses; // sviluppo: VS_GLASSES=secondi come se avessi appena preso gli occhiali if (getenv("VS_GLASSES") && !devGlasses) devGlasses = 1, Glasses_fx = 1, Glasses_left = (float)atof(getenv("VS_GLASSES")); // Glasses_fx finisce appena sotto zero, mai esattamente a 0: con !Glasses_fx il conto non partiva e il 3D restava per sempre static int glassesOut; // allo scadere: un solo fisheye di uscita, col 3D ancora acceso finche' dura if (Glasses_left > 0 && Glasses_fx <= 0 && (Glasses_left -= GetFrameTime()) <= 0) Glasses_left = 0, Glasses_fx = 1, glassesOut = 1; // tempo reale if (glassesOut && Glasses_fx <= 0) glassesOut = 0; scene_view3d = getenv("VS_3D") && *getenv("VS_3D") ? atoi(getenv("VS_3D")) : po_is("View3D") || Glasses_left > 0 || glassesOut; // Opzioni > Vista 2D | 3D if (getenv("VS_3DDIST")) view3d_dist = (float)atof(getenv("VS_3DDIST")); if (getenv("VS_3DPITCH")) view3d_pitch = (float)atof(getenv("VS_3DPITCH")); scene_render(nofill ? (Shader){ 0 } : fill_shader); // la mappa (TilingTileset) e' nella lista di disegno, depth -2000..1995 if (zoomOut) rlPopMatrix(); if (getenv("VS_BODIES")) { physics_drawDebug(); if (Core.Enemies.n) { Sprite *e = Core.Enemies.items[0]; TraceLog(LOG_WARNING, "DBG enemy x=%.1f y=%.1f w=%.0f h=%.0f sc=%.2f/%.2f org=%.2f,%.2f body pos=%.1f,%.1f c=%.1f,%.1f hw=%.1f off=%.1f,%.1f src=%.0f _sx=%.2f", e->x, e->y, e->width, e->height, e->scaleX, e->scaleY, e->originX, e->originY, e->body.position.x, e->body.position.y, e->body.center.x, e->body.center.y, e->body.halfWidth, e->body.offset.x, e->body.offset.y, e->body.sourceWidth, e->body._sx); } } static int bq = -1, bb, ba, bs, bsame; // VS_BENCH=quadsN | breaksN | addN: quad di prova (misure del costo per quad / per interruzione / per miscela) if (bq < 0) { const char *e = getenv("VS_BENCH"); bq = e && !strncmp(e, "quads", 5) ? atoi(e + 5) : 0, bb = e && !strncmp(e, "breaks", 6) ? atoi(e + 6) : 0, ba = e && !strncmp(e, "add", 3) ? atoi(e + 3) : 0, bs = e && !strncmp(e, "shader", 6) ? atoi(e + 6) : 0; if (e && !strncmp(e, "same", 4)) ba = atoi(e + 4), bsame = 1; // sameN: ogni quad additivo dentro il suo Begin/End } if (bq || bb || ba || bs) { const Frame *f1 = frame_get("vfx", "WhiteDot.png"), *f2 = frame_get("items", "GemBlue.png"); int n = bq + bb + ba + bs; for (int i = 0; i < n; i++) { const Frame *f = (bb && (i & 1)) ? f2 : f1; if (ba) BeginBlendMode((bsame || (i & 1)) ? BLEND_ADDITIVE : BLEND_ALPHA); if (bs && (i & 1)) BeginShaderMode(fill_shader); DrawTexturePro(*f->tex, (Rectangle){ f->x, f->y, f->w, f->h }, (Rectangle){ (float)(i * 7 % game_width), (float)(i * 13 % game_height), 8, 8 }, (Vector2){ 0, 0 }, 0, WHITE); if (ba) EndBlendMode(); if (bs && (i & 1)) EndShaderMode(); } } if (getenv("VS_FPS")) DrawTextEx(vs_font, TextFormat("FPS %d nemici %d", GetFPS(), Core.Enemies.n), (Vector2){ 4, game_height - 14 }, 10, 1, YELLOW); EndTextureMode(); if (vs_finish_mode() & 1) vs_gl_finish(); // VS_FINISH=rt|both: la GPU finisce la vista di gioco prima che lo schermo la legga (diagnosi del lampo nero) // Scale.FIT: la vista di gioco (altezza 456) riempie l'altezza dello schermo float sc = (float)SCREEN_H / game_height, w = game_width * sc, zw = game_width / fmaxf(camera_zoom, 1), zh = game_height / fmaxf(camera_zoom, 1); // zoom avanti: ritaglio attorno al centro if (Glasses_fx > 0) { // occhiali buffi: il mondo si gonfia e torna in 1,6 s (anche sotto la scena della reliquia trovata) Glasses_fx -= GetFrameTime() / 1.6f; FishEye.on = Glasses_fx > 0, FishEye.mode = 1, FishEye.radius = 0.25f * game_height, FishEye.intensity = sinf(PI * fmaxf(0, Glasses_fx)); } int fish = FishEye.on && FishEye.intensity > 0; // rexFishEyePostFx sulla camera principale (Moongolow) if (fish) FishEye_Begin(); DrawTexturePro(rt.texture, (Rectangle){ (game_width - zw) / 2, (game_height - zh) / 2, zw, -zh }, (Rectangle){ (SCREEN_W - w) / 2, 0, w, SCREEN_H }, (Vector2){ 0, 0 }, 0, WHITE); if (fish) EndShaderMode(); SideHUD_draw((SCREEN_W - w) / 2); if (M5.wantSnap) Machine_TakeSnapshot(rtp); // la vista e' diventata i cocci: si riparte da una nuova if (LU.active || TS.active || IF.active || WS.active || ARC.active || PS.active || CF.active || RF.active || SH.active || HE.active || DS.active || PN.active) { // UI_levelUpScene / UI_treasureScene sopra la scena di gioco in pausa, alla risoluzione da menu // Disegno diretto con una scala (683 -> 544) invece di una texture intermedia: il testo viene // ricampionato una volta sola e resta leggibile; disposizione e colori sono quelli della scena. static int filt; if (!filt) { SetTextureFilter(vs_font.texture, TEXTURE_FILTER_BILINEAR); filt = 1; } float ms = (float)SCREEN_H / MENU_H, mw = MENU_W * ms; BeginScissorMode((int)((SCREEN_W - mw) / 2), 0, (int)mw, SCREEN_H); rlPushMatrix(); rlTranslatef((SCREEN_W - mw) / 2, 0, 0); rlScalef(ms, ms, 1); if (PS.active) { PauseScene_draw(); if (!PS.optionsOpen) PauseStatsScene_draw(PS.t); } else if (CF.active) CharFoundScene_draw(); else if (RF.active) RelicFoundScene_draw(); else if (SH.active) ShopScene_draw(); else if (HE.active) HealerScene_draw(); else if (DS.active) DirecterScene_draw(); else if (PN.active) PianoScene_draw(); else if (LU.active) LevelUpScene_draw(), PauseStatsScene_draw(LU.t); else if (IF.active) ItemFoundScene_draw(); else if (WS.active) WeaponSelectScene_draw(); else if (ARC.active) { ARC_draw(); if (ARC.draft) PauseStatsScene_draw(ARC.t); } else TreasureScene_draw(); rlPopMatrix(); EndScissorMode(); } if (PG.active) { // PostGameScene: stessa resa delle scene da menu float ms = (float)SCREEN_H / MENU_H, mw = MENU_W * ms; BeginScissorMode((int)((SCREEN_W - mw) / 2), 0, (int)mw, SCREEN_H); rlPushMatrix(); rlTranslatef((SCREEN_W - mw) / 2, 0, 0); rlScalef(ms, ms, 1); PostGameScene_draw(); rlPopMatrix(); EndScissorMode(); } if (GO.active || GOI.active) { // GameOverScene / GameOverinoScene con la camera pixelata (rexPixelationPipeline: 50 -> 1 in 1 s) static RenderTexture2D full, small; if (!full.id) { full = LoadRenderTexture(MENU_W, MENU_H); SetTextureFilter(full.texture, TEXTURE_FILTER_POINT); } BeginTextureMode(full); ClearBackground(BLANK); if (GOI.active) GameOverino_draw(); else GameOverScene_draw(); EndTextureMode(); float px = 0x32 + (1 - 0x32) * lerp01(GOI.active ? GOI.t : GO.t, 0, 0x3e8); Texture2D src = full.texture; int sw = MENU_W, sh = MENU_H; if (px > 1.01f) { // campiona a blocchi px x px: giu' su una texture piccola, poi su con filtro point sw = (int)ceilf(MENU_W / px), sh = (int)ceilf(MENU_H / px); if (!small.id) { small = LoadRenderTexture(MENU_W, MENU_H); SetTextureFilter(small.texture, TEXTURE_FILTER_POINT); } BeginTextureMode(small); // si usa l'angolo sw x sh della texture ClearBackground(BLANK); DrawTexturePro(full.texture, (Rectangle){ 0, 0, MENU_W, -MENU_H }, (Rectangle){ 0, 0, sw, sh }, (Vector2){ 0, 0 }, 0, WHITE); EndTextureMode(); src = small.texture; } float ms = (float)SCREEN_H / MENU_H, mw = MENU_W * ms; Rectangle sr = src.id == full.texture.id ? (Rectangle){ 0, 0, MENU_W, -MENU_H } : (Rectangle){ 0, MENU_H - sh, sw, -sh }; // texture capovolte DrawTexturePro(src, sr, (Rectangle){ (SCREEN_W - mw) / 2, 0, mw, SCREEN_H }, (Vector2){ 0, 0 }, 0, WHITE); } draw_prof[6] += GetTime() - gd_t0; } // VS_DET: hash dello stato di gioco alla fine di ogni frame void det_game_hash(unsigned *enemies, unsigned *player) { game_context_set(0); unsigned h = 2166136261u, v; #define DH(x) do { float f_ = (float)(x); memcpy(&v, &f_, 4); h = (h ^ v) * 16777619u; } while (0) DH(Core.Enemies.n); for (int i = 0; i < Core.Enemies.n; i++) { Enemy *e = Core.Enemies.items[i]->owner; DH(e->hp); DH(e->s.x); DH(e->s.y); } *enemies = h; h = 2166136261u; if (Core.Player) { DH(Core.Player->s.x); DH(Core.Player->s.y); DH(Core.Player->level); DH(Core.Player->xp); } DH(Core.RunCoins); DH(Core.n_weapons); if (Players_n > 1) { Player *o = Slots[1].player; DH(o->isDead); DH(o->s.x); DH(o->s.y); DH(o->level); DH(o->xp); DH(o->hp); DH(Slots[1].n_weapons); } *player = h; #undef DH } // Lockstep: l'input locale per il frame futuro void game_net_submit(void) { Vector2 v = Core.Player ? Player_localMove(Slots[net_role].player ? Slots[net_role].player : Core.Player, 1) : (Vector2){ 0, 0 }; NetMove m = { (signed char)roundf(v.x * 127), (signed char)roundf(v.y * 127), 0 }; for (int b = 1; b <= 17; b++) if (IsGamepadAvailable(0) && IsGamepadButtonDown(0, b)) m.buttons |= 1u << b; if (IsKeyDown(KEY_ENTER) || IsKeyDown(KEY_SPACE)) m.buttons |= 1u << GAMEPAD_BUTTON_RIGHT_FACE_DOWN; // la tastiera sul desktop if (IsKeyDown(KEY_BACKSPACE)) m.buttons |= 1u << GAMEPAD_BUTTON_RIGHT_FACE_RIGHT; if (IsKeyDown(KEY_ESCAPE)) m.buttons |= 1u << GAMEPAD_BUTTON_MIDDLE_RIGHT; if (IsKeyDown(KEY_LEFT)) m.buttons |= 1u << GAMEPAD_BUTTON_LEFT_FACE_LEFT; if (IsKeyDown(KEY_RIGHT)) m.buttons |= 1u << GAMEPAD_BUTTON_LEFT_FACE_RIGHT; if (IsKeyDown(KEY_UP)) m.buttons |= 1u << GAMEPAD_BUTTON_LEFT_FACE_UP; if (IsKeyDown(KEY_DOWN)) m.buttons |= 1u << GAMEPAD_BUTTON_LEFT_FACE_DOWN; const char *press = getenv("VS_NETPRESS"); // sviluppo: VS_NETPRESS=frame:tasto,frame:tasto (premuto per 4 frame) for (const char *c = press; c && *c;) { unsigned f = 0; int b = 0; if (sscanf(c, "%u:%d", &f, &b) == 2 && det_frame + 4 >= f && det_frame + 4 < f + 4) m.buttons |= 1u << b; c = strchr(c, ','); if (c) c++; } net_submit(m); }