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

Iskhodnyy_kod_Doom

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

// !deathmatch

 

 

static

boolean

 

st_fragson;

// main bar left

 

 

static

patch_t*

 

sbar;

// 0-9, tall numbers

 

static

patch_t*

 

tallnum[10];

// tall % sign

 

 

static

patch_t*

 

tallpercent;

// 0-9, short, yellow (,different!) numbers

static

patch_t*

 

shortnum[10];

// 3 key-cards, 3 skulls

 

static

patch_t*

 

keys[NUMCARDS];

// face status patches

 

static

patch_t*

 

faces[ST_NUMFACES];

// face background

 

 

static

patch_t*

 

faceback;

// main bar right

 

 

static

patch_t*

 

armsbg;

// weapon ownership patches

static

patch_t*

 

arms[6][2];

// ready-weapon widget

 

static

st_number_t

 

w_ready;

// in

deathmatch only, summary of frags stats

static

st_number_t

 

w_frags;

// health widget

 

 

static

st_percent_t

w_health;

// arms background

 

 

static

st_binicon_t

w_armsbg;

// weapon ownership widgets

static

st_multicon_t

w_arms[6];

// face status widget

 

static

st_multicon_t

w_faces;

// keycard widgets

 

 

static

st_multicon_t

w_keyboxes[3];

// armor widget

 

 

static

st_percent_t

w_armor;

// ammo widgets

 

 

static

st_number_t

 

w_ammo[4];

// max

ammo widgets

 

static

st_number_t

 

w_maxammo[4];

// number of frags so far in deathmatch

static

int

st_fragscount;

741

// used to

use appopriately pained face

static int

 

st_oldhealth

= -1;

// used for evil grin

 

static boolean

oldweaponsowned[NUMWEAPONS];

// count until face changes

 

static int

 

st_facecount

= 0;

// current

face index, used by

w_faces

static int

 

st_faceindex

= 0;

// holds key-type for each key

box on bar

static int

 

keyboxes[3];

 

// a random number per tick

 

static int

 

st_randomnumber;

//Massive bunches of cheat shit

//to keep it from being easy to figure them out.

//Yeah, right...

unsigned char cheat_mus_seq[] =

{

0xb2, 0x26, 0xb6, 0xae, 0xea, 1, 0, 0, 0xff

};

 

 

unsigned char

cheat_choppers_seq[] =

{

 

 

0xb2, 0x26, 0xe2, 0x32, 0xf6, 0x2a, 0x2a, 0xa6, 0x6a, 0xea, 0xff // id...

};

 

 

unsigned char

cheat_god_seq[] =

 

{

 

 

0xb2, 0x26, 0x26, 0xaa, 0x26, 0xff

// iddqd

};

 

 

unsigned char

cheat_ammo_seq[] =

 

{

 

 

0xb2, 0x26, 0xf2, 0x66, 0xa2, 0xff

// idkfa

};

 

 

unsigned char

cheat_ammonokey_seq[] =

{

 

 

0xb2, 0x26, 0x66, 0xa2, 0xff

// idfa

};

 

 

// Smashing Pumpkins Into Samml Piles Of Putried Debris. unsigned char cheat_noclip_seq[] =

{

0xb2,

0x26,

0xea,

0x2a,

0xb2,

// idspispopd

0xea,

0x2a,

0xf6,

0x2a,

0x26,

0xff

};

//

unsigned char cheat_commercial_noclip_seq[] =

{

0xb2, 0x26, 0xe2, 0x36, 0xb2, 0x2a, 0xff

// idclip

};

742

unsigned char

cheat_powerup_seq[7][10] =

 

 

{

 

 

 

{ 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0x6e, 0xff },

// beholdv

{ 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xea, 0xff },

// beholds

{ 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xb2, 0xff },

// beholdi

{ 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0x6a, 0xff },

// beholdr

{ 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xa2, 0xff },

// beholda

{ 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0x36, 0xff },

// beholdl

{ 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xff }

// behold

};

 

 

 

unsigned char

cheat_clev_seq[] =

 

 

{

 

 

 

0xb2, 0x26,

0xe2, 0x36, 0xa6, 0x6e, 1, 0, 0, 0xff

// idclev

 

};

 

 

 

