From 3c3d32bf7e629afc76f6da3d6b6a8450dd813a3c Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Tue, 19 Sep 2023 05:17:57 -0500 Subject: [PATCH] Player gains iframes if getting hit by ground slam to prevent insta-gibbing via the spawned bullet ring. --- Crawler/Player.cpp | 11 ++++++++++- Crawler/Player.h | 3 ++- Crawler/SlimeKing.cpp | 1 + Crawler/Version.h | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Crawler/Player.cpp b/Crawler/Player.cpp index b6e47e98..30b61e6a 100644 --- a/Crawler/Player.cpp +++ b/Crawler/Player.cpp @@ -6,6 +6,7 @@ #include "BulletTypes.h" #include "DEFINES.h" #include "safemap.h" +#include "utils.h" INCLUDE_MONSTER_DATA INCLUDE_MONSTER_LIST @@ -310,7 +311,11 @@ void Player::Update(float fElapsedTime){ } geom2d::line line(pos,m.GetPos()); float dist = line.length(); - m.SetPos(line.rpoint(dist*1.1)); + if(dist<=0.001){ + m.SetPos(m.GetPos()+vf2d{util::random(2)-1,util::random(2)-1}); + }else{ + m.SetPos(line.rpoint(dist*1.1)); + } if(m.IsAlive()){ vel=line.vector().norm()*-128; } @@ -678,4 +683,8 @@ void Player::SetAnimationBasedOnTargetingDirection(float targetDirection){ UpdateAnimation("RANGER_SHOOT_N"); } } +} + +void Player::SetIframes(float duration){ + iframe_time=duration; } \ No newline at end of file diff --git a/Crawler/Player.h b/Crawler/Player.h index ea4d6bdb..c3de770e 100644 --- a/Crawler/Player.h +++ b/Crawler/Player.h @@ -53,6 +53,7 @@ private: float lastHitTimer=0; //When this is greater than zero, if we get hit again it adds to our displayed combo number. std::shared_ptrdamageNumberPtr; void Initialize(); + float iframe_time=0; protected: const float ATTACK_COOLDOWN="Warrior.Auto Attack.Cooldown"_F; const float MAGIC_ATTACK_COOLDOWN="Wizard.Auto Attack.Cooldown"_F; @@ -71,7 +72,6 @@ protected: bool SetPos(vf2d pos); float friction="Player.Friction"_F; float attack_cooldown_timer=0; - float iframe_time=0; float teleportAnimationTimer=0; vf2d teleportTarget={}; vf2d teleportStartPosition={}; @@ -131,6 +131,7 @@ public: bool CanAct(); bool CanAct(Ability&ability); void Knockback(vf2d vel); + void SetIframes(float duration); void AddBuff(BuffType type,float duration,float intensity); std::vectorGetBuffs(BuffType buff); diff --git a/Crawler/SlimeKing.cpp b/Crawler/SlimeKing.cpp index 8c2fa56d..9dc30f14 100644 --- a/Crawler/SlimeKing.cpp +++ b/Crawler/SlimeKing.cpp @@ -124,6 +124,7 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,int strategyNumbe lineToPlayer={m.GetPos(),m.GetPos()+vf2d{cos(randomDir),sin(randomDir)}*1}; } game->GetPlayer()->Knockback(lineToPlayer.vector().norm()*ConfigInt("JumpKnockbackFactor")); + game->GetPlayer()->SetIframes(1); } Landed(m.phase); m.SetStrategyDrawFunction([](Crawler*game){}); diff --git a/Crawler/Version.h b/Crawler/Version.h index 05c993bc..0bb38e2f 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 1362 +#define VERSION_BUILD 1364 #define stringify(a) stringify_(a) #define stringify_(a) #a