-- Initialize the Crown state addHook("PlayerSpawn", function(player) player.sparklecrown = false end) addHook("PlayerThink", function(player) -- Target only Archie Sonic in Super Form if player.mo and player.mo.valid and player.mo.skin == "sonic" and player.powers[pw_super] then -- --- TOGGLE ULTRA BURST & CROWN (Custom Button 3) --- if (player.cmd.buttons & BT_CUSTOM3) and not (player.prevcustom3) then player.sparklecrown = not player.sparklecrown if player.sparklecrown then S_StartSound(player.mo, sfx_cybdth) -- Activation sound P_FlashPal(player, PAL_WHITE, 5) end end player.prevcustom3 = (player.cmd.buttons & BT_CUSTOM3) -- --- DYNAMIC CROWN RENDER --- if player.sparklecrown then -- This spawns the crown logic -- Because we are NOT forcing player.panim here, ALL animations will play normally! if leveltime % 3 == 0 then -- Spawn at the player's head height local crown = P_SpawnMobj(player.mo.x, player.mo.y, player.mo.z + player.mo.height, MT_IVSP) crown.target = player.mo crown.colorized = true crown.color = SKINCOLOR_YELLOW crown.flags = $|MF_NOGRAVITY|MF_BRIGHT crown.fuse = 8 -- Short fuse so it doesn't trail too far -- Swirl math locked to the player's position local radius = 18 * FRACUNIT local angle = (leveltime * ANG10) -- We use P_SetOrigin to lock the sparkle exactly above Sonic's head P_SetOrigin(crown, player.mo.x + P_ReturnDirX(angle, radius), player.mo.y + P_ReturnDirY(angle, radius), player.mo.z + player.mo.height + (10 * FRACUNIT) ) end -- Screen Clear: Passive destruction while the crown is active searchBlockmap("objects", function(sonic, enemy) if enemy and enemy.valid and (enemy.flags & MF_ENEMY) then if P_AproxDistance(sonic.x - enemy.x, sonic.y - enemy.y) < 400*FRACUNIT then P_KillMobj(enemy, sonic, sonic) S_StartSound(enemy, sfx_pop) end end end, player.mo) end end end)