Hi! I'm still new to Ti-Basic but I've been working on a program I'm really proud of!

It's a basic Pokemon battle simulator, with the following features:
-Four randomly generated moves for both you and your enemy
-Moves can be either Physical or Special
-Moves have PP (Higher PP for lower damaging moves)
-Once you run out of PP, you're forced to use Struggle
-Moves have Accuracy (Higher Accuracy for lower damaging moves)
-Random Critical Hits

Stats are randomly generated using random base stats that aren't unrealistic.
The only thing the user really chooses in the battle is what level your pokemon should be, what level the enemy should be, and what move to use.

http://i.imgur.com/vVfWE2i.gifv
Here's a gif of a quick runthrough of the program

It works really well, It's just that i'm coming across one very small bug. When you set the enemies level very high, and yours very low, an attack that should do hundreds of damage will do a very low amount of damage, like, single digits.

Anyways, here's my code! I'm asking for critique and help since I'm still a beginner and I have a lot to learn.

Code:
``` Lbl ZZ AxesOff ClrDraw DelVar {Y1} ClrHome DelVar [C] DelVar [D] {2,6}->dim([C] Fill(0,[C] {8,4}->dim([D] Fill(0,[D] For(X,1,8 randInt(20,130)->[D](X,1 End For(K,1,8 randInt(1,2)->[D](K,2 End 1->N Text(0,21,"Welcome to my Text(6,18,"Battle Simulator Text(13,2,"First we will Text(13,45,"make a random Text(19,20,"enemy Pokemon. Text(30,19,"ENTER to advance Pause ClrDraw Text(1,1,"Before we begin, when you Text(7,1,"select a move to use, it will Text(13,1,"be shown in this format Text(20,10,"Base Power, Type Text(27,1,"As an example: Text(34,32,"77, Phys. Text(40,1,"77 Base Power, Physical Atk Text(47,19,"ENTER to advance Pause ClrHome Disp "What should the","enemys level be?"," Input "",L {0,1->L1 {0,[D](1,1)->L2 LinReg(ax+b) {Y1} Equ>String({Y1},Str1 sub(Str1,1,length(Str1)-3->Str1 {0,1->L1 {0,[D](2,1)->L2 LinReg(ax+b) {Y1} Equ>String({Y1},Str2 sub(Str2,1,length(Str2)-3->Str2 {0,1->L1 {0,[D](3,1)->L2 LinReg(ax+b) {Y1} Equ>String({Y1},Str3 sub(Str3,1,length(Str3)-3->Str3 {0,1->L1 {0,[D](4,1)->L2 LinReg(ax+b) {Y1} Equ>String({Y1},Str4 sub(Str4,1,length(Str4)-3->Str4 If [D](1,2)=1 Str1+", Phys."->Str1 If [D](2,2)=1 Str2+", Phys."->Str2 If [D](3,2)=1 Str3+", Phys."->Str3 If [D](4,2)=1 Str4+", Phys."->Str4 If [D](1,2)=2 Str1+", Spec."->Str1 If [D](2,2)=2 Str2+", Spec."->Str2 If [D](3,2)=2 Str3+", Spec."->Str3 If [D](4,2)=2 Str4+", Spec."->Str4 DelVar {Y1} randInt(0,31->I randInt(0,255->E randInt(1,255->B iPart((((2B+I+(E/4))*L)/(100))+L+10)->[C](2,1 For(A,2,6 randInt(0,31->I randInt(0,255->E randInt(5,130->B iPart((((((2B+I+(E/4))*L)/(100))+5)*N))->[C](2,A End ClrHome Text(1,38,"Stats Text(57,19,"ENTER to advance Text(3,4,"Enemy's Text(9,36,"Health Text(16,36,"Attack Text(23,30,"Sp. Attack Text(30,35,"Defense Text(37,29,"Sp. Defense Text(44,37,"Speed Pause Text(9,12,[C](2,1 Pause Text(16,12,[C](2,2 Pause Text(23,12,[C](2,3 Pause Text(30,12,[C](2,4 Pause Text(37,12,[C](2,5 Pause Text(44,12,[C](2,6 Pause ClrHome Disp "Now we make","your Pokemon! Pause "ENTER to advance ClrHome Disp "What should","your level be?"," Input "",L randInt(0,31->I randInt(0,255->E randInt(1,255->B iPart((((2B+I+(E/4))*L)/(100))+L+10)->[C](1,1     For(A,2,6 randInt(0,31->I randInt(0,255->E randInt(5,130->B iPart((((((2B+I+(E/4))*L)/(100))+5)*N))->[C](1,A End ClrHome Text(3,70,"Yours Pause Text(9,78,[C](1,1 Pause Text(16,78,[C](1,2 Pause Text(23,78,[C](1,3 Pause Text(30,78,[C](1,4 Pause Text(37,78,[C](1,5 Pause Text(44,78,[C](1,6 Pause For(Y,1,8 iPart(([D](Y,1)/10)-8)->theta If theta<0 0->theta If theta>4 4->theta 100-5theta->[D](Y,3 5-theta->[D](Y,4 End If [C](1,6)>[C](2,6 Goto A If [C](1,6)<[C](2,6 Goto B If [C](1,6)=[C](2,6 randInt(1,2->X If X=1 Goto A If X=2 Goto B Lbl A If [C](1,1)<=0 Then    ClrHome    Disp "You lost!    Pause "ENTER to advance    Menu("Battle again?","Yes",ZZ,"No",Z1    Else    ClrHome    Disp "Your turn","to attack!    Pause "ENTER to advance    ClrHome    Lbl A8    ClrHome    If [D](1,4)=0 and [D](2,4)=0 and [D](3,4)=0 and [D](4,4)=0    Then       Disp "Youre out of PP!       Disp "You struggled!       [C](1,2->A       [C](2,4->D       50->B       iPart(([C](1,1)*.25))->J       iPart([C](1,1)-[C](1,1)*.25)->[C](1,1       Goto F1    End    Menu("What move?",Str1,A1,Str2,A2,Str3,A3,Str4,A4,"View Stats",A7    Lbl A1    If [D](1,4)=0    Goto FF    [D](1,4)-1->[D](1,4    1->X    If [D](1,2)=1    Goto A5    If [D](1,2)=2    Goto A6    Lbl A2    If [D](2,4)=0    Goto FF    [D](2,4)-1->[D](2,4    2->X    If [D](2,2)=1    Goto A5    If [D](2,2)=2    Goto A6    Lbl A3    If [D](3,4)=0    Goto FF    [D](3,4)-1->[D](3,4    3->X    If [D](3,2)=1    Goto A5    If [D](3,2)=2    Goto A6    Lbl A4    If [D](4,4)=0    Goto FF    [D](4,4)-1->[D](4,4    4->X    If [D](4,2)=1    Goto A5    If [D](4,2)=2    Goto A6        Lbl A7    Pxl-On(4,4    Pause    Goto A8        Lbl A5    [C](1,2->A    [C](2,4->D    Goto B1    Lbl A6    [C](1,3->A    [C](2,5->D    Goto B1 End Lbl B1 [D](X,1->B randInt(1,100->S If S>75 Then    1.5->S    Else    1->S End Goto ST Lbl FF ClrHome Disp "Your move is Disp "out of PP! Disp " Disp "Choose a Disp "different move! Pause "Enter to advance Goto A8 Lbl ST X->Y If [D](Y,3)<=randInt(0,100 Then    ClrHome    Disp "You missed    Disp "the Pokemon!    Pause "ENTER to advance    Goto B    Else    randInt(1,100->C    If C>94    Then       2->C       Else       1->C    End End randInt(85,100)/100->R Goto GI Lbl F1 Pause ClrHome Disp "You took",J,"recoil damage! Lbl GI SCR->M iPart(((((2L+10)/(250))*(A/D)*B+2)*M))->Q [C](2,1)-Q->[C](2,1 If C=2 Disp "Critical hit!" Disp "You dealt",Q,"Damage! Pause " ClrHome Disp "Your enemy has If [C](2,1)<=0 0->[C](2,1 Disp [C](2,1),"Health left. Pause "ENTER to advance Goto B Lbl B If [C](2,1)<=0 Then    ClrHome    Disp "You won!    Pause "ENTER to advance    Menu("Battle again?","Yes",ZZ,"No",Z1    Else    ClrHome    Disp "Enemy's turn","to attack!    Pause "ENTER to advance    randInt(5,8->X    If [D](X,2)=1    [C](2,2->A    [C](1,4->D    Goto D1    If [D](X,2)=2    [C](2,3->A    [C](1,5->D    Goto D1 End Lbl D1 [D](X,1->B randInt(1,100->S If S>75 Then    1.5->S    Else    1->S End X->Y If [D](Y,3)<=randInt(0,100 Then    ClrHome    Disp "The enemy","missed!    Pause "ENTER to advance    Goto A    Else    randInt(1,100->C    If C>94    Then       2->C       Else       1->C    End End randInt(85,100)/100->R SCR->M iPart(((((2L+10)/(250))*(A/D)*B+2)*M))->Q [C](1,1)-Q->[C](1,1 ClrHome If C=2 Disp "Critical hit!" Disp "You were dealt",Q,"Damage! Pause " ClrHome Disp "You have If [C](1,1)<=0 0->[C](1,1 Disp [C](1,1),"Health left. Pause "ENTER to advance Goto A Lbl Z1 Stop ```
Your code is a little messy, but not unreasonably messy. You know that you don't have to close parenthesis/quotes, and some quotes are closed and some aren't. (I know that sometimes, you do have to close them, but ceck it over. Good COde!
Looks cool! To clarify what _iPhoenix_ said, any quote or grouping symbol at the end of a line or before a → can be left off.
Humm... here's a couple random optimizations.

This:

Code:
```DelVar [C] DelVar [D] {2,6}->dim([C] Fill(0,[C] {8,4}->dim([D] Fill(0,[D] ```

is redundant. It could be:

Code:
```DelVar [C] DelVar [D] //I like placing DelVar's on one line, but it doesn't really do much if you do. {2,6->dim([C] //After you delete them, all initial values of the entries are already 0. The fill(0) isn't needed. {8,4->dim([D] //Also notice the lack of the ending curly brace```

This:

Code:
```For(X,1,8 randInt(20,130)->[D](X,1 End For(K,1,8 randInt(1,2)->[D](K,2 End ```

can be simplified to this:

Code:
```For(X,1,8 randInt(20,130->[D](X,1 randInt(1,2->[D](X,2 End //This is okay since you had the same number of loops, I suppose? What I mean is that you had both loops going to 8. ```

This:

Code:
``` If [D](1,2)=1 Str1+", Phys."->Str1 If [D](2,2)=1 Str2+", Phys."->Str2 If [D](3,2)=1 Str3+", Phys."->Str3 If [D](4,2)=1 Str4+", Phys."->Str4 If [D](1,2)=2 Str1+", Spec."->Str1 If [D](2,2)=2 Str2+", Spec."->Str2 If [D](3,2)=2 Str3+", Spec."->Str3 If [D](4,2)=2 Str4+", Spec."->Str4 ```

could become:

Code:
``` ", Phys.->Str8 ", Spec.->Str9 //These are two arbitrary, temporary strings. If [D](1,2)=1 Str1+Str8->Str1 If [D](2,2)=1 Str2+Str8->Str2 ...//and so on If [D](4,2)=2 Str4+Str9->Str4 //I'm sure there's a better optimization, but I'm tired and yeah. ```

This:

Code:
```Pause Text(9,12,[C](2,1 Pause Text(16,12,[C](2,2 Pause Text(23,12,[C](2,3 Pause Text(30,12,[C](2,4 Pause Text(37,12,[C](2,5 Pause Text(44,12,[C](2,6 Pause ```

is a signal you should use a for loop:

Code:
```for(X,1,6   //Waaaay better than a ton of the same statement. Text(7X+2, 12, [C](2,X Pause //I'm not sure why Pause is here; it seems like it'd be annoying End ```

I'm done for now. Too tired to do more. Just post if you have any questions.

Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

»
» All times are UTC - 5 Hours

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum