MCPcopy Create free account
hub / github.com/Phobos-developers/Phobos / VeinAttackAI

Method VeinAttackAI

src/Ext/Anim/Body.cpp:124–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124void AnimExt::VeinAttackAI(AnimClass* pAnim)
125{
126 CellStruct pCoordinates = pAnim->GetMapCoords();
127 CellClass* pCell = MapClass::Instance.GetCellAt(pCoordinates);
128 ObjectClass* pOccupier = pCell->FirstObject;
129 constexpr unsigned char fullyFlownWeedStart = 0x30; // Weeds starting from this overlay frame are fully grown
130 constexpr unsigned int weedOverlayIndex = 126;
131
132 if (!pOccupier || pOccupier->GetHeight() > 0 || pCell->OverlayTypeIndex != weedOverlayIndex
133 || pCell->OverlayData < fullyFlownWeedStart || pCell->SlopeIndex)
134 {
135 pAnim->UnableToContinue = true;
136 }
137
138 if (Unsorted::CurrentFrame % 2 == 0)
139 {
140 while (pOccupier != nullptr)
141 {
142 ObjectClass* pNext = pOccupier->NextObject;
143 int damage = RulesClass::Instance->VeinDamage;
144 TechnoClass* pTechno = abstract_cast<TechnoClass*, true>(pOccupier);
145
146 if (pTechno && !pTechno->GetTechnoType()->ImmuneToVeins && !pTechno->HasAbility(Ability::VeinProof)
147 && pTechno->Health > 0 && pTechno->IsAlive && pTechno->GetHeight() <= 5)
148 {
149 pTechno->ReceiveDamage(&damage, 0, RulesExt::Global()->VeinholeWarhead, nullptr, false, false, nullptr);
150 }
151
152 pOccupier = pNext;
153 }
154 }
155}
156
157// Changes type of anim in similar fashion to Next.
158void AnimExt::ChangeAnimType(AnimClass* pAnim, AnimTypeClass* pNewType, bool resetLoops, bool restart)

Callers

nothing calls this directly

Calls 2

GetTechnoTypeMethod · 0.80
ReceiveDamageMethod · 0.80

Tested by

no test coverage detected