]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
More reference cleanup, remove poorly designed per-weapon crosshair trueaim logic Mario/weapon_reference_cleanup 1399/head
authorMario <mario.mario@y7mail.com>
Mon, 23 Dec 2024 13:46:43 +0000 (23:46 +1000)
committerMario <mario.mario@y7mail.com>
Mon, 23 Dec 2024 13:46:43 +0000 (23:46 +1000)
14 files changed:
qcsrc/client/hud/crosshair.qc
qcsrc/common/effects/all.inc
qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc
qcsrc/common/gamemodes/gamemode/onslaught/cl_generator.qc
qcsrc/common/gamemodes/gamemode/tka/sv_tka.qc
qcsrc/common/sounds/all.inc
qcsrc/common/turrets/turret/ewheel_weapon.qc
qcsrc/common/turrets/turret/flac_weapon.qc
qcsrc/common/turrets/turret/hellion_weapon.qc
qcsrc/common/turrets/turret/hk_weapon.qc
qcsrc/common/turrets/turret/phaser_weapon.qc
qcsrc/common/turrets/turret/plasma_weapon.qc
qcsrc/common/turrets/turret/tesla_weapon.qc
qcsrc/common/turrets/turret/walker_weapon.qc

index 39d56869627371de41116502f5e98f3f07cf2877..1f2139fb7a34ce6f4bdc73094e15f1c14fdb3c34 100644 (file)
@@ -49,7 +49,7 @@ void TrueAim_Init()
        (trueaim_rifle = new_pure(trueaim_rifle)).dphitcontentsmask = DPCONTENTS_BODY | DPCONTENTS_CORPSE;
 }
 
-float EnemyHitCheck()
+int EnemyHitCheck()
 {
        float t, n;
        wcross_origin = project_3d_to_2d(trace_endpos);
@@ -70,9 +70,10 @@ float EnemyHitCheck()
        return SHOTTYPE_HITENEMY;
 }
 
