From 51e838de24944073d6a95e0547f2e0b2caea61c4 Mon Sep 17 00:00:00 2001
From: sigonasr2 <sigonasr2@gmail.com>
Date: Sun, 28 Jan 2024 21:32:49 -0600
Subject: [PATCH] Items should be unuseable in the hub area. Reset ability
 cooldowns at the start of a stage.

---
 Adventures in Lestoria/Ability.h                | 2 ++
 Adventures in Lestoria/AdventuresInLestoria.cpp | 7 +++++++
 Adventures in Lestoria/Player.cpp               | 4 +++-
 Adventures in Lestoria/TODO.txt                 | 2 ++
 Adventures in Lestoria/Version.h                | 2 +-
 5 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/Adventures in Lestoria/Ability.h b/Adventures in Lestoria/Ability.h
index 254d1063..3fba8bb6 100644
--- a/Adventures in Lestoria/Ability.h	
+++ b/Adventures in Lestoria/Ability.h	
@@ -66,6 +66,8 @@ struct Ability{
 	bool canCancelCast=false;
 	InputGroup*input;
 	std::string icon;
+	//If set to true, this ability is tied to using an item.
+	bool itemAbility=false;
 	//If set to true, this ability instead activates immediately when a cast occurs. When the cast finishes, nothing happens instead.
 	bool actionPerformedDuringCast=false;
 	bool waitForRelease=false;
diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp
index 736132b3..40127d58 100644
--- a/Adventures in Lestoria/AdventuresInLestoria.cpp	
+++ b/Adventures in Lestoria/AdventuresInLestoria.cpp	
@@ -1981,6 +1981,12 @@ void AiL::LoadLevel(MapName map){
 			counter++;
 		}
 	#pragma endregion
+
+	player->GetAbility1().cooldown=0.f;
+	player->GetAbility2().cooldown=0.f;
+	player->GetAbility3().cooldown=0.f;
+	player->GetAbility4().cooldown=0.f;
+	player->GetRightClickAbility().cooldown=0.f;
 	
 	player->upperLevel=false; //Assume player starts on lower level.
 	player->ForceSetPos(MAP_DATA[map].MapData.playerSpawnLocation); //Normal set pos does one axis and then the other, so this will make sure that we actually end up at the right spot and ignore collision rules.
@@ -2745,6 +2751,7 @@ void AiL::SetLoadoutItem(int slot,std::string itemName){
 		}
 		Ability itemAbility{itemName,"","","Item.Item Cooldown Time"_F,0,inputGroup,"items/"+itemName+".png",VERY_DARK_RED,DARK_RED,PrecastData{GetLoadoutItem(slot).lock()->CastTime(),0,0},true};
 		itemAbility.actionPerformedDuringCast=GetLoadoutItem(slot).lock()->UseDuringCast();
+		itemAbility.itemAbility=true;
 
 		switch(slot){
 			case 0:{
diff --git a/Adventures in Lestoria/Player.cpp b/Adventures in Lestoria/Player.cpp
index 86cc5d34..02ea3164 100644
--- a/Adventures in Lestoria/Player.cpp	
+++ b/Adventures in Lestoria/Player.cpp	
@@ -672,7 +672,9 @@ bool Player::CanAct(){
 }
 
 bool Player::CanAct(Ability&ability){
-	return knockUpTimer==0&&!ability.waitForRelease&&(ability.canCancelCast||state!=State::CASTING)&&state!=State::ANIMATION_LOCK&&(GameState::STATE==GameState::states[States::GAME_RUN]||GameState::STATE==GameState::states[States::GAME_HUB]);
+	return knockUpTimer==0&&!ability.waitForRelease&&(ability.canCancelCast||state!=State::CASTING)&&state!=State::ANIMATION_LOCK&&
+		(GameState::STATE==GameState::states[States::GAME_RUN]
+		||GameState::STATE==GameState::states[States::GAME_HUB]&&!ability.itemAbility);
 }
 
 bool Player::HasIframes(){
diff --git a/Adventures in Lestoria/TODO.txt b/Adventures in Lestoria/TODO.txt
index b4fdd5e1..c83f0df1 100644
--- a/Adventures in Lestoria/TODO.txt	
+++ b/Adventures in Lestoria/TODO.txt	
@@ -27,6 +27,8 @@ Settings Menu
 
 - No equip sounds for weapons?
 
+- When setting loadout items while loading the game it should highlight the correct item in the consumables inventory as well.
+
 January 31st
 ============
 
diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h
index c41e6c1f..5e034daf 100644
--- a/Adventures in Lestoria/Version.h	
+++ b/Adventures in Lestoria/Version.h	
@@ -39,7 +39,7 @@ All rights reserved.
 #define VERSION_MAJOR 0
 #define VERSION_MINOR 3
 #define VERSION_PATCH 0
-#define VERSION_BUILD 6515
+#define VERSION_BUILD 6517
 
 #define stringify(a) stringify_(a)
 #define stringify_(a) #a