Sign in to follow this  
hothead

making things do damage

Recommended Posts

I've got a function called fight() what I want it to do is the enemy chooses a random move between three moves,and their damage is constantly the same how do I do this?I also want to do the same thing for the player with four moves that looks some thing like this _____________________________ (1)slash (10) damage (2)claws of blood (25) damage (3)claws of steel (50) damage (4)windscar (100) damage ----------------------------- you start with 150HP the enemy starts with 150 HP. edit:there is no defense just offense

Share this post


Link to post
Share on other sites
Well, it sounds like you got the hard part done.... the function name, etc.

But seriously I would use an array, then rand().

unsigned int Attacks[4];

Sidenote:
Your into Inu Yasha huh? Hehe. I have episodes 1-155... and getting the last few right now.... Good luck w/ your game.

Share this post


Link to post
Share on other sites
Quote:
Original post by hothead
I've got a function called fight() what I want it to do is the enemy chooses a random move between three moves,and their damage is constantly the same how do I do this?


void creatureAttack(Creature *c, Player *p)
{
printf("%s",c->attacks[rand()%3].name);
p->health -= C; // Some constant damage
}



Quote:
Original post by hothead
I also want to do the same thing for the player with four moves that looks some thing like this
_____________________________
(1)slash (10) damage
(2)claws of blood (25) damage
(3)claws of steel (50) damage
(4)windscar (100) damage
-----------------------------
you start with 150HP the enemy starts with 150 HP.
edit:there is no defense just offense


void playerAttack(Player *p, Creature *c)
{
c->health -= p->attacks[rand()%4].dmg;
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this