]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Clickable radar by Melanosuchus, for teleporting between control points. Clean up...
authorMario <mario.mario@y7mail.com>
Wed, 4 Jun 2014 22:43:26 +0000 (08:43 +1000)
committerMario <mario.mario@y7mail.com>
Wed, 4 Jun 2014 22:43:26 +0000 (08:43 +1000)
25 files changed:
defaultXonotic.cfg
gamemodes.cfg
gfx/teamradar_icon_glow.tga [new file with mode: 0644]
qcsrc/client/Main.qc
qcsrc/client/View.qc
qcsrc/client/autocvars.qh
qcsrc/client/command/cl_cmd.qc
qcsrc/client/generator.qc
qcsrc/client/hud.qc
qcsrc/client/hud.qh
qcsrc/client/mapvoting.qc
qcsrc/client/scoreboard.qc
qcsrc/client/teamradar.qc
qcsrc/client/waypointsprites.qc
qcsrc/client/waypointsprites.qh
qcsrc/common/constants.qh
qcsrc/common/mapinfo.qh
qcsrc/common/notifications.qh
qcsrc/server/autocvars.qh
qcsrc/server/g_world.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/mutators/gamemode_onslaught.qc
qcsrc/server/mutators/gamemode_onslaught.qh
qcsrc/server/teamplay.qc
qcsrc/server/waypointsprites.qc

index 2c048b39eac92ecebba09fbd6006e7623a6ca201..cf6111890827e598f642276a236e708482f993fe 100644 (file)
@@ -226,10 +226,12 @@ set cl_hitsound_antispam_time 0.05 "don't play the hitsound more often than this
 seta cl_eventchase_death 1 "camera goes into 3rd person mode when the player is dead"
 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_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)"
index a0f8b9c346c2371b3d1dd10b834fc930602c7c68..8b6120c368e41996281e4598da0756baa18e120f 100644 (file)
@@ -447,6 +447,15 @@ 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
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 4c4bc7cd7a8d5da8e3fb7326f0b2768cfbf98e07..a63d4e46563cf6801fbb5154c54832513f40a13c 100644 (file)
@@ -343,6 +343,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;
 
@@ -739,7 +742,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);
 }
 
index 2a41ba13c673c601f9134052a5f4cba68425a5ee..375ed903606675f5614a7b3a855c42e5f3429a14 100644 (file)
@@ -403,6 +403,7 @@ vector rainbow_prev_color;
 #define BUTTON_4 8
 float cl_notice_run();
 float prev_myteam;
+.float health;
 void CSQC_UpdateView(float w, float h)
 {
        entity e;
@@ -493,16 +494,37 @@ 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
        {
                WepSet weapons_stat = WepSet_GetFromStat();
-               if(((spectatee_status >= 0 && (autocvar_cl_eventchase_death && is_dead)) || intermission) && !autocvar_cl_orthoview || (autocvar_cl_eventchase_nexball && gametype == MAPINFO_TYPE_NEXBALL && !(weapons_stat & WepSet_FromWeapon(WEP_PORTO))))
+               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(((spectatee_status >= 0 && (autocvar_cl_eventchase_death && is_dead)) || intermission || ons_roundlost) && !autocvar_cl_orthoview || (autocvar_cl_eventchase_nexball && gametype == MAPINFO_TYPE_NEXBALL && !(weapons_stat & WepSet_FromWeapon(WEP_PORTO))))
                {
                        // 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
-                       if(autocvar_cl_eventchase_viewoffset)
+                       vector view_offset = autocvar_cl_eventchase_viewoffset;
+                       if(ons_roundlost) { view_offset = autocvar_cl_eventchase_generator_viewoffset; }
+
+                       if(view_offset)
                        {
-                               WarpZone_TraceLine(current_view_origin, current_view_origin + autocvar_cl_eventchase_viewoffset + ('0 0 1' * autocvar_cl_eventchase_maxs_z), MOVE_WORLDONLY, self);
-                               if(trace_fraction == 1) { current_view_origin += autocvar_cl_eventchase_viewoffset; }
+                               WarpZone_TraceLine(current_view_origin, current_view_origin + view_offset + ('0 0 1' * autocvar_cl_eventchase_maxs_z), MOVE_WORLDONLY, self);
+                               if(trace_fraction == 1) { current_view_origin += view_offset; }
                                else { current_view_origin_z += max(0, (trace_endpos_z - current_view_origin_z) - autocvar_cl_eventchase_maxs_z); }
                        }
 
@@ -512,10 +534,13 @@ void CSQC_UpdateView(float w, float h)
                        if(!autocvar_chase_active) { cvar_set("chase_active", "-1"); }
 
                        // make the camera smooth back
-                       if(autocvar_cl_eventchase_speed && eventchase_current_distance < autocvar_cl_eventchase_distance)
-                               eventchase_current_distance += autocvar_cl_eventchase_speed * (autocvar_cl_eventchase_distance - eventchase_current_distance) * frametime; // slow down the further we get
-                       else if(eventchase_current_distance != autocvar_cl_eventchase_distance)
-                               eventchase_current_distance = autocvar_cl_eventchase_distance;
+                       float chase_distance = autocvar_cl_eventchase_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
+                       else if(eventchase_current_distance != chase_distance)
+                               eventchase_current_distance = chase_distance;
 
                        makevectors(view_angles);
 
@@ -1633,6 +1658,8 @@ void CSQC_UpdateView(float w, float h)
 
        if(autocvar__hud_configure)
                HUD_Panel_Mouse();
+       else 
+               HUD_Radar_Mouse();
 
     if(hud && !intermission)
     {
index 67a03259382feba3d5e14adf53087c834eac6491..36601ecc2ee93ea09f822756bda2da361e6cd549 100644 (file)
@@ -416,6 +416,8 @@ var float autocvar_cl_eventchase_speed = 1.3;
 var vector autocvar_cl_eventchase_maxs = '12 12 8';
 var vector autocvar_cl_eventchase_mins = '-12 -12 -8';
 var vector autocvar_cl_eventchase_viewoffset = '0 0 20';
+var vector autocvar_cl_eventchase_generator_viewoffset = '0 0 80';
+var float autocvar_cl_eventchase_generator_distance = 400;
 float autocvar_cl_lerpexcess;
 string autocvar__togglezoom;
 float autocvar_cl_damageeffect;
index 9aae77dde687ef5417a61b71ae29b4524365e963..9716f3b04a3209ff332979bebff0bfb4a8ac3d0e 100644 (file)
@@ -266,9 +266,15 @@ void LocalCommand_hud(float request, float 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;
                                }
                        }
index 474890c2e1a2ed9f342f92c421a40bcc5467869e..c7cbf6c687a0589205f603de86c93a28c02e74b5 100644 (file)
@@ -1,5 +1,6 @@
 float generator_precached;
 .float count;
+.float max_health;
 
 vector randompos(vector m1, vector m2)
 {
@@ -33,84 +34,21 @@ void generator_precache()
        precache_sound("onslaught/shockwave.wav");
        precache_sound("weapons/grenade_impact.wav");
        precache_sound("weapons/rocket_impact.wav");
-
-       precache_model("models/onslaught/gen_gib1.md3");
-       precache_model("models/onslaught/gen_gib2.md3");
-       precache_model("models/onslaught/gen_gib3.md3");
+       precache_sound("onslaught/electricity_explode.wav");
 
        generator_precached = TRUE;
 }
 
-void ons_gib_damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector vforce)
+void ons_generator_ray_draw()
 {
-       self.velocity = self.velocity + vforce;
-}
-
-.float giblifetime;
-
-void gib_draw_noburn()
-{
-       if(time >= self.giblifetime)
-               remove(self);
-}
-
-void gib_draw()
-{
-       if(time >= self.move_time)
+       if(time < self.move_time)
                return;
-
+       
        self.move_time = time + 0.05;
 
-       if(time > self.giblifetime)
-       {
-               remove(self);
-               return;
-       }
-
-       self.alpha -= 0.05;
-
-       if(self.alpha < 0.1)
-       {
-               remove(self);
-               return;
-       }
-
-       if(random()<0.6)
-               pointparticles(particleeffectnum("onslaught_generator_gib_flame"), self.origin, '0 0 0', 1);
-}
-
-void ons_throwgib(vector v_from, vector v_to, string smodel, float f_lifetime, float b_burn)
-{
-       entity gib;
-
-       gib = spawn();
-
-       setmodel(gib, smodel);
-       setorigin(gib, v_from);
-       gib.solid = SOLID_CORPSE;
-       gib.move_movetype = MOVETYPE_BOUNCE;
-       gib.movetype = MOVETYPE_BOUNCE;
-       gib.health = 255;
-       gib.move_velocity = v_to;
-       gib.move_origin = v_from;
-       gib.velocity = v_to;
-       gib.alpha = 1;
-       gib.move_time = time;
-       gib.drawmask = MASK_NORMAL;
-       gib.giblifetime = time + f_lifetime;
-
-       if(b_burn)
-               gib.draw = gib_draw;
-       else
-               gib.draw = gib_draw_noburn;
-}
-
-void onslaught_generator_ray_think()
-{
-       self.nextthink = time + 0.05;
        if(self.count > 10)
        {
-               self.think = SUB_Remove;
+               remove(self);
                return;
        }
 
@@ -123,26 +61,45 @@ void onslaught_generator_ray_think()
        self.count +=1;
 }
 
-void onslaught_generator_ray_spawn(vector org)
+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.think = onslaught_generator_ray_think;
-       e.nextthink = time + 0.05;
+       e.move_time = time + 0.05;
+       e.drawmask = MASK_NORMAL;
+       e.draw = ons_generator_ray_draw;
 }
 
 void generator_draw()
 {
-       if(self.health > 0)
+       if(time < self.move_time)
                return;
 
-       if(time < self.move_time)
+       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;
 
@@ -155,17 +112,11 @@ void generator_draw()
                sound(self, CH_TRIGGER, "onslaught/shockwave.wav", VOL_BASE, ATTEN_NORM);
                pointparticles(particleeffectnum("electro_combo"), self.origin, '0 0 0', 6);
        }
-
-       // Throw some gibs
-       if(random() < 0.3)
+       
+       // rays
+       if(random() > 0.25)
        {
-               i = random();
-               if(i < 0.3)
-                       ons_throwgib(self.origin + '0 0 40', (100 * randomvec() - '1 1 1') * 11 + '0 0 20', "models/onslaught/gen_gib1.md3", 6, TRUE);
-               else if(i > 0.7)
-                       ons_throwgib(self.origin + '0 0 40', (100 * randomvec() - '1 1 1') * 12 + '0 0 20', "models/onslaught/gen_gib2.md3", 6, TRUE);
-               else
-                       ons_throwgib(self.origin + '0 0 40', (100 * randomvec() - '1 1 1') * 13 + '0 0 20', "models/onslaught/gen_gib3.md3", 6, TRUE);
+               ons_generator_ray_spawn(self.origin);
        }
 
        // Spawn fire balls
@@ -186,12 +137,6 @@ void generator_draw()
        org = self.origin + randompos(self.mins + '8 8 8', self.maxs + '-8 -8 -8');
        pointparticles(particleeffectnum("onslaught_generator_smallexplosion"), org, '0 0 0', 1);
 
-       // rays
-       if(random() > 0.25 )
-       {
-               onslaught_generator_ray_spawn(self.origin);
-       }
-
        // Final explosion
        if(self.count==1)
        {
@@ -206,7 +151,6 @@ void generator_draw()
        self.count -= 1;
 }
 
-.float max_health;
 void generator_damage(float hp)
 {
        if(hp <= 0)
@@ -238,6 +182,7 @@ void generator_damage(float hp)
 void generator_construct()
 {
        self.netname = "Generator";
+       self.classname = "onslaught_generator";
 
        setorigin(self, self.origin);
        setmodel(self, "models/onslaught/generator.md3");
index bb5eb4a68f534081953aa7d860c69602659d7fa3..27499cd1afb88c4bafc20f9179a5bb4ae1e972c0 100644 (file)
@@ -1816,6 +1816,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(float show,float clickable)
+{
+       hud_panel_radar_maximized = show;
+       hud_panel_radar_temp_hidden = 0;
+       
+       if ( show )
+       {
+               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 cursorsize = '32 32 0';
+       drawpic(mousepos-'8 4 0', strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), cursorsize, '1 1 1', 0.8, DRAWFLAG_NORMAL);
+}
+
 void HUD_Radar(void)
 {
        if (!autocvar__hud_configure)
@@ -1835,6 +1996,9 @@ void HUD_Radar(void)
                        }
                }
        }
+       
+       if ( hud_panel_radar_temp_hidden )
+               return;
 
        HUD_Panel_UpdateCvars();
 
@@ -1989,8 +2153,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);
@@ -2000,6 +2183,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)
@@ -4191,8 +4389,16 @@ void HUD_CenterPrint (void)
                hud_fade_alpha = 1 - autocvar__menu_alpha;
        }
        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 5c062c5facb3400224105766e1628651f83c8c50..2747cc10bff13fcfd4ed8214cd585639d27f7d35 100644 (file)
@@ -9,9 +9,14 @@ string hud_panelorder_prev;
 
 float hud_draw_maximized;
 float hud_panel_radar_maximized;
+float hud_panel_radar_mouse;
+float hud_panel_radar_bottom;
+float hud_panel_radar_temp_hidden;
 float chat_panel_modified;
 float radar_panel_modified;
 
+void HUD_Radar_Hide_Maximized();
+
 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
@@ -96,6 +101,8 @@ var string panel_bg_padding_str;
 
 float current_player;
 
+float mv_active;
+
 
 #define HUD_PANELS \
        HUD_PANEL(WEAPONS      , HUD_Weapons      , weapons) \
index 8caeb01d524064f51c3191440555c0cd814ce0e3..75a280fe6e87cf4b882dd724602ca65d784337e4 100644 (file)
@@ -1,6 +1,5 @@
 float mv_num_maps;
 
-float mv_active;
 string mv_maps[MAPVOTE_COUNT];
 string mv_pics[MAPVOTE_COUNT];
 string mv_pk3[MAPVOTE_COUNT];
index 46dcfb4c451f09c46287aa21a5a4bde008c8426e..7ab8576ba99ab04d8037a52bb57d3d1d2df47609 100644 (file)
@@ -293,7 +293,7 @@ string HUD_DefaultColumnLayout()
                "ping pl name | ",
                "-teams,race,lms/kills +freezetag/kills -teams,lms/deaths +freezetag/deaths -teams,lms,race,ka/suicides +freezetag/suicides -race,dm,tdm,ka,freezetag/frags ", // tdm already has this in "score"
                "+tdm/kills +tdm/deaths +tdm/suicides ",
-               "+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 ",
@@ -938,6 +938,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 0c0f10204a4773c2da21e2aa6669a46a88d4740a..ee5a5428d1e4d3a407395071206f18ac6637354b 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 1367501a8a3743ab17b2c2fa5dbb02c9a7870911..46428f3300e61902ac93cc616cd61fc8f6a2e07c 100644 (file)
@@ -33,7 +33,6 @@ float waypointsprite_alpha;
 .float maxdistance;
 .float hideflags;
 .float spawntime;
-.float health;
 .float build_started;
 .float build_starthealth;
 .float build_finished;
@@ -199,11 +198,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-invis":       return 2;
                case "item-extralife":   return 2;
                case "item-speed":       return 2;
