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

📄 a_action.c

📁 使用Doom引擎开发的著名游戏《毁灭巫师》的源代码。
💻 C
📖 第 1 页 / 共 3 页
字号:
//**************************************************************************//**//** a_action.c : Heretic 2 : Raven Software, Corp.//**//** $RCSfile: a_action.c,v $//** $Revision: 1.86 $//** $Date: 96/03/22 13:15:33 $//** $Author: bgokey $//**//**************************************************************************// HEADER FILES ------------------------------------------------------------#include "h2def.h"#include "p_local.h"#include "soundst.h"// MACROS ------------------------------------------------------------------// TYPES -------------------------------------------------------------------// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------// EXTERNAL DATA DECLARATIONS ----------------------------------------------extern fixed_t FloatBobOffsets[64];// PUBLIC DATA DEFINITIONS -------------------------------------------------int orbitTableX[256]={983025, 982725, 981825, 980340, 978255, 975600, 972330, 968490,964065, 959070, 953475, 947325, 940590, 933300, 925440, 917025,908055, 898545, 888495, 877905, 866775, 855135, 842985, 830310,817155, 803490, 789360, 774735, 759660, 744120, 728130, 711690,694845, 677565, 659880, 641805, 623340, 604500, 585285, 565725,545820, 525600, 505050, 484200, 463065, 441645, 419955, 398010,375840, 353430, 330810, 307995, 285000, 261825, 238485, 215010,191400, 167685, 143865, 119955, 95970, 71940, 47850, 23745,-375, -24495, -48600, -72690, -96720, -120705, -144600, -168420,-192150, -215745, -239220, -262545, -285720, -308715, -331530, -354135,-376530, -398700, -420630, -442320, -463725, -484860, -505695, -526230,-546450, -566340, -585885, -605085, -623925, -642375, -660435, -678105,-695370, -712215, -728625, -744600, -760125, -775200, -789795, -803925,-817575, -830715, -843375, -855510, -867135, -878235, -888810, -898845,-908340, -917295, -925695, -933540, -940815, -947520, -953670, -959235,-964215, -968625, -972450, -975690, -978330, -980400, -981870, -982740,-983025, -982725, -981825, -980340, -978255, -975600, -972330, -968490,-964065, -959070, -953475, -947325, -940590, -933300, -925440, -917025,-908055, -898545, -888495, -877905, -866775, -855135, -842985, -830310,-817155, -803490, -789360, -774735, -759660, -744120, -728130, -711690,-694845, -677565, -659880, -641805, -623340, -604485, -585285, -565725,-545820, -525600, -505050, -484200, -463065, -441645, -419955, -398010,-375840, -353430, -330810, -307995, -285000, -261825, -238485, -215010,-191400, -167685, -143865, -119955, -95970, -71940, -47850, -23745,375, 24495, 48600, 72690, 96720, 120705, 144600, 168420,192150, 215745, 239220, 262545, 285720, 308715, 331530, 354135,376530, 398700, 420630, 442320, 463725, 484860, 505695, 526230,546450, 566340, 585885, 605085, 623925, 642375, 660435, 678105,695370, 712215, 728625, 744600, 760125, 775200, 789795, 803925,817575, 830715, 843375, 855510, 867135, 878235, 888810, 898845,908340, 917295, 925695, 933540, 940815, 947520, 953670, 959235,964215, 968625, 972450, 975690, 978330, 980400, 981870, 982740};int orbitTableY[256]={375, 24495, 48600, 72690, 96720, 120705, 144600, 168420,192150, 215745, 239220, 262545, 285720, 308715, 331530, 354135,376530, 398700, 420630, 442320, 463725, 484860, 505695, 526230,546450, 566340, 585885, 605085, 623925, 642375, 660435, 678105,695370, 712215, 728625, 744600, 760125, 775200, 789795, 803925,817575, 830715, 843375, 855510, 867135, 878235, 888810, 898845,908340, 917295, 925695, 933540, 940815, 947520, 953670, 959235,964215, 968625, 972450, 975690, 978330, 980400, 981870, 982740,983025, 982725, 981825, 980340, 978255, 975600, 972330, 968490,964065, 959070, 953475, 947325, 940590, 933300, 925440, 917025,908055, 898545, 888495, 877905, 866775, 855135, 842985, 830310,817155, 803490, 789360, 774735, 759660, 744120, 728130, 711690,694845, 677565, 659880, 641805, 623340, 604500, 585285, 565725,545820, 525600, 505050, 484200, 463065, 441645, 419955, 398010,375840, 353430, 330810, 307995, 285000, 261825, 238485, 215010,191400, 167685, 143865, 119955, 95970, 71940, 47850, 23745,-375, -24495, -48600, -72690, -96720, -120705, -144600, -168420,-192150, -215745, -239220, -262545, -285720, -308715, -331530, -354135,-376530, -398700, -420630, -442320, -463725, -484860, -505695, -526230,-546450, -566340, -585885, -605085, -623925, -642375, -660435, -678105,-695370, -712215, -728625, -744600, -760125, -775200, -789795, -803925,-817575, -830715, -843375, -855510, -867135, -878235, -888810, -898845,-908340, -917295, -925695, -933540, -940815, -947520, -953670, -959235,-964215, -968625, -972450, -975690, -978330, -980400, -981870, -982740,-983025, -982725, -981825, -980340, -978255, -975600, -972330, -968490,-964065, -959070, -953475, -947325, -940590, -933300, -925440, -917025,-908055, -898545, -888495, -877905, -866775, -855135, -842985, -830310,-817155, -803490, -789360, -774735, -759660, -744120, -728130, -711690,-694845, -677565, -659880, -641805, -623340, -604485, -585285, -565725,-545820, -525600, -505050, -484200, -463065, -441645, -419955, -398010,-375840, -353430, -330810, -307995, -285000, -261825, -238485, -215010,-191400, -167685, -143865, -119955, -95970, -71940, -47850, -23745};// PRIVATE DATA DEFINITIONS ------------------------------------------------// CODE --------------------------------------------------------------------//--------------------------------------------------------------------------//// Environmental Action routines////--------------------------------------------------------------------------//==========================================================================//// A_DripBlood////==========================================================================/*void A_DripBlood(mobj_t *actor){	mobj_t *mo;	mo = P_SpawnMobj(actor->x+((P_Random()-P_Random())<<11),		actor->y+((P_Random()-P_Random())<<11), actor->z, MT_BLOOD);	mo->momx = (P_Random()-P_Random())<<10;	mo->momy = (P_Random()-P_Random())<<10;	mo->flags2 |= MF2_LOGRAV;}*///============================================================================//// A_PotteryExplode////============================================================================void A_PotteryExplode(mobj_t *actor){	mobj_t *mo=NULL;	int i;	for(i = (P_Random()&3)+3; i; i--)	{		mo = P_SpawnMobj(actor->x, actor->y, actor->z, MT_POTTERYBIT1);		P_SetMobjState(mo, mo->info->spawnstate+(P_Random()%5));		if(mo)		{			mo->momz = ((P_Random()&7)+5)*(3*FRACUNIT/4);			mo->momx = (P_Random()-P_Random())<<(FRACBITS-6);			mo->momy = (P_Random()-P_Random())<<(FRACBITS-6);		}	}	S_StartSound(mo, SFX_POTTERY_EXPLODE);	if(actor->args[0])	{ // Spawn an item		if(!nomonsters 		|| !(mobjinfo[TranslateThingType[actor->args[0]]].flags&MF_COUNTKILL))		{ // Only spawn monsters if not -nomonsters			P_SpawnMobj(actor->x, actor->y, actor->z,				TranslateThingType[actor->args[0]]);		}	}	P_RemoveMobj(actor);}//============================================================================//// A_PotteryChooseBit////============================================================================void A_PotteryChooseBit(mobj_t *actor){	P_SetMobjState(actor, actor->info->deathstate+(P_Random()%5)+1);	actor->tics = 256+(P_Random()<<1);}//============================================================================//// A_PotteryCheck////============================================================================void A_PotteryCheck(mobj_t *actor){	int i;	mobj_t *pmo;	if(!netgame)	{		pmo = players[consoleplayer].mo;		if(P_CheckSight(actor, pmo) && (abs(R_PointToAngle2(pmo->x,			pmo->y, actor->x, actor->y)-pmo->angle) <= ANGLE_45))		{ // Previous state (pottery bit waiting state)			P_SetMobjState(actor, actor->state-&states[0]-1);		}		else		{			return;		}	}	else	{		for(i = 0; i < MAXPLAYERS; i++)		{			if(!playeringame[i])			{				continue;			}			pmo = players[i].mo;			if(P_CheckSight(actor, pmo) && (abs(R_PointToAngle2(pmo->x,				pmo->y, actor->x, actor->y)-pmo->angle) <= ANGLE_45))			{ // Previous state (pottery bit waiting state)				P_SetMobjState(actor, actor->state-&states[0]-1);				return;			}		}	}		}//============================================================================//// A_CorpseBloodDrip////============================================================================void A_CorpseBloodDrip(mobj_t *actor){	if(P_Random() > 128)	{		return;	}	P_SpawnMobj(actor->x, actor->y, actor->z+actor->height/2, 		MT_CORPSEBLOODDRIP);}//============================================================================//// A_CorpseExplode////============================================================================void A_CorpseExplode(mobj_t *actor){	mobj_t *mo;	int i;	for(i = (P_Random()&3)+3; i; i--)	{		mo = P_SpawnMobj(actor->x, actor->y, actor->z, MT_CORPSEBIT);		P_SetMobjState(mo, mo->info->spawnstate+(P_Random()%3));		if(mo)		{			mo->momz = ((P_Random()&7)+5)*(3*FRACUNIT/4);			mo->momx = (P_Random()-P_Random())<<(FRACBITS-6);			mo->momy = (P_Random()-P_Random())<<(FRACBITS-6);		}	}	// Spawn a skull	mo = P_SpawnMobj(actor->x, actor->y, actor->z, MT_CORPSEBIT);	P_SetMobjState(mo, S_CORPSEBIT_4);	if(mo)	{		mo->momz = ((P_Random()&7)+5)*(3*FRACUNIT/4);		mo->momx = (P_Random()-P_Random())<<(FRACBITS-6);		mo->momy = (P_Random()-P_Random())<<(FRACBITS-6);		S_StartSound(mo, SFX_FIRED_DEATH);	}	P_RemoveMobj(actor);}//============================================================================//// A_LeafSpawn////============================================================================void A_LeafSpawn(mobj_t *actor){	mobj_t *mo;	int i;	for(i = (P_Random()&3)+1; i; i--)	{		mo = P_SpawnMobj(actor->x+((P_Random()-P_Random())<<14), actor->y+			((P_Random()-P_Random())<<14), actor->z+(P_Random()<<14), 			MT_LEAF1+(P_Random()&1));		if(mo)		{			P_ThrustMobj(mo, actor->angle, (P_Random()<<9)+3*FRACUNIT);			mo->target = actor;			mo->special1 = 0;		}	}}//============================================================================//// A_LeafThrust////============================================================================void A_LeafThrust(mobj_t *actor){	if(P_Random() > 96)	{		return;	}	actor->momz += (P_Random()<<9)+FRACUNIT;}//============================================================================//// A_LeafCheck////============================================================================void A_LeafCheck(mobj_t *actor){	actor->special1++;	if(actor->special1 >= 20)	{		P_SetMobjState(actor, S_NULL);		return;	}	if(P_Random() > 64)	{		if(!actor->momx && !actor->momy)		{			P_ThrustMobj(actor, actor->target->angle,				(P_Random()<<9)+FRACUNIT);		}		return;	}	P_SetMobjState(actor, S_LEAF1_8);	actor->momz = (P_Random()<<9)+FRACUNIT;	P_ThrustMobj(actor, actor->target->angle, (P_Random()<<9)+2*FRACUNIT);	actor->flags |= MF_MISSILE;}/*#define ORBIT_RADIUS	(15*FRACUNIT)void GenerateOrbitTable(void){	int angle;	for (angle=0; angle<256; angle++)	{		orbitTableX[angle] = FixedMul(ORBIT_RADIUS, finecosine[angle<<5]);		orbitTableY[angle] = FixedMul(ORBIT_RADIUS, finesine[angle<<5]);	}	printf("int orbitTableX[256]=\n{\n");	for (angle=0; angle<256; angle+=8)	{		printf("%d, %d, %d, %d, %d, %d, %d, %d,\n",			orbitTableX[angle],			orbitTableX[angle+1],			orbitTableX[angle+2],			orbitTableX[angle+3],			orbitTableX[angle+4],			orbitTableX[angle+5],			orbitTableX[angle+6],			orbitTableX[angle+7]);	}	printf("};\n\n");	printf("int orbitTableY[256]=\n{\n");	for (angle=0; angle<256; angle+=8)	{		printf("%d, %d, %d, %d, %d, %d, %d, %d,\n",			orbitTableY[angle],			orbitTableY[angle+1],			orbitTableY[angle+2],			orbitTableY[angle+3],			orbitTableY[angle+4],			orbitTableY[angle+5],			orbitTableY[angle+6],			orbitTableY[angle+7]);	}	printf("};\n");}*/// New bridge stuff//	Parent//		special1	true == removing from world////	Child//		target		pointer to center mobj//		args[0]		angle of ballvoid A_BridgeOrbit(mobj_t *actor){	if (actor->target->special1)	{		P_SetMobjState(actor, S_NULL);	}	actor->args[0]+=3;	actor->x = actor->target->x + orbitTableX[actor->args[0]];	actor->y = actor->target->y + orbitTableY[actor->args[0]];	actor->z = actor->target->z;}void A_BridgeInit(mobj_t *actor){	byte startangle;	mobj_t *ball1, *ball2, *ball3;	fixed_t cx,cy,cz;//	GenerateOrbitTable();	cx = actor->x;	cy = actor->y;	cz = actor->z;	startangle = P_Random();	actor->special1 = 0;	// Spawn triad into world	ball1 = P_SpawnMobj(cx, cy, cz, MT_BRIDGEBALL);	ball1->args[0] = startangle;	ball1->target = actor;	ball2 = P_SpawnMobj(cx, cy, cz, MT_BRIDGEBALL);	ball2->args[0] = (startangle+85)&255;	ball2->target = actor;	ball3 = P_SpawnMobj(cx, cy, cz, MT_BRIDGEBALL);	ball3->args[0] = (startangle+170)&255;	ball3->target = actor;	A_BridgeOrbit(ball1);	A_BridgeOrbit(ball2);	A_BridgeOrbit(ball3);}

⌨️ 快捷键说明

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