Skip to content

Commit

Permalink
Add nukes
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioSMB committed Feb 10, 2025
1 parent 69b4197 commit b4a0489
Show file tree
Hide file tree
Showing 16 changed files with 396 additions and 5 deletions.
1 change: 1 addition & 0 deletions mod/quake/common/_all.inc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "ent_cs.qc"

#include "deathtypes/all.qc"
#include "effects/qc/_mod.inc"
#include "effects/all.qc"
#include "notifications/all.qc"
#include "triggers/include.qc"
Expand Down
1 change: 1 addition & 0 deletions mod/quake/common/_all.qh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ REGISTER_NET_TEMP(ENT_CLIENT_INIT)
#include "physics.qh"


#include "effects/qc/_mod.qh"
#include "effects/all.qh"
#include "models/all.qh"
#include "sounds/all.qh"
Expand Down
2 changes: 2 additions & 0 deletions mod/quake/common/effects/all.inc
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ EFFECT(0, QCC_MUSHROOM, "spawn_point_yellow")
EFFECT(0, OTAMATONE_FIRE, "arc_smoke")

EFFECT(0, ELECTRIFY, "arc_lightning")

EFFECT(0, NUKE_EXPLODE, "fireball_explode")
2 changes: 2 additions & 0 deletions mod/quake/common/effects/qc/_mod.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// genmod.sh autogenerated file; do not modify
#include "modeleffects.qc"
2 changes: 2 additions & 0 deletions mod/quake/common/effects/qc/_mod.qh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// genmod.sh autogenerated file; do not modify
#include "modeleffects.qh"
146 changes: 146 additions & 0 deletions mod/quake/common/effects/qc/modeleffects.qc
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
#include "modeleffects.qh"

REGISTER_NET_LINKED(ENT_CLIENT_MODELEFFECT)

#ifdef SVQC

.float scale2;

bool modeleffect_SendEntity(entity this, entity to, int sf)
{
float f;
WriteHeader(MSG_ENTITY, ENT_CLIENT_MODELEFFECT);

f = 0;
if(this.velocity != '0 0 0')
f |= 1;
if(this.angles != '0 0 0')
f |= 2;
if(this.avelocity != '0 0 0')
f |= 4;

WriteByte(MSG_ENTITY, f);
WriteShort(MSG_ENTITY, this.modelindex);
WriteByte(MSG_ENTITY, this.skin);
WriteByte(MSG_ENTITY, this.frame);
WriteVector(MSG_ENTITY, this.origin);
if(f & 1)
{
WriteVector(MSG_ENTITY, this.velocity);
}
if(f & 2)
{
WriteAngleVector(MSG_ENTITY, this.angles);
}
if(f & 4)
{
WriteAngleVector(MSG_ENTITY, this.avelocity);
}
WriteShort(MSG_ENTITY, this.scale * 256.0);
WriteShort(MSG_ENTITY, this.scale2 * 256.0);
WriteByte(MSG_ENTITY, this.teleport_time * 100.0);
WriteByte(MSG_ENTITY, this.fade_time * 100.0);
WriteByte(MSG_ENTITY, this.alpha * 255.0);

return true;
}

void modeleffect_spawn(string m, float s, float f, vector o, vector v, vector ang, vector angv, float s0, float s2, float a, float t1, float t2)
{
entity e = new(modeleffect);
_setmodel(e, m);
e.frame = f;
setorigin(e, o);
e.velocity = v;
e.angles = ang;
e.avelocity = angv;
e.alpha = a;
e.teleport_time = t1;
e.fade_time = t2;
e.skin = s;
if(s0 >= 0)
e.scale = s0 / max6(-e.mins.x, -e.mins.y, -e.mins.z, e.maxs.x, e.maxs.y, e.maxs.z);
else
e.scale = -s0;
if(s2 >= 0)
e.scale2 = s2 / max6(-e.mins.x, -e.mins.y, -e.mins.z, e.maxs.x, e.maxs.y, e.maxs.z);
else
e.scale2 = -s2;
float sz = max(e.scale, e.scale2);
setsize(e, e.mins * sz, e.maxs * sz);
Net_LinkEntity(e, false, 0.1, modeleffect_SendEntity);
}

#endif

#ifdef CSQC

