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

Iskhodnyy_kod_Doom

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

if (target->player == &players[consoleplayer] && automapactive)

{

//don’t die in auto map,

//switch view prior to dying AM_Stop ();

}

}

if (target->health < -target->info->spawnhealth && target->info->xdeathstate)

{

P_SetMobjState (target, target->info->xdeathstate);

}

else

P_SetMobjState (target, target->info->deathstate); target->tics -= P_Random()&3;

if (target->tics < 1) target->tics = 1;

//I_StartSound (&actor->r, actor->info->deathsound);

//Drop stuff.

//This determines the kind of object spawned

//during the death frame of a thing.

switch (target->type)

 

{

 

 

case MT_WOLFSS:

 

case MT_POSSESSED:

 

item =

MT_CLIP;

 

break;

 

 

case MT_SHOTGUY:

 

item =

MT_SHOTGUN;

 

break;

 

 

case MT_CHAINGUY:

 

item =

MT_CHAINGUN;

 

break;

 

 

default:

 

 

return;

 

 

}

 

 

mo = P_SpawnMobj (target->x,target->y,ONFLOORZ, item);

mo->flags |= MF_DROPPED;

// special versions of items

}

//

//P_DamageMobj

//Damages both enemies and players

//"inflictor" is the thing that caused the damage

//creature or missile, can be NULL (slime, etc)

//"source" is the thing to target after taking damage

//creature or NULL

//Source and inflictor are the same for melee attacks.

//Source can be NULL for slime, barrel explosions

//and other environmental stuff.

//

431

void P_DamageMobj

(mobj_t* target, mobj_t* inflictor,

mobj_t*

source,

int

damage )

{

 

unsigned

ang;

int

saved;

player_t*

player;

fixed_t

thrust;

int

temp;

if ( !(target->flags & MF_SHOOTABLE) )

return;

// shouldn’t happen...

if (target->health <= 0) return;

if ( target->flags & MF_SKULLFLY )

{

target->momx = target->momy = target->momz = 0;

}

player = target->player;

if (player && gameskill == sk_baby)

damage >>= 1; // take half damage in trainer mode

//Some close combat weapons should not

//inflict thrust and push the victim out of reach,

//thus kick away unless using the chainsaw.

if (inflictor

&&!(target->flags & MF_NOCLIP)

&&(!source

||!source->player

||source->player->readyweapon != wp_chainsaw))

{

ang = R_PointToAngle2 ( inflictor->x, inflictor->y, target->x, target->y);

thrust = damage*(FRACUNIT>>3)*100/target->info->mass;

// make fall forwards sometimes if ( damage < 40

&&damage > target->health

&&target->z - inflictor->z > 64*FRACUNIT

&&(P_Random ()&1) )

{

ang += ANG180; thrust *= 4;

}

ang >>= ANGLETOFINESHIFT;

target->momx += FixedMul (thrust, finecosine[ang]); target->momy += FixedMul (thrust, finesine[ang]);

}

// player specific if (player)

{

// end of game hell hack

if (target->subsector->sector->special == 11

432

&& damage >= target->health)

{

damage = target->health - 1;

}

//Below certain threshold,

//ignore damage in GOD mode, or with INVUL power. if ( damage < 1000

&&( (player->cheats&CF_GODMODE)

||player->powers[pw_invulnerability] ) )

{

return;

}

if (player->armortype)

{

if (player->armortype == 1) saved = damage/3;

else

saved = damage/2;

if (player->armorpoints <= saved)

{

// armor is used up

saved = player->armorpoints; player->armortype = 0;

}

player->armorpoints -= saved; damage -= saved;

}

player->health -= damage; // mirror mobj health here for Dave if (player->health < 0)

player->health = 0;

player->attacker = source;

 

 

player->damagecount += damage;

//

add damage after armor / invuln

if (player->damagecount >

100)

 

 

player->damagecount =

100;

//

teleport stomp does 10k points...

temp = damage < 100 ? damage : 100;

if (player == &players[consoleplayer]) I_Tactile (40,10,40+temp*2);

}

// do the damage target->health -= damage; if (target->health <= 0)

