コード例 #1
0
ファイル: p_mobj.c プロジェクト: jaguar64/samples
void P_SpawnPlayer (mapthing_t *mthing)
{
    player_t	*p;
    fixed_t		x,y,z;
    mobj_t		*mobj;
    int	i;

    if (!playeringame[mthing->type-1])
        return;						/* not playing */

    p = &players[mthing->type-1];

    if (p->playerstate == PST_REBORN)
        G_PlayerReborn (mthing->type-1);

    x = mthing->x << FRACBITS;
    y = mthing->y << FRACBITS;
#if 0
    if (mthing->type==1)
    {
        x = 0xffb00000;
        y = 0xff500000;
    }
#endif
    z = ONFLOORZ;
    mobj = P_SpawnMobj (x,y,z, MT_PLAYER);

    mobj->angle = ANG45 * (mthing->angle/45);

    mobj->player = p;
    mobj->health = p->health;
    p->mo = mobj;
    p->playerstate = PST_LIVE;
    p->refire = 0;
    p->message = NULL;
    p->damagecount = 0;
    p->bonuscount = 0;
    p->extralight = 0;
    p->fixedcolormap = 0;
    p->viewheight = VIEWHEIGHT;
    P_SetupPsprites (p);		/* setup gun psprite	 */

    if (netgame == gt_deathmatch)
        for (i=0 ; i<NUMCARDS ; i++)
            p->cards[i] = true;		/* give all cards in death match mode			 */
}
コード例 #2
0
//
// P_SpawnPlayer
// Called when a player is spawned on the level.
// Most of the player structure stays unchanged
//	between levels.
//
void P_SpawnPlayer (player_t &player, mapthing2_t *mthing)
{
    // denis - clients should not control spawning
    if(!serverside)
        return;

    // [RH] Things 4001-? are also multiplayer starts. Just like 1-4.
    //		To make things simpler, figure out which player is being
    //		spawned here.
    player_t *p = &player;

    // not playing?
    if(!p->ingame())
        return;

    if (p->playerstate == PST_REBORN || p->playerstate == PST_ENTER)
        G_PlayerReborn (*p);

    AActor *mobj = new AActor (mthing->x << FRACBITS, mthing->y << FRACBITS, ONFLOORZ, MT_PLAYER);

    // set color translations for player sprites
    // [RH] Different now: MF_TRANSLATION is not used.
    //		  mobj->translation = translationtables + 256*playernum;

    mobj->angle = ANG45 * (mthing->angle/45);
    mobj->pitch = mobj->roll = 0;
    mobj->player = p;
    mobj->health = p->health;

    // [RH] Set player sprite based on skin
    if(p->userinfo.skin >= numskins)
        p->userinfo.skin = 0;

    mobj->sprite = skins[p->userinfo.skin].sprite;

    p->fov = 90.0f;
    p->mo = p->camera = mobj->ptr();
    p->playerstate = PST_LIVE;
    p->refire = 0;
    p->damagecount = 0;
    p->bonuscount = 0;
    p->extralight = 0;
    p->fixedcolormap = 0;
    p->viewheight = VIEWHEIGHT;
    p->xviewshift = 0;
    p->attacker = AActor::AActorPtr();

    // Set up some special spectator stuff
    if (p->spectator)
    {
        mobj->translucency = 0;
        p->mo->flags |= MF_SPECTATOR;
        p->mo->flags2 |= MF2_FLY;
    }

    // [RH] Allow chasecam for demo watching
    //if ((demoplayback || demonew) && chasedemo)
    //	p->cheats = CF_CHASECAM;

    // setup gun psprite
    P_SetupPsprites (p);

    // give all cards in death match mode
    if (sv_gametype != GM_COOP)
    {
        for (int i = 0; i < NUMCARDS; i++)
            p->cards[i] = true;
    }

    if(serverside)
    {
        // [RH] If someone is in the way, kill them
        P_TeleportMove (mobj, mobj->x, mobj->y, mobj->z, true);

        // [BC] Do script stuff
        if (level.behavior != NULL)
        {
            if (p->playerstate == PST_ENTER)
            {
                level.behavior->StartTypedScripts (SCRIPT_Enter, p->mo);
            }
            else if (p->playerstate == PST_REBORN)
            {
                level.behavior->StartTypedScripts (SCRIPT_Respawn, p->mo);
            }
        }

        // send new objects
        SV_SpawnMobj(mobj);
    }
}
コード例 #3
0
ファイル: g_game.c プロジェクト: GhostlyDeath/chocolate-doom
void G_InitPlayer(int player)
{
    // clear everything else to defaults
    G_PlayerReborn(player);
}