@@ -262,17 +258,11 @@ string spritelookuptext(string s)
                case "keycarrier-yellow": return _("Key carrier");
                case "redbase": return _("Red 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 94895083323964aeb3c3e1f6037cfb28acae90ad..d52a048075dda1b7653c00bbaecad8cb6d9d9773 100644 (file)
@@ -1,3 +1,6 @@
 // they are drawn using a .draw function
 void Ent_WaypointSprite();
 void Ent_RemoveWaypointSprite();
+
+
+.float health;
index c7c43bff23b9f37496d8036bd35c4b6f24323622..73662b617cd0f0534f2094c989b503fd4969b7bd 100644 (file)
@@ -187,6 +187,8 @@ const float STAT_WEAPONS3 = 75;
 const float STAT_MONSTERS_TOTAL = 76;
 const float STAT_MONSTERS_KILLED = 77;
 
+const float STAT_ROUNDLOST = 96;
+
 // mod stats (1xx)
 const float STAT_REDALIVE = 100;
 const float STAT_BLUEALIVE = 101;
index 3c0afec9827f87010a6c7fe4a7b67117dfb178b5..656b80d5fb582fa4d771b0f94e679aede4bd6fe3 100644 (file)
@@ -63,7 +63,7 @@ REGISTER_GAMETYPE(_("Key Hunt"),kh,g_keyhunt,KEYHUNT,"timelimit=20 pointlimit=10
 REGISTER_GAMETYPE(_("Assault"),as,g_assault,ASSAULT,"timelimit=20");
 #define g_assault IS_GAMETYPE(ASSAULT)
 
-REGISTER_GAMETYPE(_("Onslaught"),ons,g_onslaught,ONSLAUGHT,"timelimit=20");
+REGISTER_GAMETYPE(_("Onslaught"),ons,g_onslaught,ONSLAUGHT,"pointlimit=1 timelimit=30");
 #define g_onslaught IS_GAMETYPE(ONSLAUGHT)
 
 REGISTER_GAMETYPE(_("Nexball"),nb,g_nexball,NEXBALL,"timelimit=20 pointlimit=5 leadlimit=0");
index 81738ccd50a45db84397e5627d46f9c91ecb893e..7c12dec2fde69c030d703909ea81d5174bc7828e 100644 (file)
@@ -667,8 +667,10 @@ void Send_Notification_WOCOVA(
        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,         "3 0", _("^F2Now playing ^F4OVERTIME^F2!\n\nGenerators start now to decay.\nThe more control points your team holds,\nthe faster the enemy generator decays"), "") \
+       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!"), "") \
        MSG_CENTER_NOTIF(1, CENTER_POWERDOWN_INVISIBILITY,      0, 0, "",              CPID_POWERUP,          "0 0", _("^F2Invisibility has worn off"), "") \
        MSG_CENTER_NOTIF(1, CENTER_POWERDOWN_SHIELD,            0, 0, "",              CPID_POWERUP,          "0 0", _("^F2Shield has worn off"), "") \
index 97a39275e9e50f3c4555c13839d75de96ab7b164..5d39ccf9a6b35440a6b36d82d958efc520d9097c 100644 (file)
@@ -1278,6 +1278,8 @@ float autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay;
 float autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay_death;
 float autocvar_g_spawn_near_teammate_ignore_spawnpoint_check_health;
 float autocvar_g_spawn_near_teammate_ignore_spawnpoint_closetodeath;
+float autocvar_g_onslaught_debug;
+float autocvar_g_onslaught_teleport_wait;
 float autocvar_g_onslaught_spawn_at_controlpoints;
 var float autocvar_g_onslaught_spawn_at_controlpoints_chance = 0.5;
 float autocvar_g_onslaught_spawn_at_controlpoints_random;
@@ -1294,3 +1296,9 @@ float autocvar_g_onslaught_cp_regen;
 float autocvar_g_onslaught_gen_health;
 var float autocvar_g_onslaught_shield_force = 100;
 float autocvar_g_onslaught_allow_vehicle_touch;
+float autocvar_g_onslaught_round_timelimit;
+float autocvar_g_onslaught_point_limit;
+float autocvar_g_onslaught_warmup;
+float autocvar_g_onslaught_teleport_radius;
+float autocvar_g_onslaught_spawn_choose;
+float autocvar_g_onslaught_click_radius;
index f635bff2a2f6399e209588a9487536201c340646..5ab5eae5df0cfd0c3166a832facc8848deca8af7 100644 (file)
@@ -1653,48 +1653,6 @@ void ClearWinners(void)
                head.winning = 0;
 }
 
-// Onslaught winning condition:
-// game terminates if only one team has a working generator (or none)
-float WinningCondition_Onslaught()
-{
-       entity head;
-       float t1, t2, t3, t4;
-
-       WinningConditionHelper(); // set worldstatus
-
-       if(warmup_stage)
-               return WINNING_NO;
-
-       // first check if the game has ended
-       t1 = t2 = t3 = t4 = 0;
-       head = find(world, classname, "onslaught_generator");
-       while (head)
-       {
-               if (head.health > 0)
-               {
-                       if (head.team == NUM_TEAM_1) t1 = 1;
-                       if (head.team == NUM_TEAM_2) t2 = 1;
-                       if (head.team == NUM_TEAM_3) t3 = 1;
-                       if (head.team == NUM_TEAM_4) t4 = 1;
-               }
-               head = find(head, classname, "onslaught_generator");
-       }
-       if (t1 + t2 + t3 + t4 < 2)
-       {
-               // game over, only one team remains (or none)
-               ClearWinners();
-               if (t1) SetWinners(team, NUM_TEAM_1);
-               if (t2) SetWinners(team, NUM_TEAM_2);
-               if (t3) SetWinners(team, NUM_TEAM_3);
-               if (t4) SetWinners(team, NUM_TEAM_4);
-               dprint("Have a winner, ending game.\n");
-               return WINNING_YES;
-       }
-
-       // Two or more teams remain
-       return WINNING_NO;
-}
-
 // Assault winning condition: If the attackers triggered a round end (by fulfilling all objectives)
 // they win. Otherwise the defending team wins once the timelimit passes.
 void assault_new_round();
@@ -2075,9 +2033,6 @@ void CheckRules_World()
                return;
        }
 
-       if(g_onslaught)
-               timelimit = 0; // ONS has its own overtime rule
-
        float wantovertime;
        wantovertime = 0;
 
@@ -2163,10 +2118,6 @@ void CheckRules_World()
        {
                checkrules_status = WinningCondition_LMS();
        }
-       else if (g_onslaught)
-       {
-               checkrules_status = WinningCondition_Onslaught(); // TODO remove this?
-       }
        else
        {
                checkrules_status = WinningCondition_Scores(fraglimit, leadlimit);
index 5dc6f2e39346ff99098d6fe4a3a0768012b3db0a..459dca92801e9d91ae37a470b2010e156bf60a1c 100644 (file)
@@ -543,16 +543,6 @@ string playername(entity p)
         return p.netname;
 }
 
-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;
-}
-
 //#NO AUTOCVARS START
 
 float g_pickup_shells;
index e275850cf52119c3cc168bfc094c629897a50f73..ecf2194006a2e34dcce37fae1f0782ca91d695eb 100644 (file)
@@ -4,15 +4,17 @@
 
 float ons_CaptureShield_Customize()
 {
-       if(!self.enemy.isshielded && (onslaught_controlpoint_attackable(self.enemy, other.team) > 0 || self.enemy.classname != "onslaught_controlpoint")) { return FALSE; }
-       if(SAME_TEAM(self, other)) { return FALSE; }
+       entity e = WaypointSprite_getviewentity(other);
+
+       if(!self.enemy.isshielded && (ons_ControlPoint_Attackable(self.enemy, e.team) > 0 || self.enemy.classname != "onslaught_controlpoint")) { return FALSE; }
+       if(SAME_TEAM(self, e)) { return FALSE; }
 
        return TRUE;
 }
 
 void ons_CaptureShield_Touch()
 {
-       if(!self.enemy.isshielded && (onslaught_controlpoint_attackable(self.enemy, other.team) > 0 || self.enemy.classname != "onslaught_controlpoint")) { return; }
+       if(!self.enemy.isshielded && (ons_ControlPoint_Attackable(self.enemy, other.team) > 0 || self.enemy.classname != "onslaught_controlpoint")) { return; }
        if(!IS_PLAYER(other)) { return; }
        if(SAME_TEAM(other, self)) { return; }
 
@@ -21,12 +23,15 @@ void ons_CaptureShield_Touch()
 
        Damage(other, self, self, 0, DEATH_HURTTRIGGER, mymid, normalize(othermid - mymid) * ons_captureshield_force);
 
-       play2(other, "onslaught/damageblockedbyshield.wav");
-       
-       if(self.enemy.classname == "onslaught_generator")
-               Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_ONS_GENERATOR_SHIELDED);
-       else
-               Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_ONS_CONTROLPOINT_SHIELDED);
+       if(IS_REAL_CLIENT(other))
+       {
+               play2(other, "onslaught/damageblockedbyshield.wav");
+
+               if(self.enemy.classname == "onslaught_generator")
+                       Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_ONS_GENERATOR_SHIELDED);
+               else
+                       Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_ONS_CONTROLPOINT_SHIELDED);
+       }
 }
 
 void ons_CaptureShield_Reset()
@@ -35,7 +40,7 @@ void ons_CaptureShield_Reset()
        self.team = self.enemy.team;
 }
 
-void ons_CaptureShield_Spawn(entity generator, string themodel)
+void ons_CaptureShield_Spawn(entity generator, float is_generator)
 {
        entity shield = spawn();
 
@@ -51,64 +56,26 @@ void ons_CaptureShield_Spawn(entity generator, string themodel)
        shield.solid = SOLID_TRIGGER;
        shield.avelocity = '7 0 11';
        shield.scale = 1;
-
+       shield.model = ((is_generator) ? "models/onslaught/generator_shield.md3" : "models/onslaught/controlpoint_shield.md3");
+       
+       precache_model(shield.model);
        setorigin(shield, generator.origin);
-       setmodel(shield, themodel);
+       setmodel(shield, shield.model);
        setsize(shield, shield.scale * shield.mins, shield.scale * shield.maxs);
 }
 
-void ons_gib_damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector vforce)
-{
-       self.velocity = self.velocity + vforce;
-}
-
-.float giblifetime;
-void ons_throwgib_think()
-{
-       float d;
-
-       self.nextthink = time + 0.05;
-
-       d = self.giblifetime - time;
-
-       if(d<0)
-       {
-               self.think = SUB_Remove;
-               return;
-       }
-       if(d<1)
-               self.alpha = d;
 
-       if(d>2)
-       if(random()<0.6)
-               pointparticles(particleeffectnum("onslaught_generator_gib_flame"), self.origin, '0 0 0', 1);
-}
+// ==========
+// Junk Pile
+// ==========
 
-void ons_throwgib(vector v_from, vector v_to, string smodel, float f_lifetime, float b_burn)
+void ons_debug(string input)
 {
-       entity gib;
-
-       gib = spawn();
-
-       setmodel(gib, smodel);
-       setorigin(gib, v_from);
-       gib.solid = SOLID_CORPSE;
-       gib.movetype = MOVETYPE_BOUNCE;
-       gib.takedamage = DAMAGE_YES;
-       gib.event_damage = ons_gib_damage;
-       gib.health = -1;
-       gib.effects = EF_LOWPRECISION;
-       gib.flags = FL_NOTARGET;
-       gib.velocity = v_to;
-       gib.giblifetime = time + f_lifetime;
-
-       if (b_burn)
+       switch(autocvar_g_onslaught_debug)
        {
-               gib.think = ons_throwgib_think;
-               gib.nextthink = time + 0.05;
+               case 1: dprint(input); break;
+               case 2: print(input); break;
        }
-       else
-               SUB_SetFade(gib, gib.giblifetime, 2);
 }
 
 void FixSize(entity e)
@@ -122,6 +89,16 @@ void FixSize(entity e)
        e.maxs_z = rint(e.maxs_z);
 }
 