{

P_KillMobj (source, target); return;

}

if ( (P_Random () < target->info->painchance) && !(target->flags&MF_SKULLFLY) )

{

 

target->flags |= MF_JUSTHIT;

// fight back!

P_SetMobjState (target, target->info->painstate);

}

 

target->reactiontime = 0;

// we’re awake now...

433

if ( (!target->threshold || target->type == MT_VILE)

&&source && source != target

&&source->type != MT_VILE)

{

//if not intent on another player,

//chase after this one

target->target = source; target->threshold = BASETHRESHOLD;

if (target->state == &states[target->info->spawnstate] && target->info->seestate != S_NULL) P_SetMobjState (target, target->info->seestate);

}

}

9.8p inter.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:

//

//

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

#ifndef __P_INTER__ #define __P_INTER__

#ifdef __GNUG__ #pragma interface #endif

boolean

P_GivePower(player_t*, int);

#endif

 

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

 

//

 

// $Log:$

 

//

 

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

 

9.9p lights.c

//

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

//

-----------------------------------------------------------------------------

434

//

//$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:

//Handle Sector base lighting effects.

//Muzzle flash?

//

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

static const char

rcsid[] = "$Id: p_lights.c,v 1.5 1997/02/03 22:45:11 b1 Exp $";

#include "z_zone.h" #include "m_random.h"

#include "doomdef.h" #include "p_local.h"

// State.

#include "r_state.h"

//

// FIRELIGHT FLICKER

//

//

// T_FireFlicker

//

void T_FireFlicker (fireflicker_t* flick)

{

int amount;

if (--flick->count) return;

amount = (P_Random()&3)*16;

if (flick->sector->lightlevel - amount < flick->minlight) flick->sector->lightlevel = flick->minlight;

else

flick->sector->lightlevel = flick->maxlight - amount;

flick->count = 4;

}

//

// P_SpawnFireFlicker

435

//

void P_SpawnFireFlicker (sector_t* sector)

{

fireflicker_t* flick;

//Note that we are resetting sector attributes.

//Nothing special about it during gameplay. sector->special = 0;

flick = Z_Malloc ( sizeof(*flick), PU_LEVSPEC, 0);

P_AddThinker (&flick->thinker);

flick->thinker.function.acp1 = (actionf_p1) T_FireFlicker; flick->sector = sector;

flick->maxlight = sector->lightlevel;

flick->minlight = P_FindMinSurroundingLight(sector,sector->lightlevel)+16; flick->count = 4;

}

//

// BROKEN LIGHT FLASHING

//

//

//T_LightFlash

//Do flashing lights.

void T_LightFlash (lightflash_t* flash)

{

if (--flash->count) return;

if (flash->sector->lightlevel == flash->maxlight)

{

flash-> sector->lightlevel = flash->minlight; flash->count = (P_Random()&flash->mintime)+1;

}

else

{

flash-> sector->lightlevel = flash->maxlight; flash->count = (P_Random()&flash->maxtime)+1;

}

}

//

//P_SpawnLightFlash

//After the map has been loaded, scan each sector

//for specials that spawn thinkers

//

void P_SpawnLightFlash (sector_t* sector)

{

lightflash_t* flash;

// nothing special about it during gameplay sector->special = 0;

flash = Z_Malloc ( sizeof(*flash), PU_LEVSPEC, 0);

436

sector,
fastOrSlow, inSync )
flash;

P_AddThinker (&flash->thinker);

flash->thinker.function.acp1 = (actionf_p1) T_LightFlash; flash->sector = sector;

flash->maxlight = sector->lightlevel;

flash->minlight = P_FindMinSurroundingLight(sector,sector->lightlevel); flash->maxtime = 64;

flash->mintime = 7;

flash->count = (P_Random()&flash->maxtime)+1;

}

//

// STROBE LIGHT FLASHING

//

//

// T_StrobeFlash

//

void T_StrobeFlash (strobe_t* flash)

{

if (--flash->count) return;

if (flash->sector->lightlevel == flash->minlight)

{

flash-> sector->lightlevel = flash->maxlight; flash->count = flash->brighttime;

}

else

{

flash-> sector->lightlevel = flash->minlight; flash->count =flash->darktime;

}

}

