Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Iskhodnyy_kod_Doom

.pdf
Скачиваний:
7
Добавлен:
13.02.2015
Размер:
1.01 Mб
Скачать

( player_t*

player,

pspdef_t*

psp )

{

 

P_SetMobjState (player->mo, S_PLAY_ATK2);

P_SetPsprite (player,ps_flash,weaponinfo[player->readyweapon].flashstate);

}

 

//

 

// WEAPON ATTACKS

 

//

 

//

 

// A_Punch

 

//

 

void

 

A_Punch

 

( player_t*

player,

pspdef_t*

psp )

{

 

angle_t

angle;

int

damage;

int

slope;

damage = (P_Random ()%10+1)<<1;

if (player->powers[pw_strength]) damage *= 10;

angle = player->mo->angle;

angle += (P_Random()-P_Random())<<18;

slope = P_AimLineAttack (player->mo, angle, MELEERANGE); P_LineAttack (player->mo, angle, MELEERANGE, slope, damage);

// turn to face target if (linetarget)

{

S_StartSound (player->mo, sfx_punch); player->mo->angle = R_PointToAngle2 (player->mo->x,

player->mo->y, linetarget->x, linetarget->y);

}

}

 

//

 

// A_Saw

 

//

 

void

 

A_Saw

 

( player_t*

player,

pspdef_t*

psp )

{

 

angle_t

angle;

int

damage;

int

slope;

damage = 2*(P_Random ()%10+1); angle = player->mo->angle;

angle += (P_Random()-P_Random())<<18;

// use meleerange + 1 se the puff doesn’t skip the flash

511

slope = P_AimLineAttack (player->mo, angle, MELEERANGE+1); P_LineAttack (player->mo, angle, MELEERANGE+1, slope, damage);

if (!linetarget)

{

S_StartSound (player->mo, sfx_sawful); return;

}

S_StartSound (player->mo, sfx_sawhit);

// turn to face target

angle = R_PointToAngle2 (player->mo->x, player->mo->y, linetarget->x, linetarget->y);

if (angle - player->mo->angle > ANG180)

{

if (angle - player->mo->angle < -ANG90/20) player->mo->angle = angle + ANG90/21;

else

player->mo->angle -= ANG90/20;

}

else

{

if (angle - player->mo->angle > ANG90/20) player->mo->angle = angle - ANG90/21;

else

player->mo->angle += ANG90/20;

}

player->mo->flags |= MF_JUSTATTACKED;

}

//

 

// A_FireMissile

 

//

 

void

 

A_FireMissile

 

( player_t*

player,

pspdef_t*

psp )

{

 

player->ammo[weaponinfo[player->readyweapon].ammo]--; P_SpawnPlayerMissile (player->mo, MT_ROCKET);

}

//

 

// A_FireBFG

 

//

 

void

 

A_FireBFG

 

( player_t*

player,

pspdef_t*

psp )

{

 

player->ammo[weaponinfo[player->readyweapon].ammo] -= BFGCELLS; P_SpawnPlayerMissile (player->mo, MT_BFG);

}

//

// A_FirePlasma

//

void A_FirePlasma

( player_t* player,

512

pspdef_t*

psp )

{

player->ammo[weaponinfo[player->readyweapon].ammo]--;

P_SetPsprite (player,

ps_flash,

weaponinfo[player->readyweapon].flashstate+(P_Random ()&1) );

P_SpawnPlayerMissile (player->mo, MT_PLASMA);

}

//

//P_BulletSlope

//Sets a slope so a near miss is at aproximately

//the height of the intended target

//

 

 

fixed_t

bulletslope;

 

void P_BulletSlope

(mobj_t*

mo)

{

 

 

angle_t

an;

 

// see which target is to be aimed at an = mo->angle;

bulletslope = P_AimLineAttack (mo, an, 16*64*FRACUNIT);

if (!linetarget)

{

an += 1<<26;

bulletslope = P_AimLineAttack (mo, an, 16*64*FRACUNIT); if (!linetarget)

{

an -= 2<<26;

bulletslope = P_AimLineAttack (mo, an, 16*64*FRACUNIT);

}

}

}

 

//

 

// P_GunShot

 

//

 

void

 

P_GunShot

 

( mobj_t*

mo,

boolean

accurate )

{

 

angle_t

angle;

int

damage;

damage = 5*(P_Random ()%3+1); angle = mo->angle;

if (!accurate)

angle += (P_Random()-P_Random())<<18;

P_LineAttack (mo, angle, MISSILERANGE, bulletslope, damage);

}

//

// A_FirePistol

513

//

 

void

 

A_FirePistol

 

( player_t*

player,

pspdef_t*

psp )

