Fixing Nene Quest Bug [New Game]

I failed my physics again and again. fuck me i’m dumb. welp. thank god there’s new season of New Game!! and Emeperador Light.

Back to topic:

NENE QUEST!

Ooops. BLOCK_TYPE_IS_VALID(pHead -> nBlockUse) usually prompt when you try to delete a nonexisting object. based on the animation the player hit twice the mob and caused that error.

void Destructible::ReceiveDamage(float sourceDamage){
  auto resolvedDamage = sourceDamage;
  for(const auto& debuf : m_debuf) {
    resolvedDamage = debuf->ApplyToDamage(resolvedDamage);
    m_current -= resolvedDamage;
    if(m_currentHealth <= 0.f){
      m_currentHealth = 0.f;
      DestroyMe();
    }
  }
}

Welp. at least she’s better programmer than my other classmate when they can’t even program anything.

The code is basically says that add the get the source damage, debuf it and apply the damage to the mob. if the mob health is less than or equal to zero destroy it. the only problem of this code it doesn’t break the loop after it runs the DestroyMe(); which can cause deleting the object doesn’t exist anymore.

void Destructible::ReceiveDamage(float sourceDamage){
  auto resolvedDamage = sourceDamage;
  for(const auto& debuf : m_debuf) {
    resolvedDamage = debuf->ApplyToDamage(resolveDamage);
    m_current -= resolvedDamage;
    if(m_currentHealth <= 0.f){
      m_currentHealth = 0.f;
      DestroyMe();
      break;
    }
  }
}

Memory management is serious business. let’s fuckfix it more.

void Destructible::ReceiveDamage(float sourceDamage){
  float resolvedDamage = sourceDamage;
  for(const auto& debuf : m_debufs) {
    resolvedDamage = debuf->ApplyToDamage(sourceDamage);
    m_currentHealth -= (resolvedDamage>m_currentHealth)?m_currentHealth:resolvedDamage;
    if(m_currentHealth  <= 0.f) {
      destroyMe();
      break;
    }
  }
}

Lesson: Don’t use C++.