djcev.com

//

Git Repos / fte_dogmode / qc / triggers / setgravity.qc

Last update to this file was on 2024-03-24 at 02:40.

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
//======================================================================

const float TRIGGER_SETGRAVITY_STARTOFF = 8; // trigger will start off

//======================================================================
// forward declarations
//======================================================================

// trigger_setgravity
void() trigger_setgravity_touch;
void() trigger_setgravity_use;
void(entity e) trigger_setgravity_init;
void() trigger_setgravity;

//------------------------------------------------------------------------------

/*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
// {
//--------------------------------------------------------------
// from Copper -- dumptruck_ds
//--------------------------------------------------------------
void() trigger_setgravity_touch =
{
// from Copper -- dumptruck_ds
/*
if (sub_checkvalidtouch(other) == FALSE)
return;
*/

if (self.estate != STATE_ACTIVE)
return;

local float grav;

// 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.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;
};

//--------------------------------------------------------------
// 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;
};

//--------------------------------------------------------------
void(entity e) trigger_setgravity_init =
{
e.classname = "trigger_setgravity";
e.classtype = CT_TRIGGER_SETGRAVITY;
e.touch = trigger_setgravity_touch;
e.use = trigger_setgravity_use;

base_trigger_init (e);

// 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);
};

//--------------------------------------------------------------
void() trigger_setgravity =
{
// new spawnflags for all entities -- iw
if (SUB_Inhibit())
return;

trigger_setgravity_init (self);
};
// };

Return to the top of this page or return to the overview of this repo.

Log setgravity.qc

Date Commit Message Author + -
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.