亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? g_utils.c

?? 著名游戲quake2原代碼最新版本(vc6.0可以編譯的)
?? C
字號:
/*
Copyright (C) 1997-2001 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.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

*/
// g_utils.c -- misc utility functions for game module

#include "g_local.h"


void G_ProjectSource (vec3_t point, vec3_t distance, vec3_t forward, vec3_t right, vec3_t result)
{
	result[0] = point[0] + forward[0] * distance[0] + right[0] * distance[1];
	result[1] = point[1] + forward[1] * distance[0] + right[1] * distance[1];
	result[2] = point[2] + forward[2] * distance[0] + right[2] * distance[1] + distance[2];
}


/*
=============
G_Find

Searches all active entities for the next one that holds
the matching string at fieldofs (use the FOFS() macro) in the structure.

Searches beginning at the edict after from, or the beginning if NULL
NULL will be returned if the end of the list is reached.

=============
*/
edict_t *G_Find (edict_t *from, int fieldofs, char *match)
{
	char	*s;

	if (!from)
		from = g_edicts;
	else
		from++;

	for ( ; from < &g_edicts[globals.num_edicts] ; from++)
	{
		if (!from->inuse)
			continue;
		s = *(char **) ((byte *)from + fieldofs);
		if (!s)
			continue;
		if (!Q_stricmp (s, match))
			return from;
	}

	return NULL;
}


/*
=================
findradius

Returns entities that have origins within a spherical area

findradius (origin, radius)
=================
*/
edict_t *findradius (edict_t *from, vec3_t org, float rad)
{
	vec3_t	eorg;
	int		j;

	if (!from)
		from = g_edicts;
	else
		from++;
	for ( ; from < &g_edicts[globals.num_edicts]; from++)
	{
		if (!from->inuse)
			continue;
		if (from->solid == SOLID_NOT)
			continue;
		for (j=0 ; j<3 ; j++)
			eorg[j] = org[j] - (from->s.origin[j] + (from->mins[j] + from->maxs[j])*0.5);
		if (VectorLength(eorg) > rad)
			continue;
		return from;
	}

	return NULL;
}


/*
=============
G_PickTarget

Searches all active entities for the next one that holds
the matching string at fieldofs (use the FOFS() macro) in the structure.

Searches beginning at the edict after from, or the beginning if NULL
NULL will be returned if the end of the list is reached.

=============
*/
#define MAXCHOICES	8

edict_t *G_PickTarget (char *targetname)
{
	edict_t	*ent = NULL;
	int		num_choices = 0;
	edict_t	*choice[MAXCHOICES];

	if (!targetname)
	{
		gi.dprintf("G_PickTarget called with NULL targetname\n");
		return NULL;
	}

	while(1)
	{
		ent = G_Find (ent, FOFS(targetname), targetname);
		if (!ent)
			break;
		choice[num_choices++] = ent;
		if (num_choices == MAXCHOICES)
			break;
	}

	if (!num_choices)
	{
		gi.dprintf("G_PickTarget: target %s not found\n", targetname);
		return NULL;
	}

	return choice[rand() % num_choices];
}



void Think_Delay (edict_t *ent)
{
	G_UseTargets (ent, ent->activator);
	G_FreeEdict (ent);
}

