“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