+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 setmodel_fixsize(entity e, string m)
 {
        setmodel(e, m);
@@ -130,79 +107,67 @@ void setmodel_fixsize(entity e, string m)
 
 void onslaught_updatelinks()
 {
-       entity l, links;
+       entity l;
        // first check if the game has ended
-       dprint("--- updatelinks ---\n");
-       links = findchain(classname, "onslaught_link");
+       ons_debug("--- updatelinks ---\n");
        // mark generators as being shielded and networked
-       l = findchain(classname, "onslaught_generator");
-       while (l)
+       for(l = ons_worldgeneratorlist; l; l = l.ons_worldgeneratornext)
        {
                if (l.iscaptured)
-                       dprint(etos(l), " (generator) belongs to team ", ftos(l.team), "\n");
+                       ons_debug(strcat(etos(l), " (generator) belongs to team ", ftos(l.team), "\n"));
                else
-                       dprint(etos(l), " (generator) is destroyed\n");
+                       ons_debug(strcat(etos(l), " (generator) is destroyed\n"));
                l.islinked = l.iscaptured;
                l.isshielded = l.iscaptured;
-               l = l.chain;
+               l.sprite.SendFlags |= 16;
        }
        // mark points as shielded and not networked
-       l = findchain(classname, "onslaught_controlpoint");
-       while (l)
+       for(l = ons_worldcplist; l; l = l.ons_worldcpnext)
        {
                l.islinked = FALSE;
                l.isshielded = TRUE;
                float i;
                for(i = 0; i < 17; ++i) { l.isgenneighbor[i] = FALSE; l.iscpneighbor[i] = FALSE; }
-               dprint(etos(l), " (point) belongs to team ", ftos(l.team), "\n");
-               l = l.chain;
+               ons_debug(strcat(etos(l), " (point) belongs to team ", ftos(l.team), "\n"));
+               l.sprite.SendFlags |= 16;
        }
        // flow power outward from the generators through the network
-       l = links;
-       while (l)
-       {
-               dprint(etos(l), " (link) connects ", etos(l.goalentity), " with ", etos(l.enemy), "\n");
-               l = l.chain;
-       }
        float stop = FALSE;
        while (!stop)
        {
                stop = TRUE;
-               l = links;
-               while (l)
+               for(l = ons_worldlinklist; l; l = l.ons_worldlinknext)
                {
                        // if both points are captured by the same team, and only one of
                        // them is powered, mark the other one as powered as well
                        if (l.enemy.iscaptured && l.goalentity.iscaptured)
                                if (l.enemy.islinked != l.goalentity.islinked)
-                                       if (l.enemy.team == l.goalentity.team)
+                                       if(SAME_TEAM(l.enemy, l.goalentity))
                                        {
                                                if (!l.goalentity.islinked)
                                                {
                                                        stop = FALSE;
                                                        l.goalentity.islinked = TRUE;
-                                                       dprint(etos(l), " (link) is marking ", etos(l.goalentity), " (point) because its team matches ", etos(l.enemy), " (point)\n");
+                                                       ons_debug(strcat(etos(l), " (link) is marking ", etos(l.goalentity), " (point) because its team matches ", etos(l.enemy), " (point)\n"));
                                                }
                                                else if (!l.enemy.islinked)
                                                {
                                                        stop = FALSE;
                                                        l.enemy.islinked = TRUE;
-                                                       dprint(etos(l), " (link) is marking ", etos(l.enemy), " (point) because its team matches ", etos(l.goalentity), " (point)\n");
+                                                       ons_debug(strcat(etos(l), " (link) is marking ", etos(l.enemy), " (point) because its team matches ", etos(l.goalentity), " (point)\n"));
                                                }
                                        }
-                       l = l.chain;
                }
        }
        // now that we know which points are powered we can mark their neighbors
        // as unshielded if team differs
-       l = links;
-       while (l)
+       for(l = ons_worldlinklist; l; l = l.ons_worldlinknext)
        {
                if (l.goalentity.islinked)
                {
                        if(DIFF_TEAM(l.goalentity, l.enemy))
                        {
-                               dprint(etos(l), " (link) is unshielding ", etos(l.enemy), " (point) because its team does not match ", etos(l.goalentity), " (point)\n");
+                               ons_debug(strcat(etos(l), " (link) is unshielding ", etos(l.enemy), " (point) because its team does not match ", etos(l.goalentity), " (point)\n"));
                                l.enemy.isshielded = FALSE;
                        }
                        if(l.goalentity.classname == "onslaught_generator")
@@ -214,7 +179,7 @@ void onslaught_updatelinks()
                {
                        if(DIFF_TEAM(l.goalentity, l.enemy))
                        {
-                               dprint(etos(l), " (link) is unshielding ", etos(l.goalentity), " (point) because its team does not match ", etos(l.enemy), " (point)\n");
+                               ons_debug(strcat(etos(l), " (link) is unshielding ", etos(l.goalentity), " (point) because its team does not match ", etos(l.enemy), " (point)\n"));
                                l.goalentity.isshielded = FALSE;
                        }
                        if(l.enemy.classname == "onslaught_generator")
@@ -222,33 +187,31 @@ void onslaught_updatelinks()
                        else
                                l.goalentity.iscpneighbor[l.enemy.team] = TRUE;
                }
-               l = l.chain;
        }
-       // now update the takedamage and alpha variables on generator shields
-       l = findchain(classname, "onslaught_generator");
-       while (l)
+       // now update the generators
+       for(l = ons_worldgeneratorlist; l; l = l.ons_worldgeneratornext)
        {
                if (l.isshielded)
                {
-                       dprint(etos(l), " (generator) is shielded\n");
+                       ons_debug(strcat(etos(l), " (generator) is shielded\n"));
                        l.takedamage = DAMAGE_NO;
                        l.bot_attack = FALSE;
                }
                else
                {
-                       dprint(etos(l), " (generator) is not shielded\n");
+                       ons_debug(strcat(etos(l), " (generator) is not shielded\n"));
                        l.takedamage = DAMAGE_AIM;
                        l.bot_attack = TRUE;
                }
-               l = l.chain;
+
+               ons_Generator_UpdateSprite(l);
        }
        // now update the takedamage and alpha variables on control point icons
-       l = findchain(classname, "onslaught_controlpoint");
-       while (l)
+       for(l = ons_worldcplist; l; l = l.ons_worldcpnext)
        {
                if (l.isshielded)
                {
-                       dprint(etos(l), " (point) is shielded\n");
+                       ons_debug(strcat(etos(l), " (point) is shielded\n"));
                        if (l.goalentity)
                        {
                                l.goalentity.takedamage = DAMAGE_NO;
@@ -257,33 +220,14 @@ void onslaught_updatelinks()
                }
                else
                {
-                       dprint(etos(l), " (point) is not shielded\n");
+                       ons_debug(strcat(etos(l), " (point) is not shielded\n"));
                        if (l.goalentity)
                        {
                                l.goalentity.takedamage = DAMAGE_AIM;
                                l.goalentity.bot_attack = TRUE;
                        }
                }
-               onslaught_controlpoint_updatesprite(l);
-               l = l.chain;
-       }
-       // count generators owned by each team
-       float t1 = 0, t2 = 0, t3 = 0, t4 = 0;
-       l = findchain(classname, "onslaught_generator");
-       while (l)
-       {
-               if (l.iscaptured)
-               {
-                       switch(l.team)
-                       {
-                               case NUM_TEAM_1: t1 = 1; break;
-                               case NUM_TEAM_2: t2 = 1; break;
-                               case NUM_TEAM_3: t3 = 1; break;
-                               case NUM_TEAM_4: t4 = 1; break;
-                       }
-               }
-               onslaught_generator_updatesprite(l);
-               l = l.chain;
+               ons_ControlPoint_UpdateSprite(l);
        }
        l = findchain(classname, "ons_captureshield");
        while(l)
@@ -292,22 +236,82 @@ void onslaught_updatelinks()
                l.colormap = l.enemy.colormap;
                l = l.chain;
        }
-       // see if multiple teams remain (if not, it's game over)
-       if (t1 + t2 + t3 + t4 < 2)
-               dprint("--- game over ---\n");
-       else
-               dprint("--- done updating links ---\n");
 }
 
-float onslaught_controlpoint_can_be_linked(entity cp, float t)
+
+// ===================
+// Main Link Functions
+// ===================
+
+float ons_Link_Send(entity to, float sendflags)
+{
+       WriteByte(MSG_ENTITY, ENT_CLIENT_RADARLINK);
+       WriteByte(MSG_ENTITY, sendflags);
+       if(sendflags & 1)
+       {
+               WriteCoord(MSG_ENTITY, self.goalentity.origin_x);
+               WriteCoord(MSG_ENTITY, self.goalentity.origin_y);
+               WriteCoord(MSG_ENTITY, self.goalentity.origin_z);
+       }
+       if(sendflags & 2)
+       {
+               WriteCoord(MSG_ENTITY, self.enemy.origin_x);
+               WriteCoord(MSG_ENTITY, self.enemy.origin_y);
+               WriteCoord(MSG_ENTITY, self.enemy.origin_z);
+       }
+       if(sendflags & 4)
+       {
+               WriteByte(MSG_ENTITY, self.clientcolors); // which is goalentity's color + enemy's color * 16
+       }
+       return TRUE;
+}
+
+void ons_Link_CheckUpdate()
+{
+       // TODO check if the two sides have moved (currently they won't move anyway)
+       float cc = 0, cc1 = 0, cc2 = 0;
+       
+       if(self.goalentity.islinked || self.goalentity.iscaptured) { cc1 = (self.goalentity.team - 1) * 0x01; }
+       if(self.enemy.islinked || self.enemy.iscaptured) { cc2 = (self.enemy.team - 1) * 0x10; }
+       
+       cc = cc1 + cc2;
+
+       if(cc != self.clientcolors)
+       {
+               self.clientcolors = cc;
+               self.SendFlags |= 4;
+       }
+
+       self.nextthink = time;
+}
+
+void ons_DelayedLinkSetup()
+{
+       self.goalentity = find(world, targetname, self.target);
+       self.enemy = find(world, targetname, self.target2);
+       if(!self.goalentity) { objerror("can not find target\n"); }
+       if(!self.enemy) { objerror("can not find target2\n"); }
+
+       ons_debug(strcat(etos(self.goalentity), " linked with ", etos(self.enemy), "\n"));
+       self.SendFlags |= 3;
+       self.think = ons_Link_CheckUpdate;
+       self.nextthink = time;
+}
+
+
+// =============================
+// Main Control Point Functions
+// =============================
+
+float ons_ControlPoint_CanBeLinked(entity cp, float teamnumber)
 {
-       if(cp.isgenneighbor[t]) { return 2; }
-       if(cp.iscpneighbor[t]) { return 1; }
+       if(cp.isgenneighbor[teamnumber]) { return 2; }
+       if(cp.iscpneighbor[teamnumber]) { return 1; }
 
        return 0;
 }
 
-float onslaught_controlpoint_attackable(entity cp, float t)
+float ons_ControlPoint_Attackable(entity cp, float teamnumber)
        // -2: SAME TEAM, attackable by enemy!
        // -1: SAME TEAM!
        // 0: off limits
@@ -325,16 +329,16 @@ float onslaught_controlpoint_attackable(entity cp, float t)
        else if(cp.goalentity)
        {
                // if there's already an icon built, nothing happens
-               if(cp.team == t)
+               if(cp.team == teamnumber)
                {
-                       a = onslaught_controlpoint_can_be_linked(cp, t);
+                       a = ons_ControlPoint_CanBeLinked(cp, teamnumber);
                        if(a) // attackable by enemy?
                                return -2; // EMERGENCY!
                        return -1;
                }
                // we know it can be linked, so no need to check
                // but...
-               a = onslaught_controlpoint_can_be_linked(cp, t);
+               a = ons_ControlPoint_CanBeLinked(cp, teamnumber);
                if(a == 2) // near our generator?
                        return 3; // EMERGENCY!
                return 1;
@@ -342,9 +346,9 @@ float onslaught_controlpoint_attackable(entity cp, float t)
        else
        {
                // free point
-               if(onslaught_controlpoint_can_be_linked(cp, t))
+               if(ons_ControlPoint_CanBeLinked(cp, teamnumber))
                {
-                       a = onslaught_controlpoint_can_be_linked(cp, t); // why was this here NUM_TEAM_1 + NUM_TEAM_2 - t
+                       a = ons_ControlPoint_CanBeLinked(cp, teamnumber); // why was this here NUM_TEAM_1 + NUM_TEAM_2 - t
                        if(a == 2)
                                return 4; // GET THIS ONE NOW!
                        else
@@ -354,685 +358,141 @@ float onslaught_controlpoint_attackable(entity cp, float t)
        return 0;
 }
 
-float overtime_msg_time;
-void onslaught_generator_think()
+void ons_ControlPoint_Icon_Damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
 {
-       float d;
-       entity e;
-       self.nextthink = ceil(time + 1);
-       if (!gameover)
+       entity oself;
+       
+       if(damage <= 0) { return; }
+
+       if (self.owner.isshielded)
        {
-               if (autocvar_timelimit && time > game_starttime + autocvar_timelimit * 60)
-               {
-                       if (!overtime_msg_time)
-                       {
-                               Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_OVERTIME_CONTROLPOINT);
-                               overtime_msg_time = time;
-                       }
-                       // self.max_health / 300 gives 5 minutes of overtime.
-                       // control points reduce the overtime duration.
-                       sound(self, CH_TRIGGER, "onslaught/generator_decay.wav", VOL_BASE, ATTEN_NORM);
-                       d = 1;
-                       e = findchain(classname, "onslaught_controlpoint");
-                       while (e)
+               // this is protected by a shield, so ignore the damage
+               if (time > self.pain_finished)
+                       if (IS_PLAYER(attacker))
                        {
-                               if (e.team != self.team)
-                                       if (e.islinked)
-                                               d = d + 1;
-                               e = e.chain;
+                               play2(attacker, "onslaught/damageblockedbyshield.wav");
+                               self.pain_finished = time + 1;
+                               attacker.typehitsound += 1; // play both sounds (shield is way too quiet)
                        }
 
-                       if(autocvar_g_campaign && autocvar__campaign_testrun)
-                               d = d * self.max_health;
-                       else
-                               d = d * self.max_health / max(30, 60 * autocvar_timelimit_suddendeath);
-
-                       Damage(self, self, self, d, DEATH_HURTTRIGGER, self.origin, '0 0 0');
-               }
-               else if (overtime_msg_time)
-                       overtime_msg_time = 0;
-
-        if(!self.isshielded && self.wait < time)
-        {
-            self.wait = time + 5;
-            FOR_EACH_REALPLAYER(e)
-            {
-                               if(SAME_TEAM(e, self))
-                               {
-                                       Send_Notification(NOTIF_ONE, e, MSG_CENTER, CENTER_ONS_NOTSHIELDED_TEAM);
-                    soundto(MSG_ONE, e, CHAN_AUTO, "kh/alarm.wav", VOL_BASE, ATTEN_NONE);    // FIXME: unique sound?
-                }
-                               else
-                                       Send_Notification(NOTIF_ONE, e, MSG_CENTER, APP_TEAM_NUM_4(self.team, CENTER_ONS_NOTSHIELDED_));
-            }
-        }
+               return;
        }
-}
-
-void onslaught_generator_ring_spawn(vector org)
-{
-       modeleffect_spawn("models/onslaught/shockwavetransring.md3", 0, 0, org, '0 0 0', '0 0 0', '0 0 0', 0, -16, 0.1, 1.25, 0.25);
-}
 
-void onslaught_generator_ray_think()
-{
-       self.nextthink = time + 0.05;
-       if(self.count > 10)
+       if(IS_PLAYER(attacker))
+       if(time - ons_notification_time[self.team] > 10)
        {
-               self.think = SUB_Remove;
-               return;
+               play2team(self.team, "onslaught/controlpoint_underattack.wav");
+               ons_notification_time[self.team] = time;
        }
 
-       if(self.count > 5)
-               self.alpha -= 0.1;
+       self.health = self.health - damage;
+       if(self.owner.iscaptured)
+               WaypointSprite_UpdateHealth(self.owner.sprite, self.health);
+       else
+               WaypointSprite_UpdateBuildFinished(self.owner.sprite, time + (self.max_health - self.health) / (self.count / CP_THINKRATE));
+       self.pain_finished = time + 1;
+       // particles on every hit
+       pointparticles(particleeffectnum("sparks"), hitloc, force*-1, 1);
+       //sound on every hit
+       if (random() < 0.5)
+               sound(self, CH_TRIGGER, "onslaught/ons_hit1.wav", VOL_BASE+0.3, ATTEN_NORM);
        else
-               self.alpha += 0.1;
+               sound(self, CH_TRIGGER, "onslaught/ons_hit2.wav", VOL_BASE+0.3, ATTEN_NORM);
 
-       self.scale += 0.2;
-       self.count +=1;
-}
+       if (self.health < 0)
+       {
+               sound(self, CH_TRIGGER, "weapons/grenade_impact.wav", VOL_BASE, ATTEN_NORM);
+               pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
+               Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(self.team, INFO_ONSLAUGHT_CPDESTROYED_), self.owner.message, attacker.netname);
+               
+               PlayerScore_Add(attacker, SP_ONS_TAKES, 1);
+               PlayerScore_Add(attacker, SP_SCORE, 10);
+               
+               self.owner.goalentity = world;
+               self.owner.islinked = FALSE;
+               self.owner.iscaptured = FALSE;
+               self.owner.team = 0;
+               self.owner.colormap = 1024;
 
-void onslaught_generator_ray_spawn(vector org)
-{
-       entity e;
-       e = spawn();
-       setmodel(e, "models/onslaught/ons_ray.md3");
-       setorigin(e, org);
-       e.angles = randomvec() * 360;
-       e.alpha = 0;
-       e.scale = random() * 5 + 8;
-       e.think = onslaught_generator_ray_think;
-       e.nextthink = time + 0.05;
-}
+               WaypointSprite_UpdateMaxHealth(self.owner.sprite, 0);
 
-void onslaught_generator_shockwave_spawn(vector org)
-{
-       shockwave_spawn("models/onslaught/shockwave.md3", org, -64, 0.75, 0.5);
-}
+               onslaught_updatelinks();
 
-void onslaught_generator_damage_think()
-{
-       if(self.owner.health < 0)
-       {
-               self.think = SUB_Remove;
-               return;
-       }
-       self.nextthink = time+0.1;
+               // Use targets now (somebody make sure this is in the right place..)
+               oself = self;
+               self = self.owner;
+               activator = self;
+               SUB_UseTargets ();
+               self = oself;
 
-       // damaged fx (less probable the more damaged is the generator)
-       if(random() < 0.9 - self.owner.health / self.owner.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.owner.waslinked = self.owner.islinked;
+               if(self.owner.model != "models/onslaught/controlpoint_pad.md3")
+                       setmodel_fixsize(self.owner, "models/onslaught/controlpoint_pad.md3");
+               //setsize(self, '-32 -32 0', '32 32 8');
 
-void onslaught_generator_damage_spawn(entity gd_owner)
-{
-       entity e;
-       e = spawn();
-       e.owner = gd_owner;
-       e.health = self.owner.health;
-       setorigin(e, gd_owner.origin);
-       e.think = onslaught_generator_damage_think;
-       e.nextthink = time+1;
+               remove(self);
+       }
+       
+       self.SendFlags |= CPSF_STATUS;
 }
 
-void onslaught_generator_deaththink()
+void ons_ControlPoint_Icon_Think()
 {
-       vector org;
-       float i;
-
-       if (!self.count)
-               self.count = 40;
-
-       // White shockwave
-       if(self.count==40||self.count==20)
-       {
-               onslaught_generator_ring_spawn(self.origin);
-               sound(self, CH_TRIGGER, "onslaught/shockwave.wav", VOL_BASE, ATTEN_NORM);
-       }
+       entity oself;
+       self.nextthink = time + CP_THINKRATE;
 
-       // Throw some gibs
-       if(random() < 0.3)
+       if(autocvar_g_onslaught_cp_proxydecap)
        {
-               i = random();
-               if(i < 0.3)
-                       ons_throwgib(self.origin + '0 0 40', (100 * randomvec() - '1 1 1') * 11 + '0 0 20', "models/onslaught/gen_gib1.md3", 6, TRUE);
-               else if(i > 0.7)
-                       ons_throwgib(self.origin + '0 0 40', (100 * randomvec() - '1 1 1') * 12 + '0 0 20', "models/onslaught/gen_gib2.md3", 6, TRUE);
-               else
-                       ons_throwgib(self.origin + '0 0 40', (100 * randomvec() - '1 1 1') * 13 + '0 0 20', "models/onslaught/gen_gib3.md3", 6, TRUE);
-       }
+        float _enemy_count = 0;
+        float _friendly_count = 0;
+        float _dist;
+        entity _player;
 
-       // 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);
-       }
+        FOR_EACH_PLAYER(_player)
+        {
+            if(!_player.deadflag)
+            {
+                _dist = vlen(_player.origin - self.origin);
+                if(_dist < autocvar_g_onslaught_cp_proxydecap_distance)
+                {
+                                       if(SAME_TEAM(_player, self))
+                        ++_friendly_count;
+                    else
+                        ++_enemy_count;
+                }
+            }
+        }
 
-       // 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);
-       }
+        _friendly_count = _friendly_count * (autocvar_g_onslaught_cp_proxydecap_dps * CP_THINKRATE);
+        _enemy_count = _enemy_count * (autocvar_g_onslaught_cp_proxydecap_dps * CP_THINKRATE);
 
-       // 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);
+        self.health = bound(0, self.health + (_friendly_count - _enemy_count), self.max_health);
+               self.SendFlags |= CPSF_STATUS;
+        if(self.health <= 0)
+        {
+            ons_ControlPoint_Icon_Damage(self, self, 1, 0, self.origin, '0 0 0');
+            return;
+        }
+    }
 
-       // rays
-       if(random() > 0.25 )
+       if (time > self.pain_finished + 5)
        {
-               onslaught_generator_ray_spawn(self.origin);
+               if(self.health < self.max_health)
+               {
+                       self.health = self.health + self.count;
+                       if (self.health >= self.max_health)
+                               self.health = self.max_health;
+                       WaypointSprite_UpdateHealth(self.owner.sprite, self.health);
+               }
        }
 
-       // Final explosion
-       if(self.count==1)
+       if(self.owner.islinked != self.owner.waslinked)
        {
-               org = self.origin;
-               te_explosion(org);
-               onslaught_generator_shockwave_spawn(org);
-               pointparticles(particleeffectnum("onslaught_generator_finalexplosion"), org, '0 0 0', 1);
-               sound(self, CH_TRIGGER, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
-       }
-       else
-               self.nextthink = time + 0.05;
-
-       self.count = self.count - 1;
-}
-
-void onslaught_generator_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
-{
-       float i;
-       if (damage <= 0)
-               return;
-       if(warmup_stage)
-               return;
-       if (attacker != self)
-       {
-               if (self.isshielded)
-               {
-                       // this is protected by a shield, so ignore the damage
-                       if (time > self.pain_finished)
-                               if (IS_PLAYER(attacker))
-                               {
-                                       play2(attacker, "onslaught/damageblockedbyshield.wav");
-                                       self.pain_finished = time + 1;
-                               }
-                       return;
-               }
-               if (time > self.pain_finished)
-               {
-                       self.pain_finished = time + 10;
-                       entity head;
-                       FOR_EACH_REALPLAYER(head) if(SAME_TEAM(head, self)) { Send_Notification(NOTIF_ONE, head, MSG_CENTER, CENTER_GENERATOR_UNDERATTACK); }
-                       play2team(self.team, "onslaught/generator_underattack.wav");
-               }
-       }
-       self.health = self.health - damage;
-       WaypointSprite_UpdateHealth(self.sprite, self.health);
-       // choose an animation frame based on health
-       self.frame = 10 * bound(0, (1 - self.health / self.max_health), 1);
-       // see if the generator is still functional, or dying
-       if (self.health > 0)
-       {
-               self.lasthealth = self.health;
-       }
-       else if (!warmup_stage)
-       {
-               if (attacker == self)
-                       Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(self.team, INFO_ONSLAUGHT_GENDESTROYED_OVERTIME_));
-               else
-               {
-                       Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(self.team, INFO_ONSLAUGHT_GENDESTROYED_));
-                       PlayerScore_Add(attacker, SP_SCORE, 100);
-               }
-               self.iscaptured = FALSE;
-               self.islinked = FALSE;
-               self.isshielded = FALSE;
-               self.takedamage = DAMAGE_NO; // can't be hurt anymore
-               self.event_damage = func_null; // won't do anything if hurt
-               self.count = 0; // reset counter
-               self.think = onslaught_generator_deaththink; // explosion sequence
-               self.nextthink = time; // start exploding immediately
-               self.think(); // do the first explosion now
-
-               WaypointSprite_UpdateMaxHealth(self.sprite, 0);
-
-               onslaught_updatelinks();
-       }
-
-       // Throw some flaming gibs on damage, more damage = more chance for gib
-       if(random() < damage/220)
-       {
-               sound(self, CH_TRIGGER, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
-               i = random();
-               if(i < 0.3)
-                       ons_throwgib(hitloc + '0 0 20', force * -1, "models/onslaught/gen_gib1.md3", 5, TRUE);
-               else if(i > 0.7)
-                       ons_throwgib(hitloc + '0 0 20', force * -1, "models/onslaught/gen_gib2.md3", 5, TRUE);
-               else
-                       ons_throwgib(hitloc + '0 0 20', force * -1, "models/onslaught/gen_gib3.md3", 5, TRUE);
-       }
-       else
-       {
-               // particles on every hit
-               pointparticles(particleeffectnum("sparks"), hitloc, force * -1, 1);
-
-               //sound on every hit
-               if (random() < 0.5)
-                       sound(self, CH_TRIGGER, "onslaught/ons_hit1.wav", VOL_BASE, ATTEN_NORM);
-               else
-                       sound(self, CH_TRIGGER, "onslaught/ons_hit2.wav", VOL_BASE, ATTEN_NORM);
-       }
-
-       //throw some gibs on damage
-       if(random() < damage/200+0.2)
-               if(random() < 0.5)
-                       ons_throwgib(hitloc + '0 0 20', randomvec()*360, "models/onslaught/gen_gib1.md3", 5, FALSE);
-
-       self.SendFlags |= GSF_STATUS;
-}
-
-// update links after a delay
-void onslaught_generator_delayed()
-{
-       onslaught_updatelinks();
-       // now begin normal thinking
-       generator_link(onslaught_generator_think);
-
-       self.SendFlags = GSF_SETUP;
-}
-
-string onslaught_generator_waypointsprite_for_team(entity e, float t)
-{
-       if(t != e.team)
-       if(e.isshielded)
-               return "ons-gen-shielded";
-       switch(e.team)
-       {
-               case NUM_TEAM_1: return "ons-gen-red";
-               case NUM_TEAM_2: return "ons-gen-blue";
-               case NUM_TEAM_3: return "ons-gen-yellow";
-               case NUM_TEAM_4: return "ons-gen-pink";
-       }
-       return "";
-}
-
-void onslaught_generator_updatesprite(entity e)
-{
-       string s1, s2, s3;
-       s1 = onslaught_generator_waypointsprite_for_team(e, NUM_TEAM_1);
-       s2 = onslaught_generator_waypointsprite_for_team(e, NUM_TEAM_2);
-       s3 = onslaught_generator_waypointsprite_for_team(e, -1);
-       WaypointSprite_UpdateSprites(e.sprite, s1, s2, s3);
-
-       if(e.lastteam != e.team + 2 || e.lastshielded != e.isshielded)
-       {
-               e.lastteam = e.team + 2;
-               e.lastshielded = e.isshielded;
-               if(e.lastshielded)
-               {
-                       if(e.team == NUM_TEAM_1 || e.team == NUM_TEAM_2 || e.team == NUM_TEAM_3 || e.team == NUM_TEAM_4)
-                               WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, 0.5 * colormapPaletteColor(e.team - 1, FALSE));
-                       else
-                               WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0.5 0.5 0.5');
-               }
-               else
-               {
-                       if(e.team == NUM_TEAM_1 || e.team == NUM_TEAM_2 || e.team == NUM_TEAM_3 || e.team == NUM_TEAM_4)
-                               WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, colormapPaletteColor(e.team - 1, FALSE));
-                       else
-                               WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0.75 0.75 0.75');
-               }
-               WaypointSprite_Ping(e.sprite);
-       }
-}
-
-string onslaught_controlpoint_waypointsprite_for_team(entity e, float t)
-{
-       float a;
-       if(t != -1)
-       {
-               a = onslaught_controlpoint_attackable(e, t);
-               if(a == 3 || a == 4) // ATTACK/TOUCH THIS ONE NOW
-               {
-                       switch(e.team)
-                       {
-                               case NUM_TEAM_1: return "ons-cp-atck-red";
-                               case NUM_TEAM_2: return "ons-cp-atck-blue";
-                               case NUM_TEAM_3: return "ons-cp-atck-yellow";
-                               case NUM_TEAM_4: return "ons-cp-atck-pink";
-                               default: return "ons-cp-atck-neut";
-                       }
-               }
-               else if(a == -2) // DEFEND THIS ONE NOW
-               {
-                       switch(e.team)
-                       {
-                               case NUM_TEAM_1: return "ons-cp-dfnd-red";
-                               case NUM_TEAM_2: return "ons-cp-dfnd-blue";
-                               case NUM_TEAM_3: return "ons-cp-dfnd-yellow";
-                               case NUM_TEAM_4: return "ons-cp-dfnd-pink";
-                       }
-               }
-               else if(e.team == t || a == -1 || a == 1) // own point, or fire at it
-               {
-                       switch(e.team)
-                       {
-                               case NUM_TEAM_1: return "ons-cp-red";
-                               case NUM_TEAM_2: return "ons-cp-blue";
-                               case NUM_TEAM_3: return "ons-cp-yellow";
-                               case NUM_TEAM_4: return "ons-cp-pink";
-                       }
-               }
-               else if(a == 2) // touch it
-                       return "ons-cp-neut";
-       }
-       else
-       {
-               switch(e.team)
-               {
-                       case NUM_TEAM_1: return "ons-cp-red";
-                       case NUM_TEAM_2: return "ons-cp-blue";
-                       case NUM_TEAM_3: return "ons-cp-yellow";
-                       case NUM_TEAM_4: return "ons-cp-pink";
-                       default: return "ons-cp-neut";
-               }
-       }
-       return "";
-}
-
-void onslaught_controlpoint_updatesprite(entity e)
-{
-       string s1, s2, s3;
-       s1 = onslaught_controlpoint_waypointsprite_for_team(e, NUM_TEAM_1);
-       s2 = onslaught_controlpoint_waypointsprite_for_team(e, NUM_TEAM_2);
-       s3 = onslaught_controlpoint_waypointsprite_for_team(e, -1);
-       WaypointSprite_UpdateSprites(e.sprite, s1, s2, s3);
-
-       float sh;
-       sh = !(onslaught_controlpoint_can_be_linked(e, NUM_TEAM_1) || onslaught_controlpoint_can_be_linked(e, NUM_TEAM_2));
-
-       if(e.lastteam != e.team + 2 || e.lastshielded != sh || e.iscaptured != e.lastcaptured)
-       {
-               if(e.iscaptured) // don't mess up build bars!
-               {
-                       if(sh)
-                       {
-                               WaypointSprite_UpdateMaxHealth(e.sprite, 0);
-                       }
-                       else
-                       {
-                               WaypointSprite_UpdateMaxHealth(e.sprite, e.goalentity.max_health);
-                               WaypointSprite_UpdateHealth(e.sprite, e.goalentity.health);
-                       }
-               }
-               if(e.lastshielded)
-               {
-                       if(e.team == NUM_TEAM_1 || e.team == NUM_TEAM_2 || e.team == NUM_TEAM_3 || e.team == NUM_TEAM_4)
-                               WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, 0.5 * colormapPaletteColor(e.team - 1, FALSE));
-                       else
-                               WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0.5 0.5 0.5');
-               }
-               else
-               {
-                       if(e.team == NUM_TEAM_1 || e.team == NUM_TEAM_2 || e.team == NUM_TEAM_3 || e.team == NUM_TEAM_4)
-                               WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, colormapPaletteColor(e.team - 1, FALSE));
-                       else
-                               WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0.75 0.75 0.75');
-               }
-               WaypointSprite_Ping(e.sprite);
-
-               e.lastteam = e.team + 2;
-               e.lastshielded = sh;
-               e.lastcaptured = e.iscaptured;
-       }
-}
-
-void onslaught_generator_reset()
-{
-       self.team = self.team_saved;
-       self.lasthealth = self.max_health = self.health = autocvar_g_onslaught_gen_health;
-       self.takedamage = DAMAGE_AIM;
-       self.bot_attack = TRUE;
-       self.iscaptured = TRUE;
-       self.islinked = TRUE;
-       self.isshielded = TRUE;
-       self.think = onslaught_generator_delayed;
-       self.nextthink = time + 0.2;
-       setmodel(self, "models/onslaught/generator.md3");
-       setsize(self, GENERATOR_MIN, GENERATOR_MAX);
-
-       self.SendFlags |= GSF_STATUS;
-
-       if(!self.noalign)
-       {
-               setorigin(self, self.origin + '0 0 20');
-               droptofloor();
-       }
-
-       WaypointSprite_UpdateMaxHealth(self.sprite, self.max_health);
-       WaypointSprite_UpdateHealth(self.sprite, self.health);
-}
-
-/*QUAKED spawnfunc_onslaught_generator (0 .5 .8) (-32 -32 -24) (32 32 64)
-  Base generator.
-
-  spawnfunc_onslaught_link entities can target this.
-
-keys:
-"team" - team that owns this generator (5 = red, 14 = blue, etc), MUST BE SET.
-"targetname" - name that spawnfunc_onslaught_link entities will use to target this.
- */
-void spawnfunc_onslaught_generator()
-{
-       if(!g_onslaught) { remove(self); return; }
-
-       //entity e;
-       precache_model("models/onslaught/generator.md3");
-       precache_model("models/onslaught/generator_shield.md3");
-       precache_model("models/onslaught/shockwave.md3");
-       precache_model("models/onslaught/shockwavetransring.md3");
-       precache_model("models/onslaught/gen_gib1.md3");
-       precache_model("models/onslaught/gen_gib2.md3");
-       precache_model("models/onslaught/gen_gib3.md3");
-       precache_model("models/onslaught/ons_ray.md3");
-       precache_sound("onslaught/generator_decay.wav");
-       precache_sound("weapons/grenade_impact.wav");
-       precache_sound("weapons/rocket_impact.wav");
-       precache_sound("onslaught/generator_underattack.wav");
-       precache_sound("onslaught/shockwave.wav");
-       precache_sound("onslaught/ons_hit1.wav");
-       precache_sound("onslaught/ons_hit2.wav");
-       precache_sound("onslaught/electricity_explode.wav");
-       precache_sound("onslaught/generator_underattack.wav");
-       if (!self.team)
-               objerror("team must be set");
-
-       ons_generator[self.team] = self;
-       self.team_saved = self.team;
-       self.colormap = 1024 + (self.team - 1) * 17;
-       self.solid = SOLID_BBOX;
-       self.movetype = MOVETYPE_NONE;
-       self.lasthealth = self.max_health = self.health = autocvar_g_onslaught_gen_health;
-       setmodel(self, "models/onslaught/generator.md3");
-       setsize(self, GENERATOR_MIN, GENERATOR_MAX);
-       setorigin(self, self.origin);
-       self.takedamage = DAMAGE_AIM;
-       self.bot_attack = TRUE;
-       self.event_damage = onslaught_generator_damage;
-       self.iscaptured = TRUE;
-       self.islinked = TRUE;
-       self.isshielded = TRUE;
-       // helper entity that create fx when generator is damaged
-       onslaught_generator_damage_spawn(self);
-
-       ons_CaptureShield_Spawn(self, "models/onslaught/generator_shield.md3");
-       
-       InitializeEntity(self, onslaught_generator_delayed, INITPRIO_LAST);
-
-       WaypointSprite_SpawnFixed(string_null, self.origin + '0 0 128', self, sprite, RADARICON_NONE, '0 0 0');
-       WaypointSprite_UpdateRule(self.sprite, NUM_TEAM_2, SPRITERULE_TEAMPLAY);
-       WaypointSprite_UpdateMaxHealth(self.sprite, self.max_health);
-       WaypointSprite_UpdateHealth(self.sprite, self.health);
-
-       waypoint_spawnforitem(self);
-
-       onslaught_updatelinks();
-
-       self.reset = onslaught_generator_reset;
-}
-
-.float waslinked;
-
-void onslaught_controlpoint_icon_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
-{
-       entity oself;
-
-       if (damage <= 0)
-               return;
-       if (self.owner.isshielded)
-       {
-               // this is protected by a shield, so ignore the damage
-               if (time > self.pain_finished)
-                       if (IS_PLAYER(attacker))
-                       {
-                               play2(attacker, "onslaught/damageblockedbyshield.wav");
-                               self.pain_finished = time + 1;
-                       }
-               return;
-       }
-
-       if(IS_PLAYER(attacker))
-       if(time - ons_notification_time[self.team] > 10)
-       {
-               play2team(self.team, "onslaught/controlpoint_underattack.wav");
-               ons_notification_time[self.team] = time;
-       }
-
-       self.health = self.health - damage;
-       if(self.owner.iscaptured)
-               WaypointSprite_UpdateHealth(self.owner.sprite, self.health);
-       else
-               WaypointSprite_UpdateBuildFinished(self.owner.sprite, time + (self.max_health - self.health) / (self.count / CP_THINKRATE));
-       self.pain_finished = time + 1;
-       // particles on every hit
-       pointparticles(particleeffectnum("sparks"), hitloc, force*-1, 1);
-       //sound on every hit
-       if (random() < 0.5)
-               sound(self, CH_TRIGGER, "onslaught/ons_hit1.wav", VOL_BASE+0.3, ATTEN_NORM);
-       else
-               sound(self, CH_TRIGGER, "onslaught/ons_hit2.wav", VOL_BASE+0.3, ATTEN_NORM);
-
-       if (self.health < 0)
-       {
-               sound(self, CH_TRIGGER, "weapons/grenade_impact.wav", VOL_BASE, ATTEN_NORM);
-               pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
-               {
-                       Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(self.team, INFO_ONSLAUGHT_CPDESTROYED_), self.owner.message, attacker.netname);
-                       ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 25, "models/onslaught/controlpoint_icon_gib1.md3", 3, FALSE);
-                       ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 45, "models/onslaught/controlpoint_icon_gib2.md3", 3, FALSE);
-                       ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 45, "models/onslaught/controlpoint_icon_gib2.md3", 3, FALSE);
-                       ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 75, "models/onslaught/controlpoint_icon_gib4.md3", 3, FALSE);
-                       ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 75, "models/onslaught/controlpoint_icon_gib4.md3", 3, FALSE);
-                       ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 75, "models/onslaught/controlpoint_icon_gib4.md3", 3, FALSE);
-                       ons_throwgib(self.origin, (2 * randomvec() - '1 1 1') * 75, "models/onslaught/controlpoint_icon_gib4.md3", 3, FALSE);
-               }
-
-               PlayerScore_Add(attacker, SP_ONS_TAKES, 1);
-               PlayerScore_Add(attacker, SP_SCORE, 10);
-
-               self.owner.goalentity = world;
-               self.owner.islinked = FALSE;
-               self.owner.iscaptured = FALSE;
-               self.owner.team = 0;
-               self.owner.colormap = 1024;
-
-               WaypointSprite_UpdateMaxHealth(self.owner.sprite, 0);
-
-               onslaught_updatelinks();
-
-               // Use targets now (somebody make sure this is in the right place..)
-               oself = self;
-               self = self.owner;
-               activator = self;
-               SUB_UseTargets ();
-               self = oself;
-
-               self.owner.waslinked = self.owner.islinked;
-               if(self.owner.model != "models/onslaught/controlpoint_pad.md3")
-                       setmodel_fixsize(self.owner, "models/onslaught/controlpoint_pad.md3");
-
-               remove(self);
-       }
-
-       self.SendFlags |= CPSF_STATUS;
-}
-
-void onslaught_controlpoint_icon_think()
-{
-       entity oself;
-       self.nextthink = time + CP_THINKRATE;
-
-       if(autocvar_g_onslaught_cp_proxydecap)
-       {
-        float _enemy_count = 0;
-        float _friendly_count = 0;
-        float _dist;
-        entity _player;
-
-        FOR_EACH_PLAYER(_player)
-        {
-            if(!_player.deadflag)
-            {
-                _dist = vlen(_player.origin - self.origin);
-                if(_dist < autocvar_g_onslaught_cp_proxydecap_distance)
-                {
-                                       if(SAME_TEAM(_player, self))
-                        ++_friendly_count;
-                    else
-                        ++_enemy_count;
-                }
-            }
-        }
-
-        _friendly_count = _friendly_count * (autocvar_g_onslaught_cp_proxydecap_dps * CP_THINKRATE);
-        _enemy_count = _enemy_count * (autocvar_g_onslaught_cp_proxydecap_dps * CP_THINKRATE);
-
-        self.health = bound(0, self.health + (_friendly_count - _enemy_count), self.max_health);
-               self.SendFlags |= CPSF_STATUS;
-        if(self.health <= 0)
-        {
-            onslaught_controlpoint_icon_damage(self, self, 1, 0, self.origin, '0 0 0');
-            return;
-        }
-    }
-
-       if (time > self.pain_finished + 5)
-       {
-               if(self.health < self.max_health)
-               {
-                       self.health = self.health + self.count;
-                       if (self.health >= self.max_health)
-                               self.health = self.max_health;
-                       WaypointSprite_UpdateHealth(self.owner.sprite, self.health);
-               }
-       }
-
-       if(self.owner.islinked != self.owner.waslinked)
-       {
-               // unteam the spawnpoint if needed
-               float t;
-               t = self.owner.team;
-               if(!self.owner.islinked)
-                       self.owner.team = 0;
+               // unteam the spawnpoint if needed
+               float t;
+               t = self.owner.team;
+               if(!self.owner.islinked)
+                       self.owner.team = 0;
 
                oself = self;
                self = self.owner;
@@ -1057,7 +517,7 @@ void onslaught_controlpoint_icon_think()
        }
 }
 
-void onslaught_controlpoint_icon_buildthink()
+void ons_ControlPoint_Icon_BuildThink()
 {
        entity oself;
        float a;
@@ -1065,31 +525,36 @@ void onslaught_controlpoint_icon_buildthink()
        self.nextthink = time + CP_THINKRATE;
 
        // only do this if there is power
-       a = onslaught_controlpoint_can_be_linked(self.owner, self.owner.team);
+       a = ons_ControlPoint_CanBeLinked(self.owner, self.owner.team);
        if(!a)
                return;
 
        self.health = self.health + self.count;
-
+       
        self.SendFlags |= CPSF_STATUS;
 
        if (self.health >= self.max_health)
        {
                self.health = self.max_health;
                self.count = autocvar_g_onslaught_cp_regen * CP_THINKRATE; // slow repair rate from now on
-               self.think = onslaught_controlpoint_icon_think;
+               self.think = ons_ControlPoint_Icon_Think;
                sound(self, CH_TRIGGER, "onslaught/controlpoint_built.wav", VOL_BASE, ATTEN_NORM);
                self.owner.iscaptured = TRUE;
                self.solid = SOLID_BBOX;
 
+               pointparticles(particleeffectnum(sprintf("%s_cap", Static_Team_ColorName_Lower(self.owner.team))), self.owner.origin, '0 0 0', 1);
+
                WaypointSprite_UpdateMaxHealth(self.owner.sprite, self.max_health);
                WaypointSprite_UpdateHealth(self.owner.sprite, self.health);
 
-               Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ONSLAUGHT_CAPTURE, self.owner.ons_toucher.netname, self.owner.message);
-               Send_Notification(NOTIF_ALL_EXCEPT, self.owner.ons_toucher, MSG_CENTER, APP_TEAM_ENT_4(self.owner.ons_toucher, CENTER_ONS_CAPTURE_), self.owner.message);
-               Send_Notification(NOTIF_ONE, self.owner.ons_toucher, MSG_CENTER, CENTER_ONS_CAPTURE, self.owner.message);
-               PlayerTeamScore_Add(self.owner.ons_toucher, SP_ONS_CAPS, ST_ONS_CAPS, 1);
-               PlayerTeamScore_AddScore(self.owner.ons_toucher, 10);
+               if(IS_PLAYER(self.owner.ons_toucher))
+               {
+                       Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ONSLAUGHT_CAPTURE, self.owner.ons_toucher.netname, self.owner.message);
+                       Send_Notification(NOTIF_ALL_EXCEPT, self.owner.ons_toucher, MSG_CENTER, APP_TEAM_ENT_4(self.owner.ons_toucher, CENTER_ONS_CAPTURE_), self.owner.message);
+                       Send_Notification(NOTIF_ONE, self.owner.ons_toucher, MSG_CENTER, CENTER_ONS_CAPTURE, self.owner.message);
+                       PlayerScore_Add(self.owner.ons_toucher, SP_ONS_CAPS, 1);
+                       PlayerTeamScore_AddScore(self.owner.ons_toucher, 10);
+               }
                
                self.owner.ons_toucher = world;
 