/*
==============================
G_UseTargets

the global "activator" should be set to the entity that initiated the firing.

If self.delay is set, a DelayedUse entity will be created that will actually
do the SUB_UseTargets after that many seconds have passed.

Centerprints any self.message to the activator.

Search for (string)targetname in all entities that
match (string)self.target and call their .use function

==============================
*/
void G_UseTargets (edict_t *ent, edict_t *activator)
{
	edict_t		*t;

//
// check for a delay
//
	if (ent->delay)
	{
	// create a temp object to fire at a later time
		t = G_Spawn();
		t->classname = "DelayedUse";
		t->nextthink = level.time + ent->delay;
		t->think = Think_Delay;
		t->activator = activator;
		if (!activator)
			gi.dprintf ("Think_Delay with no activator\n");
		t->message = ent->message;
		t->target = ent->target;
		t->killtarget = ent->killtarget;
		return;
	}
	
	
//
// print the message
//
	if ((ent->message) && !(activator->svflags & SVF_MONSTER))
	{
		gi.centerprintf (activator, "%s", ent->message);
		if (ent->noise_index)
			gi.sound (activator, CHAN_AUTO, ent->noise_index, 1, ATTN_NORM, 0);
		else
			gi.sound (activator, CHAN_AUTO, gi.soundindex ("misc/talk1.wav"), 1, ATTN_NORM, 0);
	}

//
// kill killtargets
//
	if (ent->killtarget)
	{
		t = NULL;
		while ((t = G_Find (t, FOFS(targetname), ent->killtarget)))
		{
			G_FreeEdict (t);
			if (!ent->inuse)
			{
				gi.dprintf("entity was removed while using killtargets\n");
				return;
			}
		}
	}

//	gi.dprintf("TARGET: activating %s\n", ent->target);

//
// fire targets
//
	if (ent->target)
	{
		t = NULL;
		while ((t = G_Find (t, FOFS(targetname), ent->target)))
		{
			// doors fire area portals in a specific way
			if (!Q_stricmp(t->classname, "func_areaportal") &&
				(!Q_stricmp(ent->classname, "func_door") || !Q_stricmp(ent->classname, "func_door_rotating")))
				continue;

			if (t == ent)
			{
				gi.dprintf ("WARNING: Entity used itself.\n");
			}
			else
			{
				if (t->use)
					t->use (t, ent, activator);
			}
			if (!ent->inuse)
			{
				gi.dprintf("entity was removed while using targets\n");
				return;
			}
		}
	}
}


/*
=============
TempVector

This is just a convenience function
for making temporary vectors for function calls
=============
*/
float	*tv (float x, float y, float z)
{
	static	int		index;
	static	vec3_t	vecs[8];
	float	*v;

	// use an array so that multiple tempvectors won't collide
	// for a while
	v = vecs[index];
	index = (index + 1)&7;

	v[0] = x;
	v[1] = y;
	v[2] = z;

	return v;
}


/*
=============
VectorToString

This is just a convenience function
for printing vectors
=============
*/
char	*vtos (vec3_t v)
{
	static	int		index;
	static	char	str[8][32];
	char	*s;

	// use an array so that multiple vtos won't collide
	s = str[index];
	index = (index + 1)&7;

	Com_sprintf (s, 32, "(%i %i %i)", (int)v[0], (int)v[1], (int)v[2]);

	return s;
}


vec3_t VEC_UP		= {0, -1, 0};
vec3_t MOVEDIR_UP	= {0, 0, 1};
vec3_t VEC_DOWN		= {0, -2, 0};
vec3_t MOVEDIR_DOWN	= {0, 0, -1};

void G_SetMovedir (vec3_t angles, vec3_t movedir)
{
	if (VectorCompare (angles, VEC_UP))
	{
		VectorCopy (MOVEDIR_UP, movedir);
	}
	else if (VectorCompare (angles, VEC_DOWN))
	{
		VectorCopy (MOVEDIR_DOWN, movedir);
	}
	else
	{
		AngleVectors (angles, movedir, NULL, NULL);
	}

	VectorClear (angles);
}


float vectoyaw (vec3_t vec)
{
	float	yaw;
	
	if (/* vec[YAW] == 0 && */ vec[PITCH] == 0) 
	{
		yaw = 0;
		if (vec[YAW] > 0)
			yaw = 90;
		else if (vec[YAW] < 0)
			yaw = -90;
	}
	else
	{
		yaw = (int) (atan2(vec[YAW], vec[PITCH]) * 180 / M_PI);
		if (yaw < 0)
			yaw += 360;
	}

	return yaw;
}


