MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / DoItemHit

Function DoItemHit

TombEngine/Game/items.cpp:1003–1028  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1001}
1002
1003void DoItemHit(ItemInfo* target, int damage, bool isExplosive, bool allowBurn)
1004{
1005 const auto& object = Objects[target->ObjectNumber];
1006
1007 if ((object.damageType == DamageMode::Any) ||
1008 (object.damageType == DamageMode::Explosion && isExplosive))
1009 {
1010 if (target->HitPoints > 0)
1011 {
1012 SaveGame::Statistics.Game.AmmoHits++;
1013 SaveGame::Statistics.Level.AmmoHits++;
1014 DoDamage(target, damage);
1015 }
1016 }
1017
1018 if (isExplosive && allowBurn && Random::TestProbability(1 / 2.0f))
1019 ItemBurn(target);
1020
1021 if (!target->Callbacks.OnHit.empty())
1022 {
1023 short index = g_GameScriptEntities->GetIndexByName(target->Name);
1024
1025 if (index != NO_VALUE)
1026 g_GameScript->ExecuteFunction(target->Callbacks.OnHit, index);
1027 }
1028}
1029
1030void DefaultItemHit(ItemInfo& target, ItemInfo& source, std::optional<GameVector> pos, int damage, bool isExplosive, int jointIndex)
1031{

Callers 7

PunaHitFunction · 0.85
HitWinstonFunction · 0.85
HitCorpseFunction · 0.85
GuardHitFunction · 0.85
RomanStatueHitFunction · 0.85
Baddy2HitFunction · 0.85
DefaultItemHitFunction · 0.85

Calls 6

DoDamageFunction · 0.85
TestProbabilityFunction · 0.85
ItemBurnFunction · 0.85
GetIndexByNameMethod · 0.80
ExecuteFunctionMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected