Merge branch 'master' into terencehill/bot_fixes 197/head
authorterencehill <piuntn@gmail.com>
Sun, 23 Aug 2015 15:33:36 +0000 (17:33 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 23 Aug 2015 15:33:36 +0000 (17:33 +0200)
301 files changed:
defaultXonotic.cfg
gamemodes.cfg
gfx/teamradar_icon_glow.tga [new file with mode: 0644]
qcsrc/client/autocvars.qh
qcsrc/client/command/cl_cmd.qc
qcsrc/client/controlpoint.qc [new file with mode: 0644]
qcsrc/client/controlpoint.qh [new file with mode: 0644]
qcsrc/client/damage.qc
qcsrc/client/generator.qc [new file with mode: 0644]
qcsrc/client/generator.qh [new file with mode: 0644]
qcsrc/client/hud.qc
qcsrc/client/hud.qh
qcsrc/client/hud_config.qc
qcsrc/client/hud_config.qh
qcsrc/client/main.qc
qcsrc/client/main.qh
qcsrc/client/mapvoting.qc
qcsrc/client/mapvoting.qh
qcsrc/client/mutators/events.qh
qcsrc/client/progs.src
qcsrc/client/scoreboard.qc
qcsrc/client/teamradar.qc
qcsrc/client/teamradar.qh
qcsrc/client/tturrets.qc [deleted file]
qcsrc/client/tturrets.qh [deleted file]
qcsrc/client/view.qc
qcsrc/client/waypointsprites.qc
qcsrc/client/waypointsprites.qh
qcsrc/common/buffs.qh
qcsrc/common/command/generic.qc
qcsrc/common/constants.qh
qcsrc/common/csqcmodel_settings.qh
qcsrc/common/deathtypes.qh
qcsrc/common/effects.qc
qcsrc/common/effects.qh
qcsrc/common/items/item.qh
qcsrc/common/items/item/pickup.qh
qcsrc/common/mapinfo.qh
qcsrc/common/monsters/sv_monsters.qc
qcsrc/common/movetypes/movetypes.qc
qcsrc/common/movetypes/push.qh
qcsrc/common/movetypes/toss.qh
qcsrc/common/mutators/all.inc [new file with mode: 0644]
qcsrc/common/mutators/all.qc [new file with mode: 0644]
qcsrc/common/mutators/events.qh
qcsrc/common/mutators/mutator/damagetext.qc [new file with mode: 0644]
qcsrc/common/nades.qc
qcsrc/common/notifications.qh
qcsrc/common/oo.qh
qcsrc/common/p2mathlib.qc
qcsrc/common/p2mathlib.qh
qcsrc/common/physics.qc
qcsrc/common/stats.qh
qcsrc/common/triggers/func/door.qc
qcsrc/common/triggers/func/pointparticles.qh
qcsrc/common/triggers/func/train.qc
qcsrc/common/triggers/teleporters.qc
qcsrc/common/triggers/trigger/viewloc.qh
qcsrc/common/triggers/triggers.qh
qcsrc/common/turrets/all.qh [new file with mode: 0644]
qcsrc/common/turrets/checkpoint.qc [new file with mode: 0644]
qcsrc/common/turrets/cl_turrets.qc [new file with mode: 0644]
qcsrc/common/turrets/cl_turrets.qh [new file with mode: 0644]
qcsrc/common/turrets/config.qc [new file with mode: 0644]
qcsrc/common/turrets/config.qh [new file with mode: 0644]
qcsrc/common/turrets/sv_turrets.qc [new file with mode: 0644]
qcsrc/common/turrets/sv_turrets.qh [new file with mode: 0644]
qcsrc/common/turrets/targettrigger.qc [new file with mode: 0644]
qcsrc/common/turrets/turrets.qc [new file with mode: 0644]
qcsrc/common/turrets/turrets.qh [new file with mode: 0644]
qcsrc/common/turrets/unit/ewheel.qc [new file with mode: 0644]
qcsrc/common/turrets/unit/flac.qc [new file with mode: 0644]
qcsrc/common/turrets/unit/fusionreactor.qc [new file with mode: 0644]
qcsrc/common/turrets/unit/hellion.qc [new file with mode: 0644]
qcsrc/common/turrets/unit/hk.qc [new file with mode: 0644]
qcsrc/common/turrets/unit/machinegun.qc [new file with mode: 0644]
qcsrc/common/turrets/unit/mlrs.qc [new file with mode: 0644]
qcsrc/common/turrets/unit/phaser.qc [new file with mode: 0644]
qcsrc/common/turrets/unit/plasma.qc [new file with mode: 0644]
qcsrc/common/turrets/unit/plasma_dual.qc [new file with mode: 0644]
qcsrc/common/turrets/unit/tesla.qc [new file with mode: 0644]
qcsrc/common/turrets/unit/walker.qc [new file with mode: 0644]
qcsrc/common/turrets/util.qc [new file with mode: 0644]
qcsrc/common/turrets/util.qh [new file with mode: 0644]
qcsrc/common/util-pre.qh
qcsrc/common/vehicles/all.inc [new file with mode: 0644]
qcsrc/common/vehicles/all.qc [new file with mode: 0644]
qcsrc/common/vehicles/all.qh
qcsrc/common/vehicles/cl_vehicles.qc
qcsrc/common/vehicles/sv_vehicles.qc
qcsrc/common/vehicles/sv_vehicles.qh
qcsrc/common/vehicles/unit/all.qh [deleted file]
qcsrc/common/vehicles/unit/bumblebee.qc
qcsrc/common/vehicles/unit/racer.qc
qcsrc/common/vehicles/unit/raptor.qc
qcsrc/common/vehicles/unit/spiderbot.qc
qcsrc/common/vehicles/vehicle.qh [new file with mode: 0644]
qcsrc/common/vehicles/vehicles.qc [deleted file]
qcsrc/common/vehicles/vehicles.qh [deleted file]
qcsrc/common/vehicles/vehicles_include.qc [deleted file]
qcsrc/common/vehicles/vehicles_include.qh [deleted file]
qcsrc/common/viewloc.qc
qcsrc/csqcmodellib/cl_player.qc
qcsrc/dpdefs/upstream/dpextensions.qc
qcsrc/dpdefs/upstream/menudefs.qc
qcsrc/menu/anim/animation.qc
qcsrc/menu/anim/animhost.qc
qcsrc/menu/anim/easing.qc
qcsrc/menu/anim/keyframe.qc
qcsrc/menu/item.qc
qcsrc/menu/item/borderimage.qc
qcsrc/menu/item/button.qc
qcsrc/menu/item/checkbox.qc
qcsrc/menu/item/container.qc
qcsrc/menu/item/dialog.qc
qcsrc/menu/item/image.qc
qcsrc/menu/item/inputbox.qc
qcsrc/menu/item/inputcontainer.qc
qcsrc/menu/item/label.qc
qcsrc/menu/item/listbox.qc
qcsrc/menu/item/modalcontroller.qc
qcsrc/menu/item/nexposee.qc
qcsrc/menu/item/radiobutton.qc
qcsrc/menu/item/slider.qc
qcsrc/menu/item/textslider.qc
qcsrc/menu/progs.src
qcsrc/menu/xonotic/bigbutton.qc
qcsrc/menu/xonotic/bigcommandbutton.qc
qcsrc/menu/xonotic/button.qc
qcsrc/menu/xonotic/campaign.qc
qcsrc/menu/xonotic/charmap.qc
qcsrc/menu/xonotic/checkbox.qc
qcsrc/menu/xonotic/checkbox_slider_invalid.qc
qcsrc/menu/xonotic/checkbox_string.qc
qcsrc/menu/xonotic/colorbutton.qc
qcsrc/menu/xonotic/colorpicker.qc
qcsrc/menu/xonotic/colorpicker_string.qc
qcsrc/menu/xonotic/commandbutton.qc
qcsrc/menu/xonotic/credits.qc
qcsrc/menu/xonotic/crosshairpicker.qc
qcsrc/menu/xonotic/crosshairpreview.qc
qcsrc/menu/xonotic/cvarlist.qc
qcsrc/menu/xonotic/demolist.qc
qcsrc/menu/xonotic/dialog.qc
qcsrc/menu/xonotic/dialog_credits.qc
qcsrc/menu/xonotic/dialog_firstrun.qc
qcsrc/menu/xonotic/dialog_hudpanel_ammo.qc
qcsrc/menu/xonotic/dialog_hudpanel_centerprint.qc
qcsrc/menu/xonotic/dialog_hudpanel_chat.qc
qcsrc/menu/xonotic/dialog_hudpanel_engineinfo.qc
qcsrc/menu/xonotic/dialog_hudpanel_healtharmor.qc
qcsrc/menu/xonotic/dialog_hudpanel_infomessages.qc
qcsrc/menu/xonotic/dialog_hudpanel_itemstime.qc
qcsrc/menu/xonotic/dialog_hudpanel_modicons.qc
qcsrc/menu/xonotic/dialog_hudpanel_notification.qc
qcsrc/menu/xonotic/dialog_hudpanel_physics.qc
qcsrc/menu/xonotic/dialog_hudpanel_powerups.qc
qcsrc/menu/xonotic/dialog_hudpanel_pressedkeys.qc
qcsrc/menu/xonotic/dialog_hudpanel_racetimer.qc
qcsrc/menu/xonotic/dialog_hudpanel_radar.qc
qcsrc/menu/xonotic/dialog_hudpanel_score.qc
qcsrc/menu/xonotic/dialog_hudpanel_timer.qc
qcsrc/menu/xonotic/dialog_hudpanel_vote.qc
qcsrc/menu/xonotic/dialog_hudpanel_weapons.qc
qcsrc/menu/xonotic/dialog_hudsetup_exit.qc
qcsrc/menu/xonotic/dialog_monstertools.qc
qcsrc/menu/xonotic/dialog_multiplayer.qc
qcsrc/menu/xonotic/dialog_multiplayer_create.qc
qcsrc/menu/xonotic/dialog_multiplayer_create_mapinfo.qc
qcsrc/menu/xonotic/dialog_multiplayer_create_mutators.qc
qcsrc/menu/xonotic/dialog_multiplayer_join.qc
qcsrc/menu/xonotic/dialog_multiplayer_join_serverinfo.qc
qcsrc/menu/xonotic/dialog_multiplayer_media.qc
qcsrc/menu/xonotic/dialog_multiplayer_media_demo.qc
qcsrc/menu/xonotic/dialog_multiplayer_media_demo_startconfirm.qc
qcsrc/menu/xonotic/dialog_multiplayer_media_demo_timeconfirm.qc
qcsrc/menu/xonotic/dialog_multiplayer_media_musicplayer.qc
qcsrc/menu/xonotic/dialog_multiplayer_media_screenshot.qc
qcsrc/menu/xonotic/dialog_multiplayer_media_screenshot_viewer.qc
qcsrc/menu/xonotic/dialog_multiplayer_profile.qc
qcsrc/menu/xonotic/dialog_quit.qc
qcsrc/menu/xonotic/dialog_sandboxtools.qc
qcsrc/menu/xonotic/dialog_settings.qc
qcsrc/menu/xonotic/dialog_settings_audio.qc
qcsrc/menu/xonotic/dialog_settings_effects.qc
qcsrc/menu/xonotic/dialog_settings_game.qc
qcsrc/menu/xonotic/dialog_settings_game_crosshair.qc
qcsrc/menu/xonotic/dialog_settings_game_hud.qc
qcsrc/menu/xonotic/dialog_settings_game_hudconfirm.qc
qcsrc/menu/xonotic/dialog_settings_game_messages.qc
qcsrc/menu/xonotic/dialog_settings_game_model.qc
qcsrc/menu/xonotic/dialog_settings_game_view.qc
qcsrc/menu/xonotic/dialog_settings_game_weapons.qc
qcsrc/menu/xonotic/dialog_settings_input.qc
qcsrc/menu/xonotic/dialog_settings_input_userbind.qc
qcsrc/menu/xonotic/dialog_settings_misc.qc
qcsrc/menu/xonotic/dialog_settings_misc_cvars.qc
qcsrc/menu/xonotic/dialog_settings_misc_reset.qc
qcsrc/menu/xonotic/dialog_settings_user.qc
qcsrc/menu/xonotic/dialog_settings_user_languagewarning.qc
qcsrc/menu/xonotic/dialog_settings_video.qc
qcsrc/menu/xonotic/dialog_singleplayer.qc
qcsrc/menu/xonotic/dialog_singleplayer_winner.qc
qcsrc/menu/xonotic/dialog_teamselect.qc
qcsrc/menu/xonotic/gametypebutton.qc
qcsrc/menu/xonotic/gametypelist.qc
qcsrc/menu/xonotic/image.qc
qcsrc/menu/xonotic/inputbox.qc
qcsrc/menu/xonotic/keybinder.qc
qcsrc/menu/xonotic/languagelist.qc
qcsrc/menu/xonotic/listbox.qc
qcsrc/menu/xonotic/mainwindow.qc
qcsrc/menu/xonotic/maplist.qc
qcsrc/menu/xonotic/nexposee.qc
qcsrc/menu/xonotic/picker.qc
qcsrc/menu/xonotic/playerlist.qc
qcsrc/menu/xonotic/playermodel.qc
qcsrc/menu/xonotic/playlist.qc
qcsrc/menu/xonotic/radiobutton.qc
qcsrc/menu/xonotic/rootdialog.qc
qcsrc/menu/xonotic/screenshotimage.qc
qcsrc/menu/xonotic/screenshotlist.qc
qcsrc/menu/xonotic/serverlist.qc
qcsrc/menu/xonotic/skinlist.qc
qcsrc/menu/xonotic/slider.qc
qcsrc/menu/xonotic/slider_decibels.qc
qcsrc/menu/xonotic/slider_particles.qc
qcsrc/menu/xonotic/slider_picmip.qc
qcsrc/menu/xonotic/slider_resolution.qc
qcsrc/menu/xonotic/slider_sbfadetime.qc
qcsrc/menu/xonotic/soundlist.qc
qcsrc/menu/xonotic/statslist.qc
qcsrc/menu/xonotic/tab.qc
qcsrc/menu/xonotic/tabcontroller.qc
qcsrc/menu/xonotic/textlabel.qc
qcsrc/menu/xonotic/textslider.qc
qcsrc/menu/xonotic/weaponarenacheckbox.qc
qcsrc/menu/xonotic/weaponslist.qc
qcsrc/server/antilag.qc
qcsrc/server/autocvars.qh
qcsrc/server/bot/havocbot/role_onslaught.qc [deleted file]
qcsrc/server/bot/havocbot/role_onslaught.qh [deleted file]
qcsrc/server/bot/havocbot/roles.qc
qcsrc/server/cl_client.qc
qcsrc/server/cl_player.qc
qcsrc/server/command/cmd.qc
qcsrc/server/controlpoint.qc [new file with mode: 0644]
qcsrc/server/controlpoint.qh [new file with mode: 0644]
qcsrc/server/g_damage.qc
qcsrc/server/g_damage.qh
qcsrc/server/g_hook.qc
qcsrc/server/g_world.qc
qcsrc/server/generator.qc [new file with mode: 0644]
qcsrc/server/generator.qh [new file with mode: 0644]
qcsrc/server/miscfunctions.qc
qcsrc/server/miscfunctions.qh
qcsrc/server/mutators/events.qh
qcsrc/server/mutators/gamemode_assault.qc
qcsrc/server/mutators/gamemode_ctf.qc
qcsrc/server/mutators/gamemode_onslaught.qc
qcsrc/server/mutators/gamemode_onslaught.qh [new file with mode: 0644]
qcsrc/server/mutators/mutators_include.qc
qcsrc/server/mutators/mutators_include.qh
qcsrc/server/progs.src
qcsrc/server/sv_main.qc
qcsrc/server/teamplay.qc
qcsrc/server/tturrets/include/turrets.qh [deleted file]
qcsrc/server/tturrets/include/turrets_early.qh [deleted file]
qcsrc/server/tturrets/system/system_aimprocs.qc [deleted file]
qcsrc/server/tturrets/system/system_damage.qc [deleted file]
qcsrc/server/tturrets/system/system_main.qc [deleted file]
qcsrc/server/tturrets/system/system_misc.qc [deleted file]
qcsrc/server/tturrets/system/system_scoreprocs.qc [deleted file]
qcsrc/server/tturrets/units/unit_checkpoint.qc [deleted file]
qcsrc/server/tturrets/units/unit_ewheel.qc [deleted file]
qcsrc/server/tturrets/units/unit_flac.qc [deleted file]
qcsrc/server/tturrets/units/unit_fusionreactor.qc [deleted file]
qcsrc/server/tturrets/units/unit_hellion.qc [deleted file]
qcsrc/server/tturrets/units/unit_hk.qc [deleted file]
qcsrc/server/tturrets/units/unit_machinegun.qc [deleted file]
qcsrc/server/tturrets/units/unit_mlrs.qc [deleted file]
qcsrc/server/tturrets/units/unit_phaser.qc [deleted file]
qcsrc/server/tturrets/units/unit_plasma.qc [deleted file]
qcsrc/server/tturrets/units/unit_targettrigger.qc [deleted file]
qcsrc/server/tturrets/units/unit_tessla.qc [deleted file]
qcsrc/server/tturrets/units/unit_walker.qc [deleted file]
qcsrc/server/waypointsprites.qc
qcsrc/whitespace.sh
turrets.cfg
unit_ewheel.cfg [deleted file]
unit_flac.cfg [deleted file]
unit_fusreac.cfg [deleted file]
unit_hellion.cfg [deleted file]
unit_hk.cfg [deleted file]
unit_machinegun.cfg [deleted file]
unit_mlrs.cfg [deleted file]
unit_phaser.cfg [deleted file]
unit_plasma.cfg [deleted file]
unit_plasma2.cfg [deleted file]
unit_tesla.cfg [deleted file]
unit_walker.cfg [deleted file]

index 45c9201..798da09 100644 (file)
@@ -234,10 +234,12 @@ seta cl_hitsound_nom_damage 25 "damage amount at which hitsound bases pitch off"
 seta cl_eventchase_death 1 "camera goes into 3rd person mode when the player is dead; set to 2 to active the effect only when the corpse doesn't move anymore"
 seta cl_eventchase_nexball 1 "camera goes into 3rd person mode when in nexball game-mode"
 seta cl_eventchase_distance 140 "final camera distance"
+seta cl_eventchase_generator_distance 400 "final camera distance while viewing generator explosion"
 seta cl_eventchase_speed 1.3 "how fast the camera slides back, 0 is instant"
 seta cl_eventchase_maxs "12 12 8" "max size of eventchase camera bbox"
 seta cl_eventchase_mins "-12 -12 -8" "min size of eventchase camera bbox"
 seta cl_eventchase_viewoffset "0 0 20" "viewoffset of eventchase camera"
+seta cl_eventchase_generator_viewoffset "0 0 80" "viewoffset of eventchase camera while viewing generator explosion"
 
 //nifreks lockonrestart feature, used in team-based game modes, if set to 1 and all players readied up no other player can then join the game anymore, useful to block spectators from joining
 set teamplay_lockonrestart 0 "it set to 1 in a team-based game, the teams are locked once all players readied up and the game restarted (no new players can join after restart unless using the server-command unlockteams)"
@@ -288,12 +290,6 @@ set cl_deathglow 0.8 "number of seconds during which dead bodies glow out"
 
 set sv_gibhealth 100 "Minus health a dead body must have in order to get gibbed"
 
-// fragmessage: This allows extra information to be displayed with the frag centerprints.
-set sv_fraginfo 1 "Enable extra frag message information, 0 = Never display, 1 = Display only in warmup mode; 2 = Always display"
-set sv_fraginfo_ping 1 "Enable ping display information, 0 = Never display, 1 = Always display (If the player is a bot, it will say bot instead of the ping.)"
-set sv_fraginfo_handicap 1 "Enable handicap display information, 0 = Never display, 1 = Only when the player has handicap on, 2 = Always display (Displays Off if disabled)"
-set sv_fraginfo_stats 1 "Enable statistics (health/armor) display information, 0 = Never display, 1 = Always display (Only available for the person who was killed)"
-
 // use default physics
 set sv_friction_on_land 0
 set sv_friction_slick 0.5
index 7f444e4..340d01b 100644 (file)
@@ -501,7 +501,17 @@ seta g_nexball_tackling 1 "Allow ball theft?"
 //  onslaught
 // ===========
 set g_onslaught 0 "Onslaught: take control points towards the enemy generator and then destroy it"
+set g_onslaught_point_limit 1 "Onslaught point limit overriding the mapinfo specified one (use 0 to play without limit, and -1 to use the mapinfo's limit)"
+set g_onslaught_warmup 5
+set g_onslaught_round_timelimit 280
+set g_onslaught_debug 0 "show debug prints in onslaught"
+set g_onslaught_teleport_radius 200 "Allows teleporting from a control point to another"
+set g_onslaught_teleport_wait 5 "Time before player can teleport again"
+set g_onslaught_spawn_choose 1 "Allow players to choose the control point to be spawned at"
+set g_onslaught_click_radius 500 "When choosing from the map, this level of precision is required"
+
 set g_onslaught_gen_health 2500
+set g_onslaught_allow_vehicle_touch 0
 set g_onslaught_cp_health 1000
 set g_onslaught_cp_buildhealth 100
 set g_onslaught_cp_buildtime 5
@@ -509,8 +519,13 @@ set g_onslaught_cp_regen 20
 set g_onslaught_cp_proxydecap 0 "de-capture controlpoints by standing close to them"
 set g_onslaught_cp_proxydecap_distance 512
 set g_onslaught_cp_proxydecap_dps 100
+set g_onslaught_shield_force 100
 set g_onslaught_spawn_at_controlpoints 0
+set g_onslaught_spawn_at_controlpoints_chance 0.5
+set g_onslaught_spawn_at_controlpoints_random 0
 set g_onslaught_spawn_at_generator 0
+set g_onslaught_spawn_at_generator_chance 0
+set g_onslaught_spawn_at_generator_random 0
 
 
 // ======
diff --git a/gfx/teamradar_icon_glow.tga b/gfx/teamradar_icon_glow.tga
new file mode 100644 (file)
index 0000000..4272d34
Binary files /dev/null and b/gfx/teamradar_icon_glow.tga differ
index 9c1a679..a9a442b 100644 (file)
@@ -447,6 +447,8 @@ float autocvar_cl_hitsound_nom_damage = 25;
 float autocvar_cl_hitsound_antispam_time;
 int autocvar_cl_eventchase_death = 1;
 int autocvar_cl_eventchase_nexball = 1;
+vector autocvar_cl_eventchase_generator_viewoffset = '0 0 80';
+float autocvar_cl_eventchase_generator_distance = 400;
 float autocvar_cl_eventchase_distance = 140;
 float autocvar_cl_eventchase_speed = 1.3;
 vector autocvar_cl_eventchase_maxs = '12 12 8';
index f3ac323..e80130c 100644 (file)
@@ -282,9 +282,15 @@ void LocalCommand_hud(int request, int argc)
                                case "radar":
                                {
                                        if(argv(2))
-                                               hud_panel_radar_maximized = InterpretBoolean(argv(2));
+                                               HUD_Radar_Show_Maximized(InterpretBoolean(argv(2)),0);
                                        else
-                                               hud_panel_radar_maximized = !hud_panel_radar_maximized;
+                                               HUD_Radar_Show_Maximized(!hud_panel_radar_maximized,0);
+                                       return;
+                               }
+
+                               case "clickradar":
+                               {
+                                       HUD_Radar_Show_Maximized(!hud_panel_radar_mouse,1);
                                        return;
                                }
                        }
diff --git a/qcsrc/client/controlpoint.qc b/qcsrc/client/controlpoint.qc
new file mode 100644 (file)
index 0000000..a579f93
--- /dev/null
@@ -0,0 +1,212 @@
+#include "controlpoint.qh"
+#include "gibs.qh"
+#include "teamradar.qh"
+
+bool cpicon_precached;
+.int count;
+.float pain_finished;
+
+.bool iscaptured;
+
+.vector cp_origin, cp_bob_origin;
+.float cp_bob_spd;
+
+.vector cp_bob_dmg;
+
+.vector punchangle;
+
+.float max_health;
+
+.entity icon_realmodel;
+
+void cpicon_precache()
+{
+       if(cpicon_precached)
+               return; // already precached
+
+       precache_model("models/onslaught/controlpoint_icon_dmg3.md3");
+       precache_model("models/onslaught/controlpoint_icon_dmg2.md3");
+       precache_model("models/onslaught/controlpoint_icon_dmg1.md3");
+       precache_model("models/onslaught/controlpoint_icon.md3");
+
+       cpicon_precached = true;
+}
+
+void cpicon_draw()
+{
+       if(time < self.move_time) { return; }
+
+       if(self.cp_bob_dmg_z > 0)
+               self.cp_bob_dmg_z = self.cp_bob_dmg_z - 3 * frametime;
+       else
+               self.cp_bob_dmg_z = 0;
+       self.cp_bob_origin_z = 4 * PI * (1 - cos(self.cp_bob_spd));
+       self.cp_bob_spd = self.cp_bob_spd + 1.875 * frametime;
+       self.colormod = '1 1 1' * (2 - bound(0, (self.pain_finished - time) / 10, 1));
+
+       if(!self.iscaptured) self.alpha = self.health / self.max_health;
+
+       if(self.iscaptured)
+       {
+               if (self.punchangle_x > 0)
+               {
+                       self.punchangle_x = self.punchangle_x - 60 * frametime;
+                       if (self.punchangle_x < 0)
+                               self.punchangle_x = 0;
+               }
+               else if (self.punchangle_x < 0)
+               {
+                       self.punchangle_x = self.punchangle_x + 60 * frametime;
+                       if (self.punchangle_x > 0)
+                               self.punchangle_x = 0;
+               }
+
+               if (self.punchangle_y > 0)
+               {
+                       self.punchangle_y = self.punchangle_y - 60 * frametime;
+                       if (self.punchangle_y < 0)
+                               self.punchangle_y = 0;
+               }
+               else if (self.punchangle_y < 0)
+               {
+                       self.punchangle_y = self.punchangle_y + 60 * frametime;
+                       if (self.punchangle_y > 0)
+                               self.punchangle_y = 0;
+               }
+
+               if (self.punchangle_z > 0)
+               {
+                       self.punchangle_z = self.punchangle_z - 60 * frametime;
+                       if (self.punchangle_z < 0)
+                               self.punchangle_z = 0;
+               }
+               else if (self.punchangle_z < 0)
+               {
+                       self.punchangle_z = self.punchangle_z + 60 * frametime;
+                       if (self.punchangle_z > 0)
+                               self.punchangle_z = 0;
+               }
+
+               self.angles_x = self.punchangle_x;
+               self.angles_y = self.punchangle_y + self.move_angles_y;
+               self.angles_z = self.punchangle_z;
+               self.move_angles_y = self.move_angles_y + 45 * frametime;
+       }
+
+       setorigin(self, self.cp_origin + self.cp_bob_origin + self.cp_bob_dmg);
+}
+
+void cpicon_damage(float hp)
+{
+       if(!self.iscaptured) { return; }
+
+       if(hp < self.max_health * 0.25)
+               setmodel(self, "models/onslaught/controlpoint_icon_dmg3.md3");
+       else if(hp < self.max_health * 0.50)
+               setmodel(self, "models/onslaught/controlpoint_icon_dmg2.md3");
+       else if(hp < self.max_health * 0.75)
+               setmodel(self, "models/onslaught/controlpoint_icon_dmg1.md3");
+       else if(hp <= self.max_health || hp >= self.max_health)
+               setmodel(self, "models/onslaught/controlpoint_icon.md3");
+
+       self.punchangle = (2 * randomvec() - '1 1 1') * 45;
+
+       self.cp_bob_dmg_z = (2 * random() - 1) * 15;
+       self.pain_finished = time + 1;
+       self.colormod = '2 2 2';
+
+       setsize(self, CPICON_MIN, CPICON_MAX);
+}
+
+void cpicon_construct()
+{
+       self.netname = "Control Point Icon";
+
+       setmodel(self, "models/onslaught/controlpoint_icon.md3");
+       setsize(self, CPICON_MIN, CPICON_MAX);
+
+       if(self.icon_realmodel == world)
+       {
+               self.icon_realmodel = spawn();
+               setmodel(self.icon_realmodel, "null");
+               setorigin(self.icon_realmodel, self.origin);
+               setsize(self.icon_realmodel, CPICON_MIN, CPICON_MAX);
+               self.icon_realmodel.movetype = MOVETYPE_NOCLIP;
+               self.icon_realmodel.solid = SOLID_NOT;
+               self.icon_realmodel.move_origin = self.icon_realmodel.origin;
+       }
+
+       if(self.iscaptured) { self.icon_realmodel.solid = SOLID_BBOX; }
+
+       self.move_movetype      = MOVETYPE_NOCLIP;
+       self.solid                      = SOLID_NOT;
+       self.movetype           = MOVETYPE_NOCLIP;
+       self.move_origin        = self.origin;
+       self.move_time          = time;
+       self.drawmask           = MASK_NORMAL;
+       self.alpha                      = 1;
+       self.draw                       = cpicon_draw;
+       self.cp_origin          = self.origin;
+       self.cp_bob_origin      = '0 0 0.1';
+       self.cp_bob_spd         = 0;
+}
+
+.vector glowmod;
+void cpicon_changeteam()
+{
+       if(self.team)
+       {
+               self.glowmod = Team_ColorRGB(self.team - 1);
+               self.teamradar_color = Team_ColorRGB(self.team - 1);
+               self.colormap = 1024 + (self.team - 1) * 17;
+       }
+       else
+       {
+               self.colormap = 1024;
+               self.glowmod = '1 1 0';
+               self.teamradar_color = '1 1 0';
+       }
+}
+
+void ent_cpicon()
+{
+       int sf = ReadByte();
+
+       if(sf & CPSF_SETUP)
+       {
+               self.origin_x = ReadCoord();
+               self.origin_y = ReadCoord();
+               self.origin_z = ReadCoord();
+               setorigin(self, self.origin);
+
+               self.health = ReadByte();
+               self.max_health = ReadByte();
+               self.count = ReadByte();
+               self.team = ReadByte();
+               self.iscaptured = ReadByte();
+
+               if(!self.count)
+                       self.count = (self.health - self.max_health) * frametime;
+
+               cpicon_changeteam();
+               cpicon_precache();
+               cpicon_construct();
+       }
+
+       if(sf & CPSF_STATUS)
+       {
+               int _tmp = ReadByte();
+               if(_tmp != self.team)
+               {
+                       self.team = _tmp;
+                       cpicon_changeteam();
+               }
+
+               _tmp = ReadByte();
+
+               if(_tmp != self.health)
+                       cpicon_damage(_tmp);
+
+               self.health = _tmp;
+       }
+}
diff --git a/qcsrc/client/controlpoint.qh b/qcsrc/client/controlpoint.qh
new file mode 100644 (file)
index 0000000..8469b52
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef CONTROLPOINT_H
+#define CONTROLPOINT_H
+
+const vector CPICON_MIN = '-32 -32 -9';
+const vector CPICON_MAX = '32 32 25';
+
+const int CPSF_STATUS = 4;
+const int CPSF_SETUP = 8;
+
+void ent_cpicon();
+void cpicon_precache();
+
+#endif
index fb80a52..9479f57 100644 (file)
@@ -4,7 +4,7 @@
 #include "gibs.qh"
 #include "prandom.qh"
 
