ChrisOS Research ProjectOperating systems · language systems · graphics · machine emulation
DOCUMENTATION ARCHIVEMAIN BRANCH
ChrisOS/Source reference: GAMES/MINE/AI.CC

Source reference: GAMES/MINE/AI.CC

Deterministic source record. The complete textual file is reproduced below; this page does not replace architectural interpretation in the authored chapters.

File identity

Field Value
Path GAMES/MINE/AI.CC
Lines 67
Bytes 2097
SHA-256 c3ec8ed06ff1974bda5cbe6cf187a143ee77a03bf5bfd9bc335f4d89650029f4
ChrisOS revision da3df29cb397932c43d32373871fb9380e688ade

Detected syntactic dependencies

Line Include
— No preprocessor include detected.

Detected symbols

Line Symbol
1 ai_step

Complete source

The following block is the complete textual file at the recorded revision. No lines are elided, abbreviated or paraphrased.

void ai_step(float px, float pz) {
    long i;
    float dx;
    float dz;
    float step;
    int nx;
    int nz;
    for (i = 1; i < 16; i = i + 1) {
        switch (g_act[i].kind) {
        case 0:
            continue;
        case 4:
            break;
        case 5:
            break;
        default:
            dx = px - g_act[i].x;
            dz = pz - g_act[i].z;
            if (g_act[i].kind == 2) {
                g_act[i].state = 4;
            } else if (g_act[i].kind == 3 && g_rain) {
                g_act[i].state = 1;
            } else if (g_act[i].kind == 3 && dx * dx + dz * dz < 36.0) {
                g_act[i].state = 2;
            } else if (g_phase == 3 && g_act[i].kind == 1 &&
                       dx * dx + dz * dz < 64.0) {
                g_act[i].state = 3;
            } else if (g_act[i].timer % 40 < 20) {
                g_act[i].state = 1;
            } else {
                g_act[i].state = 0;
            }
            step = 0.08;
            if (g_act[i].state == 2)
                step = -0.12;
            if (g_act[i].state == 3)
                step = 0.1;
            if (g_act[i].state == 0)
                step = 0.0;
            if (g_act[i].state == 4)
                step = 0.05;
            nx = (int)(g_act[i].x + step);
            nz = (int)g_act[i].z;
            if (dx < 0.0)
                nx = (int)(g_act[i].x - step);
            if (voxel_get(nx, (int)g_act[i].y, nz) != 0 &&
                voxel_get(nx, (int)g_act[i].y, nz) != 5)
                step = 0.0;
            if (g_act[i].kind == 2 &&
                voxel_get((int)g_act[i].x, (int)g_act[i].y, (int)g_act[i].z) !=
                    5)
                step = 0.0;
            g_act[i].vx = step;
            if (dz > 0.5)
                g_act[i].vz = 0.04;
            else if (dz < -0.5)
                g_act[i].vz = 0.0 - 0.04;
            else
                g_act[i].vz = 0.0;
            if (g_act[i].state == 2)
                g_act[i].vz = 0.0 - g_act[i].vz;
            break;
        }
        g_act[i].timer = g_act[i].timer + 1;
    }
}

Role of this record

The atlas guarantees file-by-file traceability. Responsibility, invariants, ownership, concurrency, security, performance and subsystem interactions belong in authored chapters and must cite this file when applicable.

Document record ID: source-c3ec8ed06ff1974b Reviewed source: da3df29cb397 Class: generated-source-reference