Code: Select all
$shooterquerystring = "SELECT * FROM `character` WHERE `charname` = '$charname' ";
$victemquerystring2 = "SELECT * FROM `character` WHERE `charname` = '$victem' ";
$victemquery2 = mysql_query($victemquerystring2, $mysql);
$shooterquery = mysql_query($shooterquerystring, $mysql);
$shooterget = mysql_fetch_assoc($shooterquery);
$victemget = mysql_fetch_assoc($victemquery2);
#set stats for shooter, and victem
$cattack = $shooterget['attack'];
$cdefense = $shooterget['defense'];
$cstealth = $shooterget['stealth'];
$chealth = $shooterget['health'];
$conhand = $shooterget['onhand'];
$calive = $shooterget['alive'];
$vattack = $victemget['attack'];
$vdefense = $victemget['defense'];
$vstealth = $victemget['stealth'];
$vhealth = $victemget['health'];
$vonhand = $victemget['onhand'];
$valive = $victemget['alive'];
# victem defense minus character attack ='s hitchance.
$hitchance = $vdefense - $cattack;
if( $hitchance < 26 ){
#depending on modulus decide how much damage was done
if($hitchance < 27 && $hitchance > 22){
$victemdamage = rand(1,15);
}
if($hitchance < 23 && $hitchance > 18){
$victemdamage = rand(5,25);
}
if($hitchance < 19 && $hitchance > 15){
$victemdamage = rand(15,35);
}
if($hitchance < 15 && $hitchance > 10){
$victemdamage = rand(30,50);
}
if($hitchance < 10 && $hitchance > 6 ){
$victemdamage = rand(45,60);
}
if($hitchance < 6 && $hitchance > 1){
$victemdamage = rand(50,75);
}
if($hitchance == 1 or $hitchance < 1){
$victemdamage = rand(75,120);
}
# subtract damage from victem health depending on amount of damage taken from victems health pick wound type
$victemwound = $vhealth - $victemdamage;
if( $victemwound > 55 && $victemwound < $vhealth ){
$wound = "Superficial";
}
if( $victemwound > 45 && $victemwound < 55 ){
$wound = "Significant";
}
if( $victemwound > 35 && $victemwound < 45 ){
$wound = "Major";
}
if( $victemwound > 25 && $victemwound < 35 ){
$wound = "Severe";
}
if( $victemwound > 1 && $victemwound < 25 ){
$wound = "Near Fatal";
}
if( $victemwound < 1 ){
$wound = "Fatal";
}
$message = "Your shots find their target " . $victem . " Has suffered a " . $wound . " wound.";
####################################################################################
######################## Find out if there will be whackback. #######################################
####################################################################################
$hitchance2 = $cattack - $vdefense;
if( $hitchance2 < 26 ){
#depending on modulus decide how much damage was done
if($hitchance2 < 27 && $hitchance2 > 22){
$shooterdamage = rand(1,15);
}
if($hitchance2 < 23 && $hitchance2 > 18){
$shooterdamage = rand(5,25);
}
if($hitchance2 < 19 && $hitchance2 > 15){
$shooterdamage = rand(15,35);
}
if($hitchance2 < 15 && $hitchance2 > 10){
$shooterdamage = rand(30,50);
}
if($hitchance2 < 10 && $hitchance2 > 6 ){
$shooterdamage = rand(45,60);
}
if($hitchance2 < 6 && $hitchance2 > 1){
$shooterdamage = rand(50,75);
}
if($hitchance2 == 1 or $hitchance2 < 1){
$shooterdamage = rand(75,120);
}
# subtract damage
$shooterwound = $chealth - $shooterdamage;
if( $shooterwound > 55 && $shooterwound < $chealth ){
$wound2 = "Superficial";
}
if( $shooterwound > 45 && $shooterwound < 55 ){
$wound2 = "Significant";
}
if( $shooterwound > 35 && $shooterwound < 45 ){
$wound2 = "Major";
}
if( $shooterwound > 25 && $shooterwound < 35 ){
$wound2 = "Severe";
}
if( $shooterwound > 1 && $shooterwound < 25 ){
$wound2 = "Near Fatal";
}
if( $shooterwound < 1 ){
$wound2 = "Fatal";
}
$message = "Your shots find their target " . $victem . " Has suffered a " . $wound . " wound, but " . $victem . " " . "does not
miss either, you have suffered a " . $wound2 . " " . "wound.";
####################################################################################
############################ IF CHECK POCKETS ISSET THEN ADD VICTEMS ONHAND TO SHOOTERS
#############################################ON HAND#################################
####################################################################################
if(isset($_POST['loot'] ) ){
$conhand = $conhand + $vonhand;
$message = $message . "<br/>" . "Your victems pockets yielded " . "$" . number_format($vonhand);
$vonhand = 0;
}
##############################################################################################
#############################Whack back###########################################################
##############################################################################################
# find out is no hit from attacker, and only whackback
# victem defense minus character attack ='s hitchance.
$hitchance = $cattack - $vdefense;
if( $hitchance < 26 ){
#depending on modulus decide how much damage was done
if($hitchance < 27 && $hitchance > 22){
$victemdamage = rand(1,15);
}
if($hitchance < 23 && $hitchance > 18){
$victemdamage = rand(5,25);
}
if($hitchance < 19 && $hitchance > 15){
$victemdamage = rand(15,35);
}
if($hitchance < 15 && $hitchance > 10){
$victemdamage = rand(30,50);
}
if($hitchance < 10 && $hitchance > 6 ){
$victemdamage = rand(45,60);
}
if($hitchance < 6 && $hitchance > 1){
$victemdamage = rand(50,75);
}
if($hitchance == 1 or $hitchance < 1){
$victemdamage = rand(75,120);
}
# subtract damage from victem health depending on amount of damage taken from victems health pick wound type
$victemwound = $vhealth - $victemdamage;
if( $victemwound > 55 && $victemwound < $vhealth ){
$wound = "Superficial";
}
if( $victemwound > 45 && $victemwound < 55 ){
$wound = "Significant";
}
if( $victemwound > 35 && $victemwound < 45 ){
$wound = "Major";
}
if( $victemwound > 25 && $victemwound < 35 ){
$wound = "Severe";
}
if( $victemwound > 1 && $victemwound < 25 ){
$wound = "Near Fatal";
}
if( $victemwound < 1 ){
$wound = "Fatal";
}
$message = "Your shots fail to find their target, but " . "$victem" . " " . "does not miss, you have suffered a " . $wound . " " . "wound.";
if($wound == "Fatal"){
$valive = 0;
}
if($wound2 == "Fatal"){
$calive = 0;
}
$chealth = $chealth - $victemwound;
}
I just want to see if anyone else has any ideas on how to go about this without so many if statements, The completed code is virtually unmanagable due to so many nested ifs.