@@ -1101,7 +566,7 @@ void onslaught_controlpoint_icon_buildthink()
                activator = self;
                SUB_UseTargets ();
                self = oself;
-
+               
                self.SendFlags |= CPSF_SETUP;
        }
        if(self.owner.model != "models/onslaught/controlpoint_pad2.md3")
@@ -1111,74 +576,162 @@ void onslaught_controlpoint_icon_buildthink()
                pointparticles(particleeffectnum("rage"), self.origin + 10 * randomvec(), '0 0 -1', 1);
 }
 
-void onslaught_controlpoint_touch()
+void ons_ControlPoint_Icon_Spawn(entity cp, entity player)
+{
+       entity e = spawn();
+       
+       setsize(e, CPICON_MIN, CPICON_MAX);
+       setorigin(e, cp.origin + CPICON_OFFSET);
+       
+       e.classname = "onslaught_controlpoint_icon";
+       e.owner = cp;
+       e.max_health = autocvar_g_onslaught_cp_health;
+       e.health = autocvar_g_onslaught_cp_buildhealth;
+       e.solid = SOLID_NOT;
+       e.takedamage = DAMAGE_AIM;
+       e.bot_attack = TRUE;
+       e.event_damage = ons_ControlPoint_Icon_Damage;
+       e.team = player.team;
+       e.colormap = 1024 + (e.team - 1) * 17;
+       e.count = (e.max_health - e.health) * CP_THINKRATE / autocvar_g_onslaught_cp_buildtime; // how long it takes to build
+       
+       sound(e, CH_TRIGGER, "onslaught/controlpoint_build.wav", VOL_BASE, ATTEN_NORM);
+       
+       cp.goalentity = e;
+       cp.team = e.team;
+       cp.colormap = e.colormap;
+
+       pointparticles(particleeffectnum(sprintf("%sflag_touch", Static_Team_ColorName_Lower(player.team))), e.origin, '0 0 0', 1);
+
+       WaypointSprite_UpdateBuildFinished(cp.sprite, time + (e.max_health - e.health) / (e.count / CP_THINKRATE));
+       WaypointSprite_UpdateRule(cp.sprite,cp.team,SPRITERULE_TEAMPLAY);
+       cp.sprite.SendFlags |= 16;
+
+       onslaught_controlpoint_icon_link(e, ons_ControlPoint_Icon_BuildThink);
+}
+
+string ons_ControlPoint_Waypoint(entity e)
+{
+       float a;
+       if(e.team)
+       {
+               a = ons_ControlPoint_Attackable(e, e.team);
+               
+               if(a == -2) { return "ons-cp-dfnd"; } // defend now
+               if(a == -1 || a == 1 || a == 2) { return "ons-cp"; } // touch
+               if(a == 3 || a == 4) { return "ons-cp-atck"; } // attack
+       }
+       else
+               return "ons-cp";
+
+       return "";
+}
+
+void ons_ControlPoint_UpdateSprite(entity e)
+{
+       string s1;
+       s1 = ons_ControlPoint_Waypoint(e);
+       WaypointSprite_UpdateSprites(e.sprite, s1, s1, s1);
+
+       float sh;
+       sh = !(ons_ControlPoint_CanBeLinked(e, NUM_TEAM_1) || ons_ControlPoint_CanBeLinked(e, NUM_TEAM_2) || ons_ControlPoint_CanBeLinked(e, NUM_TEAM_3) || ons_ControlPoint_CanBeLinked(e, NUM_TEAM_4));
+
+       if(e.lastteam != e.team + 2 || e.lastshielded != sh || e.iscaptured != e.lastcaptured)
+       {
+               if(e.iscaptured) // don't mess up build bars!
+               {
+                       if(sh)
+                       {
+                               WaypointSprite_UpdateMaxHealth(e.sprite, 0);
+                       }
+                       else
+                       {
+                               WaypointSprite_UpdateMaxHealth(e.sprite, e.goalentity.max_health);
+                               WaypointSprite_UpdateHealth(e.sprite, e.goalentity.health);
+                       }
+               }
+               if(e.lastshielded)
+               {
+                       if(e.team)
+                               WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, 0.5 * colormapPaletteColor(e.team - 1, FALSE));
+                       else
+                               WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0.5 0.5 0.5');
+               }
+               else
+               {
+                       if(e.team)
+                               WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, colormapPaletteColor(e.team - 1, FALSE));
+                       else
+                               WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_CONTROLPOINT, '0.75 0.75 0.75');
+               }
+               WaypointSprite_Ping(e.sprite);
+
+               e.lastteam = e.team + 2;
+               e.lastshielded = sh;
+               e.lastcaptured = e.iscaptured;
+       }
+}
+
+void ons_ControlPoint_Touch()
 {
-       entity e, toucher = other;
-       float a;
-
+       entity toucher = other;
+       float attackable;
+       
        if((toucher.vehicle_flags & VHF_ISVEHICLE) && toucher.owner)
        if(autocvar_g_onslaught_allow_vehicle_touch)
                toucher = toucher.owner;
        else
                return;
-
+               
        if(!IS_PLAYER(toucher)) { return; }
-
-       a = onslaught_controlpoint_attackable(self, other.team);
-       if(a != 2 && a != 4)
+       if(toucher.deadflag != DEAD_NO) { return; }
+       
+       if ( SAME_TEAM(self,toucher) )
+       if ( self.iscaptured )
+       {
+               if(time <= toucher.teleport_antispam)
+                       Send_Notification(NOTIF_ONE, toucher, MSG_CENTER, CENTER_ONS_TELEPORT_ANTISPAM, rint(toucher.teleport_antispam - time));
+               else
+                       Send_Notification(NOTIF_ONE, toucher, MSG_CENTER, CENTER_ONS_TELEPORT);
+       }
+               
+       attackable = ons_ControlPoint_Attackable(self, toucher.team);
+       if(attackable != 2 && attackable != 4)
                return;
        // we've verified that this player has a legitimate claim to this point,
        // so start building the captured point icon (which only captures this
        // point if it successfully builds without being destroyed first)
-       self.goalentity = e = spawn();
-       e.classname = "onslaught_controlpoint_icon";
-       e.owner = self;
-       e.max_health = autocvar_g_onslaught_cp_health;
-       e.health = autocvar_g_onslaught_cp_buildhealth;
-       e.solid = SOLID_NOT;
-       e.movetype = MOVETYPE_NONE;
-       //setmodel(e, "models/onslaught/controlpoint_icon.md3");
-       setsize(e, CPICON_MIN, CPICON_MAX);
-       setorigin(e, self.origin + '0 0 96');
-       e.takedamage = DAMAGE_AIM;
-       e.bot_attack = TRUE;
-       e.event_damage = onslaught_controlpoint_icon_damage;
-       e.team = other.team;
-       e.colormap = 1024 + (e.team - 1) * 17;
-       e.count = (e.max_health - e.health) * CP_THINKRATE / autocvar_g_onslaught_cp_buildtime; // how long it takes to build
-       sound(e, CH_TRIGGER, "onslaught/controlpoint_build.wav", VOL_BASE, ATTEN_NORM);
-       self.team = e.team;
-       self.colormap = e.colormap;
-       WaypointSprite_UpdateBuildFinished(self.sprite, time + (e.max_health - e.health) / (e.count / CP_THINKRATE));
-       self.ons_toucher = other;
-       onslaught_updatelinks();
+       ons_ControlPoint_Icon_Spawn(self, toucher);
+       
+       self.ons_toucher = toucher;
 
-       onslaught_controlpoint_icon_link(e, onslaught_controlpoint_icon_buildthink);
+       onslaught_updatelinks();
 }
 
-void onslaught_controlpoint_think()
+void ons_ControlPoint_Think()
 {
        self.nextthink = time + CP_THINKRATE;
        CSQCMODEL_AUTOUPDATE();
 }
 
-void onslaught_controlpoint_reset()
+void ons_ControlPoint_Reset()
 {
-       if(self.goalentity && self.goalentity != world)
+       if(self.goalentity)
                remove(self.goalentity);
+
        self.goalentity = world;
        self.team = 0;
        self.colormap = 1024;
        self.iscaptured = FALSE;
        self.islinked = FALSE;
        self.isshielded = TRUE;
-       self.think = onslaught_controlpoint_think;
+       self.think = ons_ControlPoint_Think;
        self.ons_toucher = world;
-       self.nextthink = time + CP_THINKRATE; // don't like func_null :P
+       self.nextthink = time + CP_THINKRATE;
        setmodel_fixsize(self, "models/onslaught/controlpoint_pad.md3");
-       //setsize(self, '-32 -32 0', '32 32 8');
 
        WaypointSprite_UpdateMaxHealth(self.sprite, 0);
+       WaypointSprite_UpdateRule(self.sprite,self.team,SPRITERULE_TEAMPLAY);
 
        onslaught_updatelinks();
 
@@ -1188,21 +741,41 @@ void onslaught_controlpoint_reset()
        CSQCMODEL_AUTOUPDATE();
 }
 
-/*QUAKED spawnfunc_onslaught_controlpoint (0 .5 .8) (-32 -32 0) (32 32 128)
-  Control point. Be sure to give this enough clearance so that the shootable part has room to exist
-
-  This should link to an spawnfunc_onslaught_controlpoint entity or spawnfunc_onslaught_generator entity.
+void ons_DelayedControlPoint_Setup(void)
+{
+       onslaught_updatelinks();
+       
+       // captureshield setup
+       ons_CaptureShield_Spawn(self, FALSE);
 
-keys:
-"targetname" - name that spawnfunc_onslaught_link entities will use to target this.
-"target" - target any entities that are tied to this control point, such as vehicles and buildable structure entities.
-"message" - name of this control point (should reflect the location in the map, such as "center bridge", "north tower", etc)
- */
+       CSQCMODEL_AUTOINIT();
+}
 
-void spawnfunc_onslaught_controlpoint()
+void ons_ControlPoint_Setup(entity cp)
 {
-       if(!g_onslaught) { remove(self); return; }
+       // declarations
+       self = cp; // for later usage with droptofloor()
+       
+       // main setup
+       cp.ons_worldcpnext = ons_worldcplist; // link control point into ons_worldcplist
+       ons_worldcplist = cp;
+       
+       cp.netname = "Control point";
+       cp.team = 0;
+       cp.solid = SOLID_BBOX;
+       cp.movetype = MOVETYPE_NONE;
+       cp.touch = ons_ControlPoint_Touch;
+       cp.think = ons_ControlPoint_Think;
+       cp.nextthink = time + CP_THINKRATE;
+       cp.reset = ons_ControlPoint_Reset;
+       cp.colormap = 1024;
+       cp.iscaptured = FALSE;
+       cp.islinked = FALSE;
+       cp.isshielded = TRUE;
+       
+       if(cp.message == "") { cp.message = "a"; }
 
+       // precache - TODO: clean up!
        precache_model("models/onslaught/controlpoint_pad.md3");
        precache_model("models/onslaught/controlpoint_pad2.md3");
        precache_model("models/onslaught/controlpoint_shield.md3");
@@ -1220,168 +793,437 @@ void spawnfunc_onslaught_controlpoint()
        precache_sound("onslaught/controlpoint_underattack.wav");
        precache_sound("onslaught/ons_spark1.wav");
        precache_sound("onslaught/ons_spark2.wav");
-
-       self.solid = SOLID_BBOX;
-       self.movetype = MOVETYPE_NONE;
-       setmodel_fixsize(self, "models/onslaught/controlpoint_pad.md3");
-       if(!self.noalign)
+       
+       // appearence
+       setmodel_fixsize(cp, "models/onslaught/controlpoint_pad.md3");
+       
+       // control point placement
+       if((cp.spawnflags & 1) || cp.noalign) // don't drop to floor, just stay at fixed location
+       {
+               cp.noalign = TRUE;
+               cp.movetype = MOVETYPE_NONE;
+       }
+       else // drop to floor, automatically find a platform and set that as spawn origin
        {
-               setorigin(self, self.origin + '0 0 20');
+               setorigin(cp, cp.origin + '0 0 20');
+               cp.noalign = FALSE;
+               self = cp;
                droptofloor();
+               cp.movetype = MOVETYPE_TOSS;
        }
-       self.touch = onslaught_controlpoint_touch;
-       self.team = 0;
-       self.colormap = 1024;
-       self.iscaptured = FALSE;
-       self.islinked = FALSE;
-       self.isshielded = TRUE;
+       
+       // waypointsprites
+       WaypointSprite_SpawnFixed(string_null, self.origin + CPGEN_WAYPOINT_OFFSET, self, sprite, RADARICON_NONE, '0 0 0');
+       WaypointSprite_UpdateRule(self.sprite, self.team, SPRITERULE_TEAMPLAY);
+       
+       InitializeEntity(cp, ons_DelayedControlPoint_Setup, INITPRIO_SETLOCATION);
+}
 
-       if(self.message == "") { self.message = "a"; }
 
-       waypoint_spawnforitem(self);
+// =========================
+// Main Generator Functions
+// =========================
 