{

 

S_StartSound (player->mo, sfx_pistol);

P_SetMobjState (player->mo, S_PLAY_ATK2); player->ammo[weaponinfo[player->readyweapon].ammo]--;

P_SetPsprite (player,

ps_flash,

weaponinfo[player->readyweapon].flashstate);

P_BulletSlope (player->mo);

P_GunShot (player->mo, !player->refire);

}

 

//

 

// A_FireShotgun

 

//

 

void

 

A_FireShotgun

 

( player_t*

player,

pspdef_t*

psp )

{

 

int

i;

S_StartSound (player->mo, sfx_shotgn);

P_SetMobjState (player->mo, S_PLAY_ATK2);

player->ammo[weaponinfo[player->readyweapon].ammo]--;

P_SetPsprite (player,

ps_flash,

weaponinfo[player->readyweapon].flashstate);

P_BulletSlope (player->mo);

for (i=0 ; i<7 ; i++)

P_GunShot (player->mo, false);

}

 

//

 

// A_FireShotgun2

 

//

 

void

 

A_FireShotgun2

 

( player_t*

player,

pspdef_t*

psp )

{

 

int

i;

angle_t

angle;

int

damage;

S_StartSound (player->mo, sfx_dshtgn);

P_SetMobjState (player->mo, S_PLAY_ATK2);

player->ammo[weaponinfo[player->readyweapon].ammo]-=2;

514

P_SetPsprite (player,

ps_flash,

weaponinfo[player->readyweapon].flashstate);

P_BulletSlope (player->mo);

for (i=0 ; i<20 ; i++)

{

damage = 5*(P_Random ()%3+1); angle = player->mo->angle;

angle += (P_Random()-P_Random())<<19; P_LineAttack (player->mo,

 

angle,

 

MISSILERANGE,

 

bulletslope + ((P_Random()-P_Random())<<5), damage);

}

 

}

 

//

 

// A_FireCGun

 

//

 

void

 

A_FireCGun

 

( player_t*

player,

pspdef_t*

psp )

{

 

S_StartSound (player->mo, sfx_pistol);

if (!player->ammo[weaponinfo[player->readyweapon].ammo]) return;

P_SetMobjState (player->mo, S_PLAY_ATK2); player->ammo[weaponinfo[player->readyweapon].ammo]--;

P_SetPsprite (player,

ps_flash,

weaponinfo[player->readyweapon].flashstate + psp->state

- &states[S_CHAIN1] );

P_BulletSlope (player->mo);

P_GunShot (player->mo, !player->refire);

}

//

// ?

//

void A_Light0 (player_t *player, pspdef_t *psp)

{

player->extralight = 0;

}

void A_Light1 (player_t *player, pspdef_t *psp)

{

player->extralight = 1;

}

void A_Light2 (player_t *player, pspdef_t *psp)

{

player->extralight = 2;

}

515

//

//A_BFGSpray

//Spawn a BFG explosion on every monster in view

void A_BFGSpray (mobj_t* mo)

{

int

i;

int

j;

int

damage;

angle_t

an;

// offset angles from its attack angle for (i=0 ; i<40 ; i++)

{

an = mo->angle - ANG90/2 + ANG90/40*i;

//mo->target is the originator (player)

//of the missile

P_AimLineAttack (mo->target, an, 16*64*FRACUNIT);

if (!linetarget) continue;

P_SpawnMobj (linetarget->x,

linetarget->y,

linetarget->z + (linetarget->height>>2), MT_EXTRABFG);

damage = 0;

for (j=0;j<15;j++)

damage += (P_Random()&7) + 1;

P_DamageMobj (linetarget, mo->target,mo->target, damage);

}

}

//

 

// A_BFGsound

 

//

 

void

 

A_BFGsound

 

( player_t*

player,

pspdef_t*

psp )

{

 

S_StartSound (player->mo, sfx_bfg);

}

//

//P_SetupPsprites

//Called at start of level for each player.

void P_SetupPsprites (player_t* player)

{

int

i;

//

remove all psprites

for (i=0

; i<NUMPSPRITES ; i++)

 

player->psprites[i].state = NULL;

//

spawn

the gun

516

player->pendingweapon = player->readyweapon; P_BringUpWeapon (player);

}

//

//P_MovePsprites

//Called every tic by player thinking routine.

void P_MovePsprites (player_t* player)

{

int

i;

pspdef_t*

psp;

state_t*

state;

psp = &player->psprites[0];

for (i=0 ; i<NUMPSPRITES ; i++, psp++)

{

// a null state means not active if ( (state = psp->state) )

{

//drop tic count and possibly change state

//a -1 tic count never changes

if (psp->tics != -1)

{

psp->tics--;

if (!psp->tics)

P_SetPsprite (player, i, psp->state->nextstate);

}

}

}

player->psprites[ps_flash].sx = player->psprites[ps_weapon].sx; player->psprites[ps_flash].sy = player->psprites[ps_weapon].sy;

}

9.17p pspr.h

