]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add highly experimental RTS game-mode (for testing purposes)
authorMario <mario.mario@y7mail.com>
Wed, 6 Feb 2013 01:22:05 +0000 (12:22 +1100)
committerMario <mario.mario@y7mail.com>
Wed, 6 Feb 2013 01:22:05 +0000 (12:22 +1100)
gamemodes.cfg
qcsrc/common/mapinfo.qh
qcsrc/server/monsters/lib/monsters.qc
qcsrc/server/mutators/gamemode_rts.qc [new file with mode: 0644]
qcsrc/server/mutators/mutators.qh
qcsrc/server/progs.src
qcsrc/server/teamplay.qc

index 1219cd0ba459cae6ff5169e3606f5dfff7c3ed93..a01f05a37e830163f97db0c42c64115d7f824b14 100644 (file)
@@ -39,6 +39,7 @@ alias cl_hook_gamestart_cts
 alias cl_hook_gamestart_ka
 alias cl_hook_gamestart_ft
 alias cl_hook_gamestart_td
+alias cl_hook_gamestart_rts
 alias cl_hook_gameend
 alias cl_hook_activeweapon
 
@@ -62,6 +63,7 @@ alias sv_hook_gamestart_cts
 alias sv_hook_gamestart_ka
 alias sv_hook_gamestart_ft
 alias sv_hook_gamestart_td
+alias sv_hook_gamestart_rts
 alias sv_hook_gamerestart
 alias sv_hook_gameend
 
@@ -146,6 +148,9 @@ set g_ft_weapon_stay 0
 set g_td_respawn_waves 0
 set g_td_respawn_delay 0
 set g_td_weapon_stay 0
+set g_rts_respawn_waves 0
+set g_rts_respawn_delay 0
+set g_rts_weapon_stay 0
 
 
 // =======
@@ -503,3 +508,8 @@ set g_td_turret_mlrs_cost 80
 set g_td_turret_walker_cost 100
 set g_td_tower_buff_cost 70
 set g_td_turret_upgrade_cost 100