-float TrueAimCheck(entity wepent)
+int TrueAimCheck(entity wepent)
 {
-       if(wepent.activeweapon.spawnflags & WEP_FLAG_NOTRUEAIM)
+       Weapon wep = wepent.activeweapon;
+       if(wep.spawnflags & WEP_FLAG_NOTRUEAIM)
                return SHOTTYPE_HITWORLD;
 
        float nudge = 1; // added to traceline target and subtracted from result TOOD(divVerent): do we still need this? Doesn't the engine do this now for us?
@@ -86,39 +87,11 @@ float TrueAimCheck(entity wepent)
        ta = trueaim;
        mv = MOVE_NOMONSTERS;
 
-       switch(wepent.activeweapon) // WEAPONTODO
-       {
-               case WEP_VORTEX:
-               case WEP_OVERKILL_NEX:
-               case WEP_VAPORIZER:
-                       mv = MOVE_NORMAL;
-                       break;
-               case WEP_RIFLE:
-                       ta = trueaim_rifle;
-                       mv = MOVE_NORMAL;
-                       if(zoomscript_caught)
-                       {
-                               tracebox(view_origin, '0 0 0', '0 0 0', view_origin + view_forward * max_shot_distance, mv, ta);
-                               return EnemyHitCheck();
-                       }
-                       break;
-               case WEP_DEVASTATOR: // projectile has a size!
-                       mi = '-3 -3 -3';
-                       ma = '3 3 3';
-                       break;
-               case WEP_FIREBALL: // projectile has a size!
-                       mi = '-16 -16 -16';
-                       ma = '16 16 16';
-                       break;
-               case WEP_SEEKER: // projectile has a size!
-                       mi = '-2 -2 -2';
-                       ma = '2 2 2';
-                       break;
-               case WEP_ELECTRO: // projectile has a size!
-                       mi = '0 0 -3';
-                       ma = '0 0 -3';
-                       break;
-       }
+       if(wep.spawnflags & WEP_TYPE_HITSCAN)
+               mv = MOVE_NORMAL; // accurate enemy hit detection
+
+       if(wep == WEP_RIFLE)
+               ta = trueaim_rifle; // WEAPONTODO
 
        vector traceorigin = entcs_receiver(player_localentnum - 1).origin + (eZ * STAT(VIEWHEIGHT));
 
index 01b74119b1601b2797d939db4e4aeb563c3e9373..aa73cc7e44f45cda102bf113a77fef20640bd77c 100644 (file)
@@ -237,11 +237,17 @@ EFFECT(0, ITEM_PICKUP,              "item_pickup")
 EFFECT(0, ITEM_RESPAWN,             "item_respawn")
 EFFECT(0, ITEM_DESPAWN,             "item_despawn")
 
+// FIXME: needs custom effect
+EFFECT(0, ONS_ELECTRICITY_EXPLODE,  "electro_ballexplode")
 EFFECT(0, ONS_GENERATOR_DAMAGED,    "torch_small")
 EFFECT(0, ONS_GENERATOR_GIB,        "onslaught_generator_gib_explode")
 EFFECT(0, ONS_GENERATOR_EXPLODE,    "onslaught_generator_smallexplosion")
 EFFECT(0, ONS_GENERATOR_EXPLODE2,   "onslaught_generator_finalexplosion")
+// FIXME: needs custom effect
+EFFECT(0, ONS_SHOCKWAVE,            "electro_combo")
 
+// FIXME: needs custom effect
+EFFECT(0, KA_BALL_RESPAWN,          "electro_combo")
 
 
 EFFECT(0, LASER_DEADLY,             "laser_deadly")
index 9f694a0e09d55895fe0765330e9c2cc1430347de..e3791acbbed28afa6a96e31b2a4483041fe8852b 100644 (file)
@@ -63,8 +63,8 @@ void ka_RespawnBall(entity this) // runs whenever the ball needs to be relocated
        this.nextthink = time + autocvar_g_keepawayball_respawntime;
        navigation_dynamicgoal_set(this, NULL);
 
-       Send_Effect(EFFECT_ELECTRO_COMBO, oldballorigin, '0 0 0', 1);
-       Send_Effect(EFFECT_ELECTRO_COMBO, this.origin, '0 0 0', 1);
+       Send_Effect(EFFECT_KA_BALL_RESPAWN, oldballorigin, '0 0 0', 1);
+       Send_Effect(EFFECT_KA_BALL_RESPAWN, this.origin, '0 0 0', 1);
 
        WaypointSprite_Spawn(WP_KaBall, 0, 0, this, '0 0 64', NULL, this.team, this, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER);
        WaypointSprite_Ping(this.waypointsprite_attachedforcarrier);
index ad08116490cf4228454a169dff6dcbc6ec48c242..784d785cbb6f6bc355d50eda7af05d140f130341 100644 (file)
@@ -54,7 +54,7 @@ void generator_draw(entity this)
                if(random() < 0.9 - GetResource(this, RES_HEALTH) / this.max_health)
                if(random() < 0.01)
                {
-                       pointparticles(EFFECT_ELECTRO_BALLEXPLODE, this.origin + randompos('-50 -50 -20', '50 50 50'), '0 0 0', 1);
+                       pointparticles(EFFECT_ONS_ELECTRICITY_EXPLODE, this.origin + randompos('-50 -50 -20', '50 50 50'), '0 0 0', 1);
                        sound(this, CH_TRIGGER, SND_ONS_ELECTRICITY_EXPLODE, VOL_BASE, ATTEN_NORM);
                }
                else
@@ -75,7 +75,7 @@ void generator_draw(entity this)
        if(this.count==40||this.count==20)
        {
                sound(this, CH_TRIGGER, SND_ONS_SHOCKWAVE, VOL_BASE, ATTEN_NORM);
-               pointparticles(EFFECT_ELECTRO_COMBO, this.origin, '0 0 0', 6);
+               pointparticles(EFFECT_ONS_SHOCKWAVE, this.origin, '0 0 0', 6);
        }
 
        // rays
index 0935b9709aed2d0c25df12b6a1a10ccd38d3b9ba..16bea2df99567d98c4c53b311799d66f44219723 100644 (file)
@@ -60,8 +60,8 @@ void tka_RespawnBall(entity this) // runs whenever the ball needs to be relocate
        this.nextthink = time + autocvar_g_tkaball_respawntime;
        navigation_dynamicgoal_set(this, NULL);
 
-       Send_Effect(EFFECT_ELECTRO_COMBO, oldballorigin, '0 0 0', 1);
-       Send_Effect(EFFECT_ELECTRO_COMBO, this.origin, '0 0 0', 1);
+       Send_Effect(EFFECT_KA_BALL_RESPAWN, oldballorigin, '0 0 0', 1);
+       Send_Effect(EFFECT_KA_BALL_RESPAWN, this.origin, '0 0 0', 1);
 
        WaypointSprite_Spawn(WP_KaBall, 0, 0, this, '0 0 64', NULL, this.team, this, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER);
        WaypointSprite_Ping(this.waypointsprite_attachedforcarrier);
index 4af86ab2952bf876dea6312cc82509631d158602..de5bb6d359765ed9aa1aef6597001c91d304f3e4 100644 (file)
@@ -34,7 +34,7 @@ Sound SND_RIC_RANDOM() {
     return REGISTRY_GET(Sounds, SND_RIC1.m_id + rint(random() * 2));
 }
 
-SOUND(ROCKET_IMPACT, W_Sound("rocket_impact"));
+SOUND(ROCKET_IMPACT, W_Sound("rocket_impact")); // heavily used as a generic explosion sound
 SOUND(STRENGTH_FIRE, W_Sound("strength_fire"));
 SOUND(UNAVAILABLE, W_Sound("unavailable"));
 SOUND(WEAPONPICKUP, W_Sound("weaponpickup"));
index 483bb214d3facc99564b76b0044cccb7b8261361..86dcc8e1c791c05bd80cb73501cc16310e6a9d48 100644 (file)
@@ -7,14 +7,14 @@ SOUND(EWheelAttack_FIRE, W_Sound("lasergun_fire"));
 METHOD(EWheelAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
     bool isPlayer = IS_PLAYER(actor);
     if (fire & 1)
-    if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(WEP_ELECTRO, refire))) {
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, 1)) {
         if (isPlayer) {
             turret_initparams(actor);
             W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_EWheelAttack_FIRE, CH_WEAPON_B, 0, DEATH_TURRET_EWHEEL.m_id);
             actor.tur_shotdir_updated = w_shotdir;
             actor.tur_shotorg = w_shotorg;
             actor.tur_head = actor;
-            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(WEP_ELECTRO, animtime), w_ready);
+            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0.5, w_ready);
         }
 
         turret_do_updates(actor);
