From ccb3e10e8fe59662e9e989a1946dd18894124349 Mon Sep 17 00:00:00 2001 From: Jakob MG Date: Thu, 25 Mar 2010 15:56:01 +0100 Subject: [PATCH] Fix bad LOS origin (made ehweel and walker turrets idle in place insted of attacking) --- .../server/tturrets/include/turrets_early.qh | 1 + qcsrc/server/tturrets/system/system_main.qc | 10 +++-- qcsrc/server/tturrets/units/unit_ewheel.qc | 43 +++++++++++-------- qcsrc/server/tturrets/units/unit_walker.qc | 3 ++ 4 files changed, 37 insertions(+), 20 deletions(-) diff --git a/qcsrc/server/tturrets/include/turrets_early.qh b/qcsrc/server/tturrets/include/turrets_early.qh index 25cba992c..fa07f867f 100644 --- a/qcsrc/server/tturrets/include/turrets_early.qh +++ b/qcsrc/server/tturrets/include/turrets_early.qh @@ -28,6 +28,7 @@ vector real_origin(entity ent); .string cvar_basename; //.float spawnflags +#define TSF_SUSPENDED 1 /// Spawn a pillar model under the turret to make it look ok on uneven ground surfaces #define TSF_TERRAINBASE 2 /// Disable builtin ammo regeneration diff --git a/qcsrc/server/tturrets/system/system_main.qc b/qcsrc/server/tturrets/system/system_main.qc index 6ee08493c..afddaef0d 100644 --- a/qcsrc/server/tturrets/system/system_main.qc +++ b/qcsrc/server/tturrets/system/system_main.qc @@ -567,7 +567,8 @@ float turret_validate_target(entity e_turret,entity e_target,float validate_flag if (validate_flags & TFL_TARGETSELECT_LOS) { v_tmp = real_origin(e_target) + ((e_target.mins + e_target.maxs) * 0.5); - traceline(e_turret.tur_shotorg,v_tmp,0,e_turret); + + traceline(e_turret.tur_shotorg, v_tmp, 0, e_turret); if (e_turret.aim_firetolerance_dist < vlen(v_tmp - trace_endpos)) return -19; @@ -926,8 +927,8 @@ float turret_stdproc_init (string cvar_base_name, float csqc_shared, string base v = gettaginfo(e,gettagindex(e,"tag_fire")); if(v == '0 0 0') { - objerror("^1ERROR: Engine is borken! Turrets will NOT work. force g_turrets to 0 to run maps with turrets anyway."); - crash(); + //objerror("^1ERROR: Engine is borken! Turrets will NOT work. force g_turrets to 0 to run maps with turrets anyway."); + //crash(); } setmodel(e,""); @@ -942,6 +943,9 @@ float turret_stdproc_init (string cvar_base_name, float csqc_shared, string base csqc_shared = 0; } + if not (self.spawnflags & TSF_SUSPENDED) + droptofloor_builtin(); + // Terrainbase spawnflag. This puts a enlongated model // under the turret, so it looks ok on uneaven surfaces. if (self.spawnflags & TSF_TERRAINBASE) diff --git a/qcsrc/server/tturrets/units/unit_ewheel.qc b/qcsrc/server/tturrets/units/unit_ewheel.qc index 3f7acdac9..3d84386a4 100644 --- a/qcsrc/server/tturrets/units/unit_ewheel.qc +++ b/qcsrc/server/tturrets/units/unit_ewheel.qc @@ -171,6 +171,13 @@ void ewheel_postthink() float vz; vector wish_angle,real_angle; + /* + if(self.enemy) + dprint("enemy!\n"); + else + dprint("nothign =(!\n"); + */ + vz = self.velocity_z; self.angles_x = anglemods(self.angles_x); @@ -190,7 +197,8 @@ void ewheel_postthink() self.angles_y = (self.angles_y + real_angle_y); // Simulate banking - self.angles_z = bound(-45,real_angle_y * -2.5,45); + self.angles_z -= self.angles_z * frametime * 2; + self.angles_z = bound(-45,self.angles_z + ((real_angle_y * -25) * frametime),45); if(self.enemy) ewheel_move_enemy(); @@ -207,7 +215,10 @@ void ewheel_respawnhook() { entity e; - setorigin(self,self.pos1); + self.velocity = '0 0 0'; + self.enemy = world; + + setorigin(self, self.pos1); if (self.target != "") { @@ -230,23 +241,14 @@ void ewheel_respawnhook() void ewheel_diehook() { - turret_trowgib2(self.origin,self.velocity + '0 0 400', '-0.6 -0.2 -02', self, 3 + time + random() * 2); - self.velocity = '0 0 0'; + turret_trowgib2(self.origin, self.velocity + '0 0 400', '-0.6 -0.2 -02', self, 3 + time + random() * 2); + if (self.pathcurrent) pathlib_deletepath(self.pathcurrent.owner); self.pathcurrent = world; - - /* - if (self.damage_flags & TFL_DMG_DEATH_NORESPAWN) - { - verbstack_flush(self.verbs_move); - remove(self.verbs_move); - } - */ - } void turret_ewheel_dinit() @@ -291,12 +293,11 @@ void turret_ewheel_dinit() self.solid = SOLID_SLIDEBOX; self.takedamage = DAMAGE_AIM; - setsize(self,'-32 -32 0', '32 32 48'); + setsize(self, '-32 -32 0', '32 32 48'); + self.idle_aim = '0 0 0'; self.pos1 = self.origin; - self.idle_aim = '0 0 0'; - // Our fire routine self.turret_firefunc = ewheel_attack; self.turret_postthink = ewheel_postthink; @@ -306,6 +307,10 @@ void turret_ewheel_dinit() self.tur_head.aim_speed = cvar("g_turrets_unit_ewheel_turnrate"); self.tur_head.aim_speed = self.tur_head.aim_speed / (1 / self.ticrate); + if (!turret_tag_setup()) + dprint("Warning: Turret ",self.classname, " faild to initialize md3 tags\n"); + + //setorigin(self,self.origin + '0 0 128'); if (self.target != "") { e = find(world,targetname,self.target); @@ -319,7 +324,7 @@ void turret_ewheel_dinit() dprint("Warning: not a turrret path\n"); else { - self.pathcurrent = WALKER_PATH(self.origin,e.origin); + self.pathcurrent = WALKER_PATH(self.origin, e.origin); self.pathgoal = e; } } @@ -332,6 +337,10 @@ void spawnfunc_turret_ewheel() precache_model ("models/turrets/ewheel-base2.md3"); precache_model ("models/turrets/ewheel-gun1.md3"); + precache_model ("models/pathlib/goodsquare.md3"); + precache_model ("models/pathlib/badsquare.md3"); + precache_model ("models/pathlib/square.md3"); + turret_ewheel_loadcvars(); self.think = turret_ewheel_dinit; diff --git a/qcsrc/server/tturrets/units/unit_walker.qc b/qcsrc/server/tturrets/units/unit_walker.qc index 14dd16397..e1341b460 100644 --- a/qcsrc/server/tturrets/units/unit_walker.qc +++ b/qcsrc/server/tturrets/units/unit_walker.qc @@ -718,6 +718,9 @@ void turret_walker_dinit() return; } + if (!turret_tag_setup()) + dprint("Warning: Turret ",self.classname, " faild to initialize md3 tags\n"); + self.damage_flags |= TFL_DMG_DEATH_NOGIBS; self.target_select_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMTS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_LOS; self.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMTS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_LOS; -- 2.39.2