// ARENA for Sword Fight // By: Farhan Brillan (Rhuzzer Dev) // © 2018 (feat. KotaGames) // Include system game include './inc/mysql.php'; include './inc/functions.php'; include './inc/user.php'; // Redirect for Empty Session if(!$user) exit(header('location: /')); // Change the number of Refresh if(!$_GET['full_mana'] && !$_SESSION['refresh'] OR !$_GET['attack'] && !$_SESSION['refresh']) $_SESSION['refresh'] = rand(10000000,99999999); // Claim Data Form Get $getr = $_GET['r']; // Fetch Array From Arena Table $arena = mysql_query('SELECT * FROM `arena` WHERE `user` = "'.$user['id'].'"'); $arena = mysql_fetch_array($arena); // Selecting Opponent With Criteria if(!$arena['opponent']) { // Fetch User Opponent Data $opponent = mysql_query('SELECT * FROM `users` WHERE `atk` + `vit` + `agi` + `def` >= "'.(($user['atk'] + $user['vit'] + $user['agi'] + $user['def']) / 2).'" AND `atk` + `vit` + `agi` + `def` <= "'.($user['atk'] + $user['vit'] + $user['agi'] + $user['def']).'" AND `id` != "'.$user['id'].'" ORDER BY RAND() LIMIT 2'); $opponent = mysql_fetch_array($opponent); // If not available if(!$opponent){ $opponent = mysql_query('SELECT * FROM `users` WHERE `atk` + `vit` + `agi` + `def` >= "'.(($user['atk'] + $user['vit'] + $user['agi'] + $user['def']) / 2).'" AND `id` != "'.$user['id'].'" OR `atk` + `vit` + `agi` + `def` <= "'.($user['atk'] + $user['vit'] + $user['agi'] + $user['def']).'" AND `id` != "'.$user['id'].'" ORDER BY RAND() LIMIT 1'); $opponent = mysql_fetch_array($opponent); } // Updating ID Opponent mysql_query('UPDATE `arena` SET `opponent` = "'.$opponent['id'].'" WHERE `user` = "'.$user['id'].'"'); $arena = mysql_fetch_array(mysql_query('SELECT * FROM `arena` WHERE `user` = "'.$user['id'].'"')); } else { // Fetch User Opponent Data $opponent = mysql_query('SELECT * FROM `users` WHERE `id` = "'.$arena['opponent'].'"'); $opponent = mysql_fetch_array($opponent); } // Full Energy Attack! if($_GET['full_mana'] == true && $getr == $_SESSION['refresh']){ // Variable Special $FullATK = '1'; // Heal Function if($_GET['heal'] == 'true'){ if($user['gold'] < 15){ // Notice & Direct For Poor User $_SESSION['gold'] = (15-$user['gold']); exit(header('location: /arena/')); } }else{ // Redirect For Poor User if($user['mp'] < 50 OR $user['gold'] < 1) {$_SESSION['gold']=(1-$user['gold']);header('location: /arena/');exit;}} // Heal Function if($_GET['heal'] == 'true'){ // Update Data User mysql_query('UPDATE `users` SET `hp` = '.($user['vit'] * 2).', `mp` = '.$user['mana'].', `gold` = `gold` - 14 WHERE `id` = "'.$user['id'].'"'); $user = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "'.$_secure001.'" AND `password` = "'.$_secure002.'"')); } // Save Data For 1 Time $userhp = $user['hp']; $usermp = $user['mp']; $fights = round($user['mp']/50); $win = 0; $los = 0; $_exp = 0; $_s = 0; // Repeat System For Full Attack (SAVAGE!) for($fight = 1; $fight <= $fights; $fight++) { // Selecting Opponent With Criteria $opponent = mysql_query('SELECT * FROM `users` WHERE `atk` + `vit` + `agi` + `def` >= "'.(($user['atk'] + $user['vit'] + $user['agi'] + $user['def']) / 2).'" AND `atk` + `vit` + `agi` + `def` <= "'.($user['atk'] + $user['vit'] + $user['agi'] + $user['def']).'" AND `id` != "'.$user['id'].'" ORDER BY RAND() LIMIT 1'); $opponent = mysql_fetch_array($opponent); // If opponent not found if(!$opponent) { $opponent = mysql_query('SELECT * FROM `users` WHERE `atk` + `vit` + `agi` + `def` >= "'.(($user['atk'] + $user['vit'] + $user['agi'] + $user['def']) / 2).'" AND `id` != "'.$user['id'].'" OR `atk` + `vit` + `agi` + `def` <= "'.($user['atk'] + $user['vit'] + $user['agi'] + $user['def']).'" AND `id` != "'.$user['id'].'" ORDER BY RAND() LIMIT 1'); $opponent = mysql_fetch_array($opponent); } // Save Data for 1x Time $dmg = 0; $opponent_dmg = 0; $a_1 = false; $a_2 = false; $a_3 = false; $a_4 = false; $a_5 = false; // Activate if Lucky if($user['ability_1'] > 0) if(mt_rand(0, 100) <= $_ability['a_1_chanse'][$user['ability_1']]) $a_1 = true; if($user['ability_2'] > 0) if(mt_rand(0, 100) <= $_ability['a_2_chanse'][$user['ability_2']]) $a_2 = true; if($user['ability_3'] > 0) if(mt_rand(0, 100) <= $_ability['a_3_chanse'][$user['ability_3']]) $a_3 = true; if($user['ability_4'] > 0) if(mt_rand(0, 100) <= $_ability['a_4_chanse'][$user['ability_4']]) $a_4 = true; if($user['ability_5'] > 0) if(mt_rand(0, 100) <= $_ability['a_5_chanse'][$user['ability_5']]) $a_5 = true; // Add Damage $dmg +=round(rand(($user['atk']/6),($user['atk']/4))); // Activated Ability [1] [DMG++] if($a_1 == true) $dmg += round(($dmg / 100) * $_ability['a_1_bonus'][$user['ability_1']]); // Reduce DMG with DEF $dmg -= round(rand(($opponent['def']/12),($opponent['def']/7))); // If DMG lower from 0 if($dmg < 0) $dmg = 0; // Activated Ability [3] [CRIT++] if($a_3 == true) $crit = ( (rand(1,2) * ($user['agi'] / 100) + $_ability['a_3_crit_chanse'][$user['ability_3']] ) - (rand(1,2) * ($opponent['agi'] / 100))); // Unactivated Ability [3] [NORMAL CRIT] else $crit = ( (rand(1,2) * ($user['agi'] / 100) ) - (rand(1,2) * ($opponent['agi'] / 100))); // If Crit Activated if(mt_rand(0, 100) <= $crit) { // DMG2x $dmg *= 2; // Bonus Crit if($a_3 == true) $dmg += round(($dmg / 100) * $_ability['a_3_bonus'][$user['ability_3']]); } // Dodge system $dodge = ( (rand(1,2) * ($opponent['agi'] / 100) ) - (rand(1,2) * ($user['agi'] / 100))); // Dodge activated if(mt_rand(0, 100) <= $dodge) $dmg = 0; ### OPPONENT DMG ### // Add Opponent Damage $opponent_dmg +=round(rand(($opponent['atk']/6),($opponent['atk']/4))); // Activated Ability [2] [DEF++] if($a_2 == true) $opponent_dmg -= round(($opponent_dmg / 100) * $_ability['a_2_bonus'][$user['ability_2']]); // Reduce DMG with DEF $opponent_dmg -= round(rand(($user['def']/12),($user['def']/7))); // If DMG lower from 0 if($opponent_dmg < 0) $opponent_dmg = 0; // Critical $opponent_crit = ( (rand(1,2) * ($opponent['agi'] / 100) ) - (rand(1,2) * ($user['agi'] / 100))); // Chance to critical damage if(mt_rand(0, 100) <= $opponent_crit) { // Crit DMG = x2 DMG $opponent_dmg *= 2; // Activated Ability [4] [CRIT+DMG++] if($a_4 == true) $opponent_dmg -= round(($opponent_dmg / 100) * $_ability['a_4_bonus'][$user['ability_4']]); } // Chance to Dodge $opponent_dodge = ( (rand(1,2) * ($user['agi'] / 100) ) - (rand(1,2) * ($opponent['agi'] / 100))); // Dodge System if(mt_rand(0, 100) <= $opponent_dodge) $opponent_dmg = 0; // Activated Ability [5] [HP++] if($ability_5 == true) { // Result Lifesteal $Result_A5 = round(($opponent['vit']/ 100)*$_ability['a_5_bonus'][$user['ability_5']]); // Parameter Updated HP $UpdatedHP = ($user['hp']+$Result_A5); // Verification Full++ HP if(($user['vit']*2) < $user['hp']){ // Update HP (Not Handphone -_-) mysql_query('UPDATE `users` SET `hp` = "'.$UpdatedHP.'" WHERE `id` = "'.$user['id'].'"'); } mysql_query('UPDATE `users` SET `hp` = `hp`-"'.$Result_A5.'" WHERE `id` = "'.$opponent['id'].'"'); } // Win Reward if($dmg > $opponent_dmg) { // Reward Variables $_s += rand(7,15) * ($opponent['level']+rand(1,10)); $_exp += rand(4,10) * ($opponent['level']+rand(1,10)); $win += 1; // Add Quest Progress quest('4',$user['id'],1); } // Lose Reward else { // Reward Variables $_s += rand(1,5) * $opponent['level']; $_exp += rand(1,3) * $opponent['level']; $los += 1; } } // Bonus EXP [Guild] if($guild_memb && $guild_memb['bonus'] > 0) $_exp += round($_exp/100) * $guild_memb['bonus']; // Bonus EXP [PREMIUM] if($premium) $_exp+= round($_exp/ 100) * 2; // Update User mysql_query('UPDATE `users` SET `mp` = `mp` - '.($fights * 50).', `silver` = `silver` + '.$_s.', `gold` = `gold` - 1 WHERE `id` = "'.$user['id'].'"'); // Add Exp Func AddEXP($_exp); /* Disabled $city = mysql_fetch_array(mysql_query('SELECT * FROM `city` WHERE `id` = "2"')); $ben_nganu = ($city['level']/20); $mp_nyah = round(1+$ben_nganu,3); mysql_query('UPDATE `city` SET `silver` = `silver` + "'.($_s*$mp_nyah).'" WHERE `id` = "2"'); */ $user = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "'.$_secure001.'" AND `password` = "'.$_secure002.'"')); } ######################################################################## ######################################################################## ######################################################################## ######################################################################## if($_GET['attack'] == true && $_GET['r'] == $_SESSION['refresh']){ // Define variables $issetatk = 1; $userhp = $user['hp']; $usermp = $user['mp']; // Verification Mana and Healt Point if($user['mp'] > 49 && $user['hp'] > ( ( ($user['vit'] * 2) / 100 ) * 10 )) { // Define variables $dmg = 0; $opponent_dmg = 0; $ability_1_1 = false; $ability_2_2 = false; $ability_3_3 = false; $ability_4_4 = false; $ability_5_5 = false; // Activate if Lucky if($user['ability_1'] > 0) if(mt_rand(0, 100) <= $_ability['a_1_chanse'][$user['ability_1']]) $a_1 = true; if($user['ability_2'] > 0) if(mt_rand(0, 100) <= $_ability['a_2_chanse'][$user['ability_2']]) $a_2 = true; if($user['ability_3'] > 0) if(mt_rand(0, 100) <= $_ability['a_3_chanse'][$user['ability_3']]) $a_3 = true; if($user['ability_4'] > 0) if(mt_rand(0, 100) <= $_ability['a_4_chanse'][$user['ability_4']]) $a_4 = true; if($user['ability_5'] > 0) if(mt_rand(0, 100) <= $_ability['a_5_chanse'][$user['ability_5']]) $a_5 = true; // Add Damage $dmg +=round(rand(($user['atk']/6),($user['atk']/4))); // Activated Ability [1] [DMG++] if($a_1 == true) $dmg += round(($dmg / 100) * $_ability['a_1_bonus'][$user['ability_1']]); // Reduce DMG with DEF $dmg -= round(rand(($opponent['def']/12),($opponent['def']/7))); // If DMG lower from 0 if($dmg < 0) $dmg = 0; // Activated Ability [3] [CRIT++] if($a_3 == true) $crit = ( (rand(1,2) * ($user['agi'] / 100) + $_ability['a_3_crit_chanse'][$user['ability_3']] ) - (rand(1,2) * ($opponent['agi'] / 100))); // Unactivated Ability [3] [NORMAL CRIT] else $crit = ( (rand(1,2) * ($user['agi'] / 100) ) - (rand(1,2) * ($opponent['agi'] / 100))); // If Crit Activated if(mt_rand(0, 100) <= $crit) { // DMG2x $dmg *= 2; // Bonus Crit if($a_3 == true) $dmg += round(($dmg / 100) * $_ability['a_3_bonus'][$user['ability_3']]); } // Dodge system $dodge = ( (rand(1,2) * ($opponent['agi'] / 100) ) - (rand(1,2) * ($user['agi'] / 100))); // Dodge activated if(mt_rand(0, 100) <= $dodge) $dmg = 0; ### OPPONENT DMG ### // Add Opponent Damage $opponent_dmg +=round(rand(($opponent['atk']/6),($opponent['atk']/4))); // Activated Ability [2] [DEF++] if($a_2 == true) $opponent_dmg -= round(($opponent_dmg / 100) * $_ability['a_2_bonus'][$user['ability_2']]); // Reduce DMG with DEF $opponent_dmg -= round(rand(($user['def']/12),($user['def']/7))); // If DMG lower from 0 if($opponent_dmg < 0) $opponent_dmg = 0; // Critical $opponent_crit = ( (rand(1,2) * ($opponent['agi'] / 100) ) - (rand(1,2) * ($user['agi'] / 100))); // Chance to critical damage if(mt_rand(0, 100) <= $opponent_crit) { // Crit DMG = x2 DMG $opponent_dmg *= 2; // Activated Ability [4] [CRIT+DMG++] if($a_4 == true) $opponent_dmg -= round(($opponent_dmg / 100) * $_ability['a_4_bonus'][$user['ability_4']]); } // Chance to Dodge $opponent_dodge = ( (rand(1,2) * ($user['agi'] / 100) ) - (rand(1,2) * ($opponent['agi'] / 100))); // Dodge System if(mt_rand(0, 100) <= $opponent_dodge) $opponent_dmg = 0; // Activated Ability [5] [HP++] if($ability_5 == true) { // Result Lifesteal $Result_A5 = round(($opponent['vit']/ 100)*$_ability['a_5_bonus'][$user['ability_5']]); // Parameter Updated HP $UpdatedHP = ($user['hp']+$Result_A5); // Verification Full++ HP if(($user['vit']*2) < $user['hp']){ // Update HP (Not Handphone -_-) mysql_query('UPDATE `users` SET `hp` = "'.$UpdatedHP.'" WHERE `id` = "'.$user['id'].'"'); } mysql_query('UPDATE `users` SET `hp` = `hp`-"'.$Result_A5.'" WHERE `id` = "'.$opponent['id'].'"'); } // Parameter for Minus HP if($dmg > $opponent_dmg) $_hp = round($opponent_dmg / 4); else /* LU THOLOL ASW */ $_hp = round($opponent_dmg / 2); // For Verif Cause Minus HP if($_hp > $user['hp']) $_hp = $user['hp']; // Update Data mysql_query('UPDATE `users` SET `hp` = `hp` - '.$_hp.', `mp` = `mp` - 50 WHERE `id` = "'.$user['id'].'"') or die(mysql_error()); $user = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "'.$_secure001.'" AND `password` = "'.$_secure002.'"')); // Reward if($dmg > $opponent_dmg) { $_s = rand(1,100) + (rand(4,10) * $opponent['level']); $_exp = rand(3,10) * $opponent['level']; #if($a_f['on/off'] > time() && $ikut == '1') $point = rand(1,10); quest('4',$user['id'],1); } else { $_s = rand(1,3) + (rand(2,3) * $opponent['level']); $_exp = rand(2,5) * $opponent['level']; #if($a_f['on/off'] > time() && $ikut == '1') $point = rand(1,5); } // Bonus EXP [Guild] if($guild_memb && $guild_memb['bonus'] > 0) $_exp += round($_exp/100) * $guild_memb['bonus']; // Bonus EXP [PREMIUM] if($premium) $_exp+= round($_exp/ 100) * 2; if($_s < 1) $_s = 1; if($_exp < 1) $_exp = 1; // Update User mysql_query('UPDATE `users` SET `mp` = `mp` - '.($fights * 50).', `silver` = `silver` + '.$_s.' WHERE `id` = "'.$user['id'].'"'); // Add Exp Func AddEXP($_exp); } } $header = 'Arena'; $title = 'Arena'; $_SESSION['place'] = 'Arena'; include './inc/head.php'; // Random refresh code if($getr == $_SESSION['refresh']) $_SESSION['refresh'] = rand(10000000,99999999); if(mysql_result(mysql_query('SELECT * FROM `arena` WHERE `user` = "'.$user['id'].'"'),0) == 0) { mysql_query('INSERT INTO `arena` (`user`) VALUES ("'.$user['id'].'")'); } if($user['league_fights'] > 0){ $PlusForLeague = " (+)"; } if (!$FullATK) { $league = array( '', 'newbie', 'pengalaman', 'pro', 'master', 'titan', 'legendaris'); echo "
"; echo ""; } if(!$arena['opponent']) { $opponent = mysql_query('SELECT * FROM `users` WHERE `atk` + `vit` + `agi` + `def` >= "'.(($user['atk'] + $user['vit'] + $user['agi'] + $user['def']) / 2).'" AND `atk` + `vit` + `agi` + `def` <= "'.($user['atk'] + $user['vit'] + $user['agi'] + $user['def']).'" AND `id` != "'.$user['id'].'" ORDER BY RAND() LIMIT 2'); $opponent = mysql_fetch_array($opponent); if(!$opponent) { $opponent = mysql_query('SELECT * FROM `users` WHERE `atk` + `vit` + `agi` + `def` >= "'.(($user['atk'] + $user['vit'] + $user['agi'] + $user['def']) / 2).'" AND `id` != "'.$user['id'].'" OR `atk` + `vit` + `agi` + `def` <= "'.($user['atk'] + $user['vit'] + $user['agi'] + $user['def']).'" AND `id` != "'.$user['id'].'" ORDER BY RAND() LIMIT 1'); $opponent = mysql_fetch_array($opponent); } mysql_query('UPDATE `arena` SET `opponent` = "'.$opponent['id'].'" WHERE `user` = "'.$user['id'].'"'); $arena = mysql_query('SELECT * FROM `arena` WHERE `user` = "'.$user['id'].'"'); $arena = mysql_fetch_array($arena); } else { $wewewe = mysql_result(mysql_query('SELECT COUNT(*) FROM `users`'),0); $opponent = mysql_query('SELECT * FROM `users` WHERE `id` = "'.$arena['opponent'].'"'); $opponent = mysql_fetch_array($opponent); $opponent2 = mysql_query('SELECT * FROM `users` WHERE `id` = "'.$arena['opponent2'].'"'); $opponent2 = mysql_fetch_array($opponent2); } if($_GET['full_mana'] == true && $FullATK == '1') { // Special Varibles $FullATK = '0'; $TotalFights = $win+$los; echo "
';
if($a_2 == true) echo '
';
if($a_3 == true) echo '
';
if($a_4 == true) echo '
';
if($a_5 == true) echo '
';
echo "";
}
echo "Piala:
tas!
";
echo "";
echo "Saya dapat mengembalikan 100% kesehatan dan energi untuk kamu";
echo "";
echo "Kembalikan dan lakukan pertarungan
';
if($a_2 == true) echo '
';
if($a_3 == true) echo '
';
if($a_4 == true) echo '
';
if($a_5 == true) echo '
';
echo "";
}
echo "Piala:
";
echo "Tincture Potion