Client: Move some skyroom setup routines into their own function, add
incomplete prop_door_rotating (needs engine fixes)
This commit is contained in:
parent
6583a42a87
commit
daaf6a1974
5 changed files with 164 additions and 20 deletions
|
@ -21,7 +21,7 @@ Player_PreDraw(base_player pl, int thirdperson)
|
|||
if (pl.gflags & GF_FLASHLIGHT) {
|
||||
vector src;
|
||||
vector ang;
|
||||
|
||||
|
||||
if (pl.entnum != player_localentnum) {
|
||||
src = pl.origin + pl.view_ofs;
|
||||
ang = [pl.pitch, pl.angles[1], pl.angles[2]];
|
||||
|
|
|
@ -166,22 +166,7 @@ CSQC_UpdateView(float w, float h, float focus)
|
|||
setproperty(VF_ENVMAP, "$whiteimage");
|
||||
setproperty(VF_ORIGIN, g_vecCubePos);
|
||||
setproperty(VF_AFOV, 90);
|
||||
if (g_skyscale != 0 && g_skypos) {
|
||||
vector porg;
|
||||
vector realpos;
|
||||
|
||||
if (autocvar_dev_skyscale) {
|
||||
realpos[0] = g_vecCubePos[0] / autocvar_dev_skyscale;
|
||||
realpos[1] = g_vecCubePos[1] / autocvar_dev_skyscale;
|
||||
realpos[2] = g_vecCubePos[2] / autocvar_dev_skyscale;
|
||||
} else {
|
||||
realpos[0] = g_vecCubePos[0] / g_skyscale;
|
||||
realpos[1] = g_vecCubePos[1] / g_skyscale;
|
||||
realpos[2] = g_vecCubePos[2] / g_skyscale;
|
||||
}
|
||||
setproperty(VF_SKYROOM_CAMERA, g_skypos + realpos);
|
||||
}
|
||||
|
||||
SkyCamera_Setup();
|
||||
renderscene();
|
||||
return;
|
||||
}
|
||||
|
@ -305,6 +290,7 @@ CSQC_UpdateView(float w, float h, float focus)
|
|||
}
|
||||
|
||||
setproperty(VF_DRAWWORLD, 1);
|
||||
SkyCamera_Setup();
|
||||
|
||||
/* draw the viewmodel in a second pass if desired */
|
||||
if (autocvar_r_viewmodelpass) {
|
||||
|
|
|
@ -30,13 +30,15 @@ var int autocvar_dev_skyscale = 0;
|
|||
var vector g_skypos;
|
||||
var int g_skyscale;
|
||||
|
||||
class sky_camera:CBaseEntity
|
||||
class
|
||||
sky_camera:CBaseEntity
|
||||
{
|
||||
void(void) sky_camera;
|
||||
virtual void(string, string) SpawnKey;
|
||||
};
|
||||
|
||||
void sky_camera::SpawnKey(string strField, string strKey)
|
||||
void
|
||||
sky_camera::SpawnKey(string strField, string strKey)
|
||||
{
|
||||
switch (strField) {
|
||||
case "scale":
|
||||
|
@ -52,8 +54,29 @@ void sky_camera::SpawnKey(string strField, string strKey)
|
|||
}
|
||||
}
|
||||
|
||||
void sky_camera::sky_camera(void)
|
||||
void
|
||||
sky_camera::sky_camera(void)
|
||||
{
|
||||
g_skyscale = 16;
|
||||
Init();
|
||||
}
|
||||
|
||||
void
|
||||
SkyCamera_Setup(void)
|
||||
{
|
||||
if (g_skyscale != 0 && g_skypos) {
|
||||
vector porg;
|
||||
vector realpos;
|
||||
|
||||
if (autocvar_dev_skyscale) {
|
||||
realpos[0] = g_vecCubePos[0] / autocvar_dev_skyscale;
|
||||
realpos[1] = g_vecCubePos[1] / autocvar_dev_skyscale;
|
||||
realpos[2] = g_vecCubePos[2] / autocvar_dev_skyscale;
|
||||
} else {
|
||||
realpos[0] = g_vecCubePos[0] / g_skyscale;
|
||||
realpos[1] = g_vecCubePos[1] / g_skyscale;
|
||||
realpos[2] = g_vecCubePos[2] / g_skyscale;
|
||||
}
|
||||
setproperty(VF_SKYROOM_CAMERA, g_skypos + realpos);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,6 +102,7 @@ server/monster_furniture.cpp
|
|||
server/monster_generic.cpp
|
||||
server/monstermaker.cpp
|
||||
server/multisource.cpp
|
||||
server/prop_door_rotating.cpp
|
||||
server/random_speaker.cpp
|
||||
server/random_trigger.cpp
|
||||
server/scripted_sentence.cpp
|
||||
|
|
134
src/gs-entbase/server/prop_door_rotating.cpp
Normal file
134
src/gs-entbase/server/prop_door_rotating.cpp
Normal file
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2020 Marco Hladik <marco@icculus.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#define PRPDRFL_OPEN 1
|
||||
#define PRPDRFL_LOCKED 2048
|
||||
#define PRPDRFL_SILENT 4096
|
||||
#define PRPDRFL_USECLOSES 8192
|
||||
#define PRPDRFL_NOALERT 16384
|
||||
#define PRPDRFL_NOUSE 32768
|
||||
|
||||
class prop_door_rotating:CBaseTrigger
|
||||
{
|
||||
vector m_vecDest1;
|
||||
vector m_vecDest2;
|
||||
float m_flDistance;
|
||||
float m_flSpeed;
|
||||
|
||||
void(void) prop_door_rotating;
|
||||
|
||||
virtual void(void) Respawn;
|
||||
virtual void(void) Interact;
|
||||
|
||||
virtual void(vector, void(void)) Turn;
|
||||
virtual void(void) Opened;
|
||||
virtual void(void) Closed;
|
||||
};
|
||||
|
||||
void
|
||||
prop_door_rotating::Turn(vector vecDest, void(void) vFunc)
|
||||
{
|
||||
vector vecAngleDifference;
|
||||
float flTravelLength, flTravelTime;
|
||||
|
||||
if (!m_flSpeed) {
|
||||
dprint(sprintf("^1prop_door_rotating::^3RotToDest^7: No speed defined for %s!", targetname));
|
||||
prop_door_rotating::Respawn();
|
||||
return;
|
||||
}
|
||||
|
||||
vecAngleDifference = (vecDest - angles);
|
||||
flTravelLength = vlen(vecAngleDifference);
|
||||
flTravelTime = (flTravelLength / m_flSpeed);
|
||||
avelocity = (vecAngleDifference * (1 / flTravelTime));
|
||||
think = vFunc;
|
||||
nextthink = (ltime + flTravelTime);
|
||||
}
|
||||
|
||||
void
|
||||
prop_door_rotating::Closed(void)
|
||||
{
|
||||
avelocity = [0,0,0];
|
||||
angles = m_vecDest1;
|
||||
PlayerUse = Interact;
|
||||
}
|
||||
|
||||
void
|
||||
prop_door_rotating::Opened(void)
|
||||
{
|
||||
avelocity = [0,0,0];
|
||||
angles = m_vecDest2;
|
||||
PlayerUse = Interact;
|
||||
}
|
||||
|
||||
void
|
||||
prop_door_rotating::Interact(void)
|
||||
{
|
||||
static void TurnAway(void) {
|
||||
Turn(m_vecDest2, Opened);
|
||||
}
|
||||
static void TurnBack(void) {
|
||||
Turn(m_vecDest1, Closed);
|
||||
}
|
||||
|
||||
m_iValue = 1 - m_iValue;
|
||||
frame = 1;
|
||||
frame1time = 0.0f;
|
||||
SendFlags |= BASEFL_CHANGED_FRAME;
|
||||
|
||||
if (m_iValue)
|
||||
think = TurnAway;
|
||||
else
|
||||
think = TurnBack;
|
||||
|
||||
nextthink = ltime + 0.25f;
|
||||
PlayerUse = __NULL__;
|
||||
}
|
||||
|
||||
void
|
||||
prop_door_rotating::Respawn(void)
|
||||
{
|
||||
SetModel(m_oldModel);
|
||||
SetSolid(SOLID_BSP);
|
||||
SetMovetype(MOVETYPE_PUSH);
|
||||
SetOrigin(m_oldOrigin);
|
||||
PlayerUse = Interact;
|
||||
m_vecDest1 = m_oldAngle;
|
||||
m_vecDest2 = m_vecDest1 + [0, m_flDistance, 0];
|
||||
}
|
||||
|
||||
void
|
||||
prop_door_rotating::SpawnKey(string strKey, string strValue)
|
||||
{
|
||||
switch (strKey) {
|
||||
case "distance":
|
||||
m_flDistance = stof(strValue);
|
||||
break;
|
||||
case "speed":
|
||||
m_flSpeed = stof(strValue);
|
||||
break;
|
||||
default:
|
||||
CBaseTrigger::SpawnKey(strKey, strValue);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
prop_door_rotating::prop_door_rotating(void)
|
||||
{
|
||||
m_flDistance = 90;
|
||||
m_flSpeed = 100;
|
||||
CBaseTrigger::CBaseTrigger();
|
||||
}
|
Loading…
Reference in a new issue