0

Hi everyone how can i prevent the incrementation to exceed the limit?

7th Dec 2022, 4:03 PM
light angel
light angel - avatar
7 Answers
+ 3
Which incrementation? Please show an example code. You can use an if-statement to test if an integer variable exceeds a given limit.
7th Dec 2022, 4:05 PM
Lisa
Lisa - avatar
+ 3
light angel as far as I remember, skill spamming was using same weapon, technique, pattern, etc repeatedly. If that's your goal, you have to save the selected cases n likely in an array. Then check to see if there's a pattern or ie. are 3 last choices the same, cases of 223, etc disable or reduce impact temporarily so the player has to choose another case. but for now your code has many logical problems and hard to read. fix those first. case 3: if(hp<=lims[1] && lims[1]>hp){ (hp<=lims[1] && hp<lims[1]) ??? make a decision! hp+=10; if(hp==lims[1]){ will happen only if hp was lims[1]-10 do{ printf("Maximum hp reached\n"); hp was lims[1]-10 you added 10 hp--; now it's lims[1]-1 }while(hp==lims[1]); so this is always false, no loop } mp=mp-50; } instead you could do: hp += 10; if(hp >= lims[1]) { printf("Max hp..."); hp = lims[1] ; mp -= 50; } also lims[0,1..] aren't clear, either #define MAX_HP 123 or use a const int max_hp =123 or if you want the array, use an enum with it.
8th Dec 2022, 1:39 AM
Tina 🇺🇦🇮🇷🇹🇷
Tina 🇺🇦🇮🇷🇹🇷 - avatar
+ 1
Sololearn playground is not interactive so I cannot test your code. Which variable do you want to prevent from exceeding a limit?
7th Dec 2022, 4:12 PM
Lisa
Lisa - avatar
7th Dec 2022, 4:05 PM
light angel
light angel - avatar
7th Dec 2022, 4:10 PM
light angel
light angel - avatar
0
Hp, Mp
7th Dec 2022, 4:14 PM
light angel
light angel - avatar
0
I tried to figure it out on how to prevent skill spamming to make the game realistic, I'm a beginner
7th Dec 2022, 4:14 PM
light angel
light angel - avatar