Fix Ranger Charged Shot and Multi Shot animations being overwritten by cast completion state resetting. Release Build 8367.

mac-build
sigonasr2 8 months ago
parent d442095fde
commit 1742fa50eb
  1. 2
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 25
      Adventures in Lestoria/Player.cpp
  3. 3
      Adventures in Lestoria/Player.h
  4. 4
      Adventures in Lestoria/Ranger.cpp
  5. 2
      Adventures in Lestoria/Version.h
  6. 3
      Adventures in Lestoria/olcUTIL_Animate2D.h
  7. BIN
      x64/Release/Adventures in Lestoria.exe

@ -2068,7 +2068,6 @@ void AiL::_PrepareLevel(MapName map,MusicChange changeMusic){
Audio::UpdateBGMVolume();
#endif
game->view.SetZoom(1.f,game->view.WorldToScreen(game->camera.GetViewPosition()));
SetMosaicEffect(1U);
worldColor=WHITE;
worldColorFunc=[&](vi2d pos){return game->worldColor;};
levelTime=0;
@ -2106,6 +2105,7 @@ void AiL::_PrepareLevel(MapName map,MusicChange changeMusic){
#pragma region Monster Spawn Data Setup (Loading phase 2)
LoadingScreen::AddPhase([&](){
SetMosaicEffect(1U);
for(auto&[key,value]:MAP_DATA[GetCurrentLevel()].SpawnerData){
SpawnerTag&spawnData=MAP_DATA[GetCurrentLevel()].SpawnerData[key];
std::vector<std::pair<std::string,vf2d>>monster_list;

@ -315,13 +315,13 @@ void Player::Update(float fElapsedTime){
castInfo.castTimer-=fElapsedTime;
if(castInfo.castTimer<=0){
bool allowed=castPrepAbility->actionPerformedDuringCast;
SetState(State::NORMAL);
if(!allowed&&castPrepAbility->action(this,castInfo.castPos))allowed=true;
if(allowed){
castPrepAbility->cooldown=castPrepAbility->GetCooldownTime();
ConsumeMana(castPrepAbility->manaCost);
}
castInfo.castTimer=0;
SetState(State::NORMAL);
}
}
@ -605,6 +605,9 @@ void Player::Update(float fElapsedTime){
#pragma region Ranger
if(GetState()==State::SHOOT_ARROW){
if(rangerShootAnimationTimer>0.f){
rangerShootAnimationTimer=std::max(0.f,rangerShootAnimationTimer-fElapsedTime);
}else
if(attack_cooldown_timer<=ARROW_ATTACK_COOLDOWN-0.3){
SetState(State::NORMAL);
}
@ -773,9 +776,9 @@ void Player::AddAnimation(std::string state){
animation.AddState(state,ANIMATION_DATA.at(state));
}
void Player::UpdateAnimation(std::string animState,int specificClass,const bool force){
void Player::UpdateAnimation(std::string animState,int specificClass){
if(specificClass==ANY||specificClass&GetClass()){
animation.ChangeState(internal_animState,animState,force);
animation.ChangeState(internal_animState,animState);
}
}
@ -974,31 +977,31 @@ void Player::SetAnimationBasedOnTargetingDirection(float targetDirection){
case Class::WARRIOR:
case Class::THIEF:{
if(FacingNorth()){
UpdateAnimation("WARRIOR_SWINGSWORD_N",true);
UpdateAnimation("WARRIOR_SWINGSWORD_N");
}else
if(FacingSouth()){
UpdateAnimation("WARRIOR_SWINGSWORD_S",true);
UpdateAnimation("WARRIOR_SWINGSWORD_S");
}else
if(FacingWest()){
UpdateAnimation("WARRIOR_SWINGSWORD_W",true);
UpdateAnimation("WARRIOR_SWINGSWORD_W");
}else
if(FacingEast()){
UpdateAnimation("WARRIOR_SWINGSWORD_E",true);
UpdateAnimation("WARRIOR_SWINGSWORD_E");
}
}break;
case Class::RANGER:
case Class::TRAPPER:{
if(FacingNorth()){
UpdateAnimation("RANGER_SHOOT_N",true);
UpdateAnimation("RANGER_SHOOT_N");
}else
if(FacingSouth()){
UpdateAnimation("RANGER_SHOOT_S",true);
UpdateAnimation("RANGER_SHOOT_S");
}else
if(FacingWest()){
UpdateAnimation("RANGER_SHOOT_W",true);
UpdateAnimation("RANGER_SHOOT_W");
}else
if(FacingEast()){
UpdateAnimation("RANGER_SHOOT_E",true);
UpdateAnimation("RANGER_SHOOT_E");
}
}break;
}

@ -178,7 +178,7 @@ public:
bool Heal(int damage,bool suppressDamageNumber=false);
//specificClass is a bitwise-combination of classes from the Class enum. It makes sure certain animations only play if you are a certain class.
//Set force to true to force the animation to restart evne if the animation were already playing.
void UpdateAnimation(std::string animState,int specificClass=ANY,const bool force=false);
void UpdateAnimation(std::string animState,int specificClass=ANY);
Animate2D::Frame GetFrame();
Key GetLastReleasedMovementKey();
float GetSwordSwingTimer();
@ -316,6 +316,7 @@ private:
const bool UsingAutoAim()const;
bool lowHealthSoundPlayed=false;
float lowHealthSoundPlayedTimer=0.f;
float rangerShootAnimationTimer=0.f;
protected:
const float ATTACK_COOLDOWN="Warrior.Auto Attack.Cooldown"_F;
const float MAGIC_ATTACK_COOLDOWN="Wizard.Auto Attack.Cooldown"_F;

@ -114,6 +114,8 @@ void Ranger::InitializeClassAbilities(){
[](Player*p,vf2d pos={}){
vf2d arrowVelocity=util::pointTo(p->GetPos(),p->GetWorldAimingLocation());
BULLET_LIST.push_back(std::make_unique<ChargedArrow>(p->GetPos(),arrowVelocity*"Ranger.Ability 2.Speed"_F,12*"Ranger.Ability 2.Radius"_F/100,p->GetAttack()*"Ranger.Ability 2.DamageMult"_F,p->OnUpperLevel(),true));
p->SetState(State::SHOOT_ARROW);
p->rangerShootAnimationTimer=0.3f;
p->SetAnimationBasedOnTargetingDirection(atan2(arrowVelocity.y,arrowVelocity.x));
game->SetupWorldShake("Ranger.Ability 2.WorldShakeTime"_F);
p->Knockback(-1.f*arrowVelocity.norm()*"Ranger.Ability 2.Knockback"_F);
@ -139,6 +141,8 @@ void Ranger::InitializeClassAbilities(){
vf2d extendedLine=pointTowardsCursor.upoint(1.1f);
BULLET_LIST.push_back(std::make_unique<Arrow>(Arrow(p->GetPos(),extendedLine,vf2d{cos(newAngle)*"Ranger.Ability 3.ArrowSpd"_F,float(sin(newAngle)*"Ranger.Ability 3.ArrowSpd"_F-PI/8*"Ranger.Ability 3.ArrowSpd"_F)}+p->movementVelocity,12*"Ranger.Ability 3.ArrowRadius"_F/100,int(p->GetAttack()*"Ranger.Ability 3.DamageMult"_F),p->OnUpperLevel(),true)));
}
p->rangerShootAnimationTimer=0.3f;
p->SetState(State::SHOOT_ARROW);
p->SetAnimationBasedOnTargetingDirection(shootingAngle);
SoundEffect::PlaySFX("Ranger.Ability 3.Sound"_S,SoundEffect::CENTERED);
return true;

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1
#define VERSION_MINOR 0
#define VERSION_PATCH 0
#define VERSION_BUILD 8357
#define VERSION_BUILD 8367
#define stringify(a) stringify_(a)
#define stringify_(a) #a

@ -172,8 +172,7 @@ namespace olc::utils::Animate2D
Animation() = default;
// Change an animation state token to a new state
//If force is set, will reset the animation even if it's the same animation.
inline bool ChangeState(AnimationState& state, const StatesEnum& sStateName, bool force=false) const
inline bool ChangeState(AnimationState& state, const StatesEnum& sStateName) const
{
size_t idx = m_mapStateIndices.at(sStateName);
if (state.nIndex != idx)

Loading…
Cancel
Save