X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fvehicles%2Fvehicle%2Fraptor_weapons.qc;h=f1357f306c49e389bd43c070101c55182c2c7759;hp=62d8c12e567901bdb41627abcc091bb949bcb8ef;hb=7666560c6a475aefe6b55ff74a20444f328e0093;hpb=a8cc9eb71b0d0e44e9a968a9cf5554f6226cc838 diff --git a/qcsrc/common/vehicles/vehicle/raptor_weapons.qc b/qcsrc/common/vehicles/vehicle/raptor_weapons.qc index 62d8c12e56..f1357f306c 100644 --- a/qcsrc/common/vehicles/vehicle/raptor_weapons.qc +++ b/qcsrc/common/vehicles/vehicle/raptor_weapons.qc @@ -1,65 +1,18 @@ -#ifndef VEHICLE_RAPTOR_WEAPONS_H -#define VEHICLE_RAPTOR_WEAPONS_H - -#include "../../weapons/all.qh" - -CLASS(RaptorCannon, PortoLaunch) -/* flags */ ATTRIB(RaptorCannon, spawnflags, int, WEP_TYPE_OTHER | WEP_FLAG_HIDDEN | WEP_FLAG_MUTATORBLOCKED); -/* impulse */ ATTRIB(RaptorCannon, impulse, int, 3); -/* refname */ ATTRIB(RaptorCannon, netname, string, "raptorcannon"); -/* wepname */ ATTRIB(RaptorCannon, message, string, _("Raptor cannon")); -ENDCLASS(RaptorCannon) -REGISTER_WEAPON(RAPTOR, NEW(RaptorCannon)); - -CLASS(RaptorBomb, PortoLaunch) -/* flags */ ATTRIB(RaptorBomb, spawnflags, int, WEP_TYPE_OTHER | WEP_FLAG_HIDDEN | WEP_FLAG_MUTATORBLOCKED); -/* impulse */ ATTRIB(RaptorBomb, impulse, int, 3); -/* refname */ ATTRIB(RaptorBomb, netname, string, "raptorbomb"); -/* wepname */ ATTRIB(RaptorBomb, message, string, _("Raptor bomb")); -ENDCLASS(RaptorBomb) -REGISTER_WEAPON(RAPTOR_BOMB, NEW(RaptorBomb)); - -CLASS(RaptorFlare, PortoLaunch) -/* flags */ ATTRIB(RaptorFlare, spawnflags, int, WEP_TYPE_OTHER | WEP_FLAG_HIDDEN | WEP_FLAG_MUTATORBLOCKED); -/* impulse */ ATTRIB(RaptorFlare, impulse, int, 3); -/* refname */ ATTRIB(RaptorFlare, netname, string, "raptorflare"); -/* wepname */ ATTRIB(RaptorFlare, message, string, _("Raptor flare")); -ENDCLASS(RaptorFlare) -REGISTER_WEAPON(RAPTOR_FLARE, NEW(RaptorFlare)); - -#endif +#include "raptor_weapons.qh" #ifdef IMPLEMENTATION #ifdef SVQC -float autocvar_g_vehicle_raptor_cannon_cost; -float autocvar_g_vehicle_raptor_cannon_damage; -float autocvar_g_vehicle_raptor_cannon_radius; -float autocvar_g_vehicle_raptor_cannon_refire; -float autocvar_g_vehicle_raptor_cannon_speed; -float autocvar_g_vehicle_raptor_cannon_spread; -float autocvar_g_vehicle_raptor_cannon_force; - -float autocvar_g_vehicle_raptor_bomblets; -float autocvar_g_vehicle_raptor_bomblet_alt; -float autocvar_g_vehicle_raptor_bomblet_time; -float autocvar_g_vehicle_raptor_bomblet_damage; -float autocvar_g_vehicle_raptor_bomblet_spread; -float autocvar_g_vehicle_raptor_bomblet_edgedamage; -float autocvar_g_vehicle_raptor_bomblet_radius; -float autocvar_g_vehicle_raptor_bomblet_force; -float autocvar_g_vehicle_raptor_bomblet_explode_delay; - -METHOD(RaptorCannon, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { +METHOD(RaptorCannon, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) { bool isPlayer = IS_PLAYER(actor); entity player = isPlayer ? actor : actor.owner; entity veh = player.vehicle; // 1 [wait] 1 [wait] 2 [wait] 2 [wait] [wait] float t = autocvar_g_vehicle_raptor_cannon_refire * (1 + veh.misc_bulletcounter == 4); - if (fire1) - if (weapon_prepareattack(player, false, t)) { - if (isPlayer) W_SetupShot_Dir(player, v_forward, false, 0, SND(Null), CH_WEAPON_B, 0); + if (fire & 1) + if (weapon_prepareattack(thiswep, player, weaponentity, false, t)) { + if (isPlayer) W_SetupShot_Dir(player, v_forward, false, 0, SND_Null, CH_WEAPON_B, 0); vector org = w_shotorg; vector dir = w_shotdir; if (veh) { @@ -70,51 +23,44 @@ METHOD(RaptorCannon, wr_think, void(entity thiswep, entity actor, bool fire1, bo veh.vehicle_energy -= autocvar_g_vehicle_raptor_cannon_cost; actor.cnt = time; } - vehicles_projectile(EFFECT_RAPTOR_MUZZLEFLASH.eent_eff_name, SND(LASERGUN_FIRE), + vehicles_projectile(veh, EFFECT_RAPTOR_MUZZLEFLASH.eent_eff_name, SND_LASERGUN_FIRE, org, normalize(dir + randomvec() * autocvar_g_vehicle_raptor_cannon_spread) * autocvar_g_vehicle_raptor_cannon_speed, autocvar_g_vehicle_raptor_cannon_damage, autocvar_g_vehicle_raptor_cannon_radius, autocvar_g_vehicle_raptor_cannon_force, 0, - DEATH_VH_RAPT_CANNON, PROJECTILE_RAPTORCANNON, 0, true, true, veh ? veh : player); - weapon_thinkf(player, WFRAME_FIRE1, 0, w_ready); + DEATH_VH_RAPT_CANNON.m_id, PROJECTILE_RAPTORCANNON, 0, true, true, player); + weapon_thinkf(player, weaponentity, WFRAME_FIRE1, 0, w_ready); } } -METHOD(RaptorCannon, wr_checkammo1, bool(RacerAttack thiswep)) { - SELFPARAM(); - bool isPlayer = IS_PLAYER(self); - entity player = isPlayer ? self : self.owner; +METHOD(RaptorCannon, wr_checkammo1, bool(RacerAttack thiswep, entity actor)) { + bool isPlayer = IS_PLAYER(actor); + entity player = isPlayer ? actor : actor.owner; entity veh = player.vehicle; return isPlayer || veh.vehicle_energy >= autocvar_g_vehicle_raptor_cannon_cost; } -float autocvar_g_vehicle_raptor_bombs_refire; -void raptor_bombdrop(); -METHOD(RaptorBomb, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { +void raptor_bombdrop(entity this); +METHOD(RaptorBomb, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) { bool isPlayer = IS_PLAYER(actor); entity player = isPlayer ? actor : actor.owner; entity veh = player.vehicle; - if (fire2) - if (!isPlayer || weapon_prepareattack(player, true, autocvar_g_vehicle_raptor_bombs_refire)) { - if (veh) setself(veh); - raptor_bombdrop(); - weapon_thinkf(player, WFRAME_FIRE2, 0, w_ready); + if (fire & 2) + if (!isPlayer || weapon_prepareattack(thiswep, player, weaponentity, true, autocvar_g_vehicle_raptor_bombs_refire)) { + entity e = (veh) ? veh : player; + raptor_bombdrop(e); + weapon_thinkf(player, weaponentity, WFRAME_FIRE2, 0, w_ready); } } -float autocvar_g_vehicle_raptor_flare_refire; -float autocvar_g_vehicle_raptor_flare_lifetime; -float autocvar_g_vehicle_raptor_flare_chase; -float autocvar_g_vehicle_raptor_flare_range; +void raptor_flare_think(entity this); +void raptor_flare_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force); +void raptor_flare_touch(entity this, entity toucher); -void raptor_flare_think(); -void raptor_flare_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force); -void raptor_flare_touch(); - -METHOD(RaptorFlare, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { +METHOD(RaptorFlare, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) { bool isPlayer = IS_PLAYER(actor); entity player = isPlayer ? actor : actor.owner; entity veh = player.vehicle; - if (fire2) - if (!isPlayer || weapon_prepareattack(player, true, autocvar_g_vehicle_raptor_flare_refire)) { + if (fire & 2) + if (!isPlayer || weapon_prepareattack(thiswep, player, weaponentity, true, autocvar_g_vehicle_raptor_flare_refire)) { for(int i = 0; i < 3; ++i) { entity _flare = spawn(); setmodel(_flare, MDL_VEH_RAPTOR_FLARE); @@ -124,7 +70,7 @@ METHOD(RaptorFlare, wr_think, void(entity thiswep, entity actor, bool fire1, boo _flare.movetype = MOVETYPE_TOSS; _flare.gravity = 0.15; _flare.velocity = 0.25 * actor.velocity + (v_forward + randomvec() * 0.25)* -500; - _flare.think = raptor_flare_think; + setthink(_flare, raptor_flare_think); _flare.nextthink = time; _flare.owner = veh ? veh : player; _flare.solid = SOLID_CORPSE; @@ -132,42 +78,42 @@ METHOD(RaptorFlare, wr_think, void(entity thiswep, entity actor, bool fire1, boo _flare.event_damage = raptor_flare_damage; _flare.health = 20; _flare.tur_impacttime = time + autocvar_g_vehicle_raptor_flare_lifetime; - _flare.touch = raptor_flare_touch; + settouch(_flare, raptor_flare_touch); } - weapon_thinkf(player, WFRAME_FIRE2, 0, w_ready); + weapon_thinkf(player, weaponentity, WFRAME_FIRE2, 0, w_ready); } } -void raptor_bomblet_boom() -{SELFPARAM(); - RadiusDamage (self, self.realowner, autocvar_g_vehicle_raptor_bomblet_damage, +void raptor_bomblet_boom(entity this) +{ + RadiusDamage (this, this.realowner, autocvar_g_vehicle_raptor_bomblet_damage, autocvar_g_vehicle_raptor_bomblet_edgedamage, - autocvar_g_vehicle_raptor_bomblet_radius, world, world, - autocvar_g_vehicle_raptor_bomblet_force, DEATH_VH_RAPT_BOMB, world); - remove(self); + autocvar_g_vehicle_raptor_bomblet_radius, NULL, NULL, + autocvar_g_vehicle_raptor_bomblet_force, DEATH_VH_RAPT_BOMB.m_id, NULL); + remove(this); } -void raptor_bomblet_touch() -{SELFPARAM(); - if(other == self.owner) +void raptor_bomblet_touch(entity this, entity toucher) +{ + if(toucher == this.owner) return; - PROJECTILE_TOUCH; - self.think = raptor_bomblet_boom; - self.nextthink = time + random() * autocvar_g_vehicle_raptor_bomblet_explode_delay; + PROJECTILE_TOUCH(this, toucher); + setthink(this, raptor_bomblet_boom); + this.nextthink = time + random() * autocvar_g_vehicle_raptor_bomblet_explode_delay; } -void raptor_bomb_burst() -{SELFPARAM(); - if(self.cnt > time) +void raptor_bomb_burst(entity this) +{ + if(this.cnt > time) if(autocvar_g_vehicle_raptor_bomblet_alt) { - self.nextthink = time; - traceline(self.origin, self.origin + (normalize(self.velocity) * autocvar_g_vehicle_raptor_bomblet_alt), MOVE_NORMAL, self); - if((trace_fraction == 1.0) || (vlen(self.origin - self.owner.origin) < autocvar_g_vehicle_raptor_bomblet_radius)) + this.nextthink = time; + traceline(this.origin, this.origin + (normalize(this.velocity) * autocvar_g_vehicle_raptor_bomblet_alt), MOVE_NORMAL, this); + if((trace_fraction == 1.0) || (vdist(this.origin - this.owner.origin, <, autocvar_g_vehicle_raptor_bomblet_radius))) { - UpdateCSQCProjectile(self); + UpdateCSQCProjectile(this); return; } } @@ -175,42 +121,51 @@ void raptor_bomb_burst() entity bomblet; float i; - Damage_DamageInfo(self.origin, 0, 0, 0, '0 0 0', DEATH_VH_RAPT_FRAGMENT, 0, self); + Damage_DamageInfo(this.origin, 0, 0, 0, '0 0 0', DEATH_VH_RAPT_FRAGMENT.m_id, 0, this); for(i = 0; i < autocvar_g_vehicle_raptor_bomblets; ++i) { bomblet = spawn(); - setorigin(bomblet, self.origin); + setorigin(bomblet, this.origin); bomblet.movetype = MOVETYPE_TOSS; - bomblet.touch = raptor_bomblet_touch; - bomblet.think = raptor_bomblet_boom; + settouch(bomblet, raptor_bomblet_touch); + setthink(bomblet, raptor_bomblet_boom); bomblet.nextthink = time + 5; - bomblet.owner = self.owner; - bomblet.realowner = self.realowner; - bomblet.velocity = normalize(normalize(self.velocity) + (randomvec() * autocvar_g_vehicle_raptor_bomblet_spread)) * vlen(self.velocity); + bomblet.owner = this.owner; + bomblet.realowner = this.realowner; + bomblet.velocity = normalize(normalize(this.velocity) + (randomvec() * autocvar_g_vehicle_raptor_bomblet_spread)) * vlen(this.velocity); PROJECTILE_MAKETRIGGER(bomblet); CSQCProjectile(bomblet, true, PROJECTILE_RAPTORBOMBLET, true); } - remove(self); + remove(this); +} + +void raptor_bomb_touch(entity this, entity toucher) +{ + raptor_bomb_burst(this); } -void raptor_bombdrop() -{SELFPARAM(); +void raptor_bombdrop(entity this) +{ entity bomb_1, bomb_2; bomb_1 = spawn(); bomb_2 = spawn(); - setorigin(bomb_1, gettaginfo(self, gettagindex(self, "bombmount_left"))); - setorigin(bomb_2, gettaginfo(self, gettagindex(self, "bombmount_right"))); + vector org = gettaginfo(this, gettagindex(this, "bombmount_left")); + setorigin(bomb_1, org); + org = gettaginfo(this, gettagindex(this, "bombmount_right")); + setorigin(bomb_2, org); bomb_1.movetype = bomb_2.movetype = MOVETYPE_BOUNCE; - bomb_1.velocity = bomb_2.velocity = self.velocity; - bomb_1.touch = bomb_2.touch = raptor_bomb_burst; - bomb_1.think = bomb_2.think = raptor_bomb_burst; + bomb_1.velocity = bomb_2.velocity = this.velocity; + settouch(bomb_1, raptor_bomb_touch); + settouch(bomb_2, raptor_bomb_touch); + setthink(bomb_1, raptor_bomb_burst); + setthink(bomb_2, raptor_bomb_burst); bomb_1.cnt = bomb_2.cnt = time + 10; if(autocvar_g_vehicle_raptor_bomblet_alt) @@ -218,8 +173,8 @@ void raptor_bombdrop() else bomb_1.nextthink = bomb_2.nextthink = time + autocvar_g_vehicle_raptor_bomblet_time; - bomb_1.owner = bomb_2.owner = self; - bomb_1.realowner = bomb_2.realowner = self.owner; + bomb_1.owner = bomb_2.owner = this; + bomb_1.realowner = bomb_2.realowner = this.owner; bomb_1.solid = bomb_2.solid = SOLID_BBOX; bomb_1.gravity = bomb_2.gravity = 1; @@ -230,60 +185,58 @@ void raptor_bombdrop() CSQCProjectile(bomb_2, true, PROJECTILE_RAPTORBOMB, true); } -void raptor_flare_touch() -{SELFPARAM(); - remove(self); +void raptor_flare_touch(entity this, entity toucher) +{ + remove(this); } -void raptor_flare_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) -{SELFPARAM(); - self.health -= damage; - if(self.health <= 0) - remove(self); +void raptor_flare_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) +{ + this.health -= damage; + if(this.health <= 0) + remove(this); } -void raptor_flare_think() -{SELFPARAM(); - self.nextthink = time + 0.1; - entity _missile = findchainentity(enemy, self.owner); +void raptor_flare_think(entity this) +{ + this.nextthink = time + 0.1; + entity _missile = findchainentity(enemy, this.owner); while(_missile) { if(_missile.flags & FL_PROJECTILE) - if(vlen(self.origin - _missile.origin) < autocvar_g_vehicle_raptor_flare_range) + if(vdist(this.origin - _missile.origin, <, autocvar_g_vehicle_raptor_flare_range)) if(random() > autocvar_g_vehicle_raptor_flare_chase) - _missile.enemy = self; + _missile.enemy = this; _missile = _missile.chain; } - if(self.tur_impacttime < time) - remove(self); + if(this.tur_impacttime < time) + remove(this); } #endif #ifdef CSQC -void RaptorCBShellfragDraw() -{SELFPARAM(); - if(wasfreed(self)) +void RaptorCBShellfragDraw(entity this) +{ + if(wasfreed(this)) return; - Movetype_Physics_MatchTicrate(autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy); - self.move_avelocity += randomvec() * 15; - self.renderflags = 0; + Movetype_Physics_MatchTicrate(this, autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy); + this.avelocity += randomvec() * 15; + this.renderflags = 0; - if(self.cnt < time) - self.alpha = bound(0, self.nextthink - time, 1); + if(this.cnt < time) + this.alpha = bound(0, this.nextthink - time, 1); - if(self.alpha < ALPHA_MIN_VISIBLE) - remove(self); + if(this.alpha < ALPHA_MIN_VISIBLE) + remove(this); } void RaptorCBShellfragToss(vector _org, vector _vel, vector _ang) -{SELFPARAM(); - entity sfrag; - - sfrag = spawn(); +{ + entity sfrag = spawn(); setmodel(sfrag, MDL_VEH_RAPTOR_CB_FRAGMENT); setorigin(sfrag, _org); @@ -293,10 +246,9 @@ void RaptorCBShellfragToss(vector _org, vector _vel, vector _ang) sfrag.draw = RaptorCBShellfragDraw; - sfrag.move_origin = sfrag.origin = _org; - sfrag.move_velocity = _vel; - sfrag.move_avelocity = prandomvec() * vlen(sfrag.move_velocity); - sfrag.angles = self.move_angles = _ang; + sfrag.velocity = _vel; + sfrag.avelocity = prandomvec() * vlen(sfrag.velocity); + sfrag.angles = _ang; sfrag.move_time = time; sfrag.damageforcescale = 4;