diff --git a/Crawler/Crawler.vcxproj b/Crawler/Crawler.vcxproj
index 85ddd133..6d0520c0 100644
--- a/Crawler/Crawler.vcxproj
+++ b/Crawler/Crawler.vcxproj
@@ -272,6 +272,7 @@
+
diff --git a/Crawler/Crawler.vcxproj.filters b/Crawler/Crawler.vcxproj.filters
index 2fd7327f..7546d61c 100644
--- a/Crawler/Crawler.vcxproj.filters
+++ b/Crawler/Crawler.vcxproj.filters
@@ -132,6 +132,9 @@
Header Files
+
+ Header Files
+
diff --git a/Crawler/Monster.h b/Crawler/Monster.h
index 6f541011..a5899388 100644
--- a/Crawler/Monster.h
+++ b/Crawler/Monster.h
@@ -125,11 +125,13 @@ public:
static void InitializeStrategies();
private:
struct STRATEGY{
+ static int _GetInt(Monster&m,std::string param,int strategyNumber,int index=0);
+ static float _GetFloat(Monster&m,std::string param,int strategyNumber,int index=0);
+ static std::string _GetString(Monster&m,std::string param,int strategyNumber,int index=0);
static void RUN_STRATEGY(Monster&m,float fElapsedTime);
-
- static void RUN_TOWARDS(Monster&m,float fElapsedTime);
- static void SHOOT_AFAR(Monster&m,float fElapsedTime);
- static void TURRET(Monster&m,float fElapsedTime);
+ static void RUN_TOWARDS(Monster&m,float fElapsedTime,int strategyNumber);
+ static void SHOOT_AFAR(Monster&m,float fElapsedTime,int strategyNumber);
+ static void TURRET(Monster&m,float fElapsedTime,int strategyNumber);
};
};
diff --git a/Crawler/MonsterStrategyHelpers.h b/Crawler/MonsterStrategyHelpers.h
new file mode 100644
index 00000000..e5d85cc9
--- /dev/null
+++ b/Crawler/MonsterStrategyHelpers.h
@@ -0,0 +1,7 @@
+#pragma once
+#define GetInt(param) _GetInt(m,param,strategyNumber)
+#define GetFloat(param) _GetFloat(m,param,strategyNumber)
+#define GetString(param) _GetString(m,param,strategyNumber)
+#define GetIntArr(param,ind) _GetInt(m,param,strategyNumber,ind)
+#define GetFloatArr(param,ind) _GetFloat(m,param,strategyNumber,ind)
+#define GetStringArr(param,ind) _GetString(m,param,strategyNumber,ind)
\ No newline at end of file
diff --git a/Crawler/RUN_STRATEGY.cpp b/Crawler/RUN_STRATEGY.cpp
index 83a47086..cdc05764 100644
--- a/Crawler/RUN_STRATEGY.cpp
+++ b/Crawler/RUN_STRATEGY.cpp
@@ -1,15 +1,41 @@
#include "Monster.h"
+#include "DEFINES.h"
+#include "olcUTIL_DataFile.h"
+
+INCLUDE_DATA
+
+int Monster::STRATEGY::_GetInt(Monster&m,std::string param,int strategyNumber,int index){
+ if(DATA["Monsters"][std::to_string(m.id)].HasProperty(param)){
+ return DATA["Monsters"][std::to_string(m.id)][param].GetInt(index);
+ } else {
+ return DATA["MonsterStrategy"][std::to_string(strategyNumber)][param].GetInt(index);
+ }
+}
+float Monster::STRATEGY::_GetFloat(Monster&m,std::string param,int strategyNumber,int index){
+ if(DATA["Monsters"][std::to_string(m.id)].HasProperty(param)){
+ return DATA["Monsters"][std::to_string(m.id)][param].GetReal(index);
+ } else {
+ return DATA["MonsterStrategy"][std::to_string(strategyNumber)][param].GetReal(index);
+ }
+}
+std::string Monster::STRATEGY::_GetString(Monster&m,std::string param,int strategyNumber,int index){
+ if(DATA["Monsters"][std::to_string(m.id)].HasProperty(param)){
+ return DATA["Monsters"][std::to_string(m.id)][param].GetString(index);
+ } else {
+ return DATA["MonsterStrategy"][std::to_string(strategyNumber)][param].GetString(index);
+ }
+}
void Monster::STRATEGY::RUN_STRATEGY(Monster&m,float fElapsedTime){
switch(m.strategy){
case 0:{//Run Towards
- Monster::STRATEGY::RUN_TOWARDS(m,fElapsedTime);
+ Monster::STRATEGY::RUN_TOWARDS(m,fElapsedTime,m.strategy);
}break;
case 1:{//Shoot Afar
- Monster::STRATEGY::SHOOT_AFAR(m,fElapsedTime);
+ Monster::STRATEGY::SHOOT_AFAR(m,fElapsedTime,m.strategy);
}break;
case 2:{//Turret.
- Monster::STRATEGY::TURRET(m,fElapsedTime);
+ Monster::STRATEGY::TURRET(m,fElapsedTime,m.strategy);
}break;
}
}
\ No newline at end of file
diff --git a/Crawler/RunTowards.cpp b/Crawler/RunTowards.cpp
index 7c677af0..b4aa3ef8 100644
--- a/Crawler/RunTowards.cpp
+++ b/Crawler/RunTowards.cpp
@@ -1,15 +1,23 @@
#include "Monster.h"
#include "DEFINES.h"
#include "Crawler.h"
+#include "MonsterStrategyHelpers.h"
INCLUDE_game
INCLUDE_MONSTER_DATA
-void Monster::STRATEGY::RUN_TOWARDS(Monster&m,float fElapsedTime){
+void Monster::STRATEGY::RUN_TOWARDS(Monster&m,float fElapsedTime,int strategyNumber){
m.targetAcquireTimer=std::max(0.f,m.targetAcquireTimer-fElapsedTime);
if(m.targetAcquireTimer==0){
- m.targetAcquireTimer=3;
- m.target=geom2d::line(m.pos,game->GetPlayer()->GetPos()).upoint(1.2);
+ m.targetAcquireTimer=GetFloat("WaitTime");
+
+ auto desiredTargetLine = geom2d::line(m.pos,game->GetPlayer()->GetPos());
+ if(desiredTargetLine.length()>=GetInt("MaxDistance")/100.f*24){
+ //Trim to max distance desired.
+ m.target=desiredTargetLine.rpoint(GetInt("MaxDistance")/100.f*24);
+ } else {
+ m.target=desiredTargetLine.upoint(1.2);
+ }
m.SetState(MOVE_TOWARDS);
m.hasHitPlayer=false;
}
diff --git a/Crawler/ShootAfar.cpp b/Crawler/ShootAfar.cpp
index 4d5a09ad..fb5250e0 100644
--- a/Crawler/ShootAfar.cpp
+++ b/Crawler/ShootAfar.cpp
@@ -1,11 +1,12 @@
#include "Monster.h"
#include "DEFINES.h"
#include "Crawler.h"
+#include "MonsterStrategyHelpers.h"
INCLUDE_BULLET_LIST
INCLUDE_game
-void Monster::STRATEGY::SHOOT_AFAR(Monster&m,float fElapsedTime){
+void Monster::STRATEGY::SHOOT_AFAR(Monster&m,float fElapsedTime,int strategyNumber){
m.targetAcquireTimer=std::max(0.f,m.targetAcquireTimer-fElapsedTime);
m.attackCooldownTimer=std::max(0.f,m.attackCooldownTimer-fElapsedTime);
if(m.queueShotTimer>0){
@@ -13,14 +14,14 @@ void Monster::STRATEGY::SHOOT_AFAR(Monster&m,float fElapsedTime){
if(m.queueShotTimer<0){
m.queueShotTimer=0;
{
- BULLET_LIST.push_back(std::make_unique(Bullet(m.pos + vf2d{ 0,-4 }, geom2d::line(m.pos + vf2d{ 0,-4 }, game->GetPlayer()->GetPos()).vector().norm() * 24 * 3.f, 2, m.GetAttack(),m.upperLevel,false, { 75 / 2,162 / 2,225 / 2 })));
+ BULLET_LIST.push_back(std::make_unique(Bullet(m.pos + vf2d{ 0,-4 }, geom2d::line(m.pos + vf2d{ 0,-4 }, game->GetPlayer()->GetPos()).vector().norm() * 24 * GetInt("BulletSpeed")/100.f, 24.f*GetInt("BulletSize")/100.f, m.GetAttack(),m.upperLevel,false, { uint8_t(GetIntArr("BulletColor",0)),uint8_t(GetIntArr("BulletColor",1)),uint8_t(GetIntArr("BulletColor",2)),uint8_t(GetIntArr("BulletColor",3) )})));
}
}
}
geom2d::line line(m.pos,game->GetPlayer()->GetPos());
if(m.targetAcquireTimer==0&&m.queueShotTimer==0){
m.targetAcquireTimer=1;
- if(line.length()<24*6){
+ if(line.length()<24.f*GetInt("Range")/100.f){
m.target=line.upoint(-1.2);
if(m.canMove){
m.SetState(MOVE_AWAY);
@@ -28,7 +29,7 @@ void Monster::STRATEGY::SHOOT_AFAR(Monster&m,float fElapsedTime){
m.SetState(NORMAL);
}
} else
- if(line.length()>24*7){
+ if(line.length()>24.f*GetInt("CloseInRange")/100.0f){
m.target=line.upoint(1.2);
m.SetState(MOVE_TOWARDS);
} else {
@@ -50,7 +51,7 @@ void Monster::STRATEGY::SHOOT_AFAR(Monster&m,float fElapsedTime){
if(!pathfindingDecision){
m.StartPathfinding(2.5);
}else
- if(line.length()<=24*7){
+ if(line.length()<=24.f*GetInt("CloseInRange")/100.0f){
m.SetState(NORMAL);
}
if(moveTowardsLine.vector().x>0){
@@ -71,7 +72,7 @@ void Monster::STRATEGY::SHOOT_AFAR(Monster&m,float fElapsedTime){
if(!pathfindingDecision){
m.StartPathfinding(2.5);
}else
- if(line.length()>=24*6){
+ if(line.length()>=24.f*GetInt("Range")/100.f){
m.SetState(NORMAL);
}
if(moveTowardsLine.vector().x>0){
@@ -86,8 +87,8 @@ void Monster::STRATEGY::SHOOT_AFAR(Monster&m,float fElapsedTime){
}break;
default:{
if(m.attackCooldownTimer==0){
- m.attackCooldownTimer=1;
- m.queueShotTimer=0.7;
+ m.attackCooldownTimer=GetFloat("ShootingSpeed");
+ m.queueShotTimer=std::min(m.attackCooldownTimer-0.001,0.7);
m.PerformShootAnimation();
}
}
diff --git a/Crawler/Turret.cpp b/Crawler/Turret.cpp
index 06e53cd0..ff180bee 100644
--- a/Crawler/Turret.cpp
+++ b/Crawler/Turret.cpp
@@ -1,5 +1,6 @@
#include "Monster.h"
+#include "MonsterStrategyHelpers.h"
-void Monster::STRATEGY::TURRET(Monster&m,float fElapsedTime){
+void Monster::STRATEGY::TURRET(Monster&m,float fElapsedTime,int strategyNumber){
}
\ No newline at end of file
diff --git a/Crawler/Version.h b/Crawler/Version.h
index 33c95be1..d4ce2cc7 100644
--- a/Crawler/Version.h
+++ b/Crawler/Version.h
@@ -2,7 +2,7 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 0
-#define VERSION_BUILD 992
+#define VERSION_BUILD 999
#define stringify(a) stringify_(a)
#define stringify_(a) #a
diff --git a/Crawler/assets/config/MonsterStrategies.txt b/Crawler/assets/config/MonsterStrategies.txt
index 686cc0d6..5bf889bf 100644
--- a/Crawler/assets/config/MonsterStrategies.txt
+++ b/Crawler/assets/config/MonsterStrategies.txt
@@ -40,7 +40,7 @@ MonsterStrategy
{
Name = Run Towards
# How long to wait before attempting to path again.
- WaitTime = 2
+ WaitTime = 3
# How far the monster will travel before reassessing for a new path.
MaxDistance = 999999
}
@@ -48,12 +48,14 @@ MonsterStrategy
{
Name = Shoot Afar
# How far away the monster attempts to distance itself from the player
- Range = 800
+ Range = 700
+ # If the player is farther than this distance, close in on them.
+ CloseInRange = 850
# How often the enemy shoots.
ShootingSpeed = 1
- BulletSpeed = 100
- BulletSize = 100
- BulletColor = 0, 0, 255, 255
+ BulletSpeed = 300
+ BulletSize = 8
+ BulletColor = 37, 131, 112, 255
}
2
{
diff --git a/Crawler/assets/config/Monsters.txt b/Crawler/assets/config/Monsters.txt
index bf287983..20852ae9 100644
--- a/Crawler/assets/config/Monsters.txt
+++ b/Crawler/assets/config/Monsters.txt
@@ -44,7 +44,7 @@ Monsters
# Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse)
IdleAnimation = 10, 0.1, Repeat
JumpAnimation = 10, 0.06, Repeat
- ShootAnimation = 10, 0.1, OneShot
+ ShootAnimation = 10, 0.1, Repeat
DeathAnimation = 10, 0.1, OneShot
#Additional custom animations go down below. Start with ANIMATION[0]