Annotation of researchv10no/games/trek/warp.c, revision 1.1

1.1     ! root        1: # include      "trek.h"
        !             2: 
        !             3: /**
        !             4:  **    move under warp power
        !             5:  **/
        !             6: 
        !             7: float newpos();
        !             8: 
        !             9: ram()
        !            10: {
        !            11:        register int    course;
        !            12:        int             ix, iy;
        !            13:        float           dist;
        !            14: 
        !            15:        if(getsect(&ix, &iy)==0)
        !            16:                return;
        !            17:        course=dokalc(Quadx,Quady,ix,iy,&dist);
        !            18:        warp(1,course,dist);
        !            19: }
        !            20: 
        !            21: move()
        !            22: {
        !            23:        int             course;
        !            24:        float           dist;
        !            25: 
        !            26:        if(Status.cond==DOCKED) {
        !            27:                printf("%s is docked.\n", Status.shipname);
        !            28:                return;
        !            29:        }
        !            30:        if(getcodi(&course, &dist)==0)
        !            31:                return;
        !            32:        warp(0, course, dist);
        !            33: }
        !            34: 
        !            35: warp(ramflg, c, d)
        !            36: int            ramflg;
        !            37: int            c;
        !            38: double d;
        !            39: {
        !            40:        int                     course;
        !            41:        char                    evc;
        !            42:        float                   power;
        !            43:        float                   dist;
        !            44:        float                   time;
        !            45:        float                   speed;
        !            46:        double                  frac;
        !            47:        register int            percent;
        !            48:        register int            i;
        !            49:        extern char             Snapshot[];
        !            50: 
        !            51:        if (Damage[WARP])
        !            52:        {
        !            53:                printf("Warp drive is disabled\n");
        !            54:                return;
        !            55:        }
        !            56:        course = c;
        !            57:        dist = d;
        !            58:        time = Param.warptime * dist / Status.warp2;
        !            59:        power = (dist + 0.05) * Status.warp3;
        !            60:        power =+ Status.cloaked * Param.cloakenergy * time;
        !            61:        percent = 100 * power / Status.energy + 0.5;
        !            62:        percent =* (Status.shldup+1);
        !            63:        if (percent >= 85)
        !            64:        {
        !            65:                printf("Scotty: That would consume %d%% of our remaining energy.\n",
        !            66:                        percent);
        !            67:                if (!getynpar("Are you sure that is wise"))
        !            68:                        return;
        !            69:        }
        !            70:        percent = 100 * time / Status.time + 0.5;
        !            71:        if (percent >= 85)
        !            72:        {
        !            73:                printf("Spock: That would take %d%% of our remaining time.\n",
        !            74:                        percent);
        !            75:                if (!getynpar("Are you sure that is wise"))
        !            76:                        return;
        !            77:        }
        !            78:        if (ranf(200) < 25 * (Status.warp - 6.0))
        !            79:        {
        !            80:                frac = franf();
        !            81:                dist =* frac;
        !            82:                time =* frac;
        !            83:                damage(WARP, (frac + 1.0) * Status.warp * (franf() + 0.25) * 0.20);
        !            84:                printf("Damage occurred to warp engines\n");
        !            85:        }
        !            86:        speed = Status.warp2 / Param.warptime;
        !            87:        Move.delta = newpos(ramflg, course, time, speed);
        !            88:        dist = Move.delta * speed;
        !            89:        Status.energy =- dist * Status.warp3 * (Status.shldup + 1);
        !            90:        if (Status.warp <= 9.0)
        !            91:                return;
        !            92:        printf("___ Speed exceeding warp nine ___\n");
        !            93:        sleep(2);
        !            94:        printf("Ship's safety systems malfunction\n");
        !            95:        sleep(2);
        !            96:        printf("Crew experiencing extreme sensory distortion\n");
        !            97:        sleep(4);
        !            98:        if (ranf(100) >= 50 * dist)
        !            99:        {
        !           100:                printf("Equilibrium restored -- all systems normal\n");
        !           101:                return;
        !           102:        }
        !           103:        percent = ranf(100);
        !           104:        if (percent < 90)
        !           105:        {
        !           106:                /* time warp */
        !           107:                if (percent < 35 || !Game.snap)
        !           108:                {
        !           109:                        time = (Status.warp - 8.0) * dist * (franf() + 1.0);
        !           110:                        Status.date =+ time;
        !           111:                        printf("Positive time portal entered -- it is now Stardate %.2f\n",
        !           112:                                Status.date);
        !           113:                        for (i = 0; i < MAXEVENTS; i++)
        !           114:                                if ((evc = Event[i].evcode) == E_FIXDV || evc == E_LRTB)
        !           115:                                        reschedule(&Event[i], time);
        !           116:                } else {
        !           117:                        time = Status.date;
        !           118:                        bmove(i=Snapshot, &Status.bases, 2);
        !           119:                        bmove(i =+ 2, &Status.date, 12);
        !           120:                        bmove(i =+ 12, &Quad, sizeof Quad);
        !           121:                        bmove(i =+ sizeof Quad, &Event, sizeof Event);
        !           122:                        bmove(i =+ sizeof Event, &Base, sizeof Base);
        !           123:                        bmove(i =+ sizeof Base, &Etc, sizeof Etc);
        !           124:                        printf("Negative time portal entered -- it is now Stardate %.2f\n",
        !           125:                                Status.date);
        !           126:                        for (i = 0; i < MAXEVENTS; i++)
        !           127:                                if (Event[i].evcode == E_FIXDV)
        !           128:                                        reschedule(&Event[i], Status.date - time);
        !           129:                }
        !           130:        } else  if (percent < 95)
        !           131:                        lose(L_TOOFAST);
        !           132:                else {
        !           133:                        printf("Equilibrium restored -- extreme damage occured to ship systems\n");
        !           134:                        for (i = 0; i < NDEV; i++)
        !           135:                                damage(i, (franf() + 1.0) * (Status.warp - 6) * Param.damfac[i] * 0.20);
        !           136:                        Status.shldup = 0;
        !           137:                        dcrept();
        !           138:                }
        !           139: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.