index 14f99f6e51b6f8c45b5e6a85257df7e2837f6e62..ae0130c9073c5249aef3d9518b5c87c81f564a38 100644 (file)
@@ -7,7 +7,7 @@ SOUND(FlacAttack_FIRE, W_Sound("hagar_fire"));
 METHOD(FlacAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
     bool isPlayer = IS_PLAYER(actor);
     if (fire & 1)
-    if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(WEP_ELECTRO, refire))) {
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, 1)) {
         if (isPlayer) {
             turret_initparams(actor);
             W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_FlacAttack_FIRE, CH_WEAPON_B, 0, DEATH_TURRET_FLAC.m_id);
@@ -15,7 +15,7 @@ METHOD(FlacAttack, wr_think, void(entity thiswep, entity actor, .entity weaponen
             actor.tur_shotorg = w_shotorg;
             actor.tur_head = actor;
             actor.tur_impacttime = 10;
-            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(WEP_ELECTRO, animtime), w_ready);
+            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0.5, w_ready);
         }
 
         turret_tag_fire_update(actor);
index afe862b7e42a8cb9fa59650ac2167c19ee395561..1d30f308ef9228fd5e2c821e94197dc4bd423581 100644 (file)
@@ -10,7 +10,7 @@ SOUND(HellionAttack_FIRE, W_Sound("rocket_fire"));
 METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
     bool isPlayer = IS_PLAYER(actor);
     if (fire & 1)
-    if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(WEP_ELECTRO, refire))) {
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, 1)) {
         if (isPlayer) {
             turret_initparams(actor);
             W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_HellionAttack_FIRE, CH_WEAPON_B, 0, DEATH_TURRET_HELLION.m_id);
@@ -18,7 +18,7 @@ METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, .entity weapo
             actor.tur_shotorg = w_shotorg;
             actor.tur_head = actor;
             actor.shot_radius = 500;
-            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(WEP_ELECTRO, animtime), w_ready);
+            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0.5, w_ready);
         }
         if (!isPlayer) {
             if (actor.tur_head.frame != 0)
index dc77480be06102cbe34b9d32bd5b9edcec1e8089..47220d35c758df8f0d813cd02dd9909221f39334 100644 (file)
@@ -15,14 +15,14 @@ METHOD(HunterKillerAttack, wr_think, void(entity thiswep, entity actor, .entity
 {
        bool isPlayer = IS_PLAYER(actor);
        if (fire & 1)
-       if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(WEP_ELECTRO, refire))) {
+       if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, 1)) {
                if (isPlayer) {
             turret_initparams(actor);
             W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_HunterKillerAttack_FIRE, CH_WEAPON_B, 0, DEATH_TURRET_HK.m_id);
             actor.tur_shotdir_updated = w_shotdir;
             actor.tur_shotorg = w_shotorg;
             actor.tur_head = actor;
-            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(WEP_ELECTRO, animtime), w_ready);
+            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0.5, w_ready);
         }
         entity missile = turret_projectile(actor, SND_HunterKillerAttack_FIRE, 6, 10, DEATH_TURRET_HK.m_id, PROJECTILE_ROCKET, false, false);
         te_explosion (missile.origin);
