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

Function CrocodileControl

TombEngine/Objects/TR4/Entity/tr4_crocodile.cpp:124–361  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122 }
123
124 void CrocodileControl(short itemNumber)
125 {
126 if (!CreatureActive(itemNumber))
127 return;
128
129 auto* item = &g_Level.Items[itemNumber];
130 auto* object = &Objects[item->ObjectNumber];
131 auto* creature = GetCreatureInfo(item);
132
133 short headingAngle = 0;
134 short boneAngle = 0;
135 auto extraHeadRot = EulerAngles::Identity;
136 auto extraTorsoRot = EulerAngles::Identity;
137
138 AI_INFO ai;
139
140 if (item->HitPoints <= 0)
141 {
142 bool isInWater = TestEnvironment(ENV_FLAG_WATER, item);
143
144 if (item->Animation.ActiveState != CROC_STATE_DEATH && item->Animation.ActiveState != CROC_STATE_WATER_DEATH)
145 {
146 if (isInWater)
147 {
148 SetAnimation(item, CROC_ANIM_WATER_DEATH);
149 item->HitPoints = NOT_TARGETABLE;
150 }
151 else
152 {
153 SetAnimation(item, CROC_ANIM_LAND_DEATH);
154 }
155 }
156
157 if (isInWater)
158 {
159 CreatureFloat(itemNumber);
160 return;
161 }
162 }
163 else
164 {
165 if (item->AIBits & ALL_AIOBJ)
166 GetAITarget(creature);
167 else if (creature->HurtByLara)
168 creature->Enemy = LaraItem; // TODO: Deal with LaraItem global.
169
170 CreatureAIInfo(item, &ai);
171 GetCreatureMood(item, &ai, true);
172 CreatureMood(item, &ai, true);
173
174 headingAngle = CreatureTurn(item, creature->MaxTurn);
175 boneAngle = headingAngle;
176
177 if ((item->HitStatus || ai.distance < CROC_ALERT_RANGE) ||
178 (TargetVisible(item, &ai) && ai.distance < CROC_VISIBILITY_RANGE))
179 {
180 if (!creature->Alerted)
181 creature->Alerted = true;

Callers

nothing calls this directly

Calls 15

CreatureActiveFunction · 0.85
GetCreatureInfoFunction · 0.85
TestEnvironmentFunction · 0.85
SetAnimationFunction · 0.85
CreatureFloatFunction · 0.85
GetAITargetFunction · 0.85
CreatureAIInfoFunction · 0.85
GetCreatureMoodFunction · 0.85
CreatureMoodFunction · 0.85
CreatureTurnFunction · 0.85
TargetVisibleFunction · 0.85
AlertAllGuardsFunction · 0.85

Tested by

no test coverage detected