• 0

[PHP] Attack System Help


Question

hey all,

not sure if this is the right place so sorry if its not :D

basically, im in the middle of making a text based game using php. easiest way to explain it is its gunna be like Mob Wars on facebook.

so im trying to work out how the attacking will work, and im getting very confused :D

here is what i have so far.

function deflection($op)
{
	$opd = (((($op['str']/100)*10)/($op['def']*(1-($op['lck']/100)))*10))*3;

	return $opd;
}

function calc_attack($user, $opd)
{
	$max_attack = ($user['atk']*$user['str'])*(($user['lck']/(rand(5,50)/10))+1);

	$justified_attack = $max_attack * (1-(rand(1,$opd)));

	return round($justified_attack);
}

the idea is that the opponent will deflect a % of the attack.

i thought i had a pretty good algorithm while i was testing it in excel, but somehow everything got messed up and now it doesnt work in my php script or in my excel spreadsheet :(

just so you know, all the figures are just plucked out of thin air, there is no real significance to any number. just made it up as i went along :D

and its also worth noting that when a user signs up (at the moment) they are given stats of 100 HP and 1 for everything else. each attack takes away from the HP until someone dies.

so my question is, can anyone help me sort out/create a new attack algorithm. im open to all suggestions really.

thanks in advance

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Deflection is called "Spirited Defence" in many games. Check out Mobsters 2 on fb they have it there alont with Critical Hits canna help with the code tho im no coder =)

Link to comment
Share on other sites

  • 0

Deflection is called "Spirited Defence" in many games. Check out Mobsters 2 on fb they have it there alont with Critical Hits canna help with the code tho im no coder =)

thanks for the reply.

i've played quite a few games like this, and they each implement different things in their attack systems.

the difficulty is trying to get it working yourself :(

once i have implemented a working attack system, with the bit i have included, i will look into expanding it.

eventually i want to add, like you said, critical hits, as it should make things more varied and interesting.

anyone else got any ideas?

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.