void vectoangles (vec3_t value1, vec3_t angles)
{
	float	forward;
	float	yaw, pitch;
	
	if (value1[1] == 0 && value1[0] == 0)
	{
		yaw = 0;
		if (value1[2] > 0)
			pitch = 90;
		else
			pitch = 270;
	}
	else
	{
		if (value1[0])
			yaw = (int) (atan2(value1[1], value1[0]) * 180 / M_PI);
		else if (value1[1] > 0)
			yaw = 90;
		else
			yaw = -90;
		if (yaw < 0)
			yaw += 360;

		forward = sqrt (value1[0]*value1[0] + value1[1]*value1[1]);
		pitch = (int) (atan2(value1[2], forward) * 180 / M_PI);
		if (pitch < 0)
			pitch += 360;
	}

	angles[PITCH] = -pitch;
	angles[YAW] = yaw;
	angles[ROLL] = 0;
}

char *G_CopyString (char *in)
{
	char	*out;
	
	out = gi.TagMalloc (strlen(in)+1, TAG_LEVEL);
	strcpy (out, in);
	return out;
}


void G_InitEdict (edict_t *e)
{
	e->inuse = true;
	e->classname = "noclass";
	e->gravity = 1.0;
	e->s.number = e - g_edicts;
}

/*
=================
G_Spawn

Either finds a free edict, or allocates a new one.
Try to avoid reusing an entity that was recently freed, because it
can cause the client to think the entity morphed into something else
instead of being removed and recreated, which can cause interpolated
angles and bad trails.
=================
*/
edict_t *G_Spawn (void)
{
	int			i;
	edict_t		*e;

	e = &g_edicts[(int)maxclients->value+1];
	for ( i=maxclients->value+1 ; i<globals.num_edicts ; i++, e++)
	{
		// the first couple seconds of server time can involve a lot of
		// freeing and allocating, so relax the replacement policy
		if (!e->inuse && ( e->freetime < 2 || level.time - e->freetime > 0.5 ) )
		{
			G_InitEdict (e);
			return e;
		}
	}
	
	if (i == game.maxentities)
		gi.error ("ED_Alloc: no free edicts");
		
	globals.num_edicts++;
	G_InitEdict (e);
	return e;
}

/*
=================
G_FreeEdict

Marks the edict as free
=================
*/
void G_FreeEdict (edict_t *ed)
{
	gi.unlinkentity (ed);		// unlink from world

	if ((ed - g_edicts) <= (maxclients->value + BODY_QUEUE_SIZE))
	{
//		gi.dprintf("tried to free special edict\n");
		return;
	}

	memset (ed, 0, sizeof(*ed));
	ed->classname = "freed";
	ed->freetime = level.time;
	ed->inuse = false;
}


/*
============
G_TouchTriggers

============
*/
void	G_TouchTriggers (edict_t *ent)
{
	int			i, num;
	edict_t		*touch[MAX_EDICTS], *hit;

	// dead things don't activate triggers!
	if ((ent->client || (ent->svflags & SVF_MONSTER)) && (ent->health <= 0))
		return;

	num = gi.BoxEdicts (ent->absmin, ent->absmax, touch
		, MAX_EDICTS, AREA_TRIGGERS);

	// be careful, it is possible to have an entity in this
	// list removed before we get to it (killtriggered)
	for (i=0 ; i<num ; i++)
	{
		hit = touch[i];
		if (!hit->inuse)
			continue;
		if (!hit->touch)
			continue;
		hit->touch (hit, ent, NULL, NULL);
	}
}

/*
============
G_TouchSolids

Call after linking a new trigger in during gameplay
to force all entities it covers to immediately touch it
============
*/
void	G_TouchSolids (edict_t *ent)
{
	int			i, num;
	edict_t		*touch[MAX_EDICTS], *hit;

	num = gi.BoxEdicts (ent->absmin, ent->absmax, touch
		, MAX_EDICTS, AREA_SOLID);

	// be careful, it is possible to have an entity in this
	// list removed before we get to it (killtriggered)
	for (i=0 ; i<num ; i++)
	{
		hit = touch[i];
		if (!hit->inuse)
			continue;
		if (ent->touch)
			ent->touch (hit, ent, NULL, NULL);
		if (!ent->inuse)
			break;
	}
}




