From: Mario Date: Fri, 10 Jun 2016 10:33:10 +0000 (+1000) Subject: Clean up some of the turret code's self uses X-Git-Tag: xonotic-v0.8.2~855 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d82eed5c84b40a8eb68d9bca12e40506c6c7b6d9;p=xonotic%2Fxonotic-data.pk3dir.git Clean up some of the turret code's self uses --- diff --git a/qcsrc/common/triggers/trigger/magicear.qc b/qcsrc/common/triggers/trigger/magicear.qc index 328721040..53fda30e4 100644 --- a/qcsrc/common/triggers/trigger/magicear.qc +++ b/qcsrc/common/triggers/trigger/magicear.qc @@ -2,7 +2,7 @@ float magicear_matched; float W_Tuba_HasPlayed(entity pl, string melody, float instrument, float ignorepitch, float mintempo, float maxtempo); string trigger_magicear_processmessage(entity ear, entity source, float teamsay, entity privatesay, string msgin) -{SELFPARAM(); +{ float domatch, dotrigger, matchstart, l; string s, msg; string savemessage; @@ -28,10 +28,10 @@ string trigger_magicear_processmessage(entity ear, entity source, float teamsay, if(dotrigger) { - savemessage = self.message; - self.message = string_null; + savemessage = ear.message; + ear.message = string_null; SUB_UseTargets(ear, source, NULL); - self.message = savemessage; + ear.message = savemessage; } if(ear.netname != "") @@ -115,10 +115,10 @@ string trigger_magicear_processmessage(entity ear, entity source, float teamsay, if(dotrigger) { - savemessage = self.message; - self.message = string_null; + savemessage = ear.message; + ear.message = string_null; SUB_UseTargets(ear, source, NULL); - self.message = savemessage; + ear.message = savemessage; } if(ear.spawnflags & 16) diff --git a/qcsrc/common/turrets/checkpoint.qc b/qcsrc/common/turrets/checkpoint.qc index 2f3b11a7d..a5e758e0e 100644 --- a/qcsrc/common/turrets/checkpoint.qc +++ b/qcsrc/common/turrets/checkpoint.qc @@ -33,12 +33,12 @@ void turret_checkpoint_use() } #if 0 -void turret_checkpoint_think() -{SELFPARAM(); - if(self.enemy) - te_lightning1(self,self.origin, self.enemy.origin); +void turret_checkpoint_think(entity this) +{ + if(this.enemy) + te_lightning1(this,this.origin, this.enemy.origin); - self.nextthink = time + 0.25; + this.nextthink = time + 0.25; } #endif /*QUAKED turret_checkpoint (1 0 1) (-32 -32 -32) (32 32 32) @@ -53,17 +53,17 @@ If the checkpoint chain in not looped, the unit will go "Roaming" when the last //float tc_acum; void turret_checkpoint_init(entity this) { - traceline(self.origin + '0 0 16', self.origin - '0 0 1024', MOVE_WORLDONLY, self); - setorigin(self, trace_endpos + '0 0 32'); + traceline(this.origin + '0 0 16', this.origin - '0 0 1024', MOVE_WORLDONLY, this); + setorigin(this, trace_endpos + '0 0 32'); - if(self.target != "") + if(this.target != "") { - self.enemy = find(world, targetname, self.target); - if(self.enemy == world) + this.enemy = find(world, targetname, this.target); + if(this.enemy == world) LOG_TRACE("A turret_checkpoint faild to find its target!\n"); } - //self.think = turret_checkpoint_think; - //self.nextthink = time + tc_acum + 0.25; + //setthink(this, turret_checkpoint_think); + //this.nextthink = time + tc_acum + 0.25; //tc_acum += 0.25; } diff --git a/qcsrc/common/turrets/cl_turrets.qc b/qcsrc/common/turrets/cl_turrets.qc index 0fc168c2c..63b30bc35 100644 --- a/qcsrc/common/turrets/cl_turrets.qc +++ b/qcsrc/common/turrets/cl_turrets.qc @@ -19,9 +19,10 @@ void turret_changeteam(entity this) } -void turret_head_draw() -{SELFPARAM(); - self.drawmask = MASK_NORMAL; +// unused? +void turret_head_draw(entity this) +{ + this.drawmask = MASK_NORMAL; } void turret_draw(entity this) @@ -201,47 +202,47 @@ void turret_draw2d(entity this) ); } -void turret_construct() -{SELFPARAM(); - entity tur = get_turretinfo(self.m_id); +void turret_construct(entity this) +{ + entity tur = get_turretinfo(this.m_id); - if(self.tur_head == world) - self.tur_head = spawn(); + if(this.tur_head == world) + this.tur_head = spawn(); - self.netname = tur.turret_name; + this.netname = tur.turret_name; - setorigin(self, self.origin); - _setmodel(self, tur.model); - _setmodel(self.tur_head, tur.head_model); - setsize(self, tur.mins, tur.maxs); - setsize(self.tur_head, '0 0 0', '0 0 0'); + setorigin(this, this.origin); + _setmodel(this, tur.model); + _setmodel(this.tur_head, tur.head_model); + setsize(this, tur.mins, tur.maxs); + setsize(this.tur_head, '0 0 0', '0 0 0'); - if(self.m_id == TUR_EWHEEL.m_id) - setattachment(self.tur_head, self, ""); + if(this.m_id == TUR_EWHEEL.m_id) + setattachment(this.tur_head, this, ""); else - setattachment(self.tur_head, self, "tag_head"); - - self.tur_head.classname = "turret_head"; - self.tur_head.owner = self; - self.tur_head.move_movetype = MOVETYPE_NOCLIP; - self.move_movetype = MOVETYPE_NOCLIP; - self.tur_head.angles = self.angles; - self.health = 255; - self.solid = SOLID_BBOX; - self.tur_head.solid = SOLID_NOT; - self.movetype = MOVETYPE_NOCLIP; - self.tur_head.movetype = MOVETYPE_NOCLIP; - self.draw = turret_draw; - self.entremove = turret_remove; - self.drawmask = MASK_NORMAL; - self.tur_head.drawmask = MASK_NORMAL; - self.anim_start_time = 0; - self.draw2d = turret_draw2d; - self.maxdistance = autocvar_g_waypointsprite_turrets_maxdist; - self.teamradar_color = '1 0 0'; - self.alpha = 1; - - tur.tr_setup(tur, self); + setattachment(this.tur_head, this, "tag_head"); + + this.tur_head.classname = "turret_head"; + this.tur_head.owner = this; + this.tur_head.move_movetype = MOVETYPE_NOCLIP; + this.move_movetype = MOVETYPE_NOCLIP; + this.tur_head.angles = this.angles; + this.health = 255; + this.solid = SOLID_BBOX; + this.tur_head.solid = SOLID_NOT; + this.movetype = MOVETYPE_NOCLIP; + this.tur_head.movetype = MOVETYPE_NOCLIP; + this.draw = turret_draw; + this.entremove = turret_remove; + this.drawmask = MASK_NORMAL; + this.tur_head.drawmask = MASK_NORMAL; + this.anim_start_time = 0; + this.draw2d = turret_draw2d; + this.maxdistance = autocvar_g_waypointsprite_turrets_maxdist; + this.teamradar_color = '1 0 0'; + this.alpha = 1; + + tur.tr_setup(tur, this); } entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, float _explode); @@ -369,7 +370,7 @@ NET_HANDLE(ENT_CLIENT_TURRET, bool isnew) this.angles_x = ReadAngle(); this.angles_y = ReadAngle(); - turret_construct(); + turret_construct(this); this.colormap = 1024; this.glowmod = '0 1 1'; this.tur_head.colormap = this.colormap; diff --git a/qcsrc/common/turrets/sv_turrets.qc b/qcsrc/common/turrets/sv_turrets.qc index be7dbb8ae..c79acce2b 100644 --- a/qcsrc/common/turrets/sv_turrets.qc +++ b/qcsrc/common/turrets/sv_turrets.qc @@ -2,41 +2,41 @@ #include // Generic aiming -vector turret_aim_generic() -{SELFPARAM(); +vector turret_aim_generic(entity this) +{ vector pre_pos, prep; float distance, impact_time = 0, i, mintime; - turret_tag_fire_update(); + turret_tag_fire_update(this); - if(self.aim_flags & TFL_AIM_SIMPLE) - return real_origin(self.enemy); + if(this.aim_flags & TFL_AIM_SIMPLE) + return real_origin(this.enemy); - mintime = max(self.attack_finished_single[0] - time,0) + sys_frametime; + mintime = max(this.attack_finished_single[0] - time,0) + sys_frametime; // Baseline - pre_pos = real_origin(self.enemy); + pre_pos = real_origin(this.enemy); // Lead? - if (self.aim_flags & TFL_AIM_LEAD) + if (this.aim_flags & TFL_AIM_LEAD) { - if (self.aim_flags & TFL_AIM_SHOTTIMECOMPENSATE) // Need to conpensate for shot traveltime + if (this.aim_flags & TFL_AIM_SHOTTIMECOMPENSATE) // Need to conpensate for shot traveltime { prep = pre_pos; - distance = vlen(prep - self.tur_shotorg); - impact_time = distance / self.shot_speed; + distance = vlen(prep - this.tur_shotorg); + impact_time = distance / this.shot_speed; - prep = pre_pos + (self.enemy.velocity * (impact_time + mintime)); + prep = pre_pos + (this.enemy.velocity * (impact_time + mintime)); - if(self.aim_flags & TFL_AIM_ZPREDICT) - if(!IS_ONGROUND(self.enemy)) - if(self.enemy.movetype == MOVETYPE_WALK || self.enemy.movetype == MOVETYPE_TOSS || self.enemy.movetype == MOVETYPE_BOUNCE) + if(this.aim_flags & TFL_AIM_ZPREDICT) + if(!IS_ONGROUND(this.enemy)) + if(this.enemy.movetype == MOVETYPE_WALK || this.enemy.movetype == MOVETYPE_TOSS || this.enemy.movetype == MOVETYPE_BOUNCE) { float vz; prep_z = pre_pos_z; - vz = self.enemy.velocity_z; + vz = this.enemy.velocity_z; for(i = 0; i < impact_time; i += sys_frametime) { vz = vz - (autocvar_sv_gravity * sys_frametime); @@ -46,13 +46,13 @@ vector turret_aim_generic() pre_pos = prep; } else - pre_pos = pre_pos + self.enemy.velocity * mintime; + pre_pos = pre_pos + this.enemy.velocity * mintime; } - if(self.aim_flags & TFL_AIM_SPLASH) + if(this.aim_flags & TFL_AIM_SPLASH) { - //tracebox(pre_pos + '0 0 32',self.enemy.mins,self.enemy.maxs,pre_pos -'0 0 64',MOVE_WORLDONLY,self.enemy); - traceline(pre_pos + '0 0 32',pre_pos -'0 0 64',MOVE_WORLDONLY,self.enemy); + //tracebox(pre_pos + '0 0 32',this.enemy.mins,this.enemy.maxs,pre_pos -'0 0 64',MOVE_WORLDONLY,this.enemy); + traceline(pre_pos + '0 0 32',pre_pos -'0 0 64',MOVE_WORLDONLY,this.enemy); if(trace_fraction != 1.0) pre_pos = trace_endpos; } @@ -284,18 +284,18 @@ void turret_respawn(entity this) // Main functions #define cvar_base "g_turrets_unit_" .float clientframe; -void turrets_setframe(float _frame, float client_only) -{SELFPARAM(); - if((client_only ? self.clientframe : self.frame ) != _frame) +void turrets_setframe(entity this, float _frame, float client_only) +{ + if((client_only ? this.clientframe : this.frame ) != _frame) { - self.SendFlags |= TNSF_ANIM; - self.anim_start_time = time; + this.SendFlags |= TNSF_ANIM; + this.anim_start_time = time; } if(client_only) - self.clientframe = _frame; + this.clientframe = _frame; else - self.frame = _frame; + this.frame = _frame; } @@ -361,7 +361,7 @@ bool turret_send(entity this, entity to, float sf) } void load_unit_settings(entity ent, bool is_reload) -{SELFPARAM(); +{ string unitname = ent.netname; string sbase; @@ -422,8 +422,8 @@ void load_unit_settings(entity ent, bool is_reload) ent.track_blendrate = cvar(strcat(sbase,"_track_blendrate")); if(is_reload) { - Turret tur = get_turretinfo(self.m_id); - tur.tr_setup(tur, self); + Turret tur = get_turretinfo(ent.m_id); + tur.tr_setup(tur, ent); } } @@ -458,26 +458,26 @@ void turret_projectile_damage(entity this, entity inflictor, entity attacker, fl W_PrepareExplosionByDamage(this, this.owner, turret_projectile_explode); } -entity turret_projectile(Sound _snd, float _size, float _health, float _death, float _proj_type, float _cull, float _cli_anim) -{SELFPARAM(); +entity turret_projectile(entity actor, Sound _snd, float _size, float _health, float _death, float _proj_type, float _cull, float _cli_anim) +{ TC(Sound, _snd); entity proj; - sound (self, CH_WEAPON_A, _snd, VOL_BASE, ATTEN_NORM); + sound (actor, CH_WEAPON_A, _snd, VOL_BASE, ATTEN_NORM); proj = spawn (); - setorigin(proj, self.tur_shotorg); + setorigin(proj, actor.tur_shotorg); setsize(proj, '-0.5 -0.5 -0.5' * _size, '0.5 0.5 0.5' * _size); - proj.owner = self; - proj.realowner = self; + proj.owner = actor; + proj.realowner = actor; proj.bot_dodge = true; - proj.bot_dodgerating = self.shot_dmg; + proj.bot_dodgerating = actor.shot_dmg; setthink(proj, turret_projectile_explode); settouch(proj, turret_projectile_touch); proj.nextthink = time + 9; proj.movetype = MOVETYPE_FLYMISSILE; - proj.velocity = normalize(self.tur_shotdir_updated + randomvec() * self.shot_spread) * self.shot_speed; + proj.velocity = normalize(actor.tur_shotdir_updated + randomvec() * actor.shot_spread) * actor.shot_speed; proj.flags = FL_PROJECTILE; - proj.enemy = self.enemy; + proj.enemy = actor.enemy; proj.totalfrags = _death; PROJECTILE_MAKETRIGGER(proj); if(_health) @@ -502,7 +502,7 @@ void turret_do_updates(entity t_turret) { vector enemy_pos = real_origin(t_turret.enemy); - WITHSELF(t_turret, turret_tag_fire_update()); + turret_tag_fire_update(t_turret); t_turret.tur_shotdir_updated = v_forward; t_turret.tur_dist_enemy = vlen(t_turret.tur_shotorg - enemy_pos); @@ -533,137 +533,137 @@ void turret_do_updates(entity t_turret) ** the units .track_type and .track_flags **/ .float turret_framecounter; -void turret_track() -{SELFPARAM(); +void turret_track(entity this) +{ vector target_angle; // This is where we want to aim vector move_angle; // This is where we can aim float f_tmp; vector v1, v2; - v1 = self.tur_head.angles; - v2 = self.tur_head.avelocity; + v1 = this.tur_head.angles; + v2 = this.tur_head.avelocity; - if (self.track_flags == TFL_TRACK_NO) + if (this.track_flags == TFL_TRACK_NO) return; - if(!self.active) - target_angle = self.idle_aim - ('1 0 0' * self.aim_maxpitch); - else if (self.enemy == world) + if(!this.active) + target_angle = this.idle_aim - ('1 0 0' * this.aim_maxpitch); + else if (this.enemy == world) { - if(time > self.lip) - target_angle = self.idle_aim + self.angles; + if(time > this.lip) + target_angle = this.idle_aim + this.angles; else - target_angle = vectoangles(normalize(self.tur_aimpos - self.tur_shotorg)); + target_angle = vectoangles(normalize(this.tur_aimpos - this.tur_shotorg)); } else { - target_angle = vectoangles(normalize(self.tur_aimpos - self.tur_shotorg)); + target_angle = vectoangles(normalize(this.tur_aimpos - this.tur_shotorg)); } - self.tur_head.angles_x = anglemods(self.tur_head.angles_x); - self.tur_head.angles_y = anglemods(self.tur_head.angles_y); + this.tur_head.angles_x = anglemods(this.tur_head.angles_x); + this.tur_head.angles_y = anglemods(this.tur_head.angles_y); // Find the diffrence between where we currently aim and where we want to aim - //move_angle = target_angle - (self.angles + self.tur_head.angles); - //move_angle = shortangle_vxy(move_angle,(self.angles + self.tur_head.angles)); + //move_angle = target_angle - (this.angles + this.tur_head.angles); + //move_angle = shortangle_vxy(move_angle,(this.angles + this.tur_head.angles)); - move_angle = AnglesTransform_ToAngles(AnglesTransform_LeftDivide(AnglesTransform_FromAngles(self.angles), AnglesTransform_FromAngles(target_angle))) - self.tur_head.angles; - move_angle = shortangle_vxy(move_angle, self.tur_head.angles); + move_angle = AnglesTransform_ToAngles(AnglesTransform_LeftDivide(AnglesTransform_FromAngles(this.angles), AnglesTransform_FromAngles(target_angle))) - this.tur_head.angles; + move_angle = shortangle_vxy(move_angle, this.tur_head.angles); - switch(self.track_type) + switch(this.track_type) { case TFL_TRACKTYPE_STEPMOTOR: - f_tmp = self.aim_speed * self.ticrate; // dgr/sec -> dgr/tic - if (self.track_flags & TFL_TRACK_PITCH) + f_tmp = this.aim_speed * this.ticrate; // dgr/sec -> dgr/tic + if (this.track_flags & TFL_TRACK_PITCH) { - self.tur_head.angles_x += bound(-f_tmp,move_angle_x, f_tmp); - if(self.tur_head.angles_x > self.aim_maxpitch) - self.tur_head.angles_x = self.aim_maxpitch; + this.tur_head.angles_x += bound(-f_tmp,move_angle_x, f_tmp); + if(this.tur_head.angles_x > this.aim_maxpitch) + this.tur_head.angles_x = this.aim_maxpitch; - if(self.tur_head.angles_x < -self.aim_maxpitch) - self.tur_head.angles_x = self.aim_maxpitch; + if(this.tur_head.angles_x < -this.aim_maxpitch) + this.tur_head.angles_x = this.aim_maxpitch; } - if (self.track_flags & TFL_TRACK_ROTATE) + if (this.track_flags & TFL_TRACK_ROTATE) { - self.tur_head.angles_y += bound(-f_tmp, move_angle_y, f_tmp); - if(self.tur_head.angles_y > self.aim_maxrotate) - self.tur_head.angles_y = self.aim_maxrotate; + this.tur_head.angles_y += bound(-f_tmp, move_angle_y, f_tmp); + if(this.tur_head.angles_y > this.aim_maxrotate) + this.tur_head.angles_y = this.aim_maxrotate; - if(self.tur_head.angles_y < -self.aim_maxrotate) - self.tur_head.angles_y = self.aim_maxrotate; + if(this.tur_head.angles_y < -this.aim_maxrotate) + this.tur_head.angles_y = this.aim_maxrotate; } // CSQC - self.SendFlags |= TNSF_ANG; + this.SendFlags |= TNSF_ANG; return; case TFL_TRACKTYPE_FLUIDINERTIA: - f_tmp = self.aim_speed * self.ticrate; // dgr/sec -> dgr/tic - move_angle_x = bound(-self.aim_speed, move_angle_x * self.track_accel_pitch * f_tmp, self.aim_speed); - move_angle_y = bound(-self.aim_speed, move_angle_y * self.track_accel_rotate * f_tmp, self.aim_speed); - move_angle = (self.tur_head.avelocity * self.track_blendrate) + (move_angle * (1 - self.track_blendrate)); + f_tmp = this.aim_speed * this.ticrate; // dgr/sec -> dgr/tic + move_angle_x = bound(-this.aim_speed, move_angle_x * this.track_accel_pitch * f_tmp, this.aim_speed); + move_angle_y = bound(-this.aim_speed, move_angle_y * this.track_accel_rotate * f_tmp, this.aim_speed); + move_angle = (this.tur_head.avelocity * this.track_blendrate) + (move_angle * (1 - this.track_blendrate)); break; case TFL_TRACKTYPE_FLUIDPRECISE: - move_angle_y = bound(-self.aim_speed, move_angle_y, self.aim_speed); - move_angle_x = bound(-self.aim_speed, move_angle_x, self.aim_speed); + move_angle_y = bound(-this.aim_speed, move_angle_y, this.aim_speed); + move_angle_x = bound(-this.aim_speed, move_angle_x, this.aim_speed); break; } // pitch - if (self.track_flags & TFL_TRACK_PITCH) + if (this.track_flags & TFL_TRACK_PITCH) { - self.tur_head.avelocity_x = move_angle_x; - if((self.tur_head.angles_x + self.tur_head.avelocity_x * self.ticrate) > self.aim_maxpitch) + this.tur_head.avelocity_x = move_angle_x; + if((this.tur_head.angles_x + this.tur_head.avelocity_x * this.ticrate) > this.aim_maxpitch) { - self.tur_head.avelocity_x = 0; - self.tur_head.angles_x = self.aim_maxpitch; + this.tur_head.avelocity_x = 0; + this.tur_head.angles_x = this.aim_maxpitch; - self.SendFlags |= TNSF_ANG; + this.SendFlags |= TNSF_ANG; } - if((self.tur_head.angles_x + self.tur_head.avelocity_x * self.ticrate) < -self.aim_maxpitch) + if((this.tur_head.angles_x + this.tur_head.avelocity_x * this.ticrate) < -this.aim_maxpitch) { - self.tur_head.avelocity_x = 0; - self.tur_head.angles_x = -self.aim_maxpitch; + this.tur_head.avelocity_x = 0; + this.tur_head.angles_x = -this.aim_maxpitch; - self.SendFlags |= TNSF_ANG; + this.SendFlags |= TNSF_ANG; } } // rot - if (self.track_flags & TFL_TRACK_ROTATE) + if (this.track_flags & TFL_TRACK_ROTATE) { - self.tur_head.avelocity_y = move_angle_y; + this.tur_head.avelocity_y = move_angle_y; - if((self.tur_head.angles_y + self.tur_head.avelocity_y * self.ticrate) > self.aim_maxrotate) + if((this.tur_head.angles_y + this.tur_head.avelocity_y * this.ticrate) > this.aim_maxrotate) { - self.tur_head.avelocity_y = 0; - self.tur_head.angles_y = self.aim_maxrotate; + this.tur_head.avelocity_y = 0; + this.tur_head.angles_y = this.aim_maxrotate; - self.SendFlags |= TNSF_ANG; + this.SendFlags |= TNSF_ANG; } - if((self.tur_head.angles_y + self.tur_head.avelocity_y * self.ticrate) < -self.aim_maxrotate) + if((this.tur_head.angles_y + this.tur_head.avelocity_y * this.ticrate) < -this.aim_maxrotate) { - self.tur_head.avelocity_y = 0; - self.tur_head.angles_y = -self.aim_maxrotate; + this.tur_head.avelocity_y = 0; + this.tur_head.angles_y = -this.aim_maxrotate; - self.SendFlags |= TNSF_ANG; + this.SendFlags |= TNSF_ANG; } } - self.SendFlags |= TNSF_AVEL; + this.SendFlags |= TNSF_AVEL; // Force a angle update every 10'th frame - self.turret_framecounter += 1; - if(self.turret_framecounter >= 10) + this.turret_framecounter += 1; + if(this.turret_framecounter >= 10) { - self.SendFlags |= TNSF_ANG; - self.turret_framecounter = 0; + this.SendFlags |= TNSF_ANG; + this.turret_framecounter = 0; } } @@ -830,23 +830,23 @@ float turret_validate_target(entity e_turret, entity e_target, float validate_fl return 1; } -entity turret_select_target() -{SELFPARAM(); +entity turret_select_target(entity this) +{ entity e; // target looper entity float score; // target looper entity score entity e_enemy; // currently best scoreing target float m_score; // currently best scoreing target's score m_score = 0; - if(self.enemy && self.enemy.takedamage && turret_validate_target(self,self.enemy,self.target_validate_flags) > 0) + if(this.enemy && this.enemy.takedamage && turret_validate_target(this,this.enemy,this.target_validate_flags) > 0) { - e_enemy = self.enemy; - m_score = self.turret_score_target(self,e_enemy) * self.target_select_samebias; + e_enemy = this.enemy; + m_score = this.turret_score_target(this,e_enemy) * this.target_select_samebias; } else - e_enemy = self.enemy = world; + e_enemy = this.enemy = world; - e = findradius(self.origin, self.target_range); + e = findradius(this.origin, this.target_range); // Nothing to aim at? if (!e) @@ -856,11 +856,11 @@ entity turret_select_target() { if(e.takedamage) { - float f = turret_validate_target(self, e, self.target_select_flags); + float f = turret_validate_target(this, e, this.target_select_flags); //dprint("F is: ", ftos(f), "\n"); if ( f > 0) { - score = self.turret_score_target(self,e); + score = this.turret_score_target(this,e); if ((score > m_score) && (score > 0)) { e_enemy = e; @@ -897,78 +897,78 @@ entity turret_select_target() /** ** Preforms pre-fire checks based on the uints firecheck_flags **/ -float turret_firecheck() -{SELFPARAM(); +bool turret_firecheck(entity this) +{ // This one just dont care =) - if (self.firecheck_flags & TFL_FIRECHECK_NO) - return 1; + if (this.firecheck_flags & TFL_FIRECHECK_NO) + return true; - if (self.enemy == world) - return 0; + if (this.enemy == world) + return false; // Ready? - if (self.firecheck_flags & TFL_FIRECHECK_REFIRE) - if (self.attack_finished_single[0] > time) return 0; + if (this.firecheck_flags & TFL_FIRECHECK_REFIRE) + if (this.attack_finished_single[0] > time) return false; // Special case: volly fire turret that has to fire a full volly if a shot was fired. - if (self.shoot_flags & TFL_SHOOT_VOLLYALWAYS) - if (self.volly_counter != self.shot_volly) - if(self.ammo >= self.shot_dmg) - return 1; + if (this.shoot_flags & TFL_SHOOT_VOLLYALWAYS) + if (this.volly_counter != this.shot_volly) + if(this.ammo >= this.shot_dmg) + return true; // Lack of zombies makes shooting dead things unnecessary :P - if (self.firecheck_flags & TFL_FIRECHECK_DEAD) - if (IS_DEAD(self.enemy)) - return 0; + if (this.firecheck_flags & TFL_FIRECHECK_DEAD) + if (IS_DEAD(this.enemy)) + return false; // Own ammo? - if (self.firecheck_flags & TFL_FIRECHECK_AMMO_OWN) - if (self.ammo < self.shot_dmg) - return 0; + if (this.firecheck_flags & TFL_FIRECHECK_AMMO_OWN) + if (this.ammo < this.shot_dmg) + return false; // Other's ammo? (support-supply units) - if (self.firecheck_flags & TFL_FIRECHECK_AMMO_OTHER) - if (self.enemy.ammo >= self.enemy.ammo_max) - return 0; + if (this.firecheck_flags & TFL_FIRECHECK_AMMO_OTHER) + if (this.enemy.ammo >= this.enemy.ammo_max) + return false; // Target of opertunity? - if(turret_validate_target(self, self.tur_impactent, self.target_validate_flags) > 0) + if(turret_validate_target(this, this.tur_impactent, this.target_validate_flags) > 0) { - self.enemy = self.tur_impactent; - return 1; + this.enemy = this.tur_impactent; + return true; } - if (self.firecheck_flags & TFL_FIRECHECK_DISTANCES) + if (this.firecheck_flags & TFL_FIRECHECK_DISTANCES) { // To close? - if (self.tur_dist_aimpos < self.target_range_min) - if(turret_validate_target(self, self.tur_impactent, self.target_validate_flags) > 0) - return 1; // Target of opertunity? + if (this.tur_dist_aimpos < this.target_range_min) + if(turret_validate_target(this, this.tur_impactent, this.target_validate_flags) > 0) + return true; // Target of opertunity? else - return 0; + return false; } // Try to avoid FF? - if (self.firecheck_flags & TFL_FIRECHECK_AFF) - if (self.tur_impactent.team == self.team) - return 0; + if (this.firecheck_flags & TFL_FIRECHECK_AFF) + if (this.tur_impactent.team == this.team) + return false; // aim<->predicted impact - if (self.firecheck_flags & TFL_FIRECHECK_AIMDIST) - if (self.tur_dist_impact_to_aimpos > self.aim_firetolerance_dist) - return 0; + if (this.firecheck_flags & TFL_FIRECHECK_AIMDIST) + if (this.tur_dist_impact_to_aimpos > this.aim_firetolerance_dist) + return false; // Volly status - if (self.shot_volly > 1) - if (self.volly_counter == self.shot_volly) - if (self.ammo < (self.shot_dmg * self.shot_volly)) - return 0; + if (this.shot_volly > 1) + if (this.volly_counter == this.shot_volly) + if (this.ammo < (this.shot_dmg * this.shot_volly)) + return false; - /*if(self.firecheck_flags & TFL_FIRECHECK_VERIFIED) - if(self.tur_impactent != self.enemy) - return 0;*/ + /*if(this.firecheck_flags & TFL_FIRECHECK_VERIFIED) + if(this.tur_impactent != this.enemy) + return false;*/ - return 1; + return true; } bool turret_checkfire(entity this) @@ -976,10 +976,7 @@ bool turret_checkfire(entity this) if(MUTATOR_CALLHOOK(Turret_CheckFire, this)) return M_ARGV(1, bool); - bool ret = false; - WITHSELF(this, ret = this.turret_firecheckfunc()); - - return ret; + return this.turret_firecheckfunc(this); } void turret_fire() @@ -1037,7 +1034,7 @@ void turret_think(entity this) // So they can handle animation and wake up if need be. if(!self.active) { - turret_track(); + turret_track(self); return; } @@ -1072,11 +1069,11 @@ void turret_think(entity this) // Predict? if(!(self.aim_flags & TFL_AIM_NO)) - self.tur_aimpos = turret_aim_generic(); + self.tur_aimpos = turret_aim_generic(self); // Turn & pitch? if(!(self.track_flags & TFL_TRACK_NO)) - turret_track(); + turret_track(self); turret_do_updates(self); @@ -1092,11 +1089,11 @@ void turret_think(entity this) { // Predict or whatnot if(!(self.aim_flags & TFL_AIM_NO)) - self.tur_aimpos = turret_aim_generic(); + self.tur_aimpos = turret_aim_generic(self); // Turn & pitch if(!(self.track_flags & TFL_TRACK_NO)) - turret_track(); + turret_track(self); turret_do_updates(self); @@ -1132,7 +1129,7 @@ void turret_think(entity this) if(do_target_scan) { - self.enemy = turret_select_target(); + self.enemy = turret_select_target(self); self.target_select_time = time; } @@ -1141,7 +1138,7 @@ void turret_think(entity this) { // Turn & pitch if(!(self.track_flags & TFL_TRACK_NO)) - turret_track(); + turret_track(self); Turret tur = get_turretinfo(self.m_id); tur.tr_think(tur, self); @@ -1154,11 +1151,11 @@ void turret_think(entity this) // Predict? if(!(self.aim_flags & TFL_AIM_NO)) - self.tur_aimpos = turret_aim_generic(); + self.tur_aimpos = turret_aim_generic(self); // Turn & pitch? if(!(self.track_flags & TFL_TRACK_NO)) - turret_track(); + turret_track(self); turret_do_updates(self); @@ -1188,12 +1185,12 @@ void turret_use(entity this, entity actor, entity trigger) } -void turret_link() -{SELFPARAM(); - Net_LinkEntity(self, true, 0, turret_send); - setthink(self, turret_think); - self.nextthink = time; - self.tur_head.effects = EF_NODRAW; +void turret_link(entity this) +{ + Net_LinkEntity(this, true, 0, turret_send); + setthink(this, turret_think); + this.nextthink = time; + this.tur_head.effects = EF_NODRAW; } void turrets_manager_think(entity this) @@ -1240,8 +1237,8 @@ void turret_initparams(entity tur) #undef TRY } -float turret_initialize(Turret tur) -{SELFPARAM(); +bool turret_initialize(entity this, Turret tur) +{ if(!autocvar_g_turrets) return false; @@ -1249,7 +1246,7 @@ float turret_initialize(Turret tur) return false; // invalid turret // if tur_head exists, we can assume this turret re-spawned - if(!self.tur_head) { + if(!this.tur_head) { tur.tr_precache(tur); } @@ -1261,132 +1258,132 @@ float turret_initialize(Turret tur) e.nextthink = time + 2; } - if(!(self.spawnflags & TSF_SUSPENDED)) - builtin_droptofloor(); - - self.netname = tur.netname; - load_unit_settings(self, 0); - - if(!self.team || !teamplay) { self.team = MAX_SHOT_DISTANCE; } - if(!self.ticrate) { self.ticrate = ((self.turret_flags & TUR_FLAG_SUPPORT) ? 0.2 : 0.1); } - if(!self.health) { self.health = 1000; } - if(!self.shot_refire) { self.shot_refire = 1; } - if(!self.tur_shotorg) { self.tur_shotorg = '50 0 50'; } - if(!self.turret_flags) { self.turret_flags = TUR_FLAG_SPLASH | TUR_FLAG_MEDPROJ | TUR_FLAG_PLAYER; } - if(!self.damage_flags) { self.damage_flags = TFL_DMG_YES | TFL_DMG_RETALIATE | TFL_DMG_AIMSHAKE; } - if(!self.aim_flags) { self.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE; } - if(!self.track_type) { self.track_type = TFL_TRACKTYPE_STEPMOTOR; } - if(!self.track_flags) { self.track_flags = TFL_TRACK_PITCH | TFL_TRACK_ROTATE; } - if(!self.ammo_flags) { self.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE; } - if(!self.target_select_flags) { self.target_select_flags = TFL_TARGETSELECT_LOS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_ANGLELIMITS; } - if(!self.firecheck_flags) { self.firecheck_flags = TFL_FIRECHECK_DEAD | TFL_FIRECHECK_DISTANCES | TFL_FIRECHECK_LOS + if(!(this.spawnflags & TSF_SUSPENDED)) + WITHSELF(this, builtin_droptofloor()); + + this.netname = tur.netname; + load_unit_settings(this, 0); + + if(!this.team || !teamplay) { this.team = MAX_SHOT_DISTANCE; } + if(!this.ticrate) { this.ticrate = ((this.turret_flags & TUR_FLAG_SUPPORT) ? 0.2 : 0.1); } + if(!this.health) { this.health = 1000; } + if(!this.shot_refire) { this.shot_refire = 1; } + if(!this.tur_shotorg) { this.tur_shotorg = '50 0 50'; } + if(!this.turret_flags) { this.turret_flags = TUR_FLAG_SPLASH | TUR_FLAG_MEDPROJ | TUR_FLAG_PLAYER; } + if(!this.damage_flags) { this.damage_flags = TFL_DMG_YES | TFL_DMG_RETALIATE | TFL_DMG_AIMSHAKE; } + if(!this.aim_flags) { this.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE; } + if(!this.track_type) { this.track_type = TFL_TRACKTYPE_STEPMOTOR; } + if(!this.track_flags) { this.track_flags = TFL_TRACK_PITCH | TFL_TRACK_ROTATE; } + if(!this.ammo_flags) { this.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE; } + if(!this.target_select_flags) { this.target_select_flags = TFL_TARGETSELECT_LOS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_ANGLELIMITS; } + if(!this.firecheck_flags) { this.firecheck_flags = TFL_FIRECHECK_DEAD | TFL_FIRECHECK_DISTANCES | TFL_FIRECHECK_LOS | TFL_FIRECHECK_AIMDIST | TFL_FIRECHECK_TEAMCHECK | TFL_FIRECHECK_AMMO_OWN | TFL_FIRECHECK_REFIRE; } - if(self.track_type != TFL_TRACKTYPE_STEPMOTOR) + if(this.track_type != TFL_TRACKTYPE_STEPMOTOR) { // Fluid / Ineria mode. Looks mutch nicer. // Can reduce aim preformance alot, needs a bit diffrent aimspeed - self.aim_speed = bound(0.1, ((!self.aim_speed) ? 180 : self.aim_speed), 1000); + this.aim_speed = bound(0.1, ((!this.aim_speed) ? 180 : this.aim_speed), 1000); - if(!self.track_accel_pitch) { self.track_accel_pitch = 0.5; } - if(!self.track_accel_rotate) { self.track_accel_rotate = 0.5; } - if(!self.track_blendrate) { self.track_blendrate = 0.35; } + if(!this.track_accel_pitch) { this.track_accel_pitch = 0.5; } + if(!this.track_accel_rotate) { this.track_accel_rotate = 0.5; } + if(!this.track_blendrate) { this.track_blendrate = 0.35; } } - turret_initparams(self); + turret_initparams(this); - self.turret_flags = TUR_FLAG_ISTURRET | (tur.spawnflags); + this.turret_flags = TUR_FLAG_ISTURRET | (tur.spawnflags); - if(self.turret_flags & TUR_FLAG_SPLASH) - self.aim_flags |= TFL_AIM_SPLASH; + if(this.turret_flags & TUR_FLAG_SPLASH) + this.aim_flags |= TFL_AIM_SPLASH; - if(self.turret_flags & TUR_FLAG_MISSILE) - self.target_select_flags |= TFL_TARGETSELECT_MISSILES; + if(this.turret_flags & TUR_FLAG_MISSILE) + this.target_select_flags |= TFL_TARGETSELECT_MISSILES; - if(self.turret_flags & TUR_FLAG_PLAYER) - self.target_select_flags |= TFL_TARGETSELECT_PLAYERS; + if(this.turret_flags & TUR_FLAG_PLAYER) + this.target_select_flags |= TFL_TARGETSELECT_PLAYERS; - if(self.spawnflags & TSL_NO_RESPAWN) - self.damage_flags |= TFL_DMG_DEATH_NORESPAWN; + if(this.spawnflags & TSL_NO_RESPAWN) + this.damage_flags |= TFL_DMG_DEATH_NORESPAWN; - if (self.turret_flags & TUR_FLAG_SUPPORT) - self.turret_score_target = turret_targetscore_support; + if (this.turret_flags & TUR_FLAG_SUPPORT) + this.turret_score_target = turret_targetscore_support; else - self.turret_score_target = turret_targetscore_generic; + this.turret_score_target = turret_targetscore_generic; ++turret_count; - _setmodel(self, tur.model); - setsize(self, tur.mins, tur.maxs); - - self.m_id = tur.m_id; - self.classname = "turret_main"; - self.active = ACTIVE_ACTIVE; - self.effects = EF_NODRAW; - self.netname = tur.turret_name; - self.ticrate = bound(sys_frametime, self.ticrate, 60); - self.max_health = self.health; - self.target_validate_flags = self.target_select_flags; - self.ammo = self.ammo_max; - self.ammo_recharge *= self.ticrate; - self.solid = SOLID_BBOX; - self.takedamage = DAMAGE_AIM; - self.movetype = MOVETYPE_NOCLIP; - self.view_ofs = '0 0 0'; - self.turret_firecheckfunc = turret_firecheck; - self.event_damage = turret_damage; - self.use = turret_use; - self.bot_attack = true; - self.nextthink = time + 1; - self.nextthink += turret_count * sys_frametime; - - self.tur_head = new(turret_head); - _setmodel(self.tur_head, tur.head_model); - setsize(self.tur_head, '0 0 0', '0 0 0'); - setorigin(self.tur_head, '0 0 0'); - setattachment(self.tur_head, self, "tag_head"); - - self.tur_head.netname = self.tur_head.classname; - self.tur_head.team = self.team; - self.tur_head.owner = self; - self.tur_head.takedamage = DAMAGE_NO; - self.tur_head.solid = SOLID_NOT; - self.tur_head.movetype = self.movetype; - - if(!self.tur_defend) - if(self.target != "") + _setmodel(this, tur.model); + setsize(this, tur.mins, tur.maxs); + + this.m_id = tur.m_id; + this.classname = "turret_main"; + this.active = ACTIVE_ACTIVE; + this.effects = EF_NODRAW; + this.netname = tur.turret_name; + this.ticrate = bound(sys_frametime, this.ticrate, 60); + this.max_health = this.health; + this.target_validate_flags = this.target_select_flags; + this.ammo = this.ammo_max; + this.ammo_recharge *= this.ticrate; + this.solid = SOLID_BBOX; + this.takedamage = DAMAGE_AIM; + this.movetype = MOVETYPE_NOCLIP; + this.view_ofs = '0 0 0'; + this.turret_firecheckfunc = turret_firecheck; + this.event_damage = turret_damage; + this.use = turret_use; + this.bot_attack = true; + this.nextthink = time + 1; + this.nextthink += turret_count * sys_frametime; + + this.tur_head = new(turret_head); + _setmodel(this.tur_head, tur.head_model); + setsize(this.tur_head, '0 0 0', '0 0 0'); + setorigin(this.tur_head, '0 0 0'); + setattachment(this.tur_head, this, "tag_head"); + + this.tur_head.netname = this.tur_head.classname; + this.tur_head.team = this.team; + this.tur_head.owner = this; + this.tur_head.takedamage = DAMAGE_NO; + this.tur_head.solid = SOLID_NOT; + this.tur_head.movetype = this.movetype; + + if(!this.tur_defend) + if(this.target != "") { - self.tur_defend = find(world, targetname, self.target); - if (self.tur_defend == world) + this.tur_defend = find(world, targetname, this.target); + if (this.tur_defend == world) { - self.target = ""; + this.target = ""; LOG_TRACE("Turret has invalid defendpoint!\n"); } } - if (self.tur_defend) - self.idle_aim = self.tur_head.angles + angleofs(self.tur_head, self.tur_defend); + if (this.tur_defend) + this.idle_aim = this.tur_head.angles + angleofs(this.tur_head, this.tur_defend); else - self.idle_aim = '0 0 0'; + this.idle_aim = '0 0 0'; #ifdef TURRET_DEBUG - self.tur_debug_start = self.nextthink; - while(vdist(self.tur_debug_rvec, <, 2)) - self.tur_debug_rvec = randomvec() * 4; + this.tur_debug_start = this.nextthink; + while(vdist(this.tur_debug_rvec, <, 2)) + this.tur_debug_rvec = randomvec() * 4; - self.tur_debug_rvec_x = fabs(self.tur_debug_rvec_x); - self.tur_debug_rvec_y = fabs(self.tur_debug_rvec_y); - self.tur_debug_rvec_z = fabs(self.tur_debug_rvec_z); + this.tur_debug_rvec_x = fabs(this.tur_debug_rvec_x); + this.tur_debug_rvec_y = fabs(this.tur_debug_rvec_y); + this.tur_debug_rvec_z = fabs(this.tur_debug_rvec_z); #endif - turret_link(); - turret_respawn(self); - turret_tag_fire_update(); + turret_link(this); + turret_respawn(this); + turret_tag_fire_update(this); - tur.tr_setup(tur, self); + tur.tr_setup(tur, this); - if(MUTATOR_CALLHOOK(TurretSpawn, self)) + if(MUTATOR_CALLHOOK(TurretSpawn, this)) return false; return true; diff --git a/qcsrc/common/turrets/sv_turrets.qh b/qcsrc/common/turrets/sv_turrets.qh index 1d492e816..14b5b8853 100644 --- a/qcsrc/common/turrets/sv_turrets.qh +++ b/qcsrc/common/turrets/sv_turrets.qh @@ -1,11 +1,11 @@ #ifndef SV_TURRETS_H #define SV_TURRETS_H -entity turret_projectile(Sound _snd, float _size, float _health, float _death, float _proj_type, float _cull, float _cli_anim); +entity turret_projectile(entity actor, Sound _snd, float _size, float _health, float _death, float _proj_type, float _cull, float _cli_anim); void turret_projectile_explode(entity this); float turret_validate_target(entity e_turret, entity e_target, float validate_flags); -float turret_firecheck(); -entity turret_select_target(); +bool turret_firecheck(entity this); +entity turret_select_target(entity this); // turret fields .float ticrate; // interal ai think rate @@ -83,11 +83,11 @@ void turret_respawn(entity this); void turret_do_updates(entity e_turret); .vector tur_shotdir_updated; -.float() turret_firecheckfunc; // TODO: deprecate! +.float(entity this) turret_firecheckfunc; // TODO: deprecate! -void turrets_setframe(float _frame, float client_only); +void turrets_setframe(entity this, float _frame, float client_only); -float turret_initialize(Turret tur); +bool turret_initialize(entity this, Turret tur); /// Function to use for target evaluation. usualy turret_targetscore_generic .float(entity _turret, entity _target) turret_score_target; diff --git a/qcsrc/common/turrets/turret/ewheel.qc b/qcsrc/common/turrets/turret/ewheel.qc index 113431003..9debc63cc 100644 --- a/qcsrc/common/turrets/turret/ewheel.qc +++ b/qcsrc/common/turrets/turret/ewheel.qc @@ -36,138 +36,137 @@ const float ewheel_anim_fwd_fast = 2; const float ewheel_anim_bck_slow = 3; const float ewheel_anim_bck_fast = 4; -void ewheel_move_path() -{SELFPARAM(); +void ewheel_move_path(entity this) +{ #ifdef EWHEEL_FANCYPATH // Are we close enougth to a path node to switch to the next? - if(vdist(self.origin - self.pathcurrent.origin, <, 64)) - if (self.pathcurrent.path_next == world) + if(vdist(this.origin - this.pathcurrent.origin, <, 64)) + if (this.pathcurrent.path_next == world) { // Path endpoint reached - pathlib_deletepath(self.pathcurrent.owner); - self.pathcurrent = world; + pathlib_deletepath(this.pathcurrent.owner); + this.pathcurrent = world; - if (self.pathgoal) + if (this.pathgoal) { - if (self.pathgoal.use) - self.pathgoal.use(self.pathgoal, NULL, NULL); + if (this.pathgoal.use) + this.pathgoal.use(this.pathgoal, NULL, NULL); - if (self.pathgoal.enemy) + if (this.pathgoal.enemy) { - self.pathcurrent = pathlib_astar(self, self.pathgoal.origin,self.pathgoal.enemy.origin); - self.pathgoal = self.pathgoal.enemy; + this.pathcurrent = pathlib_astar(this, this.pathgoal.origin,this.pathgoal.enemy.origin); + this.pathgoal = this.pathgoal.enemy; } } else - self.pathgoal = world; + this.pathgoal = world; } else - self.pathcurrent = self.pathcurrent.path_next; + this.pathcurrent = this.pathcurrent.path_next; #else - if(vdist(self.origin - self.pathcurrent.origin, <, 64)) - self.pathcurrent = self.pathcurrent.enemy; + if(vdist(this.origin - this.pathcurrent.origin, <, 64)) + this.pathcurrent = this.pathcurrent.enemy; #endif - if (self.pathcurrent) + if (this.pathcurrent) { - self.moveto = self.pathcurrent.origin; - self.steerto = steerlib_attract2(self, self.moveto, 0.5, 500, 0.95); + this.moveto = this.pathcurrent.origin; + this.steerto = steerlib_attract2(this, this.moveto, 0.5, 500, 0.95); - movelib_move_simple(self, v_forward, (autocvar_g_turrets_unit_ewheel_speed_fast), 0.4); + movelib_move_simple(this, v_forward, (autocvar_g_turrets_unit_ewheel_speed_fast), 0.4); } } -void ewheel_move_enemy() -{SELFPARAM(); +void ewheel_move_enemy(entity this) +{ float newframe; - self.steerto = steerlib_arrive(self, self.enemy.origin,self.target_range_optimal); + this.steerto = steerlib_arrive(this, this.enemy.origin,this.target_range_optimal); - self.moveto = self.origin + self.steerto * 128; + this.moveto = this.origin + this.steerto * 128; - if (self.tur_dist_enemy > self.target_range_optimal) + if (this.tur_dist_enemy > this.target_range_optimal) { - if ( self.tur_head.spawnshieldtime < 1 ) + if ( this.tur_head.spawnshieldtime < 1 ) { newframe = ewheel_anim_fwd_fast; - movelib_move_simple(self, v_forward, (autocvar_g_turrets_unit_ewheel_speed_fast), 0.4); + movelib_move_simple(this, v_forward, (autocvar_g_turrets_unit_ewheel_speed_fast), 0.4); } - else if (self.tur_head.spawnshieldtime < 2) + else if (this.tur_head.spawnshieldtime < 2) { newframe = ewheel_anim_fwd_slow; - movelib_move_simple(self, v_forward, (autocvar_g_turrets_unit_ewheel_speed_slow), 0.4); + movelib_move_simple(this, v_forward, (autocvar_g_turrets_unit_ewheel_speed_slow), 0.4); } else { newframe = ewheel_anim_fwd_slow; - movelib_move_simple(self, v_forward, (autocvar_g_turrets_unit_ewheel_speed_slower), 0.4); + movelib_move_simple(this, v_forward, (autocvar_g_turrets_unit_ewheel_speed_slower), 0.4); } } - else if (self.tur_dist_enemy < self.target_range_optimal * 0.5) + else if (this.tur_dist_enemy < this.target_range_optimal * 0.5) { newframe = ewheel_anim_bck_slow; - movelib_move_simple(self, v_forward * -1, (autocvar_g_turrets_unit_ewheel_speed_slow), 0.4); + movelib_move_simple(this, v_forward * -1, (autocvar_g_turrets_unit_ewheel_speed_slow), 0.4); } else { newframe = ewheel_anim_stop; - movelib_brake_simple(self, (autocvar_g_turrets_unit_ewheel_speed_stop)); + movelib_brake_simple(this, (autocvar_g_turrets_unit_ewheel_speed_stop)); } - turrets_setframe(newframe, false); + turrets_setframe(this, newframe, false); } -void ewheel_move_idle() -{SELFPARAM(); - if(self.frame != 0) +void ewheel_move_idle(entity this) +{ + if(this.frame != 0) { - self.SendFlags |= TNSF_ANIM; - self.anim_start_time = time; + this.SendFlags |= TNSF_ANIM; + this.anim_start_time = time; } - self.frame = 0; - if(self.velocity) - movelib_brake_simple(self, (autocvar_g_turrets_unit_ewheel_speed_stop)); + this.frame = 0; + if(this.velocity) + movelib_brake_simple(this, (autocvar_g_turrets_unit_ewheel_speed_stop)); } -spawnfunc(turret_ewheel) { if(!turret_initialize(TUR_EWHEEL)) remove(this); } +spawnfunc(turret_ewheel) { if(!turret_initialize(this, TUR_EWHEEL)) remove(this); } METHOD(EWheel, tr_think, void(EWheel thistur, entity it)) { - SELFPARAM(); float vz; vector wish_angle, real_angle; - vz = self.velocity_z; + vz = it.velocity_z; - self.angles_x = anglemods(self.angles_x); - self.angles_y = anglemods(self.angles_y); + it.angles_x = anglemods(it.angles_x); + it.angles_y = anglemods(it.angles_y); - fixedmakevectors(self.angles); + fixedmakevectors(it.angles); - wish_angle = normalize(self.steerto); + wish_angle = normalize(it.steerto); wish_angle = vectoangles(wish_angle); - real_angle = wish_angle - self.angles; - real_angle = shortangle_vxy(real_angle, self.tur_head.angles); + real_angle = wish_angle - it.angles; + real_angle = shortangle_vxy(real_angle, it.tur_head.angles); - self.tur_head.spawnshieldtime = fabs(real_angle_y); - real_angle_y = bound(-self.tur_head.aim_speed, real_angle_y, self.tur_head.aim_speed); - self.angles_y = (self.angles_y + real_angle_y); + it.tur_head.spawnshieldtime = fabs(real_angle_y); + real_angle_y = bound(-it.tur_head.aim_speed, real_angle_y, it.tur_head.aim_speed); + it.angles_y = (it.angles_y + real_angle_y); - if(self.enemy) - ewheel_move_enemy(); - else if(self.pathcurrent) - ewheel_move_path(); + if(it.enemy) + ewheel_move_enemy(it); + else if(it.pathcurrent) + ewheel_move_path(it); else - ewheel_move_idle(); + ewheel_move_idle(it); - self.velocity_z = vz; + it.velocity_z = vz; - if(self.velocity) - self.SendFlags |= TNSF_MOVE; + if(it.velocity) + it.SendFlags |= TNSF_MOVE; } METHOD(EWheel, tr_death, void(EWheel this, entity it)) diff --git a/qcsrc/common/turrets/turret/ewheel_weapon.qc b/qcsrc/common/turrets/turret/ewheel_weapon.qc index 50212458f..17df7dac0 100644 --- a/qcsrc/common/turrets/turret/ewheel_weapon.qc +++ b/qcsrc/common/turrets/turret/ewheel_weapon.qc @@ -21,7 +21,7 @@ METHOD(EWheelAttack, wr_think, void(entity thiswep, entity actor, .entity weapon turret_do_updates(actor); - entity missile = turret_projectile(SND_LASERGUN_FIRE, 1, 0, DEATH_TURRET_EWHEEL.m_id, PROJECTILE_BLASTER, true, true); + entity missile = turret_projectile(actor, SND_LASERGUN_FIRE, 1, 0, DEATH_TURRET_EWHEEL.m_id, PROJECTILE_BLASTER, true, true); missile.missile_flags = MIF_SPLASH; Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, actor.tur_shotorg, actor.tur_shotdir_updated * 1000, 1); diff --git a/qcsrc/common/turrets/turret/flac.qc b/qcsrc/common/turrets/turret/flac.qc index 0969018d6..64b32d4a7 100644 --- a/qcsrc/common/turrets/turret/flac.qc +++ b/qcsrc/common/turrets/turret/flac.qc @@ -22,7 +22,7 @@ REGISTER_TURRET(FLAC, NEW(Flac)); #ifdef SVQC -spawnfunc(turret_flac) { if (!turret_initialize(TUR_FLAC)) remove(this); } +spawnfunc(turret_flac) { if (!turret_initialize(this, TUR_FLAC)) remove(this); } METHOD(Flac, tr_setup, void(Flac this, entity it)) { diff --git a/qcsrc/common/turrets/turret/flac_weapon.qc b/qcsrc/common/turrets/turret/flac_weapon.qc index eb8db7358..6adacff31 100644 --- a/qcsrc/common/turrets/turret/flac_weapon.qc +++ b/qcsrc/common/turrets/turret/flac_weapon.qc @@ -20,9 +20,9 @@ METHOD(FlacAttack, wr_think, void(entity thiswep, entity actor, .entity weaponen weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); } - turret_tag_fire_update(); + turret_tag_fire_update(actor); - entity proj = turret_projectile(SND_HAGAR_FIRE, 5, 0, DEATH_TURRET_FLAC.m_id, PROJECTILE_HAGAR, true, true); + entity proj = turret_projectile(actor, SND_HAGAR_FIRE, 5, 0, DEATH_TURRET_FLAC.m_id, PROJECTILE_HAGAR, true, true); proj.missile_flags = MIF_SPLASH | MIF_PROXY; setthink(proj, turret_flac_projectile_think_explode); proj.nextthink = time + actor.tur_impacttime + (random() * 0.01 - random() * 0.01); diff --git a/qcsrc/common/turrets/turret/fusionreactor.qc b/qcsrc/common/turrets/turret/fusionreactor.qc index 9b67e1db2..013c089f3 100644 --- a/qcsrc/common/turrets/turret/fusionreactor.qc +++ b/qcsrc/common/turrets/turret/fusionreactor.qc @@ -17,36 +17,36 @@ REGISTER_TURRET(FUSIONREACTOR, NEW(FusionReactor)); #ifdef IMPLEMENTATION #ifdef SVQC -bool turret_fusionreactor_firecheck() -{SELFPARAM(); - if (self.attack_finished_single[0] > time) +bool turret_fusionreactor_firecheck(entity this) +{ + if (this.attack_finished_single[0] > time) return false; - if (IS_DEAD(self.enemy)) + if (IS_DEAD(this.enemy)) return false; - if (self.enemy == world) + if (this.enemy == world) return false; - if (self.ammo < self.shot_dmg) + if (this.ammo < this.shot_dmg) return false; - if (self.enemy.ammo >= self.enemy.ammo_max) + if (this.enemy.ammo >= this.enemy.ammo_max) return false; - if(vdist(self.enemy.origin - self.origin, >, self.target_range)) + if(vdist(this.enemy.origin - this.origin, >, this.target_range)) return false; - if(self.team != self.enemy.team) + if(this.team != this.enemy.team) return false; - if(!(self.enemy.ammo_flags & TFL_AMMO_ENERGY)) + if(!(this.enemy.ammo_flags & TFL_AMMO_ENERGY)) return false; return true; } -spawnfunc(turret_fusionreactor) { if (!turret_initialize(TUR_FUSIONREACTOR)) remove(this); } +spawnfunc(turret_fusionreactor) { if (!turret_initialize(this, TUR_FUSIONREACTOR)) remove(this); } METHOD(FusionReactor, tr_attack, void(FusionReactor this, entity it)) { @@ -56,8 +56,7 @@ METHOD(FusionReactor, tr_attack, void(FusionReactor this, entity it)) } METHOD(FusionReactor, tr_think, void(FusionReactor thistur, entity it)) { - SELFPARAM(); - self.tur_head.avelocity = '0 250 0' * (self.ammo / self.ammo_max); + it.tur_head.avelocity = '0 250 0' * (it.ammo / it.ammo_max); } METHOD(FusionReactor, tr_setup, void(FusionReactor this, entity it)) { diff --git a/qcsrc/common/turrets/turret/hellion.qc b/qcsrc/common/turrets/turret/hellion.qc index b3100bcb5..fde81bfea 100644 --- a/qcsrc/common/turrets/turret/hellion.qc +++ b/qcsrc/common/turrets/turret/hellion.qc @@ -22,16 +22,15 @@ REGISTER_TURRET(HELLION, NEW(Hellion)); #ifdef SVQC -spawnfunc(turret_hellion) { if (!turret_initialize(TUR_HELLION)) remove(this); } +spawnfunc(turret_hellion) { if (!turret_initialize(this, TUR_HELLION)) remove(this); } METHOD(Hellion, tr_think, void(Hellion thistur, entity it)) { - SELFPARAM(); - if (self.tur_head.frame != 0) - self.tur_head.frame += 1; + if (it.tur_head.frame != 0) + it.tur_head.frame += 1; - if (self.tur_head.frame >= 7) - self.tur_head.frame = 0; + if (it.tur_head.frame >= 7) + it.tur_head.frame = 0; } METHOD(Hellion, tr_setup, void(Hellion this, entity it)) { diff --git a/qcsrc/common/turrets/turret/hellion_weapon.qc b/qcsrc/common/turrets/turret/hellion_weapon.qc index 2b80607ce..f053d782e 100644 --- a/qcsrc/common/turrets/turret/hellion_weapon.qc +++ b/qcsrc/common/turrets/turret/hellion_weapon.qc @@ -29,7 +29,7 @@ METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, .entity weapo actor.tur_shotorg = gettaginfo(actor.tur_head, gettagindex(actor.tur_head, "tag_fire2")); } - entity missile = turret_projectile(SND_ROCKET_FIRE, 6, 10, DEATH_TURRET_HELLION.m_id, PROJECTILE_ROCKET, false, false); + entity missile = turret_projectile(actor, SND_ROCKET_FIRE, 6, 10, DEATH_TURRET_HELLION.m_id, PROJECTILE_ROCKET, false, false); te_explosion (missile.origin); setthink(missile, turret_hellion_missile_think); missile.nextthink = time; diff --git a/qcsrc/common/turrets/turret/hk.qc b/qcsrc/common/turrets/turret/hk.qc index 2c9f68cf7..e7fc07030 100644 --- a/qcsrc/common/turrets/turret/hk.qc +++ b/qcsrc/common/turrets/turret/hk.qc @@ -28,16 +28,15 @@ REGISTER_TURRET(HK, NEW(HunterKiller)); .float atime; #endif -spawnfunc(turret_hk) { if(!turret_initialize(TUR_HK)) remove(this); } +spawnfunc(turret_hk) { if(!turret_initialize(this, TUR_HK)) remove(this); } METHOD(HunterKiller, tr_think, void(HunterKiller thistur, entity it)) { - SELFPARAM(); - if (self.tur_head.frame != 0) - self.tur_head.frame = self.tur_head.frame + 1; + if (it.tur_head.frame != 0) + it.tur_head.frame = it.tur_head.frame + 1; - if (self.tur_head.frame > 5) - self.tur_head.frame = 0; + if (it.tur_head.frame > 5) + it.tur_head.frame = 0; } float turret_hk_addtarget(entity e_target,entity e_sender); diff --git a/qcsrc/common/turrets/turret/hk_weapon.qc b/qcsrc/common/turrets/turret/hk_weapon.qc index dffe83c82..7d14757a1 100644 --- a/qcsrc/common/turrets/turret/hk_weapon.qc +++ b/qcsrc/common/turrets/turret/hk_weapon.qc @@ -26,7 +26,7 @@ METHOD(HunterKillerAttack, wr_think, void(entity thiswep, entity actor, .entity actor.tur_head = actor; weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); } - entity missile = turret_projectile(SND_ROCKET_FIRE, 6, 10, DEATH_TURRET_HK.m_id, PROJECTILE_ROCKET, false, false); + entity missile = turret_projectile(actor, SND_ROCKET_FIRE, 6, 10, DEATH_TURRET_HK.m_id, PROJECTILE_ROCKET, false, false); te_explosion (missile.origin); setthink(missile, turret_hk_missile_think); diff --git a/qcsrc/common/turrets/turret/machinegun.qc b/qcsrc/common/turrets/turret/machinegun.qc index 5202ea371..5dac49efc 100644 --- a/qcsrc/common/turrets/turret/machinegun.qc +++ b/qcsrc/common/turrets/turret/machinegun.qc @@ -22,7 +22,7 @@ REGISTER_TURRET(MACHINEGUN, NEW(MachineGunTurret)); #ifdef SVQC -spawnfunc(turret_machinegun) { if (!turret_initialize(TUR_MACHINEGUN)) remove(this); } +spawnfunc(turret_machinegun) { if (!turret_initialize(this, TUR_MACHINEGUN)) remove(this); } METHOD(MachineGunTurret, tr_setup, void(MachineGunTurret this, entity it)) { diff --git a/qcsrc/common/turrets/turret/mlrs.qc b/qcsrc/common/turrets/turret/mlrs.qc index bff258605..bce27118a 100644 --- a/qcsrc/common/turrets/turret/mlrs.qc +++ b/qcsrc/common/turrets/turret/mlrs.qc @@ -22,17 +22,16 @@ REGISTER_TURRET(MLRS, NEW(MLRSTurret)); #ifdef SVQC -spawnfunc(turret_mlrs) { if (!turret_initialize(TUR_MLRS)) remove(this); } +spawnfunc(turret_mlrs) { if (!turret_initialize(this, TUR_MLRS)) remove(this); } METHOD(MLRSTurret, tr_think, void(MLRSTurret thistur, entity it)) { - SELFPARAM(); // 0 = full, 6 = empty - self.tur_head.frame = bound(0, 6 - floor(0.1 + self.ammo / self.shot_dmg), 6); - if(self.tur_head.frame < 0) + it.tur_head.frame = bound(0, 6 - floor(0.1 + it.ammo / it.shot_dmg), 6); + if(it.tur_head.frame < 0) { - LOG_TRACE("ammo:",ftos(self.ammo),"\n"); - LOG_TRACE("shot_dmg:",ftos(self.shot_dmg),"\n"); + LOG_TRACE("ammo:",ftos(it.ammo),"\n"); + LOG_TRACE("shot_dmg:",ftos(it.shot_dmg),"\n"); } } METHOD(MLRSTurret, tr_setup, void(MLRSTurret this, entity it)) diff --git a/qcsrc/common/turrets/turret/mlrs_weapon.qc b/qcsrc/common/turrets/turret/mlrs_weapon.qc index 2f8dd65e9..305392cd5 100644 --- a/qcsrc/common/turrets/turret/mlrs_weapon.qc +++ b/qcsrc/common/turrets/turret/mlrs_weapon.qc @@ -18,8 +18,8 @@ METHOD(MLRSTurretAttack, wr_think, void(entity thiswep, entity actor, .entity we actor.shot_radius = 500; weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, 0, w_ready); } - turret_tag_fire_update(); - entity missile = turret_projectile(SND_ROCKET_FIRE, 6, 10, DEATH_TURRET_MLRS.m_id, PROJECTILE_ROCKET, true, true); + turret_tag_fire_update(actor); + entity missile = turret_projectile(actor, SND_ROCKET_FIRE, 6, 10, DEATH_TURRET_MLRS.m_id, PROJECTILE_ROCKET, true, true); missile.nextthink = time + max(actor.tur_impacttime,(actor.shot_radius * 2) / actor.shot_speed); missile.missile_flags = MIF_SPLASH; te_explosion (missile.origin); diff --git a/qcsrc/common/turrets/turret/phaser.qc b/qcsrc/common/turrets/turret/phaser.qc index 7675bc41e..f604b0466 100644 --- a/qcsrc/common/turrets/turret/phaser.qc +++ b/qcsrc/common/turrets/turret/phaser.qc @@ -22,34 +22,33 @@ REGISTER_TURRET(PHASER, NEW(PhaserTurret)); #ifdef SVQC -spawnfunc(turret_phaser) { if (!turret_initialize(TUR_PHASER)) remove(this); } +spawnfunc(turret_phaser) { if (!turret_initialize(this, TUR_PHASER)) remove(this); } .int fireflag; METHOD(PhaserTurret, tr_think, void(PhaserTurret thistur, entity it)) { - SELFPARAM(); - if (self.tur_head.frame != 0) + if (it.tur_head.frame != 0) { - if (self.fireflag == 1) + if (it.fireflag == 1) { - if (self.tur_head.frame == 10) - self.tur_head.frame = 1; + if (it.tur_head.frame == 10) + it.tur_head.frame = 1; else - self.tur_head.frame = self.tur_head.frame +1; + it.tur_head.frame = it.tur_head.frame +1; } - else if (self.fireflag == 2 ) + else if (it.fireflag == 2 ) { - self.tur_head.frame = self.tur_head.frame +1; - if (self.tur_head.frame == 15) + it.tur_head.frame = it.tur_head.frame +1; + if (it.tur_head.frame == 15) { - self.tur_head.frame = 0; - self.fireflag = 0; + it.tur_head.frame = 0; + it.fireflag = 0; } } } } -float turret_phaser_firecheck(); +bool turret_phaser_firecheck(entity this); METHOD(PhaserTurret, tr_setup, void(PhaserTurret this, entity it)) { it.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE; @@ -57,11 +56,10 @@ METHOD(PhaserTurret, tr_setup, void(PhaserTurret this, entity it)) it.turret_firecheckfunc = turret_phaser_firecheck; } -float turret_phaser_firecheck() +bool turret_phaser_firecheck(entity this) { - SELFPARAM(); - if (self.fireflag != 0) return 0; - return turret_firecheck(); + if (this.fireflag != 0) return false; + return turret_firecheck(this); } #endif diff --git a/qcsrc/common/turrets/turret/plasma.qc b/qcsrc/common/turrets/turret/plasma.qc index 97f5c5659..844964356 100644 --- a/qcsrc/common/turrets/turret/plasma.qc +++ b/qcsrc/common/turrets/turret/plasma.qc @@ -22,7 +22,7 @@ REGISTER_TURRET(PLASMA, NEW(PlasmaTurret)); #ifdef SVQC -spawnfunc(turret_plasma) { if (!turret_initialize(TUR_PLASMA)) remove(this); } +spawnfunc(turret_plasma) { if (!turret_initialize(this, TUR_PLASMA)) remove(this); } METHOD(PlasmaTurret, tr_attack, void(PlasmaTurret this, entity it)) { @@ -46,12 +46,11 @@ METHOD(PlasmaTurret, tr_attack, void(PlasmaTurret this, entity it)) } METHOD(PlasmaTurret, tr_think, void(PlasmaTurret thistur, entity it)) { - SELFPARAM(); - if (self.tur_head.frame != 0) - self.tur_head.frame = self.tur_head.frame + 1; + if (it.tur_head.frame != 0) + it.tur_head.frame = it.tur_head.frame + 1; - if (self.tur_head.frame > 5) - self.tur_head.frame = 0; + if (it.tur_head.frame > 5) + it.tur_head.frame = 0; } METHOD(PlasmaTurret, tr_setup, void(PlasmaTurret this, entity it)) { diff --git a/qcsrc/common/turrets/turret/plasma_dual.qc b/qcsrc/common/turrets/turret/plasma_dual.qc index 9874fb3cb..2193d84b7 100644 --- a/qcsrc/common/turrets/turret/plasma_dual.qc +++ b/qcsrc/common/turrets/turret/plasma_dual.qc @@ -28,7 +28,7 @@ REGISTER_TURRET(PLASMA_DUAL, NEW(DualPlasmaTurret)); #ifdef SVQC -spawnfunc(turret_plasma_dual) { if (!turret_initialize(TUR_PLASMA_DUAL)) remove(this); } +spawnfunc(turret_plasma_dual) { if (!turret_initialize(this, TUR_PLASMA_DUAL)) remove(this); } METHOD(DualPlasmaTurret, tr_attack, void(DualPlasmaTurret thistur, entity it)) { @@ -50,12 +50,11 @@ METHOD(DualPlasmaTurret, tr_attack, void(DualPlasmaTurret thistur, entity it)) } METHOD(DualPlasmaTurret, tr_think, void(DualPlasmaTurret thistur, entity it)) { - SELFPARAM(); - if ((self.tur_head.frame != 0) && (self.tur_head.frame != 3)) - self.tur_head.frame = self.tur_head.frame + 1; + if ((it.tur_head.frame != 0) && (it.tur_head.frame != 3)) + it.tur_head.frame = it.tur_head.frame + 1; - if (self.tur_head.frame > 6) - self.tur_head.frame = 0; + if (it.tur_head.frame > 6) + it.tur_head.frame = 0; } #endif diff --git a/qcsrc/common/turrets/turret/plasma_weapon.qc b/qcsrc/common/turrets/turret/plasma_weapon.qc index 0d61df550..535e8b475 100644 --- a/qcsrc/common/turrets/turret/plasma_weapon.qc +++ b/qcsrc/common/turrets/turret/plasma_weapon.qc @@ -16,7 +16,7 @@ METHOD(PlasmaAttack, wr_think, void(entity thiswep, entity actor, .entity weapon actor.tur_head = actor; weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); } - entity missile = turret_projectile(SND_HAGAR_FIRE, 1, 0, DEATH_TURRET_PLASMA.m_id, PROJECTILE_ELECTRO_BEAM, true, true); + entity missile = turret_projectile(actor, SND_HAGAR_FIRE, 1, 0, DEATH_TURRET_PLASMA.m_id, PROJECTILE_ELECTRO_BEAM, true, true); missile.missile_flags = MIF_SPLASH; Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, actor.tur_shotorg, actor.tur_shotdir_updated * 1000, 1); } diff --git a/qcsrc/common/turrets/turret/tesla.qc b/qcsrc/common/turrets/turret/tesla.qc index 35929ccc5..7da97e786 100644 --- a/qcsrc/common/turrets/turret/tesla.qc +++ b/qcsrc/common/turrets/turret/tesla.qc @@ -22,38 +22,37 @@ REGISTER_TURRET(TESLA, NEW(TeslaCoil)); #ifdef SVQC -spawnfunc(turret_tesla) { if (!turret_initialize(TUR_TESLA)) remove(this); } +spawnfunc(turret_tesla) { if (!turret_initialize(this, TUR_TESLA)) remove(this); } METHOD(TeslaCoil, tr_think, void(TeslaCoil thistur, entity it)) { - SELFPARAM(); - if(!self.active) + if(!it.active) { - self.tur_head.avelocity = '0 0 0'; + it.tur_head.avelocity = '0 0 0'; return; } - if(self.ammo < self.shot_dmg) + if(it.ammo < it.shot_dmg) { - self.tur_head.avelocity = '0 45 0' * (self.ammo / self.shot_dmg); + it.tur_head.avelocity = '0 45 0' * (it.ammo / it.shot_dmg); } else { - self.tur_head.avelocity = '0 180 0' * (self.ammo / self.shot_dmg); + it.tur_head.avelocity = '0 180 0' * (it.ammo / it.shot_dmg); - if(self.attack_finished_single[0] > time) + if(it.attack_finished_single[0] > time) return; float f; - f = (self.ammo / self.ammo_max); + f = (it.ammo / it.ammo_max); f = f * f; if(f > random()) if(random() < 0.1) - te_csqc_lightningarc(self.tur_shotorg,self.tur_shotorg + (randomvec() * 350)); + te_csqc_lightningarc(it.tur_shotorg,it.tur_shotorg + (randomvec() * 350)); } } -float turret_tesla_firecheck(); +bool turret_tesla_firecheck(entity this); METHOD(TeslaCoil, tr_setup, void(TeslaCoil this, entity it)) { it.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_MISSILES | @@ -70,40 +69,40 @@ METHOD(TeslaCoil, tr_setup, void(TeslaCoil this, entity it)) it.track_flags = TFL_TRACK_NO; } -float turret_tesla_firecheck() -{SELFPARAM(); +bool turret_tesla_firecheck(entity this) +{ // g_turrets_targetscan_maxdelay forces a target re-scan at least this often float do_target_scan = 0; - if((self.target_select_time + autocvar_g_turrets_targetscan_maxdelay) < time) + if((this.target_select_time + autocvar_g_turrets_targetscan_maxdelay) < time) do_target_scan = 1; // Old target (if any) invalid? - if(self.target_validate_time < time) - if (turret_validate_target(self, self.enemy, self.target_validate_flags) <= 0) + if(this.target_validate_time < time) + if (turret_validate_target(this, this.enemy, this.target_validate_flags) <= 0) { - self.enemy = world; - self.target_validate_time = time + 0.5; + this.enemy = world; + this.target_validate_time = time + 0.5; do_target_scan = 1; } // But never more often then g_turrets_targetscan_mindelay! - if (self.target_select_time + autocvar_g_turrets_targetscan_mindelay > time) + if (this.target_select_time + autocvar_g_turrets_targetscan_mindelay > time) do_target_scan = 0; if(do_target_scan) { - self.enemy = turret_select_target(); - self.target_select_time = time; + this.enemy = turret_select_target(this); + this.target_select_time = time; } - if(!turret_firecheck()) - return 0; + if(!turret_firecheck(this)) + return false; - if(self.enemy) - return 1; + if(this.enemy) + return true; - return 0; + return false; } #endif diff --git a/qcsrc/common/turrets/turret/walker.qc b/qcsrc/common/turrets/turret/walker.qc index fec4060d4..8d8106a55 100644 --- a/qcsrc/common/turrets/turret/walker.qc +++ b/qcsrc/common/turrets/turret/walker.qc @@ -65,12 +65,12 @@ const int ANIM_ROAM = 11; #define WALKER_PATH(this, s, e) pathlib_astar(this, s, e) -float walker_firecheck() -{SELFPARAM(); - if (self.animflag == ANIM_MELEE) - return 0; +bool walker_firecheck(entity this) +{ + if (this.animflag == ANIM_MELEE) + return false; - return turret_firecheck(); + return turret_firecheck(this); } void walker_melee_do_dmg(entity this) @@ -78,15 +78,15 @@ void walker_melee_do_dmg(entity this) vector where; entity e; - makevectors(self.angles); - where = self.origin + v_forward * 128; + makevectors(this.angles); + where = this.origin + v_forward * 128; e = findradius(where,32); while (e) { - if (turret_validate_target(self, e, self.target_validate_flags)) - if (e != self && e.owner != self) - Damage(e, self, self, (autocvar_g_turrets_unit_walker_melee_damage), DEATH_TURRET_WALK_MELEE.m_id, '0 0 0', v_forward * (autocvar_g_turrets_unit_walker_melee_force)); + if (turret_validate_target(this, e, this.target_validate_flags)) + if (e != this && e.owner != this) + Damage(e, this, this, (autocvar_g_turrets_unit_walker_melee_damage), DEATH_TURRET_WALK_MELEE.m_id, '0 0 0', v_forward * (autocvar_g_turrets_unit_walker_melee_force)); e = e.chain; } @@ -94,13 +94,13 @@ void walker_melee_do_dmg(entity this) void walker_setnoanim(entity this) { - turrets_setframe(ANIM_NO, false); - self.animflag = self.frame; + turrets_setframe(this, ANIM_NO, false); + this.animflag = this.frame; } void walker_rocket_explode(entity this) { - RadiusDamage (self, self.owner, (autocvar_g_turrets_unit_walker_rocket_damage), 0, (autocvar_g_turrets_unit_walker_rocket_radius), self, world, (autocvar_g_turrets_unit_walker_rocket_force), DEATH_TURRET_WALK_ROCKET.m_id, world); - remove (self); + RadiusDamage (this, this.owner, (autocvar_g_turrets_unit_walker_rocket_damage), 0, (autocvar_g_turrets_unit_walker_rocket_radius), this, world, (autocvar_g_turrets_unit_walker_rocket_force), DEATH_TURRET_WALK_ROCKET.m_id, world); + remove (this); } void walker_rocket_damage(entity this, entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector vforce) @@ -112,7 +112,7 @@ void walker_rocket_damage(entity this, entity inflictor, entity attacker, float W_PrepareExplosionByDamage(this, this.owner, walker_rocket_explode); } -#define WALKER_ROCKET_MOVE movelib_move_simple(self, newdir, (autocvar_g_turrets_unit_walker_rocket_speed), (autocvar_g_turrets_unit_walker_rocket_turnrate)); UpdateCSQCProjectile(self) +#define WALKER_ROCKET_MOVE(s) movelib_move_simple((s), newdir, (autocvar_g_turrets_unit_walker_rocket_speed), (autocvar_g_turrets_unit_walker_rocket_turnrate)); UpdateCSQCProjectile(s) void walker_rocket_loop(entity this); void walker_rocket_think(entity this) { @@ -121,123 +121,118 @@ void walker_rocket_think(entity this) float itime; float m_speed; - self.nextthink = time; + this.nextthink = time; - edist = vlen(self.enemy.origin - self.origin); + edist = vlen(this.enemy.origin - this.origin); // Simulate crude guidance - if (self.cnt < time) + if (this.cnt < time) { if (edist < 1000) - self.tur_shotorg = randomvec() * min(edist, 64); + this.tur_shotorg = randomvec() * min(edist, 64); else - self.tur_shotorg = randomvec() * min(edist, 256); + this.tur_shotorg = randomvec() * min(edist, 256); - self.cnt = time + 0.5; + this.cnt = time + 0.5; } if (edist < 128) - self.tur_shotorg = '0 0 0'; + this.tur_shotorg = '0 0 0'; - if (self.max_health < time) + if (this.max_health < time) { - setthink(self, walker_rocket_explode); - self.nextthink = time; + setthink(this, walker_rocket_explode); + this.nextthink = time; return; } - if (self.shot_dmg != 1337 && random() < 0.01) + if (this.shot_dmg != 1337 && random() < 0.01) { - walker_rocket_loop(self); + walker_rocket_loop(this); return; } - m_speed = vlen(self.velocity); + m_speed = vlen(this.velocity); // Enemy dead? just keep on the current heading then. - if (self.enemy == world || IS_DEAD(self.enemy)) - self.enemy = world; + if (this.enemy == world || IS_DEAD(this.enemy)) + this.enemy = world; - if (self.enemy) + if (this.enemy) { itime = max(edist / m_speed, 1); - newdir = steerlib_pull(self, self.enemy.origin + self.tur_shotorg); + newdir = steerlib_pull(this, this.enemy.origin + this.tur_shotorg); } else - newdir = normalize(self.velocity); + newdir = normalize(this.velocity); - WALKER_ROCKET_MOVE; + WALKER_ROCKET_MOVE(this); } void walker_rocket_loop3(entity this) { - vector newdir; - self.nextthink = time; + this.nextthink = time; - if (self.max_health < time) + if (this.max_health < time) { - setthink(self, walker_rocket_explode); + setthink(this, walker_rocket_explode); return; } - if(vdist(self.origin - self.tur_shotorg, <, 100)) + if(vdist(this.origin - this.tur_shotorg, <, 100)) { - setthink(self, walker_rocket_think); + setthink(this, walker_rocket_think); return; } - newdir = steerlib_pull(self, self.tur_shotorg); - WALKER_ROCKET_MOVE; + vector newdir = steerlib_pull(this, this.tur_shotorg); + WALKER_ROCKET_MOVE(this); - self.angles = vectoangles(self.velocity); + this.angles = vectoangles(this.velocity); } void walker_rocket_loop2(entity this) { - vector newdir; + this.nextthink = time; - self.nextthink = time; - - if (self.max_health < time) + if (this.max_health < time) { - setthink(self, walker_rocket_explode); + setthink(this, walker_rocket_explode); return; } - if(vdist(self.origin - self.tur_shotorg, <, 100)) + if(vdist(this.origin - this.tur_shotorg, <, 100)) { - self.tur_shotorg = self.origin - '0 0 200'; - setthink(self, walker_rocket_loop3); + this.tur_shotorg = this.origin - '0 0 200'; + setthink(this, walker_rocket_loop3); return; } - newdir = steerlib_pull(self, self.tur_shotorg); - WALKER_ROCKET_MOVE; + vector newdir = steerlib_pull(this, this.tur_shotorg); + WALKER_ROCKET_MOVE(this); } void walker_rocket_loop(entity this) { - self.nextthink = time; - self.tur_shotorg = self.origin + '0 0 300'; - setthink(self, walker_rocket_loop2); - self.shot_dmg = 1337; + this.nextthink = time; + this.tur_shotorg = this.origin + '0 0 300'; + setthink(this, walker_rocket_loop2); + this.shot_dmg = 1337; } -void walker_fire_rocket(vector org) -{SELFPARAM(); - entity rocket; - - fixedmakevectors(self.angles); +void walker_fire_rocket(entity this, vector org) +{ + fixedmakevectors(this.angles); te_explosion (org); - rocket = new(walker_rocket); + entity rocket = new(walker_rocket); setorigin(rocket, org); - sound (self, CH_WEAPON_A, SND_HAGAR_FIRE, VOL_BASE, ATTEN_NORM); + sound (this, CH_WEAPON_A, SND_HAGAR_FIRE, VOL_BASE, ATTEN_NORM); setsize (rocket, '-3 -3 -3', '3 3 3'); // give it some size so it can be shot - rocket.owner = self; + rocket.owner = this; rocket.bot_dodge = true; rocket.bot_dodgerating = 50; rocket.takedamage = DAMAGE_YES; @@ -245,7 +240,7 @@ void walker_fire_rocket(vector org) rocket.health = 25; rocket.tur_shotorg = randomvec() * 512; rocket.cnt = time + 1; - rocket.enemy = self.enemy; + rocket.enemy = this.enemy; if (random() < 0.01) setthink(rocket, walker_rocket_loop); @@ -269,144 +264,143 @@ void walker_fire_rocket(vector org) .vector enemy_last_loc; .float enemy_last_time; -void walker_move_to(vector _target, float _dist) -{SELFPARAM(); - switch (self.waterlevel) +void walker_move_to(entity this, vector _target, float _dist) +{ + switch (this.waterlevel) { case WATERLEVEL_NONE: if (_dist > 500) - self.animflag = ANIM_RUN; + this.animflag = ANIM_RUN; else - self.animflag = ANIM_WALK; + this.animflag = ANIM_WALK; case WATERLEVEL_WETFEET: case WATERLEVEL_SWIMMING: - if (self.animflag != ANIM_SWIM) - self.animflag = ANIM_WALK; + if (this.animflag != ANIM_SWIM) + this.animflag = ANIM_WALK; else - self.animflag = ANIM_SWIM; + this.animflag = ANIM_SWIM; break; case WATERLEVEL_SUBMERGED: - self.animflag = ANIM_SWIM; + this.animflag = ANIM_SWIM; } - self.moveto = _target; - self.steerto = steerlib_attract2(self, self.moveto, 0.5, 500, 0.95); + this.moveto = _target; + this.steerto = steerlib_attract2(this, this.moveto, 0.5, 500, 0.95); - if(self.enemy) + if(this.enemy) { - self.enemy_last_loc = _target; - self.enemy_last_time = time; + this.enemy_last_loc = _target; + this.enemy_last_time = time; } } -void walker_move_path() -{SELFPARAM(); +void walker_move_path(entity this) +{ #ifdef WALKER_FANCYPATHING // Are we close enougth to a path node to switch to the next? - if(vdist(self.origin - self.pathcurrent.origin, <, 64)) - if (self.pathcurrent.path_next == world) + if(vdist(this.origin - this.pathcurrent.origin, <, 64)) + if (this.pathcurrent.path_next == world) { // Path endpoint reached - pathlib_deletepath(self.pathcurrent.owner); - self.pathcurrent = world; + pathlib_deletepath(this.pathcurrent.owner); + this.pathcurrent = world; - if (self.pathgoal) + if (this.pathgoal) { - if (self.pathgoal.use) - self.pathgoal.use(self, NULL, NULL); + if (this.pathgoal.use) + this.pathgoal.use(this, NULL, NULL); - if (self.pathgoal.enemy) + if (this.pathgoal.enemy) { - self.pathcurrent = WALKER_PATH(self, self.pathgoal.origin, self.pathgoal.enemy.origin); - self.pathgoal = self.pathgoal.enemy; + this.pathcurrent = WALKER_PATH(this, this.pathgoal.origin, this.pathgoal.enemy.origin); + this.pathgoal = this.pathgoal.enemy; } } else - self.pathgoal = world; + this.pathgoal = world; } else - self.pathcurrent = self.pathcurrent.path_next; + this.pathcurrent = this.pathcurrent.path_next; - self.moveto = self.pathcurrent.origin; - self.steerto = steerlib_attract2(self, self.moveto,0.5,500,0.95); - walker_move_to(self.moveto, 0); + this.moveto = this.pathcurrent.origin; + this.steerto = steerlib_attract2(this, this.moveto,0.5,500,0.95); + walker_move_to(this, this.moveto, 0); #else - if(vdist(self.origin - self.pathcurrent.origin, <, 64)) - self.pathcurrent = self.pathcurrent.enemy; + if(vdist(this.origin - this.pathcurrent.origin, <, 64)) + this.pathcurrent = this.pathcurrent.enemy; - if(!self.pathcurrent) + if(!this.pathcurrent) return; - self.moveto = self.pathcurrent.origin; - self.steerto = steerlib_attract2(self, self.moveto, 0.5, 500, 0.95); - walker_move_to(self.moveto, 0); + this.moveto = this.pathcurrent.origin; + this.steerto = steerlib_attract2(this, this.moveto, 0.5, 500, 0.95); + walker_move_to(this, this.moveto, 0); #endif } -spawnfunc(turret_walker) { if(!turret_initialize(TUR_WALKER)) remove(this); } +spawnfunc(turret_walker) { if(!turret_initialize(this, TUR_WALKER)) remove(this); } METHOD(WalkerTurret, tr_think, void(WalkerTurret thistur, entity it)) { - SELFPARAM(); - fixedmakevectors(self.angles); + fixedmakevectors(it.angles); - if (self.spawnflags & TSF_NO_PATHBREAK && self.pathcurrent) - walker_move_path(); - else if (self.enemy == world) + if (it.spawnflags & TSF_NO_PATHBREAK && it.pathcurrent) + walker_move_path(it); + else if (it.enemy == world) { - if(self.pathcurrent) - walker_move_path(); + if(it.pathcurrent) + walker_move_path(it); else { - if(self.enemy_last_time != 0) + if(it.enemy_last_time != 0) { - if(vdist(self.origin - self.enemy_last_loc, <, 128) || time - self.enemy_last_time > 10) - self.enemy_last_time = 0; + if(vdist(it.origin - it.enemy_last_loc, <, 128) || time - it.enemy_last_time > 10) + it.enemy_last_time = 0; else - walker_move_to(self.enemy_last_loc, 0); + walker_move_to(it, it.enemy_last_loc, 0); } else { - if(self.animflag != ANIM_NO) + if(it.animflag != ANIM_NO) { - traceline(self.origin + '0 0 64', self.origin + '0 0 64' + v_forward * 128, MOVE_NORMAL, self); + traceline(it.origin + '0 0 64', it.origin + '0 0 64' + v_forward * 128, MOVE_NORMAL, it); if(trace_fraction != 1.0) - self.tur_head.idletime = -1337; + it.tur_head.idletime = -1337; else { - traceline(trace_endpos, trace_endpos - '0 0 256', MOVE_NORMAL, self); + traceline(trace_endpos, trace_endpos - '0 0 256', MOVE_NORMAL, it); if(trace_fraction == 1.0) - self.tur_head.idletime = -1337; + it.tur_head.idletime = -1337; } - if(self.tur_head.idletime == -1337) + if(it.tur_head.idletime == -1337) { - self.moveto = self.origin + randomvec() * 256; - self.tur_head.idletime = 0; + it.moveto = it.origin + randomvec() * 256; + it.tur_head.idletime = 0; } - self.moveto = self.moveto * 0.9 + ((self.origin + v_forward * 500) + randomvec() * 400) * 0.1; - self.moveto_z = self.origin_z + 64; - walker_move_to(self.moveto, 0); + it.moveto = it.moveto * 0.9 + ((it.origin + v_forward * 500) + randomvec() * 400) * 0.1; + it.moveto_z = it.origin_z + 64; + walker_move_to(it, it.moveto, 0); } - if(self.idletime < time) + if(it.idletime < time) { - if(random() < 0.5 || !(self.spawnflags & TSL_ROAM)) + if(random() < 0.5 || !(it.spawnflags & TSL_ROAM)) { - self.idletime = time + 1 + random() * 5; - self.moveto = self.origin; - self.animflag = ANIM_NO; + it.idletime = time + 1 + random() * 5; + it.moveto = it.origin; + it.animflag = ANIM_NO; } else { - self.animflag = ANIM_WALK; - self.idletime = time + 4 + random() * 2; - self.moveto = self.origin + randomvec() * 256; - self.tur_head.moveto = self.moveto; - self.tur_head.idletime = 0; + it.animflag = ANIM_WALK; + it.idletime = time + 4 + random() * 2; + it.moveto = it.origin + randomvec() * 256; + it.tur_head.moveto = it.moveto; + it.tur_head.idletime = 0; } } } @@ -414,47 +408,47 @@ METHOD(WalkerTurret, tr_think, void(WalkerTurret thistur, entity it)) } else { - if (self.tur_dist_enemy < (autocvar_g_turrets_unit_walker_melee_range) && self.animflag != ANIM_MELEE) + if (it.tur_dist_enemy < (autocvar_g_turrets_unit_walker_melee_range) && it.animflag != ANIM_MELEE) { vector wish_angle; - wish_angle = angleofs(self, self.enemy); - if (self.animflag != ANIM_SWIM) + wish_angle = angleofs(it, it.enemy); + if (it.animflag != ANIM_SWIM) if (fabs(wish_angle_y) < 15) { - self.moveto = self.enemy.origin; - self.steerto = steerlib_attract2(self, self.moveto, 0.5, 500, 0.95); - self.animflag = ANIM_MELEE; + it.moveto = it.enemy.origin; + it.steerto = steerlib_attract2(it, it.moveto, 0.5, 500, 0.95); + it.animflag = ANIM_MELEE; } } - else if (self.tur_head.attack_finished_single[0] < time) + else if (it.tur_head.attack_finished_single[0] < time) { - if(self.tur_head.shot_volly) + if(it.tur_head.shot_volly) { - self.animflag = ANIM_NO; + it.animflag = ANIM_NO; - self.tur_head.shot_volly = self.tur_head.shot_volly -1; - if(self.tur_head.shot_volly == 0) - self.tur_head.attack_finished_single[0] = time + (autocvar_g_turrets_unit_walker_rocket_refire); + it.tur_head.shot_volly = it.tur_head.shot_volly -1; + if(it.tur_head.shot_volly == 0) + it.tur_head.attack_finished_single[0] = time + (autocvar_g_turrets_unit_walker_rocket_refire); else - self.tur_head.attack_finished_single[0] = time + 0.2; + it.tur_head.attack_finished_single[0] = time + 0.2; - if(self.tur_head.shot_volly > 1) - walker_fire_rocket(gettaginfo(self, gettagindex(self, "tag_rocket01"))); + if(it.tur_head.shot_volly > 1) + walker_fire_rocket(it, gettaginfo(it, gettagindex(it, "tag_rocket01"))); else - walker_fire_rocket(gettaginfo(self, gettagindex(self, "tag_rocket02"))); + walker_fire_rocket(it, gettaginfo(it, gettagindex(it, "tag_rocket02"))); } else { - if (self.tur_dist_enemy > (autocvar_g_turrets_unit_walker_rocket_range_min)) - if (self.tur_dist_enemy < (autocvar_g_turrets_unit_walker_rocket_range)) - self.tur_head.shot_volly = 4; + if (it.tur_dist_enemy > (autocvar_g_turrets_unit_walker_rocket_range_min)) + if (it.tur_dist_enemy < (autocvar_g_turrets_unit_walker_rocket_range)) + it.tur_head.shot_volly = 4; } } else { - if (self.animflag != ANIM_MELEE) - walker_move_to(self.enemy.origin, self.tur_dist_enemy); + if (it.animflag != ANIM_MELEE) + walker_move_to(it, it.enemy.origin, it.tur_dist_enemy); } } @@ -463,99 +457,99 @@ METHOD(WalkerTurret, tr_think, void(WalkerTurret thistur, entity it)) float turny = 0, turnx = 0; float vz; - real_angle = vectoangles(self.steerto) - self.angles; - vz = self.velocity_z; + real_angle = vectoangles(it.steerto) - it.angles; + vz = it.velocity_z; - switch (self.animflag) + switch (it.animflag) { case ANIM_NO: - movelib_brake_simple(self, (autocvar_g_turrets_unit_walker_speed_stop)); + movelib_brake_simple(it, (autocvar_g_turrets_unit_walker_speed_stop)); break; case ANIM_TURN: turny = (autocvar_g_turrets_unit_walker_turn); - movelib_brake_simple(self, (autocvar_g_turrets_unit_walker_speed_stop)); + movelib_brake_simple(it, (autocvar_g_turrets_unit_walker_speed_stop)); break; case ANIM_WALK: turny = (autocvar_g_turrets_unit_walker_turn_walk); - movelib_move_simple(self, v_forward, (autocvar_g_turrets_unit_walker_speed_walk), 0.6); + movelib_move_simple(it, v_forward, (autocvar_g_turrets_unit_walker_speed_walk), 0.6); break; case ANIM_RUN: turny = (autocvar_g_turrets_unit_walker_turn_run); - movelib_move_simple(self, v_forward, (autocvar_g_turrets_unit_walker_speed_run), 0.6); + movelib_move_simple(it, v_forward, (autocvar_g_turrets_unit_walker_speed_run), 0.6); break; case ANIM_STRAFE_L: turny = (autocvar_g_turrets_unit_walker_turn_strafe); - movelib_move_simple(self, v_right * -1, (autocvar_g_turrets_unit_walker_speed_walk), 0.8); + movelib_move_simple(it, v_right * -1, (autocvar_g_turrets_unit_walker_speed_walk), 0.8); break; case ANIM_STRAFE_R: turny = (autocvar_g_turrets_unit_walker_turn_strafe); - movelib_move_simple(self, v_right, (autocvar_g_turrets_unit_walker_speed_walk), 0.8); + movelib_move_simple(it, v_right, (autocvar_g_turrets_unit_walker_speed_walk), 0.8); break; case ANIM_JUMP: - self.velocity += '0 0 1' * (autocvar_g_turrets_unit_walker_speed_jump); + it.velocity += '0 0 1' * (autocvar_g_turrets_unit_walker_speed_jump); break; case ANIM_LAND: break; case ANIM_PAIN: - if(self.frame != ANIM_PAIN) - defer(self, 0.25, walker_setnoanim); + if(it.frame != ANIM_PAIN) + defer(it, 0.25, walker_setnoanim); break; case ANIM_MELEE: - if(self.frame != ANIM_MELEE) + if(it.frame != ANIM_MELEE) { - defer(self, 0.41, walker_setnoanim); - defer(self, 0.21, walker_melee_do_dmg); + defer(it, 0.41, walker_setnoanim); + defer(it, 0.21, walker_melee_do_dmg); } - movelib_brake_simple(self, (autocvar_g_turrets_unit_walker_speed_stop)); + movelib_brake_simple(it, (autocvar_g_turrets_unit_walker_speed_stop)); break; case ANIM_SWIM: turny = (autocvar_g_turrets_unit_walker_turn_swim); turnx = (autocvar_g_turrets_unit_walker_turn_swim); - self.angles_x += bound(-10, shortangle_f(real_angle_x, self.angles_x), 10); - movelib_move_simple(self, v_forward, (autocvar_g_turrets_unit_walker_speed_swim), 0.3); - vz = self.velocity_z + sin(time * 4) * 8; + it.angles_x += bound(-10, shortangle_f(real_angle_x, it.angles_x), 10); + movelib_move_simple(it, v_forward, (autocvar_g_turrets_unit_walker_speed_swim), 0.3); + vz = it.velocity_z + sin(time * 4) * 8; break; case ANIM_ROAM: turny = (autocvar_g_turrets_unit_walker_turn_walk); - movelib_move_simple(self, v_forward ,(autocvar_g_turrets_unit_walker_speed_roam), 0.5); + movelib_move_simple(it, v_forward ,(autocvar_g_turrets_unit_walker_speed_roam), 0.5); break; } if(turny) { - turny = bound( turny * -1, shortangle_f(real_angle_y, self.angles_y), turny ); - self.angles_y += turny; + turny = bound( turny * -1, shortangle_f(real_angle_y, it.angles_y), turny ); + it.angles_y += turny; } if(turnx) { - turnx = bound( turnx * -1, shortangle_f(real_angle_x, self.angles_x), turnx ); - self.angles_x += turnx; + turnx = bound( turnx * -1, shortangle_f(real_angle_x, it.angles_x), turnx ); + it.angles_x += turnx; } - self.velocity_z = vz; + it.velocity_z = vz; } - if(self.origin != self.oldorigin) - self.SendFlags |= TNSF_MOVE; + if(it.origin != it.oldorigin) + it.SendFlags |= TNSF_MOVE; - self.oldorigin = self.origin; - turrets_setframe(self.animflag, false); + it.oldorigin = it.origin; + turrets_setframe(it, it.animflag, false); } METHOD(WalkerTurret, tr_death, void(WalkerTurret this, entity it)) { diff --git a/qcsrc/common/turrets/util.qc b/qcsrc/common/turrets/util.qc index 0344d1492..0d178a5cb 100644 --- a/qcsrc/common/turrets/util.qc +++ b/qcsrc/common/turrets/util.qc @@ -2,16 +2,16 @@ * Update self.tur_shotorg by getting up2date bone info * NOTICE this func overwrites the global v_forward, v_right and v_up vectors. */ -float turret_tag_fire_update() -{SELFPARAM(); - if(!self.tur_head) +float turret_tag_fire_update(entity this) +{ + if(!this.tur_head) { - error("Call to turret_tag_fire_update with self.tur_head missing!\n"); - self.tur_shotorg = '0 0 0'; + LOG_DEBUG("Call to turret_tag_fire_update with this.tur_head missing!\n"); + this.tur_shotorg = '0 0 0'; return false; } - self.tur_shotorg = gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_fire")); + this.tur_shotorg = gettaginfo(this.tur_head, gettagindex(this.tur_head, "tag_fire")); v_forward = normalize(v_forward); return true; diff --git a/qcsrc/common/turrets/util.qh b/qcsrc/common/turrets/util.qh index 536af8703..d5c948d57 100644 --- a/qcsrc/common/turrets/util.qh +++ b/qcsrc/common/turrets/util.qh @@ -3,7 +3,7 @@ float shortangle_f(float ang1, float ang2); float anglemods(float v); -float turret_tag_fire_update(); +float turret_tag_fire_update(entity this); vector shortangle_vxy(vector ang1, vector ang2); vector angleofs(entity from, entity to); vector angleofs3(vector from, vector from_a, entity to);