//

//P_SpawnStrobeFlash

//After the map has been loaded, scan each sector

//for specials that spawn thinkers

//

void P_SpawnStrobeFlash ( sector_t*

int int

{

strobe_t*

flash = Z_Malloc ( sizeof(*flash), PU_LEVSPEC, 0);

P_AddThinker (&flash->thinker);

flash->sector = sector; flash->darktime = fastOrSlow; flash->brighttime = STROBEBRIGHT;

flash->thinker.function.acp1 = (actionf_p1) T_StrobeFlash; flash->maxlight = sector->lightlevel;

437

flash->minlight = P_FindMinSurroundingLight(sector, sector->lightlevel);

if (flash->minlight == flash->maxlight) flash->minlight = 0;

// nothing special about it during gameplay sector->special = 0;

if (!inSync)

flash->count = (P_Random()&7)+1;

else

flash->count = 1;

}

//

// Start strobing lights (usually from a trigger)

//

void EV_StartLightStrobing(line_t* line)

{

int

secnum;

sector_t*

sec;

secnum = -1;

while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0)

{

sec = &sectors[secnum]; if (sec->specialdata)

continue;

P_SpawnStrobeFlash (sec,SLOWDARK, 0);

}

}

//

// TURN LINE’S TAG LIGHTS OFF

//

void EV_TurnTagLightsOff(line_t* line)

{

int

i;

int

j;

int

min;

sector_t*

sector;

sector_t*

tsec;

line_t*

templine;

sector = sectors;

 

for (j = 0;j < numsectors; j++, sector++)

{

if (sector->tag == line->tag)

{

min = sector->lightlevel;

for (i = 0;i < sector->linecount; i++)

{

templine = sector->lines[i];

tsec = getNextSector(templine,sector); if (!tsec)

continue;

if (tsec->lightlevel < min) min = tsec->lightlevel;

}

sector->lightlevel = min;

438

}

}

}

//

// TURN LINE’S TAG LIGHTS ON

//

 

void

 

EV_LightTurnOn

 

( line_t*

line,

int

bright )

{

 

int

i;

int

j;

sector_t*

sector;

sector_t*

temp;

line_t*

templine;

sector = sectors;

for (i=0;i<numsectors;i++, sector++)

{

if (sector->tag == line->tag)

{

//bright = 0 means to search

//for highest light level

//surrounding sector

if (!bright)

{

for (j = 0;j < sector->linecount; j++)

{

templine = sector->lines[j];

temp = getNextSector(templine,sector);

if (!temp)

continue;

if (temp->lightlevel > bright) bright = temp->lightlevel;

}

}

sector-> lightlevel = bright;

}

}

}

 

//

 

// Spawn glowing light

 

//

 

void T_Glow(glow_t*

g)

{

 

switch(g->direction)

 

{

 

case -1:

 

// DOWN

 

g->sector->lightlevel -= GLOWSPEED;

if (g->sector->lightlevel <= g->minlight)

{

g->sector->lightlevel += GLOWSPEED; g->direction = 1;

}

break;

439

case 1:

// UP

g->sector->lightlevel += GLOWSPEED;

if (g->sector->lightlevel >= g->maxlight)

{

g->sector->lightlevel -= GLOWSPEED; g->direction = -1;

}

break;

}

}

 

 

void P_SpawnGlowingLight(sector_t*

sector)

{

 

 

glow_t*

g;

 

g = Z_Malloc( sizeof(*g), PU_LEVSPEC, 0);

P_AddThinker(&g->thinker);

g->sector = sector;

g->minlight = P_FindMinSurroundingLight(sector,sector->lightlevel); g->maxlight = sector->lightlevel;

g->thinker.function.acp1 = (actionf_p1) T_Glow; g->direction = -1;

sector->special = 0;

}

9.10p local.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:

//Play functions, animation, global header.

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

#ifndef __P_LOCAL__ #define __P_LOCAL__

#ifndef __R_LOCAL__ #include "r_local.h" #endif

#define FLOATSPEED

(FRACUNIT*4)

440

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