1 #include "dialog_singleplayer.qh"
3 #include <common/gamemodes/_mod.qh>
4 #include "bigbutton.qh"
5 #include "radiobutton.qh"
6 #include "textlabel.qh"
9 void InstantAction_LoadMap(entity btn, entity dummy)
11 float pmin = 2, pmax = 16, pstep = 1;
13 cvar_set("timelimit_override", "10");
15 if(random() < 0.4) // 40% are DM
17 MapInfo_SwitchGameType(MAPINFO_TYPE_DEATHMATCH);
22 else if(random() < 0.5) // half of the remaining 60%, i.e. 30%, are CTF
24 MapInfo_SwitchGameType(MAPINFO_TYPE_CTF);
29 else if(random() < 0.5) // half of the remaining 30%, i.e. 15%, are TDM
31 MapInfo_SwitchGameType(MAPINFO_TYPE_TEAM_DEATHMATCH);
36 else if(random() < 0.666) // 2/3 of the remaining 15%, i.e. 10%, are KH
38 MapInfo_SwitchGameType(MAPINFO_TYPE_KEYHUNT);
41 pstep = 6; // works both for 2 and 3 teams
42 // TODO find team count of map, set pstep=2 or 3, and use 2v2(v2) games at least
44 else // somehow distribute the remaining 5%
47 r = floor(random() * 4);
52 MapInfo_SwitchGameType(MAPINFO_TYPE_LMS);
56 cvar_set("timelimit_override", "-1");
59 MapInfo_SwitchGameType(MAPINFO_TYPE_DOMINATION);
65 MapInfo_SwitchGameType(MAPINFO_TYPE_ONSLAUGHT);
71 MapInfo_SwitchGameType(MAPINFO_TYPE_ASSAULT);
76 // CA, Freezetag: bot AI does not work, add them once it does
81 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
86 m = floor(random() * MapInfo_count);
87 s = MapInfo_BSPName_ByID(m);
89 while(!fexists(sprintf("maps/%s.waypoints", s)));
90 MapInfo_LoadMap(s, 1);
94 pmin = pstep * ceil(pmin / pstep);
95 pmax = pstep * floor(pmax / pstep);
96 p = pmin + pstep * floor(random() * ((pmax - pmin) / pstep + 1));
97 cvar_set("bot_number", ftos(p - 1));
99 // make sure we go back to menu
100 cvar_set("lastlevel", "1");
103 void XonoticSingleplayerDialog_fill(entity me)
105 entity e, btnPrev, btnNext, lblTitle;
108 me.TDempty(me, (me.columns - 3) / 2);
109 me.TD(me, 2, 3, e = makeXonoticBigButton(_("Instant action! (random map with bots)"), '0 0 0'));
110 e.onClick = InstantAction_LoadMap;
111 e.onClickEntity = NULL;
115 me.TD(me, 1, 1, btnPrev = makeXonoticButton("<<", '0 0 0'));
116 me.TD(me, 1, me.columns - 2, lblTitle = makeXonoticTextLabel(0.5, _("???")));
117 me.TD(me, 1, 1, btnNext = makeXonoticButton(">>", '0 0 0'));
119 me.TD(me, me.rows - 6, me.columns, me.campaignBox = makeXonoticCampaignList());
120 btnPrev.onClick = MultiCampaign_Prev;
121 btnPrev.onClickEntity = me.campaignBox;
122 btnNext.onClick = MultiCampaign_Next;
123 btnNext.onClickEntity = me.campaignBox;
124 me.campaignBox.buttonNext = btnNext;
125 me.campaignBox.buttonPrev = btnPrev;
126 me.campaignBox.labelTitle = lblTitle;
128 me.gotoRC(me, me.rows - 2, 0);
129 me.TD(me, 1, 2, e = makeXonoticTextLabel(0.5, _("Campaign Difficulty:")));
130 me.TD(me, 1, 1, e = makeXonoticRadioButton(1, "g_campaign_skill", "-2", ZCTX(_("CSKL^Easy"))));
131 me.TD(me, 1, 1, e = makeXonoticRadioButton(1, "g_campaign_skill", "0", ZCTX(_("CSKL^Medium"))));
132 me.TD(me, 1, 1, e = makeXonoticRadioButton(1, "g_campaign_skill", "2", ZCTX(_("CSKL^Hard"))));
134 me.TD(me, 1, me.columns, e = makeXonoticButton(_("Start Singleplayer!"), '0 0 0'));
135 e.onClick = CampaignList_LoadMap;
136 e.onClickEntity = me.campaignBox;