-       self.think = onslaught_controlpoint_think;
-       self.nextthink = time + CP_THINKRATE;
+string ons_Generator_Waypoint(entity e)
+{
+       if(e.isshielded)
+               return "ons-gen-shielded";
+       return "ons-gen";
+}
+
+void ons_Generator_UpdateSprite(entity e)
+{
+       string s1;
+       s1 = ons_Generator_Waypoint(e);
+       WaypointSprite_UpdateSprites(e.sprite, s1, s1, s1);
+
+       if(e.lastteam != e.team + 2 || e.lastshielded != e.isshielded)
+       {
+               e.lastteam = e.team + 2;
+               e.lastshielded = e.isshielded;
+               if(e.lastshielded)
+               {
+                       if(e.team)
+                               WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, 0.5 * colormapPaletteColor(e.team - 1, FALSE));
+                       else
+                               WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0.5 0.5 0.5');
+               }
+               else
+               {
+                       if(e.team)
+                               WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, colormapPaletteColor(e.team - 1, FALSE));
+                       else
+                               WaypointSprite_UpdateTeamRadar(e.sprite, RADARICON_GENERATOR, '0.75 0.75 0.75');
+               }
+               WaypointSprite_Ping(e.sprite);
+       }
+}
+
+void ons_GeneratorDamage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
+{
+       if(damage <= 0) { return; }
+       if(warmup_stage || gameover) { return; }
+       if(!round_handler_IsRoundStarted()) { return; }
+
+       if (attacker != self)
+       {
+               if (self.isshielded)
+               {
+                       // this is protected by a shield, so ignore the damage
+                       if (time > self.pain_finished)
+                               if (IS_PLAYER(attacker))
+                               {
+                                       play2(attacker, "onslaught/damageblockedbyshield.wav");
+                                       attacker.typehitsound += 1;
+                                       self.pain_finished = time + 1;
+                               }
+                       return;
+               }
+               if (time > self.pain_finished)
+               {
+                       self.pain_finished = time + 10;
+                       entity head;
+                       FOR_EACH_REALPLAYER(head) if(SAME_TEAM(head, self)) { Send_Notification(NOTIF_ONE, head, MSG_CENTER, CENTER_GENERATOR_UNDERATTACK); }
+                       play2team(self.team, "onslaught/generator_underattack.wav");
+               }
+       }
+       self.health = self.health - damage;
+       WaypointSprite_UpdateHealth(self.sprite, self.health);
+       // choose an animation frame based on health
+       self.frame = 10 * bound(0, (1 - self.health / self.max_health), 1);
+       // see if the generator is still functional, or dying
+       if (self.health > 0)
+       {
+               self.lasthealth = self.health;
+       }
+       else
+       {
+               if (attacker == self)
+                       Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(self.team, INFO_ONSLAUGHT_GENDESTROYED_OVERTIME_));
+               else
+               {
+                       Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(self.team, INFO_ONSLAUGHT_GENDESTROYED_));
+                       PlayerScore_Add(attacker, SP_SCORE, 100);
+               }
+               self.iscaptured = FALSE;
+               self.islinked = FALSE;
+               self.isshielded = FALSE;
+               self.takedamage = DAMAGE_NO; // can't be hurt anymore
+               self.event_damage = func_null; // won't do anything if hurt
+               self.count = 0; // reset counter
+               self.think = func_null;
+               self.nextthink = 0;
+               //self.think(); // do the first explosion now
+
+               WaypointSprite_UpdateMaxHealth(self.sprite, 0);
+               WaypointSprite_Ping(self.sprite);
+               //WaypointSprite_Kill(self.sprite); // can't do this yet, code too poor
+
+               onslaught_updatelinks();
+       }
+
+       // Throw some flaming gibs on damage, more damage = more chance for gib
+       if(random() < damage/220)
+       {
+               sound(self, CH_TRIGGER, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
+       }
+       else
+       {
+               // particles on every hit
+               pointparticles(particleeffectnum("sparks"), hitloc, force * -1, 1);
+
+               //sound on every hit
+               if (random() < 0.5)
+                       sound(self, CH_TRIGGER, "onslaught/ons_hit1.wav", VOL_BASE, ATTEN_NORM);
+               else
+                       sound(self, CH_TRIGGER, "onslaught/ons_hit2.wav", VOL_BASE, ATTEN_NORM);
+       }
+
+       self.SendFlags |= GSF_STATUS;
+}
+
+void ons_GeneratorThink()
+{
+       entity e;
+       self.nextthink = time + GEN_THINKRATE;
+       if (!gameover)
+       {
+        if(!self.isshielded && self.wait < time)
+        {
+            self.wait = time + 5;
+            FOR_EACH_REALPLAYER(e)
+            {
+                               if(SAME_TEAM(e, self))
+                               {
+                                       Send_Notification(NOTIF_ONE, e, MSG_CENTER, CENTER_ONS_NOTSHIELDED_TEAM);
+                    soundto(MSG_ONE, e, CHAN_AUTO, "kh/alarm.wav", VOL_BASE, ATTEN_NONE);    // FIXME: unique sound?
+                }
+                               else
+                                       Send_Notification(NOTIF_ONE, e, MSG_CENTER, APP_TEAM_NUM_4(self.team, CENTER_ONS_NOTSHIELDED_));
+            }
+        }
+       }
+}
+
+void ons_GeneratorReset()
+{
+       self.team = self.team_saved;
+       self.lasthealth = self.max_health = self.health = autocvar_g_onslaught_gen_health;
+       self.takedamage = DAMAGE_AIM;
+       self.bot_attack = TRUE;
+       self.iscaptured = TRUE;
+       self.islinked = TRUE;
+       self.isshielded = TRUE;
+       self.event_damage = ons_GeneratorDamage;
+       self.think = ons_GeneratorThink;
+       self.nextthink = time + GEN_THINKRATE;
+       
+       Net_LinkEntity(self, FALSE, 0, generator_send);
+       
+       self.SendFlags = GSF_SETUP; // just incase
+       self.SendFlags |= GSF_STATUS;
 
-       self.reset = onslaught_controlpoint_reset;
+       WaypointSprite_UpdateMaxHealth(self.sprite, self.max_health);
+       WaypointSprite_UpdateHealth(self.sprite, self.health);
+       WaypointSprite_UpdateRule(self.sprite,self.team,SPRITERULE_TEAMPLAY);
+       
+       onslaught_updatelinks();
+}
 
-       WaypointSprite_SpawnFixed(string_null, self.origin + '0 0 128', self, sprite, RADARICON_NONE, '0 0 0');
-       WaypointSprite_UpdateRule(self.sprite, NUM_TEAM_2, SPRITERULE_TEAMPLAY);
+void ons_DelayedGeneratorSetup()
+{
+       // bot waypoints
+       waypoint_spawnforitem_force(self, self.origin);
+       self.nearestwaypointtimeout = 0; // activate waypointing again
+       self.bot_basewaypoint = self.nearestwaypoint;
 
+       // captureshield setup
+       ons_CaptureShield_Spawn(self, TRUE);
+       
        onslaught_updatelinks();
        
-       ons_CaptureShield_Spawn(self, "models/onslaught/controlpoint_shield.md3");
+       Net_LinkEntity(self, FALSE, 0, generator_send);
+}
 
-       CSQCMODEL_AUTOINIT();
+
+void onslaught_generator_touch()
+{
+       if ( IS_PLAYER(other) )
+       if ( SAME_TEAM(self,other) )
+       if ( self.iscaptured )
+       {
+               Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_ONS_TELEPORT);
+       }
 }
 
-float onslaught_link_send(entity to, float sendflags)
+void ons_GeneratorSetup(entity gen) // called when spawning a generator entity on the map as a spawnfunc
 {
-       WriteByte(MSG_ENTITY, ENT_CLIENT_RADARLINK);
-       WriteByte(MSG_ENTITY, sendflags);
-       if(sendflags & 1)
+       // declarations
+       float teamnumber = gen.team;
+       self = gen; // for later usage with droptofloor()
+       
+       // main setup
+       gen.ons_worldgeneratornext = ons_worldgeneratorlist; // link generator into ons_worldgeneratorlist
+       ons_worldgeneratorlist = gen;
+       
+       gen.netname = sprintf("%s generator", Team_ColoredFullName(teamnumber));
+       gen.classname = "onslaught_generator";
+       gen.solid = SOLID_BBOX;
+       gen.team_saved = teamnumber;
+       gen.movetype = MOVETYPE_NONE;
+       gen.lasthealth = gen.max_health = gen.health = autocvar_g_onslaught_gen_health;
+       gen.takedamage = DAMAGE_AIM;
+       gen.bot_attack = TRUE;
+       gen.event_damage = ons_GeneratorDamage;
+       gen.reset = ons_GeneratorReset;
+       gen.think = ons_GeneratorThink;
+       gen.nextthink = time + GEN_THINKRATE;
+       gen.iscaptured = TRUE;
+       gen.islinked = TRUE;
+       gen.isshielded = TRUE;
+       gen.touch = onslaught_generator_touch;
+       
+       // precache - TODO: clean up!
+       precache_model("models/onslaught/generator_shield.md3");
+       precache_model("models/onslaught/gen_gib1.md3");
+       precache_model("models/onslaught/gen_gib2.md3");
+       precache_model("models/onslaught/gen_gib3.md3");
+       precache_sound("onslaught/generator_decay.wav");
+       precache_sound("weapons/grenade_impact.wav");
+       precache_sound("weapons/rocket_impact.wav");
+       precache_sound("onslaught/generator_underattack.wav");
+       precache_sound("onslaught/shockwave.wav");
+       precache_sound("onslaught/ons_hit1.wav");
+       precache_sound("onslaught/ons_hit2.wav");
+       precache_sound("onslaught/generator_underattack.wav");
+       
+       // appearence
+       // model handled by CSQC
+       setsize(gen, GENERATOR_MIN, GENERATOR_MAX);
+       setorigin(gen, (gen.origin + CPGEN_SPAWN_OFFSET));
+       gen.colormap = 1024 + (teamnumber - 1) * 17;
+       
+       // generator placement
+       self = gen;
+       droptofloor();
+       
+       // waypointsprites
+       WaypointSprite_SpawnFixed(string_null, self.origin + CPGEN_WAYPOINT_OFFSET, self, sprite, RADARICON_NONE, '0 0 0');
+       WaypointSprite_UpdateRule(self.sprite, self.team, SPRITERULE_TEAMPLAY);
+       WaypointSprite_UpdateMaxHealth(self.sprite, self.max_health);
+       WaypointSprite_UpdateHealth(self.sprite, self.health);
+       
+       InitializeEntity(gen, ons_DelayedGeneratorSetup, INITPRIO_SETLOCATION);
+}
+
+
+// ===============
+//  Round Handler
+// ===============
+
+float total_generators, redowned, blueowned, yellowowned, pinkowned;
+void Onslaught_count_generators()
+{
+       entity e;
+       total_generators = redowned = blueowned = yellowowned = pinkowned = 0;
+       for(e = ons_worldgeneratorlist; e; e = e.ons_worldgeneratornext)
        {
-               WriteCoord(MSG_ENTITY, self.goalentity.origin_x);
-               WriteCoord(MSG_ENTITY, self.goalentity.origin_y);
-               WriteCoord(MSG_ENTITY, self.goalentity.origin_z);
+               ++total_generators;
+               redowned += (e.team == NUM_TEAM_1 && e.health > 0);
+               blueowned += (e.team == NUM_TEAM_2 && e.health > 0);
+               yellowowned += (e.team == NUM_TEAM_3 && e.health > 0);
+               pinkowned += (e.team == NUM_TEAM_4 && e.health > 0);
        }
-       if(sendflags & 2)
+}
+
+float Onslaught_GetWinnerTeam()
+{
+       float winner_team = 0;
+       if(redowned > 0)
+               winner_team = NUM_TEAM_1;
+       if(blueowned > 0)
        {
-               WriteCoord(MSG_ENTITY, self.enemy.origin_x);
-               WriteCoord(MSG_ENTITY, self.enemy.origin_y);
-               WriteCoord(MSG_ENTITY, self.enemy.origin_z);
+               if(winner_team) return 0;
+               winner_team = NUM_TEAM_2;
        }
-       if(sendflags & 4)
+       if(yellowowned > 0)
        {
-               WriteByte(MSG_ENTITY, self.clientcolors); // which is goalentity's color + enemy's color * 16
+               if(winner_team) return 0;
+               winner_team = NUM_TEAM_3;
        }
-       return TRUE;
+       if(pinkowned > 0)
+       {
+               if(winner_team) return 0;
+               winner_team = NUM_TEAM_4;
+       }
+       if(winner_team)
+               return winner_team;
+       return -1; // no generators left?
 }
 
-void onslaught_link_checkupdate()
+#define ONS_OWNED_GENERATORS() ((redowned > 0) + (blueowned > 0) + (yellowowned > 0) + (pinkowned > 0))
+#define ONS_OWNED_GENERATORS_OK() (ONS_OWNED_GENERATORS() > 1)
+float Onslaught_CheckWinner()
 {
-       // TODO check if the two sides have moved (currently they won't move anyway)
-       float redpower, bluepower;
-
-       redpower = bluepower = 0;
-       if(self.goalentity.islinked)
+       entity e;
+       
+       if ((autocvar_timelimit && time > game_starttime + autocvar_timelimit * 60) || (round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0))
        {
-               switch(self.goalentity.team)
+               ons_stalemate = TRUE;
+
+               if (!wpforenemy_announced)
                {
-                       case NUM_TEAM_1: redpower = 1; break;
-                       case NUM_TEAM_2: bluepower = 1; break;
+                       Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_OVERTIME_CONTROLPOINT);
+                       sound(world, CH_INFO, "onslaught/generator_decay.wav", VOL_BASE, ATTEN_NONE);
+
+                       wpforenemy_announced = TRUE;
                }
-       }
-       if(self.enemy.islinked)
-       {
-               switch(self.enemy.team)
+
+               entity tmp_entity; // temporary entity
+               float d;
+               for(tmp_entity = ons_worldgeneratorlist; tmp_entity; tmp_entity = tmp_entity.ons_worldgeneratornext) if(time >= tmp_entity.ons_overtime_damagedelay)
                {
-                       case NUM_TEAM_1: redpower = 2; break;
-                       case NUM_TEAM_2: bluepower = 2; break;
+                       // tmp_entity.max_health / 300 gives 5 minutes of overtime.
+                       // control points reduce the overtime duration.
+                       d = 1;
+                       for(e = ons_worldcplist; e; e = e.ons_worldcpnext)
+                       {
+                               if(DIFF_TEAM(e, tmp_entity))
+                               if(e.islinked)
+                                       d = d + 1;
+                       }
+
+                       if(autocvar_g_campaign && autocvar__campaign_testrun)
+                               d = d * tmp_entity.max_health;
+                       else
+                               d = d * tmp_entity.max_health / max(30, 60 * autocvar_timelimit_suddendeath);
+
+                       Damage(tmp_entity, tmp_entity, tmp_entity, d, DEATH_HURTTRIGGER, tmp_entity.origin, '0 0 0');
+                       
+                       tmp_entity.sprite.SendFlags |= 16;
+
+                       tmp_entity.ons_overtime_damagedelay = time + 1;
                }
        }
+       else { wpforenemy_announced = FALSE; ons_stalemate = FALSE; }
 
-       float cc;
-       if(redpower == 1 && bluepower == 2)
-               cc = (NUM_TEAM_1 - 1) * 0x01 + (NUM_TEAM_2 - 1) * 0x10;
-       else if(redpower == 2 && bluepower == 1)
-               cc = (NUM_TEAM_1 - 1) * 0x10 + (NUM_TEAM_2 - 1) * 0x01;
-       else if(redpower)
-               cc = (NUM_TEAM_1 - 1) * 0x11;
-       else if(bluepower)
-               cc = (NUM_TEAM_2 - 1) * 0x11;
-       else
-               cc = 0;
+       Onslaught_count_generators();
+       
+       if(ONS_OWNED_GENERATORS_OK())
+               return 0;
 
-       //print(etos(self), " rp=", ftos(redpower), " bp=", ftos(bluepower), " ");
-       //print("cc=", ftos(cc), "\n");
+       float winner_team = Onslaught_GetWinnerTeam();
 
-       if(cc != self.clientcolors)
+       if(winner_team > 0)
        {
-               self.clientcolors = cc;
-               self.SendFlags |= 4;
+               Send_Notification(NOTIF_ALL, world, MSG_CENTER, APP_TEAM_NUM_4(winner_team, CENTER_ROUND_TEAM_WIN_));
+               Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_NUM_4(winner_team, INFO_ROUND_TEAM_WIN_));
+               TeamScore_AddToTeam(winner_team, ST_ONS_CAPS, +1);
+       }
+       else if(winner_team == -1)
+       {
+               Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_ROUND_TIED);
+               Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_ROUND_TIED);
        }
+       
+       ons_stalemate = FALSE;
 
-       self.nextthink = time;
+       play2all(sprintf("ctf/%s_capture.wav", Static_Team_ColorName_Lower(winner_team)));
+       
+       round_handler_Init(7, autocvar_g_onslaught_warmup, autocvar_g_onslaught_round_timelimit);
+       
+       FOR_EACH_PLAYER(e)
+       {
+               e.ons_roundlost = TRUE;
+               e.player_blocked = TRUE;
+       }
+       
+       return 1;
 }
 
-void onslaught_link_delayed()
+float Onslaught_CheckPlayers()
 {
-       self.goalentity = find(world, targetname, self.target);
-       self.enemy = find(world, targetname, self.target2);
-       if (!self.goalentity)
-               objerror("can not find target\n");
-       if (!self.enemy)
-               objerror("can not find target2\n");
-       dprint(etos(self.goalentity), " linked with ", etos(self.enemy), "\n");
-       self.SendFlags |= 3;
-       self.think = onslaught_link_checkupdate;
-       self.nextthink = time;
+       return 1;
 }
 
-/*QUAKED spawnfunc_onslaught_link (0 .5 .8) (-16 -16 -16) (16 16 16)
-  Link between control points.
-
-  This entity targets two different spawnfunc_onslaught_controlpoint or spawnfunc_onslaught_generator entities, and suppresses shielding on both if they are owned by different teams.
-
-keys:
-"target" - first control point.
-"target2" - second control point.
- */
-void spawnfunc_onslaught_link()
+void Onslaught_RoundStart()
 {
-       if (!g_onslaught)
-       {
-               remove(self);
-               return;
-       }
-       if (self.target == "" || self.target2 == "")
-               objerror("target and target2 must be set\n");
-       InitializeEntity(self, onslaught_link_delayed, INITPRIO_FINDTARGET);
-       Net_LinkEntity(self, FALSE, 0, onslaught_link_send);
-}
-
-// bot junk
-#define HAVOCBOT_ONS_ROLE_NONE                 0
-#define HAVOCBOT_ONS_ROLE_DEFENSE      2
-#define HAVOCBOT_ONS_ROLE_ASSISTANT    4
-#define HAVOCBOT_ONS_ROLE_OFFENSE      8
+       entity tmp_entity;
+       FOR_EACH_PLAYER(tmp_entity) { tmp_entity.player_blocked = FALSE; }
 