-#include "../common/vehicles/cl_vehicles.qh"
+#include "../common/vehicles/all.qh"
 
 #include "../common/constants.qh"
 #include "../common/deathtypes.qh"
@@ -334,7 +334,7 @@ void Ent_DamageInfo(float isNew)
                                pointparticles(particleeffectnum("electro_impact"), self.origin, w_backoff * 1000, 1);
                                break;
 
-                        case DEATH_TURRET_WALK_MEELE:
+                        case DEATH_TURRET_WALK_MELEE:
                                sound(self, CH_SHOTS, "weapons/ric1.wav", VOL_BASE, ATTEN_MIN);
                                pointparticles(particleeffectnum("TE_SPARK"), self.origin, w_backoff * 1000, 1);
                                break;
diff --git a/qcsrc/client/generator.qc b/qcsrc/client/generator.qc
new file mode 100644 (file)
index 0000000..0c2ce46
--- /dev/null
@@ -0,0 +1,261 @@
+#include "generator.qh"
+
+bool generator_precached;
+.int count;
+.float max_health;
+
+vector randompos(vector m1, vector m2)
+{
+       vector v;
+       m2 = m2 - m1;
+       v_x = m2_x * random() + m1_x;
+       v_y = m2_y * random() + m1_y;
+       v_z = m2_z * random() + m1_z;
+       return  v;
+}
+
+void generator_precache()
+{
+       if(generator_precached)
+               return; // already precached
+
+       precache_model("models/onslaught/generator.md3");
+       precache_model("models/onslaught/generator_dead.md3");
+       precache_model("models/onslaught/generator_dmg1.md3");
+       precache_model("models/onslaught/generator_dmg2.md3");
+       precache_model("models/onslaught/generator_dmg3.md3");
+       precache_model("models/onslaught/generator_dmg4.md3");
+       precache_model("models/onslaught/generator_dmg5.md3");
+       precache_model("models/onslaught/generator_dmg6.md3");
+       precache_model("models/onslaught/generator_dmg7.md3");
+       precache_model("models/onslaught/generator_dmg8.md3");
+       precache_model("models/onslaught/generator_dmg9.md3");
+       precache_model("models/onslaught/generator_dead.md3");
+
+       precache_model("models/onslaught/ons_ray.md3");
+       precache_sound("onslaught/shockwave.wav");
+       precache_sound("weapons/grenade_impact.wav");
+       precache_sound("weapons/rocket_impact.wav");
+       precache_sound("onslaught/electricity_explode.wav");
+
+       generator_precached = true;
+}
+
+void ons_generator_ray_draw()
+{
+       if(time < self.move_time)
+               return;
+
+       self.move_time = time + 0.05;
+
+       if(self.count > 10)
+       {
+               remove(self);
+               return;
+       }
+
+       if(self.count > 5)
+               self.alpha -= 0.1;
+       else
+               self.alpha += 0.1;
+
+       self.scale += 0.2;
+       self.count +=1;
+}
+
+void ons_generator_ray_spawn(vector org)
+{
+       entity e;
+       e = spawn();
+       e.classname = "ons_ray";
+       setmodel(e, "models/onslaught/ons_ray.md3");
+       setorigin(e, org);
+       e.angles = randomvec() * 360;
+       e.move_origin = org;
+       e.movetype = MOVETYPE_NONE;
+       e.alpha = 0;
+       e.scale = random() * 5 + 8;
+       e.move_time = time + 0.05;
+       e.drawmask = MASK_NORMAL;
+       e.draw = ons_generator_ray_draw;
+}
+
+void generator_draw()
+{
+       if(time < self.move_time)
+               return;
+
+       if(self.health > 0)
+       {
+               // damaged fx (less probable the more damaged is the generator)
+               if(random() < 0.9 - self.health / self.max_health)
+               if(random() < 0.01)
+               {
+                       pointparticles(particleeffectnum("electro_ballexplode"), self.origin + randompos('-50 -50 -20', '50 50 50'), '0 0 0', 1);
+                       sound(self, CH_TRIGGER, "onslaught/electricity_explode.wav", VOL_BASE, ATTEN_NORM);
+               }
+               else
+                       pointparticles(particleeffectnum("torch_small"), self.origin + randompos('-60 -60 -20', '60 60 60'), '0 0 0', 1);
+
+               self.move_time = time + 0.1;
+
+               return;
+       }
+
+       if(self.count <= 0)
+               return;
+
+       vector org;
+       int i;
+
+       // White shockwave
+       if(self.count==40||self.count==20)
+       {
+               sound(self, CH_TRIGGER, "onslaught/shockwave.wav", VOL_BASE, ATTEN_NORM);
+               pointparticles(particleeffectnum("electro_combo"), self.origin, '0 0 0', 6);
+       }
+
+       // rays
+       if(random() > 0.25)
+       {
+               ons_generator_ray_spawn(self.origin);
+       }
+
+       // Spawn fire balls
+       for(i=0;i < 10;++i)
+       {
+               org = self.origin + randompos('-30 -30 -30' * i + '0 0 -20', '30 30 30' * i + '0 0 20');
+               pointparticles(particleeffectnum("onslaught_generator_gib_explode"), org, '0 0 0', 1);
+       }
+
+       // Short explosion sound + small explosion
+       if(random() < 0.25)
+       {
+               te_explosion(self.origin);
+               sound(self, CH_TRIGGER, "weapons/grenade_impact.wav", VOL_BASE, ATTEN_NORM);
+       }
+
+       // Particles
+       org = self.origin + randompos(self.mins + '8 8 8', self.maxs + '-8 -8 -8');
+       pointparticles(particleeffectnum("onslaught_generator_smallexplosion"), org, '0 0 0', 1);
+
+       // Final explosion
+       if(self.count==1)
+       {
+               org = self.origin;
+               te_explosion(org);
+               pointparticles(particleeffectnum("onslaught_generator_finalexplosion"), org, '0 0 0', 1);
+               sound(self, CH_TRIGGER, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
+       }
+
+       self.move_time = time + 0.05;
+
+       self.count -= 1;
+}
+
+void generator_damage(float hp)
+{
+       if(hp <= 0)
+               setmodel(self, "models/onslaught/generator_dead.md3");
+       else if(hp < self.max_health * 0.10)
+               setmodel(self, "models/onslaught/generator_dmg9.md3");
+       else if(hp < self.max_health * 0.20)
+               setmodel(self, "models/onslaught/generator_dmg8.md3");
+       else if(hp < self.max_health * 0.30)
+               setmodel(self, "models/onslaught/generator_dmg7.md3");
+       else if(hp < self.max_health * 0.40)
+               setmodel(self, "models/onslaught/generator_dmg6.md3");
+       else if(hp < self.max_health * 0.50)
+               setmodel(self, "models/onslaught/generator_dmg5.md3");
+       else if(hp < self.max_health * 0.60)
+               setmodel(self, "models/onslaught/generator_dmg4.md3");
+       else if(hp < self.max_health * 0.70)
+               setmodel(self, "models/onslaught/generator_dmg3.md3");
+       else if(hp < self.max_health * 0.80)
+               setmodel(self, "models/onslaught/generator_dmg2.md3");
+       else if(hp < self.max_health * 0.90)
+               setmodel(self, "models/onslaught/generator_dmg1.md3");
+       else if(hp <= self.max_health || hp >= self.max_health)
+               setmodel(self, "models/onslaught/generator.md3");
+
+       setsize(self, GENERATOR_MIN, GENERATOR_MAX);
+}
+
+void generator_construct()
+{
+       self.netname = "Generator";
+       self.classname = "onslaught_generator";
+
+       setorigin(self, self.origin);
+       setmodel(self, "models/onslaught/generator.md3");
+       setsize(self, GENERATOR_MIN, GENERATOR_MAX);
+
+       self.move_movetype      = MOVETYPE_NOCLIP;
+       self.solid                      = SOLID_BBOX;
+       self.movetype           = MOVETYPE_NOCLIP;
+       self.move_origin        = self.origin;
+       self.move_time          = time;
+       self.drawmask           = MASK_NORMAL;
+       self.alpha                      = 1;
+       self.draw                       = generator_draw;
+}
+
+.vector glowmod;
+void generator_changeteam()
+{
+       if(self.team)
+       {
+               self.glowmod = Team_ColorRGB(self.team - 1);
+               self.teamradar_color = Team_ColorRGB(self.team - 1);
+               self.colormap = 1024 + (self.team - 1) * 17;
+       }
+       else
+       {
+               self.colormap = 1024;
+               self.glowmod = '1 1 0';
+               self.teamradar_color = '1 1 0';
+       }
+}
+
+void ent_generator()
+{
+       int sf = ReadByte();
+
+       if(sf & GSF_SETUP)
+       {
+               self.origin_x = ReadCoord();
+               self.origin_y = ReadCoord();
+               self.origin_z = ReadCoord();
+               setorigin(self, self.origin);
+
+               self.health = ReadByte();
+               self.max_health = ReadByte();
+               self.count = ReadByte();
+               self.team = ReadByte();
+
+               if(!self.count)
+                       self.count = 40;
+
+               generator_changeteam();
+               generator_precache();
+               generator_construct();
+       }
+
+       if(sf & GSF_STATUS)
+       {
+               int _tmp;
+               _tmp = ReadByte();
+               if(_tmp != self.team)
+               {
+                       self.team = _tmp;
+                       generator_changeteam();
+               }
+
+               _tmp = ReadByte();
+
+               if(_tmp != self.health)
+                       generator_damage(_tmp);
+
+               self.health = _tmp;
+       }
+}
diff --git a/qcsrc/client/generator.qh b/qcsrc/client/generator.qh
new file mode 100644 (file)
index 0000000..e4e1611
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef GENERATOR_H
+#define GENERATOR_H
+const vector GENERATOR_MIN = '-52 -52 -14';
+const vector GENERATOR_MAX = '52 52 75';
+
+const int GSF_STATUS = 4;
+const int GSF_SETUP = 8;
+
+void ent_generator();
+void generator_precache();
+#endif
index 50eed4c..cfa00a1 100644 (file)
@@ -2,11 +2,14 @@
 #include "_all.qh"
 
 #include "hud_config.qh"
+#include "mapvoting.qh"
 #include "scoreboard.qh"
 #include "sortlist.qh"
 #include "teamradar.qh"
 #include "t_items.qh"
 
+#include "../dpdefs/keycodes.qh"
+
 #include "../common/buffs.qh"
 #include "../common/constants.qh"
 #include "../common/counting.qh"
@@ -2017,6 +2020,167 @@ void HUD_Timer(void)
 
 // Radar (#6)
 //
+
+float HUD_Radar_Clickable()
+{
+       return hud_panel_radar_mouse && !hud_panel_radar_temp_hidden;
+}
+
+void HUD_Radar_Show_Maximized(bool doshow,float clickable)
+{
+       hud_panel_radar_maximized = doshow;
+       hud_panel_radar_temp_hidden = 0;
+
+       if ( doshow )
+       {
+               if (clickable)
+               {
+                       if(autocvar_hud_cursormode)
+                               setcursormode(1);
+                       hud_panel_radar_mouse = 1;
+               }
+       }
+       else if ( hud_panel_radar_mouse )
+       {
+               hud_panel_radar_mouse = 0;
+               mouseClicked = 0;
+               if(autocvar_hud_cursormode)
+               if(!mv_active)
+                       setcursormode(0);
+       }
+}
+void HUD_Radar_Hide_Maximized()
+{
+       HUD_Radar_Show_Maximized(false,false);
+}
+
+
+float HUD_Radar_InputEvent(float bInputType, float nPrimary, float nSecondary)
+{
+       if(!hud_panel_radar_maximized || !hud_panel_radar_mouse ||
+               autocvar__hud_configure || mv_active)
+               return false;
+
+       if(bInputType == 3)
+       {
+               mousepos_x = nPrimary;
+               mousepos_y = nSecondary;
+               return true;
+       }
+
+       if(nPrimary == K_MOUSE1)
+       {
+               if(bInputType == 0) // key pressed
+                       mouseClicked |= S_MOUSE1;
+               else if(bInputType == 1) // key released
+                       mouseClicked -= (mouseClicked & S_MOUSE1);
+       }
+       else if(nPrimary == K_MOUSE2)
+       {
+               if(bInputType == 0) // key pressed
+                       mouseClicked |= S_MOUSE2;
+               else if(bInputType == 1) // key released
+                       mouseClicked -= (mouseClicked & S_MOUSE2);
+       }
+       else if ( nPrimary == K_ESCAPE && bInputType == 0 )
+       {
+               HUD_Radar_Hide_Maximized();
+       }
+       else
+       {
+               // allow console/use binds to work without hiding the map
+               string con_keys;
+               float keys;
+               float i;
+               con_keys = strcat(findkeysforcommand("toggleconsole", 0)," ",findkeysforcommand("+use", 0)) ;
+               keys = tokenize(con_keys); // findkeysforcommand returns data for this
+               for (i = 0; i < keys; ++i)
+               {
+                       if(nPrimary == stof(argv(i)))
+                               return false;
+               }
+
+               if ( getstati(STAT_HEALTH) <= 0 )
+               {
+                       // Show scoreboard
+                       if ( bInputType < 2 )
+                       {
+                               con_keys = findkeysforcommand("+showscores", 0);
+                               keys = tokenize(con_keys);
+                               for (i = 0; i < keys; ++i)
+                               {
+                                       if ( nPrimary == stof(argv(i)) )
+                                       {
+                                               hud_panel_radar_temp_hidden = bInputType == 0;
+                                               return false;
+                                       }
+                               }
+                       }
+               }
+               else if ( bInputType == 0 )
+                       HUD_Radar_Hide_Maximized();
+
+               return false;
+       }
+
+       return true;
+}
+
+void HUD_Radar_Mouse()
+{
+       if ( !hud_panel_radar_mouse ) return;
+       if(mv_active) return;
+
+       if ( intermission )
+       {
+               HUD_Radar_Hide_Maximized();
+               return;
+       }
+
+       if(mouseClicked & S_MOUSE2)
+       {
+               HUD_Radar_Hide_Maximized();
+               return;
+       }
+
+       if(!autocvar_hud_cursormode)
+       {
+               mousepos = mousepos + getmousepos() * autocvar_menu_mouse_speed;
+
+               mousepos_x = bound(0, mousepos_x, vid_conwidth);
+               mousepos_y = bound(0, mousepos_y, vid_conheight);
+       }
+
+       HUD_Panel_UpdateCvars();
+
+
+       panel_size = autocvar_hud_panel_radar_maximized_size;
+       panel_size_x = bound(0.2, panel_size_x, 1) * vid_conwidth;
+       panel_size_y = bound(0.2, panel_size_y, 1) * vid_conheight;
+       panel_pos_x = (vid_conwidth - panel_size_x) / 2;
+       panel_pos_y = (vid_conheight - panel_size_y) / 2;
+
+       if(mouseClicked & S_MOUSE1)
+       {
+               // click outside
+               if ( mousepos_x < panel_pos_x || mousepos_x > panel_pos_x + panel_size_x ||
+                        mousepos_y < panel_pos_y || mousepos_y > panel_pos_y + panel_size_y )
+               {
+                       HUD_Radar_Hide_Maximized();
+                       return;
+               }
+               vector pos = teamradar_texcoord_to_3dcoord(teamradar_2dcoord_to_texcoord(mousepos),view_origin_z);
+               localcmd(sprintf("cmd ons_spawn %f %f %f",pos_x,pos_y,pos_z));
+
+               HUD_Radar_Hide_Maximized();
+               return;
+       }
+
+
+       const vector cursor_size = '32 32 0';
+       drawpic(mousepos-'8 4 0', strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), cursor_size, '1 1 1', 0.8, DRAWFLAG_NORMAL);
+}
+
 void HUD_Radar(void)
 {
        if(intermission == 2) return;
@@ -2038,6 +2202,9 @@ void HUD_Radar(void)
                }
        }
 
+       if ( hud_panel_radar_temp_hidden )
+               return;
+
        HUD_Panel_UpdateCvars();
 
        float f = 0;
@@ -2191,8 +2358,27 @@ void HUD_Radar(void)
 
        for(tm = world; (tm = find(tm, classname, "radarlink")); )
                draw_teamradar_link(tm.origin, tm.velocity, tm.team);
+
+       vector coord;
+       vector brightcolor;
        for(tm = world; (tm = findflags(tm, teamradar_icon, 0xFFFFFF)); )
+       {
+               if ( hud_panel_radar_mouse )
+               if ( tm.health > 0 )
+               if ( tm.team == myteam+1 )
+               {
+                       coord = teamradar_texcoord_to_2dcoord(teamradar_3dcoord_to_texcoord(tm.origin));
+                       if ( vlen(mousepos-coord) < 8 )
+                       {
+                               brightcolor_x = min(1,tm.teamradar_color_x*1.5);
+                               brightcolor_y = min(1,tm.teamradar_color_y*1.5);
+                               brightcolor_z = min(1,tm.teamradar_color_z*1.5);
+                               drawpic(coord - '8 8 0', "gfx/teamradar_icon_glow", '16 16 0', brightcolor, panel_fg_alpha, 0);
+                       }
+               }
+
                draw_teamradar_icon(tm.origin, tm.teamradar_icon, tm, tm.teamradar_color, panel_fg_alpha);
+       }
        for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
        {
                color2 = GetPlayerColor(tm.sv_entnum);
@@ -2202,6 +2388,21 @@ void HUD_Radar(void)
        draw_teamradar_player(view_origin, view_angles, '1 1 1');
 
        drawresetcliparea();
+
+       if ( hud_panel_radar_mouse )
+       {
+               string message = "Click to select teleport destination";
+
+               if ( getstati(STAT_HEALTH) <= 0 )
+               {
+                       message = "Click to select spawn location";
+               }
+
+               drawcolorcodedstring(pos + '0.5 0 0' * (mySize_x - stringwidth(message, true, hud_fontsize)) - '0 1 0' * hud_fontsize_y * 2,
+                                                        message, hud_fontsize, hud_panel_radar_foreground_alpha, DRAWFLAG_NORMAL);
+
+               hud_panel_radar_bottom = pos_y + mySize_y + hud_fontsize_y;
+       }
 }
 
 // Score (#7)
@@ -4428,7 +4629,15 @@ void HUD_CenterPrint (void)
        }
        HUD_Panel_UpdateCvars();
 
-       if(scoreboard_fade_alpha)
+       if ( HUD_Radar_Clickable() )
+       {
+               if (hud_panel_radar_bottom >= 0.96 * vid_conheight)
+                       return;
+
+               panel_pos = eY * hud_panel_radar_bottom + eX * 0.5 * (vid_conwidth - panel_size_x);
+               panel_size_y = min(panel_size_y, vid_conheight - hud_panel_radar_bottom);
+       }
+       else if(scoreboard_fade_alpha)
        {
                hud_fade_alpha = hud_fade_alpha_save;
 
index 72e3326..8a2f76d 100644 (file)
@@ -12,6 +12,16 @@ int HUD_PANEL_LAST;
 int panel_order[HUD_PANEL_MAX];
 string hud_panelorder_prev;
 
+bool hud_draw_maximized;
+bool hud_panel_radar_maximized;
+bool hud_panel_radar_mouse;
+float hud_panel_radar_bottom;
+bool hud_panel_radar_temp_hidden;
+bool chat_panel_modified;
+bool radar_panel_modified;
+
+void HUD_Radar_Hide_Maximized();
+
 void HUD_Reset (void);
 void HUD_Main (void);
 
@@ -25,11 +35,6 @@ int vote_prev; // previous state of vote_active to check for a change
 float vote_alpha;
 float vote_change; // "time" when vote_active changed
 
-float hud_draw_maximized;
-float hud_panel_radar_maximized;
-float chat_panel_modified;
-float radar_panel_modified;
-
 vector mousepos;
 vector panel_click_distance; // mouse cursor distance from the top left corner of the panel (saved only upon a click)
 vector panel_click_resizeorigin; // coordinates for opposite point when resizing
index 485b82b..ca7fde9 100644 (file)
@@ -636,14 +636,6 @@ void HUD_Panel_Arrow_Action(float nPrimary)
        }
 }
 
-const int S_MOUSE1 = 1;
-const int S_MOUSE2 = 2;
-const int S_MOUSE3 = 4;
-int mouseClicked;
-int prevMouseClicked; // previous state
-float prevMouseClickedTime; // time during previous left mouse click, to check for doubleclicks
-vector prevMouseClickedPos; // pos during previous left mouse click, to check for doubleclicks
-
 void HUD_Panel_EnableMenu();
 entity tab_panels[HUD_PANEL_MAX];
 entity tab_panel;
index cc1d4d5..39dc659 100644 (file)
@@ -11,4 +11,12 @@ void HUD_Configure_PostDraw();
 
 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary);
 
+const int S_MOUSE1 = 1;
+const int S_MOUSE2 = 2;
+const int S_MOUSE3 = 4;
+int mouseClicked;
+int prevMouseClicked; // previous state
+float prevMouseClickedTime; // time during previous left mouse click, to check for doubleclicks
+vector prevMouseClickedPos; // pos during previous left mouse click, to check for doubleclicks
+
 #endif
index 231dd68..9e7b8bd 100644 (file)
@@ -2,9 +2,11 @@
 #include "_all.qh"
 
 #include "casings.qh"
+#include "controlpoint.qh"
 #include "csqcmodel_hooks.qh"
 #include "damage.qh"
 #include "effects.qh"
+#include "generator.qh"
 #include "gibs.qh"
 #include "hook.qh"
 #include "hud.qh"
 #include "scoreboard.qh"
 #include "shownames.qh"
 #include "sortlist.qh"
-#include "tturrets.qh"
 #include "tuba.qh"
 #include "t_items.qh"
 #include "wall.qh"
 #include "waypointsprites.qh"
 
-#include "../common/vehicles/unit/bumblebee.qh"
-#include "../common/vehicles/cl_vehicles.qh"
-#include "../common/vehicles/vehicles.qh"
+#include "../common/vehicles/all.qh"
+
+#include "mutators/events.qh"
 
 #include "weapons/projectile.qh"
 
@@ -51,6 +52,9 @@
 
 #include "../common/triggers/include.qh"
 
+#include "../common/turrets/cl_turrets.qh"
+#include "../common/turrets/turrets.qh"
+
 #include "../warpzonelib/client.qh"
 
 // --------------------------------------------------------------------------
@@ -145,11 +149,11 @@ void CSQC_Init(void)
 
        // needs to be done so early because of the constants they create
        static_init();
+       CALL_ACCUMULATED_FUNCTION(RegisterTurrets);
        CALL_ACCUMULATED_FUNCTION(RegisterNotifications);
        CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes);
        CALL_ACCUMULATED_FUNCTION(RegisterHUD_Panels);
        CALL_ACCUMULATED_FUNCTION(RegisterEffects);
-       CALL_ACCUMULATED_FUNCTION(RegisterVehicles);
 
        WaypointSprite_Load();
 
@@ -158,11 +162,11 @@ void CSQC_Init(void)
        precache_sound("misc/hit.wav");
        precache_sound("misc/typehit.wav");
 
+       generator_precache();
        Projectile_Precache();
        Hook_Precache();
        GibSplash_Precache();
        Casings_Precache();
-       turrets_precache();
        Tuba_Precache();
        CSQCPlayer_Precache();
 
@@ -368,6 +372,9 @@ float CSQC_InputEvent(float bInputType, float nPrimary, float nSecondary)
        if (HUD_Panel_InputEvent(bInputType, nPrimary, nSecondary))
                return true;
 
+       if ( HUD_Radar_InputEvent(bInputType, nPrimary, nSecondary) )
+               return true;
+
        if (MapVote_InputEvent(bInputType, nPrimary, nSecondary))
                return true;
 
@@ -783,7 +790,7 @@ void Ent_ReadSpawnEvent(float is_new)
                        button_zoom = false;
                }
        }
-
+       HUD_Radar_Hide_Maximized();
        //printf("Ent_ReadSpawnEvent(is_new = %d); origin = %s, entnum = %d, localentnum = %d\n", is_new, vtos(self.origin), entnum, player_localentnum);
 }
 
@@ -870,6 +877,8 @@ void CSQC_Ent_Update(float bIsNewEntity)
                case ENT_CLIENT_ACCURACY: Ent_ReadAccuracy(); break;
                case ENT_CLIENT_AUXILIARYXHAIR: Net_AuXair2(bIsNewEntity); break;
                case ENT_CLIENT_TURRET: ent_turret(); break;
+               case ENT_CLIENT_GENERATOR: ent_generator(); break;
+               case ENT_CLIENT_CONTROLPOINT_ICON: ent_cpicon(); break;
                case ENT_CLIENT_MODEL: CSQCModel_Read(bIsNewEntity); break;
                case ENT_CLIENT_ITEM: ItemRead(bIsNewEntity); break;
                case ENT_CLIENT_BUMBLE_RAYGUN: bumble_raygun_read(bIsNewEntity); break;
@@ -1257,69 +1266,55 @@ void Net_WeaponComplain()
 // Return value should be 1 if CSQC handled the temporary entity, otherwise return 0 to have the engine process the event.
 float CSQC_Parse_TempEntity()
 {
-       float bHandled;
-               bHandled  = true;
        // Acquire TE ID
-       float nTEID;
-               nTEID = ReadByte();
+       int nTEID = ReadByte();
 
-       if(autocvar_developer_csqcentities)
+       if (autocvar_developer_csqcentities)
                printf("CSQC_Parse_TempEntity() with nTEID=%d\n", nTEID);
 
-               // NOTE: Could just do return instead of break...
-       switch(nTEID)
+       switch (nTEID)
        {
+               case TE_CSQC_MUTATOR:
+                       int mutID = ReadMutator();
+                       if (MUTATOR_CALLHOOK(CSQC_Parse_TempEntity, mutID))
+                       return true;
                case TE_CSQC_TARGET_MUSIC:
                        Net_TargetMusic();
-                       bHandled = true;
-                       break;
+                       return true;
                case TE_CSQC_PICTURE:
                        Net_MapVote_Picture();
-                       bHandled = true;
-                       break;
+                       return true;
                case TE_CSQC_RACE:
                        Net_ReadRace();
-                       bHandled = true;
-                       break;
+                       return true;
                case TE_CSQC_VORTEXBEAMPARTICLE:
                        Net_ReadVortexBeamParticle();
-                       bHandled = true;
-                       break;
+                       return true;
                case TE_CSQC_TEAMNAGGER:
                        Net_TeamNagger();
-                       bHandled = true;
-                       break;
+                       return true;
                case TE_CSQC_ARC:
                        Net_ReadArc();
-                       bHandled = true;
-                       break;
+                       return true;
                case TE_CSQC_PINGPLREPORT:
                        Net_ReadPingPLReport();
-                       bHandled = true;
-                       break;
+                       return true;
                case TE_CSQC_WEAPONCOMPLAIN:
                        Net_WeaponComplain();
-                       bHandled = true;
-                       break;
+                       return true;
                case TE_CSQC_VEHICLESETUP:
                        Net_VehicleSetup();
-                       bHandled = true;
-                       break;
+                       return true;
                case TE_CSQC_SVNOTICE:
                        cl_notice_read();
-                       bHandled = true;
-                       break;
+                       return true;
                case TE_CSQC_SHOCKWAVEPARTICLE:
                        Net_ReadShockwaveParticle();
-                       bHandled = true;
-                       break;
+                       return true;
                default:
                        // No special logic for this temporary entity; return 0 so the engine can handle it
-                       bHandled = false;
-                       break;
+                       return false;
        }
-
-       return bHandled;
 }
 
 string getcommandkey(string text, string command)
index 0bc85a4..c8de3af 100644 (file)
@@ -153,4 +153,6 @@ entity entcs_receiver[255]; // 255 is the engine limit on maxclients
 float hud;
 float view_quality;
 int framecount;
+.float health;
+
 #endif
index 6610f80..037d906 100644 (file)
@@ -12,7 +12,6 @@
 
 int mv_num_maps;
 
-float mv_active;
 string mv_maps[MAPVOTE_COUNT];
 string mv_pics[MAPVOTE_COUNT];
 string mv_pk3[MAPVOTE_COUNT]; // map pk3 name or gametype human readable name
index 9c7086e..7a9a511 100644 (file)
@@ -11,4 +11,6 @@ float MapVote_InputEvent(float bInputType, float nPrimary, float nSecondary);
 void Ent_MapVote();
 
 void Net_MapVote_Picture();
+
+float mv_active;
 #endif
index 362e8d3..8f317c8 100644 (file)
@@ -35,4 +35,18 @@ string cmd_string;
     /**/
 MUTATOR_HOOKABLE(CSQC_ConsoleCommand, EV_CSQC_ConsoleCommand);
 
+/* Called when the crosshair is being updated */
+MUTATOR_HOOKABLE(UpdateCrosshair, EV_NO_ARGS);
+
+/**
+ * Called when a temp entity is parsed
+ * NOTE: hooks MUST start with `if (MUTATOR_RETURNVALUE) return false;`
+ * NOTE: hooks MUST start with `if (!ReadMutatorEquals(mutator_argv_int_0, name_of_mutator)) return false;`
+ * NOTE: return true if you handled the command, return false to continue handling
+ */
+#define EV_CSQC_Parse_TempEntity(i, o) \
+    /** entity id */ i(int, mutator_argv_int_0) \
+    /**/
+MUTATOR_HOOKABLE(CSQC_Parse_TempEntity, EV_CSQC_Parse_TempEntity);
+
 #endif
index ea61aed..9b68753 100644 (file)
@@ -7,9 +7,11 @@
 announcer.qc
 bgmscript.qc
 casings.qc
+controlpoint.qc
 csqcmodel_hooks.qc
 damage.qc
 effects.qc
+generator.qc
 gibs.qc
 hook.qc
 hud.qc
@@ -28,7 +30,6 @@ scoreboard.qc
 shownames.qc
 sortlist.qc
 teamradar.qc
-tturrets.qc
 tuba.qc
 t_items.qc
 view.qc
@@ -57,10 +58,13 @@ weapons/projectile.qc // TODO
 ../common/viewloc.qc
 
 ../common/items/all.qc
-
 ../common/monsters/all.qc
+../common/mutators/all.qc
+../common/vehicles/all.qc
+../common/weapons/all.qc
 
-../common/weapons/all.qc // TODO
+../common/turrets/cl_turrets.qc
+../common/turrets/turrets.qc
 
 ../common/triggers/include.qc
 
@@ -68,8 +72,6 @@ weapons/projectile.qc // TODO
 ../csqcmodellib/cl_player.qc
 ../csqcmodellib/interpolate.qc
 
-../common/vehicles/vehicles_include.qc
-
 ../server/mutators/mutator_multijump.qc
 
 ../warpzonelib/anglestransform.qc
index b6d2db2..126cc90 100644 (file)
@@ -302,7 +302,7 @@ void Cmd_HUD_Help()
 #define HUD_DefaultColumnLayout() \
 "ping pl name | " \
 "-teams,race,lms/kills +ft,tdm/kills -teams,lms/deaths +ft,tdm/deaths -teams,lms,race,ka/suicides +ft,tdm/suicides -race,dm,tdm,ka,ft/frags " /* tdm already has this in "score" */ \
