coolbunny1234

Untitled

Jan 21st, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.32 KB | None | 0 0
  1. #include common_scripts\utility;
  2. #include maps\_utility;
  3. #include maps\_hud_util;
  4.  
  5.  
  6. /*
  7. _ _ _ _
  8. | \ | | | | | |
  9. | \| | ___ | |_ ___ ___| |
  10. | . ` |/ _ \| __|/ _ | __| |
  11. | |\ | (_) | |_| __|__ \_|
  12. |_| \_|\___/ \__|\___|___(_)
  13.  
  14. -shaders that are commented out don't worry about
  15. -i'll leave the ones uncommented and you'll see the issue
  16. -mostly, the alpha of each option gets fucked up and it looks irregular, you'll see what i mean
  17. -i'll leave a comment at the shaders to fuck with
  18. */
  19.  
  20. init()
  21. {
  22. self thread onPlayerConnect();
  23. }
  24. onPlayerConnect()
  25. {
  26. for(;;)
  27. {
  28. level waittill( "connected", player );
  29. player thread onPlayerSpawned();
  30. }
  31. }
  32. onPlayerSpawned()
  33. {
  34. self endon( "disconnect" );
  35. for(;;)
  36. {
  37. self waittill( "spawned_player" );
  38. self.menuOpen = false;
  39. self.curs = 0;
  40. self thread iniMenu();
  41. self thread doButtons();
  42. self thread notifyMenu();
  43. self iPrintln("Build Version .002A");
  44. self iPrintln("created by: ^1bunny");
  45. }
  46. }
  47. notifyMenu()
  48. {
  49. self endon("death");
  50. self endon("disconnect");
  51. while(1)
  52. {
  53. button = self waittill_any_return("LT", "RT", "X", "B");
  54. if(button == "B" &&!self.menuOpen)
  55. {
  56. self freezeControls(true);
  57. //createRectangle(align,relative,x,y,width,height,color,shader,sort,alpha) just an example
  58. //fuck with that shader below
  59.  
  60. self.shader["bg"] = createRectangle("CENTER","CENTER",0,0,500,500,((148/255),0,(211/255)),"white",0,.75);
  61.  
  62. //dont fuck with commented shaders below unless you want
  63. //self.shader["bg"] = createShader("center", "center", "center", "center", 0, 0, 900, 900, "black", (0,0,0), 2, true, 999, "death");
  64. //self.shader["line1"] = createShader("center", "center", "center", "center", 190, 50, 2, 500, "white", (0,0,1), 2, true, 1, "death");
  65. //self.shader["line2"] = createShader("center", "center", "center", "center", -190, 50, 2, 500, "white", (0,0,1), 2, true, 1, "death");
  66. self.shader["text"] = self createFontString("default", 1.0);
  67. self.shader["text"] setPoint("CENTER", "TOP");
  68. self.shader["text"] setText("Project Restart v2");
  69. self.shader["inst"] = self createFontString("default", 1.0);
  70. self.shader["inst"] setPoint("CENTER", "CENTER", 0, 190);
  71. self.shader["inst"] setText("[{+actionslot 3}]/[{+actionslot 4}] Navigate [{+gostand}] Select [{+stance}] Back");
  72. self thread destroyOn(self.shader["text"], "death");
  73. self thread destroyOn(self.shader["inst"], "death");
  74. self.menuOpen = true;
  75. self thread loadMenu("main");
  76. }
  77. wait .05;
  78. }
  79. }
  80. loadMenu(menu)
  81. {
  82. if(isDefined(self.menuText))
  83. {
  84. for(i=0;i<self.menuText.size;i++)
  85. {
  86. self.menuText[i] changeFontScaleOverTime(.2);
  87. self.menuText[i].fontscale = 0;
  88. self.menuText[i] fadeOverTime(.2);
  89. self.menuText[i].alpha = 0;
  90. wait .2;
  91. self.menuText[i] destroy();
  92. }
  93. }
  94. if(menu != "main"){
  95. self.subOpen = true;
  96. }else{
  97. self.subOpen = false;
  98. }
  99. self notify("exit_menu");
  100. self.curs = 0;
  101. self.menuText = [];
  102. for(i=0;i<6;i++)
  103. self.menuText[self.menuText.size] = createShaderText("default", 2, 0, "center", "middle", "center", "middle", (sin(180+(i*60))*120)*-1, cos(180+(i*60))*120, self.option[menu][i]);
  104.  
  105. /*
  106. for(;;)
  107. {
  108. r=randomint(255);
  109. g=randomint(255);
  110. b=randomint(255);
  111. self.menuText.color = ((r/255),(g/255),(b/255));
  112. self.menuText.color fadeovertime(.4);
  113. wait .1;
  114. self.menuText.color = ((r/255),(g/255),(b/255));
  115. self.menuText.color fadeovertime(.4);
  116. wait .1;
  117. }
  118. */
  119. wait .2;
  120. self.currentMenu = menu;
  121. self thread runFunctions();
  122. }
  123. createShaderText(font, size, alpha, pos1, pos2, pos3, pos4, x, y, text)
  124. {
  125. shader = newClientHudElem(self);
  126. shader.horzAlign = pos1;
  127. shader.vertAlign = pos2;
  128. shader.alignX = pos3;
  129. shader.alignY = pos4;
  130. shader.fontscale = size;
  131. shader.font = font;
  132. shader.alpha = alpha;
  133. shader.x = x;
  134. shader.y = y;
  135. shader setText(text);
  136. return shader;
  137. }
  138. runFunctions()
  139. {
  140. self endon("death");
  141. self endon("exit_menu");
  142. while(self.menuOpen)
  143. {
  144.  
  145. for(i=0;i<self.menuText.size;i++)
  146. {
  147. if(i == self.curs)
  148. {
  149. //self.menuText[i] changeFontScaleOverTime(.2);
  150. //self.menuText[i].fontscale = 0.8;
  151. self.menuText[i].glowAlpha = 0.2;
  152. self.menuText[i].glowColor = (0,0,1);
  153. self.menuText[i].alpha = 1;
  154. }
  155. else
  156. {
  157. //self.menuText[i] changeFontScaleOverTime(.2);
  158. //self.menuText[i].fontscale = 0.5;
  159. self.menuText[i].glowAlpha = 0;
  160. self.menuText[i].alpha = 0.7;
  161. }
  162. }
  163.  
  164. button = self waittill_any_return("LT", "RT", "X", "B");
  165. if(button == "LT"||button == "RT")
  166. {
  167. if(button == "LT")
  168. self.curs--;
  169. else if(button == "RT")
  170. self.curs++;
  171. if(self.curs<0)
  172. self.curs = self.option[self.currentMenu].size-1;
  173. else if(self.curs>self.option[self.currentMenu].size-1)
  174. self.curs = 0;
  175. for(i=0;i<self.menuText.size;i++)
  176. {
  177. self.menuText[i] moveOverTime(.2);
  178. self.menuText[i].x = (sin((180+(self.curs*-60))+(i*60))*120)*-1;
  179. self.menuText[i].y = cos((180+(self.curs*-60))+(i*60))*120;
  180. }
  181. //self playSound("mouse_over");
  182. }
  183. if(button == "X")
  184. {
  185. //self playSound("mp_ingame_summary");
  186. self thread [[self.function[self.currentMenu][self.curs]]](self.input[self.currentMenu][self.curs]);
  187. }
  188. if(button == "B")
  189. {
  190. if(self.subOpen)
  191. {
  192. self thread loadMenu("main");
  193. }
  194. else
  195. {
  196. self freezeControls(false);
  197. for(i=0;i<self.shader.size;i++)
  198. self.shader[i] destroy();
  199. for(i=0;i<self.menuText.size;i++)
  200. self.menuText[i] destroy();
  201. self.menuText = undefined;
  202. self.menuOpen = false;
  203. self notify("exit_menu");
  204. }
  205. }
  206. wait .01;
  207. }
  208. }
  209. iniMenu()
  210. {
  211. self endon("death");
  212. //Main
  213. self addMenuOption("main", 0, "hi lauren");
  214. self addMenuOption("main", 1, "Sub Menu 2");
  215. self addMenuOption("main", 2, "Sub Menu 3");
  216. self addMenuOption("main", 3, "Sub Menu 4");
  217. self addMenuOption("main", 4, "Sub Menu 5");
  218. self addMenuOption("main", 5, "Sub Menu 6");
  219. self addMenuFunction("main", 0, ::loadMenu, "sub1");
  220. self addMenuFunction("main", 1, ::loadMenu, "sub2");
  221. self addMenuFunction("main", 2, ::loadMenu, "sub3");
  222. self addMenuFunction("main", 3, ::loadMenu, "sub4");
  223. self addMenuFunction("main", 4, ::loadMenu, "sub5");
  224. self addMenuFunction("main", 5, ::loadMenu, "sub6");
  225. //Sub 1
  226. self addMenuOption("sub1", 0, "im");
  227. self addMenuOption("sub1", 1, "such");
  228. self addMenuOption("sub1", 2, "a");
  229. self addMenuOption("sub1", 3, "loser");
  230. self addMenuOption("sub1", 4, "oh well");
  231. self addMenuOption("sub1", 5, "^1CLICK ME");
  232. self addMenuFunction("sub1", 0, ::test);
  233. self addMenuFunction("sub1", 1, ::test);
  234. self addMenuFunction("sub1", 2, ::test);
  235. self addMenuFunction("sub1", 3, ::test);
  236. self addMenuFunction("sub1", 4, ::test);
  237. self addMenuFunction("sub1", 5, ::loadMenu, "sub9");
  238. //sub9
  239. self addMenuOption("sub9", 0, "i");
  240. self addMenuOption("sub9", 1, "love");
  241. self addMenuOption("sub9", 2, "you");
  242. self addMenuOption("sub9", 3, "and this");
  243. self addMenuOption("sub9", 4, "and that");
  244. self addMenuOption("sub9", 5, "mostly you");
  245. self addMenuFunction("sub9", 0, ::test);
  246. self addMenuFunction("sub9", 1, ::test);
  247. self addMenuFunction("sub9", 2, ::test);
  248. self addMenuFunction("sub9", 3, ::test);
  249. self addMenuFunction("sub9", 4, ::test);
  250. self addMenuFunction("sub9", 5, ::test);
  251.  
  252.  
  253. //Sub 2
  254. self addMenuOption("sub2", 0, "Option");
  255. self addMenuOption("sub2", 1, "Option");
  256. self addMenuOption("sub2", 2, "Option");
  257. self addMenuOption("sub2", 3, "Option");
  258. self addMenuOption("sub2", 4, "Option");
  259. self addMenuOption("sub2", 5, "Option");
  260. self addMenuFunction("sub2", 0, ::test);
  261. self addMenuFunction("sub2", 1, ::test);
  262. self addMenuFunction("sub2", 2, ::test);
  263. self addMenuFunction("sub2", 3, ::test);
  264. self addMenuFunction("sub2", 4, ::test);
  265. self addMenuFunction("sub2", 5, ::test);
  266. //Sub 3
  267. self addMenuOption("sub3", 0, "Option");
  268. self addMenuOption("sub3", 1, "Option");
  269. self addMenuOption("sub3", 2, "Option");
  270. self addMenuOption("sub3", 3, "Option");
  271. self addMenuOption("sub3", 4, "Option");
  272. self addMenuOption("sub3", 5, "Option");
  273. self addMenuFunction("sub3", 0, ::test);
  274. self addMenuFunction("sub3", 1, ::test);
  275. self addMenuFunction("sub3", 2, ::test);
  276. self addMenuFunction("sub3", 3, ::test);
  277. self addMenuFunction("sub3", 4, ::test);
  278. self addMenuFunction("sub3", 5, ::test);
  279. //Sub 4
  280. self addMenuOption("sub4", 0, "Option");
  281. self addMenuOption("sub4", 1, "Option");
  282. self addMenuOption("sub4", 2, "Option");
  283. self addMenuOption("sub4", 3, "Option");
  284. self addMenuOption("sub4", 4, "Option");
  285. self addMenuOption("sub4", 5, "Option");
  286. self addMenuFunction("sub4", 0, ::test);
  287. self addMenuFunction("sub4", 1, ::test);
  288. self addMenuFunction("sub4", 2, ::test);
  289. self addMenuFunction("sub4", 3, ::test);
  290. self addMenuFunction("sub4", 4, ::test);
  291. self addMenuFunction("sub4", 5, ::test);
  292. //Sub 5
  293. self addMenuOption("sub5", 0, "Option");
  294. self addMenuOption("sub5", 1, "Option");
  295. self addMenuOption("sub5", 2, "Option");
  296. self addMenuOption("sub5", 3, "Option");
  297. self addMenuOption("sub5", 4, "Option");
  298. self addMenuOption("sub5", 5, "Option");
  299. self addMenuFunction("sub5", 0, ::test);
  300. self addMenuFunction("sub5", 1, ::test);
  301. self addMenuFunction("sub5", 2, ::test);
  302. self addMenuFunction("sub5", 3, ::test);
  303. self addMenuFunction("sub5", 4, ::test);
  304. self addMenuFunction("sub5", 5, ::test);
  305. //Sub 6
  306. self addMenuOption("sub6", 0, "Option");
  307. self addMenuOption("sub6", 1, "Option");
  308. self addMenuOption("sub6", 2, "Option");
  309. self addMenuOption("sub6", 3, "Option");
  310. self addMenuOption("sub6", 4, "Option");
  311. self addMenuOption("sub6", 5, "Option");
  312. self addMenuFunction("sub6", 0, ::test);
  313. self addMenuFunction("sub6", 1, ::test);
  314. self addMenuFunction("sub6", 2, ::test);
  315. self addMenuFunction("sub6", 3, ::test);
  316. self addMenuFunction("sub6", 4, ::test);
  317. self addMenuFunction("sub6", 5, ::test);
  318. }
  319. addMenuOption(menu, number, text)
  320. {
  321. if(!isDefined(self.option[menu])) self.option[menu] = [];
  322. self.option[menu][number] = text;
  323. }
  324. addMenuFunction(menu, number, function, input)
  325. {
  326. if(!isDefined(self.function[menu])) self.function[menu] = [];
  327. self.function[menu][number] = function;
  328. if(!isDefined(self.input[menu])) self.input[menu] = [];
  329. if(isDefined(input)) self.input[menu][number] = input;
  330. }
  331. test()
  332. {
  333. self iPrintln("Cursor Position: "+self.curs);
  334. }
  335.  
  336.  
  337. createShader(point, rPoint, pos1, pos2, x, y, width, height, elem, color, alpha, foreground, sort, e1, e2, e3)
  338. {
  339. shader = newClientHudElem(self);
  340. shader.alignX = point;
  341. shader.alignY = rPoint;
  342. shader.vertAlign = pos1;
  343. shader.horzAlign = pos2;
  344. shader.x = x;
  345. shader.y = y;
  346. shader.sort = sort;
  347. shader.color = color;
  348. shader.alpha = alpha;
  349. if(isDefined(foreground))
  350. shader.foreground = foreground;
  351. shader setShader(elem, width, height);
  352. self thread destroyOn(shader, e1, e2, e3);
  353. return shader;
  354. }
  355. destroyOn(thing, event1, event2, event3)
  356. {
  357. self waittill_any(event1, event2, event3);
  358. thing destroy();
  359. }
  360. doButtons()
  361. {
  362. self endon("disconnect");
  363. for(;;)
  364. {
  365. if(self adsButtonPressed())
  366. {
  367. while(self adsButtonPressed())
  368. {
  369. self notify("LT");
  370. wait 0.5;
  371. }
  372. }
  373. else if(self attackButtonPressed())
  374. {
  375. while(self attackButtonPressed())
  376. {
  377. self notify("RT");
  378. wait 0.5;
  379. }
  380. }
  381. else if(self useButtonPressed())
  382. {
  383. while(self useButtonPressed())
  384. {
  385. self notify("X");
  386. wait 0.5;
  387. }
  388. }
  389. else if(self meleeButtonPressed())
  390. {
  391. while(self meleeButtonPressed())
  392. {
  393. self notify("B");
  394. wait 0.5;
  395. }
  396. }
  397. wait 0.05;
  398. }
  399. }
  400. createRectangle(align,relative,x,y,width,height,color,shader,sort,alpha)
  401. {
  402. barElemBG = newClientHudElem( self );
  403. barElemBG.elemType = "bar";
  404. if ( !level.splitScreen )
  405. {
  406. barElemBG.x = -2;
  407. barElemBG.y = -2;
  408. }
  409. barElemBG.width = width;
  410. barElemBG.height = height;
  411. barElemBG.align = align;
  412. barElemBG.relative = relative;
  413. barElemBG.xOffset = 0;
  414. barElemBG.yOffset = 0;
  415. barElemBG.children = [];
  416. barElemBG.sort = sort;
  417. barElemBG.color = color;
  418. barElemBG.alpha = alpha;
  419. barElemBG setParent( level.uiParent );
  420. barElemBG setShader( shader, width , height );
  421. barElemBG.hidden = false;
  422. barElemBG setPoint(align,relative,x,y);
  423. return barElemBG;
  424. }
Advertisement
Add Comment
Please, Sign In to add comment