entityclass(ModelEffect);
classfield(ModelEffect) .float frame1time;
classfield(ModelEffect) .float lifetime, fadetime;
classfield(ModelEffect) .float teleport_time;
classfield(ModelEffect) .float scale1, scale2;

.float cnt;
.float scale;
.float alpha;

void ModelEffect_Draw(entity this)
{
this.angles = this.angles + frametime * this.avelocity;
setorigin(this, this.origin + frametime * this.velocity);
this.scale = this.scale1 + (this.scale2 - this.scale1) * (time - this.teleport_time) / (this.lifetime + this.fadetime - this.teleport_time);
this.alpha = this.cnt * bound(0, 1 - (time - this.lifetime) / this.fadetime, 1);
if(this.alpha < 0.003)
{
delete(this);
return;
}
this.drawmask = MASK_NORMAL;
if(this.scale <= 0)
{
this.drawmask = 0;
return;
}
}

NET_HANDLE(ENT_CLIENT_MODELEFFECT, bool isnew)
{
make_pure(this);

int f = ReadByte();

entity e = new(modeleffect);
e.model = "from network";
e.modelindex = ReadShort();
e.skin = ReadByte();
e.frame = ReadByte();
e.frame1time = time;
e.origin = ReadVector();
setorigin(e, e.origin);
if(f & 1)
{
e.velocity = ReadVector();
}
if(f & 2)
{
e.angles = ReadAngleVector();
}
if(f & 4)
{
e.avelocity = ReadAngleVector();
}
e.scale1 = ReadShort() / 256.0;
e.scale2 = ReadShort() / 256.0;
e.lifetime = time + ReadByte() * 0.01;
e.fadetime = ReadByte() * 0.01;
e.teleport_time = time;
e.cnt = ReadByte() / 255.0; // actually alpha

e.draw = ModelEffect_Draw;
if (isnew) IL_PUSH(g_drawables, e);

if (!isnew) delete(e); // yes, this IS stupid, but I don't need to duplicate all the read* stuff then
return true;
}
#endif
5 changes: 5 additions & 0 deletions mod/quake/common/effects/qc/modeleffects.qh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#ifdef SVQC
void modeleffect_spawn(string m, float s, float f, vector o, vector v, vector ang, vector angv, float s0, float s2, float a, float t1, float t2);
#endif
2 changes: 2 additions & 0 deletions mod/quake/common/notifications/all.inc
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@

MSG_INFO_NOTIF(WEAPON_FRAG, N_CONSOLE, 2, 0, "s1 s2", "", "", _("^BG%s^K1 was fragged by ^BG%s"), "")
MSG_INFO_NOTIF(WEAPON_THINKING_WITH_PORTALS, N_CONSOLE, 2, 0, "s1 s2", "", "", _("^BG%s%s^K1 is now thinking with portals"), "")
MSG_INFO_NOTIF(WEAPON_NUKE_SUICIDE, N_CONSOLE, 2, 0, "s1 s2", "", "", _("^BG%s%s^K1 became Death, the destroyer of worlds"), "")

#undef N_DISABLE
#undef N_CONSOLE
Expand Down Expand Up @@ -378,6 +379,7 @@

MSG_MULTI_NOTIF(WEAPON_FRAG, N_ENABLE, NULL, INFO_WEAPON_FRAG, NULL)
MSG_MULTI_NOTIF(WEAPON_THINKING_WITH_PORTALS, N_ENABLE, NULL, INFO_WEAPON_THINKING_WITH_PORTALS, CENTER_DEATH_SELF_GENERIC)
MSG_MULTI_NOTIF(WEAPON_NUKE_SUICIDE, N_ENABLE, NULL, INFO_WEAPON_NUKE_SUICIDE, CENTER_DEATH_SELF_GENERIC)

