From 78d6bfe597ad079dc9780621fb9219cb8fde9d58 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 26 Mar 2016 23:09:12 +1000 Subject: [PATCH] Clean up some more self uses --- qcsrc/common/vehicles/sv_vehicles.qc | 264 ++++++++++----------- qcsrc/common/vehicles/sv_vehicles.qh | 4 +- qcsrc/common/vehicles/vehicle/bumblebee.qc | 50 ++-- qcsrc/common/vehicles/vehicle/racer.qc | 27 +-- qcsrc/common/vehicles/vehicle/raptor.qc | 25 +- qcsrc/common/vehicles/vehicle/spiderbot.qc | 23 +- qcsrc/server/mutators/events.qh | 5 +- qcsrc/server/tests.qc | 3 +- 8 files changed, 190 insertions(+), 211 deletions(-) diff --git a/qcsrc/common/vehicles/sv_vehicles.qc b/qcsrc/common/vehicles/sv_vehicles.qc index 7e5bc93eb..0748941ea 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qc +++ b/qcsrc/common/vehicles/sv_vehicles.qc @@ -302,11 +302,11 @@ void vehicles_gib_think() self.nextthink = time + 0.1; } -entity vehicle_tossgib(entity _template, vector _vel, string _tag, bool _burn, bool _explode, float _maxtime, vector _rot) -{SELFPARAM(); +entity vehicle_tossgib(entity this, entity _template, vector _vel, string _tag, bool _burn, bool _explode, float _maxtime, vector _rot) +{ entity _gib = spawn(); _setmodel(_gib, _template.model); - vector org = gettaginfo(self, gettagindex(self, _tag)); + vector org = gettaginfo(this, gettagindex(this, _tag)); setorigin(_gib, org); _gib.velocity = _vel; _gib.movetype = MOVETYPE_TOSS; @@ -337,9 +337,9 @@ entity vehicle_tossgib(entity _template, vector _vel, string _tag, bool _burn, b bool vehicle_addplayerslot( entity _owner, entity _slot, int _hud, - string _hud_model, + Model _hud_model, bool(entity) _framefunc, - void(bool) _exitfunc, float() _enterfunc) + void(bool) _exitfunc, float(entity, entity) _enterfunc) { if(!(_owner.vehicle_flags & VHF_MULTISLOT)) _owner.vehicle_flags |= VHF_MULTISLOT; @@ -354,7 +354,7 @@ bool vehicle_addplayerslot( entity _owner, _slot.vehicle_hudmodel.viewmodelforclient = _slot; _slot.vehicle_viewport.effects = (EF_ADDITIVE | EF_DOUBLESIDED | EF_FULLBRIGHT | EF_NODEPTHTEST | EF_NOGUNBOB | EF_NOSHADOW | EF_LOWPRECISION | EF_SELECTABLE | EF_TELEPORT_BIT); - _setmodel(_slot.vehicle_hudmodel, _hud_model); + setmodel(_slot.vehicle_hudmodel, _hud_model); setmodel(_slot.vehicle_viewport, MDL_Null); setattachment(_slot.vehicle_hudmodel, _slot, ""); @@ -381,62 +381,52 @@ vector vehicle_aimturret(entity _vehic, vector _target, entity _turrret, string return vtag; } -void vehicles_reset_colors() -{SELFPARAM(); - entity e; - float _effects = 0, _colormap; - vector _glowmod, _colormod; - +void vehicles_reset_colors(entity this) +{ + int eff = 0, cmap; + const vector cmod = '0 0 0'; + if(this.team && teamplay) + cmap = 1024 + (this.team - 1) * 17; + else + cmap = 1024; if(autocvar_g_nodepthtestplayers) - _effects |= EF_NODEPTHTEST; - + eff |= EF_NODEPTHTEST; if(autocvar_g_fullbrightplayers) - _effects |= EF_FULLBRIGHT; - - if(self.team) - _colormap = 1024 + (self.team - 1) * 17; - else - _colormap = 1024; - - _glowmod = '0 0 0'; - _colormod = '0 0 0'; + eff |= EF_FULLBRIGHT; // Find all ents attacked to main model and setup effects, colormod etc. - e = findchainentity(tag_entity, self); - while(e) + FOREACH_ENTITY_ENT(tag_entity, this, { - if(e != self.vehicle_shieldent) + if(it != this.vehicle_shieldent) { - e.effects = _effects; // | EF_LOWPRECISION; - e.colormod = _colormod; - e.colormap = _colormap; - e.alpha = 1; + it.effects = eff; + it.colormod = cmod; + it.colormap = cmap; + it.alpha = 1; } - e = e.chain; - } + }); + // Also check head tags - e = findchainentity(tag_entity, self.tur_head); - while(e) + FOREACH_ENTITY_ENT(tag_entity, this.tur_head, { - if(e != self.vehicle_shieldent) + if(it != this.vehicle_shieldent) { - e.effects = _effects; // | EF_LOWPRECISION; - e.colormod = _colormod; - e.colormap = _colormap; - e.alpha = 1; + it.effects = eff; + it.colormod = cmod; + it.colormap = cmap; + it.alpha = 1; } - e = e.chain; - } + }); - self.vehicle_hudmodel.effects = self.effects = _effects; // | EF_LOWPRECISION; - self.vehicle_hudmodel.colormod = self.colormod = _colormod; - self.vehicle_hudmodel.colormap = self.colormap = _colormap; - self.vehicle_viewport.effects = (EF_ADDITIVE | EF_DOUBLESIDED | EF_FULLBRIGHT | EF_NODEPTHTEST | EF_NOGUNBOB | EF_NOSHADOW | EF_LOWPRECISION | EF_SELECTABLE | EF_TELEPORT_BIT); + this.vehicle_hudmodel.effects = this.effects = eff; // | EF_LOWPRECISION; + this.vehicle_hudmodel.colormod = this.colormod = cmod; + this.vehicle_hudmodel.colormap = this.colormap = cmap; + this.vehicle_viewport.effects = (EF_ADDITIVE | EF_DOUBLESIDED | EF_FULLBRIGHT | EF_NODEPTHTEST | EF_NOGUNBOB | EF_NOSHADOW | EF_LOWPRECISION | EF_SELECTABLE | EF_TELEPORT_BIT); - self.alpha = 1; - self.avelocity = '0 0 0'; - self.velocity = '0 0 0'; - self.effects = _effects; + this.alpha = 1; + this.avelocity = '0 0 0'; + this.velocity = '0 0 0'; + this.effects = eff; } void vehicles_clearreturn(entity veh) @@ -573,7 +563,7 @@ void vehicle_use() else { vehicles_setreturn(self); - vehicles_reset_colors(); + vehicles_reset_colors(self); } } } @@ -740,21 +730,21 @@ float vehicles_crushable(entity e) return false; } -void vehicles_impact(float _minspeed, float _speedfac, float _maxpain) -{SELFPARAM(); +void vehicles_impact(entity this, float _minspeed, float _speedfac, float _maxpain) +{ if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT) return; - if(self.play_time < time) + if(this.play_time < time) { - float wc = vlen(self.velocity - self.oldvelocity); - //dprint("oldvel: ", vtos(self.oldvelocity), "\n"); - //dprint("vel: ", vtos(self.velocity), "\n"); + float wc = vlen(this.velocity - this.oldvelocity); + //dprint("oldvel: ", vtos(this.oldvelocity), "\n"); + //dprint("vel: ", vtos(this.velocity), "\n"); if(_minspeed < wc) { float take = min(_speedfac * wc, _maxpain); - Damage (self, world, world, take, DEATH_FALL.m_id, self.origin, '0 0 0'); - self.play_time = time + 0.25; + Damage (this, world, world, take, DEATH_FALL.m_id, this.origin, '0 0 0'); + this.play_time = time + 0.25; //dprint("wc: ", ftos(wc), "\n"); //dprint("take: ", ftos(take), "\n"); @@ -901,7 +891,7 @@ void vehicles_exit(bool eject) _vehicle.vehicle_exit(eject); vehicles_setreturn(_vehicle); - vehicles_reset_colors(); + vehicles_reset_colors(_vehicle); _vehicle.owner = world; CSQCMODEL_AUTOINIT(self); @@ -962,7 +952,9 @@ bool vehicle_impulse(entity this, int imp) } void vehicles_enter(entity pl, entity veh) -{SELFPARAM(); +{ + entity oldself = self; + // Remove this when bots know how to use vehicles if((IS_BOT_CLIENT(pl) && !autocvar_g_vehicles_allow_bots)) return; @@ -979,28 +971,17 @@ void vehicles_enter(entity pl, entity veh) if(veh.vehicle_flags & VHF_MULTISLOT) if(veh.owner) { - setself(veh); - other = pl; // TODO: fix - if(!veh.gunner1) if(time >= veh.gun1.phase) if(veh.gun1.vehicle_enter) - if(veh.gun1.vehicle_enter()) - { - setself(this); + if(veh.gun1.vehicle_enter(veh, pl)) return; - } if(!veh.gunner2) if(time >= veh.gun2.phase) if(veh.gun2.vehicle_enter) - if(veh.gun2.vehicle_enter()) - { - setself(this); + if(veh.gun2.vehicle_enter(veh, pl)) return; - } - - setself(this); } if(teamplay) @@ -1106,7 +1087,7 @@ void vehicles_enter(entity pl, entity veh) CSQCModel_UnlinkEntity(veh); Vehicle info = Vehicles_from(veh.vehicleid); info.vr_enter(info, veh); - setself(this); + setself(oldself); antilag_clear(pl, CS(pl)); } @@ -1167,7 +1148,7 @@ void vehicles_spawn() FOREACH_CLIENT(IS_PLAYER(it) && it.hook.aiment == self, RemoveGrapplingHook(it)); - vehicles_reset_colors(); + vehicles_reset_colors(self); Vehicle info = Vehicles_from(self.vehicleid); info.vr_spawn(info, self); @@ -1175,121 +1156,118 @@ void vehicles_spawn() CSQCMODEL_AUTOINIT(self); } -bool vehicle_initialize(entity veh, bool nodrop) -{SELFPARAM(); +bool vehicle_initialize(entity this, Vehicle info, bool nodrop) +{ if(!autocvar_g_vehicles) return false; - if(!veh.vehicleid) + if(!info.vehicleid) return false; - if(!veh.tur_head) { - Vehicle info = Vehicles_from(veh.vehicleid); + if(!this.tur_head) info.vr_precache(info); - } - if(self.targetname && self.targetname != "") + if(this.targetname && this.targetname != "") { - self.vehicle_controller = find(world, target, self.targetname); - if(!self.vehicle_controller) + this.vehicle_controller = find(world, target, this.targetname); + if(!this.vehicle_controller) { bprint("^1WARNING: ^7Vehicle with invalid .targetname\n"); - self.active = ACTIVE_ACTIVE; + this.active = ACTIVE_ACTIVE; } else { - self.team = self.vehicle_controller.team; - self.use = vehicle_use; + this.team = this.vehicle_controller.team; + this.use = vehicle_use; if(teamplay) { - if(self.vehicle_controller.team == 0) - self.active = ACTIVE_NOT; + if(this.vehicle_controller.team == 0) + this.active = ACTIVE_NOT; else - self.active = ACTIVE_ACTIVE; + this.active = ACTIVE_ACTIVE; } } } - else { self.active = ACTIVE_ACTIVE; } + else { this.active = ACTIVE_ACTIVE; } - if(self.team && (!teamplay || !autocvar_g_vehicles_teams)) - self.team = 0; + if(this.team && (!teamplay || !autocvar_g_vehicles_teams)) + this.team = 0; - if(self.mdl == "" || !self.mdl) - _setmodel(self, veh.model); + if(this.mdl == "" || !this.mdl) + _setmodel(this, info.model); else - _setmodel(self, self.mdl); - - self.vehicle_flags |= VHF_ISVEHICLE; - - self.vehicle_viewport = new(vehicle_viewport); - self.vehicle_hudmodel = new(vehicle_hudmodel); - self.tur_head = new(tur_head); - self.tur_head.owner = self; - self.takedamage = DAMAGE_NO; - self.bot_attack = true; - self.iscreature = true; - self.teleportable = false; // no teleporting for vehicles, too buggy - self.damagedbycontents = true; - self.vehicleid = veh.vehicleid; - self.PlayerPhysplug = veh.PlayerPhysplug; - self.event_damage = func_null; - self.touch = vehicles_touch; - self.think = vehicles_spawn; - self.nextthink = time; - self.effects = EF_NODRAW; - self.dphitcontentsmask = DPCONTENTS_BODY | DPCONTENTS_SOLID; + _setmodel(this, this.mdl); + + this.vehicle_flags |= VHF_ISVEHICLE; + + this.vehicle_viewport = new(vehicle_viewport); + this.vehicle_hudmodel = new(vehicle_hudmodel); + this.tur_head = new(tur_head); + this.tur_head.owner = this; + this.takedamage = DAMAGE_NO; + this.bot_attack = true; + this.iscreature = true; + this.teleportable = false; // no teleporting for vehicles, too buggy + this.damagedbycontents = true; + this.vehicleid = info.vehicleid; + this.PlayerPhysplug = info.PlayerPhysplug; + this.event_damage = func_null; + this.touch = vehicles_touch; + this.think = vehicles_spawn; + this.nextthink = time; + this.effects = EF_NODRAW; + this.dphitcontentsmask = DPCONTENTS_BODY | DPCONTENTS_SOLID; if(autocvar_g_playerclip_collisions) - self.dphitcontentsmask |= DPCONTENTS_PLAYERCLIP; + this.dphitcontentsmask |= DPCONTENTS_PLAYERCLIP; if(autocvar_g_nodepthtestplayers) - self.effects |= EF_NODEPTHTEST; + this.effects |= EF_NODEPTHTEST; if(autocvar_g_fullbrightplayers) - self.effects |= EF_FULLBRIGHT; + this.effects |= EF_FULLBRIGHT; - _setmodel(self.vehicle_hudmodel, veh.hud_model); - setmodel(self.vehicle_viewport, MDL_Null); + _setmodel(this.vehicle_hudmodel, info.hud_model); + setmodel(this.vehicle_viewport, MDL_Null); - if(veh.head_model != "") + if(info.head_model != "") { - _setmodel(self.tur_head, veh.head_model); - setattachment(self.tur_head, self, veh.tag_head); - setattachment(self.vehicle_hudmodel, self.tur_head, veh.tag_hud); - setattachment(self.vehicle_viewport, self.vehicle_hudmodel, veh.tag_view); + _setmodel(this.tur_head, info.head_model); + setattachment(this.tur_head, this, info.tag_head); + setattachment(this.vehicle_hudmodel, this.tur_head, info.tag_hud); + setattachment(this.vehicle_viewport, this.vehicle_hudmodel, info.tag_view); } else { - setattachment(self.tur_head, self, ""); - setattachment(self.vehicle_hudmodel, self, veh.tag_hud); - setattachment(self.vehicle_viewport, self.vehicle_hudmodel, veh.tag_view); + setattachment(this.tur_head, this, ""); + setattachment(this.vehicle_hudmodel, this, info.tag_hud); + setattachment(this.vehicle_viewport, this.vehicle_hudmodel, info.tag_view); } - setsize(self, veh.mins, veh.maxs); + setsize(this, info.mins, info.maxs); if(!nodrop) { - setorigin(self, self.origin); - tracebox(self.origin + '0 0 100', veh.mins, veh.maxs, self.origin - '0 0 10000', MOVE_WORLDONLY, self); - setorigin(self, trace_endpos); + setorigin(this, this.origin); + tracebox(this.origin + '0 0 100', info.mins, info.maxs, this.origin - '0 0 10000', MOVE_WORLDONLY, this); + setorigin(this, trace_endpos); } - self.pos1 = self.origin; - self.pos2 = self.angles; - self.tur_head.team = self.team; + this.pos1 = this.origin; + this.pos2 = this.angles; + this.tur_head.team = this.team; - Vehicle info = Vehicles_from(veh.vehicleid); - info.vr_setup(info, veh); + info.vr_setup(info, this); - if(self.active == ACTIVE_NOT) - self.nextthink = 0; // wait until activated + if(this.active == ACTIVE_NOT) + this.nextthink = 0; // wait until activated else if(autocvar_g_vehicles_delayspawn) - self.nextthink = time + self.respawntime + (random() * autocvar_g_vehicles_delayspawn_jitter); + this.nextthink = time + this.respawntime + (random() * autocvar_g_vehicles_delayspawn_jitter); else - self.nextthink = time + game_starttime; + this.nextthink = time + game_starttime; - if(MUTATOR_CALLHOOK(VehicleSpawn)) + if(MUTATOR_CALLHOOK(VehicleSpawn, this)) return false; return true; diff --git a/qcsrc/common/vehicles/sv_vehicles.qh b/qcsrc/common/vehicles/sv_vehicles.qh index 06b91784b..393b93b31 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qh +++ b/qcsrc/common/vehicles/sv_vehicles.qh @@ -81,7 +81,7 @@ const float DAMAGE_TARGETDRONE = 10; .bool(int _imp) vehicles_impulse; .int vehicle_weapon2mode = _STAT(VEHICLESTAT_W2MODE); .void(int exit_flags) vehicle_exit; -.bool() vehicle_enter; +.bool(entity this, entity player) vehicle_enter; const int VHEF_NORMAL = 0; /// User pressed exit key const int VHEF_EJECT = 1; /// User pressed exit key 3 times fast (not implemented) or vehile is dying const int VHEF_RELEASE = 2; /// Release ownership, client possibly allready dissconnected / went spec / changed team / used "kill" (not implemented) @@ -99,7 +99,7 @@ float vehicles_exit_running; .float vehicle_enter_delay; // prevent players jumping to and from vehicles instantly void vehicles_exit(float eject); -float vehicle_initialize(entity vehicle, float nodrop); +float vehicle_initialize(entity this, Vehicle info, float nodrop); bool vehicle_impulse(entity this, int imp); bool vehicles_crushable(entity e); diff --git a/qcsrc/common/vehicles/vehicle/bumblebee.qc b/qcsrc/common/vehicles/vehicle/bumblebee.qc index fd6b19bf3..c3c0861e9 100644 --- a/qcsrc/common/vehicles/vehicle/bumblebee.qc +++ b/qcsrc/common/vehicles/vehicle/bumblebee.qc @@ -23,6 +23,10 @@ CLASS(Bumblebee, Vehicle) ENDCLASS(Bumblebee) REGISTER_VEHICLE(BUMBLEBEE, NEW(Bumblebee)); +#ifndef MENUQC + MODEL(VEH_BUMBLEBEE_GUNCOCKPIT, "models/vehicles/wakizashi_cockpit.dpm"); +#endif + #endif #ifdef IMPLEMENTATION @@ -285,10 +289,9 @@ void bumblebee_gunner_exit(int _exitflag) player.vehicle = world; } -bool bumblebee_gunner_enter() -{SELFPARAM(); - entity vehic = self; - entity player = other; +bool bumblebee_gunner_enter(entity this, entity player) +{ + entity vehic = this; entity gunner = world; if(!vehic.gunner1 && !vehic.gunner2 && ((time >= vehic.gun1.phase) + (time >= vehic.gun2.phase)) == 2) @@ -381,7 +384,7 @@ void bumblebee_touch() float phase_time = (time >= self.gun1.phase) + (time >= self.gun2.phase); if(time >= other.vehicle_enter_delay && phase_time) - if(bumblebee_gunner_enter()) + if(bumblebee_gunner_enter(self, other)) return; } @@ -715,14 +718,14 @@ void bumblebee_diethink() spawnfunc(vehicle_bumblebee) { - if(!autocvar_g_vehicle_bumblebee) { remove(self); return; } - if(!vehicle_initialize(VEH_BUMBLEBEE, false)) { remove(self); return; } + if(!autocvar_g_vehicle_bumblebee) { remove(this); return; } + if(!vehicle_initialize(this, VEH_BUMBLEBEE, false)) { remove(this); return; } } METHOD(Bumblebee, vr_impact, void(Bumblebee thisveh, entity instance)) { if(autocvar_g_vehicle_bumblebee_bouncepain) - vehicles_impact(autocvar_g_vehicle_bumblebee_bouncepain_x, autocvar_g_vehicle_bumblebee_bouncepain_y, autocvar_g_vehicle_bumblebee_bouncepain_z); + vehicles_impact(instance, autocvar_g_vehicle_bumblebee_bouncepain_x, autocvar_g_vehicle_bumblebee_bouncepain_y, autocvar_g_vehicle_bumblebee_bouncepain_z); } METHOD(Bumblebee, vr_enter, void(Bumblebee thisveh, entity instance)) { @@ -798,11 +801,11 @@ METHOD(Bumblebee, vr_death, void(Bumblebee thisveh, entity instance)) self.vehicle_exit(VHEF_EJECT); fixedmakevectors(self.angles); - vehicle_tossgib(self.gun1, self.velocity + v_right * 300 + v_up * 100 + randomvec() * 200, "cannon_right", rint(random()), rint(random()), 6, randomvec() * 200); - vehicle_tossgib(self.gun2, self.velocity + v_right * -300 + v_up * 100 + randomvec() * 200, "cannon_left", rint(random()), rint(random()), 6, randomvec() * 200); - vehicle_tossgib(self.gun3, self.velocity + v_forward * 300 + v_up * -100 + randomvec() * 200, "raygun", rint(random()), rint(random()), 6, randomvec() * 300); + vehicle_tossgib(instance, self.gun1, self.velocity + v_right * 300 + v_up * 100 + randomvec() * 200, "cannon_right", rint(random()), rint(random()), 6, randomvec() * 200); + vehicle_tossgib(instance, self.gun2, self.velocity + v_right * -300 + v_up * 100 + randomvec() * 200, "cannon_left", rint(random()), rint(random()), 6, randomvec() * 200); + vehicle_tossgib(instance, self.gun3, self.velocity + v_forward * 300 + v_up * -100 + randomvec() * 200, "raygun", rint(random()), rint(random()), 6, randomvec() * 300); - entity _body = vehicle_tossgib(self, self.velocity + randomvec() * 200, "", rint(random()), rint(random()), 6, randomvec() * 100); + entity _body = vehicle_tossgib(instance, self, self.velocity + randomvec() * 200, "", rint(random()), rint(random()), 6, randomvec() * 100); if(random() > 0.5) _body.touch = bumblebee_blowup; @@ -878,8 +881,8 @@ METHOD(Bumblebee, vr_spawn, void(Bumblebee thisveh, entity instance)) setorigin(self.gun3, ofs); self.angles = self.gun3.pos1; - vehicle_addplayerslot(self, self.gun1, HUD_BUMBLEBEE_GUN, "models/vehicles/wakizashi_cockpit.dpm", bumblebee_gunner_frame, bumblebee_gunner_exit, bumblebee_gunner_enter); - vehicle_addplayerslot(self, self.gun2, HUD_BUMBLEBEE_GUN, "models/vehicles/wakizashi_cockpit.dpm", bumblebee_gunner_frame, bumblebee_gunner_exit, bumblebee_gunner_enter); + vehicle_addplayerslot(self, self.gun1, HUD_BUMBLEBEE_GUN, MDL_VEH_BUMBLEBEE_GUNCOCKPIT, bumblebee_gunner_frame, bumblebee_gunner_exit, bumblebee_gunner_enter); + vehicle_addplayerslot(self, self.gun2, HUD_BUMBLEBEE_GUN, MDL_VEH_BUMBLEBEE_GUNCOCKPIT, bumblebee_gunner_frame, bumblebee_gunner_exit, bumblebee_gunner_enter); setorigin(self.vehicle_hudmodel, '50 0 -5'); // Move cockpit forward - down. setorigin(self.vehicle_viewport, '5 0 2'); // Move camera forward up @@ -916,25 +919,24 @@ METHOD(Bumblebee, vr_spawn, void(Bumblebee thisveh, entity instance)) } METHOD(Bumblebee, vr_setup, void(Bumblebee thisveh, entity instance)) { - SELFPARAM(); if(autocvar_g_vehicle_bumblebee_energy) if(autocvar_g_vehicle_bumblebee_energy_regen) - self.vehicle_flags |= VHF_ENERGYREGEN; + instance.vehicle_flags |= VHF_ENERGYREGEN; if(autocvar_g_vehicle_bumblebee_shield) - self.vehicle_flags |= VHF_HASSHIELD; + instance.vehicle_flags |= VHF_HASSHIELD; if(autocvar_g_vehicle_bumblebee_shield_regen) - self.vehicle_flags |= VHF_SHIELDREGEN; + instance.vehicle_flags |= VHF_SHIELDREGEN; if(autocvar_g_vehicle_bumblebee_health_regen) - self.vehicle_flags |= VHF_HEALTHREGEN; + instance.vehicle_flags |= VHF_HEALTHREGEN; - self.vehicle_exit = bumblebee_exit; - self.respawntime = autocvar_g_vehicle_bumblebee_respawntime; - self.vehicle_health = autocvar_g_vehicle_bumblebee_health; - self.max_health = self.vehicle_health; - self.vehicle_shield = autocvar_g_vehicle_bumblebee_shield; + instance.vehicle_exit = bumblebee_exit; + instance.respawntime = autocvar_g_vehicle_bumblebee_respawntime; + instance.vehicle_health = autocvar_g_vehicle_bumblebee_health; + instance.max_health = instance.vehicle_health; + instance.vehicle_shield = autocvar_g_vehicle_bumblebee_shield; } #endif // SVQC diff --git a/qcsrc/common/vehicles/vehicle/racer.qc b/qcsrc/common/vehicles/vehicle/racer.qc index f3670a839..da259784f 100644 --- a/qcsrc/common/vehicles/vehicle/racer.qc +++ b/qcsrc/common/vehicles/vehicle/racer.qc @@ -519,8 +519,8 @@ void racer_deadtouch() spawnfunc(vehicle_racer) { - if(!autocvar_g_vehicle_racer) { remove(self); return; } - if(!vehicle_initialize(VEH_RACER, false)) { remove(self); return; } + if(!autocvar_g_vehicle_racer) { remove(this); return; } + if(!vehicle_initialize(this, VEH_RACER, false)) { remove(this); return; } } #endif // SVQC @@ -564,7 +564,7 @@ METHOD(Racer, vr_impact, void(Racer thisveh, entity instance)) { #ifdef SVQC if(autocvar_g_vehicle_racer_bouncepain) - vehicles_impact(autocvar_g_vehicle_racer_bouncepain_x, autocvar_g_vehicle_racer_bouncepain_y, autocvar_g_vehicle_racer_bouncepain_z); + vehicles_impact(instance, autocvar_g_vehicle_racer_bouncepain_x, autocvar_g_vehicle_racer_bouncepain_y, autocvar_g_vehicle_racer_bouncepain_z); #endif } @@ -669,29 +669,26 @@ METHOD(Racer, vr_crosshair, void(Racer thisveh)) METHOD(Racer, vr_setup, void(Racer thisveh, entity instance)) { #ifdef SVQC - SELFPARAM(); - self.vehicle_exit = racer_exit; -#endif + instance.vehicle_exit = racer_exit; -#ifdef SVQC // we have no need to network energy if(autocvar_g_vehicle_racer_energy) if(autocvar_g_vehicle_racer_energy_regen) - self.vehicle_flags |= VHF_ENERGYREGEN; + instance.vehicle_flags |= VHF_ENERGYREGEN; if(autocvar_g_vehicle_racer_shield) - self.vehicle_flags |= VHF_HASSHIELD; + instance.vehicle_flags |= VHF_HASSHIELD; if(autocvar_g_vehicle_racer_shield_regen) - self.vehicle_flags |= VHF_SHIELDREGEN; + instance.vehicle_flags |= VHF_SHIELDREGEN; if(autocvar_g_vehicle_racer_health_regen) - self.vehicle_flags |= VHF_HEALTHREGEN; + instance.vehicle_flags |= VHF_HEALTHREGEN; - self.respawntime = autocvar_g_vehicle_racer_respawntime; - self.vehicle_health = autocvar_g_vehicle_racer_health; - self.vehicle_shield = autocvar_g_vehicle_racer_shield; - self.max_health = self.vehicle_health; + instance.respawntime = autocvar_g_vehicle_racer_respawntime; + instance.vehicle_health = autocvar_g_vehicle_racer_health; + instance.vehicle_shield = autocvar_g_vehicle_racer_shield; + instance.max_health = instance.vehicle_health; #endif #ifdef CSQC diff --git a/qcsrc/common/vehicles/vehicle/raptor.qc b/qcsrc/common/vehicles/vehicle/raptor.qc index 6bd599423..f1f29c55c 100644 --- a/qcsrc/common/vehicles/vehicle/raptor.qc +++ b/qcsrc/common/vehicles/vehicle/raptor.qc @@ -605,14 +605,14 @@ float raptor_impulse(float _imp) spawnfunc(vehicle_raptor) { - if(!autocvar_g_vehicle_raptor) { remove(self); return; } - if(!vehicle_initialize(VEH_RAPTOR, false)) { remove(self); return; } + if(!autocvar_g_vehicle_raptor) { remove(this); return; } + if(!vehicle_initialize(this, VEH_RAPTOR, false)) { remove(this); return; } } METHOD(Raptor, vr_impact, void(Raptor thisveh, entity instance)) { if(autocvar_g_vehicle_raptor_bouncepain) - vehicles_impact(autocvar_g_vehicle_raptor_bouncepain_x, autocvar_g_vehicle_raptor_bouncepain_y, autocvar_g_vehicle_raptor_bouncepain_z); + vehicles_impact(instance, autocvar_g_vehicle_raptor_bouncepain_x, autocvar_g_vehicle_raptor_bouncepain_y, autocvar_g_vehicle_raptor_bouncepain_z); } METHOD(Raptor, vr_enter, void(Raptor thisveh, entity instance)) { @@ -750,24 +750,23 @@ METHOD(Raptor, vr_spawn, void(Raptor thisveh, entity instance)) } METHOD(Raptor, vr_setup, void(Raptor thisveh, entity instance)) { - SELFPARAM(); if(autocvar_g_vehicle_raptor_shield) - self.vehicle_flags |= VHF_HASSHIELD; + instance.vehicle_flags |= VHF_HASSHIELD; if(autocvar_g_vehicle_raptor_shield_regen) - self.vehicle_flags |= VHF_SHIELDREGEN; + instance.vehicle_flags |= VHF_SHIELDREGEN; if(autocvar_g_vehicle_raptor_health_regen) - self.vehicle_flags |= VHF_HEALTHREGEN; + instance.vehicle_flags |= VHF_HEALTHREGEN; if(autocvar_g_vehicle_raptor_energy_regen) - self.vehicle_flags |= VHF_ENERGYREGEN; + instance.vehicle_flags |= VHF_ENERGYREGEN; - self.vehicle_exit = raptor_exit; - self.respawntime = autocvar_g_vehicle_raptor_respawntime; - self.vehicle_health = autocvar_g_vehicle_raptor_health; - self.vehicle_shield = autocvar_g_vehicle_raptor_shield; - self.max_health = self.vehicle_health; + instance.vehicle_exit = raptor_exit; + instance.respawntime = autocvar_g_vehicle_raptor_respawntime; + instance.vehicle_health = autocvar_g_vehicle_raptor_health; + instance.vehicle_shield = autocvar_g_vehicle_raptor_shield; + instance.max_health = instance.vehicle_health; } #endif diff --git a/qcsrc/common/vehicles/vehicle/spiderbot.qc b/qcsrc/common/vehicles/vehicle/spiderbot.qc index eba9fee8a..57f1310c4 100644 --- a/qcsrc/common/vehicles/vehicle/spiderbot.qc +++ b/qcsrc/common/vehicles/vehicle/spiderbot.qc @@ -536,14 +536,14 @@ bool spiderbot_impulse(int _imp) spawnfunc(vehicle_spiderbot) { - if(!autocvar_g_vehicle_spiderbot) { remove(self); return; } - if(!vehicle_initialize(VEH_SPIDERBOT, false)) { remove(self); return; } + if(!autocvar_g_vehicle_spiderbot) { remove(this); return; } + if(!vehicle_initialize(this, VEH_SPIDERBOT, false)) { remove(this); return; } } METHOD(Spiderbot, vr_impact, void(Spiderbot thisveh, entity instance)) { if(autocvar_g_vehicle_spiderbot_bouncepain) - vehicles_impact(autocvar_g_vehicle_spiderbot_bouncepain_x, autocvar_g_vehicle_spiderbot_bouncepain_y, autocvar_g_vehicle_spiderbot_bouncepain_z); + vehicles_impact(instance, autocvar_g_vehicle_spiderbot_bouncepain_x, autocvar_g_vehicle_spiderbot_bouncepain_y, autocvar_g_vehicle_spiderbot_bouncepain_z); } METHOD(Spiderbot, vr_enter, void(Spiderbot thisveh, entity instance)) { @@ -618,21 +618,20 @@ METHOD(Spiderbot, vr_spawn, void(Spiderbot thisveh, entity instance)) } METHOD(Spiderbot, vr_setup, void(Spiderbot thisveh, entity instance)) { - SELFPARAM(); if(autocvar_g_vehicle_spiderbot_shield) - self.vehicle_flags |= VHF_HASSHIELD; + instance.vehicle_flags |= VHF_HASSHIELD; if(autocvar_g_vehicle_spiderbot_shield_regen) - self.vehicle_flags |= VHF_SHIELDREGEN; + instance.vehicle_flags |= VHF_SHIELDREGEN; if(autocvar_g_vehicle_spiderbot_health_regen) - self.vehicle_flags |= VHF_HEALTHREGEN; + instance.vehicle_flags |= VHF_HEALTHREGEN; - self.respawntime = autocvar_g_vehicle_spiderbot_respawntime; - self.vehicle_health = autocvar_g_vehicle_spiderbot_health; - self.vehicle_shield = autocvar_g_vehicle_spiderbot_shield; - self.max_health = self.vehicle_health; - self.pushable = true; // spiderbot can use jumppads + instance.respawntime = autocvar_g_vehicle_spiderbot_respawntime; + instance.vehicle_health = autocvar_g_vehicle_spiderbot_health; + instance.vehicle_shield = autocvar_g_vehicle_spiderbot_shield; + instance.max_health = instance.vehicle_health; + instance.pushable = true; // spiderbot can use jumppads } #endif // SVQC diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index afd006ad9..8039d8348 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -502,7 +502,10 @@ MUTATOR_HOOKABLE(HelpMePing, EV_HelpMePing); * called when a vehicle initializes * return true to remove the vehicle */ -MUTATOR_HOOKABLE(VehicleSpawn, EV_NO_ARGS); +#define EV_VehicleSpawn(i, o) \ + /**/ i(entity, __self) \ + /**/ +MUTATOR_HOOKABLE(VehicleSpawn, EV_VehicleSpawn); /** * called when a player enters a vehicle diff --git a/qcsrc/server/tests.qc b/qcsrc/server/tests.qc index be5d3773c..b0e21e746 100644 --- a/qcsrc/server/tests.qc +++ b/qcsrc/server/tests.qc @@ -48,7 +48,8 @@ TEST(Vehicles, Spawn) noref entity v = it = new(vehicle); Vehicle veh = VEH_BUMBLEBEE; it.active = ACTIVE_NOT; - WITH(entity, self, it, vehicle_initialize(veh, false); it.nextthink = time); + vehicle_initialize(it, veh, false); + it.nextthink = time; SUCCEED(); } -- 2.39.2