Fix Warrior slowdown cancel bug (#16). Added debug configuration options to display collision and hidden player info on-screen. Release Build 935.

pull/28/head
sigonasr2 1 year ago
parent b4692769a0
commit e96514e0d4
  1. 1
      Crawler/Buff.h
  2. 13
      Crawler/Crawler.cpp
  3. 15
      Crawler/Crawler.vcxproj
  4. 32
      Crawler/Monster.cpp
  5. 2
      Crawler/Monster.h
  6. 33
      Crawler/Player.cpp
  7. 4
      Crawler/Player.h
  8. 2
      Crawler/Version.h
  9. 3
      Crawler/Warrior.cpp
  10. 2
      Crawler/assets/config/classes/Warrior.txt
  11. 8
      Crawler/assets/config/configuration.txt
  12. BIN
      x64/Release Desktop/Crawler.exe

@ -3,6 +3,7 @@ enum BuffType{
ATTACK_UP,
DAMAGE_REDUCTION,
SLOWDOWN,
BLOCK_SLOWDOWN,
};
struct Buff{

@ -18,9 +18,6 @@
INCLUDE_EMITTER_LIST
//#define DEBUG_COLLISIONS //Shows collision hitboxes.
//#define DEBUG_POS //Shows player position.
//192x192
vi2d WINDOW_SIZE={24*15,24*10};
std::map<AnimationState,Animate2D::FrameSequence>ANIMATION_DATA;
@ -565,13 +562,13 @@ void Crawler::RenderWorld(float fElapsedTime){
if(!IsForegroundTile(tileSheet,tileSheetIndex)&&!IsUpperForegroundTile(tileSheet,tileSheetIndex)){
view.DrawPartialDecal(vi2d{x,y}*24,{24,24},tileSheet.tileset.tileset->Decal(),vi2d{tileSheetX,tileSheetY}*24,{24,24});
}
#ifdef DEBUG_COLLISIONS
if("debug_collision_boxes"_I){
if(tileSheet.tileset.collision.find(tileSheetIndex)!=tileSheet.tileset.collision.end()){
geom2d::rect<int>collision=tileSheet.tileset.collision[tileSheetIndex].collision;
view.FillRectDecal(vi2d{x,y}*24+collision.pos,collision.size,{0,0,0,128});
view.DrawRectDecal(vi2d{x,y}*24+collision.pos,collision.size,GREY);
}
#endif
}
}
}
}
@ -824,10 +821,10 @@ void Crawler::RenderHud(){
}
std::string versionStr("v" + std::to_string(VERSION_MAJOR) + "." + std::to_string(VERSION_MINOR) + "." + std::to_string(VERSION_PATCH) + "." + std::to_string(VERSION_BUILD));
DrawShadowStringDecal(vf2d{ GetScreenSize() } - vf2d{ GetTextSize(versionStr) }*0.4,versionStr,WHITE,BLACK,{0.4,0.4},0.4);
#ifdef DEBUG_POS
if("debug_player_info"_I){
DrawShadowStringDecal({0,128},player->GetPos().str());
#endif
DrawShadowStringDecal({0,136},"Spd: "+std::to_string(player->GetMoveSpdMult()));
}
}
void Crawler::AddEffect(std::unique_ptr<Effect>foreground,std::unique_ptr<Effect> background){

@ -118,6 +118,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -135,6 +136,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -154,6 +156,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -171,7 +174,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -193,7 +196,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -216,7 +219,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -236,11 +239,17 @@
<Link>
<SubSystem>Console</SubSystem>
</Link>
<ClCompile>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Emscripten|x64'">
<Link>
<SubSystem>Console</SubSystem>
</Link>
<ClCompile>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="Ability.h" />

@ -126,7 +126,7 @@ bool Monster::Update(float fElapsedTime){
SetPosition(line.rpoint(-0.1));
vel=line.vector().norm()*-128;
}
if(state==NORMAL){
if(GetState()==State::NORMAL){
if(game->GetPlayer()->GetX()>pos.x){
facingDirection=RIGHT;
} else {
@ -139,7 +139,7 @@ bool Monster::Update(float fElapsedTime){
if(targetAcquireTimer==0){
targetAcquireTimer=3;
target=geom2d::line(pos,game->GetPlayer()->GetPos()).upoint(1.2);
state=MOVE_TOWARDS;
SetState(MOVE_TOWARDS);
hasHitPlayer=false;
}
switch(state){
@ -151,7 +151,7 @@ bool Monster::Update(float fElapsedTime){
}
PerformJumpAnimation();
} else {
state=NORMAL;//Revert state once we've finished moving towards target.
SetState(NORMAL);//Revert state once we've finished moving towards target.
UpdateAnimation(MONSTER_DATA[type].GetAnimations()[0]);
}
}break;
@ -180,16 +180,16 @@ bool Monster::Update(float fElapsedTime){
if(line.length()<24*6){
target=line.upoint(-1.2);
if(canMove){
state=MOVE_AWAY;
SetState(MOVE_AWAY);
} else {
state=NORMAL;
SetState(NORMAL);
}
} else
if(line.length()>24*7){
target=line.upoint(1.2);
state=MOVE_TOWARDS;
SetState(MOVE_TOWARDS);
} else {
state=NORMAL;
SetState(NORMAL);
}
}
canMove=true;
@ -208,7 +208,7 @@ bool Monster::Update(float fElapsedTime){
StartPathfinding(2.5);
}else
if(line.length()<=24*7){
state=NORMAL;
SetState(NORMAL);
}
if(moveTowardsLine.vector().x>0){
facingDirection=RIGHT;
@ -229,7 +229,7 @@ bool Monster::Update(float fElapsedTime){
StartPathfinding(2.5);
}else
if(line.length()>=24*6){
state=NORMAL;
SetState(NORMAL);
}
if(moveTowardsLine.vector().x>0){
facingDirection=RIGHT;
@ -297,8 +297,8 @@ void Monster::Collision(Monster&m){
Collision();
}
void Monster::Collision(){
if(strategy==RUN_TOWARDS&&state==MOVE_TOWARDS){
state=NORMAL;
if(strategy==RUN_TOWARDS&&GetState()==MOVE_TOWARDS){
SetState(NORMAL);
}
}
void Monster::SetVelocity(vf2d vel){
@ -392,7 +392,7 @@ void Monster::AddBuff(BuffType type,float duration,float intensity){
}
void Monster::StartPathfinding(float pathingTime){
state=State::PATH_AROUND;
SetState(PATH_AROUND);
path=game->pathfinder.Solve_AStar(pos,target,12,OnUpperLevel());
if(path.size()>0){
pathIndex=0;
@ -430,4 +430,12 @@ std::vector<Buff>Monster::GetBuffs(BuffType buff){
std::vector<Buff>filteredBuffs;
std::copy_if(buffList.begin(),buffList.end(),std::back_inserter(filteredBuffs),[buff](Buff&b){return b.type==buff;});
return filteredBuffs;
}
State Monster::GetState(){
return state;
}
void Monster::SetState(State newState){
state=newState;
}

@ -125,6 +125,8 @@ protected:
void PathAroundBehavior(float fElapsedTime);
void AddBuff(BuffType type,float duration,float intensity);
std::vector<Buff>GetBuffs(BuffType buff);
State GetState();
void SetState(State newState);
};
struct MonsterSpawner{

@ -139,7 +139,10 @@ int Player::GetAttack(){
float Player::GetMoveSpdMult(){
float mod_moveSpd=moveSpd;
for(Buff&b:GetBuffs(BuffType::SLOWDOWN)){
mod_moveSpd-=moveSpd*b.intensity;
mod_moveSpd-=mod_moveSpd*b.intensity;
}
for(Buff&b:GetBuffs(BuffType::BLOCK_SLOWDOWN)){
mod_moveSpd-=mod_moveSpd*b.intensity;
}
return mod_moveSpd;
}
@ -171,6 +174,7 @@ void Player::Update(float fElapsedTime){
notEnoughManaDisplay.second=std::max(0.f,notEnoughManaDisplay.second-fElapsedTime);
notificationDisplay.second=std::max(0.f,notificationDisplay.second-fElapsedTime);
lastHitTimer=std::max(0.f,lastHitTimer-fElapsedTime);
blockTimer=std::max(0.f,blockTimer-fElapsedTime);
manaTickTimer-=fElapsedTime;
if(castInfo.castTimer>0){
castInfo.castTimer-=fElapsedTime;
@ -237,7 +241,7 @@ void Player::Update(float fElapsedTime){
animation.UpdateState(internal_animState,fElapsedTime);
}break;
case BLOCK:{
if(rightClickAbility.COOLDOWN_TIME-rightClickAbility.cooldown>"Warrior.Right Click Ability.Duration"_F){
if(blockTimer<=0){
SetState(NORMAL);
}
}break;
@ -457,6 +461,9 @@ void Player::SetSwordSwingTimer(float val){
}
void Player::SetState(State newState){
if(GetState()==State::BLOCK){
RemoveAllBuffs(BuffType::BLOCK_SLOWDOWN);
}
state=newState;
}
@ -474,7 +481,7 @@ bool Player::HasIframes(){
bool Player::Hurt(int damage,bool onUpperLevel){
if(hp<=0||iframe_time!=0||OnUpperLevel()!=onUpperLevel) return false;
if(state==State::BLOCK)damage*=1-"Warrior.Right Click Ability.DamageReduction"_F;
if(GetState()==State::BLOCK)damage*=1-"Warrior.Right Click Ability.DamageReduction"_F;
float mod_dmg=damage;
for(Buff&b:GetBuffs(BuffType::DAMAGE_REDUCTION)){
mod_dmg-=damage*b.intensity;
@ -542,7 +549,7 @@ void Player::Moved(){
}
void Player::Spin(float duration,float spinSpd){
state=State::SPIN;
SetState(State::SPIN);
spin_attack_timer=duration;
spin_spd=spinSpd;
spin_angle=0;
@ -584,6 +591,24 @@ std::vector<Buff>Player::GetBuffs(BuffType buff){
return filteredBuffs;
}
void Player::RemoveBuff(BuffType buff){
for(auto it=buffList.begin();it!=buffList.end();++it){
Buff&b=*it;
if(b.type==buff){
buffList.erase(it);
return;
}
}
}
void Player::RemoveAllBuffs(BuffType buff){
std::erase_if(buffList,[&](Buff&b){return b.type==buff;});
}
void Player::RemoveAllBuffs(){
buffList.clear();
}
void Player::CastSpell(Ability&ability){
vf2d castPosition=game->GetWorldMousePos();
float distance=sqrt(pow(GetX()-game->GetWorldMousePos().x,2)+pow(GetY()-game->GetWorldMousePos().y,2));

@ -92,6 +92,7 @@ protected:
const float RETREAT_GHOST_FRAME_DELAY=0.025;
float ghostFrameTimer=0;
float ghostRemoveTimer=0;
float blockTimer=0;
float retreatTimer=0;
std::vector<vf2d>ghostPositions;
float rapidFireTimer=0;
@ -130,6 +131,9 @@ public:
void AddBuff(BuffType type,float duration,float intensity);
std::vector<Buff>GetBuffs(BuffType buff);
void RemoveBuff(BuffType type); //Removes the first buff found.
void RemoveAllBuffs(BuffType type); //Removes all buffs of a certain type.
void RemoveAllBuffs(); //Remove every buff.
bool Hurt(int damage,bool onUpperLevel);
//specificClass is a bitwise-combination of classes from the Class enum. It makes sure certain animations only play if you are a certain class.

@ -2,7 +2,7 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 0
#define VERSION_BUILD 927
#define VERSION_BUILD 935
#define stringify(a) stringify_(a)
#define stringify_(a) #a

@ -71,7 +71,8 @@ void Warrior::InitializeClassAbilities(){
if(p->GetState()==State::NORMAL){
rightClickAbility.cooldown=rightClickAbility.COOLDOWN_TIME;
p->SetState(State::BLOCK);
p->AddBuff(BuffType::SLOWDOWN,"Warrior.Right Click Ability.Duration"_F,"Warrior.Right Click Ability.SlowAmt"_F);
p->blockTimer="Warrior.Right Click Ability.Duration"_F;
p->AddBuff(BuffType::BLOCK_SLOWDOWN,"Warrior.Right Click Ability.Duration"_F,"Warrior.Right Click Ability.SlowAmt"_F);
return true;
}
return false;

@ -13,7 +13,7 @@ Warrior
Right Click Ability
{
Name = Block
Cooldown = 15
Cooldown = 1
Mana Cost = 0
#RGB Values. Color 1 is the left side of the bar, Color 2 is the right side.

@ -16,4 +16,10 @@ class_directory = classes/
class_list = Warrior, Thief, Ranger, Trapper, Wizard, Witch
# Whether or not to show individual data accesses from config data structure.
debug_access_options = 0
debug_access_options = 0
# Shows extra info about the player on the HUD
debug_player_info = 0
# Shows collision boxes of tiles.
debug_collision_boxes = 0

Binary file not shown.
Loading…
Cancel
Save