// my position cheat

 

 

unsigned char

cheat_mypos_seq[] =

 

 

{

 

 

 

0xb2, 0x26, 0xb6, 0xba, 0x2a, 0xf6, 0xea, 0xff

// idmypos

 

};

 

 

 

// Now what?

 

 

 

cheatseq_t

cheat_mus = { cheat_mus_seq, 0 };

 

 

cheatseq_t

cheat_god = { cheat_god_seq, 0 };

 

 

cheatseq_t

cheat_ammo = { cheat_ammo_seq, 0 };

 

 

cheatseq_t

cheat_ammonokey = { cheat_ammonokey_seq, 0 };

 

cheatseq_t

cheat_noclip = { cheat_noclip_seq, 0 };

 

 

cheatseq_t

cheat_commercial_noclip = { cheat_commercial_noclip_seq, 0 };

cheatseq_t

cheat_powerup[7] =

 

 

{

 

 

 

{cheat_powerup_seq[0], 0 },

{cheat_powerup_seq[1], 0 },

{cheat_powerup_seq[2], 0 },

{cheat_powerup_seq[3], 0 },

{cheat_powerup_seq[4], 0 },

{cheat_powerup_seq[5], 0 },

{cheat_powerup_seq[6], 0 }

};

cheatseq_t cheatseq_t cheatseq_t

cheat_choppers = { cheat_choppers_seq, 0 }; cheat_clev = { cheat_clev_seq, 0 }; cheat_mypos = { cheat_mypos_seq, 0 };

//

 

extern char*

mapnames[];

//

// STATUS BAR CODE

//

void ST_Stop(void);

void ST_refreshBackground(void)

{

if (st_statusbaron)

{

V_DrawPatch(ST_X, 0, BG, sbar);

743

if (netgame)

V_DrawPatch(ST_FX, 0, BG, faceback);

V_CopyRect(ST_X, 0, BG, ST_WIDTH, ST_HEIGHT, ST_X, ST_Y, FG);

}

}

//Respond to keyboard input events,

//intercept cheats.

boolean

ST_Responder (event_t* ev)

{

int i;

// Filter automap on/off. if (ev->type == ev_keyup

&& ((ev->data1 & 0xffff0000) == AM_MSGHEADER))

{

switch(ev->data1)

{

case AM_MSGENTERED: st_gamestate = AutomapState; st_firsttime = true;

break;

case AM_MSGEXITED:

// fprintf(stderr, "AM exited\n"); st_gamestate = FirstPersonState;

break;

}

}

// if a user keypress...

else if (ev->type == ev_keydown)

