mirror of
https://github.com/nzp-team/quakec.git
synced 2024-11-24 21:02:14 +00:00
SERVER: Micro Power Switch Revamp; Model Refresh
This commit is contained in:
parent
977c15981f
commit
293ef500a9
3 changed files with 215 additions and 142 deletions
|
@ -48,7 +48,8 @@ entities/pack_a_punch.qc
|
|||
entities/mystery_box.qc
|
||||
entities/doors.qc
|
||||
entities/window.qc
|
||||
entities/machines.qc
|
||||
entities/power_switch.qc
|
||||
entities/perk_a_cola.qc
|
||||
entities/wall_weapon.qc
|
||||
weapons/frames_core.qc
|
||||
weapons/rocket_launcher.qc
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
server/entities/machines.qc
|
||||
server/entities/perk_a_cola.qc
|
||||
|
||||
perks, power
|
||||
Perks-A-Cola Entity Logic
|
||||
|
||||
Copyright (C) 2021-2024 NZ:P Team
|
||||
|
||||
|
@ -331,6 +331,9 @@ void() touch_perk =
|
|||
//
|
||||
void(entity who) Turn_PerkLight_On =
|
||||
{
|
||||
if (who.classname == "perk_pap")
|
||||
return;
|
||||
|
||||
if (who.spawnflags & PERK_SPAWNFLAG_NOLIGHT) {
|
||||
Light_None(who);
|
||||
}
|
||||
|
@ -585,145 +588,6 @@ void() perk_mule =
|
|||
PERK_SPAWNFLAG_LIMELIGHT, 1000, 1000, true, true, 8, P_MULE);
|
||||
}
|
||||
|
||||
//
|
||||
// --------------------
|
||||
// Power Switch
|
||||
// --------------------
|
||||
//
|
||||
|
||||
void() turnpower1 =[ 1, turnpower2 ] {self.frame = 1;};
|
||||
void() turnpower2 =[ 2, turnpower3 ] {self.frame = 2;};
|
||||
void() turnpower3 =[ 3, turnpower4 ] {self.frame = 3;};
|
||||
void() turnpower4 =[ 4, SUB_Null ] {self.frame = 4;};
|
||||
|
||||
//
|
||||
// Turn_Lights()
|
||||
// Activates Perk Light Effects and LightStyles
|
||||
//
|
||||
void() Turn_Lights =
|
||||
{
|
||||
// Perk Lights
|
||||
entity tempe = findfloat(world, requirespower, 1);
|
||||
while (tempe)
|
||||
{
|
||||
if (tempe.classname != "perk_pap")
|
||||
Turn_PerkLight_On(tempe);
|
||||
tempe = findfloat (tempe, requirespower, 1);
|
||||
}
|
||||
|
||||
// Light Styles
|
||||
tempe = find(world, classname, "light");
|
||||
while(tempe)
|
||||
{
|
||||
if (tempe.spawnflags & LIGHT_SPAWNFLAG_STARTOFF) {
|
||||
tempe.style = tempe.score;
|
||||
LS_Setup();
|
||||
}/* else if (tempe.spawnflags & LIGHT_SPAWNFLAG_STARTON) {
|
||||
tempe.style = 64;
|
||||
lightstyle(tempe.style, "a");
|
||||
}*/
|
||||
|
||||
tempe = find(tempe, classname, "light");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// touch_power_Switch()
|
||||
// Power Switch touch function; play Animation and do Power things..
|
||||
//
|
||||
void() touch_power_Switch =
|
||||
{
|
||||
if (other.classname != "player" || other.downed)
|
||||
return;
|
||||
|
||||
if (isPowerOn == true)
|
||||
return;
|
||||
|
||||
local entity tempe;
|
||||
local entity old_self;
|
||||
|
||||
useprint (other, 10, 0, 0);
|
||||
if (other.button7 && !isPowerOn) {
|
||||
turnpower1();
|
||||
isPowerOn = true;
|
||||
Sound_PlaySound(world, self.oldmodel, SOUND_TYPE_ENV_VOICE, SOUND_PRIORITY_PLAYALWAYS);
|
||||
|
||||
// Print message
|
||||
if (self.message) {
|
||||
entity players = find(world, classname, "player");
|
||||
while (players != world) {
|
||||
centerprint(players, strcat(self.message, "\n"));
|
||||
players = find(players, classname, "player");
|
||||
}
|
||||
}
|
||||
|
||||
tempe = find (world, classname, "door_nzp");// trigger all paired doors
|
||||
while (tempe) {
|
||||
local entity starte;
|
||||
|
||||
if (!tempe.targetname) {
|
||||
if (!tempe.cost) {
|
||||
old_self = self;
|
||||
self = tempe;
|
||||
starte = self;
|
||||
door_go_up ();
|
||||
tempe.classname = "door_open";
|
||||
tempe = find (tempe, classname, "door_nzp");// trigger all paired doors
|
||||
self = old_self;
|
||||
}
|
||||
}
|
||||
if (tempe.targetname) {
|
||||
old_self = self;
|
||||
self = tempe;
|
||||
remove(self);
|
||||
self = old_self;
|
||||
tempe = find (tempe, classname, "door_nzp");// trigger all paired doors
|
||||
}
|
||||
}
|
||||
|
||||
tempe = find(world, classname, "perk_pap");
|
||||
while(tempe != world) {
|
||||
entity tempe2 = self;
|
||||
self = tempe;
|
||||
PAP_TurnOn();
|
||||
self = tempe2;
|
||||
tempe = find(tempe, classname, "perk_pap");
|
||||
}
|
||||
|
||||
Turn_Lights();
|
||||
SUB_UseTargets();
|
||||
}
|
||||
}
|
||||
|
||||
void() power_switch =
|
||||
{
|
||||
//
|
||||
// Set Default Stats for Compatibility
|
||||
//
|
||||
|
||||
// Model
|
||||
if (!self.model)
|
||||
self.model = "models/machines/quake_scale/power_switch.mdl";
|
||||
|
||||
// Sound
|
||||
if (!self.oldmodel)
|
||||
self.oldmodel = "sounds/machines/power.wav";
|
||||
|
||||
// Skin
|
||||
if (!self.skin)
|
||||
self.skin = 0;
|
||||
|
||||
self.solid = SOLID_TRIGGER;
|
||||
Precache_Set(self.model);
|
||||
precache_sound(self.oldmodel);
|
||||
setorigin (self, self.origin);
|
||||
setsize (self, VEC_HULL2_MIN, VEC_HULL2_MAX);
|
||||
self.classname = "power_switch";
|
||||
self.touch = touch_power_Switch;
|
||||
|
||||
isPowerOn = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Random Perk-A-Cola
|
||||
//
|
208
source/server/entities/power_switch.qc
Normal file
208
source/server/entities/power_switch.qc
Normal file
|
@ -0,0 +1,208 @@
|
|||
/*
|
||||
server/entities/power_switch.qc
|
||||
|
||||
Power Switch Entity Logic
|
||||
|
||||
Copyright (C) 2021-2024 NZ:P Team
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to:
|
||||
|
||||
Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA
|
||||
|
||||
*/
|
||||
|
||||
#define POWER_SPAWNFLAG_NOHANDLE 1
|
||||
|
||||
void(entity who) Turn_PerkLight_On;
|
||||
|
||||
//
|
||||
// Power_ActivateLights()
|
||||
// Activates Perk Light Effects and LightStyles
|
||||
//
|
||||
void() Power_ActivateLights =
|
||||
{
|
||||
// Perk Lights
|
||||
entity tempe = findfloat(world, requirespower, 1);
|
||||
while (tempe)
|
||||
{
|
||||
Turn_PerkLight_On(tempe);
|
||||
tempe = findfloat (tempe, requirespower, 1);
|
||||
}
|
||||
|
||||
// Light Styles
|
||||
tempe = find(world, classname, "light");
|
||||
while(tempe)
|
||||
{
|
||||
if (tempe.spawnflags & LIGHT_SPAWNFLAG_STARTOFF) {
|
||||
tempe.style = tempe.score;
|
||||
LS_Setup();
|
||||
}
|
||||
|
||||
tempe = find(tempe, classname, "light");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Power_HandleStop()
|
||||
// Stops "flipping" the Power Switch handle.
|
||||
//
|
||||
void() Power_HandleStop =
|
||||
{
|
||||
self.avelocity = '0 0 0';
|
||||
self.think = SUB_Null;
|
||||
}
|
||||
|
||||
//
|
||||
// Power_HandleFlip()
|
||||
// Programmatically "flips" the Power Switch handle.
|
||||
//
|
||||
void() Power_HandleFlip =
|
||||
{
|
||||
self.boxweapon.avelocity = '185 0 0';
|
||||
self.boxweapon.think = Power_HandleStop;
|
||||
self.boxweapon.nextthink = time + 0.50;
|
||||
}
|
||||
|
||||
//
|
||||
// Power_Touch()
|
||||
// Power Switch touch function, triggers global activation.
|
||||
//
|
||||
void() Power_Touch =
|
||||
{
|
||||
if (other.classname != "player" || other.downed)
|
||||
return;
|
||||
|
||||
if (isPowerOn == true)
|
||||
return;
|
||||
|
||||
entity tempe;
|
||||
entity old_self;
|
||||
|
||||
useprint (other, 10, 0, 0);
|
||||
if (other.button7 && !isPowerOn) {
|
||||
|
||||
// Animate the handle programmatically.
|
||||
if (!(self.spawnflags & POWER_SPAWNFLAG_NOHANDLE))
|
||||
Power_HandleFlip();
|
||||
|
||||
// Play the sound of the Power Switch flipping
|
||||
if (self.powerup_vo)
|
||||
Sound_PlaySound(self, self.powerup_vo, SOUND_TYPE_ENV_OBJECT, SOUND_PRIORITY_PLAYALWAYS);
|
||||
|
||||
isPowerOn = true;
|
||||
Sound_PlaySound(world, self.oldmodel, SOUND_TYPE_ENV_VOICE, SOUND_PRIORITY_PLAYALWAYS);
|
||||
|
||||
// Trigger all doors that are marked as requiring power.
|
||||
tempe = find (world, classname, "door_nzp");
|
||||
while (tempe) {
|
||||
entity starte;
|
||||
|
||||
if (!tempe.targetname) {
|
||||
if (!tempe.cost) {
|
||||
old_self = self;
|
||||
self = tempe;
|
||||
starte = self;
|
||||
door_go_up ();
|
||||
tempe.classname = "door_open";
|
||||
tempe = find (tempe, classname, "door_nzp");
|
||||
self = old_self;
|
||||
}
|
||||
}
|
||||
if (tempe.targetname) {
|
||||
old_self = self;
|
||||
self = tempe;
|
||||
remove(self);
|
||||
self = old_self;
|
||||
tempe = find (tempe, classname, "door_nzp");
|
||||
}
|
||||
}
|
||||
|
||||
tempe = find(world, classname, "perk_pap");
|
||||
while(tempe != world) {
|
||||
entity tempe2 = self;
|
||||
self = tempe;
|
||||
PAP_TurnOn();
|
||||
self = tempe2;
|
||||
tempe = find(tempe, classname, "perk_pap");
|
||||
}
|
||||
|
||||
Power_ActivateLights();
|
||||
SUB_UseTargets();
|
||||
}
|
||||
}
|
||||
|
||||
void() power_switch =
|
||||
{
|
||||
//
|
||||
// Set Default Stats for Compatibility
|
||||
//
|
||||
|
||||
// Model
|
||||
if (!self.model)
|
||||
self.model = "models/machines/quake_scale/power_switch.mdl";
|
||||
|
||||
// Handle Model
|
||||
if (!self.weapon2model)
|
||||
self.weapon2model = "models/machines/quake_scale/power_handle.mdl";
|
||||
|
||||
// Compatibility Hack -- it doesn't make sense if the Power Switch is HL
|
||||
// and the handle is Quake.
|
||||
if (self.model == "models/machines/hl_scale/power_switch.mdl" &&
|
||||
self.weapon2model == "models/machines/quake_scale/power_handle.mdl") {
|
||||
self.weapon2model = "models/machines/hl_scale/power_handle.mdl";
|
||||
self.box1 = '-3 0 -2';
|
||||
}
|
||||
|
||||
// Power Sound (Plays Everywhere)
|
||||
if (!self.oldmodel)
|
||||
self.oldmodel = "sounds/machines/power.wav";
|
||||
|
||||
// Handle Offset
|
||||
if (!self.box1)
|
||||
self.box1 = '-4 0 12';
|
||||
|
||||
// Switch Flip Sound (Spatialized)
|
||||
if (self.powerup_vo)
|
||||
precache_sound(self.powerup_vo);
|
||||
|
||||
self.solid = SOLID_TRIGGER;
|
||||
Precache_Set(self.model);
|
||||
precache_sound(self.oldmodel);
|
||||
setorigin (self, self.origin);
|
||||
setsize (self, VEC_HULL2_MIN, VEC_HULL2_MAX);
|
||||
self.classname = "power_switch";
|
||||
self.touch = Power_Touch;
|
||||
|
||||
// Spawn the Handle
|
||||
if (!(self.spawnflags & POWER_SPAWNFLAG_NOHANDLE)) {
|
||||
precache_model(self.weapon2model);
|
||||
entity handle = spawn();
|
||||
setmodel(handle, self.weapon2model);
|
||||
makevectors(self.angles);
|
||||
handle.origin = self.origin;
|
||||
handle.origin += v_right * self.box1_y;
|
||||
handle.origin += v_forward * self.box1_x;
|
||||
handle.origin += v_up * self.box1_z;
|
||||
handle.angles = self.angles;
|
||||
setorigin(handle, handle.origin);
|
||||
handle.movetype = MOVETYPE_NOCLIP;
|
||||
self.boxweapon = handle;
|
||||
}
|
||||
|
||||
// Set the global flag that indicates the Power isn't on
|
||||
isPowerOn = false;
|
||||
}
|
Loading…
Reference in a new issue