X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fturrets%2Fturret%2Fewheel.qc;h=0bdfca46ed2cec92acc84a9f96d81f34114e4385;hb=bf28c62f9ad2f130024109354c2503457195898d;hp=3bf4227cfe00f3f8647b195ed1d283ed55241f45;hpb=5f7088ff5d1154439d3fbe8ea0b63d96a215dcb9;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/turrets/turret/ewheel.qc b/qcsrc/common/turrets/turret/ewheel.qc index 3bf4227cf..0bdfca46e 100644 --- a/qcsrc/common/turrets/turret/ewheel.qc +++ b/qcsrc/common/turrets/turret/ewheel.qc @@ -1,23 +1,29 @@ -#ifndef TUR_EWHEEL_H -#define TUR_EWHEEL_H +#ifndef TURRET_EWHEEL_H +#define TURRET_EWHEEL_H + +//#define EWHEEL_FANCYPATH + +#include "ewheel_weapon.qh" CLASS(EWheel, Turret) /* spawnflags */ ATTRIB(EWheel, spawnflags, int, TUR_FLAG_PLAYER | TUR_FLAG_MOVE | TUR_FLAG_ROAM); /* mins */ ATTRIB(EWheel, mins, vector, '-32 -32 0'); /* maxs */ ATTRIB(EWheel, maxs, vector, '32 32 48'); /* modelname */ ATTRIB(EWheel, mdl, string, "ewheel-base2.md3"); -/* model */ ATTRIB(EWheel, model, string, strzone(strcat("models/turrets/", this.mdl))); -/* head_model */ ATTRIB(EWheel, head_model, string, strzone(strcat("models/turrets/", "ewheel-gun1.md3"))); +/* model */ ATTRIB_STRZONE(EWheel, model, string, strcat("models/turrets/", this.mdl)); +/* head_model */ ATTRIB_STRZONE(EWheel, head_model, string, strcat("models/turrets/", "ewheel-gun1.md3")); /* netname */ ATTRIB(EWheel, netname, string, "ewheel"); /* fullname */ ATTRIB(EWheel, turret_name, string, _("eWheel Turret")); + ATTRIB(EWheel, m_weapon, Weapon, WEP_EWHEEL); ENDCLASS(EWheel) - REGISTER_TURRET(EWHEEL, NEW(EWheel)); #endif #ifdef IMPLEMENTATION + #ifdef SVQC + float autocvar_g_turrets_unit_ewheel_speed_fast; float autocvar_g_turrets_unit_ewheel_speed_slow; float autocvar_g_turrets_unit_ewheel_speed_slower; @@ -30,12 +36,11 @@ const float ewheel_anim_fwd_fast = 2; const float ewheel_anim_bck_slow = 3; const float ewheel_anim_bck_fast = 4; -//#define EWHEEL_FANCYPATH void ewheel_move_path() {SELFPARAM(); #ifdef EWHEEL_FANCYPATH // Are we close enougth to a path node to switch to the next? - if (vlen(self.origin - self.pathcurrent.origin) < 64) + if(vdist(self.origin - self.pathcurrent.origin, <, 64)) if (self.pathcurrent.path_next == world) { // Path endpoint reached @@ -45,7 +50,7 @@ void ewheel_move_path() if (self.pathgoal) { if (self.pathgoal.use) - self.pathgoal.use(); + self.pathgoal.use(self.pathgoal, NULL, NULL); if (self.pathgoal.enemy) { @@ -60,7 +65,7 @@ void ewheel_move_path() self.pathcurrent = self.pathcurrent.path_next; #else - if (vlen(self.origin - self.pathcurrent.origin) < 64) + if(vdist(self.origin - self.pathcurrent.origin, <, 64)) self.pathcurrent = self.pathcurrent.enemy; #endif @@ -68,9 +73,9 @@ void ewheel_move_path() { self.moveto = self.pathcurrent.origin; - self.steerto = steerlib_attract2(self.moveto, 0.5, 500, 0.95); + self.steerto = steerlib_attract2(self, self.moveto, 0.5, 500, 0.95); - movelib_move_simple(v_forward, (autocvar_g_turrets_unit_ewheel_speed_fast), 0.4); + movelib_move_simple(self, v_forward, (autocvar_g_turrets_unit_ewheel_speed_fast), 0.4); } } @@ -87,29 +92,29 @@ void ewheel_move_enemy() if ( self.tur_head.spawnshieldtime < 1 ) { newframe = ewheel_anim_fwd_fast; - movelib_move_simple(v_forward, (autocvar_g_turrets_unit_ewheel_speed_fast), 0.4); + movelib_move_simple(self, v_forward, (autocvar_g_turrets_unit_ewheel_speed_fast), 0.4); } else if (self.tur_head.spawnshieldtime < 2) { newframe = ewheel_anim_fwd_slow; - movelib_move_simple(v_forward, (autocvar_g_turrets_unit_ewheel_speed_slow), 0.4); + movelib_move_simple(self, v_forward, (autocvar_g_turrets_unit_ewheel_speed_slow), 0.4); } else { newframe = ewheel_anim_fwd_slow; - movelib_move_simple(v_forward, (autocvar_g_turrets_unit_ewheel_speed_slower), 0.4); + movelib_move_simple(self, v_forward, (autocvar_g_turrets_unit_ewheel_speed_slower), 0.4); } } else if (self.tur_dist_enemy < self.target_range_optimal * 0.5) { newframe = ewheel_anim_bck_slow; - movelib_move_simple(v_forward * -1, (autocvar_g_turrets_unit_ewheel_speed_slow), 0.4); + movelib_move_simple(self, v_forward * -1, (autocvar_g_turrets_unit_ewheel_speed_slow), 0.4); } else { newframe = ewheel_anim_stop; - movelib_beak_simple((autocvar_g_turrets_unit_ewheel_speed_stop)); + movelib_brake_simple(self, (autocvar_g_turrets_unit_ewheel_speed_stop)); } turrets_setframe(newframe, false); @@ -124,182 +129,142 @@ void ewheel_move_idle() } self.frame = 0; - if (vlen(self.velocity)) - movelib_beak_simple((autocvar_g_turrets_unit_ewheel_speed_stop)); + if(self.velocity) + movelib_brake_simple(self, (autocvar_g_turrets_unit_ewheel_speed_stop)); } -void spawnfunc_turret_ewheel() { SELFPARAM(); if(!turret_initialize(TUR_EWHEEL.m_id)) remove(self); } - - METHOD(EWheel, tr_attack, bool(EWheel thistur)) - { - SELFPARAM(); - float i; - entity _mis; - - for (i = 0; i < 1; ++i) - { - turret_do_updates(self); - - _mis = turret_projectile(SND(LASERGUN_FIRE), 1, 0, DEATH_TURRET_EWHEEL, PROJECTILE_BLASTER, TRUE, TRUE); - _mis.missile_flags = MIF_SPLASH; +spawnfunc(turret_ewheel) { if(!turret_initialize(TUR_EWHEEL)) remove(self); } - Send_Effect(EFFECT_BLASTER_MUZZLEFLASH, self.tur_shotorg, self.tur_shotdir_updated * 1000, 1); +METHOD(EWheel, tr_think, void(EWheel thistur, entity it)) +{ + SELFPARAM(); + float vz; + vector wish_angle, real_angle; - self.tur_head.frame += 2; + vz = self.velocity_z; - if (self.tur_head.frame > 3) - self.tur_head.frame = 0; - } + self.angles_x = anglemods(self.angles_x); + self.angles_y = anglemods(self.angles_y); - return true; - } - METHOD(EWheel, tr_think, bool(EWheel thistur)) - { - SELFPARAM(); - float vz; - vector wish_angle, real_angle; + fixedmakevectors(self.angles); - vz = self.velocity_z; + wish_angle = normalize(self.steerto); + wish_angle = vectoangles(wish_angle); + real_angle = wish_angle - self.angles; + real_angle = shortangle_vxy(real_angle, self.tur_head.angles); - self.angles_x = anglemods(self.angles_x); - self.angles_y = anglemods(self.angles_y); + 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); - fixedmakevectors(self.angles); + if(self.enemy) + ewheel_move_enemy(); + else if(self.pathcurrent) + ewheel_move_path(); + else + ewheel_move_idle(); - wish_angle = normalize(self.steerto); - wish_angle = vectoangles(wish_angle); - real_angle = wish_angle - self.angles; - real_angle = shortangle_vxy(real_angle, self.tur_head.angles); + self.velocity_z = vz; - 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); + if(self.velocity) + self.SendFlags |= TNSF_MOVE; +} - if(self.enemy) - ewheel_move_enemy(); - else if(self.pathcurrent) - ewheel_move_path(); - else - ewheel_move_idle(); +METHOD(EWheel, tr_death, void(EWheel this, entity it)) +{ + it.velocity = '0 0 0'; - self.velocity_z = vz; +#ifdef EWHEEL_FANCYPATH + if (self.pathcurrent) + pathlib_deletepath(it.pathcurrent.owner); +#endif + it.pathcurrent = NULL; +} - if(vlen(self.velocity)) - self.SendFlags |= TNSF_MOVE; +METHOD(EWheel, tr_setup, void(EWheel this, entity it)) +{ + entity e; - return true; - } - METHOD(EWheel, tr_death, bool(EWheel thistur)) - { - SELFPARAM(); - self.velocity = '0 0 0'; + if(it.movetype == MOVETYPE_WALK) + { + it.velocity = '0 0 0'; + it.enemy = world; -#ifdef EWHEEL_FANCYPATH - if (self.pathcurrent) - pathlib_deletepath(self.pathcurrent.owner); -#endif - self.pathcurrent = world; + setorigin(it, it.pos1); - return true; - } - METHOD(EWheel, tr_setup, bool(EWheel thistur)) + if (it.target != "") { - SELFPARAM(); - entity e; - - if(self.movetype == MOVETYPE_WALK) + e = find(world, targetname, it.target); + if (!e) { - self.velocity = '0 0 0'; - self.enemy = world; - - setorigin(self, self.pos1); + LOG_TRACE("Initital waypoint for ewheel does NOT exsist, fix your map!\n"); + it.target = ""; + } - if (self.target != "") - { - e = find(world, targetname, self.target); - if (!e) - { - LOG_TRACE("Initital waypoint for ewheel does NOT exsist, fix your map!\n"); - self.target = ""; - } - - if (e.classname != "turret_checkpoint") - LOG_TRACE("Warning: not a turrret path\n"); - else - { + if (e.classname != "turret_checkpoint") + LOG_TRACE("Warning: not a turrret path\n"); + else + { #ifdef EWHEEL_FANCYPATH - self.pathcurrent = WALKER_PATH(self.origin,e.origin); - self.pathgoal = e; + it.pathcurrent = WALKER_PATH(it.origin,e.origin); + it.pathgoal = e; #else - self.pathcurrent = e; + it.pathcurrent = e; #endif - } - } } - - self.iscreature = true; - self.teleportable = TELEPORT_NORMAL; - self.damagedbycontents = true; - self.movetype = MOVETYPE_WALK; - self.solid = SOLID_SLIDEBOX; - self.takedamage = DAMAGE_AIM; - self.idle_aim = '0 0 0'; - self.pos1 = self.origin; - self.target_select_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_LOS; - self.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_LOS; - self.frame = self.tur_head.frame = 1; - self.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE; - - // Convert from dgr / sec to dgr / tic - self.tur_head.aim_speed = (autocvar_g_turrets_unit_ewheel_turnrate); - self.tur_head.aim_speed = self.tur_head.aim_speed / (1 / self.ticrate); - - return true; - } - METHOD(EWheel, tr_precache, bool(EWheel thistur)) - { - return true; } + } + + it.iscreature = true; + it.teleportable = TELEPORT_NORMAL; + it.damagedbycontents = true; + it.movetype = MOVETYPE_WALK; + it.solid = SOLID_SLIDEBOX; + it.takedamage = DAMAGE_AIM; + it.idle_aim = '0 0 0'; + it.pos1 = it.origin; + it.target_select_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_LOS; + it.target_validate_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_LOS; + it.frame = it.tur_head.frame = 1; + it.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE | TFL_AMMO_RECIEVE; + + // Convert from dgr / sec to dgr / tic + it.tur_head.aim_speed = (autocvar_g_turrets_unit_ewheel_turnrate); + it.tur_head.aim_speed = it.tur_head.aim_speed / (1 / it.ticrate); +} #endif // SVQC #ifdef CSQC -void ewheel_draw() -{SELFPARAM(); +void ewheel_draw(entity this) +{ float dt; - dt = time - self.move_time; - self.move_time = time; + dt = time - this.move_time; + this.move_time = time; if(dt <= 0) return; - fixedmakevectors(self.angles); - setorigin(self, self.origin + self.velocity * dt); - self.tur_head.angles += dt * self.tur_head.move_avelocity; - self.angles_y = self.move_angles_y; + fixedmakevectors(this.angles); + setorigin(this, this.origin + this.velocity * dt); + this.tur_head.angles += dt * this.tur_head.move_avelocity; + this.angles_y = this.move_angles_y; - if (self.health < 127) + if (this.health < 127) if(random() < 0.05) - te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16); + te_spark(this.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16); } - METHOD(EWheel, tr_setup, bool(EWheel thistur)) + METHOD(EWheel, tr_setup, void(EWheel this, entity it)) { - SELFPARAM(); - self.gravity = 1; - self.movetype = MOVETYPE_BOUNCE; - self.move_movetype = MOVETYPE_BOUNCE; - self.move_origin = self.origin; - self.move_time = time; - self.draw = ewheel_draw; - - return true; - } - METHOD(EWheel, tr_precache, bool(EWheel thistur)) - { - return true; + it.gravity = 1; + it.movetype = MOVETYPE_BOUNCE; + it.move_movetype = MOVETYPE_BOUNCE; + it.move_origin = it.origin; + it.move_time = time; + it.draw = ewheel_draw; } #endif // CSQC -#endif // REGISTER_TURRET +#endif