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;
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;
_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, "");
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)
else
{
vehicles_setreturn(self);
- vehicles_reset_colors();
+ vehicles_reset_colors(self);
}
}
}
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");
_vehicle.vehicle_exit(eject);
vehicles_setreturn(_vehicle);
- vehicles_reset_colors();
+ vehicles_reset_colors(_vehicle);
_vehicle.owner = world;
CSQCMODEL_AUTOINIT(self);
}
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;
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)
CSQCModel_UnlinkEntity(veh);
Vehicle info = Vehicles_from(veh.vehicleid);
info.vr_enter(info, veh);
- setself(this);
+ setself(oldself);
antilag_clear(pl, CS(pl));
}
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);
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;
ENDCLASS(Bumblebee)
REGISTER_VEHICLE(BUMBLEBEE, NEW(Bumblebee));
+#ifndef MENUQC
+ MODEL(VEH_BUMBLEBEE_GUNCOCKPIT, "models/vehicles/wakizashi_cockpit.dpm");
+#endif
+
#endif
#ifdef IMPLEMENTATION
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)
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;
}
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))
{
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;
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
}
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