index 1fa382fe3d2e8375066270a0a81e1ee3c195195c..d24fb0099f0c30aeb1dc2979bfdabdca25cf44d5 100644 (file)
@@ -10,7 +10,7 @@ METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, entity actor, .entity
 {
     bool isPlayer = IS_PLAYER(actor);
     if (fire & 1)
-    if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(WEP_ELECTRO, refire))) {
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, 1)) {
         if (isPlayer) {
             turret_initparams(actor);
             W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_PhaserTurretAttack_FIRE, CH_WEAPON_B, 0, DEATH_TURRET_PHASER.m_id);
@@ -18,7 +18,7 @@ METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, entity actor, .entity
             actor.tur_shotorg = w_shotorg;
             actor.tur_head = actor;
             actor.shot_speed = 1;
-            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(WEP_ELECTRO, animtime), w_ready);
+            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0.5, w_ready);
         }
         entity beam = new(PhaserTurret_beam);
         setmodel(beam, MDL_TUR_PHASER_BEAM);
index 48c924c364c5e056d4a4696eb7dc0d2a466ce768..6dc97f75b2348f7341830f18472479e7b1d9e185 100644 (file)
@@ -5,14 +5,14 @@ SOUND(PlasmaAttack_FIRE, W_Sound("hagar_fire"));
 METHOD(PlasmaAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
        bool isPlayer = IS_PLAYER(actor);
        if (fire & 1)
-       if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(WEP_ELECTRO, refire))) {
+       if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, 1)) {
                if (isPlayer) {
             turret_initparams(actor);
             W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_PlasmaAttack_FIRE, CH_WEAPON_B, 0, DEATH_TURRET_PLASMA.m_id);
             actor.tur_shotdir_updated = w_shotdir;
             actor.tur_shotorg = w_shotorg;
             actor.tur_head = actor;
-            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(WEP_ELECTRO, animtime), w_ready);
+            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0.5, w_ready);
         }
         entity missile = turret_projectile(actor, SND_PlasmaAttack_FIRE, 1, 0, DEATH_TURRET_PLASMA.m_id, PROJECTILE_ELECTRO_BEAM, true, true);
         missile.missile_flags = MIF_SPLASH;
index e877ce247e773cc7eb5cd039317d2d95cf5adf18..195b523bc3e6f027ac5f980f0c1e758cddc67a3e 100644 (file)
@@ -7,14 +7,14 @@ SOUND(TeslaCoilTurretAttack_FIRE, W_Sound("electro_fire"));
 METHOD(TeslaCoilTurretAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
     bool isPlayer = IS_PLAYER(actor);
     if (fire & 1)
-    if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(WEP_ELECTRO, refire))) {
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, 1)) {
         if (isPlayer) {
             turret_initparams(actor);
             W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_TeslaCoilTurretAttack_FIRE, CH_WEAPON_B, 0, DEATH_TURRET_TESLA.m_id);
             actor.tur_shotdir_updated = w_shotdir;
             actor.tur_shotorg = w_shotorg;
             actor.tur_head = actor;
-            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(WEP_ELECTRO, animtime), w_ready);
+            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0.5, w_ready);
         }
 
         float d = actor.shot_dmg;
index 21356d0f762985e0aa14d14f9db984894b161fc4..cc565dee271013c774d0d15a9738f592bdb56269 100644 (file)
@@ -6,14 +6,14 @@ SOUND(WalkerTurretAttack_FIRE, W_Sound("uzi_fire"));
 METHOD(WalkerTurretAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) {
     bool isPlayer = IS_PLAYER(actor);
     if (fire & 1)
-    if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(WEP_ELECTRO, refire))) {
+    if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, 1)) {
         if (isPlayer) {
             turret_initparams(actor);
             W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_WalkerTurretAttack_FIRE, CH_WEAPON_B, 0, DEATH_TURRET_WALK_GUN.m_id);
             actor.tur_shotdir_updated = w_shotdir;
             actor.tur_shotorg = w_shotorg;
             actor.tur_head = actor;
-            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(WEP_ELECTRO, animtime), w_ready);
+            weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0.5, w_ready);
         }
         sound (actor, CH_WEAPON_A, SND_WalkerTurretAttack_FIRE, VOL_BASE, ATTEN_NORM);
         fireBullet(actor, weaponentity, actor.tur_shotorg, actor.tur_shotdir_updated, actor.shot_spread, 0, actor.shot_dmg, 0, actor.shot_force, DEATH_TURRET_WALK_GUN.m_id, EFFECT_BULLET);