X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=qcsrc%2Fcommon%2Fvehicles%2Fsv_vehicles.qc;h=60a8ee07760fbe897e58cd58fab2e22904337728;hb=d22f17ca9ca038d46ee4c676175d2142764ba2f4;hp=9ef5e4604c83170d35c6fec77b7e9b4eeacd3e9e;hpb=0e8248146ce84baa99d07d1436cfa88e05dfd948;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/vehicles/sv_vehicles.qc b/qcsrc/common/vehicles/sv_vehicles.qc index 9ef5e4604..60a8ee077 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qc +++ b/qcsrc/common/vehicles/sv_vehicles.qc @@ -3,20 +3,30 @@ bool SendAuxiliaryXhair(entity this, entity to, int sf) { WriteHeader(MSG_ENTITY, ENT_CLIENT_AUXILIARYXHAIR); + WriteByte(MSG_ENTITY, sf); WriteByte(MSG_ENTITY, this.cnt); - WriteCoord(MSG_ENTITY, this.origin_x); - WriteCoord(MSG_ENTITY, this.origin_y); - WriteCoord(MSG_ENTITY, this.origin_z); + if(sf & 2) + { + 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)); + if(sf & 4) + { + 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)) @@ -27,17 +37,26 @@ void UpdateAuxiliaryXhair(entity own, vector loc, vector clr, int axh_id) 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) @@ -179,28 +198,33 @@ void vehicles_projectile_damage(entity this, entity inflictor, entity attacker, } } -void vehicles_projectile_explode(entity this) +void vehicles_projectile_explode(entity this, entity toucher) { - if(this.owner && other != NULL) + if(this.owner && toucher != NULL) { - if(other == this.owner.vehicle) + if(toucher == this.owner.vehicle) return; - if(other == this.owner.vehicle.tur_head) + if(toucher == this.owner.vehicle.tur_head) return; } - PROJECTILE_TOUCH(this); + PROJECTILE_TOUCH(this, toucher); this.event_damage = func_null; - RadiusDamage (this, this.realowner, this.shot_dmg, 0, this.shot_radius, this, NULL, this.shot_force, this.totalfrags, other); + RadiusDamage (this, this.realowner, this.shot_dmg, 0, this.shot_radius, this, NULL, this.shot_force, this.totalfrags, toucher); - remove (this); + 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); + vehicles_projectile_explode(this, trigger); } entity vehicles_projectile(entity this, string _mzlfx, Sound _mzlsound, @@ -222,8 +246,10 @@ 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; @@ -241,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); @@ -261,14 +287,19 @@ 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); - remove(this); + delete(this); +} + +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) - remove(this); + delete(this); else this.nextthink = time + 0.1; } @@ -280,7 +311,7 @@ entity vehicle_tossgib(entity this, entity _template, vector _vel, string _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; @@ -293,7 +324,7 @@ entity vehicle_tossgib(entity this, entity _template, vector _vel, string _tag, { setthink(_gib, vehicles_gib_explode); _gib.nextthink = time + random() * _explode; - settouch(_gib, vehicles_gib_explode); + settouch(_gib, vehicles_gib_touch); } else { @@ -309,7 +340,7 @@ bool vehicle_addplayerslot( entity _owner, entity _slot, int _hud, Model _hud_model, - bool(entity) _framefunc, + bool(entity,float) _framefunc, void(entity,bool) _exitfunc, float(entity, entity) _enterfunc) { if(!(_owner.vehicle_flags & VHF_MULTISLOT)) @@ -403,17 +434,15 @@ void vehicles_reset_colors(entity this) void vehicles_clearreturn(entity veh) { // Remove "return helper" entities, if any. - FOREACH_ENTITY_ENT(wp00, veh, + IL_EACH(g_vehicle_returners, it.wp00 == veh, { - if(it.classname == "vehicle_return") - { - it.classname = ""; - setthink(it, SUB_Remove); - it.nextthink = time + 0.1; + 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); - } + if(it.waypointsprite_attached) + WaypointSprite_Kill(it.waypointsprite_attached); }); } @@ -428,7 +457,7 @@ void vehicles_return(entity this) if(this.waypointsprite_attached) WaypointSprite_Kill(this.waypointsprite_attached); - remove(this); + delete(this); } void vehicles_showwp_goaway(entity this) @@ -436,7 +465,7 @@ void vehicles_showwp_goaway(entity this) if(this.waypointsprite_attached) WaypointSprite_Kill(this.waypointsprite_attached); - remove(this); + delete(this); } void vehicles_showwp(entity this) @@ -483,6 +512,7 @@ void vehicles_setreturn(entity veh) vehicles_clearreturn(veh); entity ret = new(vehicle_return); + IL_PUSH(g_vehicle_returners, ret); ret.wp00 = veh; ret.team = veh.team; setthink(ret, vehicles_showwp); @@ -502,7 +532,7 @@ void vehicles_setreturn(entity veh) void vehicle_use(entity this, entity actor, entity trigger) { - LOG_DEBUG("vehicle ", this.netname, " used by ", actor.classname, "\n"); + LOG_DEBUG("vehicle ", this.netname, " used by ", actor.classname); this.tur_head.team = actor.team; @@ -513,7 +543,7 @@ void vehicle_use(entity this, entity actor, entity trigger) if(this.active == ACTIVE_ACTIVE && !IS_DEAD(this) && !gameover) { - LOG_DEBUG("Respawning vehicle: ", this.netname, "\n"); + LOG_DEBUG("Respawning vehicle: ", this.netname); if(this.effects & EF_NODRAW) { setthink(this, vehicles_spawn); @@ -591,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; @@ -740,7 +765,7 @@ void vehicles_exit(entity vehic, bool eject) if(vehicles_exit_running) { - LOG_TRACE("^1vehicles_exit already running! this is not good...\n"); + LOG_TRACE("^1vehicles_exit already running! this is not good..."); return; } @@ -772,7 +797,7 @@ void vehicles_exit(entity vehic, bool eject) player.takedamage = DAMAGE_AIM; player.solid = SOLID_SLIDEBOX; - player.movetype = MOVETYPE_WALK; + set_movetype(player, MOVETYPE_WALK); player.effects &= ~EF_NODRAW; player.teleportable = TELEPORT_NORMAL; player.alpha = 1; @@ -822,21 +847,21 @@ void vehicles_exit(entity vehic, bool eject) vehicles_exit_running = false; } -void vehicles_touch(entity this) +void vehicles_touch(entity this, entity toucher) { - if(MUTATOR_CALLHOOK(VehicleTouch, this, other)) + if(MUTATOR_CALLHOOK(VehicleTouch, this, toucher)) return; // Vehicle currently in use if(this.owner) { if(!forbidWeaponUse(this.owner)) - if(other != NULL) - if((this.origin_z + this.maxs_z) > (other.origin_z)) - if(vehicles_crushable(other)) + if(toucher != NULL) + if((this.origin_z + this.maxs_z) > (toucher.origin_z)) + if(vehicles_crushable(toucher)) { if(vdist(this.velocity, >=, 30)) - Damage(other, this, this.owner, autocvar_g_vehicles_crush_dmg, DEATH_VH_CRUSH.m_id, '0 0 0', normalize(other.origin - this.origin) * autocvar_g_vehicles_crush_force); + 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". } @@ -852,7 +877,7 @@ void vehicles_touch(entity this) if(autocvar_g_vehicles_enter) return; - vehicles_enter(other, this); + vehicles_enter(toucher, this); } bool vehicle_impulse(entity this, int imp) @@ -887,23 +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)) { - if(!veh.gunner1) - if(time >= veh.gun1.phase) - if(veh.gun1.vehicle_enter) - 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(veh, pl)) - return; + // 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)) @@ -945,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; @@ -1003,7 +1026,6 @@ void vehicles_enter(entity pl, entity veh) MUTATOR_CALLHOOK(VehicleEnter, pl, veh); CSQCModel_UnlinkEntity(veh); - Vehicle info = Vehicles_from(veh.vehicleid); info.vr_enter(info, veh); antilag_clear(pl, CS(pl)); @@ -1024,10 +1046,21 @@ void vehicles_think(entity this) CSQCMODEL_AUTOUPDATE(this); } +void vehicles_reset(entity this) +{ + if(this.owner) + vehicles_exit(this, VHEF_RELEASE); + + vehicles_clearreturn(this); + + if(this.active != ACTIVE_NOT) + vehicles_spawn(this); +} + // initialization void vehicles_spawn(entity this) { - LOG_DEBUG("Spawning vehicle: ", this.classname, "\n"); + LOG_DEBUG("Spawning vehicle: ", this.classname); // disown & reset this.vehicle_hudmodel.viewmodelforclient = this; @@ -1035,13 +1068,16 @@ void vehicles_spawn(entity 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; - this.movetype = MOVETYPE_WALK; + 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'; @@ -1082,14 +1118,17 @@ bool vehicle_initialize(entity this, Vehicle info, bool nodrop) return false; if(!this.tur_head) + { info.vr_precache(info); + IL_PUSH(g_vehicles, this); + } if(this.targetname && this.targetname != "") { this.vehicle_controller = find(NULL, target, this.targetname); if(!this.vehicle_controller) { - LOG_DEBUG("^1WARNING: ^7Vehicle with invalid .targetname\n"); + LOG_DEBUG("^1WARNING: ^7Vehicle with invalid .targetname"); this.active = ACTIVE_ACTIVE; } else @@ -1124,6 +1163,7 @@ bool vehicle_initialize(entity this, Vehicle info, bool nodrop) 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; @@ -1164,6 +1204,8 @@ bool vehicle_initialize(entity this, Vehicle info, bool nodrop) setsize(this, info.mins, info.maxs); + info.vr_setup(info, this); + if(!nodrop) { setorigin(this, this.origin); @@ -1175,8 +1217,6 @@ bool vehicle_initialize(entity this, Vehicle info, bool nodrop) this.pos2 = this.angles; this.tur_head.team = this.team; - info.vr_setup(info, this); - if(this.active == ACTIVE_NOT) this.nextthink = 0; // wait until activated else if(autocvar_g_vehicles_delayspawn)