X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fvehicles%2Fsv_vehicles.qc;h=60a8ee07760fbe897e58cd58fab2e22904337728;hb=bd3c00d5a46a5ca6e35a51e64642d2962063cf74;hp=7e5bc93eb87abfdf7bff47b8404dd652cee62338;hpb=109c5785a22fb4336ac5e91d5f1fa91678582164;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/vehicles/sv_vehicles.qc b/qcsrc/common/vehicles/sv_vehicles.qc index 7e5bc93eb..60a8ee077 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qc +++ b/qcsrc/common/vehicles/sv_vehicles.qc @@ -1,83 +1,62 @@ #include "sv_vehicles.qh" -#if 0 -bool vehicle_send(entity to, int sf) +bool SendAuxiliaryXhair(entity this, entity to, int sf) { - WriteByte(MSG_ENTITY, ENT_CLIENT_VEHICLE); + WriteHeader(MSG_ENTITY, ENT_CLIENT_AUXILIARYXHAIR); WriteByte(MSG_ENTITY, sf); - if(sf & VSF_SPAWN) - { - WriteByte(MSG_ENTITY, self.vehicleid); - } - - if(sf & VSF_SETUP) - { - // send stuff? - } - - if(sf & VSF_ENTER) - { - // player handles the .vehicle stuff, we need only set ourselves up for driving - - // send stuff? - } + WriteByte(MSG_ENTITY, this.cnt); - if(sf & VSF_EXIT) + if(sf & 2) { - // senf stuff? + WriteCoord(MSG_ENTITY, this.origin_x); + WriteCoord(MSG_ENTITY, this.origin_y); + WriteCoord(MSG_ENTITY, this.origin_z); } - if(sf & VSF_PRECACHE) + if(sf & 4) { - // send stuff?! + WriteByte(MSG_ENTITY, rint(this.colormod_x * 255)); + WriteByte(MSG_ENTITY, rint(this.colormod_y * 255)); + WriteByte(MSG_ENTITY, rint(this.colormod_z * 255)); } return true; } -#endif - -bool SendAuxiliaryXhair(entity this, entity to, int sf) -{ - - WriteHeader(MSG_ENTITY, ENT_CLIENT_AUXILIARYXHAIR); - WriteByte(MSG_ENTITY, this.cnt); - - WriteCoord(MSG_ENTITY, this.origin_x); - WriteCoord(MSG_ENTITY, this.origin_y); - WriteCoord(MSG_ENTITY, this.origin_z); - - WriteByte(MSG_ENTITY, rint(this.colormod_x * 255)); - WriteByte(MSG_ENTITY, rint(this.colormod_y * 255)); - WriteByte(MSG_ENTITY, rint(this.colormod_z * 255)); - - return true; -} +.vector axh_prevorigin; +.vector axh_prevcolors; void UpdateAuxiliaryXhair(entity own, vector loc, vector clr, int axh_id) { if(!IS_REAL_CLIENT(own)) return; - entity axh; - axh_id = bound(0, axh_id, MAX_AXH); - axh = own.(AuxiliaryXhair[axh_id]); + entity axh = own.(AuxiliaryXhair[axh_id]); - if(axh == world || wasfreed(axh)) // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist?) + if(axh == NULL || wasfreed(axh)) // MADNESS? THIS IS QQQQCCCCCCCCC (wasfreed, why do you exsist? Mario: because of sloppy code like this) { - axh = spawn(); - axh.cnt = axh_id; - axh.drawonlytoclient = own; - axh.owner = own; + axh = new(auxiliary_xhair); + axh.cnt = axh_id; + axh.drawonlytoclient = own; + axh.owner = own; Net_LinkEntity(axh, false, 0, SendAuxiliaryXhair); } - setorigin(axh, loc); - axh.colormod = clr; - axh.SendFlags = 0x01; - own.(AuxiliaryXhair[axh_id]) = axh; + if(loc != axh.axh_prevorigin) + { + setorigin(axh, loc); + axh.SendFlags |= 2; + } + + if(clr != axh.axh_prevcolors) + { + axh.colormod = clr; + axh.SendFlags |= 4; + } + + own.(AuxiliaryXhair[axh_id]) = axh; // set it anyway...? } void CSQCVehicleSetup(entity own, int vehicle_id) @@ -95,7 +74,7 @@ void vehicles_locktarget(entity this, float incr, float decr, float _lock_time) { if(this.lock_target && IS_DEAD(this.lock_target)) { - this.lock_target = world; + this.lock_target = NULL; this.lock_strength = 0; this.lock_time = 0; } @@ -112,22 +91,22 @@ void vehicles_locktarget(entity this, float incr, float decr, float _lock_time) return; } - if(trace_ent != world) + if(trace_ent != NULL) { if(SAME_TEAM(trace_ent, this)) - trace_ent = world; + trace_ent = NULL; if(IS_DEAD(trace_ent)) - trace_ent = world; + trace_ent = NULL; if(!(IS_VEHICLE(trace_ent) || IS_TURRET(trace_ent))) - trace_ent = world; + trace_ent = NULL; if(trace_ent.alpha <= 0.5 && trace_ent.alpha != 0) - trace_ent = world; // invisible + trace_ent = NULL; // invisible } - if(this.lock_target == world && trace_ent != world) + if(this.lock_target == NULL && trace_ent != NULL) this.lock_target = trace_ent; if(this.lock_target && trace_ent == this.lock_target) @@ -146,7 +125,7 @@ void vehicles_locktarget(entity this, float incr, float decr, float _lock_time) // Have a locking target // Trace hit current target - if(trace_ent == this.lock_target && trace_ent != world) + if(trace_ent == this.lock_target && trace_ent != NULL) { this.lock_strength = min(this.lock_strength + incr, 1); if(this.lock_strength == 1) @@ -160,10 +139,16 @@ void vehicles_locktarget(entity this, float incr, float decr, float _lock_time) this.lock_strength = max(this.lock_strength - decr, 0); if(this.lock_strength == 0) - this.lock_target = world; + this.lock_target = NULL; } } +float vehicle_altitude(entity this, float amax) +{ + tracebox(this.origin, this.mins, this.maxs, this.origin - ('0 0 1' * amax), MOVE_WORLDONLY, this); + return vlen(this.origin - trace_endpos); +} + vector vehicles_force_fromtag_hover(entity this, string tag_name, float spring_length, float max_power) { force_fromtag_origin = gettaginfo(this, gettagindex(this, tag_name)); @@ -208,28 +193,38 @@ void vehicles_projectile_damage(entity this, entity inflictor, entity attacker, { this.takedamage = DAMAGE_NO; this.event_damage = func_null; - this.think = this.use; + setthink(this, adaptor_think2use); this.nextthink = time; } } -void vehicles_projectile_explode() -{SELFPARAM(); - if(self.owner && other != world) +void vehicles_projectile_explode(entity this, entity toucher) +{ + if(this.owner && toucher != NULL) { - if(other == self.owner.vehicle) + if(toucher == this.owner.vehicle) return; - if(other == self.owner.vehicle.tur_head) + if(toucher == this.owner.vehicle.tur_head) return; } - PROJECTILE_TOUCH; + PROJECTILE_TOUCH(this, toucher); - self.event_damage = func_null; - RadiusDamage (self, self.realowner, self.shot_dmg, 0, self.shot_radius, self, world, self.shot_force, self.totalfrags, other); + this.event_damage = func_null; + RadiusDamage (this, this.realowner, this.shot_dmg, 0, this.shot_radius, this, NULL, this.shot_force, this.totalfrags, toucher); - remove (self); + delete (this); +} + +void vehicles_projectile_explode_think(entity this) +{ + vehicles_projectile_explode(this, NULL); +} + +void vehicles_projectile_explode_use(entity this, entity actor, entity trigger) +{ + vehicles_projectile_explode(this, trigger); } entity vehicles_projectile(entity this, string _mzlfx, Sound _mzlsound, @@ -251,16 +246,18 @@ entity vehicles_projectile(entity this, string _mzlfx, Sound _mzlsound, proj.shot_force = _force; proj.totalfrags = _deahtype; proj.solid = SOLID_BBOX; - proj.movetype = MOVETYPE_FLYMISSILE; - proj.flags = FL_PROJECTILE; + set_movetype(proj, MOVETYPE_FLYMISSILE); + proj.flags = FL_PROJECTILE; + IL_PUSH(g_projectiles, proj); + IL_PUSH(g_bot_dodge, proj); proj.bot_dodge = true; proj.bot_dodgerating = _dmg; proj.velocity = _vel; - proj.touch = vehicles_projectile_explode; - proj.use = vehicles_projectile_explode; + settouch(proj, vehicles_projectile_explode); + proj.use = vehicles_projectile_explode_use; proj.owner = this; proj.realowner = _owner; - proj.think = SUB_Remove_self; + setthink(proj, SUB_Remove); proj.nextthink = time + 30; if(_health) @@ -270,7 +267,7 @@ entity vehicles_projectile(entity this, string _mzlfx, Sound _mzlsound, proj.health = _health; } else - proj.flags = FL_PROJECTILE | FL_NOTARGET; + proj.flags |= FL_NOTARGET; if(_mzlsound != SND_Null) sound (this, CH_WEAPON_A, _mzlsound, VOL_BASE, ATTEN_NORM); @@ -285,31 +282,36 @@ entity vehicles_projectile(entity this, string _mzlfx, Sound _mzlsound, return proj; } -void vehicles_gib_explode() -{SELFPARAM(); - sound (self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM); - Send_Effect(EFFECT_EXPLOSION_SMALL, randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1); - Send_Effect(EFFECT_EXPLOSION_SMALL, self.wp00.origin + '0 0 64', '0 0 0', 1); - remove(self); +void vehicles_gib_explode(entity this) +{ + sound (this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM); + Send_Effect(EFFECT_EXPLOSION_SMALL, randomvec() * 80 + (this.origin + '0 0 100'), '0 0 0', 1); + Send_Effect(EFFECT_EXPLOSION_SMALL, this.wp00.origin + '0 0 64', '0 0 0', 1); + delete(this); } -void vehicles_gib_think() -{SELFPARAM(); - self.alpha -= 0.1; - if(self.cnt >= time) - remove(self); +void vehicles_gib_touch(entity this, entity toucher) +{ + vehicles_gib_explode(this); +} + +void vehicles_gib_think(entity this) +{ + this.alpha -= 0.1; + if(this.cnt >= time) + delete(this); else - self.nextthink = time + 0.1; + this.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; + set_movetype(_gib, MOVETYPE_TOSS); _gib.solid = SOLID_CORPSE; _gib.colormod = '-0.5 -0.5 -0.5'; _gib.effects = EF_LOWPRECISION; @@ -320,14 +322,14 @@ entity vehicle_tossgib(entity _template, vector _vel, string _tag, bool _burn, b if(_explode) { - _gib.think = vehicles_gib_explode; + setthink(_gib, vehicles_gib_explode); _gib.nextthink = time + random() * _explode; - _gib.touch = vehicles_gib_explode; + settouch(_gib, vehicles_gib_touch); } else { _gib.cnt = time + _maxtime; - _gib.think = vehicles_gib_think; + setthink(_gib, vehicles_gib_think); _gib.nextthink = time + _maxtime - 1; _gib.alpha = 1; } @@ -337,9 +339,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, - bool(entity) _framefunc, - void(bool) _exitfunc, float() _enterfunc) + Model _hud_model, + bool(entity,float) _framefunc, + void(entity,bool) _exitfunc, float(entity, entity) _enterfunc) { if(!(_owner.vehicle_flags & VHF_MULTISLOT)) _owner.vehicle_flags |= VHF_MULTISLOT; @@ -354,7 +356,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,160 +383,139 @@ 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) { - // Remove "return helper", if any. - for (entity ret = findchain(classname, "vehicle_return"); ret; ret = ret.chain) + // Remove "return helper" entities, if any. + IL_EACH(g_vehicle_returners, it.wp00 == veh, { - if(ret.wp00 == veh) - { - ret.classname = ""; - ret.think = SUB_Remove_self; - ret.nextthink = time + 0.1; - - if(ret.waypointsprite_attached) - WaypointSprite_Kill(ret.waypointsprite_attached); - - return; - } - } + it.classname = ""; + setthink(it, SUB_Remove); + it.nextthink = time + 0.1; + IL_REMOVE(g_vehicle_returners, it); + + if(it.waypointsprite_attached) + WaypointSprite_Kill(it.waypointsprite_attached); + }); } -void vehicles_spawn(); -void vehicles_return() -{SELFPARAM(); - Send_Effect(EFFECT_TELEPORT, self.wp00.origin + '0 0 64', '0 0 0', 1); +void vehicles_spawn(entity this); +void vehicles_return(entity this) +{ + Send_Effect(EFFECT_TELEPORT, this.wp00.origin + '0 0 64', '0 0 0', 1); - self.wp00.think = vehicles_spawn; - self.wp00.nextthink = time; + setthink(this.wp00, vehicles_spawn); + this.wp00.nextthink = time; - if(self.waypointsprite_attached) - WaypointSprite_Kill(self.waypointsprite_attached); + if(this.waypointsprite_attached) + WaypointSprite_Kill(this.waypointsprite_attached); - remove(self); + delete(this); } -void vehicles_showwp_goaway() -{SELFPARAM(); - if(self.waypointsprite_attached) - WaypointSprite_Kill(self.waypointsprite_attached); - - remove(self); +void vehicles_showwp_goaway(entity this) +{ + if(this.waypointsprite_attached) + WaypointSprite_Kill(this.waypointsprite_attached); + delete(this); } -void vehicles_showwp() -{SELFPARAM(); - entity oldself = world; - vector rgb; +void vehicles_showwp(entity this) +{ + entity ent = this; - if(self.cnt) + if(ent.cnt) { - self.think = vehicles_return; - self.nextthink = self.cnt; + setthink(ent, vehicles_return); + ent.nextthink = ent.cnt; } else { - self.think = vehicles_return; - self.nextthink = time +1; - - oldself = self; - setself(spawn()); - setmodel(self, MDL_Null); - self.team = oldself.wp00.team; - self.wp00 = oldself.wp00; - setorigin(self, oldself.wp00.pos1); - - self.nextthink = time + 5; - self.think = vehicles_showwp_goaway; + setthink(ent, vehicles_return); + ent.nextthink = time + 1; + + ent = spawn(); + ent.team = this.wp00.team; + ent.wp00 = this.wp00; + setorigin(ent, this.wp00.pos1); + + ent.nextthink = time + 5; + setthink(ent, vehicles_showwp_goaway); } - if(teamplay && self.team) - rgb = Team_ColorRGB(self.team); + vector rgb; + if(teamplay && ent.team) + rgb = Team_ColorRGB(ent.team); else rgb = '1 1 1'; - entity wp = WaypointSprite_Spawn(WP_Vehicle, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_Vehicle); + entity wp = WaypointSprite_Spawn(WP_Vehicle, 0, 0, ent, '0 0 64', NULL, 0, ent, waypointsprite_attached, true, RADARICON_Vehicle); wp.colormod = rgb; - if(self.waypointsprite_attached) + if(ent.waypointsprite_attached) { - WaypointSprite_UpdateRule(self.waypointsprite_attached, self.wp00.team, SPRITERULE_DEFAULT); + WaypointSprite_UpdateRule(ent.waypointsprite_attached, ent.wp00.team, SPRITERULE_DEFAULT); if(this == NULL) - WaypointSprite_UpdateBuildFinished(self.waypointsprite_attached, self.nextthink); - WaypointSprite_Ping(self.waypointsprite_attached); + WaypointSprite_UpdateBuildFinished(ent.waypointsprite_attached, ent.nextthink); + WaypointSprite_Ping(ent.waypointsprite_attached); } - - if(this) - setself(this); } void vehicles_setreturn(entity veh) { - entity ret; - vehicles_clearreturn(veh); - ret = new(vehicle_return); + entity ret = new(vehicle_return); + IL_PUSH(g_vehicle_returners, ret); ret.wp00 = veh; ret.team = veh.team; - ret.think = vehicles_showwp; + setthink(ret, vehicles_showwp); if(IS_DEAD(veh)) { @@ -546,34 +527,32 @@ void vehicles_setreturn(entity veh) ret.nextthink = min(time + veh.respawntime, time + veh.respawntime - 1); } - setmodel(ret, MDL_Null); setorigin(ret, veh.pos1 + '0 0 96'); - } -void vehicle_use() -{SELFPARAM(); - LOG_TRACE("vehicle ",self.netname, " used by ", activator.classname, "\n"); +void vehicle_use(entity this, entity actor, entity trigger) +{ + LOG_DEBUG("vehicle ", this.netname, " used by ", actor.classname); - self.tur_head.team = activator.team; + this.tur_head.team = actor.team; - if(self.tur_head.team == 0) - self.active = ACTIVE_NOT; + if(this.tur_head.team == 0) + this.active = ACTIVE_NOT; else - self.active = ACTIVE_ACTIVE; + this.active = ACTIVE_ACTIVE; - if(self.active == ACTIVE_ACTIVE && !IS_DEAD(self) && !gameover) + if(this.active == ACTIVE_ACTIVE && !IS_DEAD(this) && !gameover) { - LOG_TRACE("Respawning vehicle: ", self.netname, "\n"); - if(self.effects & EF_NODRAW) + LOG_DEBUG("Respawning vehicle: ", this.netname); + if(this.effects & EF_NODRAW) { - self.think = vehicles_spawn; - self.nextthink = time + 3; + setthink(this, vehicles_spawn); + this.nextthink = time + 3; } else { - vehicles_setreturn(self); - vehicles_reset_colors(); + vehicles_setreturn(this); + vehicles_reset_colors(this); } } } @@ -593,18 +572,18 @@ void vehicles_regen(entity this, float timer, .float regen_field, float field_ma } } -void shieldhit_think() -{SELFPARAM(); - self.alpha -= 0.1; - if (self.alpha <= 0) +void shieldhit_think(entity this) +{ + this.alpha -= 0.1; + if (this.alpha <= 0) { - // setmodel(self, MDL_Null); - self.alpha = -1; - self.effects |= EF_NODRAW; + // setmodel(this, MDL_Null); + this.alpha = -1; + this.effects |= EF_NODRAW; } else { - self.nextthink = time + 0.1; + this.nextthink = time + 0.1; } } @@ -642,20 +621,15 @@ void vehicles_damage(entity this, entity inflictor, entity attacker, float damag // WEAPONTODO if(DEATH_ISWEAPON(deathtype, WEP_VORTEX)) damage *= autocvar_g_vehicles_vortex_damagerate; - - if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN)) + else if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN)) damage *= autocvar_g_vehicles_machinegun_damagerate; - - if(DEATH_ISWEAPON(deathtype, WEP_RIFLE)) + else if(DEATH_ISWEAPON(deathtype, WEP_RIFLE)) damage *= autocvar_g_vehicles_rifle_damagerate; - - if(DEATH_ISWEAPON(deathtype, WEP_VAPORIZER)) + else if(DEATH_ISWEAPON(deathtype, WEP_VAPORIZER)) damage *= autocvar_g_vehicles_vaporizer_damagerate; - - if(DEATH_ISWEAPON(deathtype, WEP_SEEKER)) + else if(DEATH_ISWEAPON(deathtype, WEP_SEEKER)) damage *= autocvar_g_vehicles_tag_damagerate; - - if(DEATH_WEAPONOF(deathtype) != WEP_Null) + else if(DEATH_WEAPONOF(deathtype) != WEP_Null) damage *= autocvar_g_vehicles_weapon_damagerate; this.enemy = attacker; @@ -664,7 +638,7 @@ void vehicles_damage(entity this, entity inflictor, entity attacker, float damag if((this.vehicle_flags & VHF_HASSHIELD) && (this.vehicle_shield > 0)) { - if (wasfreed(this.vehicle_shieldent) || this.vehicle_shieldent == world) + if (wasfreed(this.vehicle_shieldent) || this.vehicle_shieldent == NULL) { this.vehicle_shieldent = spawn(); this.vehicle_shieldent.effects = EF_LOWPRECISION; @@ -673,7 +647,7 @@ void vehicles_damage(entity this, entity inflictor, entity attacker, float damag setattachment(this.vehicle_shieldent, this, ""); setorigin(this.vehicle_shieldent, real_origin(this) - this.origin); this.vehicle_shieldent.scale = 256 / vlen(this.maxs - this.mins); - this.vehicle_shieldent.think = shieldhit_think; + setthink(this.vehicle_shieldent, shieldhit_think); } this.vehicle_shieldent.colormod = '1 1 1'; @@ -716,9 +690,9 @@ void vehicles_damage(entity this, entity inflictor, entity attacker, float damag { if(this.owner) if(this.vehicle_flags & VHF_DEATHEJECT) - WITH(entity, self, this, vehicles_exit(VHEF_EJECT)); + vehicles_exit(this, VHEF_EJECT); else - WITH(entity, self, this, vehicles_exit(VHEF_RELEASE)); + vehicles_exit(this, VHEF_RELEASE); antilag_clear(this, this); @@ -729,7 +703,7 @@ void vehicles_damage(entity this, entity inflictor, entity attacker, float damag } } -float vehicles_crushable(entity e) +bool vehicles_crushable(entity e) { if(IS_PLAYER(e) && time >= e.vehicle_enter_delay) return true; @@ -740,21 +714,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, NULL, NULL, 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"); @@ -763,175 +737,138 @@ void vehicles_impact(float _minspeed, float _speedfac, float _maxpain) } // vehicle enter/exit handling -vector vehicles_findgoodexit(vector prefer_spot) -{SELFPARAM(); - //vector exitspot; - float mysize; - - tracebox(self.origin + '0 0 32', STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), prefer_spot, MOVE_NORMAL, self.owner); +vector vehicles_findgoodexit(entity this, vector prefer_spot) +{ + tracebox(this.origin + '0 0 32', STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), prefer_spot, MOVE_NORMAL, this.owner); if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid) return prefer_spot; - mysize = 1.5 * vlen(self.maxs - self.mins); - float i; - vector v, v2; - v2 = 0.5 * (self.absmin + self.absmax); - for(i = 0; i < 100; ++i) + float mysize = 1.5 * vlen(this.maxs - this.mins); + vector v; + vector v2 = 0.5 * (this.absmin + this.absmax); + for(int i = 0; i < autocvar_g_vehicles_exit_attempts; ++i) { v = randomvec(); v_z = 0; v = v2 + normalize(v) * mysize; - tracebox(v2, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), v, MOVE_NORMAL, self.owner); + tracebox(v2, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), v, MOVE_NORMAL, this.owner); if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid) return v; } - /* - exitspot = (self.origin + '0 0 48') + v_forward * mysize; - tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner); - if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid) - return exitspot; - - exitspot = (self.origin + '0 0 48') - v_forward * mysize; - tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner); - if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid) - return exitspot; - - exitspot = (self.origin + '0 0 48') + v_right * mysize; - tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner); - if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid) - return exitspot; - - exitspot = (self.origin + '0 0 48') - v_right * mysize; - tracebox(self.origin + '0 0 32', PL_MIN, PL_MAX, exitspot, MOVE_NORMAL, self.owner); - if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid) - return exitspot; - */ - - return self.origin; + return this.origin; } -void vehicles_exit(bool eject) -{SELFPARAM(); - entity _vehicle; - entity _player; +void vehicles_exit(entity vehic, bool eject) +{ + entity player = vehic.owner; if(vehicles_exit_running) { - LOG_TRACE("^1vehicles_exit allready running! this is not good..\n"); + LOG_TRACE("^1vehicles_exit already running! this is not good..."); return; } vehicles_exit_running = true; - if(IS_CLIENT(self)) - { - _vehicle = self.vehicle; - if (_vehicle.vehicle_flags & VHF_PLAYERSLOT) - { - _vehicle.vehicle_exit(eject); - setself(this); - vehicles_exit_running = false; - return; - } + // TODO: this was in an IS_CLIENT check, make sure it isn't actually needed! + if(vehic.vehicle_flags & VHF_PLAYERSLOT) + { + vehic.vehicle_exit(vehic, eject); + vehicles_exit_running = false; + return; } - else - _vehicle = self; - - _player = _vehicle.owner; - setself(_vehicle); - - if (_player) + if (player) { - if (IS_REAL_CLIENT(_player)) + if (IS_REAL_CLIENT(player)) { - msg_entity = _player; + msg_entity = player; WriteByte (MSG_ONE, SVC_SETVIEWPORT); - WriteEntity( MSG_ONE, _player); + WriteEntity( MSG_ONE, player); WriteByte (MSG_ONE, SVC_SETVIEWANGLES); WriteAngle(MSG_ONE, 0); - WriteAngle(MSG_ONE, _vehicle.angles_y); + WriteAngle(MSG_ONE, vehic.angles_y); WriteAngle(MSG_ONE, 0); } - setsize(_player, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL)); - - _player.takedamage = DAMAGE_AIM; - _player.solid = SOLID_SLIDEBOX; - _player.movetype = MOVETYPE_WALK; - _player.effects &= ~EF_NODRAW; - _player.teleportable = TELEPORT_NORMAL; - _player.alpha = 1; - _player.PlayerPhysplug = func_null; - _player.vehicle = world; - _player.view_ofs = STAT(PL_VIEW_OFS, NULL); - _player.event_damage = PlayerDamage; - _player.hud = HUD_NORMAL; - PS(_player).m_switchweapon = _vehicle.m_switchweapon; - _player.last_vehiclecheck = time + 3; - _player.vehicle_enter_delay = time + 2; - - CSQCVehicleSetup(_player, HUD_NORMAL); + setsize(player, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL)); + + player.takedamage = DAMAGE_AIM; + player.solid = SOLID_SLIDEBOX; + set_movetype(player, MOVETYPE_WALK); + player.effects &= ~EF_NODRAW; + player.teleportable = TELEPORT_NORMAL; + player.alpha = 1; + player.PlayerPhysplug = func_null; + player.vehicle = NULL; + player.view_ofs = STAT(PL_VIEW_OFS, NULL); + player.event_damage = PlayerDamage; + player.hud = HUD_NORMAL; + PS(player).m_switchweapon = vehic.m_switchweapon; + player.last_vehiclecheck = time + 3; + player.vehicle_enter_delay = time + 2; + + CSQCVehicleSetup(player, HUD_NORMAL); + + Kill_Notification(NOTIF_ONE, player, MSG_CENTER, CPID_VEHICLES); + Kill_Notification(NOTIF_ONE, player, MSG_CENTER, CPID_VEHICLES_OTHER); // kill all vehicle notifications when exiting a vehicle? } - _vehicle.flags |= FL_NOTARGET; - if(!IS_DEAD(_vehicle)) - _vehicle.avelocity = '0 0 0'; + vehic.flags |= FL_NOTARGET; - _vehicle.tur_head.nodrawtoclient = world; + if(!IS_DEAD(vehic)) + vehic.avelocity = '0 0 0'; - if(!teamplay) - _vehicle.team = 0; + vehic.tur_head.nodrawtoclient = NULL; - Kill_Notification(NOTIF_ONE, _player, MSG_CENTER, CPID_VEHICLES); - Kill_Notification(NOTIF_ONE, _player, MSG_CENTER, CPID_VEHICLES_OTHER); // kill all vehicle notifications when exiting a vehicle? + if(!teamplay) + vehic.team = 0; - WaypointSprite_Kill(_vehicle.wps_intruder); + WaypointSprite_Kill(vehic.wps_intruder); - MUTATOR_CALLHOOK(VehicleExit, _player, _vehicle); + MUTATOR_CALLHOOK(VehicleExit, player, vehic); - _vehicle.team = _vehicle.tur_head.team; + vehic.team = vehic.tur_head.team; - sound (_vehicle, CH_TRIGGER_SINGLE, SND_Null, 1, ATTEN_NORM); - _vehicle.vehicle_hudmodel.viewmodelforclient = _vehicle; - _vehicle.phase = time + 1; + sound (vehic, CH_TRIGGER_SINGLE, SND_Null, 1, ATTEN_NORM); + vehic.vehicle_hudmodel.viewmodelforclient = vehic; + vehic.phase = time + 1; - _vehicle.vehicle_exit(eject); + vehic.vehicle_exit(vehic, eject); - vehicles_setreturn(_vehicle); - vehicles_reset_colors(); - _vehicle.owner = world; + vehicles_setreturn(vehic); + vehicles_reset_colors(vehic); + vehic.owner = NULL; - CSQCMODEL_AUTOINIT(self); + CSQCMODEL_AUTOINIT(vehic); - setself(this); vehicles_exit_running = false; } -void vehicles_touch() -{SELFPARAM(); - if(MUTATOR_CALLHOOK(VehicleTouch, self, other)) +void vehicles_touch(entity this, entity toucher) +{ + if(MUTATOR_CALLHOOK(VehicleTouch, this, toucher)) return; // Vehicle currently in use - if(self.owner) + if(this.owner) { - if(!forbidWeaponUse(self.owner)) - if(other != world) - if((self.origin_z + self.maxs_z) > (other.origin_z)) - if(vehicles_crushable(other)) + if(!forbidWeaponUse(this.owner)) + if(toucher != NULL) + if((this.origin_z + this.maxs_z) > (toucher.origin_z)) + if(vehicles_crushable(toucher)) { - if(vdist(self.velocity, >=, 30)) - Damage(other, self, self.owner, autocvar_g_vehicles_crush_dmg, DEATH_VH_CRUSH.m_id, '0 0 0', normalize(other.origin - self.origin) * autocvar_g_vehicles_crush_force); + if(vdist(this.velocity, >=, 30)) + Damage(toucher, this, this.owner, autocvar_g_vehicles_crush_dmg, DEATH_VH_CRUSH.m_id, '0 0 0', normalize(toucher.origin - this.origin) * autocvar_g_vehicles_crush_force); return; // Dont do selfdamage when hitting "soft targets". } - if(self.play_time < time) { - Vehicle info = Vehicles_from(self.vehicleid); - info.vr_impact(info, self); + if(this.play_time < time) { + Vehicle info = Vehicles_from(this.vehicleid); + info.vr_impact(info, this); } return; @@ -940,7 +877,7 @@ void vehicles_touch() if(autocvar_g_vehicles_enter) return; - vehicles_enter(other, self); + vehicles_enter(toucher, this); } bool vehicle_impulse(entity this, int imp) @@ -948,13 +885,13 @@ bool vehicle_impulse(entity this, int imp) entity v = this.vehicle; if (!v) return false; if (IS_DEAD(v)) return false; - bool(int) f = v.vehicles_impulse; - if (f && f(imp)) return true; + bool(entity,int) f = v.vehicles_impulse; + if (f && f(this,imp)) return true; switch (imp) { case IMP_weapon_drop.impulse: { - stuffcmd(self, "\ntoggle cl_eventchase_vehicle\nset _vehicles_shownchasemessage 1\n"); + stuffcmd(this, "\ntoggle cl_eventchase_vehicle\nset _vehicles_shownchasemessage 1\n"); return true; } } @@ -962,7 +899,7 @@ bool vehicle_impulse(entity this, int imp) } void vehicles_enter(entity pl, entity veh) -{SELFPARAM(); +{ // Remove this when bots know how to use vehicles if((IS_BOT_CLIENT(pl) && !autocvar_g_vehicles_allow_bots)) return; @@ -975,34 +912,20 @@ void vehicles_enter(entity pl, entity veh) || (pl.vehicle) ) { return; } + Vehicle info = Vehicles_from(veh.vehicleid); + if(autocvar_g_vehicles_enter) // vehicle's touch function should handle this if entering via use key is disabled (TODO) if(veh.vehicle_flags & VHF_MULTISLOT) - if(veh.owner) + if(veh.owner && SAME_TEAM(pl, veh)) { - 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); - return; - } - - if(!veh.gunner2) - if(time >= veh.gun2.phase) - if(veh.gun2.vehicle_enter) - if(veh.gun2.vehicle_enter()) - { - setself(this); - return; - } - - setself(this); + // we don't need a return value or anything here + // if successful the owner check below will prevent anything weird + info.vr_gunner_enter(info, veh, pl); } + if(veh.owner) + return; // got here and didn't enter the gunner, return + if(teamplay) if(veh.team) if(DIFF_TEAM(pl, veh)) @@ -1013,7 +936,7 @@ void vehicles_enter(entity pl, entity veh) Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_VEHICLE_STEAL_SELF); if (autocvar_g_vehicles_steal_show_waypoint) { - entity wp = WaypointSprite_Spawn(WP_VehicleIntruder, 0, 0, pl, '0 0 68', world, veh.team, veh, wps_intruder, true, RADARICON_DANGER); + entity wp = WaypointSprite_Spawn(WP_VehicleIntruder, 0, 0, pl, '0 0 68', NULL, veh.team, veh, wps_intruder, true, RADARICON_DANGER); wp.colormod = Team_ColorRGB(pl.team); } } @@ -1035,7 +958,6 @@ void vehicles_enter(entity pl, entity veh) veh.vehicle_hudmodel.viewmodelforclient = pl; - tracebox(pl.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), pl.origin, false, pl); pl.crouch = false; pl.view_ofs = STAT(PL_VIEW_OFS, NULL); setsize (pl, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL)); @@ -1045,7 +967,8 @@ void vehicles_enter(entity pl, entity veh) pl.angles = veh.angles; pl.takedamage = DAMAGE_NO; pl.solid = SOLID_NOT; - pl.movetype = MOVETYPE_NOCLIP; + pl.disableclientprediction = 1; // physics is no longer run, so this won't be reset + set_movetype(pl, MOVETYPE_NOCLIP); pl.teleportable = false; pl.alpha = -1; pl.event_damage = func_null; @@ -1102,194 +1025,206 @@ void vehicles_enter(entity pl, entity veh) MUTATOR_CALLHOOK(VehicleEnter, pl, veh); - setself(veh); CSQCModel_UnlinkEntity(veh); - Vehicle info = Vehicles_from(veh.vehicleid); info.vr_enter(info, veh); - setself(this); antilag_clear(pl, CS(pl)); } -void vehicles_think() -{SELFPARAM(); - self.nextthink = time; +void vehicles_think(entity this) +{ + this.nextthink = time + autocvar_g_vehicles_thinkrate; + + if(this.owner) + this.owner.vehicle_weapon2mode = this.vehicle_weapon2mode; + + Vehicle info = Vehicles_from(this.vehicleid); + info.vr_think(info, this); + + vehicles_painframe(this); - if(self.owner) - self.owner.vehicle_weapon2mode = self.vehicle_weapon2mode; + CSQCMODEL_AUTOUPDATE(this); +} - Vehicle info = Vehicles_from(self.vehicleid); - info.vr_think(info, self); +void vehicles_reset(entity this) +{ + if(this.owner) + vehicles_exit(this, VHEF_RELEASE); - vehicles_painframe(self); + vehicles_clearreturn(this); - CSQCMODEL_AUTOUPDATE(self); + if(this.active != ACTIVE_NOT) + vehicles_spawn(this); } // initialization -void vehicles_spawn() -{SELFPARAM(); - LOG_TRACE("Spawning vehicle: ", self.classname, "\n"); +void vehicles_spawn(entity this) +{ + LOG_DEBUG("Spawning vehicle: ", this.classname); // disown & reset - self.vehicle_hudmodel.viewmodelforclient = self; - - self.owner = world; - self.touch = vehicles_touch; - self.event_damage = vehicles_damage; - self.iscreature = true; - self.teleportable = false; // no teleporting for vehicles, too buggy - self.damagedbycontents = true; - self.movetype = MOVETYPE_WALK; - self.solid = SOLID_SLIDEBOX; - self.takedamage = DAMAGE_AIM; - self.deadflag = DEAD_NO; - self.bot_attack = true; - self.flags = FL_NOTARGET; - self.avelocity = '0 0 0'; - self.velocity = '0 0 0'; - self.think = vehicles_think; - self.nextthink = time; + this.vehicle_hudmodel.viewmodelforclient = this; + + this.owner = NULL; + settouch(this, vehicles_touch); + this.event_damage = vehicles_damage; + this.reset = vehicles_reset; + this.iscreature = true; + this.teleportable = false; // no teleporting for vehicles, too buggy + this.damagedbycontents = true; + set_movetype(this, MOVETYPE_WALK); + this.solid = SOLID_SLIDEBOX; + this.takedamage = DAMAGE_AIM; + this.deadflag = DEAD_NO; + if(!this.bot_attack) + IL_PUSH(g_bot_targets, this); + this.bot_attack = true; + this.flags = FL_NOTARGET; + this.avelocity = '0 0 0'; + this.velocity = '0 0 0'; + setthink(this, vehicles_think); + this.nextthink = time; // Reset locking - self.lock_strength = 0; - self.lock_target = world; - self.misc_bulletcounter = 0; + this.lock_strength = 0; + this.lock_target = NULL; + this.misc_bulletcounter = 0; // Return to spawn - self.angles = self.pos2; - setorigin(self, self.pos1); + this.angles = this.pos2; + setorigin(this, this.pos1); // Show it - Send_Effect(EFFECT_TELEPORT, self.origin + '0 0 64', '0 0 0', 1); + Send_Effect(EFFECT_TELEPORT, this.origin + '0 0 64', '0 0 0', 1); - if(self.vehicle_controller) - self.team = self.vehicle_controller.team; + if(this.vehicle_controller) + this.team = this.vehicle_controller.team; - FOREACH_CLIENT(IS_PLAYER(it) && it.hook.aiment == self, RemoveGrapplingHook(it)); + FOREACH_CLIENT(IS_PLAYER(it) && it.hook.aiment == this, RemoveGrapplingHook(it)); - vehicles_reset_colors(); + vehicles_reset_colors(this); - Vehicle info = Vehicles_from(self.vehicleid); - info.vr_spawn(info, self); + Vehicle info = Vehicles_from(this.vehicleid); + info.vr_spawn(info, this); - CSQCMODEL_AUTOINIT(self); + CSQCMODEL_AUTOINIT(this); } -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); + IL_PUSH(g_vehicles, this); } - 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(NULL, target, this.targetname); + if(!this.vehicle_controller) { - bprint("^1WARNING: ^7Vehicle with invalid .targetname\n"); - self.active = ACTIVE_ACTIVE; + LOG_DEBUG("^1WARNING: ^7Vehicle with invalid .targetname"); + 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; + IL_PUSH(g_bot_targets, this); + 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; + settouch(this, vehicles_touch); + setthink(this, 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); + + info.vr_setup(info, this); 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; - - Vehicle info = Vehicles_from(veh.vehicleid); - info.vr_setup(info, veh); + this.pos1 = this.origin; + this.pos2 = this.angles; + this.tur_head.team = this.team; - 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;