+
+// ====================
+//  real-time strategy
+// ====================
+set g_rts 0 "Real-Time Strategy: defend your generator & turrets by controlling monsters"
\ No newline at end of file
index c036b6d8f8f51ac0f84064fa5966a49e857a9e44..43ec2771eacd7d9e03264b7caee4af9332cac548 100644 (file)
@@ -42,6 +42,9 @@ REGISTER_GAMETYPE(_("Last Man Standing"),lms,g_lms,LMS,"timelimit=20 lives=9 lea
 REGISTER_GAMETYPE(_("Tower Defense"),td,g_td,TD,"timelimit=0 pointlimit=10 leadlimit=0")
 #define g_td IS_GAMETYPE(TD)
 
+REGISTER_GAMETYPE(_("Real-Time Strategy"),rts,g_rts,RTS,"timelimit=0 pointlimit=10 leadlimit=0")
+#define g_rts IS_GAMETYPE(RTS)
+
 REGISTER_GAMETYPE(_("Arena"),arena,g_arena,ARENA,"timelimit=20 pointlimit=10 leadlimit=0")
 #define g_arena IS_GAMETYPE(ARENA)
 
index f7612a76b35a2e076c926a23c76ac51d94a9d4bc..e6f53a68101ea949895d73880616d5c10555dea9 100644 (file)
@@ -78,6 +78,9 @@ float monster_isvalidtarget (entity targ, entity ent, float neutral)
        if(neutral == TRUE)
                return TRUE; // we come in peace!
                
+       if(targ.owner == ent.owner)
+               return FALSE;
+               
        if(targ.takedamage == DAMAGE_NO)
                return FALSE; // enemy can't be damaged
                
@@ -461,7 +464,7 @@ void monster_move(float runspeed, float walkspeed, float stopspeed, float manim_
                
        if(time >= self.last_trace)
        {
-               if(self.monster_movestate == MONSTER_MOVE_WANDER && self.goalentity.classname != "td_waypoint")
+               if(self.monster_movestate == MONSTER_MOVE_WANDER && (self.goalentity.classname != "td_waypoint" || self.goalentity != self.sprite))
                        self.last_trace = time + 2;
                else
                        self.last_trace = time + 0.5;
diff --git a/qcsrc/server/mutators/gamemode_rts.qc b/qcsrc/server/mutators/gamemode_rts.qc
new file mode 100644 (file)
index 0000000..7cbf32f
--- /dev/null
@@ -0,0 +1,165 @@
+// Real-Time Strategy
+// Gamemode by Mario
+
+.vector oldorigin;
+.float selected;
+.float last_click;
+MUTATOR_HOOKFUNCTION(rts_PlayerSpawn)
+{
+       self.oldorigin = self.origin;
+       self.last_click = time;
+       self.flags |= FL_NOTARGET;
+       self.movetype = MOVETYPE_FLY;
+       stuffcmd(self, "settemp cl_prydoncursor 1\n");
+       return FALSE;
+}
+
+MUTATOR_HOOKFUNCTION(rts_FilterItem)
+{
+       // no items... yet
+       return TRUE;
+}
+
+MUTATOR_HOOKFUNCTION(rts_SetStartItems)
+{
+       WEPSET_COPY_AW(start_weapons, 0);
+       
+       return FALSE;
+}
+
+MUTATOR_HOOKFUNCTION(rts_PlayerThink)
+{
+       entity head, wp = world;
+       if(self.cursor_trace_ent == world && self.BUTTON_ATCK)
+       {       
+               FOR_EACH_MONSTER(head)
+               {
+                       if(head.waypointsprite_attachedforcarrier)
+                               WaypointSprite_Kill(head.waypointsprite_attachedforcarrier);
+                               
+                       head.selected = FALSE;
+                       
+                       if(head.owner == self)
+                               head.owner = world;
+               }
+       }
+       if(self.cursor_trace_ent.flags & FL_MONSTER && self.BUTTON_ATCK && time >= self.last_click)
+       {
+               if(self.cursor_trace_ent.selected)
+               {
+                       WaypointSprite_Kill(self.cursor_trace_ent.waypointsprite_attachedforcarrier);
+                       self.cursor_trace_ent.selected = FALSE;
+                       self.cursor_trace_ent.owner = world;
+                       self.last_click = time + 0.5; // prevent spamming
+               }
+               else
+               {
+                       WaypointSprite_Spawn("Selected", 0, 0, self.cursor_trace_ent, '0 0 64' + ('0 0 1' * self.cursor_trace_ent.maxs_z), world, 0, self.cursor_trace_ent, waypointsprite_attachedforcarrier, FALSE, RADARICON_FLAGCARRIER, BALL_SPRITECOLOR);
+                       
+                       self.cursor_trace_ent.owner = self;
+                       self.cursor_trace_ent.selected = TRUE;
+                       self.last_click = time + 0.5; // prevent spamming
+               }
+       }
+       if(self.BUTTON_ATCK2)
+       {
+               if not(self.cursor_trace_ent)
+               {
+                       float selected_count = 0;
+                       FOR_EACH_MONSTER(head) { if(head.owner == self) selected_count += 1; }
+                       if(selected_count > 0)
+                       {
+                               wp = spawn();
+                               setorigin(wp, self.cursor_trace_endpos);
+                               WaypointSprite_SpawnFixed("Moving Here", wp.origin + '0 0 40', wp, sprite, RADARICON_HERE, '1 0.5 0');
+                       }
+               }
+               
+               FOR_EACH_MONSTER(head)
+               {
+                       if(head.owner != self) continue;
+                       
+                       if(head.goalentity)
+                       {
+                               if(head.goalentity.sprite)
+                                       WaypointSprite_Kill(head.goalentity.sprite);
+                               remove(head.goalentity);
+                               head.goalentity = world;
+                       }
+                       
+                       if(head.sprite)
+                               WaypointSprite_Kill(head.sprite);
+                       
+                       if(self.cursor_trace_ent)
+                               head.enemy = self.cursor_trace_ent;
+                       else
+                               head.goalentity = wp;
+               }
+       }
+
+       return FALSE;
+}
+
+MUTATOR_HOOKFUNCTION(rts_MonsterSpawn)
+{
+       self.effects |= EF_SELECTABLE;
+       
+       if(self.sprite)
+               WaypointSprite_Kill(self.sprite); // no waypoint names in rts...?
+       
+       return FALSE;
+}
+
+MUTATOR_HOOKFUNCTION(rts_MonsterThink)
+{
+       if(self.selected)
+               self.colormod = '1 1 1' * 4;
+       else
+               self.colormod = '1 1 1';
+               
+       return FALSE;
+}
+
+MUTATOR_HOOKFUNCTION(rts_MonsterDies)
+{
+       if(self.waypointsprite_attachedforcarrier)
+               WaypointSprite_Kill(self.waypointsprite_attachedforcarrier);
+               
+       self.selected = FALSE;
+       
+       return FALSE;
+}
+
+MUTATOR_HOOKFUNCTION(rts_PlayerPhysics)
+{
+       self.origin_z = self.oldorigin_z;
+       self.stat_sv_maxspeed *= 4; // lol
+       
+       return FALSE;
+}
+
+MUTATOR_DEFINITION(gamemode_rts)
+{
+       MUTATOR_HOOK(PlayerPhysics, rts_PlayerPhysics, CBC_ORDER_ANY);
+       MUTATOR_HOOK(PlayerSpawn, rts_PlayerSpawn, CBC_ORDER_ANY);
+       MUTATOR_HOOK(SetStartItems, rts_SetStartItems, CBC_ORDER_ANY);
+       MUTATOR_HOOK(FilterItem, rts_FilterItem, CBC_ORDER_ANY);
+       MUTATOR_HOOK(MonsterSpawn, rts_MonsterSpawn, CBC_ORDER_ANY);
+       MUTATOR_HOOK(PlayerPreThink, rts_PlayerThink, CBC_ORDER_ANY);
+       MUTATOR_HOOK(MonsterMove, rts_MonsterThink, CBC_ORDER_ANY);
+       MUTATOR_HOOK(MonsterDies, rts_MonsterDies, CBC_ORDER_ANY);
+       
+       MUTATOR_ONADD
+       {
+               if(time > 1) // game loads at time 1
+                       error("This is a game type and it cannot be added at runtime.");        
+               cvar_settemp("g_monsters", "1");
+       }
+
+       MUTATOR_ONREMOVE
+       {
+               error("This is a game type and it cannot be removed at runtime.");
+       }
+
+       return FALSE;
+}
index e8a5aa8b9c64a306cc807a5742a1668e4dfce612..7a8b5764a5394fc404a56d0cb66dca5e84f32785 100644 (file)
@@ -6,6 +6,7 @@ MUTATOR_DECLARATION(gamemode_nexball);
 MUTATOR_DECLARATION(gamemode_onslaught);
 MUTATOR_DECLARATION(gamemode_td);
 MUTATOR_DECLARATION(gamemode_domination);
+MUTATOR_DECLARATION(gamemode_rts);
 
 MUTATOR_DECLARATION(mutator_dodging);
 MUTATOR_DECLARATION(mutator_invincibleprojectiles);
index 3ac35eee205644e500e80df2ffcd5963395011d4..f7029fe2366d70726a45759685ac918f82fa9ba9 100644 (file)
@@ -219,6 +219,7 @@ mutators/gamemode_keepaway.qc
 mutators/gamemode_nexball.qc
 mutators/gamemode_onslaught.qc
 mutators/gamemode_td.qc
+mutators/gamemode_rts.qc
 mutators/mutator_invincibleproj.qc
 mutators/mutator_new_toys.qc
 mutators/mutator_nix.qc
index fb3d0ae872b37290a3e7e0016a4b5841b1fa44f8..3581f6bd18c3b3aaaaf2a3623671eb53c70ca3d0 100644 (file)
@@ -152,6 +152,13 @@ void InitGameplayMode()
                leadlimit_override = 0;
                MUTATOR_ADD(gamemode_td);
        }
+       
+       if(g_rts)
+       {
+               fraglimit_override = 0;
+               leadlimit_override = 0;
+               MUTATOR_ADD(gamemode_rts);
+       }
 
        if(g_runematch)
        {