Advertisement
TJSJ

Pokemon Test v1.1

Feb 5th, 2019
585
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. IGNORE THE YELLOW TEXT !!!
  2. //COLORED LIKE THIS
  3.  
  4.  
  5. Information about object: Var
  6. Sprite:
  7. Solid: false
  8. Visible: true
  9. Depth: 0
  10. Persistent: false
  11. Parent:
  12. Children:
  13. Mask:
  14.  
  15. No Physics Object
  16. Create Event:
  17.  
  18. execute code:
  19.  
  20. ///GENERATE POKEMON VARIABLES
  21.  
  22. MonAmount = 4;
  23.  
  24. for( i=0; i<MonAmount; i++ ) //generate our MON IDs
  25. {
  26. //generate the database for our mons so we retrieve these values
  27. //when battling and store them in the player values.
  28. //these will need to be edited manually
  29. Id[i] = i;
  30. NameId[i] = "";
  31. HlthId[i] = 0;
  32. AttkId[i] = 0;
  33. DfnsId[i] = 0;
  34. SpedId[i] = 0;
  35. }
  36.  
  37. for( p=0; p<2; p++ ) //generate our player mon objects
  38. {
  39. //there will be a pair of these variable
  40. //Plyr[0] being the client player
  41. //Plyr[1] being the opposing player
  42. PlyrName[p] = "";
  43. PlyrHlth[p] = 0;
  44. PlyrAttk[p] = 0;
  45. PlyrDfns[p] = 0;
  46. PlyrSped[p] = 0;
  47. }
  48.  
  49.  
  50.  
  51. execute code:
  52.  
  53. ///MOVE STATS
  54.  
  55. Moves = 10;
  56.  
  57. for ( i=0; i<Moves; i++ ) {
  58. MovePower[i] = 1;
  59. MoveName[i] = "Move Name";
  60. }
  61.  
  62. MoveName[0] = "Tackle";
  63. MovePower[0] = 40;
  64.  
  65. MoveName[1] = "Dorito Slap";
  66. MovePower[1] = 60;
  67.  
  68. MoveName[2] = "Donut Pounce";
  69. MovePower[2] = 60;
  70.  
  71. MoveName[3] = "Cinnamon Dust";
  72. MovePower[3] = 60;
  73.  
  74. MoveName[4] = "Ice Beam";
  75. MovePower[4] = 90;
  76.  
  77. MoveName[5] = "Water Gun";
  78. MovePower[5] = 60;
  79.  
  80. MoveName[6] = "Sparkle Ray";
  81. MovePower[6] = 90;
  82.  
  83. MoveName[7] = "Flamethrower";
  84. MovePower[7] = 90;
  85.  
  86. MoveName[8] = "Energy Ball";
  87. MovePower[8] = 90;
  88.  
  89. MoveName[9] = "Shadow Ball";
  90. MovePower[9] = 90;
  91.  
  92. MoveName[10] = "Big Kick";
  93. MovePower[10] = 120;
  94.  
  95. execute code:
  96.  
  97. ///POKEMON STAT CONSTANTS, DO NOT REFERENCE DIRECTLY!!!
  98.  
  99. /* TEMPLATE
  100. NameId[0] = "";
  101. HlthId[0] = 0;
  102. AttkId[0] = 0;
  103. DfnsId[0] = 0;
  104. SpedId[0] = 0;
  105. */
  106.  
  107. /*
  108. THESE ARE CONSTANTS, THEREFORE THESE
  109. WONT BE REFERENCED DIRECTLY!!!
  110. WE USE THE PlyrId VARIABLES INSTEAD!!!
  111. */
  112.  
  113. NameId[0] = "Dorito";
  114. HlthId[0] = 90;      
  115. AttkId[0] = 120;    
  116. DfnsId[0] = 100;    
  117. SpedId[0] = 80;      
  118.  
  119. NameId[1] = "Cinnamon Bun";
  120. HlthId[1] = 100;      
  121. AttkId[1] = 110;    
  122. DfnsId[1] = 120;      
  123. SpedId[1] = 53;    
  124.  
  125. NameId[2] = "Glazed Donut";
  126. HlthId[2] = 110;    
  127. AttkId[2] = 93;      
  128. DfnsId[2] = 80;      
  129. SpedId[2] = 144;      
  130.  
  131. NameId[3] = "Pizza";
  132. HlthId[3] = 130;    
  133. AttkId[3] = 130;      
  134. DfnsId[3] = 90;      
  135. SpedId[3] = 20;      
  136.  
  137. Step Event:
  138.  
  139. execute code:
  140.  
  141. ///STORING VALUES
  142.  
  143. /* store ids of mons so they are specifically
  144. choosen in battle, where 'm' represents
  145. the id of the mon and 'p' represents which mon
  146. you are in control of */
  147.  
  148. /* m = mon id */
  149. /* p = player number (0 or 1) */
  150.  
  151. /*
  152.  
  153. if update = true {
  154.  
  155. with(Mon) {
  156.     switch(o) {
  157.     // check if o = control player "0" or opposing player "1"
  158.         case 0:
  159.             aStoredPlyrName[m,o] = Var.PlyrName[o]
  160.             aStoredPlyrHlth[m,o] = Var.PlyrHlth[o]
  161.             aStoredPlyrAttk[m,o] = Var.PlyrAttk[o]
  162.             aStoredPlyrDfns[m,o] = Var.PlyrDfns[o]
  163.             aStoredPlyrSped[m,o] = Var.PlyrSped[o]
  164.             break;
  165.         case 1:
  166.             bStoredPlyrName[m,o] = Var.PlyrName[o]
  167.             bStoredPlyrHlth[m,o] = Var.PlyrHlth[o]
  168.             bStoredPlyrAttk[m,o] = Var.PlyrAttk[o]
  169.             bStoredPlyrDfns[m,o] = Var.PlyrDfns[o]
  170.             bStoredPlyrSped[m,o] = Var.PlyrSped[o]
  171.             break;
  172.     }
  173. }
  174. update = false;
  175. }
  176.  
  177. // change Var.update to true whenever mon is changed
  178.  
  179.  
  180.  
  181. Information about object: Mon
  182. Sprite:
  183. Solid: false
  184. Visible: true
  185. Depth: 0
  186. Persistent: false
  187. Parent:
  188. Children:
  189. Mask:
  190.  
  191. No Physics Object
  192. Create Event:
  193.  
  194. execute code:
  195.  
  196. ///CREATE PLAYER ID
  197.  
  198. o = 0; // 0 is the controlling player, 1 is the opposing player !!!
  199.  
  200. CurrentPartyMember = 1;
  201.  
  202. c = CurrentPartyMember;
  203.  
  204. m = irandom_range(0,Var.MonAmount); // which pokemon are we? (note: this is changed in BattleDummy)
  205.  
  206. DamageInflicted = 0;
  207. Waiting[0] = -1;
  208. Waiting[1] = -1;
  209. Waiting[0] = false;
  210. Waiting[1] = false;
  211. aDamageInflicted = 0;
  212. bDamageInflicted = 0;
  213. Plyr[o] = true;
  214. StoredText[0] = "text";
  215. StoredText[1] = "text";
  216. StoredText[o] = "sample text";
  217. StoredPower1 = 0;
  218. StoredPower2 = 0;
  219. Health[o] = 0;
  220. PlyrName[0] = "";
  221. PlyrHlth[0] = 0;
  222. PlyrAttk[0] = 0;
  223. PlyrDfns[0] = 0;
  224. PlyrSped[0] = 0;
  225. PlyrName[1] = "";
  226. PlyrHlth[1] = 0;
  227. PlyrAttk[1] = 0;
  228. PlyrDfns[1] = 0;
  229. PlyrSped[1] = 0;
  230. PlyrName[o] = "";
  231. PlyrHlth[o] = 0;
  232. PlyrAttk[o] = 0;
  233. PlyrDfns[o] = 0;
  234. //PlyrSped[o] = 0;
  235. aPlyrMove1 = 0;
  236. aPlyrMove2 = 0;
  237. aPlyrMove3 = 0;
  238. aPlyrMove4 = 0;
  239. bPlyrMove1 = 0;
  240. bPlyrMove2 = 0;
  241. bPlyrMove3 = 0;
  242. bPlyrMove4 = 0;
  243. MoveSelected = false;
  244. Waiting[o] = false; // are we done selecting a move?
  245. Moving[o] = false;
  246. IsDamaged[0] = false;
  247. IsDamaged[1] = false;
  248. PartyTotal[o] = 4; // default value, this is changed in BattleDummy
  249. Move[0] = 0;
  250. Move[1] = 1;
  251. Move[2] = 2;
  252. Move[3] = 3;
  253. aMoveSelected = false;
  254. bMoveSelected = false;
  255.  
  256. for ( n=0; n<PartyTotal[o]; n++ ) {
  257.    
  258.     // PLAYER ONE
  259.     aStoredPlyrName[m,n] = "";
  260.     aStoredPlyrHlth[m,n] = 0;
  261.     aStoredPlyrHlthCache[m,n] = 0;
  262.     aStoredPlyrAttk[m,n] = 0;
  263.     aStoredPlyrDfns[m,n] = 0;
  264.     aStoredPlyrSped[m,n] = 0;
  265.     aStoredPlyrMove1[m,n] = irandom_range(0,Var.Moves);
  266.     aStoredPlyrMove2[m,n] = irandom_range(0,Var.Moves);
  267.     aStoredPlyrMove3[m,n] = irandom_range(0,Var.Moves);
  268.     aStoredPlyrMove4[m,n] = irandom_range(0,Var.Moves);
  269.    
  270.     // PLAYER TWO
  271.     bStoredPlyrName[m,n] = "";
  272.     bStoredPlyrHlth[m,n] = 0;
  273.     bStoredPlyrHlthCache[m,n] = 0;
  274.     bStoredPlyrAttk[m,n] = 0;
  275.     bStoredPlyrDfns[m,n] = 0;
  276.     bStoredPlyrSped[m,n] = 0;
  277.     bStoredPlyrMove1[m,n] = irandom_range(0,Var.Moves);
  278.     bStoredPlyrMove2[m,n] = irandom_range(0,Var.Moves);
  279.     bStoredPlyrMove3[m,n] = irandom_range(0,Var.Moves);
  280.     bStoredPlyrMove4[m,n] = irandom_range(0,Var.Moves);
  281.     }
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295. /*
  296. If ((Player[a].Health > (Player[a].Health - Player[b].DamageInflicted))
  297. && Player[a].IsDamaged = true) {
  298.     Player[a].Health -= 1/128 //lose health at 1/128 rate if damaged by opponent.
  299. }
  300.  
  301. 100 > (100 - 50)
  302.       which is 50
  303.       */
  304.  
  305. execute code:
  306.  
  307. ///MOVE STATS
  308.  
  309. Moves = 10;
  310.  
  311. for ( i=0; i<Moves; i++ ) {
  312. MovePower[i] = 1;
  313. MoveName[i] = "Move Name";
  314. }
  315.  
  316. MoveName[0] = "Tackle";
  317. MovePower[0] = 40;
  318.  
  319. MoveName[1] = "Dorito Slap";
  320. MovePower[1] = 60;
  321.  
  322. MoveName[2] = "Donut Pounce";
  323. MovePower[2] = 60;
  324.  
  325. MoveName[3] = "Cinnamon Dust";
  326. MovePower[3] = 60;
  327.  
  328. MoveName[4] = "Ice Beam";
  329. MovePower[4] = 90;
  330.  
  331. MoveName[5] = "Water Gun";
  332. MovePower[5] = 60;
  333.  
  334. MoveName[6] = "Sparkle Ray";
  335. MovePower[6] = 90;
  336.  
  337. MoveName[7] = "Flamethrower";
  338. MovePower[7] = 90;
  339.  
  340. MoveName[8] = "Energy Ball";
  341. MovePower[8] = 90;
  342.  
  343. MoveName[9] = "Shadow Ball";
  344. MovePower[9] = 90;
  345.  
  346. MoveName[10] = "Big Kick";
  347. MovePower[10] = 120;
  348.  
  349. Step Event:
  350.  
  351. execute code:
  352.  
  353. if o = 0
  354. {
  355. Position = "back";
  356. sprite_index = spr_mon_back;
  357. image_xscale = 2;
  358. image_yscale = 2;
  359. image_speed = 0;
  360. image_index = m;
  361. x = view_xview + view_wview*0.2;
  362. y = view_yview + view_hview*0.6;
  363. global.aStoredPlyrName = aStoredPlyrName[m,c]
  364. global.aStoredPlyrHlth = aStoredPlyrHlth[m,c]
  365. global.aStoredPlyrAttk = aStoredPlyrAttk[m,c]
  366. global.aStoredPlyrDfns = aStoredPlyrDfns[m,c]
  367. global.aStoredPlyrSped = aStoredPlyrSped[m,c]
  368. global.aX = x
  369. global.aY = y
  370. }
  371.  
  372. if o = 1
  373. {
  374. Position = "front";
  375. sprite_index = spr_mon_front;
  376. image_xscale = 2;
  377. image_yscale = 2;
  378. image_speed = 0;
  379. image_index = m;
  380. //x = view_xview + view_wview*0.8;
  381. //y = view_yview + view_hview*0.4;
  382. x = view_wview - view_wview*0.2;
  383. y = view_hview - view_hview*0.6;
  384. global.bStoredPlyrName = bStoredPlyrName[m,c]
  385. global.bStoredPlyrHlth = bStoredPlyrHlth[m,c]
  386. global.bStoredPlyrAttk = bStoredPlyrAttk[m,c]
  387. global.bStoredPlyrDfns = bStoredPlyrDfns[m,c]
  388. global.bStoredPlyrSped = bStoredPlyrSped[m,c]
  389. global.bX = x
  390. global.bY = y
  391. }
  392.  
  393.  
  394. // if we are damaged at all...
  395.  
  396. // if player 1 is damaged by player 2
  397. if (o = 0 && global.bFinishQueue = 0 && global.Player1Damaged = true && global.aHealth > 0 && global.aWaiting = true) {
  398.     if (global.aHealth > (aStoredPlyrHlthCache[m,c] - global.bDamageInflicted)) {
  399.         global.aHealth -= 1/4; //lose health at 1/4 rate if damaged
  400.     }
  401.  
  402.     if (global.aHealth <= (aStoredPlyrHlthCache[m,c] - global.bDamageInflicted)) {
  403.         global.Player1Moving = false;
  404.         global.Player1DoneMoving = true;
  405.         global.Player1Damaged = false;
  406.         global.bFinishQueue = 1;
  407.     }
  408. }
  409.  
  410. // if player 2 is damaged by player 1
  411. if (o = 1 && global.aFinishQueue = 0 && global.Player2Damaged = true && global.bHealth > 0 && global.bWaiting = true) {
  412.     if (global.bHealth > (bStoredPlyrHlthCache[m,c] - global.aDamageInflicted)) {
  413.         global.bHealth -= 1/4; //lose health at 1/4 rate if damaged
  414.     }
  415.  
  416.     if (global.bHealth <= (bStoredPlyrHlthCache[m,c] - global.aDamageInflicted)) {
  417.         global.Player2Moving = false;
  418.         global.Player2DoneMoving = true;
  419.         global.Player2Damaged = false;
  420.         global.aFinishQueue = 1;
  421.     }
  422. }
  423.  
  424. if (o = 0 && global.Player1DoneMoving = true && global.Player2DoneMoving = true/*global.aWaiting = false*/) {
  425.     aStoredPlyrHlthCache[m,c] = global.aHealth;
  426. }
  427.  
  428. if (o = 1 && global.Player1DoneMoving = true && global.Player2DoneMoving = true/*global.bWaiting = false*/) {
  429.     bStoredPlyrHlthCache[m,c] = global.bHealth;
  430. }
  431.  
  432.  
  433.  
  434. Draw Event:
  435.  
  436. execute code:
  437.  
  438. //x1 = x-64*2*1.2;
  439. //y1 = y-64*2*1.4;
  440. //x2 = x+64*2*1.2;
  441. //y2 = y-64*2*1.2;
  442.  
  443. x1 = 128*1.2;
  444. y1 = 128*1.4;
  445. x2 = 128*1.2;
  446. y2 = 128*1.2;
  447.  
  448. if o = 0 {
  449. aX1 = global.aX-x1;
  450. aY1 = global.aY-y1;
  451. aX2 = global.aX+x2;
  452. aY2 = global.aY-y2;
  453. }
  454.  
  455. if o = 1 {
  456. bX1 = global.bX-x1;
  457. bY1 = global.bY-y1;
  458. bX2 = global.bX+x2;
  459. bY2 = global.bY-y2;
  460. }
  461.  
  462. xdiff = x2-x1
  463.  
  464. draw_sprite(sprite_index,image_index,x,y);
  465. draw_set_font(font0);
  466. draw_set_color(c_teal);
  467. draw_rectangle(x-x1,y-y1,x+x2,y-y2,false);
  468. draw_set_color(c_yellow);
  469. //text_draw(x1,y1-100,"Error: "+string(bStoredPlyrSped[m,c]),c_black);
  470. if o = 0 {
  471.     draw_rectangle(aX1,aY1,aX2*(global.aHealth/aStoredPlyrHlth[m,c]),aY2,false)
  472.     text_draw(aX1,aY1-24,PlyrName[0],c_white);
  473.     text_draw(aX1,aY1+14*2/1.25,"HP: "+string(global.aHealth)+"/"+string(aStoredPlyrHlth[m,c]),c_white);
  474.     text_draw(aX1,aY1+39,"aPlyrHlthCache: "+string(aStoredPlyrHlthCache[m,c]),c_black);
  475.     text_draw(aX1,aY1+55,"aX: "+string(aX1),c_black);  
  476.     text_draw(aX1,aY1+69,"aX1: "+string(aX2*(global.aHealth/aStoredPlyrHlth[m,c])),c_black);
  477. }
  478.  
  479.  
  480. if o = 1 {
  481.     draw_rectangle(bX1,bY1,bX2*(global.bHealth/bStoredPlyrHlth[m,c]),bY2,false)
  482.     text_draw(bX1,bY1-24,PlyrName[1],c_white);
  483.     text_draw(bX1,bY1+14*2/1.25,"HP: "+string(global.bHealth)+"/"+string(bStoredPlyrHlth[m,c]),c_white);
  484.     text_draw(bX1,bY1+39,"bPlyrHlthCache: "+string(bStoredPlyrHlthCache[m,c]),c_black);
  485.     text_draw(bX1,bY1+55,"bX: "+string(bX1),c_black);
  486.     text_draw(bX1,bY1+69,"bX1: "+string(bX2*(global.bHealth/bStoredPlyrHlth[m,c])),c_black);
  487. }
  488.  
  489. Information about object: BattleDummy
  490. Sprite:
  491. Solid: false
  492. Visible: true
  493. Depth: 0
  494. Persistent: false
  495. Parent:
  496. Children:
  497. Mask:
  498.  
  499. No Physics Object
  500. Create Event:
  501.  
  502. execute code:
  503.  
  504. /// FETCH VALUES FOR POKEMON ON THE FIELD
  505. // Var object holds all the constants
  506.  
  507. // IMPORTANT vvvvvvvvvv
  508.  
  509. // m = mon id;
  510. // c = position in party;
  511.  
  512. // IMPORTANT ^^^^^^^^^^
  513.  
  514. debugger = false;
  515. message_text = "";
  516. instance_create(x,y,Var);
  517. global.PlayerQueue = 0;
  518. global.FinishedTurn = true;
  519. global.Player1Moving = false;
  520. global.Player2Moving = false;
  521. global.Player1DoneMoving = true;
  522. global.Player2DoneMoving = true;
  523. global.Player1Damaged = false;
  524. global.Player2Damaged = false;
  525. global.aHealth = 90;
  526. global.bHealth = 90;
  527. global.aDamageInflicted = 0;
  528. global.bDamageInflicted = 0;
  529. global.aWaiting = false;
  530. global.bWaiting = false;
  531. global.aFinishQueue = 0;
  532. global.bFinishQueue = 0;
  533. SelectedMove = 0;
  534. OtherSelectedMove = 0;
  535. aSideName = "";
  536. bSideName = "";
  537. delay = 0;
  538. PreAttackDelay = 1;
  539. PostAttackDelay = 1;
  540.  
  541. /* PLAYER 1 MON ------------------------- */
  542.  
  543. with(instance_create(x,y,Mon)) { /* PLAYER 1 MON ------------------------- */
  544.  
  545. o = 0; // set mon to be player 1
  546.  
  547. m = irandom_range(0,3); // for now we randomly select a mon
  548.  
  549. image_index = m; //update sprite to appropriate mon
  550.  
  551. // then we grab the corresponding stats for that mon
  552. aStoredPlyrName[m,c] = Var.NameId[m];
  553. aStoredPlyrHlth[m,c] = Var.HlthId[m];
  554. aStoredPlyrHlthCache[m,c] = Var.HlthId[m];
  555. aStoredPlyrAttk[m,c] = Var.AttkId[m];
  556. aStoredPlyrDfns[m,c] = Var.DfnsId[m];
  557. aStoredPlyrSped[m,c] = Var.SpedId[m];
  558. aStoredPlyrMove1[m,c] = irandom_range(0,Var.Moves);
  559. aStoredPlyrMove2[m,c] = irandom_range(0,Var.Moves);
  560. aStoredPlyrMove3[m,c] = irandom_range(0,Var.Moves);
  561. aStoredPlyrMove4[m,c] = irandom_range(0,Var.Moves);
  562.  
  563. // now we set our local stat variables to equal the stored data
  564. // PlyrName[0] = aStoredPlyrName[1,1] <-- Mon #1 in the 1st spot of your party
  565.  
  566. global.aHealth = aStoredPlyrHlth[m,c];
  567. PlyrName[o] = aStoredPlyrName[m,c];
  568. PlyrHlth[o] = aStoredPlyrHlth[m,c];
  569. PlyrAttk[o] = aStoredPlyrAttk[m,c];
  570. PlyrDfns[o] = aStoredPlyrDfns[m,c];
  571. PlyrSped[0] = aStoredPlyrSped[m,c];
  572. aPlyrMove1 = aStoredPlyrMove1[m,c];
  573. aPlyrMove2 = aStoredPlyrMove2[m,c];
  574. aPlyrMove3 = aStoredPlyrMove3[m,c];
  575. aPlyrMove4 = aStoredPlyrMove4[m,c];
  576. }
  577.  
  578. /* PLAYER 2 MON ------------------------- */
  579.  
  580. with(instance_create(x,y,Mon)) { /* PLAYER 2 MON ------------------------- */
  581.  
  582. o = 1; // set mon to be player 2
  583.  
  584. m = irandom_range(0,3); // for now we randomly select a mon
  585.  
  586. image_index = m; //update sprite to appropriate mon
  587.  
  588. // then we grab the corresponding stats for that mon
  589. bStoredPlyrName[m,c] = Var.NameId[m];
  590. bStoredPlyrHlth[m,c] = Var.HlthId[m];
  591. bStoredPlyrHlthCache[m,c] = Var.HlthId[m];
  592. bStoredPlyrAttk[m,c] = Var.AttkId[m];
  593. bStoredPlyrDfns[m,c] = Var.DfnsId[m];
  594. bStoredPlyrSped[m,c] = Var.SpedId[m];
  595. bStoredPlyrMove1[m,c] = irandom_range(0,Var.Moves);
  596. bStoredPlyrMove2[m,c] = irandom_range(0,Var.Moves);
  597. bStoredPlyrMove3[m,c] = irandom_range(0,Var.Moves);
  598. bStoredPlyrMove4[m,c] = irandom_range(0,Var.Moves);
  599.  
  600. // now we set our local stat variables to equal the stored data
  601. //PlyrName[1] = bStoredPlyrName[1,1] <-- Mon #1 in the 1st spot of opponents party
  602.  
  603. global.bHealth = bStoredPlyrHlth[m,c];
  604. PlyrName[o] = bStoredPlyrName[m,c];
  605. PlyrHlth[o] = bStoredPlyrHlth[m,c];
  606. PlyrAttk[o] = bStoredPlyrAttk[m,c];
  607. PlyrDfns[o] = bStoredPlyrDfns[m,c];
  608. PlyrSped[1] = bStoredPlyrSped[m,c];
  609. bPlyrMove1 = bStoredPlyrMove1[m,c];
  610. bPlyrMove2 = bStoredPlyrMove2[m,c];
  611. bPlyrMove3 = bStoredPlyrMove3[m,c];
  612. bPlyrMove4 = bStoredPlyrMove4[m,c];
  613. }
  614.  
  615. Step Event:
  616.  
  617. for other object: execute code:
  618.  
  619. ///HANDLE ATTACKS QUEUE
  620.  
  621. MonExists = instance_exists(Mon);
  622.  
  623. Key = keyboard_check(ord('R'));
  624. MouseLeft = mouse_check_button(mb_left);
  625.  
  626. if Key || MouseLeft { game_restart(); }
  627.  
  628. if global.FinishedTurn = false {
  629.  
  630. if PreAttackDelay > 0 { //if delay is greater than zero
  631.     PreAttackDelay -= 0.2; //subtract 0.2
  632. }
  633.  
  634. if PreAttackDelay <= 0 { //if delay is less than or equal to zero
  635.     PreAttackDelay = -1; //set it to zero incase value goes less than zero
  636. }
  637.  
  638. if PostAttackDelay > 0 { //if delay is greater than zero
  639.     PostAttackDelay -= 0.2; //subtract 0.2
  640. }
  641.  
  642. if PostAttackDelay <= 0 { //if delay is less than or equal to zero
  643.     PostAttackDelay = -1; //set it to zero incase value goes less than zero
  644. }
  645.  
  646. }
  647.  
  648. with(Mon) {
  649. if o = 0 && aMoveSelected = true && global.aWaiting = false {
  650.     global.aWaiting = true;
  651.     switch(other.SelectedMove) {
  652.         case 0:
  653.             StoredText[0] = PlyrName[o]+" used "+string(Var.MoveName[aPlyrMove1])+"!";
  654.             global.aDamageInflicted = (Var.MovePower[aPlyrMove1]*(PlyrAttk[o]/global.bStoredPlyrDfns))/50+2;
  655.             break;
  656.         case 1:
  657.             StoredText[0] = PlyrName[o]+" used "+string(Var.MoveName[aPlyrMove2])+"!";
  658.             global.aDamageInflicted = (Var.MovePower[aPlyrMove2]*(PlyrAttk[o]/global.bStoredPlyrDfns))/50+2;
  659.             break;
  660.         case 2:
  661.             StoredText[0] = PlyrName[o]+" used "+string(Var.MoveName[aPlyrMove3])+"!";
  662.             global.aDamageInflicted = (Var.MovePower[aPlyrMove3]*(PlyrAttk[o]/global.bStoredPlyrDfns))/50+2;
  663.             break;
  664.         case 3:
  665.             StoredText[0] = PlyrName[o]+" used "+string(Var.MoveName[aPlyrMove4])+"!";
  666.             global.aDamageInflicted = (Var.MovePower[aPlyrMove4]*(PlyrAttk[o]/global.bStoredPlyrDfns))/50+2;
  667.             break;
  668.     }
  669.     //global.PlayerQueue += 1;
  670.     }
  671. if o = 1 && bMoveSelected = true && global.bWaiting = false {
  672.     global.bWaiting = true;
  673.     switch(other.OtherSelectedMove) {
  674.         case 0:
  675.             StoredText[1] = "The opposing "+PlyrName[o]+" used "+string(Var.MoveName[bPlyrMove1])+"!";
  676.             global.bDamageInflicted = (Var.MovePower[bPlyrMove1]*(PlyrAttk[o]/global.aStoredPlyrDfns))/50+2;
  677.             break;
  678.         case 1:
  679.             StoredText[1] = "The opposing "+PlyrName[o]+" used "+string(Var.MoveName[bPlyrMove2])+"!";
  680.             global.bDamageInflicted = (Var.MovePower[bPlyrMove2]*(PlyrAttk[o]/global.aStoredPlyrDfns))/50+2;
  681.             break;
  682.         case 2:
  683.             StoredText[1] = "The opposing "+PlyrName[o]+" used "+string(Var.MoveName[bPlyrMove3])+"!";
  684.             global.bDamageInflicted = (Var.MovePower[bPlyrMove3]*(PlyrAttk[o]/global.aStoredPlyrDfns))/50+2;
  685.             break;
  686.         case 3:
  687.             StoredText[1] = "The opposing "+PlyrName[o]+" used "+string(Var.MoveName[bPlyrMove4])+"!";
  688.             global.bDamageInflicted = (Var.MovePower[bPlyrMove4]*(PlyrAttk[o]/global.aStoredPlyrDfns))/50+2;
  689.             break;
  690.     }
  691.     //global.PlayerQueue += 1;
  692.     }
  693. }
  694.  
  695. //BEGIN ATTACKING ONCE EVERYONE HAS SELECTED A MOVE
  696. //DETERMINE WHO IS FASTER FIRST TO BUILD A QUEUE
  697.  
  698. if (global.PlayerQueue >= 2) {
  699.  
  700.     global.FinishedTurn = false; //allows text box to fire off attack cmds
  701.    
  702.     //check 'o' value of Mon object and see who is faster
  703.             with(Mon) {
  704.             if (o = 0) { // player 1 moves
  705.             if ((global.aStoredPlyrSped > global.bStoredPlyrSped) || global.bFinishQueue = 1) /*if faster or player 2 already moved*/
  706.                 {
  707.                 if (global.Player1Moving = false && aMoveSelected = true && bMoveSelected = true) {
  708.                         global.Player1Moving = true;
  709.                         global.Player1DoneMoving = false;
  710.                         other.PreAttackDelay = 2;
  711.                         other.message_text = StoredText[0];
  712.                     }
  713.                 //if player 1 is moving
  714.                 if (global.Player1Moving = true || global.bFinishQueue = 1) {
  715.                     //other.message_text = StoredText[0];
  716.                     }
  717.             }
  718.             }
  719.             if (o = 0 && other.PreAttackDelay = -1 && global.Player1Moving = true && global.Player1DoneMoving = false) {
  720.                     global.Player2Damaged = true;
  721.                 }
  722.             }
  723.            
  724.             with(Mon) {
  725.             if (o = 1) { // player 2 moves
  726.             if ((global.aStoredPlyrSped <= global.bStoredPlyrSped) || global.aFinishQueue = 1) //if faster or player 1 already moved
  727.                 {
  728.                 if (global.Player2Moving = false && aMoveSelected = true && bMoveSelected = true) {
  729.                         global.Player2Moving = true; // player 2 moves, damages player 1
  730.                         global.Player2DoneMoving = false;
  731.                         other.PreAttackDelay = 2;
  732.                         other.message_text = StoredText[1];
  733.                     }
  734.                 //if player 2 is moving
  735.                 if (global.Player2Moving = true || global.aFinishQueue = 1) {
  736.                     //other.message_text = StoredText[1];
  737.                     }
  738.             }
  739.             }
  740.             if (o = 1 && other.PreAttackDelay = -1 && global.Player2Moving = true && global.Player2DoneMoving = false) {
  741.                     global.Player1Damaged = true;
  742.                 }
  743.             }
  744. }
  745.  
  746. if (MonExists)
  747. if (PreAttackDelay = -1 && global.aFinishQueue = 1 && global.bFinishQueue = 1 && global.FinishedTurn = false) {
  748.     global.FinishedTurn = true; //finish the turn
  749.     global.PlayerQueue = 0;
  750.     global.Player1Moving = false;
  751.     global.Player2Moving = false;
  752.     global.Player1Damaged = false;
  753.     global.Player2Damaged = false;
  754.     global.Player1DoneMoving = true;
  755.     global.Player2DoneMoving = true;
  756.     global.aWaiting = 0;
  757.     global.bWaiting = 0;
  758.     OtherSelectedMove = irandom_range(0,3);
  759.     with(Mon) {
  760.         aMoveSelected = false;
  761.         bMoveSelected = false;
  762.     }
  763.     global.aFinishQueue = 0;
  764.     global.bFinishQueue = 0;
  765. }
  766.  
  767. if global.FinishedTurn = true {
  768.     message_text = "What will "+string(aSideName)+" do?"
  769. }  
  770.    
  771.  
  772. Draw Event:
  773.  
  774. execute code:
  775.  
  776. /*
  777.  
  778. x1y1====================================
  779. ========================================
  780. ========================================
  781. ====================================x2y2
  782.  
  783. */
  784. padding = 32;
  785. box_height = 128;
  786. textboxcolor = c_white;
  787.  
  788. box_left = view_xview+padding;
  789. box_top = view_yview+view_hview-padding-box_height;
  790. box_right = view_xview+view_wview-padding;
  791. box_bottom = view_yview+view_hview-padding;
  792.  
  793. with(Mon) {
  794.     if o = 0 {
  795.         other.aSideName = PlyrName[0];
  796.         }
  797.     if o = 1 {
  798.         other.bSideName = PlyrName[1];
  799.         }
  800. }
  801.  
  802. draw_set_color(textboxcolor);
  803. draw_rectangle(box_left,box_top,box_right,box_bottom,false)
  804.  
  805. // display text message
  806.  
  807. text_draw(box_left*1.3,box_top*1.01,string(message_text),c_black);
  808.  
  809. Left = keyboard_check_pressed(vk_left);
  810. Right = keyboard_check_pressed(vk_right);
  811. Up = keyboard_check_pressed(vk_up);
  812. Down = keyboard_check_pressed(vk_down);
  813. Select = keyboard_check_pressed(vk_enter);
  814. maxStringWidth = "ThisIsTheMaxStringLimit";
  815. longestString = string_width(maxStringWidth);
  816. MoveColor1 = c_black;
  817. MoveColor2 = c_black;
  818. MoveColor3 = c_black;
  819. MoveColor4 = c_black;
  820.  
  821. /* Moves
  822.  
  823.   0  |  1
  824. -----------
  825.   2  |  3
  826.  
  827. */
  828.  
  829. if delay > 0 {
  830.     delay -= 0.2;
  831. }
  832.  
  833. if (Left && delay = 0)
  834. if (SelectedMove = 1 || SelectedMove = 3) {
  835.     SelectedMove -= 1;
  836.     delay = 0.6;
  837. }
  838.  
  839. if (Left && delay = 0)
  840. if (SelectedMove = 0 || SelectedMove = 2) {
  841.     SelectedMove += 1;
  842.     delay = 0.6;
  843. }
  844.  
  845. if (Right && delay = 0)
  846. if (SelectedMove = 0 || SelectedMove = 2) {
  847.     SelectedMove += 1;
  848.     delay = 0.6;
  849. }
  850.  
  851. if (Right && delay = 0)
  852. if (SelectedMove = 1 || SelectedMove = 3) {
  853.     SelectedMove -= 1;
  854.     delay = 0.6;
  855. }
  856.  
  857. if (Up && delay = 0)
  858. if (SelectedMove = 2 || SelectedMove = 3) {
  859.     SelectedMove -= 2;
  860.     delay = 0.6;
  861. }
  862.  
  863. if (Up && delay = 0)
  864. if (SelectedMove = 0 || SelectedMove = 1) {
  865.     SelectedMove += 2;
  866.     delay = 0.6;
  867. }
  868.  
  869. if (Down && delay = 0)
  870. if (SelectedMove = 0 || SelectedMove = 1) {
  871.     SelectedMove += 2;
  872.     delay = 0.6;
  873. }
  874.  
  875. if (Down && delay = 0)
  876. if (SelectedMove = 2 || SelectedMove = 3) {
  877.     SelectedMove -= 2;
  878.     delay = 0.6;
  879. }
  880.  
  881.  
  882. switch(SelectedMove) {
  883.     case 0:
  884.         MoveColor1 = c_yellow;
  885.         MoveColor2 = c_black;
  886.         MoveColor3 = c_black;
  887.         MoveColor4 = c_black;
  888.         break;
  889.     case 1:
  890.         MoveColor1 = c_black;
  891.         MoveColor2 = c_yellow;
  892.         MoveColor3 = c_black;
  893.         MoveColor4 = c_black;  
  894.         break;
  895.     case 2:
  896.         MoveColor1 = c_black;
  897.         MoveColor2 = c_black;
  898.         MoveColor3 = c_yellow;
  899.         MoveColor4 = c_black;  
  900.         break;
  901.     case 3:
  902.         MoveColor1 = c_black;
  903.         MoveColor2 = c_black;
  904.         MoveColor3 = c_black;
  905.         MoveColor4 = c_yellow;  
  906.         break;
  907. }
  908.  
  909. if Left { debugger = true; }
  910.  
  911. if debugger = true {
  912. text_draw(box_left*1.3,box_top*0.90,"Player Queue: "+string(global.PlayerQueue),c_black);
  913. //text_draw(box_left*1.3,box_top*0.85,"bSelected: "+string(Mon.bMoveSelected),c_black);
  914. //text_draw(box_left*1.3,box_top*0.80,"aSelected: "+string(Mon.aMoveSelected),c_black);
  915. text_draw(box_left*1.3,box_top*0.70,"bMoving: "+string(global.Player2Moving),c_black);
  916. text_draw(box_left*1.3,box_top*0.65,"aMoving: "+string(global.Player1Moving),c_black);
  917. //text_draw(box_left*1.3,box_top*0.70,"bDamageInflicted: "+string(global.bDamageInflicted),c_black);
  918. //text_draw(box_left*1.3,box_top*0.65,"aDamageInflicted: "+string(global.aDamageInflicted),c_black);
  919. text_draw(box_left*1.3,box_top*0.75,"FinishedTurn: "+string(global.FinishedTurn),c_black);
  920. text_draw(box_left*1.3,box_top*0.85,"PreAttackDelay: "+string(PreAttackDelay),c_black);
  921. text_draw(box_left*1.3,box_top*0.80,"PostAttackDelay: "+string(PostAttackDelay),c_black);
  922. }
  923.  
  924. with(Mon) {
  925. if other.Select && aMoveSelected = false {
  926.     aMoveSelected = true;
  927.     global.PlayerQueue += 1;
  928.     if bMoveSelected = false {
  929.         bMoveSelected = true;
  930.         global.PlayerQueue += 1;
  931.     }
  932.     //global.PlayerQueue += 1;
  933.     }
  934. }
  935.  
  936. // display the movepool
  937.  
  938. text_draw(box_right-(longestString*2)-(padding*2),box_top*1.08,string(Var.MoveName[Mon.aPlyrMove1]),MoveColor1);
  939. text_draw(box_right-padding-string_width(string(Var.MoveName[Mon.aPlyrMove2])),box_top*1.08,string(Var.MoveName[Mon.aPlyrMove2]),MoveColor2);
  940. text_draw(box_right-(longestString*2)-(padding*2),box_top*1.15,string(Var.MoveName[Mon.aPlyrMove3]),MoveColor3);
  941. text_draw(box_right-padding-string_width(string(Var.MoveName[Mon.aPlyrMove4])),box_top*1.15,string(Var.MoveName[Mon.aPlyrMove4]),MoveColor4);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement