Okay, I've tried 100 different setups for the attack system and I can't seem to find anything worthwile that works well.
I have basic attack points and defense points and health system. I haven't added anything else yet, but might in the future. Anyone have any ideas? I do have bullets that you have to have in order to attack the person. Those bullets can be chosen b/w 1 and 20, 20 being the higher possible damage done to the player. And I have it setup to where you lose, that the health you lose goes to the other player. I like it like that, since health won't be able to be restored otherwise.
Battle Attack Formulas
Re: Battle Attack Formulas
Vampire bullets!
I think it's a question of what message are you trying to get across with a combat system, in terms of how you build it. What are you trying to get at?
I think it's a question of what message are you trying to get across with a combat system, in terms of how you build it. What are you trying to get at?
Re: Battle Attack Formulas
haha Vampires YAY...Callan S. wrote:Vampire bullets!
I think it's a question of what message are you trying to get across with a combat system, in terms of how you build it. What are you trying to get at?
Well, it's a mafia style game, where you need bullets to hit em. I want them to be able to hit someone, but at the lower numbers of bullets chosen, have a possible chance of losing, but the higher bullets used, have a better chance of winning, but of course have it based off users atk/def.... I just can't come up with a good formula. If I go by basic atk/def by number of bullets, then the lower amount used on lower bullets you might lose, but the higher bullets, the MORE you lose... I don't want it like that. It's hard to come up with a battle system to be honest. At least for me lol
Re: Battle Attack Formulas
Well with only the 2 stats you gave us. Its kind of hard to come up with a good battle formula.Epiales wrote:haha Vampires YAY...Callan S. wrote:Vampire bullets!
I think it's a question of what message are you trying to get across with a combat system, in terms of how you build it. What are you trying to get at?
Well, it's a mafia style game, where you need bullets to hit em. I want them to be able to hit someone, but at the lower numbers of bullets chosen, have a possible chance of losing, but the higher bullets used, have a better chance of winning, but of course have it based off users atk/def.... I just can't come up with a good formula. If I go by basic atk/def by number of bullets, then the lower amount used on lower bullets you might lose, but the higher bullets, the MORE you lose... I don't want it like that. It's hard to come up with a battle system to be honest. At least for me lol
Maybe use an altered version of your formula. like a for loop for each bullet
Code: Select all
$hits = 0;
for($i = 0; $i < {INSERT_NUM_BULLETS_VAR}; $i++)
$dice = rand(1,100);
//20% chance of missing with bullet
if($dice < 20)
{
//some sort of message maybe
}
else//bullet hit
{
//use altered version of your formula. Each bullet hit does damage
//this will tell whoever how many times there bullet hit oppoment
$hits++;
}
}
//no hits
if($hits == 0)
{
echo "DAMN I SUCK AT SHOOTING!!!";
}
else
{
echo "whatever you want $hits";
}
Re: Battle Attack Formulas
What is the if $dice is < 20 for? And the $hits? Since the $hits is always equaling 1 and no more?Sim wrote:Callan S. wrote:Vampire bullets!
Well with only the 2 stats you gave us. Its kind of hard to come up with a good battle formula.
Maybe use an altered version of your formula. like a for loop for each bulletCode: Select all
$hits = 0; for($i = 0; $i < {INSERT_NUM_BULLETS_VAR}; $i++) $dice = rand(1,100); //20% chance of missing with bullet if($dice < 20) { //some sort of message maybe } else//bullet hit { //use altered version of your formula. Each bullet hit does damage //this will tell whoever how many times there bullet hit oppoment $hits++; } } //no hits if($hits == 0) { echo "DAMN I SUCK AT SHOOTING!!!"; } else { echo "whatever you want $hits"; }
I'm assuming that the < 20 is basically the formula for a 20% chance to miss and 80% chance to hit...
I thought the other would be like... You use 15 bullets to attack, but only like 6 of them hit the person and the others don't hit them. I thought that would be what the $hit would be, the number 6 to show 6 bullets hit them.... but the $hits always remain at 1 no matter what I put in there? I do n't see anything that would make that number go up, so not sure what it's there for. I like the idea of using so many bullets, and then having the chance to only have a few of them hit or all of them hit.
I guess something like:
Code: Select all
$r = rand(1, $_POST['dropdown']);
Re: Battle Attack Formulas
Okay, I'm this far so far. I need to come up with some type of health loss to the person that loses now. At least I think I'm started in the right direction with u're formula. Thx! You can see below how I"ve used it so far.
Code: Select all
if (isset($_POST['dropdown'])) {
// cast to integer to avoid malicious values
$dropdown = (int)$_POST['dropdown'];
$hits = 0;
for($i = 0; $i < $_POST['dropdown']; $i++)
$r = rand(1, $_POST['dropdown']);
$dice = rand(1,100);
//20% chance of missing with bullet
if($dice < 20)
{
//some sort of message maybe
}
else//bullet hit
{
//DEFENDERS FORMULAS//
$sql = "SELECT * FROM users WHERE `id`='".$id."'";
$user_query = mysqli_query($db_conx, $sql);
$numrows = mysqli_num_rows($user_query);
while ($row = mysqli_fetch_array($user_query, MYSQLI_ASSOC)) {
$def_user = $row['username'];
$defense_user_strength = $row['strength'];
$defense_user_defense = $row['defense'];
$defense_user_defense = $defense_user_strength + $defense_user_defense;
//ATTACKERS FORMULAS//
$sql = "SELECT * FROM users WHERE id = '$_SESSION[userid]'";
$user_query = mysqli_query($db_conx, $sql);
$numrows = mysqli_num_rows($user_query);
while ($row = mysqli_fetch_array($user_query, MYSQLI_ASSOC)) {
$attack_user_strength = $row['strength'];
$attack_user_defense = $row['defense'];
$attack_user_attack = $attack_user_strength + $attack_user_defense;
}
}
//this will tell whoever how many times there bullet hit oppoment
$hits++;
}
}
//no hits
if($hits == 0)
{
$sql = "SELECT * FROM users WHERE `id`='".$id."'";
$user_query = mysqli_query($db_conx, $sql);
$numrows = mysqli_num_rows($user_query);
while ($row = mysqli_fetch_array($user_query, MYSQLI_ASSOC)) {
$def_user = $row['username'];
$sql = "SELECT * FROM users WHERE id = '$_SESSION[userid]'";
$user_query = mysqli_query($db_conx, $sql);
$numrows = mysqli_num_rows($user_query);
while ($row = mysqli_fetch_array($user_query, MYSQLI_ASSOC)) {
$def_user_loss = .020 * $row['hpoints'];
echo "DAMN YOU SUCK AT SHOOTING!!! YOU SHOT AT $def_user $i TIMES, AND MISSED EVERY TIME!!!";
echo "YOU LOSE $def_user_loss HEALTH (2%) FOR BEING A POOR SHOT!";
}}}
else
{
echo "You shot $i times at $def_user and hit them $r times! ";
}
- KyleMassacre
- Posts: 573
- Joined: Wed Nov 27, 2013 12:42 pm
Re: Battle Attack Formulas
Well if your using a bullet system I would base everything off of that. For example if you use one bullet then your chances of hitting them are slim as opposed to using 50. But I would set it up to where if they are using less bullets then the damage would be greater. For visual reference:
You probably wouldn't need a switch() but ehh oh well. I will keep it because it can open up possibilities for you
Code: Select all
$bullets = 4;
switch($bullets) {
case $bullets:
$damageX = $bullets * .5;
$accuracy = $damageX / .4;
break;
}
echo $damageX. " Damage and ".$accuracy. " Accuracy";