{

if (!netgame)

{

//b. - enabled for more debug fun.

//if (gameskill != sk_nightmare) {

//’dqd’ cheat for toggleable god mode

if (cht_CheckCheat(&cheat_god, ev->data1))

{

plyr->cheats ^= CF_GODMODE;

if (plyr->cheats & CF_GODMODE)

{

if (plyr->mo) plyr->mo->health = 100;

plyr->health = 100; plyr->message = STSTR_DQDON;

}

else

plyr->message = STSTR_DQDOFF;

}

// ’fa’ cheat for killer fucking arsenal

else if (cht_CheckCheat(&cheat_ammonokey, ev->data1))

{

plyr->armorpoints = 200; plyr->armortype = 2;

for (i=0;i<NUMWEAPONS;i++) plyr->weaponowned[i] = true;

744

for (i=0;i<NUMAMMO;i++) plyr->ammo[i] = plyr->maxammo[i];

plyr->message = STSTR_FAADDED;

}

// ’kfa’ cheat for key full ammo

else if (cht_CheckCheat(&cheat_ammo, ev->data1))

{

plyr->armorpoints = 200; plyr->armortype = 2;

for (i=0;i<NUMWEAPONS;i++) plyr->weaponowned[i] = true;

for (i=0;i<NUMAMMO;i++) plyr->ammo[i] = plyr->maxammo[i];

for (i=0;i<NUMCARDS;i++) plyr->cards[i] = true;

plyr->message = STSTR_KFAADDED;

}

// ’mus’ cheat for changing music

else if (cht_CheckCheat(&cheat_mus, ev->data1))

{

char

buf[3];

int

musnum;

plyr->message = STSTR_MUS; cht_GetParam(&cheat_mus, buf);

if (gamemode == commercial)

{

musnum = mus_runnin + (buf[0]-’0’)*10 + buf[1]-’0’ - 1;

if (((buf[0]-’0’)*10 + buf[1]-’0’) > 35) plyr->message = STSTR_NOMUS;

else

S_ChangeMusic(musnum, 1);

}

else

{

musnum = mus_e1m1 + (buf[0]-’1’)*9 + (buf[1]-’1’);

if (((buf[0]-’1’)*9 + buf[1]-’1’) > 31) plyr->message = STSTR_NOMUS;

else

S_ChangeMusic(musnum, 1);

}

}

//Simplified, accepting both "noclip" and "idspispopd".

//no clipping mode cheat

else if ( cht_CheckCheat(&cheat_noclip, ev->data1)

|| cht_CheckCheat(&cheat_commercial_noclip,ev->data1) )

{

plyr->cheats ^= CF_NOCLIP;

if (plyr->cheats & CF_NOCLIP) plyr->message = STSTR_NCON;

else

plyr->message = STSTR_NCOFF;

}

// ’behold?’ power-up cheats

745

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

{

if (cht_CheckCheat(&cheat_powerup[i], ev->data1))

{

if (!plyr->powers[i]) P_GivePower( plyr, i);

else if (i!=pw_strength) plyr->powers[i] = 1;

else

plyr->powers[i] = 0;

plyr->message = STSTR_BEHOLDX;

}

}

// ’behold’ power-up menu

if (cht_CheckCheat(&cheat_powerup[6], ev->data1))

{

plyr->message = STSTR_BEHOLD;

}

// ’choppers’ invulnerability & chainsaw

else if (cht_CheckCheat(&cheat_choppers, ev->data1))

{

plyr->weaponowned[wp_chainsaw] = true; plyr->powers[pw_invulnerability] = true; plyr->message = STSTR_CHOPPERS;

}

// ’mypos’ for player position

else if (cht_CheckCheat(&cheat_mypos, ev->data1))

{

static char buf[ST_MSGWIDTH];

sprintf(buf, "ang=0x%x;x,y=(0x%x,0x%x)", players[consoleplayer].mo->angle,

players[consoleplayer].mo->x, players[consoleplayer].mo->y);

plyr->message = buf;

}

}

// ’clev’ change-level cheat

if (cht_CheckCheat(&cheat_clev, ev->data1))

{

char

buf[3];

int

epsd;

int

map;

cht_GetParam(&cheat_clev, buf);

if (gamemode == commercial)

{

epsd = 0;

map = (buf[0] - ’0’)*10 + buf[1] - ’0’;

}

else

{

epsd = buf[0] - ’0’; map = buf[1] - ’0’;

}

// Catch invalid maps. if (epsd < 1)

return false;

if (map < 1) return false;

746

// Ohmygod - this is not going to work. if ((gamemode == retail)

&& ((epsd > 4) || (map > 9))) return false;

if ((gamemode == registered)

&& ((epsd > 3) || (map > 9))) return false;

if ((gamemode == shareware)

&& ((epsd > 1) || (map > 9))) return false;

if ((gamemode == commercial)

&& (( epsd > 1) || (map > 34))) return false;

// So be it.

plyr->message = STSTR_CLEV; G_DeferedInitNew(gameskill, epsd, map);

}

}

return false;

}

int ST_calcPainOffset(void)

{

int

health;

static int

lastcalc;

static int

oldhealth = -1;

health = plyr->health > 100 ? 100 : plyr->health;

if (health != oldhealth)

{

lastcalc = ST_FACESTRIDE * (((100 - health) * ST_NUMPAINFACES) / 101); oldhealth = health;

}

return lastcalc;

}

//

//This is a not-very-pretty routine which handles

//the face states and their timing.

//the precedence of expressions is:

//dead > evil grin > turned head > straight ahead

void ST_updateFaceWidget(void)

