MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / applyDamage

Method applyDamage

source/game/StarNpc.cpp:321–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

319}
320
321List<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
344List<DamageNotification> Npc::selfDamageNotifications() {
345 return m_statusController->pullSelfDamageNotifications();

Callers 1

Calls 2

applyDamageRequestMethod · 0.80
invokeMethod · 0.45

Tested by

no test coverage detected