Sinisterly
PokeBatch - The Pokemon experience in Batch - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Coding (https://sinister.li/Forum-Coding)
+--- Forum: Coding (https://sinister.li/Forum-Coding--71)
+--- Thread: PokeBatch - The Pokemon experience in Batch (/Thread-PokeBatch-The-Pokemon-experience-in-Batch)

Pages: 1 2


RE: PokeBatch - The Pokemon experience in Batch - Daedalus - 11-29-2013

You must be insane to write a full program like this in batch haha. I made a simple game once and it was just headache after headache. Anyway, sorry I can't help, just wanted to say it seems like it has potential and I'm really looking forward to the final version. Smile


RE: PokeBatch - The Pokemon experience in Batch - noize - 11-29-2013

(11-28-2013, 10:51 PM)Coder-san Wrote: I'm trying to use String array in Batch. I got some info and modified it.

Code:
@echo off setlocal ENABLEDELAYEDEXPANSION REM String, with words separated by spaces set pokemons=Caterpie Oddish Rattata Cubone set index=0 for %%A in (%pokemons%) do ( set pokemon[%index%] = %%A set /a index += 1 ) set pokemon set /a r=%random% %%!index! +1 set /a rnd=%r%-1 cls echo You are walking on tall grass echo Something is inside the grass echo A wild !pokemon[%rnd%]! has appeared pause

But I'm getting a blank space. Any ideas?

This is my output:
Code:
You are walking on tall grass Something is inside the grass A wild has appeared Press any key to continue . . .

A few FUCKING IMPORTANT things to be mentioned here.

1. FOR %%A in (%string%) ... won't work at all. Look up FOR /?, that kind of usage works only with files (instead of %string%). If you want to get the content of %string% separated by spaces you need something like this:

Code:
set s=Test Word Space for /f "tokens=1-3" %%a in ('echo %s%') do ( echo %%a echo %%b echo %%c )

The above code would output:

Code:
Test Word Space

2. there are NO arrays in Batch. You can make your own pseudo-tables by assigning variables like %array[index]%, but that wouldn't be an array element, just a variable with "array[index]" for an identifier.


RE: PokeBatch - The Pokemon experience in Batch - noize - 11-29-2013

(11-29-2013, 12:05 AM)Daedalus Wrote: You must be insane to write a full program like this in batch haha. I made a simple game once and it was just headache after headache. Anyway, sorry I can't help, just wanted to say it seems like it has potential and I'm really looking forward to the final version. Smile

Why? In Batch it's just so easy to write a program like this.


RE: PokeBatch - The Pokemon experience in Batch - Coder-san - 11-29-2013

(11-29-2013, 03:15 PM)noize Wrote: [...]
A few FUCKING IMPORTANT things to be mentioned here.

1. FOR %%A in (%string%) ... won't work at all. Look up FOR /?, that kind of usage works only with files (instead of %string%). If you want to get the content of %string% separated by spaces you need something like this:

Code:
set s=Test Word Space for /f "tokens=1-3" %%a in ('echo %s%') do ( echo %%a echo %%b echo %%c )

The above code would output:

Code:
Test Word Space

2. there are NO arrays in Batch. You can make your own pseudo-tables by assigning variables like %array[index]%, but that wouldn't be an array element, just a variable with "array[index]" for an identifier.

Oh well it was worth a try. As you can see, I'm trying to achieve this:

!pokemon[%rnd%]!

So a random wild pokemon pops up.

But I guess I'll stop it right there, and perhaps change it to a situation-based game. Because I'd need pokemon as objects so they can have hp, attack and stuff. Maybe in C# or so.

Thanks a lot for your help. Never knew Batch, so it was a good opportunity for learning.


RE: PokeBatch - The Pokemon experience in Batch - Coder-san - 11-30-2013

I'm having too much fun to let it go. Biggrin
Making it a bit mediocre now since I am unable handle the complexity in Batch myself.
Opening post updated with full code till now.

Still having trouble with Batch however.

After I choose an attack, it just closes on me.

Code:
:wildpokemon echo A wild %wildpkmn% has appeared echo. echo %wildpkmn%: %wildpkmn% set wildpkmn-lvl=2 set wildpkmn-hp=20 set wildpkmn-att=2 set wildpkmn-def=2 set wildpkmn-spd=2 set wildpkmn-spatt=2 set wildpkmn-spdef=2 echo. echo %name%: Go %starter% I choose you! echo %starter%: %starter% pause :wildpokemon-battle cls echo \---------------------------------------------------\ echo \ %wildpkmn% (Lvl %wildpkmn-lvl%) \ echo \---------------------------------------------------\ echo. echo HP: %wildpkmn-hp% echo. echo. echo \---------------------------------------------------\ echo \ %starter% (Lvl %starter-lvl%) \ echo \---------------------------------------------------\ echo. echo HP: %starter-hp% echo. echo. echo What do you want to do? echo. echo Enter option number to pick an option (1,2) echo 1) Tackle Attack echo 2) Bite echo 3) [Run] set /p wildpkmn-atk= pause set /a critical=%random% %%!1 +1 if '%wildpkmn-atk%' == '1' set impact-wildpkmn=((2*%wildpkmn-att%)/2)*(%critical%+1) if '%wildpkmn-atk%' == '2' set impact-wildpkmn=((3*%wildpkmn-att%)/2)*(%critical%+1) cls echo \---------------------------------------------------\ echo \ %wildpkmn% (Lvl %wildpkmn-lvl%) \ echo \---------------------------------------------------\ echo. echo HP: %wildpkmn-hp% set wildpkmn-hp=%wildpkmn-hp%-(%impact-wildpkmn%-%wildpkmn-def%) if '%critical%' == '0' echo %wildpkmn% lost %impact-wildpkmn% HP if '%critical%' == '1' ( echo Critical Hit! echo %wildpkmn% lost %impact-wildpkmn% HP ) echo HP: %wildpkmn-hp% echo. if %wildpkmn-hp% <=0 goto wild-1-victory

I also want the wildpkmn-hp to be:

Code:
set wildpkmn-hp=%wildpkmn-lvl%*10

But I'm getting a Missing operator error.


RE: PokeBatch - The Pokemon experience in Batch - noize - 11-30-2013

(11-29-2013, 06:03 PM)Coder-san Wrote: Oh well it was worth a try. As you can see, I'm trying to achieve this:

!pokemon[%rnd%]!

So a random wild pokemon pops up.

These are your lines of code to define RND:

Code:
set /a r=%random% %%!index! +1 set /a rnd=%r%-1

Would you mind letting me know what you were trying/hoping to achieve with this? 'cause I just can't get what you wanted to get here.

It's not a problem to pop up a random Pokemon, when they're all already indicized.

Your buggy code:

Code:
set wildpkmn-hp=%wildpkmn-lvl%*10

Your better-be-new code:

Code:
set /a wildpkmn-hp=%wildpkmn-lvl%*10

To identify why it just "closes on you", open up a shell instance and invoke your script from over there. It should not close, so that you can read the error message and identify the problem.


RE: PokeBatch - The Pokemon experience in Batch - ninja805 - 12-09-2013

Wow Coder-San, it seems like you put a heck-load of amount of work and time into this, I'll plan on playing it later on and see what I think! :Grin: