cokoladka

Achievement map

Jul 17th, 2018
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.20 KB | None | 0 0
  1. /*
  2. * :-)
  3. */
  4.  
  5. /*
  6. * MAIN.NUT
  7. */
  8.  
  9. DoIncludeScript("achiev_map/state.nut", null);
  10. DoIncludeScript("achiev_map/messages.nut", null);
  11. DoIncludeScript("achiev_map/bot-controller.nut", null);
  12.  
  13. Event_RoundStart <- function()
  14. {
  15. if (!::state.exists("init"))
  16. {
  17. ::state.init <- true;
  18. ::state.bots <- {
  19. ct = true,
  20. t = true,
  21. };
  22. ::messages.Welcome( (ScriptGetGameMode() == 0 && ScriptGetGameType() == 3) ? true : false );
  23. SendToConsole("mp_warmup_end");
  24. }
  25.  
  26. EntFire("credits_spammer", "enable", "", 0, null);
  27. }
  28.  
  29. /*
  30. * STATE.NUT
  31. */
  32.  
  33. /*
  34. * hey stranger íf you are wandering here, i just want to say that this script is written by (C) me and im pretty proud (•◡•)
  35. * plz giv me github star https://gist.github.com/cokolele/58b997f4cafdb832b1647200eba1799f
  36. */
  37.  
  38. if (!getroottable().rawin("state"))
  39. {
  40. local entHolder = Entities.FindByClassname(null, "worldspawn");
  41. local entState = Entities.CreateByClassname("info_target");
  42. entHolder.SetOwner(entState);
  43.  
  44. entState = entHolder.GetOwner();
  45. if (entState.ValidateScriptScope())
  46. ::state <- entState.GetScriptScope();
  47.  
  48. state.exists <- function(var)
  49. {
  50. return state.rawin(var);
  51. }
  52. }
  53.  
  54. /*
  55. * MESSAGES.NUT
  56. */
  57.  
  58. ::messages <- {};
  59.  
  60. messages.Welcome <- function(validMode)
  61. {
  62. ScriptPrintMessageChatAll(" **");
  63. ScriptPrintMessageChatAll(" *");
  64. ScriptPrintMessageChatAll(" * Welcome to");
  65.  
  66. ScriptPrintMessageChatAll(" *");
  67. ScriptPrintMessageChatAll(" * Achievement Map");
  68. ScriptPrintMessageChatAll(" *");
  69.  
  70. if (validMode)
  71. ScriptPrintMessageChatAll(" * type !help");
  72. else
  73. ScriptPrintMessageChatAll(" * You should start the map in custom gamemode");
  74. ScriptPrintMessageChatAll(" *");
  75. ScriptPrintMessageChatAll(" **");
  76. }
  77.  
  78. messages.Help <- function()
  79. {
  80. ScriptPrintMessageChatAll(" ");
  81.  
  82. ScriptPrintMessageChatAll(" * !bot kick t - kicks all T bots");
  83. ScriptPrintMessageChatAll(" * !bot kick ct - kicks all CT bots");
  84. ScriptPrintMessageChatAll(" * !bot add t - adds up to 10 T bots");
  85. ScriptPrintMessageChatAll(" * !bot add ct - adds up to 10 CT bots");
  86.  
  87. ScriptPrintMessageChatAll(" ");
  88. }
  89.  
  90. messages.CTMax <- function()
  91. {
  92. ScriptPrintMessageChatAll(" ");
  93. ScriptPrintMessageChatAll("  CT bots at maximum");
  94. ScriptPrintMessageChatAll(" ");
  95. }
  96.  
  97. messages.TMax <- function()
  98. {
  99. ScriptPrintMessageChatAll(" ");
  100. ScriptPrintMessageChatAll("  T bots at maximum");
  101. ScriptPrintMessageChatAll(" ");
  102. }
  103.  
  104. messages.CTMin <- function()
  105. {
  106. ScriptPrintMessageChatAll(" ");
  107. ScriptPrintMessageChatAll("  CT bots at minimum");
  108. ScriptPrintMessageChatAll(" ");
  109. }
  110.  
  111. messages.TMin <- function()
  112. {
  113. ScriptPrintMessageChatAll(" ");
  114. ScriptPrintMessageChatAll("  T bots at minimum");
  115. ScriptPrintMessageChatAll(" ");
  116. }
  117.  
  118. messages.Auto <- function()
  119. {
  120. ScriptPrintMessageChatAll(" **");
  121. ScriptPrintMessageChatAll(" *");
  122. ScriptPrintMessageChatAll(" * map by:");
  123.  
  124. ScriptPrintMessageChatAll(" *");
  125. ScriptPrintMessageChatAll(" * čokoladka:-)");
  126. ScriptPrintMessageChatAll(" *");
  127.  
  128. ScriptPrintMessageChatAll(" * www.steamcommunity.com/id/nubikkk/");
  129. ScriptPrintMessageChatAll(" *");
  130. ScriptPrintMessageChatAll(" **");
  131. }
  132.  
  133. /*
  134.  
  135. messages.BotsMax <- function()
  136. {
  137. ScriptPrintMessageChatAll(" \x04**");
  138. ScriptPrintMessageChatAll(" \x04*\x06 You have reached maximum number of bots");
  139. ScriptPrintMessageChatAll(" \x04**");
  140. }
  141.  
  142. messages.BotsMin <- function(team)
  143. {
  144. team = (team == 2) ? "T" : "CT";
  145. ScriptPrintMessageChatAll(" \x04**");
  146. ScriptPrintMessageChatAll(" \x04*\x06 You have reached minimum number of bots for team " + team);
  147. ScriptPrintMessageChatAll(" \x04**");
  148. }
  149.  
  150. messages.BotsAdded <- function(num, team)
  151. {
  152. local whom = (num == 1) ? "bot" : "bots";
  153. num = num.tostring();
  154. team = (team == 2) ? "T" : "CT";
  155. ScriptPrintMessageChatAll(" \x04->\x09 You have added " + num + " " + whom + " to team " + team);
  156. }
  157.  
  158. messages.BotsKicked <- function(num, team)
  159. {
  160. local whom = (num == 1) ? "bot" : "bots";
  161. num = num.tostring();
  162. team = (team == 2) ? "T" : "CT";
  163. ScriptPrintMessageChatAll(" \x04->\x09 You have kicked " + num + " " + whom + " from team " + team);
  164. }
  165.  
  166. messages.BotsKickedAll <- function(team)
  167. {
  168. team = (team == 2) ? "T" : "CT";
  169. ScriptPrintMessageChatAll(" \x04->\x09 You have kicked all bot from team " + team);
  170. }
  171. */
  172.  
  173. /*
  174. * BOT-CONTROLLER.NUT
  175. */
  176.  
  177. Event_PlayerSay <- function()
  178. {
  179. if (this.event_data.text.find("!bot", 0) != null)
  180. {
  181. local text = this.event_data.text;
  182.  
  183. if (text == "!bot kick t")
  184. {
  185. if (::state.bots.t)
  186. {
  187. SendToConsole("bot_kick t all");
  188. SendToConsole("bot_kick t");
  189. ::state.bots.t = false;
  190. }
  191. else ::messages.TMin();
  192. }
  193. else if (text == "!bot kick ct")
  194. {
  195. if (::state.bots.ct)
  196. {
  197. SendToConsole("bot_kick ct all");
  198. SendToConsole("bot_kick ct");
  199. ::state.bots.ct = false;
  200. }
  201. else ::messages.CTMin();
  202. }
  203. else if (text == "!bot add t")
  204. {
  205. if (!::state.bots.t)
  206. {
  207. local i;
  208. for (i = 0; i < 10; i++) SendToConsole("bot_add_t");
  209. ::state.bots.t = true;
  210. }
  211. else ::messages.TMax();
  212. }
  213. else if (text == "!bot add ct")
  214. {
  215. if (!::state.bots.ct)
  216. {
  217. local i;
  218. for (i = 0; i < 10; i++) SendToConsole("bot_add_ct");
  219. ::state.bots.ct = true;
  220. }
  221. else ::messages.CTMax();
  222. }
  223. }
  224.  
  225. if (this.event_data.text.find("!help", 0) != null)
  226. {
  227. ::messages.Help();
  228. }
  229. }
  230.  
  231. /*::botsController <- {};
  232.  
  233. botsController._CheckBotsMax <- function()
  234. {
  235. if ((state.ct + state.t) >= 30)
  236. {
  237. messages.BotsMax();
  238. return true;
  239. }
  240. return false
  241. }
  242.  
  243. botsController._CheckBotsMin <- function(team)
  244. {
  245. printl(" t: " + ::state.t);
  246. printl(" ct: " + ::state.ct);
  247. if ((team == 2 && ::state.t <= 0) || (team == 3 && ::state.ct <= 0))
  248. {
  249. messages.BotsMin(team);
  250. return true;
  251. }
  252. return false;
  253. }
  254.  
  255. botsController.BotsAdd <- function(num, team)
  256. {
  257. if (this._CheckBotsMax()) return;
  258.  
  259. local added;
  260. for (added = 0; added < num; added++)
  261. {
  262. if (this._CheckBotsMax()) break;
  263.  
  264. if (team == 2) SendToConsole("bot_add_t");
  265. else SendToConsole("bot_add_ct");
  266. }
  267.  
  268. messages.BotsAdded(added, team);
  269. }
  270.  
  271. botsController.state <- {
  272. kicking = false
  273. team = null
  274. initialNum = null
  275. currentNum = null
  276. }
  277.  
  278. botsController.BotsKick <- function(num, team)
  279. {
  280. if (!this.state.kicking)
  281. {
  282. if (this._CheckBotsMin(team)) return;
  283.  
  284. if (num == 1)
  285. {
  286. if (team == 2) SendToConsole("bot_kick t");
  287. else SendToConsole("bot_kick ct");
  288.  
  289. messages.BotsKicked(1, team);
  290. }
  291. else
  292. {
  293. if (team == 2) SendToConsole("bot_kick t");
  294. else SendToConsole("bot_kick ct");
  295.  
  296. this.state = {
  297. kicking = true
  298. team = team
  299. initialNum = num
  300. currentNum = num--
  301. }
  302. }
  303. }
  304. else
  305. {
  306. if (this._CheckBotsMin(this.state.team) && this.state.currentNum > 0)
  307. {
  308. messages.BotsKicked((this.state.initialNum - this.state.currentNum), this.team);
  309. this.state.kicking = false;
  310. return;
  311. }
  312. else if (this.state.currentNum > 0)
  313. {
  314. if (this.state.team == 2) SendToConsole("bot_kick t");
  315. else SendToConsole("bot_kick ct");
  316.  
  317. this.state.currentNum--;
  318. }
  319. else{
  320. messages.BotsKicked(this.state.initialNum, this.team);
  321. this.state.kicking = false;
  322. }
  323. }
  324. }
  325. */
  326. /*
  327. function BotsKickAll(team)
  328. {
  329. if (this._CheckBotsMin(team)) return;
  330.  
  331. if (team == 2) {
  332. this.t = 0;
  333. SendToConsole("bot_kick t all");
  334. } else {
  335. this.ct = 0;
  336. SendToConsole("bot_kick ct all");
  337. }
  338.  
  339. ::messages.BotsKickedAll(team);
  340. }
  341.  
  342. function _BotKick(team)
  343. {
  344. if (team == 2) {
  345. this.t--;
  346. SendToConsole("bot_kick t");
  347. } else {
  348. this.ct--;
  349. SendToConsole("bot_kick ct");
  350. }
  351. }
  352.  
  353. function _CheckBotsMax()
  354. {
  355. if ((this.ct + this.t) == this.MAX_BOTS) {
  356. ::messages.BotsMax();
  357. return true;
  358. }
  359. return false;
  360. }
  361.  
  362. function _CheckBotsMin(team)
  363. {
  364. if ((this.t == this.MIN_BOTS && team == 2) || (this.ct == this.MIN_BOTS && team == 3)) {
  365. ::messages.BotsMin(team);
  366. return true;
  367. }
  368. return false;
  369. }
  370. }
  371. */
Add Comment
Please, Sign In to add comment