Git Repos / fte_dogmode / qc / func / plat.qc
Last update to this file was on 2024-06-26 at 03:47.
Show plat.qc
//==============================================================================
// func_plat -- was plats.qc
//==============================================================================
//======================================================================
// constants
//======================================================================
#ifdef SSQC
const float PLAT_LOW_TRIGGER = 1;
#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
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
#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.state == FUNC_STATE_BOTTOM)
sub_runvoidas (self.owner, func_plat_go_up);
else if (self.owner.state == FUNC_STATE_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 & 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 =
{
local float netflags = ReadFloat ();
base_func_netreceive_read (isnew, netflags);
if (isnew)
func_plat_init (self);
if (netflags & BASE_FUNC_NET_VELOCITY)
{
if (self.velocity != self.velocity_net)
{
if (self.velocity)
{
self.origin_start = self.origin;
self.movetime = time;
}
else
{
self.movetime = 0;
}
}
}
self.origin_net = self.origin;
self.velocity_net = self.velocity;
if (netflags & BASE_FUNC_NET_MODEL)
setmodelindex (self, self.modelindex);
if (netflags & BASE_FUNC_NET_SIZE)
setsize (self, self.mins, self.maxs);
if (netflags & BASE_FUNC_NET_ORIGIN)
setorigin (self, self.origin);
};
#endif
#ifdef SSQC
//--------------------------------------------------------------
void() func_plat_hit_top =
{
self.state = FUNC_STATE_TOP;
sound (self, CHAN_VOICE, self.noise1, VOL_MHI, ATTN_NORM);
self.think = func_plat_go_down;
self.nextthink = self.ltime + 3;
self.SendFlags = BASE_FUNC_NET_SPEED |
BASE_FUNC_NET_ORIGIN | BASE_FUNC_NET_VELOCITY;
};
//--------------------------------------------------------------
void() func_plat_hit_bottom =
{
self.state = FUNC_STATE_BOTTOM;
sound (self, CHAN_VOICE, self.noise1, VOL_MHI, ATTN_NORM);
self.SendFlags = BASE_FUNC_NET_SPEED |
BASE_FUNC_NET_ORIGIN | BASE_FUNC_NET_VELOCITY;
};
//--------------------------------------------------------------
void() func_plat_go_down =
{
self.state = FUNC_STATE_DOWN;
sub_calcmove (self, self.pos2, self.speed,
func_plat_hit_bottom);
sound (self, CHAN_VOICE, self.noise, VOL_MHI, ATTN_NORM);
self.SendFlags = BASE_FUNC_NET_SPEED |
BASE_FUNC_NET_ORIGIN | BASE_FUNC_NET_VELOCITY;
};
//--------------------------------------------------------------
void() func_plat_go_up =
{
self.state = FUNC_STATE_UP;
sub_calcmove (self, self.pos1, self.speed, func_plat_hit_top);
sound (self, CHAN_VOICE, self.noise, VOL_MHI, ATTN_NORM);
self.SendFlags = BASE_FUNC_NET_SPEED |
BASE_FUNC_NET_ORIGIN | BASE_FUNC_NET_VELOCITY;
};
//--------------------------------------------------------------
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.state == FUNC_STATE_UP)
func_plat_go_up ();
else if (self.state == FUNC_STATE_DOWN)
func_plat_go_down ();
return;
}
t_damage2 (other, self, self, 1);
// reverse direction
if (self.state == FUNC_STATE_UP)
func_plat_go_down ();
else if (self.state == FUNC_STATE_DOWN)
func_plat_go_up ();
else
objerror ("func_plat_blocked: bad self.state\n");
};
//--------------------------------------------------------------
void() func_plat_use =
{
self.use = sub_null;
if (self.targetname != "")
{
if (self.state != FUNC_STATE_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
#if defined(CSQC) || defined(SSQC)
//--------------------------------------------------------------
void(entity e) func_plat_init =
{
e.classname = "plat";
e.classtype = CT_FUNC_PLAT;
base_func_init (e);
#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;
// FIX THIS TO LOAD A GENERIC PLAT SOUND
if (e.sounds == 1)
{
precache_sound ("plats/plat1.wav");
precache_sound ("plats/plat2.wav");
e.noise = "plats/plat1.wav";
e.noise1 = "plats/plat2.wav";
}
if (e.sounds == 2)
{
precache_sound ("plats/medplat1.wav");
precache_sound ("plats/medplat2.wav");
e.noise = "plats/medplat1.wav";
e.noise1 = "plats/medplat2.wav";
}
e.mangle = e.angles;
e.angles = '0 0 0';
#endif
// SOLID_BSP and MOVETYPE_PUSH on both client and server -- CEV
e.solid = SOLID_BSP;
e.movetype = MOVETYPE_PUSH;
setorigin (e, e.origin);
#if defined(SSQC)
setmodel (e, e.model);
#elif defined(CSQC)
self.oldorigin = self.origin;
setmodelindex (e, e.modelindex);
#endif
setsize (e, e.mins, e.maxs);
#ifdef SSQC
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.height)
e.pos2_z = e.origin_z - e.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.state = FUNC_STATE_UP;
}
else
{
setorigin (e, e.pos2);
e.state = FUNC_STATE_BOTTOM;
}
// network func_plat to the CSQC client -- CEV
// e.SendEntity = base_func_netsend;
e.SendFlags = BASE_FUNC_NET_ORIGIN | BASE_FUNC_NET_SIZE |
BASE_FUNC_NET_MODEL | BASE_FUNC_NET_SPEED;
#endif
#ifdef CSQC
e.drawmask = DRAWMASK_NORMAL;
e.predraw = base_func_predraw_solidpush;
#endif
};
#endif
#ifdef SSQC
//--------------------------------------------------------------
void() func_plat =
{
// new spawnflags for all entities -- iw
if (SUB_Inhibit())
return;
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 | + | - |
---|---|---|---|---|
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.