From a6002aed8ad694c8588b9577e97b193b4e71c26e Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Thu, 3 Apr 2025 16:15:32 -0400 Subject: [PATCH] Add in Arena Game State. Add in a virtual override function for game states to specify if the player is active in certain states. Release Build 12140. --- .../Adventures in Lestoria.vcxproj | 2 + .../Adventures in Lestoria.vcxproj.filters | 6 ++ Adventures in Lestoria/GameState.cpp | 2 + Adventures in Lestoria/GameState.h | 2 + Adventures in Lestoria/Player.cpp | 2 +- Adventures in Lestoria/State_Arena.cpp | 87 +++++++++++++++++++ Adventures in Lestoria/State_Arena.h | 49 +++++++++++ Adventures in Lestoria/State_Death.h | 1 + Adventures in Lestoria/State_Dialog.h | 1 + Adventures in Lestoria/State_GameRun.h | 1 + Adventures in Lestoria/State_LevelComplete.h | 1 + Adventures in Lestoria/State_MainMenu.h | 1 + Adventures in Lestoria/State_OverworldMap.h | 1 + Adventures in Lestoria/State_Story.h | 1 + Adventures in Lestoria/Version.h | 2 +- 15 files changed, 157 insertions(+), 2 deletions(-) create mode 100644 Adventures in Lestoria/State_Arena.cpp create mode 100644 Adventures in Lestoria/State_Arena.h diff --git a/Adventures in Lestoria/Adventures in Lestoria.vcxproj b/Adventures in Lestoria/Adventures in Lestoria.vcxproj index 33257258..e02d616e 100644 --- a/Adventures in Lestoria/Adventures in Lestoria.vcxproj +++ b/Adventures in Lestoria/Adventures in Lestoria.vcxproj @@ -661,6 +661,7 @@ + @@ -1143,6 +1144,7 @@ + diff --git a/Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters b/Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters index 9dcc64d0..438052ff 100644 --- a/Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters +++ b/Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters @@ -714,6 +714,9 @@ Header Files\Utils + + Header Files\State + @@ -1316,6 +1319,9 @@ Source Files\Effects + + Source Files\Game States + diff --git a/Adventures in Lestoria/GameState.cpp b/Adventures in Lestoria/GameState.cpp index 1f824c30..fc688b58 100644 --- a/Adventures in Lestoria/GameState.cpp +++ b/Adventures in Lestoria/GameState.cpp @@ -44,6 +44,7 @@ All rights reserved. #include "State_GameHub.h" #include "State_Death.h" #include "State_Dialog.h" +#include "State_Arena.h" INCLUDE_game @@ -60,6 +61,7 @@ void GameState::Initialize(){ NEW_STATE(States::GAME_HUB,State_GameHub); NEW_STATE(States::DEATH,State_Death); NEW_STATE(States::DIALOG,State_Dialog); + NEW_STATE(States::ARENA,State_Arena); } void GameState::_ChangeState(States::State newState){ diff --git a/Adventures in Lestoria/GameState.h b/Adventures in Lestoria/GameState.h index cad8538c..e1283c44 100644 --- a/Adventures in Lestoria/GameState.h +++ b/Adventures in Lestoria/GameState.h @@ -54,6 +54,7 @@ namespace States{ DIALOG, KEYBIND, DEATH, + ARENA, }; }; @@ -78,5 +79,6 @@ public: virtual void GetAnyMouseRelease(int32_t mouseButton); static void ChangeState(States::State newState,float fadeOutDuration=0,uint8_t mosaicEffect=1U); virtual void OnLevelLoad()=0; + virtual bool IsPlayerControlledGameplayState()=0; //Return true if this state allows the player to be controlled. Returns false for any other type of state. static States::State GetCurrentState(); }; \ No newline at end of file diff --git a/Adventures in Lestoria/Player.cpp b/Adventures in Lestoria/Player.cpp index ea90a3f8..064f0857 100644 --- a/Adventures in Lestoria/Player.cpp +++ b/Adventures in Lestoria/Player.cpp @@ -892,7 +892,7 @@ bool Player::CanAct(){ const bool Player::CanAct(const Ability&ability){ return knockUpTimer==0&&!ability.waitForRelease&&(ability.canCancelCast||state!=State::CASTING)&&state!=State::ANIMATION_LOCK&&state!=State::DEADLYDASH&&state!=State::RETREAT&& - (GameState::STATE==GameState::states[States::GAME_RUN]||GameState::STATE==GameState::states[States::GAME_HUB]); + GameState::STATE->IsPlayerControlledGameplayState(); } bool Player::HasIframes(){ diff --git a/Adventures in Lestoria/State_Arena.cpp b/Adventures in Lestoria/State_Arena.cpp new file mode 100644 index 00000000..6e351531 --- /dev/null +++ b/Adventures in Lestoria/State_Arena.cpp @@ -0,0 +1,87 @@ +#pragma region License +/* +License (OLC-3) +~~~~~~~~~~~~~~~ + +Copyright 2024 Joshua Sigona + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions or derivations of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions or derivative works in binary form must reproduce the above +copyright notice. This list of conditions and the following disclaimer must be +reproduced in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may +be used to endorse or promote products derived from this software without specific +prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + +Portions of this software are copyright © 2024 The FreeType +Project (www.freetype.org). Please see LICENSE_FT.txt for more information. +All rights reserved. +*/ +#pragma endregion +#include "State_Arena.h" +#include "AdventuresInLestoria.h" +#include "DEFINES.h" +#include "Menu.h" +#include "ItemDrop.h" +#include "VisualNovel.h" +#include "State_OverworldMap.h" +#include "GameEvent.h" +#include "SaveFile.h" +#include "MenuComponent.h" +#include "Unlock.h" +#include "Tutorial.h" + +INCLUDE_MONSTER_LIST +INCLUDE_game + +void State_Arena::OnStateChange(GameState*prevState){ + if(Menu::IsMenuOpen()){ + Menu::CloseAllMenus(); + } + + if(Unlock::IsUnlocked("STORY_1_3")&&!Tutorial::TaskIsComplete(TutorialTaskName::CLEAR_DEMO)){ + Tutorial::SetNextTask(TutorialTaskName::CLEAR_DEMO); + } + else + if(Unlock::IsUnlocked("STORY_1_2")&&!Tutorial::TaskIsComplete(TutorialTaskName::BLACKSMITH)){ + Tutorial::SetNextTask(TutorialTaskName::BLACKSMITH); + } + else + if(Unlock::IsUnlocked("BOSS_2_B")&&!Tutorial::TaskIsComplete(TutorialTaskName::ARTIFICER_INTRO)){ + Tutorial::SetNextTask(TutorialTaskName::ARTIFICER_INTRO); + } + + SaveFile::SaveGame(); + + game->GetPlayer()->SetState(State::NORMAL); + + game->LoadLevel("HUB"); +} +void State_Arena::OnLevelLoad(){ + game->UpdateDiscordStatus("Eternal Arena",game->GetPlayer()->GetClassName()); +} +void State_Arena::OnUserUpdate(AiL*game){ + State_GameRun::OnUserUpdate(game); + + game->ClearTimedOutGarbage(); +} +void State_Arena::Draw(AiL*game){ + State_GameRun::Draw(game); +} \ No newline at end of file diff --git a/Adventures in Lestoria/State_Arena.h b/Adventures in Lestoria/State_Arena.h new file mode 100644 index 00000000..8dcc68e2 --- /dev/null +++ b/Adventures in Lestoria/State_Arena.h @@ -0,0 +1,49 @@ +#pragma region License +/* +License (OLC-3) +~~~~~~~~~~~~~~~ + +Copyright 2024 Joshua Sigona + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions or derivations of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions or derivative works in binary form must reproduce the above +copyright notice. This list of conditions and the following disclaimer must be +reproduced in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may +be used to endorse or promote products derived from this software without specific +prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + +Portions of this software are copyright © 2024 The FreeType +Project (www.freetype.org). Please see LICENSE_FT.txt for more information. +All rights reserved. +*/ +#pragma endregion +#pragma once +#include "State_GameRun.h" +#include "olcPGEX_ViewPort.h" + +class State_Arena:public State_GameRun{ + ViewPort port; + Renderable r; + virtual void OnStateChange(GameState*prevState)override final; + virtual void OnUserUpdate(AiL*game)override final; + virtual void Draw(AiL*game)override final; + virtual void OnLevelLoad()override final; +}; \ No newline at end of file diff --git a/Adventures in Lestoria/State_Death.h b/Adventures in Lestoria/State_Death.h index e5a5c32a..dbbb52f7 100644 --- a/Adventures in Lestoria/State_Death.h +++ b/Adventures in Lestoria/State_Death.h @@ -48,4 +48,5 @@ protected: virtual void OnUserUpdate(AiL*game)override; virtual void Draw(AiL*game)override; virtual void OnLevelLoad()override; + inline virtual bool IsPlayerControlledGameplayState()override final{return false;} }; \ No newline at end of file diff --git a/Adventures in Lestoria/State_Dialog.h b/Adventures in Lestoria/State_Dialog.h index 9fbf78b4..1e653489 100644 --- a/Adventures in Lestoria/State_Dialog.h +++ b/Adventures in Lestoria/State_Dialog.h @@ -43,4 +43,5 @@ class State_Dialog:public GameState { virtual void OnUserUpdate(AiL*game)override final; virtual void Draw(AiL*game)override final; virtual void OnLevelLoad()override final; + inline virtual bool IsPlayerControlledGameplayState()override final{return false;} }; \ No newline at end of file diff --git a/Adventures in Lestoria/State_GameRun.h b/Adventures in Lestoria/State_GameRun.h index 63034079..a0df40bc 100644 --- a/Adventures in Lestoria/State_GameRun.h +++ b/Adventures in Lestoria/State_GameRun.h @@ -47,4 +47,5 @@ protected: virtual void OnUserUpdate(AiL*game)override; virtual void Draw(AiL*game)override; virtual void OnLevelLoad()override; + inline virtual bool IsPlayerControlledGameplayState()override final{return true;} }; \ No newline at end of file diff --git a/Adventures in Lestoria/State_LevelComplete.h b/Adventures in Lestoria/State_LevelComplete.h index a2c3624b..2dd73873 100644 --- a/Adventures in Lestoria/State_LevelComplete.h +++ b/Adventures in Lestoria/State_LevelComplete.h @@ -50,6 +50,7 @@ class State_LevelComplete:public GameState{ virtual void Draw(AiL*game)override final; virtual void DrawOverlay(AiL*game)override final; virtual void OnLevelLoad()override final; + inline virtual bool IsPlayerControlledGameplayState()override final{return false;} public: static void TurnOffXPSound(); }; \ No newline at end of file diff --git a/Adventures in Lestoria/State_MainMenu.h b/Adventures in Lestoria/State_MainMenu.h index 8bccbd4f..e2877818 100644 --- a/Adventures in Lestoria/State_MainMenu.h +++ b/Adventures in Lestoria/State_MainMenu.h @@ -43,6 +43,7 @@ class State_MainMenu:public GameState{ virtual void OnUserUpdate(AiL*game)override final; virtual void Draw(AiL*game)override final; virtual void OnLevelLoad()override final; + inline virtual bool IsPlayerControlledGameplayState()override final{return false;} const ZoneData&ChooseRandomFocusArea(); vf2d cameraMoveDir; diff --git a/Adventures in Lestoria/State_OverworldMap.h b/Adventures in Lestoria/State_OverworldMap.h index 85288819..c570007e 100644 --- a/Adventures in Lestoria/State_OverworldMap.h +++ b/Adventures in Lestoria/State_OverworldMap.h @@ -63,6 +63,7 @@ public: virtual void Draw(AiL*game)override final; virtual void DrawOverlay(AiL*game)override final; virtual void OnLevelLoad()override final; + inline virtual bool IsPlayerControlledGameplayState()override final{return false;} static void StartLevel(); static void UpdateCurrentConnectionPoint(const ConnectionPoint&connection); }; \ No newline at end of file diff --git a/Adventures in Lestoria/State_Story.h b/Adventures in Lestoria/State_Story.h index b368922c..c52c76b5 100644 --- a/Adventures in Lestoria/State_Story.h +++ b/Adventures in Lestoria/State_Story.h @@ -43,4 +43,5 @@ class State_Story:public GameState{ virtual void OnUserUpdate(AiL*game)override final; virtual void Draw(AiL*game)override final; virtual void OnLevelLoad()override final; + inline virtual bool IsPlayerControlledGameplayState()override final{return false;} }; \ No newline at end of file diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index b52a1dd4..5a43dba9 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 1 #define VERSION_MINOR 3 #define VERSION_PATCH 0 -#define VERSION_BUILD 12137 +#define VERSION_BUILD 12140 #define stringify(a) stringify_(a) #define stringify_(a) #a