Trying to create typing rpg

Hi, my question is, could anyone explain or "borrow" me the code for:

In my game I would like to create an item that its chance of hitting the enemy is 80% and if it hits, it steals for example 15 health out of 100. To use it I would have to type 1 in the output window.

I am kind of struggiling and to be honest I have no idea of how I should start it. Would love some help, thanks anyway.

Last edited on
Use a PRNG for the 80% hit cahnce then simply subtract 15 from the current health if it was a hit or not.

Anyways if you are trying to make a game you should invest some time into learning a graphics library or a game engine.

Graphics library: sfml or sdl
Game Engine: unity or udk/unreal
Thank you for the reply.

I am not going to use the engine yet, that game is going to be without graphics and only for my use. I want to practice the simple coding, because I'm very bad it ;x therfore I know the pseudocode but not the real code.. ;c
Well 80% is 80/100 = 8/10 = 4/5 so that would mean if the number you get is 0-3 then it is a hit and if it is a 4 then it is a miss. Or alternatively you could make 0 a missing and 1-4 a hit.

So bool hit = rand() % 5;
Topic archived. No new replies allowed.