// Emacs style mode select -*- C++ -*- //-----------------------------------------------------------------------------

//

//$Id:$

//Copyright (C) 1993-1996 by id Software, Inc.

//This program is free software; you can redistribute it and/or

//modify it under the terms of the GNU General Public License

//as published by the Free Software Foundation; either version 2

//of the License, or (at your option) any later version.

//

//This program is distributed in the hope that it will be useful,

//but WITHOUT ANY WARRANTY; without even the implied warranty of

//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

//GNU General Public License for more details.

//

//DESCRIPTION:

//Sprite animation.

//-----------------------------------------------------------------------------

517

#ifndef __P_PSPR__ #define __P_PSPR__

//Basic data types.

//Needs fixed point, and BAM angles. #include "m_fixed.h"

#include "tables.h"

//

//Needs to include the precompiled

//sprite animation tables.

//Header generated by multigen utility.

//This includes all the data for thing animation,

//i.e. the Thing Atrributes table

//and the Frame Sequence table.

#include "info.h"

#ifdef __GNUG__ #pragma interface #endif

//

//Frame flags:

//handles maximum brightness (torches, muzzle flare, light sources)

#define

FF_FULLBRIGHT

0x8000

// flag in thing->frame

#define

FF_FRAMEMASK

0x7fff

 

//

//Overlay psprites are scaled shapes

//drawn directly on the view screen,

//coordinates are given for a 320*200 view screen.

typedef enum

{

ps_weapon, ps_flash, NUMPSPRITES

} psprnum_t;

 

 

typedef struct

 

 

{

 

 

state_t*

state;

// a NULL state means not active

int

tics;

 

fixed_t

sx;

 

fixed_t

sy;

 

} pspdef_t;

 

 

#endif

 

 

//-----------------------------------------------------------------------------

 

 

//

 

 

// $Log:$

 

 

//

 

 

//-----------------------------------------------------------------------------

 

 

9.18p saveg.c

// Emacs style mode select -*- C++ -*-

518

//-----------------------------------------------------------------------------

//

//$Id:$

//Copyright (C) 1993-1996 by id Software, Inc.

//This program is free software; you can redistribute it and/or

//modify it under the terms of the GNU General Public License

//as published by the Free Software Foundation; either version 2

//of the License, or (at your option) any later version.

//

//This program is distributed in the hope that it will be useful,

//but WITHOUT ANY WARRANTY; without even the implied warranty of

//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

//GNU General Public License for more details.

//

//$Log:$

//DESCRIPTION:

//Archiving: SaveGame I/O.

//-----------------------------------------------------------------------------

static const char

rcsid[] = "$Id: p_tick.c,v 1.4 1997/02/03 16:47:55 b1 Exp $";

#include "i_system.h" #include "z_zone.h" #include "p_local.h"

// State.

#include "doomstat.h" #include "r_state.h"

byte* save_p;

//Pads save_p to a 4-byte boundary

//so that the load/save works on SGI&Gecko.

#define PADSAVEP()

save_p += (4 - ((int) save_p & 3)) & 3

//

// P_ArchivePlayers

//

void P_ArchivePlayers (void)

{

int

i;

int

j;

player_t*

dest;

for (i=0 ; i<MAXPLAYERS ; i++)

{

if (!playeringame[i]) continue;

PADSAVEP();

dest =

(player_t *)save_p;

memcpy

(dest,&players[i],sizeof(player_t));

save_p

+= sizeof(player_t);

for (j=0 ; j<NUMPSPRITES ; j++)

{

 

if

(dest->psprites[j].state)

519

{

dest->psprites[j].state

= (state_t *)(dest->psprites[j].state-states);

}

}

}

}

//

// P_UnArchivePlayers

//

void P_UnArchivePlayers (void)

{

 

int

i;

int

j;

for (i=0 ; i<MAXPLAYERS ; i++)

{

if (!playeringame[i])

continue;

PADSAVEP();

memcpy (&players[i],save_p, sizeof(player_t)); save_p += sizeof(player_t);

// will be set when unarc thinker players[i].mo = NULL; players[i].message = NULL; players[i].attacker = NULL;

for (j=0 ; j<NUMPSPRITES ; j++)

{

if (players[i]. psprites[j].state)

{

players[i]. psprites[j].state

= &states[ (int)players[i].psprites[j].state ];

}

}

}

}

 

//

 

// P_ArchiveWorld

 

//

 

void P_ArchiveWorld (void)

 

{

 

int

i;

int

j;

sector_t*

sec;

line_t*

li;

side_t*

si;

short*

put;

put = (short *)save_p;

 

// do sectors

for (i=0, sec = sectors ; i<numsectors ; i++,sec++)

{

*put++ = sec->floorheight >> FRACBITS; *put++ = sec->ceilingheight >> FRACBITS; *put++ = sec->floorpic;

520

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]