--[[ ENGLISH> adjustStretching - Function to adjust sprite stretching based on player state. PT-BR> adjustStretching - Função para ajustar o estiramento do sprite com base no estado do jogador. ESPAÑOL> adjustStretching - Función para ajustar el estiramiento del sprite basado en el estado del jugador. ]]-- local function adjustStretching(player) -- Checks if the player is active before applying adjustments -- Verifica se o jogador está ativo antes de aplicar ajustes -- Verifica si el jugador está activo antes de aplicar ajustes if player.mo and player.mo.valid then -- Initialize control variables if not defined -- Inicializa variáveis de controle se não definidas -- Inicializa variables de control si no están definidas if not player.stretch then player.stretch = { jt = 0, jp = false, sp = false, tk = false, tr = false, sp_mola = false, fire = false, fall = false, float = false, glide = false, fly = false, melee = false, melee_finish = false, melee_landing = false, twinspin = false, -- Added for Twin Spin control / Adicionado para controle do Twin Spin / Añadido para control de Twin Spin current_spriteyscale = FRACUNIT, current_spritexscale = FRACUNIT, current_spriteyoffset = 0 } end local state = player.mo.state -- Stretch adjustment when running -- Ajuste de estiramento ao correr -- Ajuste de estiramiento al correr if state == S_PLAY_RUN and not player.stretch.tr then player.stretch.tr = true player.stretch.jt = 5 elseif state ~= S_PLAY_RUN then player.stretch.tr = false end -- Gradual reduction of stretching -- Redução gradual do estiramento -- Reducción gradual del estiramiento if player.stretch.jt > 0 then player.stretch.jt = player.stretch.jt - 1 elseif player.stretch.jt < 0 then player.stretch.jt = player.stretch.jt + 1 end -- Stretch adjustment when spindashing -- Ajuste de estiramento ao spindashing -- Ajuste de estiramiento al hacer spindashing if (player.pflags & PF_SPINNING) ~= 0 and not player.stretch.sp then player.stretch.sp = true player.stretch.jt = -5 elseif (player.pflags & PF_SPINNING) == 0 then player.stretch.sp = false end -- Stretch adjustment when jumping -- Ajuste de estiramento ao pular -- Ajuste de estiramiento al saltar if state == S_PLAY_JUMP and not player.stretch.jp then player.stretch.jp = true player.stretch.jt = 6 elseif state ~= S_PLAY_JUMP then player.stretch.jp = false end -- Stretch adjustment when using a spring -- Ajuste de estiramento ao usar uma mola -- Ajuste de estiramiento al usar un resorte if state == S_PLAY_SPRING and not player.stretch.sp_mola then player.stretch.sp_mola = true player.stretch.jt = 8 elseif state ~= S_PLAY_SPRING then player.stretch.sp_mola = false end -- Stretch adjustment when falling from a spring -- Ajuste de estiramento ao cair de uma mola -- Ajuste de estiramiento al caer de un resorte if state ~= S_PLAY_SPRING and player.stretch.sp_mola and player.mo.z ~= player.mo.floorz then if player.stretch.jt > -50 then player.stretch.jt = player.stretch.jt - 1 end end -- Stretch adjustment when taking damage -- Ajuste de estiramento ao sofrer dano -- Ajuste de estiramiento al recibir daño if state == S_PLAY_PAIN and not player.stretch.pain then player.stretch.jt = 6 player.stretch.pain = true elseif state ~= S_PLAY_PAIN then player.stretch.pain = false end -- Stretch adjustment when dying -- Ajuste de estiramento ao morrer -- Ajuste de estiramiento al morir if state == S_PLAY_DEAD and not player.stretch.dead then player.stretch.jt = 6 player.stretch.dead = true elseif state ~= S_PLAY_DEAD then player.stretch.dead = false end -- Stretch adjustment when idle -- Ajuste de estiramento ao ficar parado -- Ajuste de estiramiento al estar inactivo if state == S_PLAY_WAIT and not player.stretch.wait then player.stretch.jt = 1 player.stretch.wait = true elseif state ~= S_PLAY_WAIT then player.stretch.wait = false end -- Stretch adjustment when riding -- Ajuste de estiramento ao cavalgar -- Ajuste de estiramiento al montar if state == S_PLAY_RIDE and not player.stretch.ride then player.stretch.jt = 6 player.stretch.ride = true elseif state ~= S_PLAY_RIDE then player.stretch.ride = false end -- Stretch adjustment when falling -- Ajuste de estiramento ao cair -- Ajuste de estiramiento al caer if state == S_PLAY_FALL and not player.stretch.fall then player.stretch.jt = 6 player.stretch.fall = true elseif state ~= S_PLAY_FALL then player.stretch.fall = false end -- Stretch adjustment when gliding -- Ajuste de estiramento ao planar -- Ajuste de estiramiento al planear if state == S_PLAY_GLIDE and not player.stretch.glide then player.stretch.jt = 6 player.stretch.glide = true elseif state ~= S_PLAY_GLIDE then player.stretch.glide = false end -- Stretch adjustment when gasping -- Ajuste de estiramento ao ofegar -- Ajuste de estiramiento al jadear if state == S_PLAY_GASP then player.stretch.jt = 6 end -- Stretch adjustment when transforming into Super -- Ajuste de estiramento ao se transformar em Super -- Ajuste de estiramiento al transformarse en Super if state == S_PLAY_SUPER_TRANS1 then player.stretch.jt = 6 end -- Stretch adjustment when floating -- Ajuste de estiramento ao flutuar -- Ajuste de estiramiento al flotar if (state == S_PLAY_FLOAT or state == S_PLAY_FLOAT_RUN) and not player.stretch.float then player.stretch.jt = 3 player.stretch.float = true elseif state ~= S_PLAY_FLOAT and state ~= S_PLAY_FLOAT_RUN then player.stretch.float = false end -- Stretch adjustment when firing -- Ajuste de estiramento ao disparar -- Ajuste de estiramiento al disparar if state == S_PLAY_FIRE and not player.stretch.fire then player.stretch.jt = 3 player.stretch.fire = true elseif state ~= S_PLAY_FIRE then player.stretch.fire = false end -- Stretch adjustment when flying -- Ajuste de estiramento ao voar -- Ajuste de estiramiento al volar if state == S_PLAY_FLY and not player.stretch.fly then player.stretch.jt = 3 player.stretch.fly = true elseif state ~= S_PLAY_FLY then player.stretch.fly = false end -- Stretch adjustment when melee attacking -- Ajuste de estiramento ao atacar corpo a corpo -- Ajuste de estiramiento al atacar cuerpo a cuerpo if state == S_PLAY_MELEE and not player.stretch.melee then player.stretch.jt = 3 player.stretch.melee = true elseif state ~= S_PLAY_MELEE then player.stretch.melee = false end -- Stretch adjustment when finishing melee attack -- Ajuste de estiramento ao finalizar ataque corpo a corpo -- Ajuste de estiramiento al finalizar el ataque cuerpo a cuerpo if state == S_PLAY_MELEE_FINISH and not player.stretch.melee_finish then player.stretch.jt = 3 player.stretch.melee_finish = true elseif state ~= S_PLAY_MELEE_FINISH then player.stretch.melee_finish = false end -- Stretch adjustment when landing from melee attack -- Ajuste de estiramento ao pousar de um ataque corpo a corpo -- Ajuste de estiramiento al aterrizar de un ataque cuerpo a cuerpo if state == S_PLAY_MELEE_LANDING and not player.stretch.melee_landing then player.stretch.jt = 3 player.stretch.melee_landing = true elseif state ~= S_PLAY_MELEE_LANDING then player.stretch.melee_landing = false end -- Stretch adjustment when performing Twin Spin -- Ajuste de estiramento ao realizar Twin Spin -- Ajuste de estiramiento al realizar Twin Spin if state == S_PLAY_TWINSPIN and not player.stretch.twinspin then player.stretch.jt = 4 player.stretch.twinspin = true elseif state ~= S_PLAY_TWINSPIN then player.stretch.twinspin = false end -- Adjust scaling and offset of sprites only if necessary -- Ajusta a escala e o deslocamento do sprite apenas se necessário -- Ajusta la escala y el desplazamiento del sprite solo si es necesario local new_spriteyscale = (player.stretch.jt * FRACUNIT) / 10 + FRACUNIT local new_spritexscale = (-1 * player.stretch.jt * FRACUNIT) / 10 + FRACUNIT local new_spriteyoffset = -1 * ((player.stretch.jt * (state == S_PLAY_ROLL and player.spinheight or player.height)) / 20) if new_spriteyscale ~= player.stretch.current_spriteyscale then player.mo.spriteyscale = new_spriteyscale player.stretch.current_spriteyscale = new_spriteyscale end if new_spritexscale ~= player.stretch.current_spritexscale then player.mo.spritexscale = new_spritexscale player.stretch.current_spritexscale = new_spritexscale end if new_spriteyoffset ~= player.stretch.current_spriteyoffset then player.mo.spriteyoffset = new_spriteyoffset player.stretch.current_spriteyoffset = new_spriteyoffset end end end -- Hook to call adjustStretching function every frame -- Gancho para chamar a função adjustStretching a cada quadro -- Gancho para llamar a la función adjustStretching en cada cuadro addHook("PlayerThink", adjustStretching)