Attack System

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.
Post Reply
bultrayer
Posts: 10
Joined: Tue Jan 22, 2013 7:52 am

Attack System

Post 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?
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: Attack System

Post 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!";
}
Post Reply

Return to “Advanced Help and Support”