Some improvements to my battle system?

“I edit this post, I think this info could be useful for those who are confused with the * if statements”

“Let’s learn together, I also have many questions!”

“As my battle system becomes more stable, I will add the changes until a final version remains and I can leave it here for those users who need it.”

“I am creating a basic but functional battle system.”

“My idea is that the battles function as small challenges to unlock in order to continue with the plot of the story I am writing.”

“What I have is the following:”

“I’m going to mark comments enclosed in quotes, so they understand that all this is not part of the code:”

“At the head of the game, I create 2 variables called “s” and “s1”, these represent the health of the character and the enemy, being that of the latter “s1”.”
“Then I create 5 variables with the names of attacks of the main character and 5 with those of the enemy, these being “b1”, “b2”, “b3”, “b4” and “b5”.”
“Finally I create 5 more variables with the names of the enemies, it is important to comment that for this example, the enemy that I am going to use is the “e2”, which represents the enemy 2.”

“Now the battle:”

“The system is simple. You and the enemy have 100% health before starting the battle. The mechanics are simple:”
“If you win, you are sent to another scene to continue the story. If you tie, you must fight again. If you lose, you must fight again.”
“Commands to send to other scenes can skip them, they could use “goto” and “label” to have everything in the same file.”
“Now let’s see what doesn’t end up working:”
“When the user attacks, the system works fine. If I attack with attack 1, the screen shows:”
“You use moonbeam.”
“Gargoyles use Rock Gliding.”

“But, if I use the same attack again, the message that appears is the following:”
“You use 8.”
“Gargoyles use 6.”

“Note: The number may vary, as you will see in the code, I use the “rand” command to generate random damage.”

“For the teachers of the forum:”
"It is important to comment that this always happens after the second attack, in all attacks. Is it a problem with the “RAND” command? I have read that there are problems with this command, although at the moment I can’t think of something similar to make the damage of the attacks is random "

“What is missing from this battle?”

“I want the enemy’s attacks to be random”

“I have an idea, I have not researched much but at the time of sending this entry, I will be doing some experiments.”

“I imagine that with the “if, elseif and else” command and the “rand” command we can randomize the attacks.”

“Well guys, I leave the code so far, those interested can follow this thread, and the experienced can help us with their valuable knowledge!.”

“Example:”

*create s “100”
*create s1 “100”
*create a1 “lunar ray”
*create a2 “animarian fire”
*create a3 “lava stroke”
*create a4 “thunder sword”
*create a5 “flash hit”
*create b1 “rock slide”
*create b2 “magna”
*create b3 “dark dimension”
*create b4 “stone sword”
*create b5 “destruction”
*create e1 “hippocampus”
*create e2 “gargoyles”
*create e3 “kraken”
*create e4 “chimera”
*create e5 “phoenix”

*if ((s <= 0) and (s1 <= 0))

The battle with $!{e2} is tied. You must fight again until you get the stone talisman.
*goto_scene startup r_b_cap2

*elseif s <= 0

Iou were defeated by $!{e2}. Now you will have to fight again.
*goto_scene startup cap2

*elseif s1 <= 0

You defeated the powerful $!{e2}!

You unlock this challenge and get the stone talisman.
*page_break Keep playing!
*goto_scene startup r_b_cap2_completo

*else

*label elections

What do you choose?
*choice
#$!{a1}.

You use $!{a1}.

$!{e2} use $!{b1}.

*rand b1 4 9
*set s -b1
*rand a1 4 9
*set s1 -a1
Your health is $!{s}, and that of ${e2} is ${s1}.
*goto elections

#$!{a2}.

You use $!{a2}.

$!{e2} use $!{b2}.

*rand b2 7 13
*set s -b2
*rand a2 7 13
*set s1 -a2
Your health is ${s}, and that of $!{e2} is ${s1}.
*goto elections

#$!{a3}.

You use $!{a3}!.

$!{e2} use $!{b3}.

*rand b3 9 15
*set s -b3
*rand a3 9 15
*set s1 -a3
Your health is ${s}, and that of $!{e2} is ${s1}.
*goto elections

#$!{a4}.

You use $!{a4}.

$!{e2} use $!{b4}.

*rand b4 11 17
*set s -b4
*rand a4 11 17
*set s1 -a4
Your health is ${s}, and that of $!{e2} is ${s1}.
*goto elections

#$!{a5}.

You use $!{a5}.

$!{e2} use $!{b5}.

*rand b5 13 19
*set s -b5
*rand a5 13 19
*set s1 -a5
Your health is ${s}, and that of $!{e2} is ${s1}.
*goto elections

Randomize the damage value first, then apply that value as substraction.

*rand dmg 0 6
*set hp -dmg
1 Like

Omg, a ChoiceScript game in Spanish (I checked and there isn’t a rule that says I can only post in English, but for the sake of not being a pain for the mods, I may as well write on both languages)

Vos sos el otro escritor de Argentina, no? Un placer! Perdón por comentar acá, pero hace un montón que no veo nadie de mi país en el foro (y mucho menos alguien medio activo) y a lo mejor es porque no dormí nada, pero pensé que sería lindo saludar. Tu juego se ve cool y la verdad amaría verlo terminado. Creo que nunca jugué un CS en español, menos uno de fantasía 'xD Así que, err, buena suerte! Si querés ayuda con tu inglés avisá!

You’re the other writer from Argentina, no? A pleasure! Sorry for commenting here, but it’s been a while since I see someone from my country in the forum, let alone someone who’s kind of active, and maybe it’s bc I haven’t had enough sleep, but I thought it may be nice to say hi. Your game looks cool and I would love to see it finished. I think I never played a CS in Spanish, specially a fantasy one 'xD So, err, best of luck! If you need help with your English let me know!

Hi, I’m from Argentina too, I thought I was alone.
[español] Hola, yo también soy de Argentina, pensé que estaba solo. [español]

Regarding the language CoG and HG only publishes titles written in english or at least that’s what it says here.
[español] Con respecto al lenguaje CoG y Hosted games sólo publican en inglés, o por lo menos eso es lo que dice acá. [español]

So I would recommend you to write your story in english if you want to publish it by those means.
[español] Asique te recomiendo que escribas tu historia en ingles si queres publicarla por esos medios. [español]

The command “*finish” after the “*goto” isn’t necessary
[español] El comando “*finish” después del “*goto” no es necesario.

1 Like

Thanks for your answers guys.
I have modified the post, now I have another question, I invite you to read it.
Thank you very much everyone, we are still here in the thread.

It seems you are trying to use b1 as a text string and then changing it to a numeric random value. You need one variable for b1 “Rock slide” and another for the numeric damage or whatever that it does like b1damage # or b1d or whatever you want to call it.

I see you are using some variables like a1, a2 etc as lists of sorts. It might be possible to implement arrays to improve the code.

If its possible can you wrap the whole code in those code boxes so that its better readable so we can analyze better.