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

Function InitializeSlot

TombEngine/Game/control/lot.cpp:139–313  ·  view source on GitHub ↗

* @brief Initializes a creature's AI slot with movement capabilities based on its LotType. * * This is the core initialization function that sets up a creature's pathfinding parameters. * The LotType (defined per object in Objects[]) determines: * - Step: Maximum height the creature can step UP to reach another box. * - Drop: Maximum height the creature can DROP down to reach another box (neg

Source from the content-addressed store, hash-verified

137 * @param makeTarget If true, creates an AI target item for special pathfinding.
138 */
139void InitializeSlot(short itemNumber, bool makeTarget)
140{
141 auto* item = &g_Level.Items[itemNumber];
142 auto* object = &Objects[item->ObjectNumber];
143 item->Data = CreatureInfo();
144 auto* creature = GetCreatureInfo(item);
145
146 // Initialize pathfinding node array.
147 InitializeLOTarray(itemNumber);
148
149 // Initialize creature state.
150 creature->ItemNumber = itemNumber;
151 creature->Mood = MoodType::Bored;
152 creature->JointRotation[0] = 0;
153 creature->JointRotation[1] = 0;
154 creature->JointRotation[2] = 0;
155 creature->JointRotation[3] = 0;
156 creature->Alerted = false;
157 creature->HeadLeft = false;
158 creature->HeadRight = false;
159 creature->ReachedGoal = false;
160 creature->HurtByLara = false;
161 creature->Patrol = false;
162 creature->JumpAhead = false;
163 creature->MonkeySwingAhead = false;
164 creature->MaxTurn = ANGLE(1);
165 creature->Flags = 0;
166 creature->Enemy = nullptr;
167
168 // Initialize LOT defaults.
169 creature->LOT.CanJump = false;
170 creature->LOT.CanMonkey = false;
171 creature->LOT.IsJumping = false;
172 creature->LOT.IsMonkeying = false;
173 creature->LOT.Fly = NO_FLYING;
174 creature->LOT.BlockMask = BLOCKED;
175 creature->AITargetNumber = NO_VALUE;
176 creature->AITarget = nullptr;
177
178 // Create AI target item if needed (for AI_FOLLOW, AI_PATROL, etc.)
179 if (makeTarget)
180 {
181 creature->AITargetNumber = CreateItem();
182 if (creature->AITargetNumber != NO_VALUE)
183 creature->AITarget = &g_Level.Items[creature->AITargetNumber];
184 }
185
186 // Set movement capabilities based on object's LotType.
187 // Each LotType defines what terrain the creature can traverse.
188 switch (object->LotType)
189 {
190 default:
191 case LotType::Basic:
192 // Basic ground creatures: small step up, medium drop down.
193 // Examples: dogs, rats, small animals.
194 creature->LOT.Step = CLICK(1); // Can step up 1 click (256 units).
195 creature->LOT.Drop = -CLICK(2); // Can drop down 2 clicks (512 units).
196 creature->LOT.Zone = ZoneType::Basic;

Callers 1

EnableEntityAIFunction · 0.85

Calls 7

GetCreatureInfoFunction · 0.85
InitializeLOTarrayFunction · 0.85
ANGLEFunction · 0.85
ClearLOTFunction · 0.85
CreateZoneFunction · 0.85
CreatureInfoClass · 0.70
CreateItemFunction · 0.50

Tested by

no test coverage detected