-"+ctf/caps +ctf/pickups +ctf/fckills +ctf/returns " \
+"+ctf/caps +ctf/pickups +ctf/fckills +ctf/returns +ons/caps +ons/takes " \
 "+lms/lives +lms/rank " \
 "+kh/caps +kh/pushes +kh/destroyed " \
 "?+race/laps ?+race/time ?+race/fastest " \
@@ -960,6 +960,8 @@ vector HUD_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_siz
 float HUD_WouldDrawScoreboard() {
        if (autocvar__hud_configure)
                return 0;
+       else if (HUD_Radar_Clickable())
+               return 0;
        else if (scoreboard_showscores)
                return 1;
        else if (intermission == 1)
index aa7923b..874fec1 100644 (file)
@@ -46,6 +46,34 @@ vector teamradar_texcoord_to_2dcoord(vector in)
        return out;
 }
 
+
+vector teamradar_2dcoord_to_texcoord(vector in)
+{
+       vector out;
+       out = in;
+
+       out -= teamradar_origin2d;
+       if(v_flipped)
+               out_x = -out_x;
+       out = out / teamradar_size;
+
+       out_y = - out_y; // screen space is reversed
+       out = rotate(out, -teamradar_angle * DEG2RAD);
+
+       out += teamradar_origin3d_in_texcoord;
+
+       return out;
+}
+
+vector teamradar_texcoord_to_3dcoord(vector in,float z)
+{
+       vector out;
+       out_x = in_x * (mi_picmax_x - mi_picmin_x) + mi_picmin_x;
+       out_y = in_y * (mi_picmax_y - mi_picmin_y) + mi_picmin_y;
+       out_z = z;
+       return out;
+}
+
 vector yinvert(vector v)
 {
        v.y = 1 - v.y;
index f7c186a..b2329cf 100644 (file)
@@ -33,10 +33,14 @@ float vlen_maxnorm2d(vector v);
 
 float vlen_minnorm2d(vector v);
 
+vector teamradar_2dcoord_to_texcoord(vector in);
+
 vector teamradar_3dcoord_to_texcoord(vector in);
 
 vector teamradar_texcoord_to_2dcoord(vector in);
 
+vector teamradar_texcoord_to_3dcoord(vector in,float z);
+
 vector yinvert(vector v);
 
 void draw_teamradar_background(float fg);
diff --git a/qcsrc/client/tturrets.qc b/qcsrc/client/tturrets.qc
deleted file mode 100644 (file)
index d469fdc..0000000
+++ /dev/null
@@ -1,696 +0,0 @@
-#include "tturrets.qh"
-#include "_all.qh"
-
-#include "hud.qh"
-#include "movelib.qh"
-#include "prandom.qh"
-#include "teamradar.qh"
-#include "waypointsprites.qh"
-
-#include "../common/teams.qh"
-
-#include "../common/movetypes/movetypes.qh"
-
-#include "../server/tturrets/include/turrets_early.qh"
-
-#include "../warpzonelib/anglestransform.qh"
-#include "../warpzonelib/mathlib.qh"
-
-.vector colormod;
-.float cnt;
-.float alpha;
-.float gravity;
-
-string tid2info_base;
-string tid2info_head;
-string tid2info_name;
-vector  tid2info_min;
-vector  tid2info_max;
-
-void turret_tid2info(float _tid);
-void turret_precache(float _tid);
-float turret_is_precache[TID_LAST];
-
-void turrets_precache()
-{
-    turret_precache(TID_COMMON);
-}
-
-void turret_precache(int _tid)
-{
-    if (!turret_is_precache[TID_COMMON])
-    {
-        precache_sound ("weapons/rocket_impact.wav");
-        precache_model ("models/turrets/base-gib1.md3");
-        precache_model ("models/turrets/base-gib2.md3");
-        precache_model ("models/turrets/base-gib3.md3");
-        precache_model ("models/turrets/base-gib4.md3");
-        precache_model ("models/turrets/head-gib1.md3");
-        precache_model ("models/turrets/head-gib2.md3");
-        precache_model ("models/turrets/head-gib3.md3");
-        precache_model ("models/turrets/head-gib4.md3");
-        precache_model ("models/turrets/base.md3");
-        precache_model ("models/turrets/rocket.md3");
-    }
-    turret_tid2info(_tid);
-    if(turret_is_precache[_tid])
-        return;
-
-    switch(_tid)
-    {
-        case TID_EWHEEL:
-            precache_model ("models/turrets/ewheel-base2.md3");
-            precache_model ("models/turrets/ewheel-gun1.md3");
-            break;
-        case TID_FLAC:
-            precache_model ("models/turrets/flac.md3");
-            break;
-        case TID_FUSION:
-            precache_model ("models/turrets/reactor.md3");
-            break;
-        case TID_HELLION:
-            precache_model ("models/turrets/hellion.md3");
-            break;
-        case TID_HK:
-            precache_model ("models/turrets/hk.md3");
-            break;
-        case TID_MACHINEGUN:
-            precache_model ("models/turrets/machinegun.md3");
-            precache_sound ("weapons/uzi_fire.wav");
-            break;
-        case TID_MLRS:
-            precache_model ("models/turrets/mlrs.md3");
-            break;
-        case TID_PHASER:
-            precache_model ("models/turrets/phaser.md3");
-            precache_model ("models/turrets/phaser_beam.md3");
-            precache_sound ("turrets/phaser.wav");
-            break;
-        case TID_PLASMA:
-            precache_model ("models/turrets/plasma.md3");
-            break;
-        case TID_PLASMA_DUAL:
-            precache_model ("models/turrets/plasmad.md3");
-            break;
-        case TID_TESLA:
-            precache_model ("models/turrets/tesla_head.md3");
-            precache_model ("models/turrets/tesla_base.md3");
-            break;
-        case TID_WALKER:
-            precache_model ("models/turrets/walker_head_minigun.md3");
-            precache_model ("models/turrets/walker_body.md3");
-            precache_sound ("weapons/uzi_fire.wav");
-            break;
-    }
-    turret_is_precache[_tid] = true;
-}
-
-void turret_tid2info(float _tid)
-{
-    tid2info_base = "models/turrets/base.md3";
-    tid2info_min = '-32 -32 0';
-    tid2info_max = '32 32 64';
-
-    switch(_tid)
-    {
-        case TID_EWHEEL:
-            tid2info_base = "models/turrets/ewheel-base2.md3";
-            tid2info_head = "models/turrets/ewheel-gun1.md3";
-            tid2info_name = "eWheel";
-            break;
-        case TID_FLAC:
-            tid2info_head = "models/turrets/flac.md3";
-            tid2info_name = "Flac Cannon";
-            break;
-        case TID_FUSION:
-            tid2info_head = "models/turrets/reactor.md3";
-            tid2info_name = "Fusion Reactor";
-            tid2info_min = '-34 -34 0';
-            tid2info_max = '34 34 90';
-            break;
-        case TID_HELLION:
-            tid2info_head = "models/turrets/hellion.md3";
-            tid2info_name = "Hellion";
-            break;
-        case TID_HK:
-            tid2info_head = "models/turrets/hk.md3";
-            tid2info_name = "Hunter-Killer";
-            break;
-        case TID_MACHINEGUN:
-            tid2info_head = "models/turrets/machinegun.md3";
-            tid2info_name = "Machinegun";
-            break;
-        case TID_MLRS:
-            tid2info_head = "models/turrets/mlrs.md3";
-            tid2info_name = "MLRS";
-            break;
-        case TID_PHASER:
-            tid2info_head = "models/turrets/phaser.md3";
-            tid2info_name = "Phaser";
-            break;
-        case TID_PLASMA:
-            tid2info_head = "models/turrets/plasma.md3";
-            tid2info_name = "Plasma";
-            break;
-        case TID_PLASMA_DUAL:
-            tid2info_head = "models/turrets/plasmad.md3";
-            tid2info_name = "Dual Plasma";
-            break;
-        case TID_TESLA:
-            tid2info_base = "models/turrets/tesla_base.md3";
-            tid2info_head = "models/turrets/tesla_head.md3";
-            tid2info_name = "Tesla coil";
-            tid2info_min = '-60 -60 0';
-            tid2info_max  ='60 60 128';
-            break;
-        case TID_WALKER:
-            tid2info_base = "models/turrets/walker_body.md3";
-            tid2info_head = "models/turrets/walker_head_minigun.md3";
-            tid2info_name = "Walker";
-            tid2info_min = '-70 -70 0';
-            tid2info_max = '70 70 95';
-            break;
-    }
-}
-
-void turret_remove()
-{
-    remove(self.tur_head);
-    //remove(self.enemy);
-    self.tur_head = world;
-}
-
-class(Turret) .vector glowmod;
-void turret_changeteam()
-{
-       switch(self.team - 1)
-       {
-        case NUM_TEAM_1: // Red
-            self.glowmod = '2 0 0';
-            self.teamradar_color = '1 0 0';
-            break;
-
-        case NUM_TEAM_2: // Blue
-            self.glowmod = '0 0 2';
-            self.teamradar_color = '0 0 1';
-            break;
-
-        case NUM_TEAM_3: // Yellow
-            self.glowmod = '1 1 0';
-            self.teamradar_color = '1 1 0';
-            break;
-
-        case NUM_TEAM_4: // Pink
-            self.glowmod = '1 0 1';
-            self.teamradar_color = '1 0 1';
-            break;
-       }
-
-       if(self.team)
-        self.colormap = 1024 + (self.team - 1) * 17;
-
-       self.tur_head.colormap = self.colormap;
-       self.tur_head.glowmod = self.glowmod;
-
-}
-
-void turret_head_draw()
-{
-    self.drawmask = MASK_NORMAL;
-}
-
-void turret_draw()
-{
-    float dt;
-
-    dt = time - self.move_time;
-    self.move_time = time;
-    if(dt <= 0)
-        return;
-
-    self.tur_head.angles += dt * self.tur_head.move_avelocity;
-
-    if (self.health < 127)
-    {
-        dt = random();
-
-        if(dt < 0.03)
-            te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
-    }
-
-    if(self.health < 85)
-    if(dt < 0.01)
-        pointparticles(particleeffectnum("smoke_large"), (self.origin + (randomvec() * 80)), '0 0 0', 1);
-
-    if(self.health < 32)
-    if(dt < 0.015)
-        pointparticles(particleeffectnum("smoke_small"), (self.origin + (randomvec() * 80)), '0 0 0', 1);
-
-}
-
-void turret_draw2d()
-{
-       if(self.netname == "")
-           return;
-
-       if(!autocvar_g_waypointsprite_turrets)
-               return;
-
-    if(autocvar_cl_hidewaypoints)
-        return;
-
-       float dist = vlen(self.origin - view_origin);
-    float t = (GetPlayerColor(player_localnum) + 1);
-
-       vector o;
-       string txt;
-
-       if(autocvar_cl_vehicles_hud_tactical)
-       if(dist < 10240 && t != self.team)
-       {
-        // TODO: Vehicle tactical hud
-        o = project_3d_to_2d(self.origin + '0 0 32');
-        if(o.z < 0
-        || o.x < (vid_conwidth * waypointsprite_edgeoffset_left)
-        || o.y < (vid_conheight * waypointsprite_edgeoffset_top)
-        || o.x > (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right))
-        || o.y > (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)))
-            return; // Dont draw wp's for turrets out of view
-        o.z = 0;
-        if(hud != HUD_NORMAL)
-        {        
-                       if(self.turret_type == TID_EWHEEL || self.turret_type == TID_WALKER)
-                               txt = "gfx/vehicles/turret_moving.tga";
-                       else
-                               txt = "gfx/vehicles/turret_stationary.tga";
-
-                       vector pz = drawgetimagesize(txt) * autocvar_cl_vehicles_crosshair_size;
-                       drawpic(o - pz * 0.5, txt, pz , '1 1 1', 0.7, DRAWFLAG_NORMAL);
-        }
-       }
-
-       if(dist > self.maxdistance)
-        return;
-
-       string spriteimage = self.netname;
-       float a = self.alpha * autocvar_hud_panel_fg_alpha;
-       vector rgb = spritelookupcolor(spriteimage, self.teamradar_color);
-
-
-       if(self.maxdistance > waypointsprite_normdistance)
-               a *= pow(bound(0, (self.maxdistance - dist) / (self.maxdistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent);
-       else if(self.maxdistance > 0)
-               a *= pow(bound(0, (waypointsprite_fadedistance - dist) / (waypointsprite_fadedistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent) * (1 - waypointsprite_minalpha) + waypointsprite_minalpha;
-
-       if(rgb == '0 0 0')
-       {
-               self.teamradar_color = '1 0 1';
-               printf("WARNING: sprite of name %s has no color, using pink so you notice it\n", spriteimage);
-       }
-
-       txt = self.netname;
-       if(autocvar_g_waypointsprite_spam && waypointsprite_count >= autocvar_g_waypointsprite_spam)
-               txt = _("Spam");
-       else
-               txt = spritelookuptext(spriteimage);
-
-       if(time - floor(time) > 0.5 && t == self.team)
-       {
-               if(self.helpme && time < self.helpme)
-               {
-                   a *= SPRITE_HELPME_BLINK;
-                   txt = sprintf(_("%s under attack!"), txt);
-               }
-               else
-                       a *= spritelookupblinkvalue(spriteimage);
-       }
-
-       if(autocvar_g_waypointsprite_uppercase)
-               txt = strtoupper(txt);
-
-       if(a > 1)
-       {
-               rgb *= a;
-               a = 1;
-       }
-
-       if(a <= 0)
-           return;
-
-       rgb = fixrgbexcess(rgb);
-
-       o = project_3d_to_2d(self.origin + '0 0 64');
-       if(o.z < 0
-       || o.x < (vid_conwidth * waypointsprite_edgeoffset_left)
-       || o.y < (vid_conheight * waypointsprite_edgeoffset_top)
-       || o.x > (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right))
-       || o.y > (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)))
-           return; // Dont draw wp's for turrets out of view
-
-       o.z = 0;
-
-       float edgedistance_min, crosshairdistance;
-               edgedistance_min = min((o.y - (vid_conheight * waypointsprite_edgeoffset_top)),
-       (o.x - (vid_conwidth * waypointsprite_edgeoffset_left)),
-       (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right)) - o.x,
-       (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)) - o.y);
-
-       float vidscale = max(vid_conwidth / vid_width, vid_conheight / vid_height);
-
-       crosshairdistance = sqrt( pow(o.x - vid_conwidth/2, 2) + pow(o.y - vid_conheight/2, 2) );
-
-       t = waypointsprite_scale * vidscale;
-       a *= waypointsprite_alpha;
-
-       {
-               a = a * (1 - (1 - waypointsprite_distancefadealpha) * (bound(0, dist/waypointsprite_distancefadedistance, 1)));
-               t = t * (1 - (1 - waypointsprite_distancefadescale) * (bound(0, dist/waypointsprite_distancefadedistance, 1)));
-       }
-       if (edgedistance_min < waypointsprite_edgefadedistance) {
-               a = a * (1 - (1 - waypointsprite_edgefadealpha) * (1 - bound(0, edgedistance_min/waypointsprite_edgefadedistance, 1)));
-               t = t * (1 - (1 - waypointsprite_edgefadescale) * (1 - bound(0, edgedistance_min/waypointsprite_edgefadedistance, 1)));
-       }
-       if(crosshairdistance < waypointsprite_crosshairfadedistance) {
-               a = a * (1 - (1 - waypointsprite_crosshairfadealpha) * (1 - bound(0, crosshairdistance/waypointsprite_crosshairfadedistance, 1)));
-               t = t * (1 - (1 - waypointsprite_crosshairfadescale) * (1 - bound(0, crosshairdistance/waypointsprite_crosshairfadedistance, 1)));
-       }
-
-       o = drawspritearrow(o, M_PI, rgb, a, SPRITE_ARROW_SCALE * t);
-    o = drawspritetext(o, M_PI, (SPRITE_HEALTHBAR_WIDTH + 2 * SPRITE_HEALTHBAR_BORDER) * t, rgb, a, waypointsprite_fontsize * '1 1 0', txt);
-    drawhealthbar(
-            o,
-            0,
-            self.health / 255,
-            '0 0 0',
-            '0 0 0',
-            0.5 * SPRITE_HEALTHBAR_WIDTH * t,
-            0.5 * SPRITE_HEALTHBAR_HEIGHT * t,
-            SPRITE_HEALTHBAR_MARGIN * t + 0.5 * waypointsprite_fontsize,
-            SPRITE_HEALTHBAR_BORDER * t,
-            0,
-            rgb,
-            a * SPRITE_HEALTHBAR_BORDERALPHA,
-            rgb,
-            a * SPRITE_HEALTHBAR_HEALTHALPHA,
-            DRAWFLAG_NORMAL
-            );
-}
-
-void turret_walker_draw()
-{
-    float dt;
-
-    dt = time - self.move_time;
-    self.move_time = time;
-    if(dt <= 0)
-        return;
-
-    fixedmakevectors(self.angles);
-    movelib_groundalign4point(300, 100, 0.25, 45);
-    setorigin(self, self.origin + self.velocity * dt);
-    self.tur_head.angles += dt * self.tur_head.move_avelocity;
-    self.angles_y = self.move_angles.y;
-
-    if (self.health < 127)
-    if(random() < 0.15)
-        te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
-}
-
-void turret_ewheel_draw()
-{
-    float dt;
-
-    dt = time - self.move_time;
-    self.move_time = time;
-    if(dt <= 0)
-        return;
-
-    fixedmakevectors(self.angles);
-    setorigin(self, self.origin + self.velocity * dt);
-    self.tur_head.angles += dt * self.tur_head.move_avelocity;
-    self.angles_y = self.move_angles.y;
-
-    if (self.health < 127)
-    if(random() < 0.05)
-        te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
-}
-
-void turret_construct()
-{
-    if(self.tur_head == world)
-        self.tur_head = spawn();
-
-    turret_tid2info(self.turret_type);
-    self.netname = tid2info_name;
-
-    setorigin(self, self.origin);
-    setmodel(self, tid2info_base);
-    setmodel(self.tur_head, tid2info_head);
-    setsize(self, tid2info_min, tid2info_max);
-    setsize(self.tur_head, '0 0 0', '0 0 0');
-
-    if(self.turret_type == TID_EWHEEL)
-        setattachment(self.tur_head, self, "");
-    else
-        setattachment(self.tur_head, self, "tag_head");
-
-    self.tur_head.classname     = "turret_head";
-    self.tur_head.owner         = self;
-    self.tur_head.move_movetype = MOVETYPE_NOCLIP;
-    self.move_movetype          = MOVETYPE_NOCLIP;
-    self.tur_head.angles        = self.angles;
-    self.health                 = 255;
-    self.solid                  = SOLID_BBOX;
-    self.tur_head.solid         = SOLID_NOT;
-    self.movetype               = MOVETYPE_NOCLIP;
-    self.tur_head.movetype      = MOVETYPE_NOCLIP;
-    self.draw                   = turret_draw;
-    self.entremove              = turret_remove;
-    self.drawmask               = MASK_NORMAL;
-    self.tur_head.drawmask      = MASK_NORMAL;
-    self.anim_start_time        = 0;
-    self.draw2d = turret_draw2d;
-    self.maxdistance = autocvar_g_waypointsprite_turrets_maxdist;
-    self.teamradar_color = '1 0 0';
-    self.alpha = 1;
-
-    if(self.turret_type == TID_EWHEEL || self.turret_type == TID_WALKER)
-    {
-        self.gravity            = 1;
-        self.movetype           = MOVETYPE_BOUNCE;
-        self.move_movetype      = MOVETYPE_BOUNCE;
-        self.move_origin        = self.origin;
-        self.move_time          = time;
-        switch(self.turret_type)
-        {
-            case TID_EWHEEL:
-                self.draw               = turret_ewheel_draw;
-                break;
-            case TID_WALKER:
-                self.draw               = turret_walker_draw;
-                break;
-
-        }
-    }
-}
-
-entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, float _explode);
-void turret_gibboom();
-void turret_gib_draw()
-{
-    Movetype_Physics_MatchTicrate(autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
-
-    self.drawmask = MASK_NORMAL;
-
-       if(self.cnt)
-       {
-           if(time >= self.nextthink)
-           {
-            turret_gibboom();
-            remove(self);
-           }
-       }
-       else
-       {
-        self.alpha = bound(0, self.nextthink - time, 1);
-        if(self.alpha < ALPHA_MIN_VISIBLE)
-            remove(self);
-       }
-}
-
-void turret_gibboom()
-{
-    float i;
-
-    sound (self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
-    pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
-
-    for (i = 1; i < 5; i = i + 1)
-        turret_gibtoss(strcat("models/turrets/head-gib", ftos(i), ".md3"), self.origin + '0 0 2', self.velocity + randomvec() * 700, '0 0 0', false);
-}
-
-entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, float _explode)
-{
-    entity gib;
-
-    traceline(_from, _to, MOVE_NOMONSTERS, world);
-    if(trace_startsolid)
-        return world;
-
-    gib = spawn();
-    setorigin(gib, _from);
-    setmodel(gib, _model);
-    gib.colormod    = _cmod;
-       gib.solid       = SOLID_CORPSE;
-    gib.draw        = turret_gib_draw;
-    gib.cnt         = _explode;
-    setsize(gib, '-1 -1 -1', '1 1 1');
-    if(_explode)
-    {
-        gib.nextthink = time + 0.2 * (autocvar_cl_gibs_lifetime * (1 + prandom() * 0.15));
-        gib.effects = EF_FLAME;
-    }
-    else
-        gib.nextthink = time + autocvar_cl_gibs_lifetime * (1 + prandom() * 0.15);
-
-    gib.gravity         = 1;
-       gib.move_movetype   = MOVETYPE_BOUNCE;
-       gib.move_origin     = _from;
-       setorigin(gib,        _from);
-       gib.move_velocity   = _to;
-       gib.move_avelocity  = prandomvec() * 32;
-       gib.move_time       = time;
-       gib.damageforcescale = 1;
-       gib.classname = "turret_gib";
-
-       return gib;
-}
-
-void turret_die()
-{
-
-    sound (self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
-    pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
-    turret_tid2info(self.turret_type);
-    if (!autocvar_cl_nogibs)
-    {
-        // Base
-        if(self.turret_type == TID_EWHEEL)
-            turret_gibtoss(tid2info_base, self.origin + '0 0 18', self.velocity + '0 0 400' + '0.1 0.1 1' * (random() * 400), '-1 -1 -1', true);
-        else if (self.turret_type == TID_WALKER)
-            turret_gibtoss(tid2info_base, self.origin + '0 0 18', self.velocity + '0 0 300' + '0.1 0.1 1' * (random() * 200), '-1 -1 -1', true);
-        else if (self.turret_type == TID_TESLA)
-            turret_gibtoss(tid2info_base, self.origin + '0 0 18', '0 0 200', '-1 -1 -1', false);
-        else
-        {
-            if (random() > 0.5)
-            {
-                turret_gibtoss("models/turrets/base-gib2.md3", self.origin + '0 0 8', '0 0 50' + randomvec() * 150, '0 0 0', false);
-                turret_gibtoss("models/turrets/base-gib3.md3", self.origin + '0 0 8', '0 0 50' + randomvec() * 150, '0 0 0', false);
-                turret_gibtoss("models/turrets/base-gib4.md3", self.origin + '0 0 8', '0 0 50' + randomvec() * 150, '0 0 0', false);
-            }
-            else
-                turret_gibtoss("models/turrets/base-gib1.md3", self.origin + '0 0 8', '0 0 0', '0 0 0', true);
-
-            entity headgib = turret_gibtoss(tid2info_head, self.origin + '0 0 32', '0 0 200' + randomvec() * 200, '-1 -1 -1', true);
-            if(headgib)
-            {
-                headgib.angles = headgib.move_angles = self.tur_head.angles;
-                headgib.avelocity = headgib.move_avelocity = self.tur_head.move_avelocity + randomvec() * 45;
-                headgib.avelocity_y = headgib.move_avelocity_y = headgib.move_avelocity.y * 5;
-                headgib.gravity = 0.5;
-            }
-        }
-    }
-
-    setmodel(self, "null");
-    setmodel(self.tur_head, "null");
-}
-
-void ent_turret()
-{
-    int sf = ReadByte();
-
-       if(sf & TNSF_SETUP)
-       {
-           self.turret_type = ReadByte();
-
-           self.origin_x = ReadCoord();
-           self.origin_y = ReadCoord();
-           self.origin_z = ReadCoord();
-           setorigin(self, self.origin);
-
-           self.angles_x = ReadAngle();
-           self.angles_y = ReadAngle();
-
-           turret_precache(self.turret_type);
-           turret_construct();
-           self.colormap = 1024;
-           self.glowmod = '0 1 1';
-           self.tur_head.colormap = self.colormap;
-           self.tur_head.glowmod = self.glowmod;
-    }
-
-    if(sf & TNSF_ANG)
-    {
-        if(self.tur_head == world) // aparenly this can happpen before TNSF_SETUP. great.
-            self.tur_head = spawn();
-
-        self.tur_head.move_angles_x = ReadShort();
-        self.tur_head.move_angles_y = ReadShort();
-        //self.tur_head.angles = self.angles + self.tur_head.move_angles;
-        self.tur_head.angles = self.tur_head.move_angles;
-    }
-
-    if(sf & TNSF_AVEL)
-    {
-        if(self.tur_head == world) // aparenly this can happpen before TNSF_SETUP. great.
-            self.tur_head = spawn();
-
-        self.tur_head.move_avelocity_x = ReadShort();
-        self.tur_head.move_avelocity_y = ReadShort();
-    }
-
-    if(sf & TNSF_MOVE)
-    {
-        self.origin_x = ReadShort();
-        self.origin_y = ReadShort();
-        self.origin_z = ReadShort();
-        setorigin(self, self.origin);
-
-        self.velocity_x = ReadShort();
-        self.velocity_y = ReadShort();
-        self.velocity_z = ReadShort();
-
-        self.move_angles_y = ReadShort();
-
-        self.move_time     = time;
-        self.move_velocity = self.velocity;
-        self.move_origin   = self.origin;
-    }
-
-    if(sf & TNSF_ANIM)
-    {
-        self.frame1time = ReadCoord();
-        self.frame      = ReadByte();
-    }
-
-    if(sf & TNSF_STATUS)
-    {
-        int _tmp = ReadByte();
-        if(_tmp != self.team)
-        {
-            self.team = _tmp;
-            turret_changeteam();
-        }
-
-        _tmp = ReadByte();
-        if(_tmp == 0 && self.health != 0)
-            turret_die();
-        else if(self.health && self.health != _tmp)
-            self.helpme = servertime + 10;
-
-        self.health = _tmp;
-    }
-    //self.enemy.health = self.health / 255;
-}
diff --git a/qcsrc/client/tturrets.qh b/qcsrc/client/tturrets.qh
deleted file mode 100644 (file)
index 4cf9854..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef TTURRETS_H
-#define TTURRETS_H
-
-void ent_turret();
-void turrets_precache();
-entityclass(Turret);
-class(Turret) .entity tur_head;
-#endif
index 67bcf42..e846a66 100644 (file)
@@ -10,6 +10,8 @@
 #include "shownames.qh"
 #include "waypointsprites.qh"
 
+#include "mutators/events.qh"
+
 #include "../common/constants.qh"
 #include "../common/mapinfo.qh"
 #include "../common/nades.qh"
@@ -801,6 +803,8 @@ void UpdateCrosshair()
                wcross_alpha_prev = wcross_alpha;
                wcross_color_prev = wcross_color;
 
+               MUTATOR_CALLHOOK(UpdateCrosshair);
+
                wcross_scale *= 1 - autocvar__menu_alpha;
                wcross_alpha *= 1 - autocvar__menu_alpha;
                wcross_size = draw_getimagesize(wcross_name) * wcross_scale;
@@ -1109,16 +1113,35 @@ void CSQC_UpdateView(float w, float h)
        if(autocvar_chase_active <= 0) // greater than 0 means it's enabled manually, and this code is skipped
        {
                float vehicle_chase = (hud != HUD_NORMAL && (autocvar_cl_eventchase_vehicle || spectatee_status > 0));
-               if(WantEventchase())
+               float ons_roundlost = (gametype == MAPINFO_TYPE_ONSLAUGHT && getstati(STAT_ROUNDLOST));
+               entity gen = world;
+
+               if(ons_roundlost)
+               {
+                       entity e;
+                       for(e = world; (e = find(e, classname, "onslaught_generator")); )
+                       {
+                               if(e.health <= 0)
+                               {
+                                       gen = e;
+                                       break;
+                               }
+                       }
+                       if(!gen)
+                               ons_roundlost = FALSE; // don't enforce the 3rd person camera if there is no dead generator to show
+               }
+               if(WantEventchase() || (!autocvar_cl_orthoview && ons_roundlost))
                {
                        eventchase_running = true;
 
                        // make special vector since we can't use view_origin (It is one frame old as of this code, it gets set later with the results this code makes.)
                        vector current_view_origin = (csqcplayer ? csqcplayer.origin : pmove_org);
+                       if(ons_roundlost) { current_view_origin = gen.origin; }
 
                        // detect maximum viewoffset and use it
                        vector view_offset = autocvar_cl_eventchase_viewoffset;
                        if(vehicle_chase && autocvar_cl_eventchase_vehicle_viewoffset) { view_offset = autocvar_cl_eventchase_vehicle_viewoffset; }
+                       if(ons_roundlost) { view_offset = autocvar_cl_eventchase_generator_viewoffset; }
 
                        if(view_offset)
                        {
@@ -1135,6 +1158,7 @@ void CSQC_UpdateView(float w, float h)
                        // make the camera smooth back
                        float chase_distance = autocvar_cl_eventchase_distance;
                        if(vehicle_chase && autocvar_cl_eventchase_vehicle_distance) { chase_distance = autocvar_cl_eventchase_vehicle_distance; }
+                       if(ons_roundlost) { chase_distance = autocvar_cl_eventchase_generator_distance; }
 
                        if(autocvar_cl_eventchase_speed && eventchase_current_distance < chase_distance)
                                eventchase_current_distance += autocvar_cl_eventchase_speed * (chase_distance - eventchase_current_distance) * frametime; // slow down the further we get
@@ -1811,6 +1835,8 @@ void CSQC_UpdateView(float w, float h)
 
        if(autocvar__hud_configure)
                HUD_Panel_Mouse();
+       else
+               HUD_Radar_Mouse();
 
     if(hud && !intermission)
     if(hud == HUD_BUMBLEBEE_GUN)
index f63b3cf..40fc56a 100644 (file)
@@ -172,11 +172,8 @@ float spritelookupblinkvalue(string s)
 
        switch(s)
        {
-               case "ons-cp-atck-neut": return 2;
-               case "ons-cp-atck-red":  return 2;
-               case "ons-cp-atck-blue": return 2;
-               case "ons-cp-dfnd-red":  return 0.5;
-               case "ons-cp-dfnd-blue": return 0.5;
+               case "ons-cp-atck":      return 2;
+               case "ons-cp-dfnd":      return 0.5;
                case "item_health_mega": return 2;
                case "item_armor_large": return 2;
                case "item-invis":       return 2;
@@ -238,17 +235,11 @@ string spritelookuptext(string s)
                case "neutralbase": return _("White base");
                case "pinkbase": return _("Pink base");
                case "waypoint": return _("Waypoint");
-               case "ons-gen-red": return _("Generator");
-               case "ons-gen-blue": return _("Generator");
+               case "ons-gen": return _("Generator");
                case "ons-gen-shielded": return _("Generator");
-               case "ons-cp-neut": return _("Control point");
-               case "ons-cp-red": return _("Control point");
-               case "ons-cp-blue": return _("Control point");
-               case "ons-cp-atck-neut": return _("Control point");
-               case "ons-cp-atck-red": return _("Control point");
-               case "ons-cp-atck-blue": return _("Control point");
-               case "ons-cp-dfnd-red": return _("Control point");
-               case "ons-cp-dfnd-blue": return _("Control point");
+               case "ons-cp": return _("Control point");
+               case "ons-cp-atck": return _("Control point");
+               case "ons-cp-dfnd": return _("Control point");
                case "race-checkpoint": return _("Checkpoint");
                case "race-finish": return _("Finish");
                case "race-start": return _("Start");
index adea76c..cb4f7ad 100644 (file)
@@ -78,6 +78,7 @@ void Draw_WaypointSprite();
 // they are drawn using a .draw function
 
 void Ent_RemoveWaypointSprite();
+
 void Ent_WaypointSprite();
 
 void WaypointSprite_Load_Frames(string ext);
index db57943..ddf5722 100644 (file)
@@ -34,7 +34,7 @@ CLASS(Buff, Pickup)
        ATTRIB(Buff, m_skin, int, 0)
        ATTRIB(Buff, m_sprite, string, "")
 #ifdef SVQC
-       METHOD(Buff, m_time, float(entity))
+       METHOD(Buff, m_time, float(entity));
        float Buff_m_time(entity this) { return cvar(strcat("g_buffs_", this.netname, "_time")); }
 #endif
 ENDCLASS(Buff)
index 6aa93a0..d12cc06 100644 (file)
@@ -20,7 +20,7 @@
        #include "../../server/command/cmd.qh"
        #include "../../server/command/common.qh"
        #include "../../server/command/sv_cmd.qh"
-
+       #include "../../common/turrets/config.qh"
        #include "../../common/weapons/config.qh"
 #endif
 
@@ -363,6 +363,59 @@ void GenericCommand_dumpweapons(float request) // WEAPONTODO: make this work wit
        }
 }
 
+void GenericCommand_dumpturrets(float request)
+{
+       switch(request)
+       {
+               case CMD_REQUEST_COMMAND:
+               {
+                       #ifdef SVQC
+                       tur_config_file = -1;
+                       tur_config_alsoprint = -1;
+                       string filename = argv(1);
+
+                       if(filename == "")
+                       {
+                               filename = "turrets_dump.cfg";
+                               tur_config_alsoprint = FALSE;
+                       }
+                       else if(filename == "-")
+                       {
+                               filename = "turrets_dump.cfg";
+                               tur_config_alsoprint = TRUE;
+                       }
+                       tur_config_file = fopen(filename, FILE_WRITE);
+
+                       if(tur_config_file >= 0)
+                       {
+                               Dump_Turret_Settings();
+                               print(sprintf("Dumping turrets... File located in ^2data/data/%s^7.\n", filename));
+                               fclose(tur_config_file);
+                               tur_config_file = -1;
+                               tur_config_alsoprint = -1;
+                       }
+                       else
+                       {
+                               print(sprintf("^1Error: ^7Could not open file '%s'!\n", filename));
+                       }
+                       #else
+                       print(_("Turrets dump command only works with sv_cmd.\n"));
+                       #endif
+                       return;
+               }
+
+               default:
+               case CMD_REQUEST_USAGE:
+               {
+                       print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " dumpturrets [filename]"));
+                       print("  Where 'filename' is the file to write (default is turrets_dump.cfg),\n");
+                       print("  if supplied with '-' output to console as well as default,\n");
+                       print("  if left blank, it will only write to default.\n");
+                       return;
+               }
+       }
+}
+
 void GenericCommand_maplist(float request, float argc)
 {
        switch(request)
@@ -672,6 +725,7 @@ void GenericCommand_(float request)
        GENERIC_COMMAND("dumpcommands", GenericCommand_dumpcommands(request), "Dump all commands on the program to *_cmd_dump.txt") \
        GENERIC_COMMAND("dumpitems", GenericCommand_dumpitems(request), "Dump all items to the console") \
        GENERIC_COMMAND("dumpnotifs", GenericCommand_dumpnotifs(request), "Dump all notifications into notifications_dump.txt") \
+       GENERIC_COMMAND("dumpturrets", GenericCommand_dumpturrets(request), "Dump all turrets into turrets_dump.txt") \
        GENERIC_COMMAND("dumpweapons", GenericCommand_dumpweapons(request), "Dump all weapons into weapons_dump.txt") \
        GENERIC_COMMAND("maplist", GenericCommand_maplist(request, arguments), "Automatic control of maplist") \
        GENERIC_COMMAND("nextframe", GenericCommand_nextframe(request, arguments, command), "Execute the given command next frame of this VM") \
index 1953b1f..231046d 100644 (file)
@@ -31,6 +31,14 @@ const int AS_INT = 2;
 const int AS_FLOAT_TRUNCATED = 2;
 const int AS_FLOAT = 8;
 
+const int TE_CSQC_MUTATOR = 99;
+#define MUTATOR_HASH(s) crc16(true, s)
+#define WriteMutator(to, s) do { \
+    WriteByte(to, TE_CSQC_MUTATOR); \
+    WriteLong(to, MUTATOR_HASH(#s)); \
+} while (0)
+#define ReadMutator() ReadLong()
+#define ReadMutatorEquals(read, s) (read == MUTATOR_HASH(#s))
 const int TE_CSQC_PICTURE = 100;
 const int TE_CSQC_RACE = 101;
 const int TE_CSQC_VORTEXBEAMPARTICLE = 103;
@@ -115,7 +123,9 @@ const int ENT_CLIENT_TRIGGER_IMPULSE = 68;
 const int ENT_CLIENT_SWAMP = 69;
 const int ENT_CLIENT_CORNER = 70;
 const int ENT_CLIENT_KEYLOCK = 71;
-const int ENT_CLIENT_EFFECT = 72;
+const int ENT_CLIENT_GENERATOR = 72;
+const int ENT_CLIENT_CONTROLPOINT_ICON = 73;
+const int ENT_CLIENT_EFFECT = 74;
 const int ENT_CLIENT_VIEWLOC = 78;
 const int ENT_CLIENT_VIEWLOC_TRIGGER = 79;
 
index ac14969..e11604a 100644 (file)
@@ -61,7 +61,7 @@
        CSQCMODEL_PROPERTY(1024, float, ReadAngle, WriteAngle, v_angle_x) \
        CSQCMODEL_PROPERTY_SCALED(4096, float, ReadByte, WriteByte, scale, 16, 0, 255) \
        CSQCMODEL_PROPERTY(8192, int, ReadInt24_t, WriteInt24_t, dphitcontentsmask) \
-       CSQCMODEL_PROPERTY(16384, TAG_VIEWLOC_TYPE, ReadShort, WriteEntity, TAG_VIEWLOC_NAME) 
+       CSQCMODEL_PROPERTY(16384, TAG_VIEWLOC_TYPE, ReadShort, WriteEntity, TAG_VIEWLOC_NAME)
 // TODO get rid of colormod/glowmod here, find good solution for vortex charge glowmod hack; also get rid of some useless properties on non-players that only exist for CopyBody
 
 // add hook function calls here
index dae684c..b9c215f 100644 (file)
@@ -62,7 +62,7 @@ int DEATH_VHLAST;
        DEATHTYPE(DEATH_TURRET_PLASMA,          DEATH_SELF_TURRET_PLASMA,           NO_MSG,                        NORMAL_POS) \
        DEATHTYPE(DEATH_TURRET_TESLA,           DEATH_SELF_TURRET_TESLA,            NO_MSG,                        NORMAL_POS) \
        DEATHTYPE(DEATH_TURRET_WALK_GUN,        DEATH_SELF_TURRET_WALK_GUN,         NO_MSG,                        NORMAL_POS) \
-       DEATHTYPE(DEATH_TURRET_WALK_MEELE,      DEATH_SELF_TURRET_WALK_MEELE,       NO_MSG,                        NORMAL_POS) \
+       DEATHTYPE(DEATH_TURRET_WALK_MELEE,      DEATH_SELF_TURRET_WALK_MELEE,       NO_MSG,                        NORMAL_POS) \
        DEATHTYPE(DEATH_TURRET_WALK_ROCKET,     DEATH_SELF_TURRET_WALK_ROCKET,      NO_MSG,                        DEATH_TURRET_LAST) \
        DEATHTYPE(DEATH_VH_BUMB_DEATH,          DEATH_SELF_VH_BUMB_DEATH,           DEATH_MURDER_VH_BUMB_DEATH,    DEATH_VHFIRST) \
        DEATHTYPE(DEATH_VH_BUMB_GUN,            NO_MSG,                             DEATH_MURDER_VH_BUMB_GUN,      NORMAL_POS) \
index 81dbd70..349fdff 100644 (file)
@@ -34,7 +34,7 @@ void Read_Effect(bool is_new)
                vel_y = ReadCoord();
                vel_z = ReadCoord();
        }
-       
+
        if(!eff_trail)
                eff_cnt = ReadByte();
 
@@ -117,4 +117,4 @@ void Send_Effect(string eff_name, vector eff_loc, vector eff_vel, int eff_cnt)
 
        Net_LinkEntity(net_eff, false, 0, Net_Write_Effect);
 }
-#endif
\ No newline at end of file
+#endif
index 5262dee..790d8a7 100644 (file)
@@ -91,7 +91,7 @@
     EFFECT(0, EFFECT_ITEM_PICKUP,               "item_pickup") \
     EFFECT(0, EFFECT_ITEM_RESPAWN,              "item_respawn") \
     EFFECT(0, EFFECT_JUMPPAD,                   "jumppad_activate") \
-    EFFECT(1, EFFECT_BULLET,                    "tr_bullet") 
+    EFFECT(1, EFFECT_BULLET,                    "tr_bullet")
 
 
 
index 6ecd6d7..0b17f35 100644 (file)
@@ -5,7 +5,7 @@
 /** If you register a new item, make sure to add it to all.inc */
 CLASS(GameItem, Object)
     ATTRIB(GameItem, m_id, int, 0)
-    METHOD(GameItem, show, void(entity this))
+    METHOD(GameItem, show, void(entity this));
     void GameItem_show(entity this) { print("A game item\n"); }
     void ITEM_HANDLE(Show, entity this) { this.show(this); }
 ENDCLASS(GameItem)
index 1875517..6436170 100644 (file)
@@ -5,7 +5,7 @@ CLASS(Pickup, GameItem)
     ATTRIB(Pickup, m_model, string, string_null)
     ATTRIB(Pickup, m_sound, string, "misc/itempickup.wav")
     ATTRIB(Pickup, m_name, string, string_null)
-    METHOD(Pickup, show, void(entity this))
+    METHOD(Pickup, show, void(entity this));
     void Pickup_show(entity this) { printf("%s: %s\n", etos(this), this.m_name); }
 #ifdef SVQC
     ATTRIB(Pickup, m_botvalue, int, 0)
@@ -14,7 +14,7 @@ CLASS(Pickup, GameItem)
     ATTRIB(Pickup, m_pickupevalfunc, float(entity player, entity item), generic_pickupevalfunc)
     ATTRIB(Pickup, m_respawntime, float(), func_null)
     ATTRIB(Pickup, m_respawntimejitter, float(), func_null)
-    METHOD(Pickup, giveTo, bool(entity this, entity item, entity player))
+    METHOD(Pickup, giveTo, bool(entity this, entity item, entity player));
     bool Pickup_giveTo(entity this, entity item, entity player) { return Item_GiveTo(item, player); }
     bool ITEM_HANDLE(Pickup, entity this, entity item, entity player);
 #endif
index 22b17d9..e997937 100644 (file)
@@ -52,49 +52,49 @@ REGISTER_REGISTRY(RegisterGametypes)
 #define IS_GAMETYPE(NAME) \
     (MapInfo_LoadedGametype == MAPINFO_TYPE_##NAME)
 
-REGISTER_GAMETYPE(_("Deathmatch"),dm,g_dm,DEATHMATCH,false,"timelimit=20 pointlimit=30 leadlimit=0",_("Kill all enemies"));
+REGISTER_GAMETYPE(_("Deathmatch"),dm,g_dm,DEATHMATCH,false,"timelimit=20 pointlimit=30 leadlimit=0",_("Score as many frags as you can."));
 #define g_dm IS_GAMETYPE(DEATHMATCH)
 
-REGISTER_GAMETYPE(_("Last Man Standing"),lms,g_lms,LMS,false,"timelimit=20 lives=9 leadlimit=0",_("Survive and kill until the enemies have no lives left"));
+REGISTER_GAMETYPE(_("Last Man Standing"),lms,g_lms,LMS,false,"timelimit=20 lives=9 leadlimit=0",_("Survive and kill until the enemies have no lives left."));
 #define g_lms IS_GAMETYPE(LMS)
 
-REGISTER_GAMETYPE(_("Race"),rc,g_race,RACE,false,"timelimit=20 qualifying_timelimit=5 laplimit=7 teamlaplimit=15 leadlimit=0",_("Race against other players to the finish line"));
+REGISTER_GAMETYPE(_("Race"),rc,g_race,RACE,false,"timelimit=20 qualifying_timelimit=5 laplimit=7 teamlaplimit=15 leadlimit=0",_("Race against other players to the finish line."));
 #define g_race IS_GAMETYPE(RACE)
 
-REGISTER_GAMETYPE(_("Race CTS"),cts,g_cts,CTS,false,"timelimit=20 skill=-1",_("Race for fastest time"));
+REGISTER_GAMETYPE(_("Race CTS"),cts,g_cts,CTS,false,"timelimit=20 skill=-1",_("Race for fastest time."));
 #define g_cts IS_GAMETYPE(CTS)
 
-REGISTER_GAMETYPE(_("Team Deathmatch"),tdm,g_tdm,TEAM_DEATHMATCH,true,"timelimit=20 pointlimit=50 teams=2 leadlimit=0",_("Kill all enemy teammates"));
+REGISTER_GAMETYPE(_("Team Deathmatch"),tdm,g_tdm,TEAM_DEATHMATCH,true,"timelimit=20 pointlimit=50 teams=2 leadlimit=0",_("Help your team score the most frags against the enemy team."));
 #define g_tdm IS_GAMETYPE(TEAM_DEATHMATCH)
 
-REGISTER_GAMETYPE(_("Capture the Flag"),ctf,g_ctf,CTF,true,"timelimit=20 caplimit=10 leadlimit=6",_("Find and bring the enemy flag to your base to capture it"));
+REGISTER_GAMETYPE(_("Capture the Flag"),ctf,g_ctf,CTF,true,"timelimit=20 caplimit=10 leadlimit=6",_("Find and bring the enemy flag to your base to capture it, defend your base from the other team."));
 #define g_ctf IS_GAMETYPE(CTF)
 
-REGISTER_GAMETYPE(_("Clan Arena"),ca,g_ca,CA,true,"timelimit=20 pointlimit=10 teams=2 leadlimit=0",_("Kill all enemy teammates to win the round"));
+REGISTER_GAMETYPE(_("Clan Arena"),ca,g_ca,CA,true,"timelimit=20 pointlimit=10 teams=2 leadlimit=0",_("Kill all enemy teammates to win the round."));
 #define g_ca IS_GAMETYPE(CA)
 
-REGISTER_GAMETYPE(_("Domination"),dom,g_domination,DOMINATION,true,"timelimit=20 pointlimit=200 teams=2 leadlimit=0",_("Capture all the control points to win"));
+REGISTER_GAMETYPE(_("Domination"),dom,g_domination,DOMINATION,true,"timelimit=20 pointlimit=200 teams=2 leadlimit=0",_("Capture and defend all the control points to win."));
 #define g_domination IS_GAMETYPE(DOMINATION)
 
-REGISTER_GAMETYPE(_("Key Hunt"),kh,g_keyhunt,KEYHUNT,true,"timelimit=20 pointlimit=1000 teams=3 leadlimit=0",_("Gather all the keys to win the round"));
+REGISTER_GAMETYPE(_("Key Hunt"),kh,g_keyhunt,KEYHUNT,true,"timelimit=20 pointlimit=1000 teams=3 leadlimit=0",_("Gather all the keys to win the round."));
 #define g_keyhunt IS_GAMETYPE(KEYHUNT)
 
-REGISTER_GAMETYPE(_("Assault"),as,g_assault,ASSAULT,true,"timelimit=20",_("Destroy obstacles to find and destroy the enemy power core before time runs out"));
+REGISTER_GAMETYPE(_("Assault"),as,g_assault,ASSAULT,true,"timelimit=20",_("Destroy obstacles to find and destroy the enemy power core before time runs out."));
 #define g_assault IS_GAMETYPE(ASSAULT)
 
-REGISTER_GAMETYPE(_("Onslaught"),ons,g_onslaught,ONSLAUGHT,true,"timelimit=20",_("Capture control points to reach and destroy the enemy generator"));
+REGISTER_GAMETYPE(_("Onslaught"),ons,g_onslaught,ONSLAUGHT,true,"pointlimit=1 timelimit=20",_("Capture control points to reach and destroy the enemy generator."));
 #define g_onslaught IS_GAMETYPE(ONSLAUGHT)
 
-REGISTER_GAMETYPE(_("Nexball"),nb,g_nexball,NEXBALL,true,"timelimit=20 pointlimit=5 leadlimit=0",_("XonSports"));
+REGISTER_GAMETYPE(_("Nexball"),nb,g_nexball,NEXBALL,true,"timelimit=20 pointlimit=5 leadlimit=0",_("Shoot and kick the ball into the enemies goal, keep your goal clean."));
 #define g_nexball IS_GAMETYPE(NEXBALL)
 
-REGISTER_GAMETYPE(_("Freeze Tag"),ft,g_freezetag,FREEZETAG,true,"timelimit=20 pointlimit=10 teams=2 leadlimit=0",_("Kill enemies to freeze them, stand next to teammates to revive them"));
+REGISTER_GAMETYPE(_("Freeze Tag"),ft,g_freezetag,FREEZETAG,true,"timelimit=20 pointlimit=10 teams=2 leadlimit=0",_("Kill enemies to freeze them, stand next to teammates to revive them, freeze the most enemies to win."));
 #define g_freezetag IS_GAMETYPE(FREEZETAG)
 
-REGISTER_GAMETYPE(_("Keepaway"),ka,g_keepaway,KEEPAWAY,true,"timelimit=20 pointlimit=30",_("Hold the ball to get points for kills"));
+REGISTER_GAMETYPE(_("Keepaway"),ka,g_keepaway,KEEPAWAY,true,"timelimit=20 pointlimit=30",_("Hold the ball to get points for kills."));
 #define g_keepaway IS_GAMETYPE(KEEPAWAY)
 
-REGISTER_GAMETYPE(_("Invasion"),inv,g_invasion,INVASION,false,"pointlimit=50 teams=0",_("Survive against waves of monsters"));
+REGISTER_GAMETYPE(_("Invasion"),inv,g_invasion,INVASION,false,"pointlimit=50 teams=0",_("Survive against waves of monsters."));
 #define g_invasion IS_GAMETYPE(INVASION)
 
 const int MAPINFO_FEATURE_WEAPONS       = 1; // not defined for instagib-only maps
index 887ac20..249e6f9 100644 (file)
     #include "../../server/defs.qh"
     #include "../deathtypes.qh"
     #include "../../server/mutators/mutators_include.qh"
-    #include "../../server/tturrets/include/turrets_early.qh"
-    #include "../vehicles/sv_vehicles.qh"
+       #include "../../server/steerlib.qh"
+       #include "../turrets/sv_turrets.qh"
+       #include "../turrets/util.qh"
+    #include "../vehicles/all.qh"
     #include "../../server/campaign.qh"
     #include "../../server/command/common.qh"
     #include "../../server/command/cmd.qh"
        #include "../triggers/triggers.qh"
     #include "../../csqcmodellib/sv_model.qh"
     #include "../../server/round_handler.qh"
-    #include "../../server/tturrets/include/turrets.qh"
 #endif
 
 // =========================
index 3dd286e..90be773 100644 (file)
@@ -42,7 +42,7 @@ int _Movetype_FlyMove(float dt, bool applygravity, vector stepnormal, float step
 
        for(i = 0; i <= MAX_CLIP_PLANES; ++i)
                planes[i] = '0 0 0';
-       
+
        grav = 0;
 
        restore_velocity = self.move_velocity;
index 44d5442..685982b 100644 (file)
@@ -3,4 +3,4 @@
 
 void _Movetype_Physics_Pusher(float dt);
 
-#endif
\ No newline at end of file
+#endif
index 9e11595..63152e0 100644 (file)
@@ -3,4 +3,4 @@
 
 void _Movetype_Physics_Toss(float dt);
 
-#endif
\ No newline at end of file
+#endif
diff --git a/qcsrc/common/mutators/all.inc b/qcsrc/common/mutators/all.inc
new file mode 100644 (file)
index 0000000..4cb1a6c
--- /dev/null
@@ -0,0 +1 @@
+#include "mutator/damagetext.qc"
diff --git a/qcsrc/common/mutators/all.qc b/qcsrc/common/mutators/all.qc
new file mode 100644 (file)
index 0000000..14530a3
--- /dev/null
@@ -0,0 +1 @@
+#include "all.inc"
index e193d5f..eb46486 100644 (file)
@@ -3,8 +3,28 @@
 
 #define EV_NO_ARGS(i, o)
 
+#pragma noref 1
 string ret_string;
 
+#define MUTATOR_TYPES(_, x) \
+    _(x, bool) \
+    _(x, int) \
+    _(x, entity) \
+    _(x, float) \
+    _(x, vector) \
+    _(x, string) \
+    /**/
+
+#define MUTATOR_NEWGLOBAL(x, type) type mutator_argv_##type##_##x;
+
+MUTATOR_TYPES(MUTATOR_NEWGLOBAL, 0)
+MUTATOR_TYPES(MUTATOR_NEWGLOBAL, 1)
+
+#undef MUTATOR_TYPES
+#undef MUTATOR_NEWGLOBAL
+
+#pragma noref 0
+
 /** appends ":mutatorname" to ret_string for logging */
 #define EV_BuildMutatorsString(i, o) \
     /**/ i(string, ret_string) \
diff --git a/qcsrc/common/mutators/mutator/damagetext.qc b/qcsrc/common/mutators/mutator/damagetext.qc
new file mode 100644 (file)
index 0000000..aacfc73
--- /dev/null
@@ -0,0 +1,125 @@
+REGISTER_MUTATOR(damagetext, true);
+
+#ifdef CSQC
+bool autocvar_cl_damagetext = false;
+string autocvar_cl_damagetext_format = "-%3$d";
+vector autocvar_cl_damagetext_color = '1 1 0';
+float autocvar_cl_damagetext_size = 8;
+float autocvar_cl_damagetext_alpha_start = 1;
+float autocvar_cl_damagetext_alpha_lifetime = 3;
+vector autocvar_cl_damagetext_velocity = '0 0 20';
+vector autocvar_cl_damagetext_offset = '0 -40 0';
+float autocvar_cl_damagetext_accumulate_range = 30;
+STATIC_INIT(cl_damagetext) {
+    CVAR_DESCRIBE(cl_damagetext, _("Draw damage dealt. 0: disabled, 1: enabled"));
+    CVAR_DESCRIBESTR(cl_damagetext_format, _("How to format the damage text. 1$ is health, 2$ is armor, 3$ is both"));
+    CVAR_DESCRIBEVEC(cl_damagetext_color, _("Default damage text color"));
+    CVAR_DESCRIBE(cl_damagetext_size, _("Damage text font size"));
+    CVAR_DESCRIBE(cl_damagetext_alpha_start, _("Damage text initial alpha"));
+    CVAR_DESCRIBE(cl_damagetext_alpha_lifetime, _("Damage text lifetime in seconds"));
+    CVAR_DESCRIBEVEC(cl_damagetext_velocity, _("Damage text move direction"));
+    CVAR_DESCRIBEVEC(cl_damagetext_offset, _("Damage text offset"));
+    CVAR_DESCRIBE(cl_damagetext_accumulate_range, _("Damage text spawned within this range is accumulated"));
+}
+
+CLASS(DamageText, Object)
+    ATTRIB(DamageText, m_color, vector, autocvar_cl_damagetext_color)
+    ATTRIB(DamageText, m_size, float, autocvar_cl_damagetext_size)
+    ATTRIB(DamageText, alpha, float, autocvar_cl_damagetext_alpha_start)
+    ATTRIB(DamageText, fade_rate, float, 1 / autocvar_cl_damagetext_alpha_lifetime)
+    ATTRIB(DamageText, velocity, vector, autocvar_cl_damagetext_velocity)
+    ATTRIB(DamageText, m_group, int, 0)
+    ATTRIB(DamageText, m_damage, int, 0)
+    ATTRIB(DamageText, m_armordamage, int, 0)
+    ATTRIB(DamageText, time_prev, float, time)
+
+    void DamageText_draw() {
+        entity this = self;
+        float dt = time - this.time_prev;
+        this.time_prev = time;
+        setorigin(this, this.origin + dt * this.velocity);
+        this.alpha -= dt * this.fade_rate;
+        if (this.alpha < 0) remove(this);
+        vector pos = project_3d_to_2d(this.origin) + autocvar_cl_damagetext_offset;
+        if (pos.z >= 0 && this.m_size > 0) {
+            pos.z = 0;
+            string s = sprintf(autocvar_cl_damagetext_format, this.m_damage, this.m_armordamage, this.m_damage + this.m_armordamage);
+            drawcolorcodedstring2(pos, s, this.m_size * '1 1 0', this.m_color, this.alpha, DRAWFLAG_NORMAL);
+        }
+    }
+    ATTRIB(DamageText, draw2d, void(), DamageText_draw)
+
+    void DamageText_update(DamageText this, vector _origin, int _health, int _armor) {
+        this.m_damage = _health;
+        this.m_armordamage = _armor;
+        setorigin(this, _origin);
+        this.alpha = 1;
+    }
+
+    CONSTRUCTOR(DamageText, int _group, vector _origin, int _health, int _armor) {
+        CONSTRUCT(DamageText);
+        this.m_group = _group;
+        DamageText_update(this, _origin, _health, _armor);
+        return this;
+    }
+ENDCLASS(DamageText)
+#endif
+
+#ifdef SVQC
+int autocvar_sv_damagetext = 2;
+STATIC_INIT(sv_damagetext) {
+    CVAR_DESCRIBE(sv_damagetext, _("<= 0: disabled, >= 1: spectators, >= 2: players, >= 3: all players"));
+}
+#define SV_DAMAGETEXT_DISABLED()        (autocvar_sv_damagetext <= 0 /* disabled */)
+#define SV_DAMAGETEXT_SPECTATORS_ONLY() (autocvar_sv_damagetext >= 1 /* spectators only */)
+#define SV_DAMAGETEXT_PLAYERS()         (autocvar_sv_damagetext >= 2 /* players */)
+#define SV_DAMAGETEXT_ALL()             (autocvar_sv_damagetext >= 3 /* all players */)
+MUTATOR_HOOKFUNCTION(damagetext, PlayerDamaged) {
+    if (SV_DAMAGETEXT_DISABLED()) return;
+    const entity attacker = mutator_argv_entity_0;
+    const entity hit = mutator_argv_entity_1; if (hit == attacker) return;
+    const int health = mutator_argv_int_0;
+    const int armor = mutator_argv_int_1;
+    const vector location = hit.origin;
+    entity e;
+    FOR_EACH_REALCLIENT(e) if (
+        (SV_DAMAGETEXT_ALL()) ||
+        (SV_DAMAGETEXT_PLAYERS() && e == attacker) ||
+        (SV_DAMAGETEXT_SPECTATORS_ONLY() && IS_SPEC(e) && e.enemy == attacker) ||
+        (SV_DAMAGETEXT_SPECTATORS_ONLY() && IS_OBSERVER(e))
+    ) {
+        msg_entity = e;
+        WriteByte(MSG_ONE, SVC_TEMPENTITY);
+        WriteMutator(MSG_ONE, damagetext);
+        WriteShort(MSG_ONE, health);
+        WriteShort(MSG_ONE, armor);
+        WriteEntity(MSG_ONE, hit);
+        WriteCoord(MSG_ONE, location.x);
+        WriteCoord(MSG_ONE, location.y);
+        WriteCoord(MSG_ONE, location.z);
+    }
+}
+#endif
+
+#ifdef CSQC
+MUTATOR_HOOKFUNCTION(damagetext, CSQC_Parse_TempEntity) {
+    if (MUTATOR_RETURNVALUE) return false;
+    if (!ReadMutatorEquals(mutator_argv_int_0, damagetext)) return false;
+    int health = ReadShort();
+    int armor = ReadShort();
+    int group = ReadShort();
+    vector location = vec3(ReadCoord(), ReadCoord(), ReadCoord());
+    if (autocvar_cl_damagetext) {
+        if (autocvar_cl_damagetext_accumulate_range) {
+            for (entity e = findradius(location, autocvar_cl_damagetext_accumulate_range); e; e = e.chain) {
+                if (e.instanceOfDamageText && e.m_group == group) {
+                    DamageText_update(e, location, e.m_damage + health, e.m_armordamage + armor);
+                    return true;
+                }
+            }
+        }
+        NEW(DamageText, group, location, health, armor);
+    }
+    return true;
+}
+#endif
index fcdc553..f9ddb8e 100644 (file)
@@ -4,7 +4,6 @@
        #include "nades.qh"
        #include "buffs.qh"
        #include "../common/movetypes/movetypes.qh"
-       #include "../server/tturrets/include/turrets_early.qh"
        #include "../client/main.qh"
        #include "../csqcmodellib/cl_model.qh"
 #elif defined(MENUQC)
@@ -12,6 +11,7 @@
        #include "../dpdefs/progsdefs.qh"
     #include "constants.qh"
     #include "../server/constants.qh"
+       #include "../common/turrets/sv_turrets.qh"
 #endif
 
 
index 59d9f62..92386b3 100644 (file)
@@ -447,7 +447,7 @@ void Send_Notification_WOCOVA(
     MSG_INFO_NOTIF(1, INFO_DEATH_SELF_TURRET_PLASMA,       2, 1, "s1 s2loc spree_lost", "s1",       "notify_death",         _("^BG%s^K1 got served some superheated plasma from a turret%s%s"), "") \
     MSG_INFO_NOTIF(1, INFO_DEATH_SELF_TURRET_TESLA,        2, 1, "s1 s2loc spree_lost", "s1",       "notify_death",         _("^BG%s^K1 was electrocuted by a Tesla turret%s%s"), "") \
     MSG_INFO_NOTIF(1, INFO_DEATH_SELF_TURRET_WALK_GUN,     2, 1, "s1 s2loc spree_lost", "s1",       "notify_death",         _("^BG%s^K1 got served a lead enrichment by a Walker turret%s%s"), "") \
-    MSG_INFO_NOTIF(1, INFO_DEATH_SELF_TURRET_WALK_MEELE,   2, 1, "s1 s2loc spree_lost", "s1",       "notify_death",         _("^BG%s^K1 was impaled by a Walker turret%s%s"), "") \
+    MSG_INFO_NOTIF(1, INFO_DEATH_SELF_TURRET_WALK_MELEE,   2, 1, "s1 s2loc spree_lost", "s1",       "notify_death",         _("^BG%s^K1 was impaled by a Walker turret%s%s"), "") \
     MSG_INFO_NOTIF(1, INFO_DEATH_SELF_TURRET_WALK_ROCKET,  2, 1, "s1 s2loc spree_lost", "s1",       "notify_death",         _("^BG%s^K1 was blasted away by a Walker turret%s%s"), "") \
     MSG_INFO_NOTIF(1, INFO_DEATH_SELF_VH_BUMB_DEATH,       2, 1, "s1 s2loc spree_lost", "s1",       "notify_death",         _("^BG%s^K1 got caught in the blast of a Bumblebee explosion%s%s"), "") \
     MSG_INFO_NOTIF(1, INFO_DEATH_SELF_VH_CRUSH,            2, 1, "s1 s2loc spree_lost", "s1",       "notify_death",         _("^BG%s^K1 was crushed by a vehicle%s%s"), "") \
@@ -493,6 +493,10 @@ void Send_Notification_WOCOVA(
     MSG_INFO_NOTIF(1, INFO_LMS_FORFEIT,                    1, 0, "s1", "",                          "",                     _("^BG%s^F3 forfeited"), "") \
     MSG_INFO_NOTIF(1, INFO_LMS_NOLIVES,                    1, 0, "s1", "",                          "",                     _("^BG%s^F3 has no more lives left"), "") \
     MSG_INFO_NOTIF(1, INFO_MONSTERS_DISABLED,              0, 0, "", "",                            "",                     _("^BGMonsters are currently disabled"), "") \
+    MSG_INFO_NOTIF(1, INFO_ONSLAUGHT_CAPTURE,              2, 0, "s1 s2", "",                       "",                     _("^BG%s^BG captured %s^BG control point"), "") \
+    MULTITEAM_INFO(1, INFO_ONSLAUGHT_CPDESTROYED_, 4,      2, 0, "s1 s2", "",                       "",                     _("^TC^TT^BG team %s^BG control point has been destroyed by %s"), "") \
+    MULTITEAM_INFO(1, INFO_ONSLAUGHT_GENDESTROYED_, 4,     0, 0, "", "",                            "",                     _("^TC^TT^BG generator has been destroyed"), "") \
+    MULTITEAM_INFO(1, INFO_ONSLAUGHT_GENDESTROYED_OVERTIME_, 4,  0, 0, "", "",                      "",                     _("^TC^TT^BG generator spontaneously combusted due to overtime!"), "") \
     MSG_INFO_NOTIF(1, INFO_POWERUP_INVISIBILITY,           1, 0, "s1", "s1",                        "strength",             _("^BG%s^K1 picked up Invisibility"), "") \
     MSG_INFO_NOTIF(1, INFO_POWERUP_SHIELD,                 1, 0, "s1", "s1",                        "shield",               _("^BG%s^K1 picked up Shield"), "") \
     MSG_INFO_NOTIF(1, INFO_POWERUP_SPEED,                  1, 0, "s1", "s1",                        "shield",               _("^BG%s^K1 picked up Speed"), "") \
@@ -693,6 +697,7 @@ void Send_Notification_WOCOVA(
     MSG_CENTER_NOTIF(1, CENTER_FREEZETAG_REVIVE_SELF,       0, 0, "",             NO_CPID,             "0 0", _("^K3You revived yourself"), "") \
     MSG_CENTER_NOTIF(1, CENTER_FREEZETAG_REVIVED,           1, 0, "s1",           NO_CPID,             "0 0", _("^K3You were revived by ^BG%s"), "") \
     MSG_CENTER_NOTIF(1, CENTER_FREEZETAG_AUTO_REVIVED,      0, 1, "f1",           NO_CPID,             "0 0", _("^K3You were automatically revived after %s second(s)"), "") \
+    MSG_CENTER_NOTIF(1, CENTER_GENERATOR_UNDERATTACK,       0, 0, "",             NO_CPID,             "0 0", _("^BGThe generator is under attack!"), "") \
     MULTITEAM_CENTER(1, CENTER_ROUND_TEAM_WIN_, 4,          0, 0, "",             CPID_ROUND,          "0 0", _("^TC^TT^BG team wins the round"), "") \
     MSG_CENTER_NOTIF(1, CENTER_ROUND_PLAYER_WIN,            1, 0, "s1",           CPID_ROUND,          "0 0", _("^BG%s^BG wins the round"), "") \
     MSG_CENTER_NOTIF(1, CENTER_FREEZETAG_SELF,              0, 0, "",             NO_CPID,             "0 0", _("^K1You froze yourself"), "") \
@@ -728,7 +733,14 @@ void Send_Notification_WOCOVA(
     MSG_CENTER_NOTIF(1, CENTER_NIX_COUNTDOWN,               0, 2, "item_wepname",  CPID_NIX,              "1 f2", _("^F2^COUNT^BG until weapon change...\nNext weapon: ^F1%s"), "") \
     MSG_CENTER_NOTIF(1, CENTER_NIX_NEWWEAPON,               0, 1, "item_wepname",  CPID_NIX,              "0 0", _("^F2Active weapon: ^F1%s"), "") \
     MSG_CENTER_NOTIF(1, CENTER_NADE,                        0, 0, "",              NO_CPID,               "0 0", _("^BGPress ^F2DROPWEAPON^BG again to toss the grenade!"), "") \
-    MSG_CENTER_NOTIF(1, CENTER_ONS_NOTSHIELDED,             0, 0, "",              CPID_ONSLAUGHT,        "0 0", _("^K1Your generator is NOT shielded!\n^BGRe-capture controlpoints to shield it!"), "") \
+    MSG_CENTER_NOTIF(1, CENTER_ONS_CAPTURE,                 1, 0, "s1",            CPID_ONSLAUGHT,        "0 0", _("^BGYou captured %s^BG control point"), "") \
+    MULTITEAM_CENTER(1, CENTER_ONS_CAPTURE_, 4,             1, 0, "s1",            CPID_ONSLAUGHT,        "0 0", _("^TC^TT^BG team captured %s^BG control point"), "") \
+    MSG_CENTER_NOTIF(1, CENTER_ONS_CONTROLPOINT_SHIELDED,   0, 0, "",              CPID_ONS_CAPSHIELD,    "0 0", _("^BGThis control point currently cannot be captured"), "") \
+    MSG_CENTER_NOTIF(1, CENTER_ONS_GENERATOR_SHIELDED,      0, 0, "",              CPID_ONS_CAPSHIELD,    "0 0", _("^BGThe enemy generator cannot be destroyed yet\n^F2Capture some control points to unshield it"), "") \
+    MULTITEAM_CENTER(1, CENTER_ONS_NOTSHIELDED_, 4,         0, 0, "",              CPID_ONSLAUGHT,        "0 0", _("^BGThe ^TCenemy^BG generator is no longer shielded!"), "") \
+    MSG_CENTER_NOTIF(1, CENTER_ONS_NOTSHIELDED_TEAM,        0, 0, "",              CPID_ONSLAUGHT,        "0 0", _("^K1Your generator is NOT shielded!\n^BGRe-capture control points to shield it!"), "") \
+    MSG_CENTER_NOTIF(1, CENTER_ONS_TELEPORT,                0, 0, "pass_key",      CPID_ONSLAUGHT,        "0 0", _("^BGPress ^F2DROPFLAG%s^BG to teleport"), "") \
+    MSG_CENTER_NOTIF(1, CENTER_ONS_TELEPORT_ANTISPAM,       0, 1, "f1secs",        CPID_ONSLAUGHT,        "0 0", _("^BGTeleporting disabled for %s"), "") \
     MSG_CENTER_NOTIF(1, CENTER_OVERTIME_FRAG,               0, 0, "",              CPID_OVERTIME,         "0 0", _("^F2Now playing ^F4OVERTIME^F2!\nKeep fragging until we have a winner!"), _("^F2Now playing ^F4OVERTIME^F2!\nKeep scoring until we have a winner!")) \
     MSG_CENTER_NOTIF(1, CENTER_OVERTIME_CONTROLPOINT,       0, 0, "",              CPID_OVERTIME,         "5 0", _("^F2Now playing ^F4OVERTIME^F2!\n\nGenerators are now decaying.\nThe more control points your team holds,\nthe faster the enemy generator decays"), "") \
     MSG_CENTER_NOTIF(1, CENTER_OVERTIME_TIME,               0, 1, "f1time",        CPID_OVERTIME,         "0 0", _("^F2Now playing ^F4OVERTIME^F2!\n^BGAdded ^F4%s^BG to the game!"), "") \
@@ -852,7 +864,7 @@ void Send_Notification_WOCOVA(
     MSG_MULTI_NOTIF(1, DEATH_SELF_TURRET_PLASMA,             NO_MSG,        INFO_DEATH_SELF_TURRET_PLASMA,             CENTER_DEATH_SELF_TURRET) \
     MSG_MULTI_NOTIF(1, DEATH_SELF_TURRET_TESLA,              NO_MSG,        INFO_DEATH_SELF_TURRET_TESLA,              CENTER_DEATH_SELF_TURRET) \
     MSG_MULTI_NOTIF(1, DEATH_SELF_TURRET_WALK_GUN,           NO_MSG,        INFO_DEATH_SELF_TURRET_WALK_GUN,           CENTER_DEATH_SELF_TURRET_WALK) \
-    MSG_MULTI_NOTIF(1, DEATH_SELF_TURRET_WALK_MEELE,         NO_MSG,        INFO_DEATH_SELF_TURRET_WALK_MEELE,         CENTER_DEATH_SELF_TURRET_WALK) \
+    MSG_MULTI_NOTIF(1, DEATH_SELF_TURRET_WALK_MELEE,         NO_MSG,        INFO_DEATH_SELF_TURRET_WALK_MELEE,         CENTER_DEATH_SELF_TURRET_WALK) \
     MSG_MULTI_NOTIF(1, DEATH_SELF_TURRET_WALK_ROCKET,        NO_MSG,        INFO_DEATH_SELF_TURRET_WALK_ROCKET,        CENTER_DEATH_SELF_TURRET_WALK) \
     MSG_MULTI_NOTIF(1, DEATH_SELF_VH_BUMB_DEATH,             NO_MSG,        INFO_DEATH_SELF_VH_BUMB_DEATH,             CENTER_DEATH_SELF_VH_BUMB_DEATH) \
     MSG_MULTI_NOTIF(1, DEATH_SELF_VH_CRUSH,                  NO_MSG,        INFO_DEATH_SELF_VH_CRUSH,                  CENTER_DEATH_SELF_VH_CRUSH) \
@@ -1333,6 +1345,7 @@ enum {
 ,   CPID_MOTD
 ,   CPID_NIX
 ,   CPID_ONSLAUGHT
+,   CPID_ONS_CAPSHIELD
 ,   CPID_OVERTIME
 ,   CPID_POWERUP
 ,   CPID_RACE_FINISHLAP
@@ -1353,7 +1366,7 @@ float NOTIF_CHOICE_COUNT;
 
 // notification limits -- INCREASE AS NECESSARY
 const float NOTIF_ANNCE_MAX   = 100;
-const float NOTIF_INFO_MAX    = 300;
+const float NOTIF_INFO_MAX    = 350;
 const float NOTIF_CENTER_MAX  = 250;
 const float NOTIF_MULTI_MAX   = 200;
 const float NOTIF_CHOICE_MAX  = 30;
index aa660ab..add63b0 100644 (file)
@@ -97,7 +97,8 @@ ACCUMULATE_FUNCTION(__static_init, RegisterClasses)
 #define METHOD(cname, name, prototype)      \
     class(cname) .prototype name;           \
     prototype cname##_##name;               \
-    INIT_STATIC(cname) { this.name = cname##_##name; }
+    INIT_STATIC(cname) { this.name = cname##_##name; } \
+    prototype cname##_##name
 
 #define ATTRIB(cname, name, type, val)      \
     class(cname) .type name;                \
index ad569ff..85c5396 100644 (file)
@@ -1,22 +1,22 @@
 /*
  Copyright (C) 2015 Micah Talkiewicz.
+
  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version 2
  of the License, or (at your option) any later version.
+
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
  See the GNU General Public License for more details.
+
  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
+
 vector vec_bias(vector v, float f){
        vector c;
        c_x = v_x + f;
@@ -31,7 +31,7 @@ vector vec_to_min (vector a, vector b) {
        c_z = min (a_z, b_z);
        return c;
 }
+
 vector vec_to_max (vector a, vector b) {
        vector c;
        c_x = max (a_x, b_x);
@@ -39,46 +39,46 @@ vector vec_to_max (vector a, vector b) {
        c_z = max (a_z, b_z);
        return c;
 }
+
 // there may already be a function for bounding a vector in this manner, however my very quick search did not reveal one -- Player_2
 vector vec_bounds_in (vector point, vector a, vector b) {
        vector c, d, e;
-        
+
        d = vec_to_min(a,b);
        e = vec_to_max(a,b);
-        
+
        c = vec_to_max(point, d);
        c = vec_to_min(c, e);
-        
+
        return c;
-        
+
 }
+
 vector vec_bounds_out (vector point, vector a, vector b) {
        vector c, d, e;
-        
+
        d = vec_to_max(a,b);
        e = vec_to_min(a,b);
-        
+
        c = vec_to_max(point, d);
        c = vec_to_min(c, e);
-        
+
        return c;
-        
+
 }
+
 float angle_snap_f (float f, float increment){
-        
+
        float i;
        for (i = 0; i <= 360; ){
                if (f <= i - increment)
                        return  i - increment;
                i = i + increment;
        }
-        
+
        return 0;
 }
+
 vector angle_snap_vec (vector v,  float increment) {
        vector c;
        c_x = angle_snap_f (v_x, increment);
index a8dc7ab..c92f26a 100644 (file)
@@ -1,17 +1,17 @@
 /*
  Copyright (C) 2015 Micah Talkiewicz.
+
  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version 2
  of the License, or (at your option) any later version.
+
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
  See the GNU General Public License for more details.
+
  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
index 6c0bd61..e5b8344 100644 (file)
@@ -327,7 +327,7 @@ void PM_ClientMovement_Move()
        vector trace1_plane_normal = '0 0 0';
        vector trace2_plane_normal = '0 0 0';
        vector trace3_plane_normal = '0 0 0';
-       
+
 
        PM_ClientMovement_UpdateStatus(false);
        primalvelocity = self.velocity;
@@ -1668,7 +1668,7 @@ void PM_Main()
 
        PM_ClientMovement_UpdateStatus(true);
 #endif
-       
+
 
 #ifdef SVQC
        WarpZone_PlayerPhysics_FixVAngle();
@@ -1936,7 +1936,7 @@ void CSQC_ClientMovement_PlayerMove_Frame(void)
        PM_Main();
 
 #ifdef CSQC
-       self.pmove_flags = 
+       self.pmove_flags =
                        ((self.flags & FL_DUCKED) ? PMF_DUCKED : 0) |
                        (!(self.flags & FL_JUMPRELEASED) ? 0 : PMF_JUMP_HELD) |
                        ((self.flags & FL_ONGROUND) ? PMF_ONGROUND : 0);
index eb6b0ea..83afc18 100644 (file)
@@ -119,7 +119,7 @@ const int STAT_SHIELD_TIME            = 95;
 const int STAT_FUELREGEN_TIME         = 96;
 const int STAT_JETPACK_TIME           = 97;
 const int STAT_SUPERWEAPONS_TIME      = 98;
-// 99 empty?
+const int STAT_ROUNDLOST              = 99;
 
 /* The following stats change depending on the gamemode, so can share the same ID */
 // IDs 100 to 104 reserved for gamemodes
@@ -190,22 +190,22 @@ const int STAT_CTF_FLAGSTATUS         = 124;
 // 137 empty?
 // 138 empty?
 // 139 empty?
-// 140 empty?
-// 141 empty?
-// 142 empty?
-// 143 empty?
-// 144 empty?
-// 145 empty?
-// 146 empty?
-// 147 empty?
-// 148 empty?
-// 149 empty?
-// 150 empty?
-// 151 empty?
-// 152 empty?
-// 153 empty?
-// 154 empty?
-// 155 empty?
+// 140 reserved
+// 141 reserved
+// 142 reserved
+// 143 reserved
+// 144 reserved
+// 145 reserved
+// 146 reserved
+// 147 reserved
+// 148 reserved
+// 149 reserved
+// 150 reserved
+// 151 reserved
+// 152 reserved
+// 153 reserved
+// 154 reserved
+// 155 reserved
 // 156 empty?
 // 157 empty?
 // 158 empty?
index 1b62163..04f8f24 100644 (file)
@@ -27,7 +27,7 @@ void() door_rotating_go_up;
 
 void door_blocked()
 {
-       if((self.spawnflags & 8) 
+       if((self.spawnflags & 8)
 #ifdef SVQC
                && (other.takedamage != DAMAGE_NO)
 #elif defined(CSQC)
index d446e72..f08ea48 100644 (file)
@@ -2,4 +2,4 @@
 
 void Ent_PointParticles();
 
-#endif
\ No newline at end of file
+#endif
index 001a759..0de3489 100644 (file)
@@ -200,7 +200,7 @@ void spawnfunc_func_train()
        if (!InitMovingBrushTrigger())
                return;
        self.effects |= EF_LOWPRECISION;
-       
+
        if (self.spawnflags & 2)
        {
                self.platmovetype_turn = true;
index a583716..89a5fa2 100644 (file)
@@ -15,8 +15,8 @@
     #include "../../server/constants.qh"
     #include "../../server/defs.qh"
     #include "../deathtypes.qh"
-    #include "../../server/tturrets/include/turrets_early.qh"
-    #include "../vehicles/sv_vehicles.qh"
+    #include "../turrets/sv_turrets.qh"
+    #include "../vehicles/all.qh"
     #include "../mapinfo.qh"
     #include "../../server/anticheat.qh"
 #endif
index c7fd150..6708a8e 100644 (file)
@@ -12,4 +12,4 @@ void ent_viewloc();
 void ent_viewloc_trigger();
 #endif
 
-#endif
\ No newline at end of file
+#endif
index 474f797..c8e593f 100644 (file)
@@ -34,6 +34,8 @@ void target_voicescript_clear(entity pl);
 
 .vector dest;
 
+void FixSize(entity e);
+
 #ifdef CSQC
 void trigger_common_read(bool withtarget);
 void trigger_remove_generic();
diff --git a/qcsrc/common/turrets/all.qh b/qcsrc/common/turrets/all.qh
new file mode 100644 (file)
index 0000000..04bb10f
--- /dev/null
@@ -0,0 +1,12 @@
+#include "unit/ewheel.qc"
+#include "unit/flac.qc"
+#include "unit/fusionreactor.qc"
+#include "unit/hellion.qc"
+#include "unit/hk.qc"
+#include "unit/machinegun.qc"
+#include "unit/mlrs.qc"
+#include "unit/phaser.qc"
+#include "unit/plasma.qc"
+#include "unit/plasma_dual.qc"
+#include "unit/tesla.qc"
+#include "unit/walker.qc"
diff --git a/qcsrc/common/turrets/checkpoint.qc b/qcsrc/common/turrets/checkpoint.qc
new file mode 100644 (file)
index 0000000..f2fc3a8
--- /dev/null
@@ -0,0 +1,82 @@
+/**
+    turret_checkpoint
+**/
+
+
+//.entity checkpoint_target;
+
+/*
+#define checkpoint_cache_who  flagcarried
+#define checkpoint_cache_from lastrocket
+#define checkpoint_cache_to   selected_player
+*/
+
+.entity pathgoal;
+
+/*
+entity path_makeorcache(entity forwho,entity start, entity end)
+{
+    entity oldself;
+    entity pth;
+    oldself = self;
+    self = forwho;
+
+    //pth = pathlib_makepath(start.origin,end.origin,PFL_GROUNDSNAP,500,1.5,PT_QUICKSTAR);
+
+    self = oldself;
+    return pth;
+}
+*/
+
+void turret_checkpoint_use()
+{
+}
+
+#if 0
+void turret_checkpoint_think()
+{
+    if(self.enemy)
+        te_lightning1(self,self.origin, self.enemy.origin);
+
+    self.nextthink = time + 0.25;
+}
+#endif
+/*QUAKED turret_checkpoint (1 0 1) (-32 -32 -32) (32 32 32)
+-----------KEYS------------
+target: .targetname of next waypoint in chain.
+wait:   Pause at this point # seconds.
+-----------SPAWNFLAGS-----------
+---------NOTES----------
+If a loop is of targets are formed, any unit entering this loop will patrol it indefinitly.
+If the checkpoint chain in not looped, the unit will go "Roaming" when the last point is reached.
+*/
+//float tc_acum;
+void turret_checkpoint_init()
+{
+    traceline(self.origin + '0 0 16', self.origin - '0 0 1024', MOVE_WORLDONLY, self);
+    setorigin(self, trace_endpos + '0 0 32');
+
+    if(self.target != "")
+    {
+        self.enemy = find(world, targetname, self.target);
+        if(self.enemy == world)
+            dprint("A turret_checkpoint faild to find its target!\n");
+    }
+    //self.think = turret_checkpoint_think;
+    //self.nextthink = time + tc_acum + 0.25;
+    //tc_acum += 0.25;
+}
+
+void spawnfunc_turret_checkpoint()
+{
+    setorigin(self,self.origin);
+    self.think = turret_checkpoint_init;
+    self.nextthink = time + 0.2;
+}
+
+// Compat.
+void spawnfunc_walker_checkpoint()
+{
+    self.classname = "turret_checkpoint";
+    spawnfunc_turret_checkpoint();
+}
diff --git a/qcsrc/common/turrets/cl_turrets.qc b/qcsrc/common/turrets/cl_turrets.qc
new file mode 100644 (file)
index 0000000..f0b3bdf
--- /dev/null
@@ -0,0 +1,445 @@
+void turret_remove()
+{
+       remove(self.tur_head);
+       //remove(self.enemy);
+       self.tur_head = world;
+}
+
+.vector glowmod;
+void turret_changeteam()
+{
+       self.glowmod = Team_ColorRGB(self.team - 1) * 2;
+       self.teamradar_color = Team_ColorRGB(self.team - 1);
+
+       if(self.team)
+               self.colormap = 1024 + (self.team - 1) * 17;
+
+       self.tur_head.colormap = self.colormap;
+       self.tur_head.glowmod = self.glowmod;
+
+}
+
+void turret_head_draw()
+{
+       self.drawmask = MASK_NORMAL;
+}
+
+void turret_draw()
+{
+       float dt;
+
+       dt = time - self.move_time;
+       self.move_time = time;
+       if(dt <= 0)
+               return;
+
+       self.tur_head.angles += dt * self.tur_head.move_avelocity;
+
+       if (self.health < 127)
+       {
+               dt = random();
+
+               if(dt < 0.03)
+                       te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
+       }
+
+       if(self.health < 85)
+       if(dt < 0.01)
+               pointparticles(particleeffectnum("smoke_large"), (self.origin + (randomvec() * 80)), '0 0 0', 1);
+
+       if(self.health < 32)
+       if(dt < 0.015)
+               pointparticles(particleeffectnum("smoke_small"), (self.origin + (randomvec() * 80)), '0 0 0', 1);
+
+}
+
+void turret_draw2d()
+{
+       if(self.netname == "")
+               return;
+
+       if(!autocvar_g_waypointsprite_turrets)
+               return;
+
+       if(autocvar_cl_hidewaypoints)
+               return;
+
+       float dist = vlen(self.origin - view_origin);
+       float t = (GetPlayerColor(player_localnum) + 1);
+
+       vector o;
+       string txt;
+
+       if(autocvar_cl_vehicles_hud_tactical)
+       if(dist < 10240 && t != self.team)
+       {
+               // TODO: Vehicle tactical hud
+               o = project_3d_to_2d(self.origin + '0 0 32');
+               if(o_z < 0
+               || o_x < (vid_conwidth * waypointsprite_edgeoffset_left)
+               || o_y < (vid_conheight * waypointsprite_edgeoffset_top)
+               || o_x > (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right))
+               || o_y > (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)))
+                       return; // Dont draw wp's for turrets out of view
+               o_z = 0;
+               if(hud != HUD_NORMAL)
+               {
+                       if((get_turretinfo(self.turretid)).spawnflags & TUR_FLAG_MOVE)
+                               txt = "gfx/vehicles/turret_moving.tga";
+                       else
+                               txt = "gfx/vehicles/turret_stationary.tga";
+
+                       vector pz = drawgetimagesize(txt) * autocvar_cl_vehicles_crosshair_size;
+                       drawpic(o - pz * 0.5, txt, pz , '1 1 1', 0.7, DRAWFLAG_NORMAL);
+               }
+       }
+
+       if(dist > self.maxdistance)
+               return;
+
+       string spriteimage = self.netname;
+       float a = self.alpha * autocvar_hud_panel_fg_alpha;
+       vector rgb = spritelookupcolor(spriteimage, self.teamradar_color);
+
+
+       if(self.maxdistance > waypointsprite_normdistance)
+               a *= pow(bound(0, (self.maxdistance - dist) / (self.maxdistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent);
+       else if(self.maxdistance > 0)
+               a *= pow(bound(0, (waypointsprite_fadedistance - dist) / (waypointsprite_fadedistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent) * (1 - waypointsprite_minalpha) + waypointsprite_minalpha;
+
+       if(rgb == '0 0 0')
+       {
+               self.teamradar_color = '1 0 1';
+               printf("WARNING: sprite of name %s has no color, using pink so you notice it\n", spriteimage);
+       }
+
+       txt = self.netname;
+       if(autocvar_g_waypointsprite_spam && waypointsprite_count >= autocvar_g_waypointsprite_spam)
+               txt = _("Spam");
+       else
+               txt = spritelookuptext(spriteimage);
+
+       if(time - floor(time) > 0.5 && t == self.team)
+       {
+               if(self.helpme && time < self.helpme)
+               {
+                       a *= SPRITE_HELPME_BLINK;
+                       txt = sprintf(_("%s under attack!"), txt);
+               }
+               else
+                       a *= spritelookupblinkvalue(spriteimage);
+       }
+
+       if(autocvar_g_waypointsprite_uppercase)
+               txt = strtoupper(txt);
+
+       if(a > 1)
+       {
+               rgb *= a;
+               a = 1;
+       }
+
+       if(a <= 0)
+               return;
+
+       rgb = fixrgbexcess(rgb);
+
+       o = project_3d_to_2d(self.origin + '0 0 64');
+       if(o_z < 0
+       || o_x < (vid_conwidth * waypointsprite_edgeoffset_left)
+       || o_y < (vid_conheight * waypointsprite_edgeoffset_top)
+       || o_x > (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right))
+       || o_y > (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)))
+               return; // Dont draw wp's for turrets out of view
+
+       o_z = 0;
+
+       float edgedistance_min, crosshairdistance;
+               edgedistance_min = min((o_y - (vid_conheight * waypointsprite_edgeoffset_top)),
+       (o_x - (vid_conwidth * waypointsprite_edgeoffset_left)),
+       (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right)) - o_x,
+       (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)) - o_y);
+
+       float vidscale = max(vid_conwidth / vid_width, vid_conheight / vid_height);
+
+       crosshairdistance = sqrt( pow(o_x - vid_conwidth/2, 2) + pow(o_y - vid_conheight/2, 2) );
+
+       t = waypointsprite_scale * vidscale;
+       a *= waypointsprite_alpha;
+
+       {
+               a = a * (1 - (1 - waypointsprite_distancefadealpha) * (bound(0, dist/waypointsprite_distancefadedistance, 1)));
+               t = t * (1 - (1 - waypointsprite_distancefadescale) * (bound(0, dist/waypointsprite_distancefadedistance, 1)));
+       }
+       if (edgedistance_min < waypointsprite_edgefadedistance) {
+               a = a * (1 - (1 - waypointsprite_edgefadealpha) * (1 - bound(0, edgedistance_min/waypointsprite_edgefadedistance, 1)));
+               t = t * (1 - (1 - waypointsprite_edgefadescale) * (1 - bound(0, edgedistance_min/waypointsprite_edgefadedistance, 1)));
+       }
+       if(crosshairdistance < waypointsprite_crosshairfadedistance) {
+               a = a * (1 - (1 - waypointsprite_crosshairfadealpha) * (1 - bound(0, crosshairdistance/waypointsprite_crosshairfadedistance, 1)));
+               t = t * (1 - (1 - waypointsprite_crosshairfadescale) * (1 - bound(0, crosshairdistance/waypointsprite_crosshairfadedistance, 1)));
+       }
+
+       o = drawspritearrow(o, M_PI, rgb, a, SPRITE_ARROW_SCALE * t);
+       o = drawspritetext(o, M_PI, (SPRITE_HEALTHBAR_WIDTH + 2 * SPRITE_HEALTHBAR_BORDER) * t, rgb, a, waypointsprite_fontsize * '1 1 0', txt);
+       drawhealthbar(
+                       o,
+                       0,
+                       self.health / 255,
+                       '0 0 0',
+                       '0 0 0',
+                       0.5 * SPRITE_HEALTHBAR_WIDTH * t,
+                       0.5 * SPRITE_HEALTHBAR_HEIGHT * t,
+                       SPRITE_HEALTHBAR_MARGIN * t + 0.5 * waypointsprite_fontsize,
+                       SPRITE_HEALTHBAR_BORDER * t,
+                       0,
+                       rgb,
+                       a * SPRITE_HEALTHBAR_BORDERALPHA,
+                       rgb,
+                       a * SPRITE_HEALTHBAR_HEALTHALPHA,
+                       DRAWFLAG_NORMAL
+                       );
+}
+
+void turret_construct()
+{
+       entity tur = get_turretinfo(self.turretid);
+
+       if(self.tur_head == world)
+               self.tur_head = spawn();
+
+       self.netname = TUR_NAME(self.turretid);
+
+       setorigin(self, self.origin);
+       setmodel(self, tur.model);
+       setmodel(self.tur_head, tur.head_model);
+       setsize(self, tur.mins, tur.maxs);
+       setsize(self.tur_head, '0 0 0', '0 0 0');
+
+       if(self.turretid == TUR_EWHEEL)
+               setattachment(self.tur_head, self, "");
+       else
+               setattachment(self.tur_head, self, "tag_head");
+
+       self.tur_head.classname                 = "turret_head";
+       self.tur_head.owner                             = self;
+       self.tur_head.move_movetype             = MOVETYPE_NOCLIP;
+       self.move_movetype                              = MOVETYPE_NOCLIP;
+       self.tur_head.angles                    = self.angles;
+       self.health                                             = 255;
+       self.solid                                              = SOLID_BBOX;
+       self.tur_head.solid                             = SOLID_NOT;
+       self.movetype                                   = MOVETYPE_NOCLIP;
+       self.tur_head.movetype                  = MOVETYPE_NOCLIP;
+       self.draw                                               = turret_draw;
+       self.entremove                                  = turret_remove;
+       self.drawmask                                   = MASK_NORMAL;
+       self.tur_head.drawmask                  = MASK_NORMAL;
+       self.anim_start_time                    = 0;
+       self.draw2d = turret_draw2d;
+       self.maxdistance = autocvar_g_waypointsprite_turrets_maxdist;
+       self.teamradar_color = '1 0 0';
+       self.alpha = 1;
+
+       TUR_ACTION(self.turretid, TR_SETUP);
+}
+
+entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, float _explode);
+void turret_gibboom();
+void turret_gib_draw()
+{
+       Movetype_Physics_MatchTicrate(autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
+
+       self.drawmask = MASK_NORMAL;
+
+       if(self.cnt)
+       {
+               if(time >= self.nextthink)
+               {
+                       turret_gibboom();
+                       remove(self);
+               }
+       }
+       else
+       {
+               self.alpha = bound(0, self.nextthink - time, 1);
+               if(self.alpha < ALPHA_MIN_VISIBLE)
+                       remove(self);
+       }
+}
+
+void turret_gibboom()
+{
+       float i;
+
+       sound (self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
+       pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
+
+       for (i = 1; i < 5; i = i + 1)
+               turret_gibtoss(strcat("models/turrets/head-gib", ftos(i), ".md3"), self.origin + '0 0 2', self.velocity + randomvec() * 700, '0 0 0', false);
+}
+
+entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, float _explode)
+{
+       entity gib;
+
+       traceline(_from, _to, MOVE_NOMONSTERS, world);
+       if(trace_startsolid)
+               return world;
+
+       gib = spawn();
+       setorigin(gib, _from);
+       setmodel(gib, _model);
+       gib.colormod    = _cmod;
+       gib.solid          = SOLID_CORPSE;
+       gib.draw                = turret_gib_draw;
+       gib.cnt          = _explode;
+       setsize(gib, '-1 -1 -1', '1 1 1');
+       if(_explode)
+       {
+               gib.nextthink = time + 0.2 * (autocvar_cl_gibs_lifetime * (1 + prandom() * 0.15));
+               gib.effects = EF_FLAME;
+       }
+       else
+               gib.nextthink = time + autocvar_cl_gibs_lifetime * (1 + prandom() * 0.15);
+
+       gib.gravity              = 1;
+       gib.move_movetype   = MOVETYPE_BOUNCE;
+       gib.move_origin  = _from;
+       setorigin(gib,          _from);
+       gib.move_velocity   = _to;
+       gib.move_avelocity  = prandomvec() * 32;
+       gib.move_time      = time;
+       gib.damageforcescale = 1;
+       gib.classname = "turret_gib";
+
+       return gib;
+}
+
+void turret_die()
+{
+       sound (self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
+       pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
+       if (!autocvar_cl_nogibs)
+       {
+               // Base
+               if(self.turretid == TUR_EWHEEL)
+                       turret_gibtoss((get_turretinfo(self.turretid)).model, self.origin + '0 0 18', self.velocity + '0 0 400' + '0.1 0.1 1' * (random() * 400), '-1 -1 -1', true);
+               else if (self.turretid == TUR_WALKER)
+                       turret_gibtoss((get_turretinfo(self.turretid)).model, self.origin + '0 0 18', self.velocity + '0 0 300' + '0.1 0.1 1' * (random() * 200), '-1 -1 -1', true);
+               else if (self.turretid == TUR_TESLA)
+                       turret_gibtoss((get_turretinfo(self.turretid)).model, self.origin + '0 0 18', '0 0 200', '-1 -1 -1', false);
+               else
+               {
+                       if (random() > 0.5)
+                       {
+                               turret_gibtoss("models/turrets/base-gib2.md3", self.origin + '0 0 8', '0 0 50' + randomvec() * 150, '0 0 0', false);
+                               turret_gibtoss("models/turrets/base-gib3.md3", self.origin + '0 0 8', '0 0 50' + randomvec() * 150, '0 0 0', false);
+                               turret_gibtoss("models/turrets/base-gib4.md3", self.origin + '0 0 8', '0 0 50' + randomvec() * 150, '0 0 0', false);
+                       }
+                       else
+                               turret_gibtoss("models/turrets/base-gib1.md3", self.origin + '0 0 8', '0 0 0', '0 0 0', true);
+
+                       entity headgib = turret_gibtoss((get_turretinfo(self.turretid)).head_model, self.origin + '0 0 32', '0 0 200' + randomvec() * 200, '-1 -1 -1', true);
+                       if(headgib)
+                       {
+                               headgib.angles = headgib.move_angles = self.tur_head.angles;
+                               headgib.avelocity = headgib.move_avelocity = self.tur_head.move_avelocity + randomvec() * 45;
+                               headgib.avelocity_y = headgib.move_avelocity_y = headgib.move_avelocity_y * 5;
+                               headgib.gravity = 0.5;
+                       }
+               }
+       }
+
+       setmodel(self, "null");
+       setmodel(self.tur_head, "null");
+}
+
+void ent_turret()
+{
+       float sf;
+       sf = ReadByte();
+
+       if(sf & TNSF_SETUP)
+       {
+               self.turretid = ReadByte();
+
+               self.origin_x = ReadCoord();
+               self.origin_y = ReadCoord();
+               self.origin_z = ReadCoord();
+               setorigin(self, self.origin);
+
+               self.angles_x = ReadAngle();
+               self.angles_y = ReadAngle();
+
+               turret_construct();
+               self.colormap = 1024;
+               self.glowmod = '0 1 1';
+               self.tur_head.colormap = self.colormap;
+               self.tur_head.glowmod = self.glowmod;
+       }
+
+       if(sf & TNSF_ANG)
+       {
+               if(self.tur_head == world) // aparenly this can happpen before TNSF_SETUP. great.
+                       self.tur_head = spawn();
+
+               self.tur_head.move_angles_x = ReadShort();
+               self.tur_head.move_angles_y = ReadShort();
+               //self.tur_head.angles = self.angles + self.tur_head.move_angles;
+               self.tur_head.angles = self.tur_head.move_angles;
+       }
+
+       if(sf & TNSF_AVEL)
+       {
+               if(self.tur_head == world) // aparenly this can happpen before TNSF_SETUP. great.
+                       self.tur_head = spawn();
+
+               self.tur_head.move_avelocity_x = ReadShort();
+               self.tur_head.move_avelocity_y = ReadShort();
+       }
+
+       if(sf & TNSF_MOVE)
+       {
+               self.origin_x = ReadShort();
+               self.origin_y = ReadShort();
+               self.origin_z = ReadShort();
+               setorigin(self, self.origin);
+
+               self.velocity_x = ReadShort();
+               self.velocity_y = ReadShort();
+               self.velocity_z = ReadShort();
+
+               self.move_angles_y = ReadShort();
+
+               self.move_time   = time;
+               self.move_velocity = self.velocity;
+               self.move_origin   = self.origin;
+       }
+
+       if(sf & TNSF_ANIM)
+       {
+               self.frame1time = ReadCoord();
+               self.frame        = ReadByte();
+       }
+
+       if(sf & TNSF_STATUS)
+       {
+               float _tmp;
+               _tmp = ReadByte();
+               if(_tmp != self.team)
+               {
+                       self.team = _tmp;
+                       turret_changeteam();
+               }
+
+               _tmp = ReadByte();
+               if(_tmp == 0 && self.health != 0)
+                       turret_die();
+               else if(self.health && self.health != _tmp)
+                       self.helpme = servertime + 10;
+
+               self.health = _tmp;
+       }
+       //self.enemy.health = self.health / 255;
+}
diff --git a/qcsrc/common/turrets/cl_turrets.qh b/qcsrc/common/turrets/cl_turrets.qh
new file mode 100644 (file)
index 0000000..0f8ff94
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef CL_TURRETS_H
+#define CL_TURRETS_H
+
+void ent_turret();
+
+#endif
diff --git a/qcsrc/common/turrets/config.qc b/qcsrc/common/turrets/config.qc
new file mode 100644 (file)
index 0000000..547b5c6
--- /dev/null
@@ -0,0 +1,62 @@
+// ==========================
+//  Turret Config Generator
+// ==========================
+
+void T_Config_Queue_Swap(float root, float child, entity pass)
+{
+       string oldroot = tur_config_queue[root];
+       tur_config_queue[root] = tur_config_queue[child];
+       tur_config_queue[child] = oldroot;
+}
+
+float T_Config_Queue_Compare(float root, float child, entity pass)
+{
+       float i, r, c;
+
+       for(i = 1; i <= 100; ++i)
+       {
+               r = str2chr(tur_config_queue[root], i);
+               c = str2chr(tur_config_queue[child], i);
+               if(r == c) { continue; }
+               else if(c > r) { return -1; }
+               else { return 1; }
+       }
+
+       return 0;
+}
+
+void Dump_Turret_Settings(void)
+{
+       float i, x, totalsettings = 0;
+       for(i = TUR_FIRST; i <= TUR_LAST; ++i)
+       {
+               // step 1: clear the queue
+               TUR_CONFIG_COUNT = 0;
+               for(x = 0; x <= MAX_TUR_CONFIG; ++x)
+                       { tur_config_queue[x] = string_null; }
+
+               // step 2: build new queue
+               TUR_ACTION(i, TR_CONFIG);
+
+               // step 3: sort queue
+               heapsort(TUR_CONFIG_COUNT, T_Config_Queue_Swap, T_Config_Queue_Compare, world);
+
+               // step 4: write queue
+               TUR_CONFIG_WRITETOFILE(sprintf("// {{{ #%d: %s\n", i, TUR_NAME(i)))
+               for(x = 0; x <= TUR_CONFIG_COUNT; ++x)
+                       { TUR_CONFIG_WRITETOFILE(tur_config_queue[x]) }
+               TUR_CONFIG_WRITETOFILE("// }}}\n")
+
+               // step 5: debug info
+               print(sprintf("#%d: %s: %d settings...\n", i, TUR_NAME(i), TUR_CONFIG_COUNT));
+               totalsettings += TUR_CONFIG_COUNT;
+       }
+
+       // clear queue now that we're finished
+       TUR_CONFIG_COUNT = 0;
+       for(x = 0; x <= MAX_TUR_CONFIG; ++x)
+               { tur_config_queue[x] = string_null; }
+
+       // extra information
+       print(sprintf("Totals: %d turrets, %d settings\n", (i - 1), totalsettings));
+}
diff --git a/qcsrc/common/turrets/config.qh b/qcsrc/common/turrets/config.qh
new file mode 100644 (file)
index 0000000..85cbd20
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef TURRETS_CONFIG_H
+#define TURRETS_CONFIG_H
+
+#ifdef SVQC
+
+void Dump_Turret_Settings(void);
+float tur_config_file;
+float tur_config_alsoprint;
+
+#define MAX_TUR_CONFIG 256
+float TUR_CONFIG_COUNT;
+string tur_config_queue[MAX_TUR_CONFIG];
+
+#define TUR_CONFIG_QUEUE(a) { \
+       tur_config_queue[TUR_CONFIG_COUNT] = a; \
+       ++TUR_CONFIG_COUNT; }
+
+#define TUR_CONFIG_WRITETOFILE(a) { \
+       fputs(tur_config_file, a); \
+       if(tur_config_alsoprint) { print(a); } }
+
+#define TUR_CONFIG_WRITE_CVARS(turret,name) \
+               { TUR_CONFIG_QUEUE( \
+                       sprintf("set g_turrets_unit_%s_%s %g\n", #turret, #name, \
+                       cvar(sprintf("g_turrets_unit_%s_%s", #turret, #name)))) } \
+
+#define TUR_CONFIG_SETTINGS(tursettings) \
+       #define TUR_ADD_CVAR(turret,name) TUR_CONFIG_WRITE_CVARS(turret,name) \
+       tursettings \
+       #undef TUR_ADD_CVAR
+
+#endif
+
+#endif
diff --git a/qcsrc/common/turrets/sv_turrets.qc b/qcsrc/common/turrets/sv_turrets.qc
new file mode 100644 (file)
index 0000000..fa5318d
--- /dev/null
@@ -0,0 +1,1394 @@
+#ifdef SVQC
+#include "../../server/autocvars.qh"
+
+// Generic aiming
+vector turret_aim_generic()
+{
+
+       vector pre_pos, prep;
+       float distance, impact_time = 0, i, mintime;
+
+       turret_tag_fire_update();
+
+       if(self.aim_flags & TFL_AIM_SIMPLE)
+               return real_origin(self.enemy);
+
+       mintime = max(self.attack_finished_single - time,0) + sys_frametime;
+
+       // Baseline
+       pre_pos = real_origin(self.enemy);
+
+       // Lead?
+       if (self.aim_flags & TFL_AIM_LEAD)
+       {
+               if (self.aim_flags & TFL_AIM_SHOTTIMECOMPENSATE)           // Need to conpensate for shot traveltime
+               {
+                       prep = pre_pos;
+
+                       distance = vlen(prep - self.tur_shotorg);
+                       impact_time = distance / self.shot_speed;
+
+                       prep = pre_pos + (self.enemy.velocity * (impact_time + mintime));
+
+                       if(self.aim_flags & TFL_AIM_ZPREDICT)
+                       if(!(self.enemy.flags & FL_ONGROUND))
+                       if(self.enemy.movetype == MOVETYPE_WALK || self.enemy.movetype == MOVETYPE_TOSS || self.enemy.movetype == MOVETYPE_BOUNCE)
+                       {
+                               float vz;
+                               prep_z = pre_pos_z;
+                               vz = self.enemy.velocity_z;
+                               for(i = 0; i < impact_time; i += sys_frametime)
+                               {
+                                       vz = vz - (autocvar_sv_gravity * sys_frametime);
+                                       prep_z = prep_z + vz * sys_frametime;
+                               }
+                       }
+                       pre_pos = prep;
+               }
+               else
+                       pre_pos = pre_pos + self.enemy.velocity * mintime;
+       }
+
+       if(self.aim_flags & TFL_AIM_SPLASH)
+       {
+               //tracebox(pre_pos + '0 0 32',self.enemy.mins,self.enemy.maxs,pre_pos -'0 0 64',MOVE_WORLDONLY,self.enemy);
+               traceline(pre_pos + '0 0 32',pre_pos -'0 0 64',MOVE_WORLDONLY,self.enemy);
+               if(trace_fraction != 1.0)
+                       pre_pos = trace_endpos;
+       }
+
+       return pre_pos;
+}
+
+float turret_targetscore_support(entity _turret,entity _target)
+{
+       float score;            // Total score
+       float s_score = 0, d_score;
+
+       if (_turret.enemy == _target) s_score = 1;
+
+       d_score = min(_turret.target_range_optimal,tvt_dist) / max(_turret.target_range_optimal,tvt_dist);
+
+       score = (d_score * _turret.target_select_rangebias) +
+                       (s_score * _turret.target_select_samebias);
+
+       return score;
+}
+
+/*
+* Generic bias aware score system.
+*/
+float turret_targetscore_generic(entity _turret, entity _target)
+{
+       float d_dist;      // Defendmode Distance
+       float score;            // Total score
+       float d_score;    // Distance score
+       float a_score;    // Angular score
+       float m_score = 0;  // missile score
+       float p_score = 0;  // player score
+       float ikr;                // ideal kill range
+
+       if (_turret.tur_defend)
+       {
+               d_dist = vlen(real_origin(_target) - _turret.tur_defend.origin);
+               ikr = vlen(_turret.origin - _turret.tur_defend.origin);
+               d_score = 1 - d_dist / _turret.target_range;
+       }
+       else
+       {
+               // Make a normlized value base on the targets distance from our optimal killzone
+               ikr = _turret.target_range_optimal;
+               d_score = min(ikr, tvt_dist) / max(ikr, tvt_dist);
+       }
+
+       a_score = 1 - tvt_thadf / _turret.aim_maxrotate;
+
+       if ((_turret.target_select_missilebias > 0) && (_target.flags & FL_PROJECTILE))
+               m_score = 1;
+
+       if ((_turret.target_select_playerbias > 0) && IS_CLIENT(_target))
+               p_score = 1;
+
+       d_score = max(d_score, 0);
+       a_score = max(a_score, 0);
+       m_score = max(m_score, 0);
+       p_score = max(p_score, 0);
+
+       score = (d_score * _turret.target_select_rangebias) +
+                       (a_score * _turret.target_select_anglebias) +
+                       (m_score * _turret.target_select_missilebias) +
+                       (p_score * _turret.target_select_playerbias);
+
+       if(_turret.target_range < vlen(_turret.tur_shotorg - real_origin(_target)))
+       {
+               //dprint("Wtf?\n");
+               score *= 0.001;
+       }
+
+#ifdef TURRET_DEBUG
+       string sd,sa,sm,sp,ss;
+       string sdt,sat,smt,spt;
+
+       sd = ftos(d_score);
+       d_score *= _turret.target_select_rangebias;
+       sdt = ftos(d_score);
+
+       //sv = ftos(v_score);
+       //v_score *= _turret.target_select_samebias;
+       //svt = ftos(v_score);
+
+       sa = ftos(a_score);
+       a_score *= _turret.target_select_anglebias;
+       sat = ftos(a_score);
+
+       sm = ftos(m_score);
+       m_score *= _turret.target_select_missilebias;
+       smt = ftos(m_score);
+
+       sp = ftos(p_score);
+       p_score *= _turret.target_select_playerbias;
+       spt = ftos(p_score);
+
+
+       ss = ftos(score);
+       bprint("^3Target scores^7 \[  ",_turret.netname, "  \] ^3for^7 \[  ", _target.netname,"  \]\n");
+       bprint("^5Range:\[  ",sd,  "  \]^2+bias:\[  ",sdt,"  \]\n");
+       bprint("^5Angle:\[  ",sa,  "  \]^2+bias:\[  ",sat,"  \]\n");
+       bprint("^5Missile:\[  ",sm,"  \]^2+bias:\[  ",smt,"  \]\n");
+       bprint("^5Player:\[  ",sp, "  \]^2+bias:\[  ",spt,"  \]\n");
+       bprint("^3Total (w/bias):\[^1",ss,"\]\n");
+
+#endif
+
+       return score;
+}
+
+// Generic damage handling
+void turret_hide()
+{
+       self.effects   |= EF_NODRAW;
+       self.nextthink = time + self.respawntime - 0.2;
+       self.think       = turret_respawn;
+}
+
+void turret_die()
+{
+       self.deadflag             = DEAD_DEAD;
+       self.tur_head.deadflag = self.deadflag;
+
+// Unsolidify and hide real parts
+       self.solid                       = SOLID_NOT;
+       self.tur_head.solid      = self.solid;
+
+       self.event_damage                 = func_null;
+       self.takedamage                  = DAMAGE_NO;
+
+       self.health                      = 0;
+
+// Go boom
+       //RadiusDamage (self,self, min(self.ammo,50),min(self.ammo,50) * 0.25,250,world,min(self.ammo,50)*5,DEATH_TURRET,world);
+
+       if(self.damage_flags & TFL_DMG_DEATH_NORESPAWN)
+       {
+               TUR_ACTION(self.turretid, TR_DEATH);
+
+               remove(self.tur_head);
+               remove(self);
+       }
+       else
+       {
+               // Setup respawn
+               self.SendFlags    |= TNSF_STATUS;
+               self.nextthink   = time + 0.2;
+               self.think               = turret_hide;
+
+               TUR_ACTION(self.turretid, TR_DEATH);
+       }
+}
+
+void turret_damage (entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector vforce)
+{
+       // Enough already!
+       if(self.deadflag == DEAD_DEAD)
+               return;
+
+       // Inactive turrets take no damage. (hm..)
+       if(!self.active)
+               return;
+
+       if(SAME_TEAM(self, attacker))
+       {
+               if(autocvar_g_friendlyfire)
+                       damage = damage * autocvar_g_friendlyfire;
+               else
+                       return;
+       }
+
+       self.health -= damage;
+
+       // thorw head slightly off aim when hit?
+       if (self.damage_flags & TFL_DMG_HEADSHAKE)
+       {
+               self.tur_head.angles_x = self.tur_head.angles_x + (-0.5 + random()) * damage;
+               self.tur_head.angles_y = self.tur_head.angles_y + (-0.5 + random()) * damage;
+
+               self.SendFlags  |= TNSF_ANG;
+       }
+
+       if (self.turret_flags & TUR_FLAG_MOVE)
+               self.velocity = self.velocity + vforce;
+
+       if (self.health <= 0)
+       {
+               self.event_damage                 = func_null;
+               self.tur_head.event_damage = func_null;
+               self.takedamage                  = DAMAGE_NO;
+               self.nextthink = time;
+               self.think = turret_die;
+       }
+
+       self.SendFlags  |= TNSF_STATUS;
+}
+
+void() turret_think;
+void turret_respawn()
+{
+       // Make sure all parts belong to the same team since
+       // this function doubles as "teamchange" function.
+       self.tur_head.team      = self.team;
+       self.effects                       &= ~EF_NODRAW;
+       self.deadflag                           = DEAD_NO;
+       self.effects                            = EF_LOWPRECISION;
+       self.solid                                      = SOLID_BBOX;
+       self.takedamage                         = DAMAGE_AIM;
+       self.event_damage                       = turret_damage;
+       self.avelocity                          = '0 0 0';
+       self.tur_head.avelocity         = self.avelocity;
+       self.tur_head.angles            = self.idle_aim;
+       self.health                                     = self.max_health;
+       self.enemy                                      = world;
+       self.volly_counter                      = self.shot_volly;
+       self.ammo                                       = self.ammo_max;
+
+       self.nextthink = time + self.ticrate;
+       self.think       = turret_think;
+
+       self.SendFlags = TNSF_FULL_UPDATE;
+
+       TUR_ACTION(self.turretid, TR_SETUP);
+}
+
+
+// Main functions
+#define cvar_base "g_turrets_unit_"
+.float clientframe;
+void turrets_setframe(float _frame, float client_only)
+{
+       if((client_only ? self.clientframe : self.frame ) != _frame)
+       {
+               self.SendFlags |= TNSF_ANIM;
+               self.anim_start_time = time;
+       }
+
+        if(client_only)
+               self.clientframe = _frame;
+       else
+               self.frame = _frame;
+
+}
+
+float turret_send(entity to, float sf)
+{
+
+       WriteByte(MSG_ENTITY, ENT_CLIENT_TURRET);
+       WriteByte(MSG_ENTITY, sf);
+       if(sf & TNSF_SETUP)
+       {
+               WriteByte(MSG_ENTITY, self.turretid);
+
+               WriteCoord(MSG_ENTITY, self.origin_x);
+               WriteCoord(MSG_ENTITY, self.origin_y);
+               WriteCoord(MSG_ENTITY, self.origin_z);
+
+               WriteAngle(MSG_ENTITY, self.angles_x);
+               WriteAngle(MSG_ENTITY, self.angles_y);
+       }
+
+       if(sf & TNSF_ANG)
+       {
+               WriteShort(MSG_ENTITY, rint(self.tur_head.angles_x));
+               WriteShort(MSG_ENTITY, rint(self.tur_head.angles_y));
+       }
+
+       if(sf & TNSF_AVEL)
+       {
+               WriteShort(MSG_ENTITY, rint(self.tur_head.avelocity_x));
+               WriteShort(MSG_ENTITY, rint(self.tur_head.avelocity_y));
+       }
+
+       if(sf & TNSF_MOVE)
+       {
+               WriteShort(MSG_ENTITY, rint(self.origin_x));
+               WriteShort(MSG_ENTITY, rint(self.origin_y));
+               WriteShort(MSG_ENTITY, rint(self.origin_z));
+
+               WriteShort(MSG_ENTITY, rint(self.velocity_x));
+               WriteShort(MSG_ENTITY, rint(self.velocity_y));
+               WriteShort(MSG_ENTITY, rint(self.velocity_z));
+
+               WriteShort(MSG_ENTITY, rint(self.angles_y));
+       }
+
+       if(sf & TNSF_ANIM)
+       {
+               WriteCoord(MSG_ENTITY, self.anim_start_time);
+               WriteByte(MSG_ENTITY, self.frame);
+       }
+
+       if(sf & TNSF_STATUS)
+       {
+               WriteByte(MSG_ENTITY, self.team);
+
+               if(self.health <= 0)
+                       WriteByte(MSG_ENTITY, 0);
+               else
+                       WriteByte(MSG_ENTITY, ceil((self.health / self.max_health) * 255));
+       }
+
+       return true;
+}
+
+void load_unit_settings(entity ent, string unitname, float is_reload)
+{
+       string sbase;
+
+       if (ent == world)
+               return;
+
+       if(!ent.turret_scale_damage)    ent.turret_scale_damage = 1;
+       if(!ent.turret_scale_range)             ent.turret_scale_range  = 1;
+       if(!ent.turret_scale_refire)    ent.turret_scale_refire = 1;
+       if(!ent.turret_scale_ammo)              ent.turret_scale_ammo   = 1;
+       if(!ent.turret_scale_aim)               ent.turret_scale_aim     = 1;
+       if(!ent.turret_scale_health)    ent.turret_scale_health = 1;
+       if(!ent.turret_scale_respawn)   ent.turret_scale_respawn = 1;
+
+       sbase = strcat(cvar_base,unitname);
+       if (is_reload)
+       {
+               ent.enemy = world;
+               ent.tur_head.avelocity = '0 0 0';
+
+               ent.tur_head.angles = '0 0 0';
+       }
+
+       ent.health       = cvar(strcat(sbase,"_health")) * ent.turret_scale_health;
+       ent.respawntime = cvar(strcat(sbase,"_respawntime")) * ent.turret_scale_respawn;
+
+       ent.shot_dmg             = cvar(strcat(sbase,"_shot_dmg")) * ent.turret_scale_damage;
+       ent.shot_refire   = cvar(strcat(sbase,"_shot_refire")) * ent.turret_scale_refire;
+       ent.shot_radius   = cvar(strcat(sbase,"_shot_radius")) * ent.turret_scale_damage;
+       ent.shot_speed          = cvar(strcat(sbase,"_shot_speed"));
+       ent.shot_spread   = cvar(strcat(sbase,"_shot_spread"));
+       ent.shot_force          = cvar(strcat(sbase,"_shot_force")) * ent.turret_scale_damage;
+       ent.shot_volly          = cvar(strcat(sbase,"_shot_volly"));
+       ent.shot_volly_refire = cvar(strcat(sbase,"_shot_volly_refire")) * ent.turret_scale_refire;
+
+       ent.target_range                 = cvar(strcat(sbase,"_target_range")) * ent.turret_scale_range;
+       ent.target_range_min     = cvar(strcat(sbase,"_target_range_min")) * ent.turret_scale_range;
+       ent.target_range_optimal = cvar(strcat(sbase,"_target_range_optimal")) * ent.turret_scale_range;
+       //ent.target_range_fire = cvar(strcat(sbase,"_target_range_fire")) * ent.turret_scale_range;
+
+       ent.target_select_rangebias = cvar(strcat(sbase,"_target_select_rangebias"));
+       ent.target_select_samebias  = cvar(strcat(sbase,"_target_select_samebias"));
+       ent.target_select_anglebias = cvar(strcat(sbase,"_target_select_anglebias"));
+       ent.target_select_playerbias = cvar(strcat(sbase,"_target_select_playerbias"));
+       //ent.target_select_fov = cvar(cvar_gets(sbase,"_target_select_fov"));
+
+       ent.ammo_max     = cvar(strcat(sbase,"_ammo_max")) * ent.turret_scale_ammo;
+       ent.ammo_recharge = cvar(strcat(sbase,"_ammo_recharge")) * ent.turret_scale_ammo;
+
+       ent.aim_firetolerance_dist = cvar(strcat(sbase,"_aim_firetolerance_dist"));
+       ent.aim_speed   = cvar(strcat(sbase,"_aim_speed")) * ent.turret_scale_aim;
+       ent.aim_maxrotate  = cvar(strcat(sbase,"_aim_maxrot"));
+       ent.aim_maxpitch = cvar(strcat(sbase,"_aim_maxpitch"));
+
+       ent.track_type          = cvar(strcat(sbase,"_track_type"));
+       ent.track_accel_pitch = cvar(strcat(sbase,"_track_accel_pitch"));
+       ent.track_accel_rotate  = cvar(strcat(sbase,"_track_accel_rot"));
+       ent.track_blendrate  = cvar(strcat(sbase,"_track_blendrate"));
+
+       if(is_reload)
+               TUR_ACTION(self.turretid, TR_SETUP);
+}
+
+void turret_projectile_explode()
+{
+
+       self.takedamage = DAMAGE_NO;
+       self.event_damage = func_null;
+#ifdef TURRET_DEBUG
+       float d;
+       d = RadiusDamage (self, self.owner, self.owner.shot_dmg, 0, self.owner.shot_radius, self, world, self.owner.shot_force, self.totalfrags, world);
+       self.owner.tur_debug_dmg_t_h = self.owner.tur_debug_dmg_t_h + d;
+       self.owner.tur_debug_dmg_t_f = self.owner.tur_debug_dmg_t_f + self.owner.shot_dmg;
+#else
+       RadiusDamage (self, self.realowner, self.owner.shot_dmg, 0, self.owner.shot_radius, self, world, self.owner.shot_force, self.totalfrags, world);
+#endif
+       remove(self);
+}
+
+void turret_projectile_touch()
+{
+       PROJECTILE_TOUCH;
+       turret_projectile_explode();
+}
+
+void turret_projectile_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector vforce)
+{
+       self.velocity  += vforce;
+       self.health     -= damage;
+       //self.realowner = attacker; // Dont change realowner, it does not make much sense for turrets
+       if(self.health <= 0)
+               W_PrepareExplosionByDamage(self.owner, turret_projectile_explode);
+}
+
+entity turret_projectile(string _snd, float _size, float _health, float _death, float _proj_type, float _cull, float _cli_anim)
+{
+       entity proj;
+
+       sound (self, CH_WEAPON_A, _snd, VOL_BASE, ATTEN_NORM);
+       proj                             = spawn ();
+       setorigin(proj, self.tur_shotorg);
+       setsize(proj, '-0.5 -0.5 -0.5' * _size, '0.5 0.5 0.5' * _size);
+       proj.owner                = self;
+       proj.realowner    = self;
+       proj.bot_dodge    = true;
+       proj.bot_dodgerating = self.shot_dmg;
+       proj.think                = turret_projectile_explode;
+       proj.touch                = turret_projectile_touch;
+       proj.nextthink    = time + 9;
+       proj.movetype           = MOVETYPE_FLYMISSILE;
+       proj.velocity           = normalize(self.tur_shotdir_updated + randomvec() * self.shot_spread) * self.shot_speed;
+       proj.flags                = FL_PROJECTILE;
+       proj.enemy                = self.enemy;
+       proj.totalfrags  = _death;
+       PROJECTILE_MAKETRIGGER(proj);
+       if(_health)
+       {
+               proj.health              = _health;
+               proj.takedamage  = DAMAGE_YES;
+               proj.event_damage  = turret_projectile_damage;
+       }
+       else
+               proj.flags |= FL_NOTARGET;
+
+       CSQCProjectile(proj, _cli_anim, _proj_type, _cull);
+
+       return proj;
+}
+
+/**
+** updates enemy distances, predicted impact point/time
+** and updated aim<->predict impact distance.
+**/
+void turret_do_updates(entity t_turret)
+{
+       vector enemy_pos;
+       entity oldself;
+
+       oldself = self;
+       self = t_turret;
+
+       enemy_pos = real_origin(self.enemy);
+
+       turret_tag_fire_update();
+
+       self.tur_shotdir_updated = v_forward;
+       self.tur_dist_enemy = vlen(self.tur_shotorg - enemy_pos);
+       self.tur_dist_aimpos = vlen(self.tur_shotorg - self.tur_aimpos);
+
+       /*if((self.firecheck_flags & TFL_FIRECHECK_VERIFIED) && (self.enemy))
+       {
+               oldpos = self.enemy.origin;
+               setorigin(self.enemy, self.tur_aimpos);
+               tracebox(self.tur_shotorg, '-1 -1 -1', '1 1 1', self.tur_shotorg + (self.tur_shotdir_updated * self.tur_dist_aimpos), MOVE_NORMAL,self);
+               setorigin(self.enemy, oldpos);
+
+               if(trace_ent == self.enemy)
+                       self.tur_dist_impact_to_aimpos = 0;
+               else
+                       self.tur_dist_impact_to_aimpos = vlen(trace_endpos - self.tur_aimpos);
+       }
+       else*/
+               tracebox(self.tur_shotorg, '-1 -1 -1','1 1 1', self.tur_shotorg + (self.tur_shotdir_updated * self.tur_dist_aimpos), MOVE_NORMAL,self);
+
+       self.tur_dist_impact_to_aimpos = vlen(trace_endpos - self.tur_aimpos) - (vlen(self.enemy.maxs - self.enemy.mins) * 0.5);
+       self.tur_impactent                       = trace_ent;
+       self.tur_impacttime                     = vlen(self.tur_shotorg - trace_endpos) / self.shot_speed;
+
+       self = oldself;
+}
+
+/**
+** Handles head rotation according to
+** the units .track_type and .track_flags
+**/
+.float turret_framecounter;
+void turret_track()
+{
+       vector target_angle; // This is where we want to aim
+       vector move_angle;   // This is where we can aim
+       float f_tmp;
+       vector v1, v2;
+       v1 = self.tur_head.angles;
+       v2 = self.tur_head.avelocity;
+
+       if (self.track_flags == TFL_TRACK_NO)
+               return;
+
+       if(!self.active)
+               target_angle = self.idle_aim - ('1 0 0' * self.aim_maxpitch);
+       else if (self.enemy == world)
+       {
+               if(time > self.lip)
+                       target_angle = self.idle_aim + self.angles;
+               else
+                       target_angle = vectoangles(normalize(self.tur_aimpos - self.tur_shotorg));
+       }
+       else
+       {
+               target_angle = vectoangles(normalize(self.tur_aimpos - self.tur_shotorg));
+       }
+
+       self.tur_head.angles_x = anglemods(self.tur_head.angles_x);
+       self.tur_head.angles_y = anglemods(self.tur_head.angles_y);
+
+       // Find the diffrence between where we currently aim and where we want to aim
+       //move_angle = target_angle - (self.angles + self.tur_head.angles);
+       //move_angle = shortangle_vxy(move_angle,(self.angles + self.tur_head.angles));
+
+       move_angle = AnglesTransform_ToAngles(AnglesTransform_LeftDivide(AnglesTransform_FromAngles(self.angles), AnglesTransform_FromAngles(target_angle))) - self.tur_head.angles;
+       move_angle = shortangle_vxy(move_angle, self.tur_head.angles);
+
+       switch(self.track_type)
+       {
+               case TFL_TRACKTYPE_STEPMOTOR:
+                       f_tmp = self.aim_speed * self.ticrate; // dgr/sec -> dgr/tic
+                       if (self.track_flags & TFL_TRACK_PITCH)
+                       {
+                               self.tur_head.angles_x += bound(-f_tmp,move_angle_x, f_tmp);
+                               if(self.tur_head.angles_x > self.aim_maxpitch)
+                                       self.tur_head.angles_x = self.aim_maxpitch;
+
+                               if(self.tur_head.angles_x  < -self.aim_maxpitch)
+                                       self.tur_head.angles_x = self.aim_maxpitch;
+                       }
+
+                       if (self.track_flags & TFL_TRACK_ROTATE)
+                       {
+                               self.tur_head.angles_y += bound(-f_tmp, move_angle_y, f_tmp);
+                               if(self.tur_head.angles_y > self.aim_maxrotate)
+                                       self.tur_head.angles_y = self.aim_maxrotate;
+
+                               if(self.tur_head.angles_y  < -self.aim_maxrotate)
+                                       self.tur_head.angles_y = self.aim_maxrotate;
+                       }
+
+                       // CSQC
+                       self.SendFlags  |= TNSF_ANG;
+
+                       return;
+
+               case TFL_TRACKTYPE_FLUIDINERTIA:
+                       f_tmp = self.aim_speed * self.ticrate; // dgr/sec -> dgr/tic
+                       move_angle_x = bound(-self.aim_speed, move_angle_x * self.track_accel_pitch * f_tmp, self.aim_speed);
+                       move_angle_y = bound(-self.aim_speed, move_angle_y * self.track_accel_rotate * f_tmp, self.aim_speed);
+                       move_angle = (self.tur_head.avelocity * self.track_blendrate) + (move_angle * (1 - self.track_blendrate));
+                       break;
+
+               case TFL_TRACKTYPE_FLUIDPRECISE:
+
+                       move_angle_y = bound(-self.aim_speed, move_angle_y, self.aim_speed);
+                       move_angle_x = bound(-self.aim_speed, move_angle_x, self.aim_speed);
+
+                       break;
+       }
+
+       //  pitch
+       if (self.track_flags & TFL_TRACK_PITCH)
+       {
+               self.tur_head.avelocity_x = move_angle_x;
+               if((self.tur_head.angles_x + self.tur_head.avelocity_x * self.ticrate) > self.aim_maxpitch)
+               {
+                       self.tur_head.avelocity_x = 0;
+                       self.tur_head.angles_x = self.aim_maxpitch;
+
+                       self.SendFlags  |= TNSF_ANG;
+               }
+
+               if((self.tur_head.angles_x + self.tur_head.avelocity_x * self.ticrate) < -self.aim_maxpitch)
+               {
+                       self.tur_head.avelocity_x = 0;
+                       self.tur_head.angles_x = -self.aim_maxpitch;
+
+                       self.SendFlags  |= TNSF_ANG;
+               }
+       }
+
+       //  rot
+       if (self.track_flags & TFL_TRACK_ROTATE)
+       {
+               self.tur_head.avelocity_y = move_angle_y;
+
+               if((self.tur_head.angles_y + self.tur_head.avelocity_y * self.ticrate) > self.aim_maxrotate)
+               {
+                       self.tur_head.avelocity_y = 0;
+                       self.tur_head.angles_y = self.aim_maxrotate;
+
+                       self.SendFlags  |= TNSF_ANG;
+               }
+
+               if((self.tur_head.angles_y + self.tur_head.avelocity_y * self.ticrate) < -self.aim_maxrotate)
+               {
+                       self.tur_head.avelocity_y = 0;
+                       self.tur_head.angles_y = -self.aim_maxrotate;
+
+                       self.SendFlags  |= TNSF_ANG;
+               }
+       }
+
+       self.SendFlags  |= TNSF_AVEL;
+
+       // Force a angle update every 10'th frame
+       self.turret_framecounter += 1;
+       if(self.turret_framecounter >= 10)
+       {
+               self.SendFlags |= TNSF_ANG;
+               self.turret_framecounter = 0;
+       }
+}
+
+/*
+ + TFL_TARGETSELECT_NO
+ + TFL_TARGETSELECT_LOS
+ + TFL_TARGETSELECT_PLAYERS
+ + TFL_TARGETSELECT_MISSILES
+ - TFL_TARGETSELECT_TRIGGERTARGET
+ + TFL_TARGETSELECT_ANGLELIMITS
+ + TFL_TARGETSELECT_RANGELIMITS
+ + TFL_TARGETSELECT_TEAMCHECK
+ - TFL_TARGETSELECT_NOBUILTIN
+ + TFL_TARGETSELECT_OWNTEAM
+*/
+
+/**
+** Evaluate a entity for target valitity based on validate_flags
+** NOTE: the caller must check takedamage before calling this, to inline this check.
+**/
+float turret_validate_target(entity e_turret, entity e_target, float validate_flags)
+{
+       vector v_tmp;
+
+       //if(!validate_flags & TFL_TARGETSELECT_NOBUILTIN)
+       //      return -0.5;
+
+       if(!e_target)
+               return -2;
+
+       if(e_target.owner == e_turret)
+               return -0.5;
+
+       if(!checkpvs(e_target.origin, e_turret))
+               return -1;
+
+       if(e_target.alpha <= 0.3)
+               return -1;
+
+       if(g_onslaught)
+               if (substring(e_target.classname, 0, 10) == "onslaught_") // don't attack onslaught targets, that's the player's job!
+                       return - 3;
+
+       if (validate_flags & TFL_TARGETSELECT_NO)
+               return -4;
+
+       // If only this was used more..
+       if (e_target.flags & FL_NOTARGET)
+               return -5;
+
+       // Cant touch this
+       if(IS_VEHICLE(e_target))
+       {
+               if (e_target.vehicle_health <= 0)
+                       return -6;
+       }
+       else if (e_target.health <= 0)
+               return -6;
+       else if(e_target.frozen > 0)
+               return -6;
+
+       // player
+       if (IS_CLIENT(e_target))
+       {
+               if(!(validate_flags & TFL_TARGETSELECT_PLAYERS))
+                       return -7;
+
+               if (e_target.deadflag != DEAD_NO)
+                       return -8;
+       }
+
+       // enemy turrets
+       if(validate_flags & TFL_TARGETSELECT_NOTURRETS)
+       if(e_target.owner.tur_head == e_target)
+       if(e_target.team != e_turret.team) // Dont break support units.
+               return -9;
+
+       // Missile
+       if (e_target.flags & FL_PROJECTILE)
+       if(!(validate_flags & TFL_TARGETSELECT_MISSILES))
+               return -10;
+
+       if (validate_flags & TFL_TARGETSELECT_MISSILESONLY)
+       if(!(e_target.flags & FL_PROJECTILE))
+               return -10.5;
+
+       // Team check
+       if (validate_flags & TFL_TARGETSELECT_TEAMCHECK)
+       {
+               if (validate_flags & TFL_TARGETSELECT_OWNTEAM)
+               {
+                       if (e_target.team != e_turret.team)
+                               return -11;
+
+                       if (e_turret.team != e_target.owner.team)
+                               return -12;
+               }
+               else
+               {
+                       if (e_target.team == e_turret.team)
+                               return -13;
+
+                       if (e_turret.team == e_target.owner.team)
+                               return -14;
+               }
+       }
+
+       // Range limits?
+       tvt_dist = vlen(e_turret.origin - real_origin(e_target));
+       if (validate_flags & TFL_TARGETSELECT_RANGELIMITS)
+       {
+               if (tvt_dist < e_turret.target_range_min)
+                       return -15;
+
+               if (tvt_dist > e_turret.target_range)
+                       return -16;
+       }
+
+       // Can we even aim this thing?
+       tvt_thadv = angleofs3(e_turret.tur_head.origin, e_turret.angles + e_turret.tur_head.angles, e_target);
+       tvt_tadv = shortangle_vxy(angleofs(e_turret, e_target), e_turret.angles);
+       tvt_thadf = vlen(tvt_thadv);
+       tvt_tadf = vlen(tvt_tadv);
+
+       /*
+       if(validate_flags & TFL_TARGETSELECT_FOV)
+       {
+               if(e_turret.target_select_fov < tvt_thadf)
+                       return -21;
+       }
+       */
+
+       if (validate_flags & TFL_TARGETSELECT_ANGLELIMITS)
+       {
+               if (fabs(tvt_tadv_x) > e_turret.aim_maxpitch)
+                       return -17;
+
+               if (fabs(tvt_tadv_y) > e_turret.aim_maxrotate)
+                       return -18;
+       }
+
+       // Line of sight?
+       if (validate_flags & TFL_TARGETSELECT_LOS)
+       {
+               v_tmp = real_origin(e_target) + ((e_target.mins + e_target.maxs) * 0.5);
+
+               traceline(e_turret.origin + '0 0 16', v_tmp, 0, e_turret);
+
+               if (e_turret.aim_firetolerance_dist < vlen(v_tmp - trace_endpos))
+                       return -19;
+       }
+
+       if (e_target.classname == "grapplinghook")
+               return -20;
+
+       /*
+       if (e_target.classname == "func_button")
+               return -21;
+       */
+
+#ifdef TURRET_DEBUG_TARGETSELECT
+       dprint("Target:",e_target.netname," is a valid target for ",e_turret.netname,"\n");
+#endif
+
+       return 1;
+}
+
+entity turret_select_target()
+{
+       entity e;               // target looper entity
+       float  score;   // target looper entity score
+       entity e_enemy;  // currently best scoreing target
+       float  m_score;  // currently best scoreing target's score
+
+       m_score = 0;
+       if(self.enemy && self.enemy.takedamage && turret_validate_target(self,self.enemy,self.target_validate_flags) > 0)
+       {
+               e_enemy = self.enemy;
+               m_score = self.turret_score_target(self,e_enemy) * self.target_select_samebias;
+       }
+       else
+               e_enemy = self.enemy = world;
+
+       e = findradius(self.origin, self.target_range);
+
+       // Nothing to aim at?
+       if (!e)
+               return world;
+
+       while (e)
+       {
+               if(e.takedamage)
+               {
+                       float f = turret_validate_target(self, e, self.target_select_flags);
+                       //dprint("F is: ", ftos(f), "\n");
+                       if ( f > 0)
+                       {
+                               score = self.turret_score_target(self,e);
+                               if ((score > m_score) && (score > 0))
+                               {
+                                       e_enemy = e;
+                                       m_score = score;
+                               }
+                       }
+               }
+               e = e.chain;
+       }
+
+       return e_enemy;
+}
+
+
+/*
+ + = implemented
+ - = not implemented
+
+ + TFL_FIRECHECK_NO
+ + TFL_FIRECHECK_WORLD
+ + TFL_FIRECHECK_DEAD
+ + TFL_FIRECHECK_DISTANCES
+ - TFL_FIRECHECK_LOS
+ + TFL_FIRECHECK_AIMDIST
+ + TFL_FIRECHECK_REALDIST
+ - TFL_FIRECHECK_ANGLEDIST
+ - TFL_FIRECHECK_TEAMCECK
+ + TFL_FIRECHECK_AFF
+ + TFL_FIRECHECK_AMMO_OWN
+ + TFL_FIRECHECK_AMMO_OTHER
+ + TFL_FIRECHECK_REFIRE
+*/
+
+/**
+** Preforms pre-fire checks based on the uints firecheck_flags
+**/
+float turret_firecheck()
+{
+       // This one just dont care =)
+       if (self.firecheck_flags & TFL_FIRECHECK_NO)
+               return 1;
+
+       if (self.enemy == world)
+               return 0;
+
+       // Ready?
+       if (self.firecheck_flags & TFL_FIRECHECK_REFIRE)
+               if (self.attack_finished_single > time) return 0;
+
+       // Special case: volly fire turret that has to fire a full volly if a shot was fired.
+       if (self.shoot_flags & TFL_SHOOT_VOLLYALWAYS)
+               if (self.volly_counter != self.shot_volly)
+                       if(self.ammo >= self.shot_dmg)
+                               return 1;
+
+       // Lack of zombies makes shooting dead things unnecessary :P
+       if (self.firecheck_flags & TFL_FIRECHECK_DEAD)
+               if (self.enemy.deadflag != DEAD_NO)
+                       return 0;
+
+       // Own ammo?
+       if (self.firecheck_flags & TFL_FIRECHECK_AMMO_OWN)
+               if (self.ammo < self.shot_dmg)
+                       return 0;
+
+       // Other's ammo? (support-supply units)
+       if (self.firecheck_flags & TFL_FIRECHECK_AMMO_OTHER)
+               if (self.enemy.ammo >= self.enemy.ammo_max)
+                       return 0;
+
+       // Target of opertunity?
+       if(turret_validate_target(self, self.tur_impactent, self.target_validate_flags) > 0)
+       {
+               self.enemy = self.tur_impactent;
+               return 1;
+       }
+
+       if (self.firecheck_flags & TFL_FIRECHECK_DISTANCES)
+       {
+               // To close?
+               if (self.tur_dist_aimpos < self.target_range_min)
+                       if(turret_validate_target(self, self.tur_impactent, self.target_validate_flags) > 0)
+                               return 1; // Target of opertunity?
+                       else
+                               return 0;
+       }
+
+       // Try to avoid FF?
+       if (self.firecheck_flags & TFL_FIRECHECK_AFF)
+               if (self.tur_impactent.team == self.team)
+                       return 0;
+
+       // aim<->predicted impact
+       if (self.firecheck_flags & TFL_FIRECHECK_AIMDIST)
+               if (self.tur_dist_impact_to_aimpos > self.aim_firetolerance_dist)
+                       return 0;
+
+       // Volly status
+       if (self.shot_volly > 1)
+               if (self.volly_counter == self.shot_volly)
+                       if (self.ammo < (self.shot_dmg * self.shot_volly))
+                               return 0;
+
+       /*if(self.firecheck_flags & TFL_FIRECHECK_VERIFIED)
+               if(self.tur_impactent != self.enemy)
+                       return 0;*/
+
+       return 1;
+}
+
+void turret_fire()
+{
+       if (autocvar_g_turrets_nofire != 0)
+               return;
+
+       TUR_ACTION(self.turretid, TR_ATTACK);
+
+       self.attack_finished_single = time + self.shot_refire;
+       self.ammo -= self.shot_dmg;
+       self.volly_counter = self.volly_counter - 1;
+
+       if (self.volly_counter <= 0)
+       {
+               self.volly_counter = self.shot_volly;
+
+               if (self.shoot_flags & TFL_SHOOT_CLEARTARGET)
+                       self.enemy = world;
+
+               if (self.shot_volly > 1)
+                       self.attack_finished_single = time + self.shot_volly_refire;
+       }
+
+#ifdef TURRET_DEBUG
+       if (self.enemy) paint_target3(self.tur_aimpos, 64, self.tur_debug_rvec, self.tur_impacttime + 0.25);
+#endif
+}
+
+void turret_think()
+{
+       entity e;
+
+       self.nextthink = time + self.ticrate;
+
+       // ONS uses somewhat backwards linking.
+       if (teamplay)
+       {
+               if (g_onslaught)
+                       if (self.target)
+                       {
+                               e = find(world, targetname,self.target);
+                               if (e != world)
+                                       self.team = e.team;
+                       }
+
+               if (self.team != self.tur_head.team)
+                       turret_respawn();
+       }
+
+#ifdef TURRET_DEBUG
+       if (self.tur_debug_tmr1 < time)
+       {
+               if (self.enemy) paint_target (self.enemy,128,self.tur_debug_rvec,0.9);
+               paint_target(self,256,self.tur_debug_rvec,0.9);
+               self.tur_debug_tmr1 = time + 1;
+       }
+#endif
+
+       // Handle ammo
+       if (!(self.spawnflags & TSF_NO_AMMO_REGEN))
+       if (self.ammo < self.ammo_max)
+               self.ammo = min(self.ammo + self.ammo_recharge, self.ammo_max);
+
+       // Inactive turrets needs to run the think loop,
+       // So they can handle animation and wake up if need be.
+       if(!self.active)
+       {
+               turret_track();
+               return;
+       }
+
+       // This is typicaly used for zaping every target in range
+       // turret_fusionreactor uses this to recharge friendlys.
+       if (self.shoot_flags & TFL_SHOOT_HITALLVALID)
+       {
+               // Do a self.turret_fire for every valid target.
+               e = findradius(self.origin,self.target_range);
+               while (e)
+               {
+                       if(e.takedamage)
+                       {
+                               if (turret_validate_target(self,e,self.target_validate_flags))
+                               {
+                                       self.enemy = e;
+
+                                       turret_do_updates(self);
+
+                                       if (self.turret_firecheckfunc())
+                                               turret_fire();
+                               }
+                       }
+
+                       e = e.chain;
+               }
+               self.enemy = world;
+       }
+       else if(self.shoot_flags & TFL_SHOOT_CUSTOM)
+       {
+               // This one is doing something.. oddball. assume its handles what needs to be handled.
+
+               // Predict?
+               if(!(self.aim_flags & TFL_AIM_NO))
+                       self.tur_aimpos = turret_aim_generic();
+
+               // Turn & pitch?
+               if(!(self.track_flags & TFL_TRACK_NO))
+                       turret_track();
+
+               turret_do_updates(self);
+
+               // Fire?
+               if (self.turret_firecheckfunc())
+                       turret_fire();
+       }
+       else
+       {
+               // Special case for volly always. if it fired once it must compleate the volly.
+               if(self.shoot_flags & TFL_SHOOT_VOLLYALWAYS)
+                       if(self.volly_counter != self.shot_volly)
+                       {
+                               // Predict or whatnot
+                               if(!(self.aim_flags & TFL_AIM_NO))
+                                       self.tur_aimpos = turret_aim_generic();
+
+                               // Turn & pitch
+                               if(!(self.track_flags & TFL_TRACK_NO))
+                                       turret_track();
+
+                               turret_do_updates(self);
+
+                               // Fire!
+                               if (self.turret_firecheckfunc() != 0)
+                                       turret_fire();
+
+                               TUR_ACTION(self.turretid, TR_THINK);
+
+                               return;
+                       }
+
+               // Check if we have a vailid enemy, and try to find one if we dont.
+
+               // g_turrets_targetscan_maxdelay forces a target re-scan at least this often
+               float do_target_scan = 0;
+               if((self.target_select_time + autocvar_g_turrets_targetscan_maxdelay) < time)
+                       do_target_scan = 1;
+
+               // Old target (if any) invalid?
+               if(self.target_validate_time < time)
+               if (turret_validate_target(self, self.enemy, self.target_validate_flags) <= 0)
+               {
+                       self.enemy = world;
+                       self.target_validate_time = time + 0.5;
+                       do_target_scan = 1;
+               }
+
+               // But never more often then g_turrets_targetscan_mindelay!
+               if (self.target_select_time + autocvar_g_turrets_targetscan_mindelay > time)
+                       do_target_scan = 0;
+
+               if(do_target_scan)
+               {
+                       self.enemy = turret_select_target();
+                       self.target_select_time = time;
+               }
+
+               // No target, just go to idle, do any custom stuff and bail.
+               if (self.enemy == world)
+               {
+                       // Turn & pitch
+                       if(!(self.track_flags & TFL_TRACK_NO))
+                               turret_track();
+
+                       TUR_ACTION(self.turretid, TR_THINK);
+
+                       // And bail.
+                       return;
+               }
+               else
+                       self.lip = time + autocvar_g_turrets_aimidle_delay; // Keep track of the last time we had a target.
+
+               // Predict?
+               if(!(self.aim_flags & TFL_AIM_NO))
+                       self.tur_aimpos = turret_aim_generic();
+
+               // Turn & pitch?
+               if(!(self.track_flags & TFL_TRACK_NO))
+                       turret_track();
+
+               turret_do_updates(self);
+
+               // Fire?
+               if (self.turret_firecheckfunc())
+                       turret_fire();
+       }
+
+       TUR_ACTION(self.turretid, TR_THINK);
+}
+
+/*
+       When .used a turret switch team to activator.team.
+       If activator is world, the turret go inactive.
+*/
+void turret_use()
+{
+       dprint("Turret ",self.netname, " used by ", activator.classname, "\n");
+
+       self.team = activator.team;
+
+       if(self.team == 0)
+               self.active = ACTIVE_NOT;
+       else
+               self.active = ACTIVE_ACTIVE;
+
+}
+
+void turret_link()
+{
+       Net_LinkEntity(self, true, 0, turret_send);
+       self.think       = turret_think;
+       self.nextthink = time;
+       self.tur_head.effects = EF_NODRAW;
+}
+
+void turrets_manager_think()
+{
+       self.nextthink = time + 1;
+
+       entity e;
+       if (autocvar_g_turrets_reloadcvars == 1)
+       {
+               e = nextent(world);
+               while (e)
+               {
+                       if (IS_TURRET(e))
+                       {
+                               load_unit_settings(e,e.cvar_basename,1);
+                               TUR_ACTION(self.turretid, TR_THINK);
+                       }
+
+                       e = nextent(e);
+               }
+               cvar_set("g_turrets_reloadcvars","0");
+       }
+}
+
+float turret_initialize(float tur_id)
+{
+       if(!autocvar_g_turrets)
+               return false;
+
+       entity e;
+       entity tur = get_turretinfo(tur_id);
+       if(tur.turretid == 0)
+               return false; // invalid turret
+
+       if(!self.tur_head) { TUR_ACTION(tur_id, TR_PRECACHE); } // if tur_head exists, we can assume this turret re-spawned
+
+       e = find(world, classname, "turret_manager");
+       if(!e)
+       {
+               e = spawn();
+               e.classname = "turret_manager";
+               e.think = turrets_manager_think;
+               e.nextthink = time + 2;
+       }
+
+       if(!(self.spawnflags & TSF_SUSPENDED))
+               builtin_droptofloor();
+
+       self.cvar_basename = tur.cvar_basename;
+       load_unit_settings(self, self.cvar_basename, 0);
+
+       if(!self.team || !teamplay)             { self.team = MAX_SHOT_DISTANCE; }
+       if(!self.ticrate)                               { self.ticrate = ((self.turret_flags & TUR_FLAG_SUPPORT) ? 0.2 : 0.1); }
+       if(!self.health)                                { self.health = 1000; }
+       if(!self.shot_refire)                   { self.shot_refire = 1; }
+       if(!self.tur_shotorg)                   { self.tur_shotorg = '50 0 50'; }
+       if(!self.turret_flags)                  { self.turret_flags = TUR_FLAG_SPLASH | TUR_FLAG_MEDPROJ | TUR_FLAG_PLAYER; }
+       if(!self.damage_flags)                  { self.damage_flags = TFL_DMG_YES | TFL_DMG_RETALIATE | TFL_DMG_AIMSHAKE; }
+       if(!self.aim_flags)                             { self.aim_flags = TFL_AIM_LEAD | TFL_AIM_SHOTTIMECOMPENSATE; }
+       if(!self.track_type)                    { self.track_type = TFL_TRACKTYPE_STEPMOTOR; }
+       if(!self.track_flags)                   { self.track_flags = TFL_TRACK_PITCH | TFL_TRACK_ROTATE; }
+       if(!self.ammo_flags)                    { self.ammo_flags = TFL_AMMO_ENERGY | TFL_AMMO_RECHARGE; }
+       if(!self.target_select_flags)   { self.target_select_flags = TFL_TARGETSELECT_LOS | TFL_TARGETSELECT_TEAMCHECK | TFL_TARGETSELECT_RANGELIMITS | TFL_TARGETSELECT_ANGLELIMITS; }
+       if(!self.firecheck_flags)               { self.firecheck_flags = TFL_FIRECHECK_DEAD | TFL_FIRECHECK_DISTANCES | TFL_FIRECHECK_LOS
+                                                                                                                  | TFL_FIRECHECK_AIMDIST | TFL_FIRECHECK_TEAMCHECK | TFL_FIRECHECK_AMMO_OWN | TFL_FIRECHECK_REFIRE; }
+
+       if(self.track_type != TFL_TRACKTYPE_STEPMOTOR)
+       {
+               // Fluid / Ineria mode. Looks mutch nicer.
+               // Can reduce aim preformance alot, needs a bit diffrent aimspeed
+
+               self.aim_speed = bound(0.1, ((!self.aim_speed) ? 180 : self.aim_speed), 1000);
+
+               if(!self.track_accel_pitch)             { self.track_accel_pitch = 0.5; }
+               if(!self.track_accel_rotate)    { self.track_accel_rotate = 0.5; }
+               if(!self.track_blendrate)               { self.track_blendrate = 0.35; }
+       }
+
+       self.respawntime                                = max(-1, ((!self.respawntime) ? 60 : self.respawntime));
+       self.shot_refire                                = bound(0.01, ((!self.shot_refire) ? 1 : self.shot_refire), 9999);
+       self.shot_dmg                                   = max(1, ((!self.shot_dmg) ? self.shot_refire * 50 : self.shot_dmg));
+       self.shot_radius                                = max(1, ((!self.shot_radius) ? self.shot_dmg * 0.5 : self.shot_radius));
+       self.shot_speed                                 = max(1, ((!self.shot_speed) ? 2500 : self.shot_speed));
+       self.shot_spread                                = bound(0.0001, ((!self.shot_spread) ? 0.0125 : self.shot_spread), 500);
+       self.shot_force                                 = bound(0.001, ((!self.shot_force) ? self.shot_dmg * 0.5 + self.shot_radius * 0.5 : self.shot_force), 5000);
+       self.shot_volly                                 = bound(1, ((!self.shot_volly) ? 1 : self.shot_volly), floor(self.ammo_max / self.shot_dmg));
+       self.shot_volly_refire                  = bound(self.shot_refire, ((!self.shot_volly_refire) ? self.shot_refire * self.shot_volly : self.shot_volly_refire), 60);
+       self.target_range                               = bound(0, ((!self.target_range) ? self.shot_speed * 0.5 : self.target_range), MAX_SHOT_DISTANCE);
+       self.target_range_min                   = bound(0, ((!self.target_range_min) ? self.shot_radius * 2 : self.target_range_min), MAX_SHOT_DISTANCE);
+       self.target_range_optimal               = bound(0, ((!self.target_range_optimal) ? self.target_range * 0.5 : self.target_range_optimal), MAX_SHOT_DISTANCE);
+       self.aim_maxrotate                              = bound(0, ((!self.aim_maxrotate) ? 90 : self.aim_maxrotate), 360);
+       self.aim_maxpitch                               = bound(0, ((!self.aim_maxpitch) ? 20 : self.aim_maxpitch), 90);
+       self.aim_speed                                  = bound(0.1, ((!self.aim_speed) ? 36 : self.aim_speed), 1000);
+       self.aim_firetolerance_dist     = bound(0.1, ((!self.aim_firetolerance_dist) ? 5 + (self.shot_radius * 2) : self.aim_firetolerance_dist), MAX_SHOT_DISTANCE);
+       self.target_select_rangebias    = bound(-10, ((!self.target_select_rangebias) ? 1 : self.target_select_rangebias), 10);
+       self.target_select_samebias     = bound(-10, ((!self.target_select_samebias) ? 1 : self.target_select_samebias), 10);
+       self.target_select_anglebias    = bound(-10, ((!self.target_select_anglebias) ? 1 : self.target_select_anglebias), 10);
+       self.target_select_missilebias  = bound(-10, ((!self.target_select_missilebias) ? 1 : self.target_select_missilebias), 10);
+       self.target_select_playerbias   = bound(-10, ((!self.target_select_playerbias) ? 1 : self.target_select_playerbias), 10);
+       self.ammo_max                                   = max(self.shot_dmg, ((!self.ammo_max) ? self.shot_dmg * 10 : self.ammo_max));
+       self.ammo_recharge                              = max(0, ((!self.ammo_recharge) ? self.shot_dmg * 0.5 : self.ammo_recharge));
+
+       self.turret_flags = TUR_FLAG_ISTURRET | (tur.spawnflags);
+
+       if(self.turret_flags & TUR_FLAG_SPLASH)
+               self.aim_flags |= TFL_AIM_SPLASH;
+
+       if(self.turret_flags & TUR_FLAG_MISSILE)
+               self.target_select_flags |= TFL_TARGETSELECT_MISSILES;
+
+       if(self.turret_flags & TUR_FLAG_PLAYER)
+               self.target_select_flags |= TFL_TARGETSELECT_PLAYERS;
+
+       if(self.spawnflags & TSL_NO_RESPAWN)
+               self.damage_flags |= TFL_DMG_DEATH_NORESPAWN;
+
+       if (self.turret_flags & TUR_FLAG_SUPPORT)
+               self.turret_score_target = turret_targetscore_support;
+       else
+               self.turret_score_target = turret_targetscore_generic;
+
+       ++turret_count;
+
+       setmodel(self, tur.model);
+       setsize(self, tur.mins, tur.maxs);
+
+       self.turretid                           = tur_id;
+       self.classname                          = "turret_main";
+       self.active                                     = ACTIVE_ACTIVE;
+       self.effects                            = EF_NODRAW;
+       self.netname                            = TUR_NAME(tur_id);
+       self.ticrate                            = bound(sys_frametime, self.ticrate, 60);
+       self.max_health                         = self.health;
+       self.target_validate_flags      = self.target_select_flags;
+       self.ammo                                       = self.ammo_max;
+       self.ammo_recharge                 *= self.ticrate;
+       self.solid                                      = SOLID_BBOX;
+       self.takedamage                         = DAMAGE_AIM;
+       self.movetype                           = MOVETYPE_NOCLIP;
+       self.view_ofs                           = '0 0 0';
+       self.turret_firecheckfunc       = turret_firecheck;
+       self.event_damage                       = turret_damage;
+       self.use                                        = turret_use;
+       self.bot_attack                         = true;
+       self.nextthink                          = time + 1;
+       self.nextthink                     += turret_count * sys_frametime;
+
+       self.tur_head = spawn();
+       setmodel(self.tur_head, tur.head_model);
+       setsize(self.tur_head, '0 0 0', '0 0 0');
+       setorigin(self.tur_head, '0 0 0');
+       setattachment(self.tur_head, self, "tag_head");
+
+       self.tur_head.netname           = self.tur_head.classname = "turret_head";
+       self.tur_head.team                      = self.team;
+       self.tur_head.owner                     = self;
+       self.tur_head.takedamage        = DAMAGE_NO;
+       self.tur_head.solid                     = SOLID_NOT;
+       self.tur_head.movetype          = self.movetype;
+
+       if(!self.tur_defend)
+       if(self.target != "")
+       {
+               self.tur_defend = find(world, targetname, self.target);
+               if (self.tur_defend == world)
+               {
+                       self.target = "";
+                       dprint("Turret has invalid defendpoint!\n");
+               }
+       }
+
+       if (self.tur_defend)
+               self.idle_aim = self.tur_head.angles + angleofs(self.tur_head, self.tur_defend);
+       else
+               self.idle_aim = '0 0 0';
+
+#ifdef TURRET_DEBUG
+       self.tur_debug_start = self.nextthink;
+       while (vlen(self.tur_debug_rvec) < 2)
+               self.tur_debug_rvec = randomvec() * 4;
+
+       self.tur_debug_rvec_x = fabs(self.tur_debug_rvec_x);
+       self.tur_debug_rvec_y = fabs(self.tur_debug_rvec_y);
+       self.tur_debug_rvec_z = fabs(self.tur_debug_rvec_z);
+#endif
+
+       turret_link();
+       turret_respawn();
+       turret_tag_fire_update();
+
+       TUR_ACTION(tur_id, TR_SETUP);
+
+       if(MUTATOR_CALLHOOK(TurretSpawn, self))
+               return false;
+
+       return true;
+}
+#endif
diff --git a/qcsrc/common/turrets/sv_turrets.qh b/qcsrc/common/turrets/sv_turrets.qh
new file mode 100644 (file)
index 0000000..8bba1c4
--- /dev/null
@@ -0,0 +1,117 @@
+#ifndef SV_TURRETS_H
+#define SV_TURRETS_H
+
+// turret fields
+.float ticrate; // interal ai think rate
+.vector aim_idle; // where to aim while idle
+.entity tur_head; // top part of the turret
+.entity tur_defend; // defend this entity
+.vector tur_shotorg; // shot origin
+.vector tur_aimpos; // aiming location
+.float tur_impacttime; // predicted projectile impact time
+.entity tur_impactent; // entity the projectile hit
+.float tur_dist_enemy; // distance to enemy
+.float tur_dist_aimpos; // distance to aim location
+.float tur_dist_impact_to_aimpos; // distance impact<->aim
+.float volly_counter; // decrement counter from .shot_volly to 0
+
+.float shot_refire; // attack refire
+.float shot_speed; // projectile speed
+.float shot_spread; // inaccuracy
+.float shot_dmg; // core damage of projectile
+.float shot_radius; // projectile damage radius
+.float shot_force; // projectile damage force
+.float shot_volly; // smaller than 1 = shoot # times at target
+.float shot_volly_refire; // refire after completed volly
+
+.float target_range;
+.float target_range_min;
+.float target_range_optimal;
+
+.float target_select_rangebias;
+.float target_select_samebias;
+.float target_select_anglebias;
+.float target_select_missilebias;
+.float target_select_playerbias;
+.float target_select_time; // last time turret had a valid target
+.float target_validate_time; // throttle re-validation of current target
+
+.float aim_firetolerance_dist;
+.float aim_speed;
+.float aim_maxpitch;
+.float aim_maxrotate;
+
+.float ammo; // current ammo
+.float ammo_recharge; // recharge rate
+.float ammo_max; // maximum ammo
+
+.vector idle_aim;
+
+/// Map time control over pain inflicted
+.float turret_scale_damage;
+/// Map time control targetting range
+.float turret_scale_range;
+/// Map time control refire
+.float turret_scale_refire;
+/// Map time control ammo held and recharged
+.float turret_scale_ammo;
+/// Map time control aim speed
+.float turret_scale_aim;
+/// Map time control health
+.float turret_scale_health;
+/// Map time control respawn time
+.float turret_scale_respawn;
+
+// tracking type
+.float track_type;
+const float TFL_TRACKTYPE_STEPMOTOR = 1; // hard angle increments, ugly for fast turning with best accuracy
+const float TFL_TRACKTYPE_FLUIDPRECISE = 2; // smooth absolute movement, looks OK with fair accuracy
+const float TFL_TRACKTYPE_FLUIDINERTIA = 3; // simulated inertia ("wobbly" mode), worst accuracy, depends on below flags
+.float track_accel_pitch;
+.float track_accel_rotate;
+.float track_blendrate;
+
+void() turret_respawn;
+
+/// updates aim org, shot org, shot dir and enemy org for selected turret
+void turret_do_updates(entity e_turret);
+.vector tur_shotdir_updated;
+
+.float() turret_firecheckfunc; // TODO: deprecate!
+
+void turrets_setframe(float _frame, float client_only);
+
+float turret_initialize(float tur_id);
+
+/// Function to use for target evaluation. usualy turret_targetscore_generic
+.float(entity _turret, entity _target) turret_score_target;
+
+.float(entity e_target,entity e_sender) turret_addtarget;
+
+.entity pathcurrent;
+
+float turret_count;
+
+// debugging
+// Uncomment below to enable various debug output.
+//#define TURRET_DEBUG
+//#define TURRET_DEBUG_TARGETVALIDATE
+//#define TURRET_DEBUG_TARGETSELECT
+#ifdef TURRET_DEBUG
+.float tur_debug_dmg_t_h; // total damage that hit something (can be more than tur_debug_dmg_t_f since it should count radius damage)
+.float tur_debug_dmg_t_f; // total damage
+.float tur_debug_start; // turret initialization time
+.float tur_debug_tmr1; // random timer
+.float tur_debug_tmr2; // random timer
+.float tur_debug_tmr3; // random timer
+.vector tur_debug_rvec; // random vector
+#endif
+
+// aiming
+vector tvt_thadv; // turret head angle diff vector, updated by a successful call to turret_validate_target
+vector tvt_tadv; // turret angle diff vector, updated by a successful call to turret_validate_target
+float tvt_thadf; // turret head angle diff float, updated by a successful call to turret_validate_target
+float tvt_tadf; // turret angle diff float, updated by a successful call to turret_validate_target
+float tvt_dist; // turret distance, updated by a successful call to turret_validate_target
+
+#endif
diff --git a/qcsrc/common/turrets/targettrigger.qc b/qcsrc/common/turrets/targettrigger.qc
new file mode 100644 (file)
index 0000000..6551064
--- /dev/null
@@ -0,0 +1,38 @@
+void spawnfunc_turret_targettrigger();
+void turret_targettrigger_touch();
+
+void turret_targettrigger_touch()
+{
+    entity e;
+    if (self.cnt > time) return;
+    entity oldself;
+    oldself = self;
+
+    e = find(world, targetname, self.target);
+    while (e)
+    {
+        if (e.turret_flags & TUR_FLAG_RECIEVETARGETS)
+        {
+            self = e;
+            if(e.turret_addtarget)
+                e.turret_addtarget(other,oldself);
+        }
+
+        e = find(e, targetname, oldself.target);
+    }
+
+    oldself.cnt = time + 0.5;
+
+    self = oldself;
+}
+
+/*QUAKED turret_targettrigger (.5 .5 .5) ?
+*/
+void spawnfunc_turret_targettrigger()
+{
+    if(!autocvar_g_turrets) { remove(self); return; }
+
+    InitTrigger ();
+
+    self.touch = turret_targettrigger_touch;
+}
diff --git a/qcsrc/common/turrets/turrets.qc b/qcsrc/common/turrets/turrets.qc
new file mode 100644 (file)
index 0000000..a47b975
--- /dev/null
@@ -0,0 +1,77 @@
+#include "all.qh"
+
+// TURRET PLUGIN SYSTEM
+entity turret_info[TUR_MAXCOUNT];
+entity dummy_turret_info;
+
+void turrets_common_precache()
+{
+       precache_sound ("weapons/rocket_impact.wav");
+       precache_model ("models/turrets/base-gib1.md3");
+       precache_model ("models/turrets/base-gib2.md3");
+       precache_model ("models/turrets/base-gib3.md3");
+       precache_model ("models/turrets/base-gib4.md3");
+       precache_model ("models/turrets/head-gib1.md3");
+       precache_model ("models/turrets/head-gib2.md3");
+       precache_model ("models/turrets/head-gib3.md3");
+       precache_model ("models/turrets/head-gib4.md3");
+       precache_model ("models/turrets/base.md3");
+       precache_model ("models/turrets/rocket.md3");
+
+       precache_model ("models/turrets/c512.md3");
+       precache_model ("models/marker.md3");
+
+#ifdef TURRET_DEBUG
+       precache_model ("models/turrets/c512.md3");
+       precache_model ("models/pathlib/goodsquare.md3");
+       precache_model ("models/pathlib/badsquare.md3");
+       precache_model ("models/pathlib/square.md3");
+       precache_model ("models/pathlib/edge.md3");
+#endif
+}
+
+void register_turret(float id, float(float) func, float turretflags, vector min_s, vector max_s, string modelname, string headmodelname, string shortname, string mname)
+{
+       entity e;
+       turret_info[id - 1] = e = spawn();
+       e.classname = "turret_info";
+       e.turretid = id;
+       e.netname = shortname;
+       e.turret_name = mname;
+       e.turret_func = func;
+       e.mdl = modelname;
+       e.cvar_basename = shortname;
+       e.spawnflags = turretflags;
+       e.mins = min_s;
+       e.maxs = max_s;
+       e.model = strzone(strcat("models/turrets/", modelname));
+       e.head_model = strzone(strcat("models/turrets/", headmodelname));
+
+       #ifndef MENUQC
+       turrets_common_precache();
+       #endif
+}
+float t_null(float dummy) { return 0; }
+void register_turrets_done()
+{
+       dummy_turret_info = spawn();
+       dummy_turret_info.classname = "turret_info";
+       dummy_turret_info.turretid = 0; // you can recognize dummies by this
+       dummy_turret_info.netname = "";
+       dummy_turret_info.turret_name = "Turret";
+       dummy_turret_info.turret_func = t_null;
+       dummy_turret_info.mdl = "";
+       dummy_turret_info.mins = '-0 -0 -0';
+       dummy_turret_info.maxs = '0 0 0';
+       dummy_turret_info.model = "";
+}
+entity get_turretinfo(float id)
+{
+       entity m;
+       if(id < TUR_FIRST || id > TUR_LAST)
+               return dummy_turret_info;
+       m = turret_info[id - 1];
+       if(m)
+               return m;
+       return dummy_turret_info;
+}
diff --git a/qcsrc/common/turrets/turrets.qh b/qcsrc/common/turrets/turrets.qh
new file mode 100644 (file)
index 0000000..b3736af
--- /dev/null
@@ -0,0 +1,202 @@
+#ifndef TURRETS_H
+#define TURRETS_H
+
+// turret requests
+#define TR_SETUP          1 // (BOTH) setup turret data
+#define TR_THINK                 2 // (SERVER) logic to run every frame
+#define TR_DEATH          3 // (SERVER) called when turret dies
+#define TR_PRECACHE       4 // (BOTH) precaches models/sounds used by this turret
+#define TR_ATTACK         5 // (SERVER) called when turret attacks
+#define TR_CONFIG         6 // (ALL)
+
+// functions:
+entity get_turretinfo(int id);
+
+// fields:
+.entity tur_head;
+
+// target selection flags
+.int target_select_flags;
+.int target_validate_flags;
+const int TFL_TARGETSELECT_NO = 2; // don't automatically find targets
+const int TFL_TARGETSELECT_LOS = 4; // require line of sight to find targets
+const int TFL_TARGETSELECT_PLAYERS = 8; // target players
+const int TFL_TARGETSELECT_MISSILES = 16; // target projectiles
+const int TFL_TARGETSELECT_TRIGGERTARGET = 32; // respond to turret_trigger_target events
+const int TFL_TARGETSELECT_ANGLELIMITS = 64; // apply extra angular limits to target selection
+const int TFL_TARGETSELECT_RANGELIMITS = 128; // limit target selection range
+const int TFL_TARGETSELECT_TEAMCHECK = 256; // don't attack teammates
+const int TFL_TARGETSELECT_NOBUILTIN = 512; // only attack targets when triggered
+const int TFL_TARGETSELECT_OWNTEAM = 1024; // only attack teammates
+const int TFL_TARGETSELECT_NOTURRETS = 2048; // don't attack other turrets
+const int TFL_TARGETSELECT_FOV = 4096; // extra limits to attack range
+const int TFL_TARGETSELECT_MISSILESONLY = 8192; // only attack missiles
+
+// aim flags
+.int aim_flags;
+const int TFL_AIM_NO = 1; // no aiming
+const int TFL_AIM_SPLASH = 2; // aim for ground around the target's feet
+const int TFL_AIM_LEAD = 4; // try to predict target movement
+const int TFL_AIM_SHOTTIMECOMPENSATE = 8; // compensate for shot traveltime when leading
+const int TFL_AIM_ZPREDICT = 16; // predict target's z position at impact
+const int TFL_AIM_SIMPLE = 32; // aim at player's current location
+
+// tracking flags
+.int track_flags;
+const int TFL_TRACK_NO = 2; // don't move head
+const int TFL_TRACK_PITCH = 4; // pitch head
+const int TFL_TRACK_ROTATE = 8; // rotate head
+
+// prefire checks
+.int firecheck_flags;
+const int TFL_FIRECHECK_DEAD = 4; // don't attack dead targets (zombies?)
+const int TFL_FIRECHECK_DISTANCES = 8; // another range check
+const int TFL_FIRECHECK_LOS = 16; // line of sight
+const int TFL_FIRECHECK_AIMDIST = 32; // consider distance impactpoint<->aimspot
+const int TFL_FIRECHECK_REALDIST = 64; // consider enemy origin<->impactpoint
+const int TFL_FIRECHECK_ANGLEDIST = 128; // consider angular diff head<->aimspot
+const int TFL_FIRECHECK_TEAMCHECK = 256; // don't attack teammates
+const int TFL_FIRECHECK_AFF = 512; // try to avoid any friendly fire
+const int TFL_FIRECHECK_AMMO_OWN = 1024; // own ammo needs to be larger than damage dealt
+const int TFL_FIRECHECK_AMMO_OTHER = 2048; // target's ammo needs to be less than max
+const int TFL_FIRECHECK_REFIRE = 4096; // check single attack finished delays
+const int TFL_FIRECHECK_NO = 16384; // no prefire checks
+
+// attack flags
+.int shoot_flags;
+const int TFL_SHOOT_NO = 64; // no attacking
+const int TFL_SHOOT_VOLLY = 2; // fire in vollies
+const int TFL_SHOOT_VOLLYALWAYS = 4; // always do a full volly, even if target is lost
+const int TFL_SHOOT_HITALLVALID = 8; // loop through all valid targets
+const int TFL_SHOOT_CLEARTARGET = 16; // lose target after attack (after volly is done if in volly mode)
+const int TFL_SHOOT_CUSTOM = 32; // custom attacking
+
+// turret capabilities
+.int turret_flags;
+const int TUR_FLAG_NONE = 0; // no abilities
+const int TUR_FLAG_SNIPER = 2; // sniping turret
+const int TUR_FLAG_SPLASH = 4; // can deal splash damage
+const int TUR_FLAG_HITSCAN = 8; // hit scan
+const int TUR_FLAG_MULTIGUN = 16; // multiple guns
+const int TUR_FLAG_GUIDED = 32; // laser guided projectiles
+const int TUR_FLAG_SLOWPROJ = 64; // turret fires slow projectiles
+const int TUR_FLAG_MEDPROJ = 128; // turret fires medium projectiles
+const int TUR_FLAG_FASTPROJ = 256; // turret fires fast projectiles
+const int TUR_FLAG_PLAYER = 512; // can damage players
+const int TUR_FLAG_MISSILE = 1024; // can damage missiles
+const int TUR_FLAG_SUPPORT = 2048; // supports other units
+const int TUR_FLAG_AMMOSOURCE = 4096; // can provide ammunition
+const int TUR_FLAG_RECIEVETARGETS = 8192; // can recieve targets from external sources
+const int TUR_FLAG_MOVE = 16384; // can move
+const int TUR_FLAG_ROAM = 32768; // roams around if not attacking
+const int TUR_FLAG_ISTURRET = 65536; // identifies this unit as a turret
+
+// ammo types
+#define ammo_flags currentammo
+const int TFL_AMMO_NONE = 64; // doesn't use ammo
+const int TFL_AMMO_ENERGY = 2; // uses power
+const int TFL_AMMO_BULLETS = 4; // uses bullets
+const int TFL_AMMO_ROCKETS = 8; // uses explosives
+const int TFL_AMMO_RECHARGE = 16; // regenerates ammo
+const int TFL_AMMO_RECIEVE = 32; // can recieve ammo from support units
+
+// damage flags
+.int damage_flags;
+const int TFL_DMG_NO = 256; // doesn't take damage
+const int TFL_DMG_YES = 2; // can be damaged
+const int TFL_DMG_TEAM = 4; // can be damaged by teammates
+const int TFL_DMG_RETALIATE = 8; // target attackers
+const int TFL_DMG_RETALIATE_TEAM = 16; // target attackers, even if on same team
+const int TFL_DMG_TARGETLOSS = 32; // loses target when damaged
+const int TFL_DMG_AIMSHAKE = 64; // damage throws off aim
+const int TFL_DMG_HEADSHAKE = 128; // damage shakes head
+const int TFL_DMG_DEATH_NORESPAWN = 256; // no re-spawning
+
+// spawn flags
+const int TSF_SUSPENDED = 1;
+const int TSF_TERRAINBASE = 2; // currently unused
+const int TSF_NO_AMMO_REGEN = 4; // disable builtin ammo regeneration
+const int TSF_NO_PATHBREAK = 8; // don't break path to chase enemies, will still fire at them if possible
+const int TSL_NO_RESPAWN = 16; // don't re-spawn
+const int TSL_ROAM = 32; // roam while idle
+
+// send flags
+const int TNSF_UPDATE       = 2;
+const int TNSF_STATUS       = 4;
+const int TNSF_SETUP        = 8;
+const int TNSF_ANG          = 16;
+const int TNSF_AVEL         = 32;
+const int TNSF_MOVE         = 64;
+.float anim_start_time;
+const int TNSF_ANIM         = 128;
+
+const int TNSF_FULL_UPDATE  = 16777215;
+
+
+// entity properties of turretinfo:
+.int turretid; // TUR_...
+.string netname; // short name
+.string turret_name; // human readable name
+.float(float) turret_func; // m_...
+.string mdl; // currently a copy of the model
+.string model; // full name of model
+.string head_model; // full name of tur_head model
+.string cvar_basename; // TODO: deprecate!
+.float spawnflags;
+.vector mins, maxs; // turret hitbox size
+
+// other useful macros
+#define TUR_ACTION(turrettype,mrequest) (get_turretinfo(turrettype)).turret_func(mrequest)
+#define TUR_NAME(turrettype) (get_turretinfo(turrettype)).turret_name
+
+// =====================
+//  Turret Registration
+// =====================
+
+float t_null(float dummy);
+void register_turret(float id, float(float) func, float turretflags, vector min_s, vector max_s, string modelname, string headmodelname, string shortname, string mname);
+void register_turrets_done();
+
+const float TUR_MAXCOUNT = 24;
+#define TUR_FIRST 1
+float TUR_COUNT;
+float TUR_LAST;
+
+#define REGISTER_TURRET_2(id,func,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname) \
+       float id; \
+       float func(float); \
+       void RegisterTurrets_##id() \
+       { \
+               TUR_LAST = (id = TUR_FIRST + TUR_COUNT); \
+               ++TUR_COUNT; \
+               register_turret(id,func,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname); \
+       } \
+       ACCUMULATE_FUNCTION(RegisterTurrets, RegisterTurrets_##id)
+#ifdef MENUQC
+#define REGISTER_TURRET(id,func,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname) \
+       REGISTER_TURRET_2(TUR_##id,t_null,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname)
+#else
+#define REGISTER_TURRET(id,func,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname) \
+       REGISTER_TURRET_2(TUR_##id,func,turretflags,min_s,max_s,modelname,headmodelname,shortname,mname)
+#endif
+
+#define TUR_DUPECHECK(dupecheck,cvar) \
+       #ifndef dupecheck \
+               #define dupecheck \
+               float cvar; \
+       #else \
+               #error DUPLICATE TURRET CVAR: cvar \
+       #endif
+
+#define TUR_ADD_CVAR(turret,name) \
+               TUR_DUPECHECK(TUR_CVAR_##turret##_##name, autocvar_g_turrets_unit_##turret##_##name)
+
+#define TUR_CVAR(turret,name) autocvar_g_turrets_unit_##turret##_##name
+
+#include "all.qh"
+
+#undef TUR_ADD_CVAR
+#undef REGISTER_TURRET
+ACCUMULATE_FUNCTION(RegisterTurrets, register_turrets_done);
+
+#endif
diff --git a/qcsrc/common/turrets/unit/ewheel.qc b/qcsrc/common/turrets/unit/ewheel.qc
new file mode 100644 (file)
index 0000000..495e60f
--- /dev/null
@@ -0,0 +1,311 @@
+#ifdef REGISTER_TURRET
+REGISTER_TURRET(
+/* TUR_##id   */ EWHEEL,
+/* function   */ t_ewheel,
+/* spawnflags */ TUR_FLAG_PLAYER | TUR_FLAG_MOVE | TUR_FLAG_ROAM,
+/* mins,maxs  */ '-32 -32 0', '32 32 48',
+/* model      */ "ewheel-base2.md3",
+/* head_model */ "ewheel-gun1.md3",
+/* netname    */ "ewheel",
+/* fullname   */ _("eWheel Turret")
+);
+#else
+#ifdef SVQC
+float autocvar_g_turrets_unit_ewheel_speed_fast;
+float autocvar_g_turrets_unit_ewheel_speed_slow;
+float autocvar_g_turrets_unit_ewheel_speed_slower;
+float autocvar_g_turrets_unit_ewheel_speed_stop;
+float autocvar_g_turrets_unit_ewheel_turnrate;
+
+const float ewheel_anim_stop = 0;
+const float ewheel_anim_fwd_slow = 1;
+const float ewheel_anim_fwd_fast = 2;
+const float ewheel_anim_bck_slow = 3;
+const float ewheel_anim_bck_fast = 4;
+
+//#define EWHEEL_FANCYPATH
+void ewheel_move_path()
+{
+#ifdef EWHEEL_FANCYPATH
+    // Are we close enougth to a path node to switch to the next?
+    if (vlen(self.origin  - self.pathcurrent.origin) < 64)
+        if (self.pathcurrent.path_next == world)
+        {
+            // Path endpoint reached
+            pathlib_deletepath(self.pathcurrent.owner);
+            self.pathcurrent = world;
+
+            if (self.pathgoal)
+            {
+                if (self.pathgoal.use)
+                    self.pathgoal.use();
+
+                if (self.pathgoal.enemy)
+                {
+                    self.pathcurrent = pathlib_astar(self.pathgoal.origin,self.pathgoal.enemy.origin);
+                    self.pathgoal = self.pathgoal.enemy;
+                }
+            }
+            else
+                self.pathgoal = world;
+        }
+        else
+            self.pathcurrent = self.pathcurrent.path_next;
+
+#else
+    if (vlen(self.origin - self.pathcurrent.origin) < 64)
+        self.pathcurrent = self.pathcurrent.enemy;
+#endif
+
+    if (self.pathcurrent)
+    {
+
+        self.moveto = self.pathcurrent.origin;
+        self.steerto = steerlib_attract2(self.moveto, 0.5, 500, 0.95);
+
+        movelib_move_simple(v_forward, (autocvar_g_turrets_unit_ewheel_speed_fast), 0.4);
+    }
+}
+
+void ewheel_move_enemy()
+{
+    float newframe;
+
+    self.steerto = steerlib_arrive(self.enemy.origin,self.target_range_optimal);
+
+    self.moveto  = self.origin + self.steerto * 128;
+
+    if (self.tur_dist_enemy > self.target_range_optimal)
+    {
+        if ( self.tur_head.spawnshieldtime < 1 )
+        {
+            newframe = ewheel_anim_fwd_fast;
+            movelib_move_simple(v_forward, (autocvar_g_turrets_unit_ewheel_speed_fast), 0.4);
+        }
+        else if (self.tur_head.spawnshieldtime < 2)
+        {
+
+            newframe = ewheel_anim_fwd_slow;
+            movelib_move_simple(v_forward, (autocvar_g_turrets_unit_ewheel_speed_slow), 0.4);
+       }
+        else
+        {
+            newframe = ewheel_anim_fwd_slow;
+            movelib_move_simple(v_forward, (autocvar_g_turrets_unit_ewheel_speed_slower), 0.4);
+        }
+    }
+    else if (self.tur_dist_enemy < self.target_range_optimal * 0.5)
+    {
+        newframe = ewheel_anim_bck_slow;
+        movelib_move_simple(v_forward * -1, (autocvar_g_turrets_unit_ewheel_speed_slow), 0.4);
+    }
+    else
+    {
+        newframe = ewheel_anim_stop;
+        movelib_beak_simple((autocvar_g_turrets_unit_ewheel_speed_stop));
+    }
+
+    turrets_setframe(newframe, false);
+}
+
+void ewheel_move_idle()
+{
+    if(self.frame != 0)
+    {
+        self.SendFlags |= TNSF_ANIM;
+        self.anim_start_time = time;
+    }
+
+    self.frame = 0;
+    if (vlen(self.velocity))
+        movelib_beak_simple((autocvar_g_turrets_unit_ewheel_speed_stop));
+}
+
+void spawnfunc_turret_ewheel() { if(!turret_initialize(TUR_EWHEEL)) remove(self); }
+
+float t_ewheel(float req)
+{
+    switch(req)
+    {
+        case TR_ATTACK:
+        {
+            float i;
+            entity _mis;
+
+            for (i = 0; i < 1; ++i)
+            {
+                turret_do_updates(self);
+
+                _mis = turret_projectile("weapons/lasergun_fire.wav", 1, 0, DEATH_TURRET_EWHEEL, PROJECTILE_BLASTER, TRUE, TRUE);
+                _mis.missile_flags = MIF_SPLASH;
+
+                Send_Effect("laser_muzzleflash", self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
+
+                self.tur_head.frame += 2;
+
+                if (self.tur_head.frame > 3)
+                    self.tur_head.frame = 0;
+            }
+
+            return true;
+        }
+        case TR_THINK:
+        {
+            float vz;
+            vector wish_angle, real_angle;
+
+            vz = self.velocity_z;
+
+            self.angles_x = anglemods(self.angles_x);
+            self.angles_y = anglemods(self.angles_y);
+
+            fixedmakevectors(self.angles);
+
+            wish_angle = normalize(self.steerto);
+            wish_angle = vectoangles(wish_angle);
+            real_angle = wish_angle - self.angles;
+            real_angle = shortangle_vxy(real_angle, self.tur_head.angles);
+
+            self.tur_head.spawnshieldtime = fabs(real_angle_y);
+            real_angle_y  = bound(-self.tur_head.aim_speed, real_angle_y, self.tur_head.aim_speed);
+            self.angles_y = (self.angles_y + real_angle_y);
+
+            if(self.enemy)
+                ewheel_move_enemy();
+            else if(self.pathcurrent)
+                ewheel_move_path();
+            else
+                ewheel_move_idle();
+
+            self.velocity_z = vz;
+
+            if(vlen(self.velocity))
+                self.SendFlags |= TNSF_MOVE;
+
+            return true;
+        }
+        case TR_DEATH:
+        {
+            self.velocity = '0 0 0';
+
+#ifdef EWHEEL_FANCYPATH
+            if (self.pathcurrent)
+                pathlib_deletepath(self.pathcurrent.owner);
+#endif
+            self.pathcurrent = world;
+
+            return true;
+        }
+        case TR_SETUP:
+        {
+            entity e;
+
+            if(self.movetype == MOVETYPE_WALK)
+            {
+                self.velocity = '0 0 0';
+                self.enemy = world;
+
+                setorigin(self, self.pos1);
+
+                if (self.target != "")
+                {
+                    e = find(world, targetname, self.target);
+                    if (!e)
+                    {
+                        dprint("Initital waypoint for ewheel does NOT exsist, fix your map!\n");
+                        self.target = "";
+                    }
+
+                    if (e.classname != "turret_checkpoint")
+                        dprint("Warning: not a turrret path\n");
+