sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
Send_Effect(EFFECT_ROCKET_EXPLODE, this.origin, '0 0 0', 1);
+ if (this.tur_spawned)
+ tmp_turcount--;
+
tur.tr_death(tur, this);
delete(this.tur_head);
if(!this.active)
return;
+ if(this.realowner == attacker)
+ {
+ if(autocvar_g_friendlyfire)
+ damage = damage * autocvar_g_friendlyfire;
+ else
+ return;
+ }
+
if(SAME_TEAM(this, attacker))
{
if(autocvar_g_friendlyfire)
// Check if we have a vailid enemy, and try to find one if we dont.
+ // Don't attack against owner
+ if (turret_select_target(this) == this.realowner) return;
+
// g_turrets_targetscan_maxdelay forces a target re-scan at least this often
float do_target_scan = 0;
if((this.target_select_time + autocvar_g_turrets_targetscan_maxdelay) < time)
if(do_target_scan)
{
this.enemy = turret_select_target(this);
+ // Don't attack against owner
+ if (this.enemy == this.realowner) return;
this.target_select_time = time;
}
entity spawnturret (entity e, string turret, Turret tur, entity spawnedby, entity own, vector orig, bool respwn, bool invincible, bool removeifinvalid, int moveflag, bool optional)
{
+ if (autocvar_g_turrets_max <= 0 || autocvar_g_turrets_max_perplayer <= 0) { print_to(own, "Turret spawning is disabled"); return NULL; }
+
+ if (tmp_turcount >= autocvar_g_turrets_max) { print_to(own, "The maximum turret count has been reached"); return NULL; }
+
+ if (tmp_turcount >= autocvar_g_turrets_max_perplayer) { print_to(own, "You can't spawn any more turrets"); return NULL; }
+
e.spawnflags = TSF_SUSPENDED;
+ e.tur_spawned = true;
if(!respwn) { e.spawnflags |= TSL_NO_RESPAWN; }
if(invincible) { e.damage_flags |= TFL_DMG_NO; }
// spawn!
turret_initialize(e, tur);
+ tmp_turcount++;
+
//LOG_INFOF("^1tur.netname^3: %s", tur.netname);
if (optional)
bool autocvar_g_turrets;
float autocvar_g_turrets_aimidle_delay;
+int autocvar_g_turrets_max;
+int autocvar_g_turrets_max_perplayer;
bool autocvar_g_turrets_nofire;
bool autocvar_g_turrets_reloadcvars;
float autocvar_g_turrets_targetscan_maxdelay;
.float tur_dist_enemy; // distance to enemy
.float tur_dist_aimpos; // distance to aim location
.float tur_dist_impact_to_aimpos; // distance impact<->aim
+.bool tur_spawned; // spawned turret using spawnturret
.float volly_counter; // decrement counter from .shot_volly to 0
-
.float target_select_time; // last time turret had a valid target
.float target_validate_time; // throttle re-validation of current target
.entity pathgoal;
+int tmp_turcount;
float turret_count;
// debugging
if(IS_DEAD(veh))
{
- if (veh.cannot_respawn)
+ if (veh.cannot_respawn)
{
sound (veh, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
Send_Effect(EFFECT_EXPLOSION_BIG, veh.origin + '0 0 100', '0 0 0', 1);
+ tmp_vehcount--;
+
delete(veh);
return;
}
entity spawnvehicle (entity e, string vehicle, Vehicle veh, entity spawnedby, entity own, vector orig, bool no_respwn, bool removeifinvalid, bool optional, bool nodrop)
{
+ if (autocvar_g_vehicles_max <= 0 || autocvar_g_vehicles_max_perplayer <= 0) { print_to(own, "Vehicle spawning is disabled"); return NULL; }
+
+ if (tmp_vehcount >= autocvar_g_vehicles_max) { print_to(own, "The maximum vehicle count has been reached"); return NULL; }
+
+ if (tmp_vehcount >= autocvar_g_vehicles_max_perplayer) { print_to(own, "You can't spawn any more vehicles"); return NULL; }
+
e.spawnflags = VHF_MULTISLOT;
// if this spawnflag isn't, it won't be spawned
// spawn!
vehicle_initialize(e, veh, nodrop);
+ tmp_vehcount++;
+
return e;
}
float autocvar_g_vehicles_crush_minspeed = 100;
bool autocvar_g_vehicles_delayspawn = true;
float autocvar_g_vehicles_delayspawn_jitter = 10;
+int autocvar_g_vehicles_max;
+int autocvar_g_vehicles_max_perplayer;
float autocvar_g_vehicles_allow_bots;
int autocvar_g_vehicles_exit_attempts = 25;
float autocvar_g_vehicles_thinkrate = 0.1;
const int VHEF_EJECT = 1; /// User pressed exit key 3 times fast (not implemented) or vehicle is dying
const int VHEF_RELEASE = 2; /// Release ownership, client possibly allready dissconnected / went spec / changed team / used "kill" (not implemented)
+int tmp_vehcount;
float vehicles_exit_running;
// macros
set g_turrets 1
set g_turrets_reloadcvars 0
set g_turrets_nofire 0
+set g_turrets_max 10
+set g_turrets_max_perplayer 2
set g_turrets_targetscan_mindelay 0.1 "delay target rescanning to lower resource usage"
set g_turrets_targetscan_maxdelay 1 "scan at least this often"
set g_vehicles_steal_show_waypoint 1 "show a waypoint above the thief"
set g_vehicles_delayspawn 1
set g_vehicles_delayspawn_jitter 10
+set g_vehicles_max 10
+set g_vehicles_max_perplayer 2
set g_vehicles_teams 1 "allow team specific vehicles"
set g_vehicles_teleportable 0