From 2a93628f0ca568185a65768560dc4077cde9c5f7 Mon Sep 17 00:00:00 2001 From: Marvin Winkens Date: Wed, 26 Feb 2025 14:34:07 +0100 Subject: [PATCH] add slides --- src/game/client/components/mapimages.cpp | 2 +- src/game/client/prediction/entities/character.cpp | 10 ++++++++++ src/game/editor/explanations.cpp | 4 +++- src/game/mapitems.cpp | 2 +- src/game/mapitems.h | 1 + src/game/server/entities/character.cpp | 10 ++++++++++ 6 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/game/client/components/mapimages.cpp b/src/game/client/components/mapimages.cpp index 3099472823c..4192c7ab7e3 100644 --- a/src/game/client/components/mapimages.cpp +++ b/src/game/client/components/mapimages.cpp @@ -210,7 +210,7 @@ static bool IsValidTile(int LayerType, bool EntitiesAreMasked, EMapImageModType if(EntitiesModType == MAP_IMAGE_MOD_TYPE_DDNET || EntitiesModType == MAP_IMAGE_MOD_TYPE_DDRACE) { - if(EntitiesModType == MAP_IMAGE_MOD_TYPE_DDNET || TileIndex != TILE_SPEED_BOOST_OLD || TileIndex != TILE_SPEED_BOOST) + if(EntitiesModType == MAP_IMAGE_MOD_TYPE_DDNET || TileIndex != TILE_SPEED_BOOST_OLD || TileIndex != TILE_SPEED_BOOST || TileIndex != TILE_SPEED_SLIDE) { if(LayerType == MAP_IMAGE_ENTITY_LAYER_TYPE_ALL_EXCEPT_SWITCH && !IsValidGameTile(TileIndex) && diff --git a/src/game/client/prediction/entities/character.cpp b/src/game/client/prediction/entities/character.cpp index afdc366cb86..0762415925d 100644 --- a/src/game/client/prediction/entities/character.cpp +++ b/src/game/client/prediction/entities/character.cpp @@ -716,6 +716,16 @@ void CCharacter::HandleSkippableTiles(int Index) } m_Core.m_Vel = ClampVel(m_MoveRestrictions, TempVel); } + else if(Type == TILE_SPEED_SLIDE) + { + TempVel = ClampVel(m_MoveRestrictions, TempVel); + float CurrentDirectionalSpeed = dot(Direction, TempVel); + if(CurrentDirectionalSpeed >= 0) + { + TempVel += Direction * -CurrentDirectionalSpeed; + } + m_Core.m_Vel = ClampVel(m_MoveRestrictions, TempVel); + } } } diff --git a/src/game/editor/explanations.cpp b/src/game/editor/explanations.cpp index 1684580ebe7..aed375ed27f 100644 --- a/src/game/editor/explanations.cpp +++ b/src/game/editor/explanations.cpp @@ -151,9 +151,11 @@ const char *CEditor::ExplainDDNet(int Tile, int Layer) if(Layer == LAYER_TELE) return "CHECKPOINT TELEPORT TO: Tees will appear here after touching TELEPORT CHECKPOINT with the same number and falling into CFROM TELEPORT."; break; - case TILE_TELECHECKIN: + case TILE_TELECHECKIN: // also TILE_SPEED_SLIDE if(Layer == LAYER_TELE) return "BLUE CHECKPOINT TELEPORT: Sends tees to CTO with the same number as the last touched TELEPORT CHECKPOINT. Speed and hook are kept."; + if(Layer == LAYER_SPEEDUP) + return "SLIDE: Allows the Tee to slide, can be angled."; break; case TILE_REFILL_JUMPS: if(Layer == LAYER_GAME || Layer == LAYER_FRONT) diff --git a/src/game/mapitems.cpp b/src/game/mapitems.cpp index f9b0420b9a2..78efdfce779 100644 --- a/src/game/mapitems.cpp +++ b/src/game/mapitems.cpp @@ -78,7 +78,7 @@ bool IsTeleTileNumberUsedAny(int Index) bool IsValidSpeedupTile(int Index) { - return Index == TILE_SPEED_BOOST_OLD || Index == TILE_SPEED_BOOST; + return Index == TILE_SPEED_BOOST_OLD || Index == TILE_SPEED_BOOST || Index == TILE_SPEED_SLIDE; } bool IsValidSwitchTile(int Index) diff --git a/src/game/mapitems.h b/src/game/mapitems.h index 215d5f6f3e3..d48cddf10d5 100644 --- a/src/game/mapitems.h +++ b/src/game/mapitems.h @@ -130,6 +130,7 @@ enum TILE_TELEOUT, TILE_SPEED_BOOST_OLD = 28, TILE_SPEED_BOOST, + TILE_SPEED_SLIDE = 31, TILE_TELECHECK = 29, TILE_TELECHECKOUT, TILE_TELECHECKIN, diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index b213f0fecc0..1088c1a1f3b 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -1492,6 +1492,16 @@ void CCharacter::HandleSkippableTiles(int Index) } m_Core.m_Vel = ClampVel(m_MoveRestrictions, TempVel); } + else if(Type == TILE_SPEED_SLIDE) + { + TempVel = ClampVel(m_MoveRestrictions, TempVel); + float CurrentDirectionalSpeed = dot(Direction, TempVel); + if(CurrentDirectionalSpeed >= 0) + { + TempVel += Direction * -CurrentDirectionalSpeed; + } + m_Core.m_Vel = ClampVel(m_MoveRestrictions, TempVel); + } } }