Git Repos / fte_dogmode / qc / func / plat.qc
Last update to this file was on 2025-08-13 at 05:20.
Show plat.qc
//==============================================================================
// func_plat -- was plats.qc
//==============================================================================
//======================================================================
// constants
//======================================================================
#ifdef SSQC
//----------------------------------------------------------------------
// func_plat spawnflags -- CEV
//----------------------------------------------------------------------
typedef enumflags
{
SPAWNFLAG_FUNC_PLAT_LOW_TRIGGER = 1
// SPAWNFLAG_NOT_ON_EASY = 256, // see base_entities.qc -- CEV
// SPAWNFLAG_NOT_ON_NORMAL = 512,
// SPAWNFLAG_NOT_ON_HARD_OR_NIGHTMARE = 1024,
// SPAWNFLAG_NOT_IN_DEATHMATCH = 2048,
// SPAWNFLAG_NOT_IN_COOP = 4096,
// SPAWNFLAG_NOT_IN_SP = 8192,
// SPAWNFLAG_NOT_ON_SKILL2 = 32768, // see base_entities.qc -- CEV
// SPAWNFLAG_NOT_ON_SKILL3 = 65536, // see base_entities.qc -- CEV
// SPAWNFLAG_CENTERPRINTALL = 131072 // see base_entities.qc -- CEV
} func_plat_spawnflags;
#endif
//======================================================================
// forward declarations
//======================================================================
#ifdef SSQC
// temp_plat_trigger
void() temp_plat_trigger_touch;
entity(entity own) spawn_temp_plat_trigger;
void(entity e) temp_plat_trigger_init;
strip void() temp_plat_trigger;
#endif
// func_plat
#ifdef CSQC
void(float isnew) func_plat_netreceive;
#endif
#ifdef SSQC
// FUNC_PLAT_SOUND(field, sound1, sound2)
void() func_plat_hit_top;
void() func_plat_hit_bottom;
void() func_plat_go_down;
void() func_plat_go_up;
void() func_plat_blocked;
void() func_plat_use;
#endif
#ifdef SSQC
void(string key, string value) func_plat_init_field;
#endif
#if defined(CSQC) || defined(SSQC)
void(entity e) func_plat_init;
#endif
#ifdef SSQC
void() func_plat;
#endif
//------------------------------------------------------------------------------
#ifdef SSQC
//----------------------------------------------------------------------
// class temp_plat_trigger: base_tempentity
// {
//--------------------------------------------------------------
void() temp_plat_trigger_touch =
{
// from Copper -- dumptruck_ds
if (sub_checkvalidtouch(other) == FALSE)
return;
if (self.owner.classtype != CT_FUNC_PLAT)
return;
if (self.owner.moveflags == FMF_BOTTOM)
sub_runvoidas (self.owner, func_plat_go_up);
else if (self.owner.moveflags == FMF_TOP)
// delay going down
self.owner.nextthink = self.owner.ltime + 1;
};
//--------------------------------------------------------------
entity(entity own) spawn_temp_plat_trigger =
{
local entity e = spawn ();
e.owner = own;
temp_plat_trigger_init (e);
return e;
};
//--------------------------------------------------------------
void(entity e) temp_plat_trigger_init =
{
e.classname = "temp_plat_trigger";
e.classtype = CT_TEMP_PLAT_TRIGGER;
base_tempentity_init (e);
e.movetype = MOVETYPE_NONE;
e.solid = SOLID_TRIGGER;
e.touch = temp_plat_trigger_touch;
if (!e.owner)
objerror ("temp_plat_trigger_init: no linked plat!\n");
if (e.owner.classtype != CT_FUNC_PLAT)
return;
local vector tmin = e.owner.mins + '25 25 0';
local vector tmax = e.owner.maxs - '25 25 -8';
tmin_z = tmax_z - (e.owner.pos1_z - e.owner.pos2_z + 8);
if (e.owner.spawnflags & SPAWNFLAG_FUNC_PLAT_LOW_TRIGGER)
tmax_z = tmin_z + 8;
if (e.owner.size_x <= 50)
{
tmin_x = (e.owner.mins_x + e.owner.maxs_x) / 2;
tmax_x = tmin_x + 1;
}
if (e.owner.size_y <= 50)
{
tmin_y = (e.owner.mins_y + e.owner.maxs_y) / 2;
tmax_y = tmin_y + 1;
}
setsize (e, tmin, tmax);
};
//--------------------------------------------------------------
strip void() temp_plat_trigger =
{
temp_plat_trigger_init (self);
};
// };
#endif
/*QUAKED func_plat (0 .5 .8) ? PLAT_LOW_TRIGGER 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
speed default 150
Plats are always drawn in the extended position, so they will light correctly.
If the plat is the target of another trigger or button, it will start out disabled in the extended position until it is trigger, when it will lower and become a normal plat.
If the "height" key is set, that will determine the amount the plat moves, instead of being implicitly determined by the model's height.
Set "sounds" to one of the following:
1) base fast
2) chain slow
*/
//----------------------------------------------------------------------
// class func_plat: base_func
// {
#ifdef CSQC
//--------------------------------------------------------------
void(float isnew) func_plat_netreceive =
{
// creates the netflag variable -- CEV
BASE_FUNC_NETRECEIVE (func_plat_init)
if (isnew)
base_entity_que_add (self, QUE_TYPE_ACTOR);
};
#endif
#ifdef SSQC
//--------------------------------------------------------------
#define FUNC_PLAT_SOUND(field, sound1, sound2) \
/* { */ \
if (self.field != __NULL__ && self.field != "") \
{ \
sound (self, CHAN_VOICE, self.field, \
VOL_MHI, ATTN_NORM); \
} \
else \
{ \
local sound_info_t snd = snd_empty; \
if (self.sounds == 1) \
snd = sound1; \
else if (self.sounds == 2) \
snd = sound2; \
if (snd.wav != snd_empty.wav) \
{ \
SOUND (self, snd) \
} \
} \
/* } */
//--------------------------------------------------------------
void() func_plat_hit_top =
{
self.moveflags = FMF_TOP;
FUNC_PLAT_SOUND (noise1, snd_plat_base2, snd_plat_med2)
self.think = func_plat_go_down;
self.nextthink = self.ltime + 3;
self.SendFlags = NETFLAG_BASE_ENTITY_ORIGIN;
};
//--------------------------------------------------------------
void() func_plat_hit_bottom =
{
self.moveflags = FMF_BOTTOM;
FUNC_PLAT_SOUND (noise1, snd_plat_base2, snd_plat_med2)
self.SendFlags = NETFLAG_BASE_ENTITY_ORIGIN;
};
//--------------------------------------------------------------
void() func_plat_go_down =
{
self.moveflags = FMF_DOWN;
base_func_calcmove (self, self.pos2, self.speed,
func_plat_hit_bottom);
FUNC_PLAT_SOUND (noise, snd_plat_base1, snd_plat_med1)
self.SendFlags = NETFLAG_BASE_ENTITY_ORIGIN;
};
//--------------------------------------------------------------
void() func_plat_go_up =
{
self.moveflags = FMF_UP;
base_func_calcmove (self, self.pos1, self.speed,
func_plat_hit_top);
FUNC_PLAT_SOUND (noise, snd_plat_base1, snd_plat_med1)
self.SendFlags = NETFLAG_BASE_ENTITY_ORIGIN;
};
//--------------------------------------------------------------
void() func_plat_blocked =
{
// handle projectiles -- CEV
if (other.classgroup & CG_PROJECTILE)
{
if (other.mins != '0 0 0' || other.maxs != '0 0 0')
setsize (other, '0 0 0', '0 0 0');
// continue on the same path
if (self.moveflags == FMF_UP)
func_plat_go_up ();
else if (self.moveflags == FMF_DOWN)
func_plat_go_down ();
return;
}
t_damage2 (other, self, self, 1);
// reverse direction
if (self.moveflags == FMF_UP)
func_plat_go_down ();
else if (self.moveflags == FMF_DOWN)
func_plat_go_up ();
else
objerror ("func_plat_blocked: bad self.moveflags\n");
};
//--------------------------------------------------------------
void() func_plat_use =
{
self.use = sub_null;
if (self.targetname != "")
{
if (self.moveflags != FMF_UP)
objerror ("func_plat_use: not in up state\n");
func_plat_go_down ();
}
else
{
if (self.think)
// already activated
return;
func_plat_go_down ();
}
};
#endif
#ifdef SSQC
//--------------------------------------------------------------
void(string key, string value) func_plat_init_field =
{
switch (key)
{
case "height":
if (!self.t_height)
self.t_height = stof (value);
break;
}
};
#endif
#if defined(CSQC) || defined(SSQC)
//--------------------------------------------------------------
void(entity e) func_plat_init =
{
e.classname = "plat";
e.classtype = CT_FUNC_PLAT;
base_func_init (e);
#ifdef CSQC
setmodelindex (e, e.modelindex);
setsize (e, e.mins, e.maxs);
setorigin (e, e.origin);
e.drawmask = DRAWMASK_NORMAL;
e.predraw = base_func_predraw;
#endif
#ifdef SSQC
if (!e.t_length)
e.t_length = 80;
if (!e.t_width)
e.t_width = 10;
if (e.sounds == 0)
e.sounds = 2;
// undefined behavior when sounds is set to 3 or greater -- CEV
if (e.noise == "" && e.noise1 == "" && e.sounds < 3)
{
if (e.sounds == 1)
{
precache_sound (snd_plat_base1.wav);
precache_sound (snd_plat_base2.wav);
}
else if (e.sounds == 2)
{
precache_sound (snd_plat_med1.wav);
precache_sound (snd_plat_med2.wav);
}
}
if (e.noise != __NULL__ && e.noise != "")
precache_sound (e.noise);
if (e.noise1 != __NULL__ && e.noise1 != "")
precache_sound (e.noise1);
e.mangle = e.angles;
e.angles = '0 0 0';
// SOLID_BSP and MOVETYPE_PUSH on both client and server -- CEV
e.solid = SOLID_BSP;
e.movetype = MOVETYPE_PUSH;
setorigin (e, e.origin);
setmodel (e, e.model);
setsize (e, e.mins, e.maxs);
e.blocked = func_plat_blocked;
e.use = func_plat_use;
if (!e.speed)
e.speed = 150;
// pos1 is the top position, pos2 is the bottom
e.pos1 = e.origin;
e.pos2 = e.origin;
if (e.t_height)
e.pos2_z = e.origin_z - e.t_height;
else
e.pos2_z = e.origin_z - e.size_z + 8;
// dprint (sprintf("func_plat_init: pos1 %v, pos2 %v, "
// "origin %v\n", e.pos1, e.pos2, e.origin));
// the "start moving" trigger
spawn_temp_plat_trigger (e);
if (e.targetname != "")
{
e.moveflags = FMF_UP;
}
else
{
setorigin (e, e.pos2);
e.moveflags = FMF_BOTTOM;
}
// network func_plat to the CSQC client -- CEV
e.tick = base_func_neteval;
e.SendEntity = base_entity_netsend;
e.SendFlags = NETFLAG_BASE_ENTITY_FULLSEND;
#endif
};
#endif
#ifdef SSQC
//--------------------------------------------------------------
void() func_plat =
{
BASE_FUNC_PREINIT (func_plat_init_field)
func_plat_init (self);
};
#endif
// };
Return to the top of this page or return to the overview of this repo.
Log plat.qc
Date | Commit Message | Author | + | - |
---|---|---|---|---|
2025-08-13 | Another big commit. Item changes, field rework, etc. | cev | +80 | -38 |
2025-03-30 | Big commit. Entity networking, etc. | cev | +41 | -59 |
2024-06-26 | pmove fixes, GL now a faux tribolt, wall climbing | cev | +4 | -2 |
2024-06-15 | Major update, committing as-is, will have bugs | cev | +101 | -8 |
2024-03-24 | Fix projectile and func_ blocked interaction | cev | +15 | |
2024-03-24 | 2nd pass refactor, rework QC class structure | cev | +148 | -193 |
2024-02-18 | Client/player, projectiles, entrypoints refactor | cev | +3 | -3 |
2024-01-31 | Class based monster refactor & start projectiles | cev | +77 | -13 |
2024-01-09 | Continue OO / Class-based refactor | cev | +212 | -186 |
2023-11-27 | Code reorg, minor movement changes, misc | cev | +226 |
Return to the top of this page or return to the overview of this repo.