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?
Attack System
- hallsofvallhalla
- Site Admin
- Posts: 12023
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Attack System
php
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 * floor(rand($hafpercent,$percent));
}
else
{
echo "You lose!";
}
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!";
}