/*
==============================================================================

Kill box

==============================================================================
*/

/*
=================
KillBox

Kills all entities that would touch the proposed new positioning
of ent.  Ent should be unlinked before calling this!
=================
*/
qboolean KillBox (edict_t *ent)
{
	trace_t		tr;

	while (1)
	{
		tr = gi.trace (ent->s.origin, ent->mins, ent->maxs, ent->s.origin, NULL, MASK_PLAYERSOLID);
		if (!tr.ent)
			break;

		// nail it
		T_Damage (tr.ent, ent, ent, vec3_origin, ent->s.origin, vec3_origin, 100000, 0, DAMAGE_NO_PROTECTION, MOD_TELEFRAG);

		// if we didn't kill it, fail
		if (tr.ent->solid)
			return false;
	}

	return true;		// all clear
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美久久久影院| 成人综合在线网站| 悠悠色在线精品| 亚洲国产激情av| 中文字幕精品—区二区四季| 欧美激情在线免费观看| 亚洲国产精品99久久久久久久久| 国产精品色一区二区三区| 国产精品日产欧美久久久久| 中文字幕中文字幕中文字幕亚洲无线| 国产女同互慰高潮91漫画| 国产精品久久久久一区二区三区共| 国产亲近乱来精品视频| 亚洲欧美另类图片小说| 香蕉久久一区二区不卡无毒影院| 日本网站在线观看一区二区三区| 精品一区二区成人精品| 懂色av噜噜一区二区三区av| 色综合视频一区二区三区高清| 欧美影视一区在线| 精品第一国产综合精品aⅴ| 国产精品嫩草影院com| 亚洲激情在线播放| 美女视频一区在线观看| 成人精品视频一区二区三区| 在线观看日韩一区| 久久色.com| 亚洲欧美日本韩国| 精品一区中文字幕| 99视频精品全部免费在线| 欧美日韩综合色| 久久品道一品道久久精品| 亚洲夂夂婷婷色拍ww47| 国产剧情一区在线| 欧美丝袜自拍制服另类| 国产欧美精品一区aⅴ影院| 亚洲第一电影网| 国产成a人亚洲精品| 欧美丝袜第三区| 中文字幕二三区不卡| 秋霞午夜av一区二区三区 | 色婷婷国产精品综合在线观看| 欧美日韩在线三区| 国产精品视频免费看| 美腿丝袜亚洲三区| 91国产精品成人| 日本一区二区三级电影在线观看| 天堂蜜桃一区二区三区| 99国产精品久久久久久久久久| 欧美一区二区成人| 伊人婷婷欧美激情| www.爱久久.com| 欧美精品一区二区三区很污很色的| 亚洲午夜一二三区视频| 91原创在线视频| 欧美激情一区二区在线| 精品亚洲成a人在线观看| 欧美日韩一区二区三区不卡| 亚洲啪啪综合av一区二区三区| 丁香激情综合五月| 精品少妇一区二区三区在线视频| 性感美女久久精品| 欧美揉bbbbb揉bbbbb| 亚洲激情综合网| 色综合天天综合在线视频| 亚洲国产精品av| 国产成人免费视频网站| 久久久国际精品| 久久国产乱子精品免费女| 日韩一级免费一区| 日韩欧美国产一区二区三区| 99免费精品在线| 麻豆91在线看| 精品1区2区3区| 亚洲一区二区三区四区在线观看 | 国产毛片一区二区| 精品88久久久久88久久久| 蜜臀av一级做a爰片久久| 3d动漫精品啪啪一区二区竹菊| 亚洲一区av在线| 欧美美女bb生活片| 日本欧美韩国一区三区| 精品久久久久久久人人人人传媒| 久久99最新地址| 久久这里只有精品首页| 成人av在线一区二区| 亚洲蜜臀av乱码久久精品蜜桃| 91精品福利在线| 视频一区欧美精品| xnxx国产精品| 成人sese在线| 亚洲精品国久久99热| 69久久99精品久久久久婷婷| 日本一区中文字幕| 久久久久久电影| 一本大道久久a久久综合| 五月激情综合婷婷| 久久综合久久99| 99久久er热在这里只有精品15| 亚洲一区二区免费视频| 日韩欧美在线一区二区三区| 风间由美一区二区三区在线观看| 亚洲视频免费看| 日韩一区二区免费在线观看| 成人ar影院免费观看视频| 亚洲国产毛片aaaaa无费看 | 亚洲品质自拍视频网站| 日韩一区二区三区精品视频| 不卡的av在线| 日本女优在线视频一区二区| 中文字幕第一区二区| 欧美日本一区二区三区四区| 国产高清在线精品| 香蕉加勒比综合久久| 日本一区二区久久| 91麻豆精品国产91久久久久久久久 | 91香蕉视频mp4| 青青国产91久久久久久| 成人免费在线视频观看| 日韩欧美资源站| 91亚洲国产成人精品一区二三 | 成人丝袜高跟foot| 美女一区二区三区| 亚洲午夜影视影院在线观看| 日本一区二区成人在线| 日韩免费看网站| 欧美色图12p| 色综合久久久网| 国产伦精品一区二区三区视频青涩| 亚洲国产视频直播| 亚洲欧美偷拍卡通变态| 国产亚洲人成网站| 精品久久国产字幕高潮| 在线综合视频播放| 欧美系列日韩一区| 99久久国产综合色|国产精品| 国产乱码字幕精品高清av | 91精品国产综合久久小美女| 日本黄色一区二区| 91丝袜呻吟高潮美腿白嫩在线观看| 国产一区二区免费看| 六月丁香综合在线视频| 日韩综合在线视频| 视频一区国产视频| 亚洲成人福利片| 一个色综合网站| 亚洲欧美偷拍卡通变态| 亚洲欧美日韩国产综合在线| 中文字幕中文在线不卡住| 欧美激情一区二区三区不卡| 国产欧美日韩卡一| 国产欧美精品一区二区三区四区| 国产色综合一区| 欧美激情自拍偷拍| 国产精品伦一区二区三级视频| 久久久久久日产精品| 国产亚洲精品bt天堂精选| 国产欧美日韩另类视频免费观看| 国产亚洲精品免费| 国产精品国产三级国产aⅴ原创| 国产精品的网站| 亚洲柠檬福利资源导航| 亚洲电影视频在线| 日韩成人av影视| 蜜桃传媒麻豆第一区在线观看| 激情综合五月天| 国产成人av影院| 99在线热播精品免费| 欧美午夜精品一区二区蜜桃| 欧美一区二区三区视频在线观看| 日韩欧美一区二区三区在线| 欧美精品一区二区三| 国产精品久久久久久福利一牛影视 | 91网站视频在线观看| 国产亚洲精品超碰| 日韩美女视频一区| 日韩国产精品久久久久久亚洲| 九九**精品视频免费播放| 成人黄色777网| 欧美性生活久久| 26uuu色噜噜精品一区| 亚洲欧美电影院| 奇米一区二区三区| 成人福利电影精品一区二区在线观看| 99re这里只有精品视频首页| 在线观看91av| 亚洲国产精品t66y| 三级欧美在线一区| av在线这里只有精品| 欧美精品第1页| 中文字幕av不卡| 轻轻草成人在线| 色屁屁一区二区| 久久久久久9999| 天堂午夜影视日韩欧美一区二区| 国产成人午夜视频| 日韩欧美在线综合网| 亚洲丝袜另类动漫二区| 激情六月婷婷久久| 91黄色免费网站|