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

Method canDamage

source/game/StarDamageTypes.cpp:42–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42bool EntityDamageTeam::canDamage(EntityDamageTeam victim, bool victimIsSelf) const {
43 if (victimIsSelf) {
44 if (type == TeamType::Indiscriminate)
45 return true;
46 } else if (type == TeamType::Friendly) {
47 if (victim.type == TeamType::Enemy || victim.type == TeamType::Passive || victim.type == TeamType::Environment || victim.type == TeamType::Indiscriminate)
48 return true;
49 } else if (type == TeamType::Enemy) {
50 if (victim.type == TeamType::Friendly || victim.type == TeamType::PVP || victim.type == TeamType::Indiscriminate)
51 return true;
52 else if (victim.type == TeamType::Enemy && team != victim.team)
53 return true;
54 } else if (type == TeamType::PVP) {
55 if (victim.type == TeamType::Enemy || victim.type == TeamType::Passive || victim.type == TeamType::Environment || victim.type == TeamType::Indiscriminate)
56 return true;
57 else if (victim.type == TeamType::PVP && (team == 0 || team != victim.team))
58 return true;
59 } else if (type == TeamType::Passive) {
60 // never deal damage
61 } else if (type == TeamType::Ghostly) {
62 // never deal damage
63 } else if (type == TeamType::Environment) {
64 if (victim.type == TeamType::Friendly || victim.type == TeamType::PVP || victim.type == TeamType::Indiscriminate)
65 return true;
66 } else if (type == TeamType::Indiscriminate) {
67 if (victim.type == TeamType::Friendly || victim.type == TeamType::Enemy || victim.type == TeamType::PVP
68 || victim.type == TeamType::Passive
69 || victim.type == TeamType::Environment
70 || victim.type == TeamType::Indiscriminate)
71 return true;
72 } else if (type == TeamType::Assistant) {
73 if (victim.type == TeamType::Enemy || victim.type == TeamType::Passive || victim.type == TeamType::Environment || victim.type == TeamType::Indiscriminate)
74 return true;
75 }
76
77 return false;
78}
79
80bool EntityDamageTeam::operator==(EntityDamageTeam const& rhs) const {
81 return tie(type, team) == tie(rhs.type, rhs.team);

Callers 3

queryHitMethod · 0.80
entityCanDamageMethod · 0.80
isValidTargetMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected