| 319 | } |
| 320 | |
| 321 | List<DamageNotification> Npc::applyDamage(DamageRequest const& damage) { |
| 322 | if (!inWorld()) |
| 323 | return {}; |
| 324 | |
| 325 | auto notifications = m_statusController->applyDamageRequest(damage); |
| 326 | |
| 327 | float totalDamage = 0.0f; |
| 328 | for (auto const& notification : notifications) |
| 329 | totalDamage += notification.healthLost; |
| 330 | |
| 331 | if (totalDamage > 0 && m_hitDamageNotificationLimiter < m_hitDamageNotificationLimit) { |
| 332 | m_scriptComponent.invoke("damage", JsonObject{ |
| 333 | {"sourceId", damage.sourceEntityId}, |
| 334 | {"damage", totalDamage}, |
| 335 | {"sourceDamage", damage.damage}, |
| 336 | {"sourceKind", damage.damageSourceKind} |
| 337 | }); |
| 338 | m_hitDamageNotificationLimiter++; |
| 339 | } |
| 340 | |
| 341 | return notifications; |
| 342 | } |
| 343 | |
| 344 | List<DamageNotification> Npc::selfDamageNotifications() { |
| 345 | return m_statusController->pullSelfDamageNotifications(); |
no test coverage detected