What's the point in racking up points every time some hp is taken if you're going to reward the player when the NPC dies anyway?
Within your minigame let's say the NPC id is named id so you could do this:
Code:
int points ; //stores the player's points
switch( id )
{
case 90 : //npc had 100 hp
points = points + 100 ;
break ;
case 80 : //npc has 500 hp
points = points + 500 ;
break ;
default :
return ;
break ;
}
This code is only useful to you if you know what to change each variable to, but this is how you could do it, manually. This is an easy way to do it as long as you know each NPCs hp.
- - - Updated - - -
Originally Posted by
mohammed
you miss understood ... sorry i can't explain well since i didn't sleep from 2 days !
Example for the minigame
Npc is spawned
there is 3 players in the minigame
Player number 1
took 20% of the npc's hp
player number 2
took 50% of the npcs hp
player number 3
took 30% of the npc's hp
So the result will be
Player number 1
got 20 points
player number 2
got 50 points
player number 3
got 30 points
this is the example
I hope you guys can help ...
Oh okay, well, you should create a new npcPoint variable to be written into player files (like pest control points).
Then in your minigame method/class you could perhaps create an array that will hold something like:
Code:
int pArray = { 1 , 2 , 3 , 4 } ;
1,2,3,4 can represent the players so in this instance 4 would be the maximum amount of players.
In your mini-game assign each player an id within that array and check to make sure no number is used more than once and do not allow for more than 4 players.
Then, for each npc call to get their hp ( I do not have a method for this at hand ) or you could manually input it.
Then with every hit a player gets on this npc let's say player 1 gets 20hp, assign this to
Code:
pArray[ 1 ] = pArray[ 1 ] + newPoints ;
newPoints would be the hp that has been taken from the npc.
At the end of the game when points are being distributed, just assign the points to each player that has been playing with a for loop:
Code:
for( i = 1 ; i <= 4 ; i++ )
{
npcPoint = pArray[ i ] ;
}
Obviously I haven't given you much code but I've given you a simple structure on how you could complete this task.