{

int

 

i;

angle_t

 

badguyangle;

angle_t

 

diffang;

static

int

lastattackdown = -1;

static

int

priority = 0;

boolean

 

doevilgrin;

if (priority < 10)

{

 

 

//

dead

 

if

(!plyr->health)

{

 

 

747

priority = 9;

st_faceindex = ST_DEADFACE; st_facecount = 1;

}

}

if (priority < 9)

{

if (plyr->bonuscount)

{

// picking up bonus doevilgrin = false;

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

{

if (oldweaponsowned[i] != plyr->weaponowned[i])

{

doevilgrin = true;

oldweaponsowned[i] = plyr->weaponowned[i];

}

}

if (doevilgrin)

{

// evil grin if just picked up weapon priority = 8;

st_facecount = ST_EVILGRINCOUNT;

st_faceindex = ST_calcPainOffset() + ST_EVILGRINOFFSET;

}

}

}

if (priority < 8)

{

if (plyr->damagecount

&&plyr->attacker

&&plyr->attacker != plyr->mo)

{

// being attacked priority = 7;

if (plyr->health - st_oldhealth > ST_MUCHPAIN)

{

st_facecount = ST_TURNCOUNT;

st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET;

}

else

{

badguyangle = R_PointToAngle2(plyr->mo->x, plyr->mo->y, plyr->attacker->x, plyr->attacker->y);

if (badguyangle > plyr->mo->angle)

{

// whether right or left

diffang = badguyangle - plyr->mo->angle; i = diffang > ANG180;

}

else

{

// whether left or right

diffang = plyr->mo->angle - badguyangle; i = diffang <= ANG180;

} // confusing, aint it?

748

st_facecount = ST_TURNCOUNT; st_faceindex = ST_calcPainOffset();

if (diffang < ANG45)

{

// head-on

st_faceindex += ST_RAMPAGEOFFSET;

}

else if (i)

{

// turn face right st_faceindex += ST_TURNOFFSET;

}

else

{

// turn face left

st_faceindex += ST_TURNOFFSET+1;

}

}

}

}

if (priority < 7)

{

// getting hurt because of your own damn stupidity if (plyr->damagecount)

{

if (plyr->health - st_oldhealth > ST_MUCHPAIN)

{

priority = 7;

st_facecount = ST_TURNCOUNT;

st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET;

}

else

{

priority = 6;

st_facecount = ST_TURNCOUNT;

st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET;

}

}

}

if (priority < 6)

{

// rapid firing

if (plyr->attackdown)

{

if (lastattackdown==-1) lastattackdown = ST_RAMPAGEDELAY;

else if (!--lastattackdown)

{

priority = 5;

st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET; st_facecount = 1;

lastattackdown = 1;

}

}

else

lastattackdown = -1;

}

749

if (priority < 5)

{

// invulnerability

if ((plyr->cheats & CF_GODMODE)

|| plyr->powers[pw_invulnerability])

{

priority = 4;

st_faceindex = ST_GODFACE; st_facecount = 1;

}

}

// look left or look right if the facecount has timed out if (!st_facecount)

{

st_faceindex = ST_calcPainOffset() + (st_randomnumber % 3); st_facecount = ST_STRAIGHTFACECOUNT;

priority = 0;

}

st_facecount--;

}

void ST_updateWidgets(void)

{

static int

largeammo = 1994; // means "n/a"

int

i;

//must redirect the pointer if the ready weapon has changed.

//if (w_ready.data != plyr->readyweapon)

//{

if (weaponinfo[plyr->readyweapon].ammo == am_noammo) w_ready.num = &largeammo;

else

w_ready.num = &plyr->ammo[weaponinfo[plyr->readyweapon].ammo];

//{

//static int tic=0;

//static int dir=-1;

//if (!(tic&15))

//plyr->ammo[weaponinfo[plyr->readyweapon].ammo]+=dir;

//if (plyr->ammo[weaponinfo[plyr->readyweapon].ammo] == -100)

//dir = 1;

//tic++;

//}

w_ready.data = plyr->readyweapon;

//if (*w_ready.on)

//STlib_updateNum(&w_ready, true);

//refresh weapon change

//}

//update keycard multiple widgets for (i=0;i<3;i++)

{

keyboxes[i] = plyr->cards[i] ? i : -1;

if (plyr->cards[i+3]) keyboxes[i] = i+3;

}

750

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