diff --git a/Adventures in Lestoria/Adventures in Lestoria.vcxproj b/Adventures in Lestoria/Adventures in Lestoria.vcxproj
index 3e602540..ed89c350 100644
--- a/Adventures in Lestoria/Adventures in Lestoria.vcxproj
+++ b/Adventures in Lestoria/Adventures in Lestoria.vcxproj
@@ -309,6 +309,10 @@
+
+
+
+
@@ -700,6 +704,7 @@
+
diff --git a/Adventures in Lestoria/Boar.cpp b/Adventures in Lestoria/Boar.cpp
index 41615fce..295ddd6a 100644
--- a/Adventures in Lestoria/Boar.cpp
+++ b/Adventures in Lestoria/Boar.cpp
@@ -59,7 +59,7 @@ void Monster::STRATEGY::BOAR(Monster&m,float fElapsedTime,std::string strategy){
switch(m.phase){
case PhaseName::MOVE:{
- float distToPlayer=geom2d::line(m.GetPos(),game->GetPlayer()->GetPos()).length();
+ float distToPlayer=m.GetDistanceFrom(game->GetPlayer()->GetPos());
if(m.canMove&&distToPlayer>=ConfigInt("Closein Range")/100.f*24){
m.RemoveBuff(BuffType::SELF_INFLICTED_SLOWDOWN);
RUN_TOWARDS(m,fElapsedTime,"Run Towards");
diff --git a/Adventures in Lestoria/Direction.h b/Adventures in Lestoria/Direction.h
new file mode 100644
index 00000000..c6c3d4c8
--- /dev/null
+++ b/Adventures in Lestoria/Direction.h
@@ -0,0 +1,45 @@
+#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
+
+enum class Direction{
+ NORTH,
+ EAST,
+ SOUTH,
+ WEST
+};
\ No newline at end of file
diff --git a/Adventures in Lestoria/Goblin_Dagger.cpp b/Adventures in Lestoria/Goblin_Dagger.cpp
new file mode 100644
index 00000000..84eeb055
--- /dev/null
+++ b/Adventures in Lestoria/Goblin_Dagger.cpp
@@ -0,0 +1,123 @@
+#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 "AdventuresInLestoria.h"
+#include "DEFINES.h"
+#include "Monster.h"
+#include "MonsterStrategyHelpers.h"
+/*
+Attack Strategie:
+Runs infront of player,
+short preparation for attack (~0.3 - 0.5 secs depending what looks better animation wise)
+and either slashes with the dagger or stabs with it.
+1 sec of idle before loop repeats
+*/
+
+INCLUDE_game
+INCLUDE_ANIMATION_DATA
+using A=Attribute;
+
+void Monster::STRATEGY::GOBLIN_DAGGER(Monster&m,float fElapsedTime,std::string strategy){
+ enum PhaseName{
+ MOVE,
+ WINDUP,
+ RECOVERY,
+ };
+
+ enum AttackType{
+ STAB,
+ SLASH
+ };
+
+ enum class ANIMATION_OFFSET{
+ STAB_WINDUP_ANIMATION=0,
+ STAB_ANIMATION=4,
+ SLASH_WINDUP_ANIMATION=8,
+ SLASH_ANIMATION=12,
+ IDLE_ANIMATION=16,
+ };
+
+ auto SetFacingAnimation=[&](ANIMATION_OFFSET animation,vf2d target){
+ m.PerformOtherAnimation(int(animation)+int(m.GetFacingDirectionToTarget(target)));
+ };
+
+ using enum ANIMATION_OFFSET;
+ switch(m.phase){
+ case MOVE:{
+ float distToPlayer=m.GetDistanceFrom(game->GetPlayer()->GetPos());
+ if(distToPlayer>ConfigFloat("Attack Spacing")/100.f*24){
+ RUN_TOWARDS(m,fElapsedTime,"Run Towards");
+ }else{
+ m.phase=WINDUP;
+ m.I(A::ATTACK_TYPE)=STAB; //TODO: Choose randomly between stab or slash.
+ m.F(A::CASTING_TIMER)=ConfigFloat("Stab Windup Time");
+ switch(m.I(A::ATTACK_TYPE)){
+ case STAB:{
+ SetFacingAnimation(STAB_WINDUP_ANIMATION,game->GetPlayer()->GetPos());
+ }break;
+ case SLASH:{
+ SetFacingAnimation(SLASH_WINDUP_ANIMATION,game->GetPlayer()->GetPos());
+ }break;
+ default:ERR(std::format("WARNING! Invalid Attack type {} provided. THIS SHOULD NOT BE HAPPENING!",m.I(A::ATTACK_TYPE)));
+ }
+ }
+ }break;
+ case WINDUP:{
+ m.F(A::CASTING_TIMER)-=fElapsedTime;
+ if(m.F(A::CASTING_TIMER)<=0){
+ m.phase=RECOVERY;
+ switch(m.I(A::ATTACK_TYPE)){
+ case STAB:{
+ SetFacingAnimation(STAB_ANIMATION,game->GetPlayer()->GetPos());
+ }break;
+ case SLASH:{
+ SetFacingAnimation(SLASH_ANIMATION,game->GetPlayer()->GetPos());
+ }break;
+ default:ERR(std::format("WARNING! Invalid Attack type {} provided. THIS SHOULD NOT BE HAPPENING!",m.I(A::ATTACK_TYPE)));
+ }
+ m.F(A::CASTING_TIMER)=m.GetCurrentAnimation().GetTotalAnimationDuration();
+ m.F(A::RECOVERY_TIME)=ConfigFloat("Attack Recovery Time");
+ }
+ }break;
+ case RECOVERY:{
+ m.F(A::CASTING_TIMER)-=fElapsedTime;
+ m.F(A::RECOVERY_TIME)-=fElapsedTime;
+ if(m.F(A::CASTING_TIMER)<=0){SetFacingAnimation(IDLE_ANIMATION,game->GetPlayer()->GetPos());}
+ if(m.F(A::RECOVERY_TIME)<=0)m.phase=MOVE;
+ }break;
+ }
+}
\ No newline at end of file
diff --git a/Adventures in Lestoria/Monster.cpp b/Adventures in Lestoria/Monster.cpp
index 264833ce..04a8a252 100644
--- a/Adventures in Lestoria/Monster.cpp
+++ b/Adventures in Lestoria/Monster.cpp
@@ -871,4 +871,19 @@ const bool Monster::HasLineOfSight(vf2d targetPos)const{
losLineMarker+=game->GetCurrentMapData().TileSize.x/2.f;
}
return hasLoS;
+}
+
+const float Monster::GetDistanceFrom(vf2d target)const{
+ return geom2d::line(GetPos(),target).length();
+}
+
+const Direction Monster::GetFacingDirectionToTarget(vf2d target)const{
+ float targetDirection=util::angleTo(GetPos(),target);
+ LOG(targetDirection<-PI/4)return Direction::EAST;
+ else if(targetDirection>=3*PI/4||targetDirection<-3*PI/4)return Direction::WEST;
+ else if(targetDirection<=3*PI/4&&targetDirection>PI/4)return Direction::SOUTH;
+ else if(targetDirection>=-3*PI/4&&targetDirection<-PI/4)return Direction::NORTH;
+
+ ERR(std::format("WARNING! Target direction {} did not result in a proper facing direction!! THIS SHOULD NOT BE HAPPENING!",targetDirection));
}
\ No newline at end of file
diff --git a/Adventures in Lestoria/Monster.h b/Adventures in Lestoria/Monster.h
index 6e5b05a2..84c89ff9 100644
--- a/Adventures in Lestoria/Monster.h
+++ b/Adventures in Lestoria/Monster.h
@@ -47,6 +47,7 @@ All rights reserved.
#include "GameEvent.h"
#include "TMXParser.h"
#include "MonsterData.h"
+#include "Direction.h"
INCLUDE_ITEM_DATA
@@ -147,6 +148,8 @@ public:
const float GetCollisionDamage()const;
const bool IsNPC()const;
const bool HasLineOfSight(vf2d targetPos)const;
+ const float GetDistanceFrom(vf2d target)const;
+ const Direction GetFacingDirectionToTarget(vf2d target)const;
private:
std::string name;
vf2d pos;
@@ -230,6 +233,7 @@ private:
static void URSULE(Monster&m,float fElapsedTime,std::string strategy);
static void NPC(Monster&m,float fElapsedTime,std::string strategy);
static void BOAR(Monster&m,float fElapsedTime,std::string strategy);
+ static void GOBLIN_DAGGER(Monster&m,float fElapsedTime,std::string strategy);
};
bool bumpedIntoTerrain=false; //Gets set to true before a strategy executes if the monster runs into some terrain on this frame.
bool attackedByPlayer=false; //Gets set to true before a strategy executes if the monster has been attacked by the player.
diff --git a/Adventures in Lestoria/MonsterAttribute.h b/Adventures in Lestoria/MonsterAttribute.h
index dd91afc2..4bb674aa 100644
--- a/Adventures in Lestoria/MonsterAttribute.h
+++ b/Adventures in Lestoria/MonsterAttribute.h
@@ -107,4 +107,5 @@ enum class Attribute{
LAST_JUMP_TIMER,
INITIALIZED,
JUMP_MOVE_TO_TARGET_TIMER,
+ ATTACK_TYPE,
};
\ No newline at end of file
diff --git a/Adventures in Lestoria/RUN_STRATEGY.cpp b/Adventures in Lestoria/RUN_STRATEGY.cpp
index 6eb23c36..f361fd89 100644
--- a/Adventures in Lestoria/RUN_STRATEGY.cpp
+++ b/Adventures in Lestoria/RUN_STRATEGY.cpp
@@ -54,6 +54,7 @@ void Monster::InitializeStrategies(){
STRATEGY_DATA.insert("Ursule",Monster::STRATEGY::URSULE);
STRATEGY_DATA.insert("NPC",Monster::STRATEGY::NPC);
STRATEGY_DATA.insert("Boar",Monster::STRATEGY::BOAR);
+ STRATEGY_DATA.insert("Goblin Dagger",Monster::STRATEGY::GOBLIN_DAGGER);
STRATEGY_DATA.SetInitialized();
}
diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h
index d70bd58f..013bcfe2 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 2
#define VERSION_PATCH 0
-#define VERSION_BUILD 9021
+#define VERSION_BUILD 9027
#define stringify(a) stringify_(a)
#define stringify_(a) #a
diff --git a/Adventures in Lestoria/assets/Campaigns/2_1.tmx b/Adventures in Lestoria/assets/Campaigns/2_1.tmx
index 509003e0..7cf5f3ac 100644
--- a/Adventures in Lestoria/assets/Campaigns/2_1.tmx
+++ b/Adventures in Lestoria/assets/Campaigns/2_1.tmx
@@ -1,5 +1,5 @@
-