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

Function CanCreatureJump

TombEngine/Game/control/box.cpp:3362–3408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3360}
3361
3362bool CanCreatureJump(ItemInfo& item, JumpDistance jumpDistType)
3363{
3364 const auto& creature = *GetCreatureInfo(&item);
3365 if (creature.Enemy == nullptr)
3366 return false;
3367
3368 float stepDist = BLOCK(0.92f);
3369
3370 int vPos = item.Pose.Position.y;
3371 auto pointCollA = GetPointCollision(item, item.Pose.Orientation.y, stepDist);
3372 auto pointCollB = GetPointCollision(item, item.Pose.Orientation.y, stepDist * 2);
3373 auto pointCollC = GetPointCollision(item, item.Pose.Orientation.y, stepDist * 3);
3374
3375 switch (jumpDistType)
3376 {
3377 default:
3378 case JumpDistance::Block1:
3379 if (item.BoxNumber == creature.Enemy->BoxNumber ||
3380 vPos >= (pointCollA.GetFloorHeight() - STEPUP_HEIGHT) ||
3381 vPos >= (pointCollB.GetFloorHeight() + CLICK(1)) ||
3382 vPos <= (pointCollB.GetFloorHeight() - CLICK(1)) ||
3383 pointCollA.GetSector().PathfindingBoxID == NO_VALUE ||
3384 pointCollB.GetSector().PathfindingBoxID == NO_VALUE)
3385 {
3386 return false;
3387 }
3388
3389 break;
3390
3391 case JumpDistance::Block2:
3392 if (item.BoxNumber == creature.Enemy->BoxNumber ||
3393 vPos >= (pointCollA.GetFloorHeight() - STEPUP_HEIGHT) ||
3394 vPos >= (pointCollB.GetFloorHeight() - STEPUP_HEIGHT) ||
3395 vPos >= (pointCollC.GetFloorHeight() + CLICK(1)) ||
3396 vPos <= (pointCollC.GetFloorHeight() - CLICK(1)) ||
3397 pointCollA.GetSector().PathfindingBoxID == NO_VALUE ||
3398 pointCollB.GetSector().PathfindingBoxID == NO_VALUE ||
3399 pointCollC.GetSector().PathfindingBoxID == NO_VALUE)
3400 {
3401 return false;
3402 }
3403
3404 break;
3405 }
3406
3407 return true;
3408}

Callers 2

RaptorControlFunction · 0.85
GuardControlFunction · 0.85

Calls 3

GetCreatureInfoFunction · 0.85
GetPointCollisionFunction · 0.85
GetFloorHeightMethod · 0.45

Tested by

no test coverage detected