-.float havocbot_role_flags;
-.float havocbot_attack_time;
+       for(tmp_entity = ons_worldcplist; tmp_entity; tmp_entity = tmp_entity.ons_worldcpnext)
+               tmp_entity.sprite.SendFlags |= 16;
 
-.void() havocbot_role;
-.void() havocbot_previous_role;
+       for(tmp_entity = ons_worldgeneratorlist; tmp_entity; tmp_entity = tmp_entity.ons_worldgeneratornext)
+               tmp_entity.sprite.SendFlags |= 16;
+}
 
-void() havocbot_role_ons_defense;
-void() havocbot_role_ons_offense;
-void() havocbot_role_ons_assistant;
 
-void(entity bot) havocbot_ons_reset_role;
-void(float ratingscale, vector org, float sradius) havocbot_goalrating_items;
-void(float ratingscale, vector org, float sradius) havocbot_goalrating_enemyplayers;
+// ================
+// Bot player logic
+// ================
 
-.entity havocbot_ons_target;
+// NOTE: LEGACY CODE, needs to be re-written!
 
 void havocbot_goalrating_ons_offenseitems(float ratingscale, vector org, float sradius)
 {
@@ -1408,8 +1250,8 @@ void havocbot_goalrating_ons_offenseitems(float ratingscale, vector org, float s
        if(!needweapons && !needarmor)
                return;
 
-//     dprint(self.netname, " needs weapons ", ftos(needweapons) , "\n");
-//     dprint(self.netname, " needs armor ", ftos(needarmor) , "\n");
+       ons_debug(strcat(self.netname, " needs weapons ", ftos(needweapons) , "\n"));
+       ons_debug(strcat(self.netname, " needs armor ", ftos(needarmor) , "\n"));
 
        // See what is around
        head = findchainfloat(bot_pickup, TRUE);
@@ -1430,29 +1272,29 @@ void havocbot_goalrating_ons_offenseitems(float ratingscale, vector org, float s
 
 void havocbot_role_ons_setrole(entity bot, float role)
 {
-       dprint(strcat(bot.netname," switched to "));
+       ons_debug(strcat(bot.netname," switched to "));
        switch(role)
        {
                case HAVOCBOT_ONS_ROLE_DEFENSE:
-                       dprint("defense");
+                       ons_debug("defense");
                        bot.havocbot_role = havocbot_role_ons_defense;
                        bot.havocbot_role_flags = HAVOCBOT_ONS_ROLE_DEFENSE;
                        bot.havocbot_role_timeout = 0;
                        break;
                case HAVOCBOT_ONS_ROLE_ASSISTANT:
-                       dprint("assistant");
+                       ons_debug("assistant");
                        bot.havocbot_role = havocbot_role_ons_assistant;
                        bot.havocbot_role_flags = HAVOCBOT_ONS_ROLE_ASSISTANT;
                        bot.havocbot_role_timeout = 0;
                        break;
                case HAVOCBOT_ONS_ROLE_OFFENSE:
-                       dprint("offense");
+                       ons_debug("offense");
                        bot.havocbot_role = havocbot_role_ons_offense;
                        bot.havocbot_role_flags = HAVOCBOT_ONS_ROLE_OFFENSE;
                        bot.havocbot_role_timeout = 0;
                        break;
        }
-       dprint("\n");
+       ons_debug("\n");
 }
 
 float havocbot_ons_teamcount(entity bot, float role)
@@ -1461,7 +1303,7 @@ float havocbot_ons_teamcount(entity bot, float role)
        entity head;
 
        FOR_EACH_PLAYER(head)
-       if(head.team==self.team)
+       if(SAME_TEAM(head, self))
        if(head.havocbot_role_flags & role)
                ++c;
 
@@ -1473,10 +1315,8 @@ void havocbot_goalrating_ons_controlpoints_attack(float ratingscale)
        entity cp, cp1, cp2, best, pl, wp;
        float radius, found, bestvalue, c;
 
-       cp1 = cp2 = findchain(classname, "onslaught_controlpoint");
-
        // Filter control points
-       for (; cp2; cp2 = cp2.chain)
+       for(cp2 = ons_worldcplist; cp2; cp2 = cp2.ons_worldcpnext)
        {
                cp2.wpcost = c = 0;
                cp2.wpconsidered = FALSE;
@@ -1485,21 +1325,13 @@ void havocbot_goalrating_ons_controlpoints_attack(float ratingscale)
                        continue;
 
                // Ignore owned controlpoints
-               if(self.team == NUM_TEAM_1)
-               {
-                       if( (cp2.isgenneighbor[NUM_TEAM_2] || cp2.iscpneighbor[NUM_TEAM_2]) && !(cp2.isgenneighbor[NUM_TEAM_1] || cp2.iscpneighbor[NUM_TEAM_1]) )
-                               continue;
-               }
-               else if(self.team == NUM_TEAM_2)
-               {
-                       if( (cp2.isgenneighbor[NUM_TEAM_1] || cp2.iscpneighbor[NUM_TEAM_1]) && !(cp2.isgenneighbor[NUM_TEAM_2] || cp2.iscpneighbor[NUM_TEAM_2]) )
-                               continue;
-               }
+               if(!(cp2.isgenneighbor[self.team] || cp2.iscpneighbor[self.team]))
+                       continue;
 
                // Count team mates interested in this control point
                // (easier and cleaner than keeping counters per cp and teams)
                FOR_EACH_PLAYER(pl)
-               if(pl.team==self.team)
+               if(SAME_TEAM(pl, self))
                if(pl.havocbot_role_flags & HAVOCBOT_ONS_ROLE_OFFENSE)
                if(pl.havocbot_ons_target==cp2)
                        ++c;
@@ -1512,7 +1344,7 @@ void havocbot_goalrating_ons_controlpoints_attack(float ratingscale)
        // We'll consider only the best case
        bestvalue = 99999999999;
        cp = world;
-       for (; cp1; cp1 = cp1.chain)
+       for(cp1 = ons_worldcplist; cp1; cp1 = cp1.ons_worldcpnext)
        {
                if (!cp1.wpconsidered)
                        continue;
@@ -1528,7 +1360,7 @@ void havocbot_goalrating_ons_controlpoints_attack(float ratingscale)
        if (!cp)
                return;
 
-//     dprint(self.netname, " chose cp ranked ", ftos(bestvalue), "\n");
+       ons_debug(strcat(self.netname, " chose cp ranked ", ftos(bestvalue), "\n"));
 
        if(cp.goalentity)
        {
@@ -1569,12 +1401,12 @@ void havocbot_goalrating_ons_controlpoints_attack(float ratingscale)
                {
                        navigation_routerating(cp, ratingscale, 10000);
                }
-       //      dprint(self.netname, " found an attackable controlpoint at ", vtos(cp.origin) ,"\n");
+               ons_debug(strcat(self.netname, " found an attackable controlpoint at ", vtos(cp.origin) ,"\n"));
        }
        else
        {
                // Should be touched
-               // dprint(self.netname, " found a touchable controlpoint at ", vtos(cp.origin) ,"\n");
+               ons_debug(strcat(self.netname, " found a touchable controlpoint at ", vtos(cp.origin) ,"\n"));
                found = FALSE;
 
                // Look for auto generated waypoint
@@ -1599,9 +1431,9 @@ float havocbot_goalrating_ons_generator_attack(float ratingscale)
        entity g, wp, bestwp;
        float found, best;
 
-       for (g = findchain(classname, "onslaught_generator"); g; g = g.chain)
+       for(g = ons_worldgeneratorlist; g; g = g.ons_worldgeneratornext)
        {
-               if(g.team == self.team || g.isshielded)
+               if(SAME_TEAM(g, self) || g.isshielded)
                        continue;
 
                // Should be attacked
@@ -1626,7 +1458,7 @@ float havocbot_goalrating_ons_generator_attack(float ratingscale)
 
                if(bestwp)
                {
-               //      dprint("waypoints found around generator\n");
+                       ons_debug("waypoints found around generator\n");
                        navigation_routerating(bestwp, ratingscale, 10000);
                        bestwp.cnt += 1;
 
@@ -1639,7 +1471,7 @@ float havocbot_goalrating_ons_generator_attack(float ratingscale)
                }
                else
                {
-               //      dprint("generator found without waypoints around\n");
+                       ons_debug("generator found without waypoints around\n");
                        // if there aren't waypoints near the generator go straight to it
                        navigation_routerating(g, ratingscale, 10000);
                        self.havocbot_attack_time = 0;
@@ -1709,7 +1541,7 @@ void havocbot_ons_reset_role(entity bot)
        // if there is only me on the team switch to offense
        c = 0;
        FOR_EACH_PLAYER(head)
-       if(head.team==self.team)
+       if(SAME_TEAM(head, self))
                ++c;
 
        if(c==1)
@@ -1722,13 +1554,172 @@ void havocbot_ons_reset_role(entity bot)
 }
 
 
+/*
+ * Find control point or generator owned by the same team self which is nearest to pos
+ * if max_dist is positive, only control points within this range will be considered
+ */
+entity ons_Nearest_ControlPoint(vector pos, float max_dist)
+{
+       entity tmp_entity, closest_target = world;
+       tmp_entity = findchain(classname, "onslaught_controlpoint");
+       while(tmp_entity)
+       {
+               if(SAME_TEAM(tmp_entity, self))
+               if(tmp_entity.iscaptured)
+               if(max_dist <= 0 || vlen(tmp_entity.origin - pos) <= max_dist)
+               if(vlen(tmp_entity.origin - pos) <= vlen(closest_target.origin - pos) || closest_target == world)
+                       closest_target = tmp_entity;
+               tmp_entity = tmp_entity.chain;
+       }
+       tmp_entity = findchain(classname, "onslaught_generator");
+       while(tmp_entity)
+       {
+               if(SAME_TEAM(tmp_entity, self))
+               if(max_dist <= 0 || vlen(tmp_entity.origin - pos) < max_dist)
+               if(vlen(tmp_entity.origin - pos) <= vlen(closest_target.origin - pos) || closest_target == world)
+                       closest_target = tmp_entity;
+               tmp_entity = tmp_entity.chain;
+       }
+       
+       return closest_target;
+}
+
+/*
+ * Find control point or generator owned by the same team self which is nearest to pos
+ * if max_dist is positive, only control points within this range will be considered
+ * This function only check distances on the XY plane, disregarding Z
+ */
+entity ons_Nearest_ControlPoint_2D(vector pos, float max_dist)
+{
+       entity tmp_entity, closest_target = world;
+       vector delta;
+       float smallest_distance = 0, distance;
+       
+       tmp_entity = findchain(classname, "onslaught_controlpoint");
+       while(tmp_entity)
+       {
+               delta = tmp_entity.origin - pos;
+               delta_z = 0;
+               distance = vlen(delta);
+               
+               if(SAME_TEAM(tmp_entity, self))
+               if(tmp_entity.iscaptured)
+               if(max_dist <= 0 || distance <= max_dist)
+               if(closest_target == world || distance <= smallest_distance )
+               {
+                       closest_target = tmp_entity;
+                       smallest_distance = distance;
+               }
+               
+               tmp_entity = tmp_entity.chain;
+       }
+       tmp_entity = findchain(classname, "onslaught_generator");
+       while(tmp_entity)
+       {
+               delta = tmp_entity.origin - pos;
+               delta_z = 0;
+               distance = vlen(delta);
+               
+               if(SAME_TEAM(tmp_entity, self))
+               if(max_dist <= 0 || distance <= max_dist)
+               if(closest_target == world || distance <= smallest_distance )
+               {
+                       closest_target = tmp_entity;
+                       smallest_distance = distance;
+               }
+               
+               tmp_entity = tmp_entity.chain;
+       }
+       
+       return closest_target;
+}
+/**
+ * find the number of control points and generators in the same team as self
+ */
+float ons_Count_SelfControlPoints()
+{
+       entity tmp_entity;
+       tmp_entity = findchain(classname, "onslaught_controlpoint");
+       float n = 0;
+       while(tmp_entity)
+       {
+               if(SAME_TEAM(tmp_entity, self))
+               if(tmp_entity.iscaptured)
+                       n++;
+               tmp_entity = tmp_entity.chain;
+       }
+       tmp_entity = findchain(classname, "onslaught_generator");
+       while(tmp_entity)
+       {
+               if(SAME_TEAM(tmp_entity, self))
+                       n++;
+               tmp_entity = tmp_entity.chain;
+       }
+       return n;
+}
+
+/**
+ * Teleport player to a random position near tele_target
+ * if tele_effects is true, teleport sound+particles are created
+ * return FALSE on failure
+ */
+float ons_Teleport(entity player, entity tele_target, float range, float tele_effects)
+{
+       if ( !tele_target )
+               return FALSE;
+       
+       float i;
+       vector loc;
+       float theta;
+       for(i = 0; i < 16; ++i)
+       {
+               theta = random() * 2 * M_PI;
+               loc_y = sin(theta);
+               loc_x = cos(theta);
+               loc_z = 0;
+               loc *= random() * range;
+               
+               loc += tele_target.origin + '0 0 128';
+               
+               tracebox(loc, PL_MIN, PL_MAX, loc, MOVE_NORMAL, player);
+               if(trace_fraction == 1.0 && !trace_startsolid)
+               {
+                       traceline(tele_target.origin, loc, MOVE_NOMONSTERS, tele_target); // double check to make sure we're not spawning outside the world
+                       if(trace_fraction == 1.0 && !trace_startsolid)
+                       {
+                               if ( tele_effects )
+                               {
+                                       pointparticles(particleeffectnum("teleport"), player.origin, '0 0 0', 1);
+                                       sound (player, CH_TRIGGER, "misc/teleport.wav", VOL_BASE, ATTEN_NORM);
+                               }
+                               setorigin(player, loc);
+                               player.angles = '0 1 0' * ( theta * RAD2DEG + 180 );
+                               makevectors(player.angles);
+                               player.fixangle = TRUE;
+                               player.teleport_antispam = time + autocvar_g_onslaught_teleport_wait;
+
+                               if ( tele_effects )
+                                       pointparticles(particleeffectnum("teleport"), player.origin + v_forward * 32, '0 0 0', 1);
+                               return TRUE;
+                       }
+               }
+       }
+       
+       return FALSE;
+}
+
 // ==============
 // Hook Functions
 // ==============
 
 MUTATOR_HOOKFUNCTION(ons_ResetMap)
 {
-       FOR_EACH_PLAYER(self) { self.ons_deathloc = '0 0 0'; }
+       FOR_EACH_PLAYER(self)
+       {
+               self.ons_roundlost = FALSE;
+               self.ons_deathloc = '0 0 0';
+               PutClientInServer();
+       }
        return FALSE;
 }
 
@@ -1740,6 +1731,32 @@ MUTATOR_HOOKFUNCTION(ons_RemovePlayer)
 
 MUTATOR_HOOKFUNCTION(ons_PlayerSpawn)
 {
+       if(!round_handler_IsRoundStarted())
+       {
+               self.player_blocked = TRUE;
+               return FALSE;
+       }
+       
+       entity l;
+       for(l = ons_worldgeneratorlist; l; l = l.ons_worldgeneratornext)
+       {
+               l.sprite.SendFlags |= 16;
+       }
+       for(l = ons_worldcplist; l; l = l.ons_worldcpnext)
+       {
+               l.sprite.SendFlags |= 16;
+       }
+
+       if(ons_stalemate) { Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_OVERTIME_CONTROLPOINT); }
+
+       if ( autocvar_g_onslaught_spawn_choose )
+       if ( self.ons_spawn_by )
+       if ( ons_Teleport(self,self.ons_spawn_by,autocvar_g_onslaught_teleport_radius,FALSE) )
+       {
+               self.ons_spawn_by = world;
+               return FALSE;
+       }
+       
        if(autocvar_g_onslaught_spawn_at_controlpoints)
        if(random() <= autocvar_g_onslaught_spawn_at_controlpoints_chance)
        {
@@ -1749,20 +1766,16 @@ MUTATOR_HOOKFUNCTION(ons_PlayerSpawn)
                
                // new joining player or round reset, don't bother checking
                if(spawn_loc == '0 0 0') { return FALSE; }
-               
-               tmp_entity = findchain(classname, "onslaught_controlpoint");
-               
+
                if(random_target) { RandomSelection_Init(); }
 
-               while(tmp_entity)
+               for(tmp_entity = ons_worldcplist; tmp_entity; tmp_entity = tmp_entity.ons_worldcpnext)
                {
                        if(SAME_TEAM(tmp_entity, self))
                        if(random_target)
                                RandomSelection_Add(tmp_entity, 0, string_null, 1, 1);
                        else if(vlen(tmp_entity.origin - spawn_loc) <= vlen(closest_target.origin - spawn_loc) || closest_target == world)
                                closest_target = tmp_entity;
-                       
-                       tmp_entity = tmp_entity.chain;
                }
                
                if(random_target) { closest_target = RandomSelection_chosen_ent; }
@@ -1800,11 +1813,9 @@ MUTATOR_HOOKFUNCTION(ons_PlayerSpawn)
                // new joining player or round reset, don't bother checking
                if(spawn_loc == '0 0 0') { return FALSE; }
                
-               tmp_entity = findchain(classname, "onslaught_generator");
-               
                if(random_target) { RandomSelection_Init(); }
 
-               while(tmp_entity)
+               for(tmp_entity = ons_worldgeneratorlist; tmp_entity; tmp_entity = tmp_entity.ons_worldgeneratornext)
                {
                        if(random_target)
                                RandomSelection_Add(tmp_entity, 0, string_null, 1, 1);
@@ -1814,8 +1825,6 @@ MUTATOR_HOOKFUNCTION(ons_PlayerSpawn)
                                if(vlen(tmp_entity.origin - spawn_loc) <= vlen(closest_target.origin - spawn_loc) || closest_target == world)
                                        closest_target = tmp_entity;
                        }
-                       
-                       tmp_entity = tmp_entity.chain;
                }
                
                if(random_target) { closest_target = RandomSelection_chosen_ent; }
@@ -1849,6 +1858,20 @@ MUTATOR_HOOKFUNCTION(ons_PlayerSpawn)
 MUTATOR_HOOKFUNCTION(ons_PlayerDies)
 {
        frag_target.ons_deathloc = frag_target.origin;
+       entity l;
+       for(l = ons_worldgeneratorlist; l; l = l.ons_worldgeneratornext)
+       {
+               l.sprite.SendFlags |= 16;
+       }
+       for(l = ons_worldcplist; l; l = l.ons_worldcpnext)
+       {
+               l.sprite.SendFlags |= 16;
+       }
+       
+       if ( autocvar_g_onslaught_spawn_choose )
+       if ( ons_Count_SelfControlPoints() > 1 )
+               stuffcmd(self, "qc_cmd_cl hud clickradar\n");
+       
        return FALSE;
 }
 
@@ -1861,48 +1884,63 @@ MUTATOR_HOOKFUNCTION(ons_MonsterThink)
        return FALSE;
 }
 
-MUTATOR_HOOKFUNCTION(ons_MonsterSpawn)
+void ons_MonsterSpawn_Delayed()
 {
-       entity e, ee = world;
+       entity e, own = self.owner;
        
-       if(self.targetname)
+       if(!own) { remove(self); return; }
+       
+       if(own.targetname)
        {
-               e = find(world,target,self.targetname);
+               e = find(world, target, own.targetname);
                if(e != world)
                {
-                       self.team = e.team;
-                       ee = e;
+                       own.team = e.team;
+                       
+                       activator = e;
+                       own.use();
                }
        }
        
-       if(ee)
-       {
-        activator = ee;
-        self.use();
-    }
+       remove(self);
+}
+
+MUTATOR_HOOKFUNCTION(ons_MonsterSpawn)
+{
+       entity e = spawn();
+       e.owner = self;
+       InitializeEntity(e, ons_MonsterSpawn_Delayed, INITPRIO_FINDTARGET);
 
        return FALSE;
 }
 
-MUTATOR_HOOKFUNCTION(ons_TurretSpawn)
+void ons_TurretSpawn_Delayed()
 {
-       entity e, ee = world;
-       if(self.targetname)
+       entity e, own = self.owner;
+
+       if(!own) { remove(self); return; }
+
+       if(own.targetname)
        {
-               e = find(world, target, self.targetname);
+               e = find(world, target, own.targetname);
                if(e != world)
                {
-                       self.team = e.team;
-                       ee = e;
+                       own.team = e.team;
+                       own.active = ACTIVE_NOT;
+                       
+                       activator = e;
+                       own.use();
                }
        }
 
-       if(ee)
-       {
-               activator = ee;
-               if(self.use)
-                       self.use();
-       }
+       remove(self);
+}
+
+MUTATOR_HOOKFUNCTION(ons_TurretSpawn)
+{
+       entity e = spawn();
+       e.owner = self;
+       InitializeEntity(e, ons_TurretSpawn_Delayed, INITPRIO_FINDTARGET);
 
        return FALSE;
 }
@@ -1916,28 +1954,173 @@ MUTATOR_HOOKFUNCTION(ons_BotRoles)
 MUTATOR_HOOKFUNCTION(ons_GetTeamCount)
 {
        // onslaught is special
-       entity head = findchain(classname, "onslaught_generator");
-       while (head)
+       entity tmp_entity;
+       for(tmp_entity = ons_worldgeneratorlist; tmp_entity; tmp_entity = tmp_entity.ons_worldgeneratornext)
        {
-               switch(head.team)
+               switch(tmp_entity.team)
                {
                        case NUM_TEAM_1: c1 = 0; break;
                        case NUM_TEAM_2: c2 = 0; break;
                        case NUM_TEAM_3: c3 = 0; break;
                        case NUM_TEAM_4: c4 = 0; break;
                }
-               head = head.chain;
        }
 
        return TRUE;
 }
 
+MUTATOR_HOOKFUNCTION(ons_SpectateCopy)
+{
+       self.ons_roundlost = other.ons_roundlost; // make spectators see it too
+       return FALSE;
+}
+
+MUTATOR_HOOKFUNCTION(ons_SV_ParseClientCommand)
+{
+       if(MUTATOR_RETURNVALUE) // command was already handled?
+               return FALSE;
+
+       if ( cmd_name == "ons_spawn" )
+       {
+               vector pos = self.origin;
+               if(cmd_argc > 1)
+                       pos_x = stof(argv(1));
+               if(cmd_argc > 2)
+                       pos_y = stof(argv(2));
+               if(cmd_argc > 3)
+                       pos_z = stof(argv(3));
+               
+               if ( IS_PLAYER(self) )
+               {
+                       entity source_point = ons_Nearest_ControlPoint(self.origin, autocvar_g_onslaught_teleport_radius);
+
+                       if ( !source_point && self.health > 0 )
+                       {
+                               sprint(self, "\nYou need to be next to a control point\n");
+                               return 1;
+                       }
+
+                       entity closest_target = ons_Nearest_ControlPoint_2D(pos, autocvar_g_onslaught_click_radius);
+
+                       if ( closest_target == world )
+                       {
+                               sprint(self, "\nNo control point found\n");
+                               return 1;
+                       }
+
+                       if ( self.health <= 0 )
+                       {
+                               self.ons_spawn_by = closest_target;
+                               self.respawn_flags = self.respawn_flags | RESPAWN_FORCE;
+                       }
+                       else
+                       {
+                               if ( source_point == closest_target )
+                               {
+                                       sprint(self, "\nTeleporting to the same point\n");
+                                       return 1;
+                               }
+
+                               if ( !ons_Teleport(self,closest_target,autocvar_g_onslaught_teleport_radius,TRUE) )
+                                       sprint(self, "\nUnable to teleport there\n");
+                       }
+                       
+                       //sprint(self, "\nNo teleportation for you\n");
+
+                       return 1;
+               }
+               
+               return 1;
+       }
+       return 0;
+}
+
+MUTATOR_HOOKFUNCTION(ons_PlayerUseKey)
+{
+       if(MUTATOR_RETURNVALUE || gameover) { return FALSE; }
+       
+       if((time > self.teleport_antispam) && (self.deadflag == DEAD_NO) && !self.vehicle)
+       {
+               entity source_point = ons_Nearest_ControlPoint(self.origin, autocvar_g_onslaught_teleport_radius);
+               if ( source_point )
+               {
+                       stuffcmd(self, "qc_cmd_cl hud clickradar\n");
+                       return TRUE;
+               }
+       }
+       
+       return FALSE;
+}
+
+// ==========
+// Spawnfuncs
+// ==========
+
+/*QUAKED spawnfunc_onslaught_link (0 .5 .8) (-16 -16 -16) (16 16 16)
+  Link between control points.
+
+  This entity targets two different spawnfunc_onslaught_controlpoint or spawnfunc_onslaught_generator entities, and suppresses shielding on both if they are owned by different teams.
+
+keys:
+"target" - first control point.
+"target2" - second control point.
+ */
+void spawnfunc_onslaught_link()
+{
+       if(!g_onslaught) { remove(self); return; }
+
+       if (self.target == "" || self.target2 == "")
+               objerror("target and target2 must be set\n");
+
+       self.ons_worldlinknext = ons_worldlinklist; // link into ons_worldlinklist
+       ons_worldlinklist = self;
+
+       InitializeEntity(self, ons_DelayedLinkSetup, INITPRIO_FINDTARGET);
+       Net_LinkEntity(self, FALSE, 0, ons_Link_Send);
+}
+
+/*QUAKED spawnfunc_onslaught_controlpoint (0 .5 .8) (-32 -32 0) (32 32 128)
+  Control point. Be sure to give this enough clearance so that the shootable part has room to exist
+
+  This should link to an spawnfunc_onslaught_controlpoint entity or spawnfunc_onslaught_generator entity.
+
+keys:
+"targetname" - name that spawnfunc_onslaught_link entities will use to target this.
+"target" - target any entities that are tied to this control point, such as vehicles and buildable structure entities.
+"message" - name of this control point (should reflect the location in the map, such as "center bridge", "north tower", etc)
+ */
+
+void spawnfunc_onslaught_controlpoint()
+{
+       if(!g_onslaught) { remove(self); return; }
+       
+       ons_ControlPoint_Setup(self);
+}
+
+/*QUAKED spawnfunc_onslaught_generator (0 .5 .8) (-32 -32 -24) (32 32 64)
+  Base generator.
+
+  spawnfunc_onslaught_link entities can target this.
+
+keys:
+"team" - team that owns this generator (5 = red, 14 = blue, etc), MUST BE SET.
+"targetname" - name that spawnfunc_onslaught_link entities will use to target this.
+ */
+void spawnfunc_onslaught_generator()
+{
+       if(!g_onslaught) { remove(self); return; }
+       if(!self.team) { objerror("team must be set"); }
+
+       ons_GeneratorSetup(self);
+}
+
+
 // scoreboard setup
 void ons_ScoreRules()
 {
        CheckAllowedTeams(world);
        ScoreRules_basics(((c4>=0) ? 4 : (c3>=0) ? 3 : 2), SFL_SORT_PRIO_PRIMARY, 0, TRUE);
-       ScoreInfo_SetLabel_TeamScore  (ST_ONS_CAPS,     "caps",      SFL_SORT_PRIO_PRIMARY);
+       ScoreInfo_SetLabel_TeamScore  (ST_ONS_CAPS,     "destroyed", SFL_SORT_PRIO_PRIMARY);
        ScoreInfo_SetLabel_PlayerScore(SP_ONS_CAPS,     "caps",      SFL_SORT_PRIO_SECONDARY);
        ScoreInfo_SetLabel_PlayerScore(SP_ONS_TAKES,    "takes",     0);
        ScoreRules_basics_end();
@@ -1946,11 +2129,22 @@ void ons_ScoreRules()
 void ons_DelayedInit() // Do this check with a delay so we can wait for teams to be set up
 {
        ons_ScoreRules();
+       
+       round_handler_Spawn(Onslaught_CheckPlayers, Onslaught_CheckWinner, Onslaught_RoundStart);
+       round_handler_Init(5, autocvar_g_onslaught_warmup, autocvar_g_onslaught_round_timelimit);
 }
 
 void ons_Initialize()
 {
+       precache_sound("ctf/red_capture.wav");
+       precache_sound("ctf/blue_capture.wav");
+       precache_sound("ctf/yellow_capture.wav");
+       precache_sound("ctf/pink_capture.wav");
+
        ons_captureshield_force = autocvar_g_onslaught_shield_force;
+
+       addstat(STAT_ROUNDLOST, AS_INT, ons_roundlost);
+
        InitializeEntity(world, ons_DelayedInit, INITPRIO_GAMETYPE);
 }
 
@@ -1964,7 +2158,11 @@ MUTATOR_DEFINITION(gamemode_onslaught)
        MUTATOR_HOOK(MonsterMove, ons_MonsterThink, CBC_ORDER_ANY);
        MUTATOR_HOOK(MonsterSpawn, ons_MonsterSpawn, CBC_ORDER_ANY);
        MUTATOR_HOOK(TurretSpawn, ons_TurretSpawn, CBC_ORDER_ANY);
-       MUTATOR_HOOK(HavocBot_ChooseRule, ons_BotRoles, CBC_ORDER_ANY);
+       MUTATOR_HOOK(HavocBot_ChooseRole, ons_BotRoles, CBC_ORDER_ANY);
+       MUTATOR_HOOK(GetTeamCount, ons_GetTeamCount, CBC_ORDER_ANY);
+       MUTATOR_HOOK(SpectateCopy, ons_SpectateCopy, CBC_ORDER_ANY);
+       MUTATOR_HOOK(SV_ParseClientCommand, ons_SV_ParseClientCommand, CBC_ORDER_ANY);
+       MUTATOR_HOOK(PlayerUseKey, ons_PlayerUseKey, CBC_ORDER_ANY);
 
        MUTATOR_ONADD
        {
index 7e318cc4b54cb70644992e8dec48d7c855691f66..d78dfe5d795b228e3c8e55230b1a6d176610e3ee 100644 (file)
@@ -6,38 +6,86 @@
 
 // control point / generator constants
 #define CP_THINKRATE 0.2
+#define GEN_THINKRATE 1
+#define CPGEN_SPAWN_OFFSET ('0 0 1' * (PL_MAX_z - 13))
+#define CPGEN_WAYPOINT_OFFSET ('0 0 128')
+#define CPICON_OFFSET ('0 0 96')
+
+// list of generators on the map
+entity ons_worldgeneratorlist;
+.entity ons_worldgeneratornext;
+.entity ons_stalegeneratornext;
+
+// list of control points on the map
+entity ons_worldcplist;
+.entity ons_worldcpnext;
+.entity ons_stalecpnext;
+
+// list of links on the map
+entity ons_worldlinklist;
+.entity ons_worldlinknext;
+.entity ons_stalelinknext;
 
 // definitions
 .entity sprite;
 .string target2;
 .float iscaptured;
 .float islinked;
-.float isgenneighbor_red;
-.float isgenneighbor_blue;
-.float iscpneighbor_red;
-.float iscpneighbor_blue;
 .float isshielded;
 .float lasthealth;
 .float lastteam;
 .float lastshielded;
 .float lastcaptured;
 
-entity ons_generator[17];
+.float waslinked;
+
+float ons_stalemate;
+
+.float teleport_antispam;
+
+.float ons_roundlost;
+
+// waypoint sprites
+.entity bot_basewaypoint; // generator waypointsprite
+float wpforenemy_announced;
+
 .float isgenneighbor[17];
 .float iscpneighbor[17];
 float ons_notification_time[17];
 
+.float ons_overtime_damagedelay;
+
 .vector ons_deathloc;
 
+.entity ons_spawn_by;
+
 // declarations for functions used outside gamemode_onslaught.qc
-void onslaught_generator_updatesprite(entity e);
-void onslaught_controlpoint_updatesprite(entity e);
-void onslaught_link_checkupdate();
-float onslaught_controlpoint_attackable(entity cp, float t);
+void ons_Generator_UpdateSprite(entity e);
+void ons_ControlPoint_UpdateSprite(entity e);
+float ons_ControlPoint_Attackable(entity cp, float teamnumber);
 
 // CaptureShield: Prevent capturing or destroying control point/generator if it is not available yet
 float ons_captureshield_force; // push force of the shield
 
+// bot player logic
+#define HAVOCBOT_ONS_ROLE_NONE                 0
+#define HAVOCBOT_ONS_ROLE_DEFENSE      2
+#define HAVOCBOT_ONS_ROLE_ASSISTANT    4
+#define HAVOCBOT_ONS_ROLE_OFFENSE      8
+
+.entity havocbot_ons_target;
+
+.float havocbot_role_flags;
+.float havocbot_attack_time;
+
+void havocbot_role_ons_defense();
+void havocbot_role_ons_offense();
+void havocbot_role_ons_assistant();
+
+void havocbot_ons_reset_role(entity bot);
+void havocbot_goalrating_items(float ratingscale, vector org, float sradius);
+void havocbot_goalrating_enemyplayers(float ratingscale, vector org, float sradius);
+
 // score rule declarations
 #define ST_ONS_CAPS 1
 #define SP_ONS_CAPS 4
index ee8e6492a5f2d37bd7455963fce8b3b678980a6b..19ec610fdcc198648908fecbcb217b7877f3823a 100644 (file)
@@ -153,8 +153,7 @@ void InitGameplayMode()
        if(g_onslaught)
        {
                ActivateTeamplay();
-               fraglimit_override = 0;
-               leadlimit_override = 0;
+               fraglimit_override = autocvar_g_onslaught_point_limit;
                have_team_spawns = -1; // request team spawns
                MUTATOR_ADD(gamemode_onslaught);
        }
index 736cc564cc4c81bffaae6096cddc11b46c8ac867..0045374a23ce8f7a01a8e0bdd4c674da69fe4d4f 100644 (file)
@@ -301,12 +301,27 @@ float WaypointSprite_SendEntity(entity to, float sendflags)
                WriteCoord(MSG_ENTITY, self.fade_time);
                WriteCoord(MSG_ENTITY, self.teleport_time);
                WriteShort(MSG_ENTITY, self.fade_rate); // maxdist
-               float f;
-               f = 0;
+               float f = 0;
                if(self.currentammo)
                        f |= 1; // hideable
                if(self.exteriormodeltoclient == to)
                        f |= 2; // my own
+               if(g_onslaught)
+               {
+                       if(self.owner.classname == "onslaught_controlpoint")
+                       {
+                               entity wp_owner = self.owner;
+                               entity e = WaypointSprite_getviewentity(to);
+                               if(SAME_TEAM(e, wp_owner) && wp_owner.goalentity.health >= wp_owner.goalentity.max_health) { f |= 2; }
+                               if(!ons_ControlPoint_Attackable(wp_owner, e.team)) { f |= 2; }
+                       }
+                       if(self.owner.classname == "onslaught_generator")
+                       {
+                               entity wp_owner = self.owner;
+                               if(wp_owner.isshielded && wp_owner.health >= wp_owner.max_health) { f |= 2; }
+                               if(wp_owner.health <= 0) { f |= 2; }
+                       }
+               }
                WriteByte(MSG_ENTITY, f);
        }