Git Repos / fte_dogmode / qc / triggers / setgravity.qc
Last update to this file was on 2024-07-03 at 07:20.
Show setgravity.qc
//==============================================================================
// trigger_setgravity; was in hip_trig.qc
//==============================================================================
/*
Trigger QuickC program
By Jim Dose' 12/2/96
Copyright (c)1996 Hipnotic Interactive, Inc.
All rights reserved.
Distributed (unsupported) on 3.12.97
*/
//======================================================================
// constants
//======================================================================
#if defined(CSQC) || defined(SSQC)
const float TRIGGER_SETGRAVITY_STARTOFF = 8; // trigger will start off
// trigger net constants start at 1<<4
const float TRIGGER_SETGRAVITY_NET_GRAVITY = 1<<6; // .gravity has changed
#endif
//======================================================================
// forward declarations
//======================================================================
// trigger_setgravity
#ifdef CSQC
void(float isnew) trigger_setgravity_netreceive;
#endif
#ifdef SSQC
float(entity to, float netflags) trigger_setgravity_netsend;
#endif
#if defined(CSQC) || defined(SSQC)
void() trigger_setgravity_touch;
#endif
#ifdef SSQC
void() trigger_setgravity_use;
#endif
#if defined(CSQC) || defined(SSQC)
void(entity e) trigger_setgravity_init;
#endif
#ifdef SSQC
void() trigger_setgravity;
#endif
//------------------------------------------------------------------------------
/*QUAKED trigger_setgravity (.5 .5 .5) ? X X X X X X X X NOT_ON_EASY NOT_ON_NORMAL NOT_ON_HARD_OR_NIGHTMARE NOT_IN_DEATHMATCH NOT_IN_COOP NOT_IN_SINGLEPLAYER X NOT_ON_HARD_ONLY NOT_ON_NIGHTMARE_ONLY
set the gravity of a player
"gravity" what to set the players gravity to
- 0 (default) normal gravity
- 1 no gravity
- 2 almost no gravity
- 10 is a good setting
- ...
- 101 normal gravity
- 102 slightly higher gravity
- ...
- 1000 very high gravity
NOTE: the amount of gravity can only be changed by touching another
trigger_setgravity with a different setting. The gravity key defaults to 0
which is normal gravity. Lower numbers (e.g. 25) equal lower gravity. Setting
100 is normal gravity. Numbers above 100 will make the player “heavier”, i.e.
harder to jump. If you want multiple trigger setgravity triggers in one room or
area, make sure the brushes are not touching each other. This can cause the
triggers not to work properly.
*/
//----------------------------------------------------------------------
// class trigger_setgravity: base_trigger
// {
#ifdef CSQC
//--------------------------------------------------------------
void(float isnew) trigger_setgravity_netreceive =
{
local float netflags = ReadFloat ();
if (netflags & BASE_TRIGGER_NET_ORIGIN)
{
self.origin_x = ReadCoord ();
self.origin_y = ReadCoord ();
self.origin_z = ReadCoord ();
}
if (netflags & BASE_TRIGGER_NET_SIZE)
{
self.mins_x = ReadCoord ();
self.mins_y = ReadCoord ();
self.mins_z = ReadCoord ();
self.maxs_x = ReadCoord ();
self.maxs_y = ReadCoord ();
self.maxs_z = ReadCoord ();
}
if (netflags & TRIGGER_SETGRAVITY_NET_GRAVITY)
self.gravity = ReadFloat ();
if (netflags & BASE_TRIGGER_NET_ESTATE)
self.estate = ReadFloat ();
if (isnew)
trigger_setgravity_init (self);
};
#endif
#ifdef SSQC
//--------------------------------------------------------------
float(entity to, float netflags) trigger_setgravity_netsend =
{
WriteShort (MSG_ENTITY, self.classtype);
WriteFloat (MSG_ENTITY, netflags);
if (netflags & BASE_TRIGGER_NET_ORIGIN)
{
WriteCoord (MSG_ENTITY, self.origin_x);
WriteCoord (MSG_ENTITY, self.origin_y);
WriteCoord (MSG_ENTITY, self.origin_z);
}
if (netflags & BASE_TRIGGER_NET_SIZE)
{
WriteCoord (MSG_ENTITY, self.mins_x);
WriteCoord (MSG_ENTITY, self.mins_y);
WriteCoord (MSG_ENTITY, self.mins_z);
WriteCoord (MSG_ENTITY, self.maxs_x);
WriteCoord (MSG_ENTITY, self.maxs_y);
WriteCoord (MSG_ENTITY, self.maxs_z);
}
if (netflags & TRIGGER_SETGRAVITY_NET_GRAVITY)
WriteFloat (MSG_ENTITY, self.gravity);
if (netflags & BASE_TRIGGER_NET_ESTATE)
WriteFloat (MSG_ENTITY, self.estate);
return TRUE;
};
#endif
#if defined(CSQC) || defined(SSQC)
//--------------------------------------------------------------
// from Copper -- dumptruck_ds
//--------------------------------------------------------------
void() trigger_setgravity_touch =
{
// from Copper -- dumptruck_ds
/*
if (sub_checkvalidtouch(other) == FALSE)
return;
*/
// This is commented out so that the changing gravity will
// affect everything, if you don't want to use all affecting
// gravity changes, then uncomment these two lines.
// if (other.classtype != CT_PLAYER)
// return;
if (self.estate != STATE_ACTIVE)
return;
local float grav;
if (self.gravity == -1)
grav = 1;
else
grav = self.gravity;
// the player's gravity is now managed in PlayerPreThink(),
// however other entities don't have special gravity
// management, so their gravity is still set directly -- iw
if (other.classtype == CT_PLAYER)
other.wantedgravity = grav;
else
other.gravity = grav;
};
#endif
#ifdef SSQC
//--------------------------------------------------------------
// dumptruck_ds based on hipnotic blocker_use
//--------------------------------------------------------------
void() trigger_setgravity_use =
{
if (self.estate != STATE_ACTIVE)
self.estate = STATE_ACTIVE;
else
self.estate = STATE_INACTIVE;
self.SendFlags |= BASE_TRIGGER_NET_ESTATE;
};
#endif
#if defined(CSQC) || defined(SSQC)
//--------------------------------------------------------------
void(entity e) trigger_setgravity_init =
{
e.classname = "trigger_setgravity";
e.classtype = CT_TRIGGER_SETGRAVITY;
e.touch = trigger_setgravity_touch;
base_trigger_init (e);
#ifdef CSQC
setorigin (e, e.origin);
setsize (e, e.mins, e.maxs);
#endif
#ifdef SSQC
e.use = trigger_setgravity_use;
// dumptruck_ds
if (e.spawnflags & TRIGGER_SETGRAVITY_STARTOFF)
e.estate = STATE_INACTIVE;
if (!e.gravity)
e.gravity = -1;
else
e.gravity = ((e.gravity - 1) / 100);
sub_checkwaiting (e);
e.SendEntity = trigger_setgravity_netsend;
e.SendFlags = e.SendFlags | BASE_TRIGGER_NET_ORIGIN |
BASE_TRIGGER_NET_SIZE |
TRIGGER_SETGRAVITY_NET_GRAVITY |
BASE_TRIGGER_NET_ESTATE;
#endif
};
#endif
#ifdef SSQC
//--------------------------------------------------------------
void() trigger_setgravity =
{
// new spawnflags for all entities -- iw
if (SUB_Inhibit())
return;
trigger_setgravity_init (self);
};
#endif
// };
Return to the top of this page or return to the overview of this repo.
Log setgravity.qc
Date | Commit Message | Author | + | - |
---|---|---|---|---|
2024-07-03 | pmove changes and fixes, improved climbing | cev | +1 | -1 |
2024-06-15 | Major update, committing as-is, will have bugs | cev | +117 | -6 |
2024-03-24 | 2nd pass refactor, rework QC class structure | cev | +50 | -25 |
2024-02-18 | Client/player, projectiles, entrypoints refactor | cev | +1 | -1 |
2024-01-09 | Continue OO / Class-based refactor | cev | +19 | -17 |
2023-12-09 | Start OO / class-based refactor, work on items | cev | +73 | -68 |
2023-11-20 | changes to movement, build environment, file reorg | cev | +103 |
Return to the top of this page or return to the overview of this repo.