⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 p_user.c

📁 The source code of Doom legacy for windows
💻 C
📖 第 1 页 / 共 3 页
字号:
            //    pitch = 0;            pitch = (attacker->z - player->mo->z)>>17;            player->aiming = G_ClipAimingPitch (&pitch);    }    else if (player->damagecount)        player->damagecount--;    if (player->cmd.buttons & BT_USE)    {        player->playerstate = PST_REBORN;        player->mo->special2 = 666;    }}//----------------------------------------------------------------------------//// PROC P_ChickenPlayerThink////----------------------------------------------------------------------------void P_ChickenPlayerThink(player_t *player){        mobj_t *pmo;        if(player->health > 0)        { // Handle beak movement                P_UpdateBeak(player, &player->psprites[ps_weapon]);        }        if(player->chickenTics&15)        {                return;        }        pmo = player->mo;        if(!(pmo->momx+pmo->momy) && P_Random() < 160)        { // Twitch view angle                pmo->angle += P_SignedRandom()<<19;        }        if((pmo->z <= pmo->floorz) && (P_Random() < 32))        { // Jump and noise                pmo->momz += FRACUNIT;                P_SetMobjState(pmo, S_CHICPLAY_PAIN);                return;        }        if(P_Random() < 48)        { // Just noise#ifdef HW3SOUND                S_StartScreamSound(pmo, sfx_chicact);#else                S_StartSound(pmo, sfx_chicact);#endif        }}//----------------------------------------------------------------------------//// FUNC P_UndoPlayerChicken////----------------------------------------------------------------------------boolean P_UndoPlayerChicken(player_t *player){        mobj_t *fog;        mobj_t *mo;        mobj_t *pmo;        fixed_t x;        fixed_t y;        fixed_t z;        angle_t angle;        int playerNum;        weapontype_t weapon;        int oldFlags;        int oldFlags2;        pmo = player->mo;        x = pmo->x;        y = pmo->y;        z = pmo->z;        angle = pmo->angle;        weapon = pmo->special1;        oldFlags = pmo->flags;        oldFlags2 = pmo->flags2;        P_SetMobjState(pmo, S_FREETARGMOBJ);        mo = P_SpawnMobj(x, y, z, MT_PLAYER);        if(P_TestMobjLocation(mo) == false)        { // Didn't fit                P_RemoveMobj(mo);                mo = P_SpawnMobj(x, y, z, MT_CHICPLAYER);                mo->angle = angle;                mo->health = player->health;                mo->special1 = weapon;                mo->player = player;                mo->flags = oldFlags;                mo->flags2 = oldFlags2;                player->mo = mo;                player->chickenTics = 2*35;                return(false);        }        playerNum = player-players;        if(playerNum != 0)        { // Set color translation                mo->flags |= playerNum<<MF_TRANSSHIFT;        }        mo->angle = angle;        mo->player = player;        mo->reactiontime = 18;        if(oldFlags2&MF2_FLY)        {                mo->flags2 |= MF2_FLY;                mo->flags |= MF_NOGRAVITY;        }        player->chickenTics = 0;        player->powers[pw_weaponlevel2] = 0;        player->weaponinfo = wpnlev1info;        player->health = mo->health = MAXHEALTH;        player->mo = mo;        angle >>= ANGLETOFINESHIFT;        fog = P_SpawnMobj(x+20*finecosine[angle],                y+20*finesine[angle], z+TELEFOGHEIGHT, MT_TFOG);        S_StartSound(fog, sfx_telept);        P_PostChickenWeapon(player, weapon);        return(true);}//// P_MoveCamera : make sure the camera is not outside the world//                and looks at the player avatar//camera_t camera;//#define VIEWCAM_DIST    (128<<FRACBITS)//#define VIEWCAM_HEIGHT  (20<<FRACBITS)consvar_t cv_cam_dist   = {"cam_dist"  ,"128"  ,CV_FLOAT,NULL};consvar_t cv_cam_height = {"cam_height", "20"   ,CV_FLOAT,NULL};consvar_t cv_cam_speed  = {"cam_speed" ,  "0.25",CV_FLOAT,NULL};void P_ResetCamera (player_t *player){    fixed_t             x;    fixed_t             y;    fixed_t             z;    camera.chase = true;    x = player->mo->x;    y = player->mo->y;    z = player->mo->z + (cv_viewheight.value<<FRACBITS);    // hey we should make sure that the sounds are heard from the camera    // instead of the marine's head : TO DO    // set bits for the camera    if (!camera.mo)        camera.mo = P_SpawnMobj (x,y,z, MT_CHASECAM);    else    {        camera.mo->x = x;        camera.mo->y = y;        camera.mo->z = z;    }    camera.mo->angle = player->mo->angle;    camera.aiming = 0;}boolean PTR_FindCameraPoint (intercept_t* in){/*    int         side;    fixed_t             slope;    fixed_t             dist;    line_t*             li;    li = in->d.line;    if ( !(li->flags & ML_TWOSIDED) )        return false;    // crosses a two sided line    //added:16-02-98: Fab comments : sets opentop, openbottom, openrange    //                lowfloor is the height of the lowest floor    //                         (be it front or back)    P_LineOpening (li);    dist = FixedMul (attackrange, in->frac);    if (li->frontsector->floorheight != li->backsector->floorheight)    {        //added:18-02-98: comments :        // find the slope aiming on the border between the two floors        slope = FixedDiv (openbottom - cameraz , dist);        if (slope > aimslope)            return false;    }    if (li->frontsector->ceilingheight != li->backsector->ceilingheight)    {        slope = FixedDiv (opentop - shootz , dist);        if (slope < aimslope)            goto hitline;    }    return true;    // hit line  hitline:*/    // stop the search    return false;}fixed_t cameraz;void P_MoveChaseCamera (player_t *player){    angle_t             angle;    fixed_t             x,y,z ,viewpointx,viewpointy;    fixed_t             dist;    mobj_t*             mo;    subsector_t*        newsubsec;    float               f1,f2;    if (!camera.mo)        P_ResetCamera (player);    mo = player->mo;    angle = mo->angle;    // sets ideal cam pos    dist  = cv_cam_dist.value;    x = mo->x - FixedMul( finecosine[(angle>>ANGLETOFINESHIFT) & FINEMASK], dist);    y = mo->y - FixedMul(   finesine[(angle>>ANGLETOFINESHIFT) & FINEMASK], dist);    z = mo->z + (cv_viewheight.value<<FRACBITS) + cv_cam_height.value;/*    P_PathTraverse ( mo->x, mo->y, x, y, PT_ADDLINES, PTR_UseTraverse );*/    // move camera down to move under lower ceilings    newsubsec = R_IsPointInSubsector ((mo->x + camera.mo->x)>>1,(mo->y + camera.mo->y)>>1);                  if (!newsubsec)    {        // use player sector         if (mo->subsector->sector->ceilingheight - camera.mo->height < z)            z = mo->subsector->sector->ceilingheight - camera.mo->height-11*FRACUNIT; // don't be blocked by a opened door    }    else    // camera fit ?    if (newsubsec->sector->ceilingheight - camera.mo->height < z)        // no fit        z = newsubsec->sector->ceilingheight - camera.mo->height-11*FRACUNIT;        // is the camera fit is there own sector    newsubsec = R_PointInSubsector (camera.mo->x,camera.mo->y);    if (newsubsec->sector->ceilingheight - camera.mo->height < z)        z = newsubsec->sector->ceilingheight - camera.mo->height-11*FRACUNIT;    // point viewed by the camera    // this point is just 64 unit forward the player    dist = 64 << FRACBITS;    viewpointx = mo->x + FixedMul( finecosine[(angle>>ANGLETOFINESHIFT) & FINEMASK], dist);    viewpointy = mo->y + FixedMul( finesine[(angle>>ANGLETOFINESHIFT) & FINEMASK], dist);    camera.mo->angle = R_PointToAngle2(camera.mo->x,camera.mo->y,                                       viewpointx  ,viewpointy);    // folow the player    camera.mo->momx = FixedMul(x - camera.mo->x,cv_cam_speed.value);    camera.mo->momy = FixedMul(y - camera.mo->y,cv_cam_speed.value);    camera.mo->momz = FixedMul(z - camera.mo->z,cv_cam_speed.value);    // compute aming to look the viewed point    f1=FIXED_TO_FLOAT(viewpointx-camera.mo->x);    f2=FIXED_TO_FLOAT(viewpointy-camera.mo->y);    dist=sqrt(f1*f1+f2*f2)*FRACUNIT;    angle=R_PointToAngle2(0,camera.mo->z, dist                         ,mo->z+(mo->height>>1)+finesine[(player->aiming>>ANGLETOFINESHIFT) & FINEMASK] * 64);    G_ClipAimingPitch(&angle);    dist=camera.aiming-angle;    camera.aiming-=(dist>>3);}byte weapontobutton[NUMWEAPONS]={wp_fist    <<BT_WEAPONSHIFT,                                 wp_pistol  <<BT_WEAPONSHIFT,                                 wp_shotgun <<BT_WEAPONSHIFT,                                 wp_chaingun<<BT_WEAPONSHIFT,                                 wp_missile <<BT_WEAPONSHIFT,                                 wp_plasma  <<BT_WEAPONSHIFT,                                 wp_bfg     <<BT_WEAPONSHIFT,                                (wp_fist    <<BT_WEAPONSHIFT) | BT_EXTRAWEAPON,// wp_chainsaw                                (wp_shotgun <<BT_WEAPONSHIFT) | BT_EXTRAWEAPON};//wp_supershotgun#ifdef CLIENTPREDICTION2void CL_ResetSpiritPosition(mobj_t *mobj){    P_UnsetThingPosition(mobj->player->spirit);    mobj->player->spirit->x=mobj->x;    mobj->player->spirit->y=mobj->y;    mobj->player->spirit->z=mobj->z;    mobj->player->spirit->momx=0;    mobj->player->spirit->momy=0;    mobj->player->spirit->momz=0;    mobj->player->spirit->angle=mobj->angle;    P_SetThingPosition(mobj->player->spirit);}void P_ProcessCmdSpirit (player_t* player,ticcmd_t *cmd){    fixed_t   movepushforward=0,movepushside=0;#ifdef PARANOIA    if(!player)        I_Error("P_MoveSpirit : player null");    if(!player->spirit)        I_Error("P_MoveSpirit : player->spirit null");    if(!cmd)        I_Error("P_MoveSpirit : cmd null");#endif    // don't move if dead    if( player->playerstate != PST_LIVE )    {        cmd->angleturn &= ~TICCMD_XY;        return;    }    onground = (player->spirit->z <= player->spirit->floorz) ||               (player->cheats & CF_FLYAROUND);    if (player->spirit->reactiontime)    {        player->spirit->reactiontime--;        return;    }    player->spirit->angle = cmd->angleturn<<16;    cmd->angleturn |= TICCMD_XY;/*    // now weapon is allways send change is detected at receiver side    if(cmd->buttons & BT_CHANGE)     {        player->spirit->movedir = cmd->buttons & (BT_WEAPONMASK | BT_EXTRAWEAPON);        cmd->buttons &=~BT_CHANGE;    }    else    {        if( player->pendingweapon!=wp_nochange )            player->spirit->movedir=weapontobutton[player->pendingweapon];        cmd->buttons&=~(BT_WEAPONMASK | BT_EXTRAWEAPON);        cmd->buttons|=player->spirit->movedir;    }*/    if (cmd->forwardmove)    {        movepushforward = cmd->forwardmove * movefactor;                if (player->spirit->eflags & MF_UNDERWATER)        {            // half forward speed when waist under water            // a little better grip if feets touch the ground            if (!onground)                movepushforward >>= 1;            else                movepushforward = movepushforward *3/4;        }        else        {            // allow very small movement while in air for gameplay            if (!onground)                movepushforward >>= 3;        }                P_ThrustSpirit (player->spirit, player->spirit->angle, movepushforward);    }        if (cmd->sidemove)    {        movepushside = cmd->sidemove * movefactor;        if (player->spirit->eflags & MF_UNDERWATER)        {            if (!onground)                movepushside >>= 1;            else                movepushside = movepushside *3/4;        }        else             if (!onground)                movepushside >>= 3;                    P_ThrustSpirit (player->spirit, player->spirit->angle-ANG90, movepushside);    }        // mouselook swim when waist underwater    player->spirit->eflags &= ~MF_SWIMMING;    if (player->spirit->eflags & MF_UNDERWATER)    {        fixed_t a;        // swim up/down full move when forward full speed        a = FixedMul( movepushforward*50, finesine[ (cmd->aiming>>(ANGLETOFINESHIFT-16)) ] >>5 );                if ( a != 0 ) {            player->spirit->eflags |= MF_SWIMMING;            player->spirit->momz += a;        }    }    //added:22-02-98: jumping    if (cmd->buttons & BT_JUMP)    {        // can't jump while in air, can't jump while jumping        if (!(player->jumpdown & 2) &&             (onground || (player->spirit->eflags & MF_UNDERWATER)) )        {            if (onground)                player->spirit->momz = JUMPGRAVITY;            else //water content                player->spirit->momz = JUMPGRAVITY/2;            //TODO: goub gloub when push up in water                        if ( !(player->cheats & CF_FLYAROUND) && onground && !(player->spirit->eflags & MF_UNDERWATER))            {#ifdef HW3SOUND                S_StartScreamSound(player->spirit, sfx_jump);#else                S_StartSound (player->spirit, sfx_jump);#endif                // keep jumping ok if FLY mode.                player->jumpdown |= 2;            }        }    }    else        player->jumpdown &= ~2;}void P_MoveSpirit (player_t* p,ticcmd_t *cmd, int realtics){    if( gamestate != GS_LEVEL )        return;    if(p->spirit)    {        extern boolean supdate;        int    i;        p->spirit->flags|=MF_SOLID;        for(i=0;i<realtics;i++)        {            P_ProcessCmdSpirit(p,cmd);            P_MobjThinker(p->spirit);        }                         p->spirit->flags&=~MF_SOLID;        P_CalcHeight (p);                 // z-bobing of player        A_TicWeapon(p, &p->psprites[0]);  // bobing of weapon        cmd->x=p->spirit->x;        cmd->y=p->spirit->y;        supdate=true;    }    else    if(p->mo)    {        cmd->x=p->mo->x;        cmd->y=p->mo->y;    }}#endif//// P_PlayerThink//boolean playerdeadview; //Fab:25-04-98:show dm rankings while in death viewvoid P_PlayerThink (player_t* player){    ticcmd_t*           cmd;    weapontype_t        newweapon;    int                 waterz;#ifdef PARANOIA    if(!player->mo) I_Error("p_playerthink : players[%d].mo == NULL",player-players);#endif    // fixme: do this in the cheat code    if (player->cheats & CF_NOCLIP)        player->mo->flags |= MF_NOCLIP;    else        player->mo->flags &= ~MF_NOCLIP;    // chain saw run forward    cmd = &player->cmd;    if (player->mo->flags & MF_JUSTATTACKED)    {// added : now angle turn is a absolute value not relative#ifndef ABSOLUTEANGLE        cmd->angleturn = 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -