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

Function WolfControl

TombEngine/Objects/TR1/Entity/tr1_wolf.cpp:104–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102 }
103
104 void WolfControl(short itemNumber)
105 {
106 if (!CreatureActive(itemNumber))
107 return;
108
109 auto& item = g_Level.Items[itemNumber];
110 const auto& object = Objects[item.ObjectNumber];
111 auto& creature = *GetCreatureInfo(&item);
112
113 short headingAngle = 0;
114 short tiltAngle = 0;
115 auto extraHeadRot = EulerAngles::Identity;
116
117 if (item.HitPoints <= 0)
118 {
119 if (item.Animation.ActiveState != WOLF_STATE_DEATH)
120 SetAnimation(item, WolfDeathAnims[Random::GenerateInt(0, (int)WolfDeathAnims.size() - 1)]);
121 }
122 else
123 {
124 AI_INFO ai;
125 CreatureAIInfo(&item, &ai);
126
127 if (ai.ahead)
128 extraHeadRot.y = ai.angle;
129
130 GetCreatureMood(&item, &ai, false);
131 CreatureMood(&item, &ai, false);
132
133 if (item.Animation.ActiveState != WOLF_STATE_SLEEP)
134 headingAngle = CreatureTurn(&item, creature.MaxTurn);
135
136 switch (item.Animation.ActiveState)
137 {
138 case WOLF_STATE_SLEEP:
139 extraHeadRot.y = 0;
140
141 if (creature.Mood == MoodType::Escape || ai.zoneNumber == ai.enemyZone)
142 {
143 item.Animation.TargetState = WOLF_STATE_IDLE;
144 item.Animation.RequiredState = WOLF_STATE_CROUCH;
145 }
146 else if (Random::TestProbability(WOLF_WAKE_CHANCE))
147 {
148 item.Animation.TargetState = WOLF_STATE_IDLE;
149 item.Animation.RequiredState = WOLF_STATE_WALK;
150 }
151
152 break;
153
154 case WOLF_STATE_IDLE:
155 if (item.Animation.RequiredState != NO_VALUE)
156 {
157 item.Animation.TargetState = item.Animation.RequiredState;
158 }
159 else
160 {
161 item.Animation.TargetState = WOLF_STATE_WALK;

Callers

nothing calls this directly

Calls 15

CreatureActiveFunction · 0.85
GetCreatureInfoFunction · 0.85
SetAnimationFunction · 0.85
GenerateIntFunction · 0.85
CreatureAIInfoFunction · 0.85
GetCreatureMoodFunction · 0.85
CreatureMoodFunction · 0.85
CreatureTurnFunction · 0.85
TestProbabilityFunction · 0.85
DoDamageFunction · 0.85
CreatureEffectFunction · 0.85
CreatureTiltFunction · 0.85

Tested by

no test coverage detected