int AIScriptRelay::cpp_nearestEntityId(lua_State *lua, String type)
		{
			AI *nearest = nearestEntity(type);

			if (nearest)
			{
				mCurrentScript->addRecentAiReference(nearest);
				lua_pushnumber(lua, nearest->getHost());

				return 1;
			}

			return 0;
		}
		int AIScriptRelay::cpp_nearestEntityPos(lua_State *lua, String type)
		{
			AI *nearest = nearestEntity(type);

			if (nearest)
			{
				Vec2d pos = nearest->mSpatial->getPos();
				lua_pushnumber(lua, pos.x);
				lua_pushnumber(lua, pos.y);

				return 2;
			}

			return 0;
		}
		int AIScriptRelay::cpp_nearestEntityId(lua_State *lua)
		{
			String arg = mCurrentScript->getArgString(1);

			if (arg != "")
				return cpp_nearestEntityId(lua, arg);

			AI *nearest = nearestEntity();

			if (nearest)
			{
				mCurrentScript->addRecentAiReference(nearest);
				lua_pushnumber(lua, nearest->getHost());

				return 1;
			}

			return 0;
		}
		int AIScriptRelay::cpp_nearestEntityPos(lua_State *lua)
		{
			String arg = mCurrentScript->getArgString(1);

			if (arg != "")
				return cpp_nearestEntityPos(lua, arg);

			AI *nearest = nearestEntity();

			if (nearest)
			{
				Vec2d pos = nearest->mSpatial->getPos();
				lua_pushnumber(lua, pos.x);
				lua_pushnumber(lua, pos.y);

				return 2;
			}

			return 0;
		}
Example #5
0
void CCam::enemyCam(camInfo_t *ci)
{
	int entityNum = nearestEntity();

	if (entityNum == -1)
		return;

	player_t *player = &eth32.cg.players[entityNum];

	int w = ci->x2 - ci->x1;
	int h = ci->y2 - ci->y1;

	// Set the view
	memcpy(&camRefDef, &eth32.cg.refdef, sizeof(refdef_t));
	// fov
	camRefDef.fov_x = (w>h) ? ci->fov : ci->fov * w / h;
	camRefDef.fov_y = (h>w) ? ci->fov : ci->fov * h / w;
	// origin
	VectorCopy( player->lerpOrigin, camRefDef.vieworg );

	if (player->currentState->eFlags & EF_CROUCHING)
		camRefDef.vieworg[2] += CROUCH_VIEWHEIGHT;
	else if (player->currentState->eFlags & EF_PRONE)
		camRefDef.vieworg[2] += PRONE_VIEWHEIGHT;
	else
		camRefDef.vieworg[2] += DEFAULT_VIEWHEIGHT;

	// view angle
	AnglesToAxis(player->currentState->apos.trBase, camRefDef.viewaxis);

	// Draw the spycam
	drawCam(ci->x1, ci->y1, w, h, &camRefDef, qfalse);

	sprintf(this->str, player->name);
	Draw.Text(ci->x1 + (w / 2) - (TEXTWIDTH(this->str) / 2), ci->y1 + h - 22 , 0.24f, str, GUI_FONTCOLOR1, qfalse, qtrue, &eth32.cg.media.fontArial, true);
}