]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/turrets/sv_turrets.qc
Merge branch 'terencehill/arc_suicide_message' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / turrets / sv_turrets.qc
index 84aae19335fd0d970a32a2024090780e16c3d372..2e6068bf56ac823cbefc287b163941447c19a7b8 100644 (file)
@@ -1,6 +1,12 @@
 #include "sv_turrets.qh"
+
 #ifdef SVQC
-#include <server/autocvars.qh>
+#include <common/mapobjects/defs.qh>
+#include <server/bot/api.qh>
+#include <server/damage.qh>
+#include <server/weapons/common.qh>
+#include <server/weapons/weaponsystem.qh>
+#include <server/world.qh>
 
 // Generic aiming
 vector turret_aim_generic(entity this)
@@ -320,7 +326,6 @@ void turrets_setframe(entity this, float _frame, float client_only)
 
 bool turret_send(entity this, entity to, float sf)
 {
-
        WriteHeader(MSG_ENTITY, ENT_CLIENT_TURRET);
        WriteByte(MSG_ENTITY, sf);
        if(sf & TNSF_SETUP)
@@ -329,8 +334,7 @@ bool turret_send(entity this, entity to, float sf)
 
                WriteVector(MSG_ENTITY, this.origin);
 
-               WriteAngle(MSG_ENTITY, this.angles_x);
-               WriteAngle(MSG_ENTITY, this.angles_y);
+               WriteAngleVector2D(MSG_ENTITY, this.angles);
        }
 
        if(sf & TNSF_ANG)
@@ -402,7 +406,7 @@ void load_unit_settings(entity ent, bool is_reload)
        ent.ammo_max             *= ent.turret_scale_ammo;
        ent.ammo_recharge        *= ent.turret_scale_ammo;
        ent.aim_speed            *= ent.turret_scale_aim;
-       ent.health               *= ent.turret_scale_health;
+       SetResourceExplicit(ent, RES_HEALTH, GetResource(ent, RES_HEALTH) * ent.turret_scale_health);
        ent.respawntime          *= ent.turret_scale_respawn;
        ent.shot_dmg             *= ent.turret_scale_damage;
        ent.shot_refire          *= ent.turret_scale_refire;
@@ -426,11 +430,11 @@ void turret_projectile_explode(entity this)
        this.event_damage = func_null;
 #ifdef TURRET_DEBUG
        float d;
-       d = RadiusDamage (this, this.owner, this.owner.shot_dmg, 0, this.owner.shot_radius, this, NULL, this.owner.shot_force, this.totalfrags, DMG_NOWEP, NULL);
+       d = RadiusDamage (this, this.owner, this.owner.shot_dmg, 0, this.owner.shot_radius, this, NULL, this.owner.shot_force, this.projectiledeathtype, DMG_NOWEP, NULL);
        this.owner.tur_debug_dmg_t_h = this.owner.tur_debug_dmg_t_h + d;
        this.owner.tur_debug_dmg_t_f = this.owner.tur_debug_dmg_t_f + this.owner.shot_dmg;
 #else
-       RadiusDamage (this, this.realowner, this.owner.shot_dmg, 0, this.owner.shot_radius, this, NULL, this.owner.shot_force, this.totalfrags, DMG_NOWEP, NULL);
+       RadiusDamage (this, this.realowner, this.owner.shot_dmg, 0, this.owner.shot_radius, this, NULL, this.owner.shot_force, this.projectiledeathtype, DMG_NOWEP, NULL);
 #endif
        delete(this);
 }
@@ -472,7 +476,7 @@ entity turret_projectile(entity actor, Sound _snd, float _size, float _health, f
        IL_PUSH(g_projectiles, proj);
        IL_PUSH(g_bot_dodge, proj);
        proj.enemy                = actor.enemy;
-       proj.totalfrags  = _death;
+       proj.projectiledeathtype         = _death;
        PROJECTILE_MAKETRIGGER(proj);
        if(_health)
        {
@@ -788,7 +792,6 @@ float turret_validate_target(entity e_turret, entity e_target, float validate_fl
        tvt_thadv = angleofs3(e_turret.tur_head.origin, e_turret.angles + e_turret.tur_head.angles, e_target.origin);
        tvt_tadv = shortangle_vxy(angleofs(e_turret, e_target), e_turret.angles);
        tvt_thadf = vlen(tvt_thadv);
-       tvt_tadf = vlen(tvt_tadv);
 
        /*
        if(validate_flags & TFL_TARGETSELECT_FOV)
@@ -1242,9 +1245,9 @@ void turret_initparams(entity tur)
        #undef TRY
 }
 
-bool turret_closetotarget(entity this, vector targ)
+bool turret_closetotarget(entity this, vector targ, float range)
 {
-       vector path_extra_size = '64 64 64';
+       vector path_extra_size = '1 1 1' * range;
        return boxesoverlap(targ - path_extra_size, targ + path_extra_size, this.absmin - path_extra_size, this.absmax + path_extra_size);
 }
 
@@ -1253,7 +1256,7 @@ void turret_findtarget(entity this)
        entity e = find(NULL, classname, "turret_manager");
        if(!e)
        {
-               e = new(turret_manager);
+               e = new_pure(turret_manager);
                setthink(e, turrets_manager_think);
                e.nextthink = time + 2;
        }