| 75 | }; |
| 76 | |
| 77 | void TRexControl(short itemNumber) |
| 78 | { |
| 79 | if (!CreatureActive(itemNumber)) |
| 80 | return; |
| 81 | |
| 82 | auto* item = &g_Level.Items[itemNumber]; |
| 83 | auto* creature = GetCreatureInfo(item); |
| 84 | |
| 85 | short headingAngle = 0; |
| 86 | short headYRot = 0; |
| 87 | |
| 88 | if (item->HitPoints <= 0) |
| 89 | { |
| 90 | if (item->Animation.ActiveState == TREX_STATE_IDLE) |
| 91 | { |
| 92 | item->Animation.TargetState = TREX_STATE_DEATH; |
| 93 | } |
| 94 | else |
| 95 | { |
| 96 | item->Animation.TargetState = TREX_STATE_IDLE; |
| 97 | } |
| 98 | } |
| 99 | else |
| 100 | { |
| 101 | AI_INFO ai; |
| 102 | CreatureAIInfo(item, &ai); |
| 103 | |
| 104 | if (ai.ahead) |
| 105 | headYRot = ai.angle; |
| 106 | |
| 107 | GetCreatureMood(item, &ai, true); |
| 108 | CreatureMood(item, &ai, true); |
| 109 | |
| 110 | headingAngle = CreatureTurn(item, creature->MaxTurn); |
| 111 | |
| 112 | if (item->TouchBits.TestAny()) |
| 113 | DoDamage(LaraItem, (item->Animation.ActiveState == TREX_STATE_RUN_FORWARD) ? TREX_RUN_CONTACT_DAMAGE : TREX_CONTACT_DAMAGE); |
| 114 | |
| 115 | creature->Flags = (creature->Mood != MoodType::Escape && !ai.ahead && ai.enemyFacing > -FRONT_ARC && ai.enemyFacing < FRONT_ARC); |
| 116 | |
| 117 | if (ai.distance > pow(1500, 2) && |
| 118 | ai.distance < pow(BLOCK(4), 2) && |
| 119 | ai.bite && !creature->Flags) |
| 120 | { |
| 121 | creature->Flags = 1; |
| 122 | } |
| 123 | |
| 124 | switch (item->Animation.ActiveState) |
| 125 | { |
| 126 | case TREX_STATE_IDLE: |
| 127 | if (item->Animation.RequiredState != NO_VALUE) |
| 128 | item->Animation.TargetState = item->Animation.RequiredState; |
| 129 | else if (ai.distance < pow(1500, 2) && ai.bite) |
| 130 | item->Animation.TargetState = TREX_STATE_ATTACK; |
| 131 | else if (creature->Mood == MoodType::Bored || creature->Flags) |
| 132 | item->Animation.TargetState = TREX_STATE_WALK_FORWARD; |
| 133 | else |
| 134 | item->Animation.TargetState = TREX_STATE_RUN_FORWARD; |
nothing calls this directly
no test coverage detected