#undef N_DISABL
#undef N_ENABLE
Expand Down
4 changes: 2 additions & 2 deletions mod/quake/common/triggers/trigger/earthquake.qc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void earthquake_rumble(entity this)
stop_earthquake(this);
else
{
_sound(this, CH_TRIGGER_SINGLE, "equake/rumble.wav", 1, ATTN_NONE );
_sound(this, CH_TRIGGER_SINGLE, "equake/rumble.wav", 1, ATTN_NONE);
setthink(this, earthquake_rumble);
this.nextthink = time + 1;
}
Expand All @@ -22,6 +22,7 @@ void earthquake_rumble(entity this)
void start_earthquake(entity this)
{
earthquake_active = true;
earthquake_intensity = this.weapon * 0.5;
if(this.spawnflags & EQ_RANDOM)
this.attack_finished = time + random() * this.delay;
else
Expand Down Expand Up @@ -63,7 +64,6 @@ spawnfunc(earthquake)

precache_sound("equake/rumble.wav");
earthquake_active = false;
earthquake_intensity = this.weapon * 0.5;

setsize(this, '0 0 0', '0 0 0');
setthink(this, stop_earthquake);
Expand Down
1 change: 1 addition & 0 deletions mod/quake/common/weapons/all.inc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "weapon/organ.qh"
#include "weapon/ball.qh"
#include "weapon/wand.qh"
#include "weapon/nuke.qh"

// WARNING: also update the weapon priority list in all.qh or your weapon won't work properly!!

Expand Down
6 changes: 3 additions & 3 deletions mod/quake/common/weapons/all.qh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

#ifdef GAMEQC
// TODO: cleaner way to list these?
noref string autocvar_cl_quake_weaponpriority = "katana breegull mushroom pogo rocketlauncher multirocketlauncher impaler cannon lightning plasma shock lightme otamatone laser_gun mic grenadelauncher multigrenade proximitygun tuba napalm fish chimes mayo spellbook hammer portalgun ocarina supernailgun lavasupernailgun organ crossbow piano sshotgun ripper doot nailgun lavanailgun biogun kazoo shotgun banjo ball wand chainsaw pan axe bongos";
noref string autocvar_cl_quake_weaponpriority = "katana breegull mushroom pogo rocketlauncher multirocketlauncher impaler nuke cannon lightning plasma shock lightme otamatone laser_gun mic grenadelauncher multigrenade proximitygun tuba napalm fish chimes mayo spellbook hammer portalgun ocarina supernailgun lavasupernailgun organ crossbow piano sshotgun ripper doot nailgun lavanailgun biogun kazoo shotgun banjo ball wand chainsaw pan axe bongos";
noref bool autocvar_cl_quake_weaponpriority_useforcycling = false;
noref string autocvar_cl_quake_weaponpriority0 = "rocketlauncher cannon multirocketlauncher impaler grenadelauncher multigrenade biogun proximitygun tuba napalm fish mayo"; // explosives
noref string autocvar_cl_quake_weaponpriority0 = "rocketlauncher nuke cannon multirocketlauncher impaler grenadelauncher multigrenade biogun proximitygun tuba napalm fish mayo"; // explosives
noref string autocvar_cl_quake_weaponpriority1 = "lightning plasma shock lightme"; // energy
noref string autocvar_cl_quake_weaponpriority2 = "lightning portalgun"; // hitscan exact
noref string autocvar_cl_quake_weaponpriority3 = "lightning sshotgun shotgun"; // hitscan all
noref string autocvar_cl_quake_weaponpriority4 = "laser_gun shock grenadelauncher multigrenade napalm fish mayo ocarina supernailgun biogun tuba lavasupernailgun crossbow piano doot nailgun lavanailgun bongos kazoo chainsaw"; // spam weapons
noref string autocvar_cl_quake_weaponpriority5 = "cannon impaler portalgun"; // movement weapons
noref string autocvar_cl_quake_weaponpriority5 = "nuke cannon impaler portalgun"; // movement weapons
noref string autocvar_cl_quake_weaponpriority6 = "tuba mic ocarina otamatone banjo bongos chimes mayo organ piano kazoo doot"; // musical instruments
noref string autocvar_cl_quake_weaponpriority7 = "";
noref string autocvar_cl_quake_weaponpriority8 = "";
Expand Down
1 change: 1 addition & 0 deletions mod/quake/common/weapons/weapon/_mod.inc
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@
#include "chimes.qc"
#include "ball.qc"
#include "wand.qc"
#include "nuke.qc"
1 change: 1 addition & 0 deletions mod/quake/common/weapons/weapon/_mod.qh
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@
#include "chimes.qh"
#include "ball.qh"
#include "wand.qh"
#include "nuke.qh"
Loading

0 comments on commit b4a0489

Please sign in to comment.