Page 1 of 1
Attack System
Posted: Wed Jan 23, 2013 3:15 pm
by bultrayer
Alright , im looking to make attack system , the attack system will take resources and money from the players who been attacked
depends on the attacker power , if the attacker power is stronger then the attacked person so the attacker will win.
I'am not finding the right way doing it , can any one help?
Re: Attack System
Posted: Wed Jan 23, 2013 4:43 pm
by hallsofvallhalla
php
Code: Select all
if($playerattack > $otherplayerattack)
{
////get the difference in attack power, so the bigger the hit the more gold taken
$percent = ($playerattack - $otherplayerattack) / 100;
/////randomize each percent
$hafpercent = $percent / 2;
$goldreceived = $otherplayergold * floor(rand($hafpercent,$percent));
}
else
{
echo "You lose!";
}
javascript
Code: Select all
if(playerattack > otherplayerattack)
{
////get the difference in attack power, so the bigger the hit the more gold taken
percent = (playerattack - otherplayerattack) / 100;
/////randomize each percent
hafpercent = percent / 2;
goldreceived = otherplayergold * math.floor(math.random(hafpercent,percent));
}
else
{
document.getElementbyId('outputtext').innerHTML= "You lose!";
}