някой може ли да ми каже къде е грешката
ето кода
ето кода
Код:
<?php
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ *\
|| + Inferno Technologies Software
|| +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|| + Product: vB RPG Inferno V2.4 By Zero Tolerance
|| + Null: DGT
|| +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|| + Copyright 2004 - 2005 Inferno Technologies
|| + All Rights Reserved
\* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(0);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'inferno');
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();
// get special data templates from the datastore
$specialtemplates = array();
// pre-cache templates used by specific actions
$actiontemplates = array(
'Profile' => array(
'inferno_profile',
),
'Shop' => array(
'inferno_inv_end',
'inferno_inv_row',
'inferno_inv_top',
'inferno_shop_end',
'inferno_shop_row',
'inferno_shop_top',
'inferno_cat_end',
'inferno_cat_row',
'inferno_cat_top',
),
'Bank' => array(
'inferno_bank',
),
'scan' => array(
'inferno_scan',
),
'Healing' => array(
'inferno_heal_inv_end',
'inferno_heal_inv_row',
'inferno_heal_inv_top',
'inferno_heal_main_end',
'inferno_heal_main_row',
'inferno_heal_main_top',
),
'Donate' => array(
'inferno_donate_item',
'inferno_donate_money',
),
'Equip' => array(
'inferno_equip_cat_end',
'inferno_equip_cat_row',
'inferno_equip_cat_top',
'inferno_equip_cur_end',
'inferno_equip_cur_row',
'inferno_equip_cur_top',
),
'SelectEquip' => array(
'inferno_equip_do_end',
'inferno_equip_do_row',
'inferno_equip_do_top',
),
'Summon' => array(
'inferno_summon_end',
'inferno_summon_row',
'inferno_summon_top',
'inferno_summon_your_end',
'inferno_summon_your_row',
'inferno_summon_your_top',
),
'ScanSummon' => array(
'inferno_summon_your_scan',
),
'Battle' => array(
'inferno_battle_main_end',
'inferno_battle_main_row',
'inferno_battle_main_top',
),
'CreateBattle' => array(
'inferno_battle_create_member',
),
'BattleGround' => array(
'inferno_preload_image',
'inferno_battle_log_end',
'inferno_battle_log_row',
'inferno_battle_log_top',
'inferno_battle_your_battle',
'inferno_battle_p1_cell',
'inferno_battle_p1_bot_cell',
'inferno_battle_p1_summon_cell',
'inferno_battle_p2_cell',
'inferno_battle_p2_bot_cell',
'inferno_battle_p2_summon_cell',
'inferno_battle_image_sprite',
),
'ViewBattle' => array(
'inferno_battle_log_end',
'inferno_battle_log_row',
'inferno_battle_log_top',
'inferno_battle_view_battle',
'inferno_battle_p1_view_cell',
'inferno_battle_p1_view_summon_cell',
'inferno_battle_p2_view_cell',
'inferno_battle_p2_bot_view_cell',
'inferno_battle_p2_view_summon_cell',
'inferno_battle_image_sprite',
),
'ScanMember' => array(
'inferno_scanm_end',
'inferno_scanm_equiptop',
'inferno_scanm_healtop',
'inferno_scanm_heal_row',
'inferno_scanm_invrow',
'inferno_scanm_mini1',
'inferno_scanm_miniprof',
'inferno_scanm_statsend',
'inferno_scanm_top',
'inferno_scanm_spellsrow',
'inferno_scanm_spellstop',
),
'BattleWon' => array(
'inferno_battle_won',
),
'Synthesis' => array(
'inferno_synthesis_top',
'inferno_synthesis_row',
'inferno_synthesis_end',
'inferno_synthesis_cur_top',
'inferno_synthesis_cur_row',
'inferno_synthesis_cur_end',
),
'BuySynthesis' => array(
'inferno_synthesis_buy_top',
'inferno_synthesis_buy_row',
'inferno_synthesis_buy_end',
),
'Clan' => array(
'inferno_clan_top',
'inferno_clan_row',
'inferno_clan_end',
'inferno_clan_menu',
),
'ViewClan' => array(
'inferno_clan_view_top',
'inferno_clan_view_row',
'inferno_clan_view_end',
'inferno_clan_menu',
),
'JoinClan' => array(
'inferno_clan_invite',
'inferno_clan_menu',
),
'ManageClan' => array(
'inferno_clan_manage',
'inferno_clan_menu',
),
'ManageClanMembers' => array(
'inferno_clan_manage_members_top',
'inferno_clan_manage_members_row',
'inferno_clan_manage_members_end',
'inferno_clan_menu',
),
'InviteMember' => array(
'inferno_clan_invite_member',
'inferno_clan_menu',
),
'BuyClan' => array(
'inferno_clan_buy',
'inferno_clan_menu',
),
'Jobs' => array(
'inferno_job_top',
'inferno_job_row',
'inferno_job_end',
'inferno_job_yours_top',
'inferno_job_yours_row',
'inferno_job_yours_end',
),
'Lottery' => array(
'inferno_lottery_top',
'inferno_lottery_row',
'inferno_lottery_end',
'inferno_lottery_buyticket',
'inferno_lottery_ticket',
),
'Help' => array(
'inferno_help_top',
'inferno_help_row',
'inferno_help_end',
'inferno_help_search',
),
'ViewHelp' => array(
'inferno_help_view',
'inferno_help_search',
),
'DoHelpSearch' => array(
'inferno_help_top_search',
'inferno_help_row_h',
'inferno_help_end',
'inferno_help_search',
),
'Store' => array(
'inferno_store_top',
'inferno_store_row',
'inferno_store_end',
),
'Auction' => array(
'inferno_auction_top',
'inferno_auction_row',
'inferno_auction_end',
'inferno_auction_menu',
),
'StartAuction' => array(
'inferno_auction_start',
'inferno_auction_menu',
),
'EditAuction' => array(
'inferno_auction_edit',
'inferno_auction_menu',
),
'CancelAuction' => array(
'inferno_auction_cancel',
'inferno_auction_menu',
),
'ViewAuction' => array(
'inferno_auction_view_top',
'inferno_auction_view_row',
'inferno_auction_view_end',
'inferno_auction_menu',
),
'AddBid' => array(
'inferno_auction_addbid',
'inferno_auction_menu',
),
'EditBid' => array(
'inferno_auction_editbid',
'inferno_auction_menu',
),
'CloseAuction' => array(
'inferno_auction_close_top',
'inferno_auction_close_row',
'inferno_auction_close_end',
'inferno_auction_menu',
),
'Statistics' => array(
'inferno_statistics_clan_top',
'inferno_statistics_clan_row',
'inferno_statistics_clan_end',
'inferno_statistics_items_top',
'inferno_statistics_items_row',
'inferno_statistics_items_end',
'inferno_statistics_rpgchar3_top',
'inferno_statistics_rpgchar3_row',
'inferno_statistics_rpgchar3_end',
'inferno_statistics_rpgchar2_top',
'inferno_statistics_rpgchar2_row',
'inferno_statistics_rpgchar2_end',
'inferno_statistics_rpgchar_top',
'inferno_statistics_rpgchar_row',
'inferno_statistics_rpgchar_end',
'inferno_stats_top',
'inferno_stats_row',
'inferno_stats_end',
),
'MembersList' => array(
'inferno_memberlist_topletter',
'inferno_memberlist_top',
'inferno_memberlist_row',
'inferno_memberlist_end',
),
'Spells' => array(
'inferno_spells_top',
'inferno_spells_row',
'inferno_spells_end',
'inferno_spells_inv_top',
'inferno_spells_inv_row',
'inferno_spells_inv_end',
),
'TripleTriadShop' => array(
'inferno_triad_card_inv_top',
'inferno_triad_card_inv_row',
'inferno_triad_card_inv_end',
'inferno_triad_menu',
),
'BuyCard' => array(
'inferno_triad_card_buycard_top',
'inferno_triad_card_buycard_row',
'inferno_triad_card_buycard_end',
'inferno_triad_menu',
),
'BuyCardPack' => array(
'inferno_triad_card_buycard_buy',
'inferno_triad_menu',
),
'DoBuyCardPack' => array(
'inferno_triad_card_buycard_bought',
'inferno_triad_menu',
),
'ScanCard' => array(
'inferno_triad_card_scan',
'inferno_triad_menu',
),
'ViewCards' => array(
'inferno_triad_card_view_top',
'inferno_triad_card_newrow',
'inferno_triad_card_cell',
'inferno_triad_card_view_end',
'inferno_triad_menu',
),
'ViewPlayerDeck' => array(
'inferno_triad_viewplayer_top',
'inferno_triad_menu',
),
'TriadTutorial' => array(
'inferno_triad_tutorial',
'inferno_triad_menu',
),
'TriadBattle' => array(
'inferno_triad_battle_top',
'inferno_triad_battle_member_row',
'inferno_triad_battle_bot_row',
'inferno_triad_battle_end',
'inferno_triad_menu',
),
'CreateTriadBotBattle' => array(
'inferno_triad_choosecard_cardcell',
'inferno_triad_battle_create_bot',
'inferno_triad_menu',
),
'CreateTriadMemberBattle' => array(
'inferno_triad_choosecard_cardcell',
'inferno_triad_battle_create_member',
'inferno_triad_menu',
),
'VerifyChooseCards' => array(
'inferno_triad_choosecard_cardcell',
'inferno_triad_battle_accept_member',
),
'TriadCurrentBotBattle' => array(
'inferno_triad_battleground_bot',
),
'TriadCurrentBattle' => array(
'inferno_triad_battleground_member',
),
'TriadWon' => array(
'inferno_triad_battlewon_top',
'inferno_triad_battlewon_row',
'inferno_triad_battlewon_end',
),
'ViewTriadBattle' => array(
'inferno_triad_battleground_member',
),
'ViewTriadBotBattle' => array(
'inferno_triad_battleground_bot',
),
'SkillPoints' => array(
'inferno_skillpoints_conversion',
),
'RPGWorld' => array(
'inferno_rpgworld_map',
'inferno_rpgworld_menu',
),
'RPGArena' => array(
'inferno_rpgarena_end',
'inferno_rpgarena_row',
'inferno_rpgarena_top',
'inferno_rpgworld_menu',
),
'JoinMap' => array(
'inferno_rpgarena_joinmap',
'inferno_rpgworld_menu',
),
'ViewMap' => array(
'inferno_rpgarena_viewmap',
'inferno_rpgworld_menu',
),
'DonateToClan' => array(
'inferno_clan_donate_members',
'inferno_clan_menu',
),
'TriadTrade' => array(
'inferno_triadtrade_end',
'inferno_triadtrade_row',
'inferno_triadtrade_top',
'inferno_triad_menu',
),
'StartTriadTrade' => array(
'inferno_triadtrade_create',
'inferno_triad_menu',
),
'ViewTriadTrade' => array(
'inferno_triadtrade_view_end',
'inferno_triadtrade_view_row',
'inferno_triadtrade_view_top',
'inferno_triad_menu',
),
'AddOffer' => array(
'inferno_triadtrade_addoffer',
'inferno_triad_menu',
),
'MemberSearch' => array(
'inferno_membersearch',
),
'DoMemberSearch' => array(
'inferno_memberlist_top',
'inferno_memberlist_row',
'inferno_memberlist_end',
),
'Hospital' => array(
'inferno_hospital',
),
'AcceptTradeOffer' => array(
'inferno_triadtrade_accept_top',
'inferno_triadtrade_accept_row',
'inferno_triadtrade_accept_end',
'inferno_triad_menu',
),
'RPGWorld-Game' => array(
'inferno_rpgworld_game',
'inferno_rpgworld_game_load',
'inferno_rpgworld_game_load_none',
'inferno_rpgworld_menu',
),
'RPGWorld-Game' => array(
'inferno_rpgworld_newgame',
'inferno_rpgworld_menu',
),
);
// pre-cache templates used by all actions O_O
$globaltemplates = array(
'inferno',
'inferno_header',
'inferno_error',
'inferno_redirect',
'inferno_x_main',
'inferno_users_online',
'inferno_profile',
'inferno_inv_end',
'inferno_inv_row',
'inferno_inv_top',
'inferno_shop_end',
'inferno_shop_row',
'inferno_shop_top',
'inferno_cat_end',
'inferno_cat_row',
'inferno_cat_top',
'navbar',
'inferno_triad_menu',
'inferno_sec_offline',
'inferno_battle_cells_view_end',
'inferno_itemshop_params',
);
// insert shop templates for no action in url (stop useless queries)
// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
// Global Requirements & Functions
require_once('./global.php');
require_once(DIR . '/includes/functions_user.php');
require_once(DIR . '/includes/class_bbcode.php');
require_once(DIR . '/Inferno/system/engine.system.php');
require_once(DIR . '/includes/functions_legacy.php');
legacy_enable();
$System = new system_engine;
$DB=$db; // What? Its easier to write ^_^;
$DB_site = $DB; // incase i used it anywhere...
$rpg_body=""; // Template Var
// global query
$gmember=$DB->query("select * from inferno_user where rid='{$bbuserinfo['userid']}'");
$member=$DB->fetch_array($gmember);
$GLOBAL_EXP_Need = EXP_Needed_For_Level((intval($member['level'] + 1)));
$rpg_option=$DB->query_first("select * from inferno_options where id='1'");
function ConfigureLanguage(){
global $member;
if($member['gender']=="Male"){
$language = "his";
} else if($member['gender']=="Female"){
$language = "her";
} else {
$language = "their";
}
return $language;
}
function CheckStatLow(){
// Globalize a function to check stats are NOT negative
global $DB,$member;
$member_r=$DB->query_first("select * from inferno_user where gid='{$member['gid']}'");
$check_stats=array();
$check_stats[]="hp";
$check_stats[]="hpm";
$check_stats[]="mp";
$check_stats[]="mpm";
$check_stats[]="str";
$check_stats[]="def";
$check_stats[]="vitality";
$check_stats[]="evasion";
$do_query=0;
$build_query="";
foreach($check_stats as $check){
if($member_r[$check]<1){
$member_r[$check]=1;
$do_query++;
} else {
$member_r[$check] = $member_r[$check];
}
if($check=="evasion"){ // last stat check
$build_query.="{$check}='{$member_r[$check]}'"; // no comma
} else {
$build_query.="{$check}='{$member_r[$check]}',"; // comma
}
}
if($do_query>0){ // if the stats are not negative or below 1, then no need to execute a useless query
$DB->query("update inferno_user set {$build_query} where gid='{$member['gid']}'");
}
}
function RunError($message){
// Theres probably some globals below not in use, uhm, who cares?
global $bbuserinfo, $session, $stylevar, $_POST, $vbphrase,$navbits,$show,$header;
global $templatecache, $DB_site, $vboptions, $style,$headinclude,$footer;
global $tempusagecache, $templateassoc,$pmbox,$rpg_body;
if($message=="Sorry, this section has been turned offline. Please contact the administrator for more information" && can_moderate()){
eval('$rpg_body .= "' . fetch_template('inferno_sec_offline') . '";');
} else {
$rpg_body = "";
eval('$rpg_body .= "' . fetch_template('inferno_error') . '";');
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
// Inferno header template (global links)
eval('$rpgheader = "' . fetch_template('inferno_header') . '";');
eval('print_output("' . fetch_template('inferno') . '");');
exit;
}
}
function SendPM($message,$title,$to,$from = 0){
global $vbulletin, $DB;
$to = $DB->query_first("select username, userid from ".TABLE_PREFIX."user where userid='{$to}'");
$DataManager_PM =& datamanager_init('PM', $vbulletin, ERRTYPE_ARRAY);
$DataManager_PM->set('fromuserid', $to['userid']);
$DataManager_PM->set('fromusername', $to['username']);
$DataManager_PM->set('title', $title);
$DataManager_PM->set('message', $message);
$DataManager_PM->set_recipients($to['username'],$to['permissions']);
$DataManager_PM->set('dateline', TIMENOW);
$DataManager_PM->save();
}
// nasty stuff these sql database's
function ParseInput($val){
// Cancel Out Number's
if(is_int($val))
{
$val = intval($val);
return $val;
} else {
$val = htmlspecialchars_uni(trim(addslashes($val)));
return $val;
}
}
function ReturnTurn($turn){
if($turn=="P1"){$newturn="P2";}else{$newturn="P1";}
return $newturn;
}
function EXP_Needed_For_Level($Level){
$EXP_Per_Level = 500;
$EXP_Needed = ($EXP_Per_Level * $Level);
return $EXP_Needed;
}
function WinBattle($winner,$loser,$battle,$rage,$exp){
// Theres probably some globals below not in use, uhm, who cares?
global $bbuserinfo, $session, $stylevar, $_POST, $vbphrase,$navbits,$show,$header;
global $templatecache, $DB_site, $vboptions, $style,$headinclude,$footer;
global $tempusagecache, $templateassoc,$DB,$rpg_option;
// v2.1 --------------------------------
// Calculate EXP Reward
// v2.1 --------------------------------
// Pull Out Required Variables
$Winner_HP = $winner['hpm'];
$Winner_Level = $winner['level'];
$Damage_Taken = $winner['battle_damage'];
$Opponent_Level = $loser['level'];
$Summon_Play = 0;
// Summon?
if($Your_Summon = $DB->query_first("select * from inferno_summons_users where sowner='{$winner['gid']}'")){
$Summon_Play = 1;
$Damage_Taken = ($Damage_Taken + $Your_Summon['battle_damage']);
}
// Calculate EXP Needed To Level Up
$EXPNeededToLevel = EXP_Needed_For_Level((intval($Winner_Level + 1)));
// Set Default % Amount Of EXP You Will Gain
$EXP_Percent_Gain = 10;
// Calculate Level Difference - Make EXP Percent Gain Alterations (Up or Down)
$Level_Diff = $Opponent_Level - $Winner_Level;
$Reversal = 0;
if($Level_Diff < 1){
$Level_Diff = $Winner_Level - $Opponent_Level;
$Reversal = 1;
}
if(intval($Winner_Level - $Opponent_Level) == 0){
$Level_Diff = 1;
}
if($Reversal == 1){
$EXP_Percent_Gain = ($EXP_Percent_Gain - (1 * $Level_Diff));
if($EXP_Percent_Gain < 1){
$EXP_Percent_Gain = 1;
}
} else {
$EXP_Percent_Gain = ($EXP_Percent_Gain + (1 * $Level_Diff));
}
$EXP_Give = (($EXPNeededToLevel / 100) * $EXP_Percent_Gain);
// Calculate Damage Taken
$HP_1_Percent = ($Winner_HP / 100);
$DMG_Percent = intval($Damage_Taken / $HP_1_Percent);
if($DMG_Percent > 80){ $DMG_Percent = 80; }
$EXP_Final = intval($EXP_Give * (($DMG_Percent + 20) / 100));
// Summon?
if($Summon_Play == 1){
$EXP_Final = ($EXP_Final / 2);
$SEXP = ($EXP_Final + $Your_Summon['exp']);
$Summon_Level = $Your_Summon['level'];
$SEXPNeededToLevel = EXP_Needed_For_Level((intval($Summon_Level + 1)));
$SGain = 0;
// Calculate How Many Levels Gained If Any
while(($SEXP >= $SEXPNeededToLevel)){
$SGain++;
LevelUpSummon($Your_Summon);
$SEXP = intval($SEXP - $SEXPNeededToLevel);
$SEXPNeededToLevel = EXP_Needed_For_Level((intval($Summon_Level + ($SGain + 1))));
}
$DB->query("update inferno_summons_users set exp='{$SEXP}',battle_damage='0' where sowner='{$winner['gid']}'");
}
$Total_EXP_Gained = $EXP_Final;
$EXP_Final = intval($winner['exp'] + $EXP_Final);
$Level_Increation = 0;
// Calculate How Many Levels Gained If Any
while(($EXP_Final >= $EXPNeededToLevel)){
$Level_Increation++;
$EXP_Final = intval($EXP_Final - $EXPNeededToLevel);
$EXPNeededToLevel = EXP_Needed_For_Level((intval($Winner_Level + ($Level_Increation + 1))));
}
// Set Down New Character Data
$New_Level = ($Winner_Level + $Level_Increation);
$New_Skill_Points = ($winner['skill_points'] + ($rpg_option['skill_point_reward'] * $Level_Increation));
// v2.1 --------------------------------
// Calculate EXP Reward
// v2.1 --------------------------------
// 5% money from hand + 5% money from bank
$hand_take=$loser['money']/100*5;
$hand_take=(int)$hand_take;
$bank_take=$loser['bankmoney']/100*5;
$bank_take=(int)$bank_take;
// Send loser battle lost pm
$messageb="{$winner['name']} has won the battle between you two, it seems he/her were too strong for you to handle. This has resulted in you loosing {$hand_take} {$vbphrase['money']} from your money on hand and {$bank_take} {$vbphrase['money']} from your bank";
$messageb=ParseInput($messageb);
$title="You have lost your battle";
$to=$loser['rid'];
$from=$winner['rid'];
SendPM($messageb,$title,$to,$from);
// Remove battle
$DB->query("delete from inferno_battle where bid='{$battle['bid']}'");
// Remove battle logs
$DB->query("delete from inferno_battlelog where bid='{$battle['bid']}'");
// Remove players
$DB->query("update inferno_user set inbattle='0',money=money+'{$hand_take}',bankmoney=bankmoney+'{$bank_take}',rage='{$rage}',exp='{$EXP_Final}',level='{$New_Level}',skill_points='{$New_Skill_Points}',won=won+'1',battle_damage='0' where gid='{$winner['gid']}'");
$DB->query("update inferno_user set inbattle='0',money=money-'{$hand_take}',bankmoney=bankmoney-'{$bank_take}',hp='0',lost=lost+'1',battle_damage='0' where gid='{$loser['gid']}'");
$DB->query("update inferno_summons_users set battle_damage='0' where sowner='{$loser['gid']}'");
// Redirect winner to battle won screen
$PackUp = array(
'exp_gain' => $Total_EXP_Gained,
'level_gain' => $Level_Increation,
);
// Wrap Up + Convert Outgoind Data
$PackUp = serialize($PackUp);
$PackUp = urlencode($PackUp);
$loser['name'] = ParseInput($loser['name']);
RunError("<script>parent.location.href='inferno.php?$session[sessionurl]do=BattleWon&lname={$loser['name']}&data={$PackUp}'</script>");
}
function LevelUpSummon($summon){
// Theres probably some globals below not in use, uhm, who cares?
global $bbuserinfo, $session, $stylevar, $_POST, $vbphrase,$navbits,$show,$header;
global $templatecache, $DB_site, $vboptions, $style,$headinclude,$footer;
global $tempusagecache, $templateassoc,$DB;
$n_hp=rand(3,15);
$n_hp=(int)$n_hp;
$n_mp=rand(3,15);
$n_mp=(int)$n_mp;
$n_str=rand(3,15);
$n_str=(int)$n_str;
$n_def=rand(3,15);
$n_def=(int)$n_def;
$n_evasion=rand(0,3);
$n_evasion=(int)$n_evasion;
$n_vitality=rand(0,3);
$n_vitality=(int)$n_vitality;
$DB->query("update inferno_summons_users set hp=hp+'{$n_hp}',hpm=hpm+'{$n_hp}',mp=mp+'{$n_mp}',mpm=mpm+'{$n_mp}',str=str+'{$n_str}',def=def+'{$n_def}',level=level+'1',evasion=evasion+'{$n_evasion}',vitality=vitality+'{$n_vitality}' where suid='{$summon['suid']}'");
}
function WinBotBattle($winner,$loser,$battle,$rage,$exp){
// Theres probably some globals below not in use, uhm, who cares?
global $bbuserinfo, $session, $stylevar, $_POST, $vbphrase,$navbits,$show,$header;
global $templatecache, $DB_site, $vboptions, $style,$headinclude,$footer;
global $tempusagecache, $templateassoc,$DB,$rpg_option;
// v2.1 --------------------------------
// Calculate EXP Reward
// v2.1 --------------------------------
// Pull Out Required Variables
$Winner_HP = $winner['hpm'];
$Winner_Level = $winner['level'];
$Damage_Taken = $winner['battle_damage'];
$Opponent_Level = $loser['bot_level'];
$Summon_Play = 0;
// Summon?
if($Your_Summon = $DB->query_first("select * from inferno_summons_users where sowner='{$winner['gid']}'")){
$Summon_Play = 1;
$Damage_Taken = ($Damage_Taken + $Your_Summon['battle_damage']);
}
// Calculate EXP Needed To Level Up
$EXPNeededToLevel = EXP_Needed_For_Level((intval($Winner_Level + 1)));
// Set Default % Amount Of EXP You Will Gain
$EXP_Percent_Gain = 10;
// Calculate Level Difference - Make EXP Percent Gain Alterations (Up or Down)
$Level_Diff = $Opponent_Level - $Winner_Level;
$Reversal = 0;
if($Level_Diff < 1){
$Level_Diff = $Winner_Level - $Opponent_Level;
$Reversal = 1;
}
if(intval($Winner_Level - $Opponent_Level) == 0){
$Level_Diff = 1;
}
if($Reversal == 1){
$EXP_Percent_Gain = ($EXP_Percent_Gain - (1 * $Level_Diff));
if($EXP_Percent_Gain < 1){
$EXP_Percent_Gain = 1;
}
} else {
$EXP_Percent_Gain = ($EXP_Percent_Gain + (1 * $Level_Diff));
}
$EXP_Give = (($EXPNeededToLevel / 100) * $EXP_Percent_Gain);
// Calculate Damage Taken
$HP_1_Percent = ($Winner_HP / 100);
$DMG_Percent = intval($Damage_Taken / $HP_1_Percent);
if($DMG_Percent > 80){ $DMG_Percent = 80; }
$EXP_Final = intval($EXP_Give * (($DMG_Percent + 20) / 100));
// Summon?
if($Summon_Play == 1){
$EXP_Final = ($EXP_Final / 2);
$SEXP = ($EXP_Final + $Your_Summon['exp']);
$Summon_Level = $Your_Summon['level'];
$SEXPNeededToLevel = EXP_Needed_For_Level((intval($Summon_Level + 1)));
$SGain = 0;
// Calculate How Many Levels Gained If Any
while(($SEXP >= $SEXPNeededToLevel)){
$SGain++;
LevelUpSummon($Your_Summon);
$SEXP = intval($SEXP - $SEXPNeededToLevel);
$SEXPNeededToLevel = EXP_Needed_For_Level((intval($Summon_Level + ($SGain + 1))));
}
$DB->query("update inferno_summons_users set exp='{$SEXP}',battle_damage='0' where sowner='{$winner['gid']}'");
}
$Total_EXP_Gained = $EXP_Final;
$EXP_Final = intval($winner['exp'] + $EXP_Final);
$Level_Increation = 0;
// Calculate How Many Levels Gained If Any
while(($EXP_Final >= $EXPNeededToLevel)){
$Level_Increation++;
$EXP_Final = intval($EXP_Final - $EXPNeededToLevel);
$EXPNeededToLevel = EXP_Needed_For_Level((intval($Winner_Level + ($Level_Increation + 1))));
}
// Set Down New Character Data
$New_Level = ($Winner_Level + $Level_Increation);
$New_Skill_Points = ($winner['skill_points'] + ($rpg_option['skill_point_reward'] * $Level_Increation));
// v2.1 --------------------------------
// Calculate EXP Reward
// v2.1 --------------------------------
// Remove battle
$DB->query("delete from inferno_battle where bid='{$battle['bid']}'");
// Remove battle logs
$DB->query("delete from inferno_battlelog where bid='{$battle['bid']}'");
// Remove players
$DB->query("update inferno_user set inbattle='0',money=money+'{$loser['bot_reward']}',won=won+'1',rage='{$rage}',exp='{$EXP_Final}',level='{$New_Level}',skill_points='{$New_Skill_Points}',battle_damage='0' where gid='{$winner['gid']}'");
$DB->query("update inferno_battlebot set bot_inbattle='0',bot_hp=bot_hpm,bot_mp=bot_mpm,bot_loss=bot_loss+'1' where bot_id='{$loser['bot_id']}'");
// Redirect winner to battle won screen
$loser['bot_name']=ParseInput($loser['bot_name']);
$PackUp = array(
'exp_gain' => $Total_EXP_Gained,
'level_gain' => $Level_Increation,
);
// Wrap Up + Convert Outgoind Data
$PackUp = serialize($PackUp);
$PackUp = urlencode($PackUp);
// Is it a temp bot?
if($loser['is_temp'] == "yes"){
// Remove Temp Bot
$DB->query("delete from inferno_battlebot where bot_id='{$loser['bot_id']}'");
RunError("<script>parent.location.href='inferno.php?$session[sessionurl]do=RPGWorld-InGame'</script>");
} else {
RunError("<script>parent.location.href='inferno.php?$session[sessionurl]do=BattleWon&lname={$loser['bot_name']}&data={$PackUp}'</script>");
}
}
function LoseBotBattle($loser,$winner,$battle){
// Theres probably some globals below not in use, uhm, who cares?
global $bbuserinfo, $session, $stylevar, $_POST, $vbphrase,$navbits,$show,$header;
global $templatecache, $DB_site, $vboptions, $style,$headinclude,$footer;
global $tempusagecache, $templateassoc,$DB;
// Remove battle
$DB->query("delete from inferno_battle where bid='{$battle['bid']}'");
// Remove battle logs
$DB->query("delete from inferno_battlelog where bid='{$battle['bid']}'");
// Remove players
$DB->query("update inferno_user set inbattle='0',lost=lost+'1',hp='0',battle_damage='0' where gid='{$loser['gid']}'");
$DB->query("update inferno_battlebot set bot_inbattle='0',bot_hp=bot_hpm,bot_mp=bot_mpm,bot_vics=bot_vics+'1' where bot_id='{$winner['bot_id']}'");
// Is it a temp bot?
if($winner['is_temp'] == "yes"){
// Remove Temp Bot
$DB->query("delete from inferno_battlebot where bot_id='{$winner['bot_id']}'");
RunError("<script>alert('You lost your battle with {$winner['bot_name']}');parent.location.href='inferno.php?$session[sessionurl]do=RPGWorld-InGame'</script>");
} else {
RunError("<script>alert('You lost your battle with {$winner['bot_name']}');parent.location.href='inferno.php?$session[sessionurl]do=Battle'</script>");
}
}
$navbits= array();
$navbits[""]= "";
if (!$vbulletin->userinfo['userid'])
{
RunError("RPG Inferno is not available to guests. Please login or <a href='register.php'>Register</a>");
}
if($member['rid']=="" && $_GET['do']!='DoProfile' && $_GET['do']!='Help'){
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// Navigation
$navbits= array("inferno.php?$session[sessionurl]do=Profile" => "Creating Profile");
$navbits[""]= "RPG Profile";
// ---------------------------------
// Section Control: Online/Offline -
// ---------------------------------
if($rpg_option['rpgcp_status']=="offline"){
RunError("Sorry, this section has been turned offline. Please contact the administrator for more information");
}
// ---------------------------------
// Section Control: Online/Offline -
// ---------------------------------
// need to create rpg profile
// grab elements
$elements="";
$gete=$DB->query("select * from inferno_element order by eid");
while($element=$DB->fetch_array($gete)){
if($element['eid']==$member['element']){
$elements.="<option value='{$element['eid']}' strength='{$element['strength']}' weakness='{$element['weakness']}' str='{$element['estr']}' hp='{$element['ehp']}' mp='{$element['emp']}' def='{$element['edef']}' img='{$element['img']}' effect='{$element['effect']}' selected>{$element['element']}</option>";
} else {
$elements.="<option value='{$element['eid']}' strength='{$element['strength']}' weakness='{$element['weakness']}' str='{$element['estr']}' hp='{$element['ehp']}' mp='{$element['emp']}' def='{$element['edef']}' img='{$element['img']}' effect='{$element['effect']}'>{$element['element']}</option>";
}}
// Create Drops For Av Height/Width
$avh="";
$avw="";
for($d=0;$d<=$rpg_option['max_avh'];$d++){
$avh.="<option value='{$d}'>{$d}</option>";
}
for($d=0;$d<=$rpg_option['max_avw'];$d++){
$avw.="<option value='{$d}'>{$d}</option>";
}
$rpg_avatars="<option value='CustomAvatar'>Use Own Settings</option>";
$get_av_cats=$DB->query("select * from inferno_rpgavatar_gallery_cats order by catname");
while($cat=$DB->fetch_array($get_av_cats)){
$Cats[]=$cat;
}
$get_av=$DB->query("select * from inferno_rpgavatar_gallery order by avname");
while($avatars_i = $DB->fetch_array($get_av)){
$all_avatars[] = $avatars_i;
}
if($Cats[0]){
foreach($Cats as $av_cat){
$rpg_avatars.="<optgroup label='{$av_cat['catname']}'>";
foreach($all_avatars as $av){
if($av['avcat']==$av_cat['acid']){
if($member['avatar']==$vboptions[bburl].'/Inferno/Avatar_Gallery/'.$av['avurl']){
$rpg_avatars.="<option value='{$vboptions[bburl]}/Inferno/Avatar_Gallery/{$av['avurl']}' selected>{$av['avname']}</option>";
} else {
$rpg_avatars.="<option value='{$vboptions[bburl]}/Inferno/Avatar_Gallery/{$av['avurl']}'>{$av['avname']}</option>";
}
}
}
}
}
eval('$rpg_body .= "' . fetch_template('inferno_profile') . '";');
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
// Inferno header template (global links)
eval('$rpgheader = "' . fetch_template('inferno_header') . '";');
eval('$rpg_body .= "' . fetch_template('inferno_x_main') . '";');
eval('print_output("' . fetch_template('inferno') . '");');
}
function UpdateLocation($act){
global $DB,$rpg_option,$member;
$_SERVER['QUERY_STRING']=ParseInput($_SERVER['QUERY_STRING']);
$DB->query("update inferno_user set rpg_location='{$_SERVER['QUERY_STRING']}',time_location='".time()."' where gid='{$member['gid']}'");
}
// ############################ NO ACTION ################################
if (!$_GET['do'] || $_GET['do']=="") {
$_GET['do'] = "Shop";
}
$InfernoPerms = convert_bits_to_array($vbulletin->userinfo['permissions']['infernopermissions'], $vbulletin->bf_ugp['infernopermissions']);
if (!$InfernoPerms['canuseinferno'])
{
RunError('You\'re usergroup does not have access to use RPG Inferno.');
}
// No RPG Name?
if($member['name']=="" && $_GET['do']!='DoProfile' && $_GET['do']!='Help' && $_GET['do']!='Profile'){
$navbits= array("inferno.php?$session[sessionurl]do=".$Action => "Profile Error");
$navbits[""]= "Profile Error";
RunError("Your RPG Name is currently blank. Please go to the <a href='inferno.php?$session[sessionurl]do=Profile'>RPG CP</a> to fix this");
}
// ######################### Functions Array #############################
// Action
$Action=$_GET['do'];
if($Action=="Profile"){
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// RPG Profile
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// Navigation
$navbits= array("inferno.php?$session[sessionurl]do=".$Action => "Updating RPG Profile");
$navbits[""]= "RPG Profile";
// ---------------------------------
// Section Control: Online/Offline -
// ---------------------------------
if($rpg_option['rpgcp_status']=="offline"){
RunError("Sorry, this section has been turned offline. Please contact the administrator for more information");
}
// ---------------------------------
// Section Control: Online/Offline -
// ---------------------------------
// grab elements
$elements="";
$gete=$DB->query("select * from inferno_element order by eid");
while($element=$DB->fetch_array($gete)){
if($element['eid']==$member['element']){
$elements.="<option value='{$element['eid']}' strength='{$element['strength']}' weakness='{$element['weakness']}' str='{$element['estr']}' hp='{$element['ehp']}' mp='{$element['emp']}' def='{$element['edef']}' img='{$element['img']}' effect='{$element['effect']}' selected>{$element['element']}</option>";
} else {
$elements.="<option value='{$element['eid']}' strength='{$element['strength']}' weakness='{$element['weakness']}' str='{$element['estr']}' hp='{$element['ehp']}' mp='{$element['emp']}' def='{$element['edef']}' img='{$element['img']}' effect='{$element['effect']}'>{$element['element']}</option>";
}}
// Create Drops For Av Height/Width
$avh="";
$avw="";
for($d=0;$d<=$rpg_option['max_avh'];$d++){
if($d==$member['ah']){
$avh.="<option value='{$d}' selected>{$d}</option>";
} else {
$avh.="<option value='{$d}'>{$d}</option>";
}
}
for($d=0;$d<=$rpg_option['max_avw'];$d++){
if($d==$member['aw']){
$avw.="<option value='{$d}' selected>{$d}</option>";
} else {
$avw.="<option value='{$d}'>{$d}</option>";
}
}
$rpg_avatars="<option value='CustomAvatar'>Use Own Settings</option>";
$get_av_cats=$DB->query("select * from inferno_rpgavatar_gallery_cats order by catname");
while($cat=$DB->fetch_array($get_av_cats)){
$Cats[]=$cat;
}
$get_av=$DB->query("select * from inferno_rpgavatar_gallery order by avname");
while($avatars_i = $DB->fetch_array($get_av)){
$all_avatars[] = $avatars_i;
}
if($Cats[0]){
foreach($Cats as $av_cat){
$rpg_avatars.="<optgroup label='{$av_cat['catname']}'>";
foreach($all_avatars as $av){
if($av['avcat']==$av_cat['acid']){
if($member['avatar']==$vboptions[bburl].'/Inferno/Avatar_Gallery/'.$av['avurl']){
$rpg_avatars.="<option value='{$vboptions[bburl]}/Inferno/Avatar_Gallery/{$av['avurl']}' selected>{$av['avname']}</option>";
} else {
$rpg_avatars.="<option value='{$vboptions[bburl]}/Inferno/Avatar_Gallery/{$av['avurl']}'>{$av['avname']}</option>";
}
}
}
}
}
eval('$rpg_body .= "' . fetch_template('inferno_profile') . '";');
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// RPG Profile
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
}
if($_GET['do']=="DoProfile"){
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// RPG Profile [Add/Update]
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// Navigation
$navbits= array("inferno.php?$session[sessionurl]do=".$Action => "RPG Profile Updated");
$navbits[""]= "RPG Profile";
if($_POST['name']==""){
RunError("You did not enter a character name. Please go back and enter one");
}
// ---------------------------------
// Section Control: Online/Offline -
// ---------------------------------
if($rpg_option['rpgcp_status']=="offline"){
RunError("Sorry, this section has been turned offline. Please contact the administrator for more information");
}
// ---------------------------------
// Section Control: Online/Offline -
// ---------------------------------
// ++++++++++++
// Parse Inputs
// ++++++++++++
$_POST['element']=ParseInput($_POST['element']);
$_POST['aw']=ParseInput($_POST['aw']);
$_POST['ah']=ParseInput($_POST['ah']);
$_POST['name']=ParseInput($_POST['name']);
$_POST['smove']=ParseInput($_POST['smove']);
$_POST['gender']=ParseInput($_POST['gender']);
$_POST['align']=ParseInput($_POST['align']);
$_POST['avatar']=ParseInput($_POST['avatar']);
$_POST['rpg_avatar_gallery']=ParseInput($_POST['rpg_avatar_gallery']);
// ++++++++++++
// Parse Inputs
// ++++++++++++
// Checking RPG Name...
if($check_name=$DB->query_first("select * from inferno_user where name='{$_POST['name']}'")){
// check it isn't you :P
if($check_name['gid']!=$member['gid']){
RunError("This RPG Name has already been chosen, please choose another");
}
}
// Possible Errors --
if($_POST['aw']>$rpg_option['max_avw'] || $_POST['ah']>$rpg_option['max_avh']){
RunError("Sorry but your inputted values for either avatar width/height are beyond the set limits");
}
if($member['inbattle']>0){
RunError("You are in battle, you cannot change your profile");
}
// using from rpg avatar gallery?
if($_POST['rpg_avatar_gallery']!="CustomAvatar"){
// determine image dimensions
$_POST['rpg_avatar_gallery']=str_replace(' ','%20',$_POST['rpg_avatar_gallery']);
$size=@getimagesize($_POST['rpg_avatar_gallery']);
$_POST['aw']=$size[0];
$_POST['ah']=$size[1];
$_POST['avatar']=$_POST['rpg_avatar_gallery'];
}
// connect to element selected
$gelm=$DB->query("select * from inferno_element where eid='{$_POST['element']}'");
$theelement=$DB->fetch_array($gelm);
if($member['rid']==""){
// Add New Row [oh god =( ]
// elemental selection - stats increase
// new peeps first
$nhp=100;
$nhpm=100;
$nmp=100;
$nmpm=100;
$nstr=30;
$ndef=30;
$nhp+=$theelement['ehp'];
$nhpm+=$theelement['ehp'];
$nmp+=$theelement['emp'];
$nmpm+=$theelement['emp'];
$nstr+=$theelement['estr'];
$ndef+=$theelement['edef'];
$DB->query("insert into inferno_user values('',
'".$bbuserinfo[userid]."',
'{$rpg_option['new_characer_money']}',
'0',
'',
'0',
'0',
'0',
'0',
'0',
$nhp,
$nhpm,
$nmp,
$nmpm,
$nstr,
$ndef,
'0',
'0',
'0',
'".$_POST['element']."',
'0',
'0',
'0',
'".$_POST['aw']."',
'".$_POST['ah']."',
'0',
'',
'0',
'',
'".$_POST['name']."',
'".$_POST['smove']."',
'',
'".$_POST['gender']."',
'".$_POST['align']."',
'".$_POST['avatar']."',
'',
'0',
'0',
'{$Action}',
'".time()."',
'15',
'15',
'',
'0',
'no',
'0',
'0')");
} else {
// connect to old element - remove those stats
$gelmo=$DB->query("select * from inferno_element where eid='{$member['element']}'");
$oldelement=$DB->fetch_array($gelmo);
$member['hp']-=$oldelement['ehp'];
$member['hpm']-=$oldelement['ehp'];
$member['mp']-=$oldelement['emp'];
$member['mpm']-=$oldelement['emp'];
$member['str']-=$oldelement['estr'];
$member['def']-=$oldelement['edef'];
// Increase stats from new selected element (even if it aint new, just cancels it out :P)
// connect to element selected
$gelm=$DB->query("select * from inferno_element where eid='{$_POST['element']}'");
$theelement=$DB->fetch_array($gelm);
$member['hp']+=$theelement['ehp'];
$member['hpm']+=$theelement['ehp'];
$member['mp']+=$theelement['emp'];
$member['mpm']+=$theelement['emp'];
$member['str']+=$theelement['estr'];
$member['def']+=$theelement['edef'];
// Yay!, just update XD
$DB->query("update inferno_user set avatar='{$_POST['avatar']}',aw='{$_POST['aw']}',ah='{$_POST['ah']}',align='{$_POST['align']}',smove='{$_POST['smove']}',gender='".$_POST['gender']."',name='".$_POST['name']."',element='".$_POST['element']."',hp='{$member['hp']}',hpm='{$member['hpm']}',mp='{$member['mp']}',mpm='{$member['mpm']}',str='{$member['str']}',def='{$member['def']}' where rid='".$bbuserinfo['userid']."'");
}
// Redirect Bitch!
$message="RPG Profile Updated!";
$url="inferno.php?$session[sessionurl]do=Profile";
eval('$rpg_body .= "' . fetch_template('inferno_redirect') . '";');
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// RPG Profile [Add/Update]
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
}
if($Action=='Shop') {
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// Itemshop
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// Navigation
$navbits= array("inferno.php?$session[sessionurl]do=".$Action => "Buy Items");
$navbits[""]= "Itemshop";
// ---------------------------------
// Section Control: Online/Offline -
// ---------------------------------
if($rpg_option['itemshop_status']=="offline"){
RunError("Sorry, this section has been turned offline. Please contact the administrator for more information");
}
// ---------------------------------
// Section Control: Online/Offline -
// ---------------------------------
$View_Options = false;
$Display = $_GET['display'];
if($Display == 'buyonly'){
$YCID = $DB->query_first("select jid from inferno_jobs where jname='{$member['class']}'");
$YCID = $YCID['jid'];
}
$cache_upgrade=array(); // Why reload what we already have? O_o
$myitem=array();
// Call Inventory Top
eval('$rpg_body .= "' . fetch_template('inferno_inv_top') . '";');
// Call Inventory Row
$inv_row=$DB->query("select u.*,s.*,i.*
from inferno_stock s
left join inferno_items i on(i.id=s.item_id)
left join inferno_synthesis u on(u.sid=s.upgrade_id)
where s.member_id='".$member['gid']."'");
while ($items = $DB->fetch_array($inv_row)) {
$myitem[]=$items;
}
// display items with upgrade
if($myitem[0]){ // member has any items? [if not cancel out foreach()]
foreach($myitem as $the_item){
// upgrade?
if($the_item['upgrade_id']>0){
$the_item['the_upgrade']=$the_item['sname'];
} else {
$the_item['the_upgrade']="<i>None</i>";
}
$the_item['Sell']=(int)$the_item['cost']/3;
$the_item['Sell']=floor($the_item['Sell']);
$the_item['Sell']=number_format($the_item['Sell']);
$items=$the_item; // clarify var
eval('$rpg_body .= "' . fetch_template('inferno_inv_row') . '";');
}
}
// Call Inventory End
eval('$rpg_body .= "' . fetch_template('inferno_inv_end') . '";');
$CatAll=array();
$all=$DB->query("select * from inferno_cat order by cid");
// step 1 - array cats
$all_items = 0;
$all_sold = 0;
$all_profit = 0;
while($cat=$DB->fetch_array($all)){
$CatAll[$cat['cid']]=$cat;
$all_items+=$cat['citems'];
$all_sold+=$cat['csold'];
$all_profit+=$cat['cprofit'];
}
$all_items = number_format($all_items);
$all_sold = number_format($all_sold);
$all_profit = number_format($all_profit);
$all_profit.=" {$vbphrase['money']}";
if($_GET['showshop']){
// select all items (saves mass queries for tons of categories)
$get_all_items = $DB->query("select * from inferno_items order by cost");
while($all_i = $DB->fetch_array($get_all_items)){
$AllItems[]=$all_i;
}
if($_GET['showshop']=="all_shops"){
// --- Show All Shops ---
$View_Options = true;
// step 2 - paste shops
if(is_array($CatAll)){
foreach($CatAll as $TheCat){
// - relay shop top
$cats=$TheCat;
eval('$rpg_body .= "' . fetch_template('inferno_shop_top') . '";');
// - relay shop items
if(is_array($AllItems)){
foreach($AllItems as $items){
if($items['type']==$TheCat['cid']){
if($Display == 'buyonly'){
$Check = $System->CanBuyItem($items,$YCID);
} else {
$Check = 1 == 1;
}
if($member['money'] >= $items['cost']){
$items['BuyLink']="<a href='?$session[sessionurl]do=BuyItem&id={$items['id']}'>Buy</a>";
} else {
$items['BuyLink']="<a disabled=true href='javascript:;' title='Not Enough {$vbphrase[money]} To Buy This Item'>Buy</a>";
}
$items['cost']=number_format($items['cost']);
if($Check){
eval('$rpg_body .= "' . fetch_template('inferno_shop_row') . '";');
}
}
}
}
// - relay shop bottom
eval('$rpg_body .= "' . fetch_template('inferno_shop_end') . '";');
}
}
// --- Show All Shops ---
} else {
// Grab Shop From DB
$cats=$CatAll[$_GET['showshop']];
if($cats['cname']!=""){ // Cat Exists
$View_Options = true;
// Call Shop Top
eval('$rpg_body .= "' . fetch_template('inferno_shop_top') . '";');
// Call Shop Cat/All Cats + Items (If Selected)
if(is_array($AllItems)){
foreach($AllItems as $items){
if($items['type']==$_GET['showshop']){
if($Display == 'buyonly'){
$Check = $System->CanBuyItem($items,$YCID);
} else {
$Check = 1 == 1;
}
if($member['money'] >= $items['cost']){
$items['BuyLink']="<a href='?$session[sessionurl]do=BuyItem&id={$items['id']}'>Buy</a>";
} else {
$items['BuyLink']="<a disabled=true href='javascript:;' title='Not Enough {$vbphrase[money]} To Buy This Item'>Buy</a>";
}
$items['cost']=number_format($items['cost']);
if($Check){
eval('$rpg_body .= "' . fetch_template('inferno_shop_row') . '";');
}
}
}
}
// Call Shop Bottom
eval('$rpg_body .= "' . fetch_template('inferno_shop_end') . '";');
}}}
// Call Shop Cats Top
eval('$rpg_body .= "' . fetch_template('inferno_cat_top') . '";');
if($View_Options){
eval('$rpg_body = str_replace("<{ITEMSHOP_PARAMS}>","' . fetch_template('inferno_itemshop_params') . '",$rpg_body);');
} else {
$rpg_body = str_replace("<{ITEMSHOP_PARAMS}>","",$rpg_body);
}
// Call Shop Cats Row
if(is_array($CatAll)){
foreach($CatAll as $thecats){
$thecats['csold']=number_format($thecats['csold']);
$thecats['cprofit']=number_format($thecats['cprofit']);
$thecats['citems']=number_format($thecats['citems']);
eval('$rpg_body .= "' . fetch_template('inferno_cat_row') . '";');
}
}
// Call Shop Cats Bottom
eval('$rpg_body .= "' . fetch_template('inferno_cat_end') . '";');
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// Itemshop
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
}
if($_GET['do']=="BuyItem"){
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// Buy Item [actually]
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// Navigation
$navbits= array("inferno.php?$session[sessionurl]do=".$Action => "Buying Item");
$navbits[""]= "Itemshop";
// ---------------------------------
// Section Control: Online/Offline -
// ---------------------------------
if($rpg_option['itemshop_status']=="offline"){
RunError("Sorry, this section has been turned offline. Please contact the administrator for more information");
}
// ---------------------------------
// Section Control: Online/Offline -
// ---------------------------------
// Check item exists
$gitem=$DB->query("select * from inferno_items where id='{$_GET['id']}'");
$item=$DB->fetch_array($gitem);
if($item['id']==""){
RunError("The item you have requested was not found, please check the link you have clicked");
}
// Can you actually afford this item?
if(($member['money']-$item['cost']) < 0){
RunError("The item you have requested is too expensive for you to buy at this moment");
}
// have the required stats
if($item['level']>$member['level'] || $item['hp_require']>$member['hpm'] || $item['mp_require']>$member['mpm'] || $item['str_require']>$member['str'] || $item['def_require']>$member['def'] || $item['vit_require']>$member['vitality'] || $item['eva_require']>$member['evasion']){
RunError("You do not meet the requirements to handle this item. Please <a href='inferno.php?$session[sessionurl]do=scan&id={$item['id']}'>Scan</a> the item to see the requirements needed.");
}
// not out of stock?
if($item['stock']<1){
RunError("This item is currently out of stock. Please call again when we have some more in stock");
}
// Your Class = Allowed?
$Your_Class = $DB->query_first("select * from inferno_jobs where jname = '{$member['class']}'");
$Allowed = explode("|",$item['class_allow']);
$Allow = 0;
if(is_array($Allowed)){
foreach($Allowed as $jid){
if($jid == $Your_Class['jid']){
$Allow++;
}
}
}
if($Allow == 0){
RunError("Sorry but this item cannot be used by your class.");
}
// already own?
$runx=$DB->query("select * from inferno_stock where item_id='{$item['id']}' and member_id='{$member['gid']}'");
$your_items=$DB->fetch_array($runx);
if($your_items['uid']!=""){
RunError("You already own this item");
}
// take money
$DB->query("update inferno_user set money=money-'{$item['cost']}' where gid='{$member['gid']}'");
// insert into inventory
$DB->query("insert into inferno_stock values('','{$item['id']}','{$member['gid']}','0')");
// update cat statistics
$DB->query("update inferno_cat set csold=csold+'1',cprofit=cprofit+'{$item['cost']}' where cid='{$item['type']}'");
$DB->query("update inferno_items set sold=sold+'1',stock=stock-'1' where id='{$item['id']}'");
// ok, no problems, get the hell out of here O.o
$message="Item {$item['name']} Successfully Purchased";
$url="inferno.php?showshop={$item['type']}";
eval('$rpg_body .= "' . fetch_template('inferno_redirect') . '";');
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// Buy Item [actually]
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
}
if($_GET['do']=="sellitem"){
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// Sell Item
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// Navigation
$navbits= array("inferno.php?$session[sessionurl]do=".$Action => "Selling Item");
$navbits[""]= "Itemshop";
// ---------------------------------
// Section Control: Online/Offline -
// ---------------------------------
if($rpg_option['itemshop_status']=="offline"){
RunError("Sorry, this section has been turned offline. Please contact the administrator for more information");
}
// ---------------------------------
// Section Control: Online/Offline -
// ---------------------------------
// Check item exists
$gitem=$DB->query("select * from inferno_items where id='{$_GET['id']}'");
$item=$DB->fetch_array($gitem);
if($item['id']==""){
RunError("The item you have requested was not found, please check the link you have clicked");
}
// Check you own the item
$runx=$DB->query("select * from inferno_stock where item_id='{$item['id']}' and member_id='{$member['gid']}'");
$your_items=$DB->fetch_array($runx);
if($your_items['uid']==""){
RunError("You do not own this item to sell");
}
// you put item in an auction?
if($auction=$DB->query_first("select * from inferno_auction where item='{$item['id']}' and owner='{$member['gid']}'")){
RunError("The item you are trying to sell is currently in an auction you are running, please close or cancel the auction first");
}
// upgraded?
if($your_items['upgrade_id']>0){
RunError("Please remove any upgrades to an item before selling it.");
}
// Give Money (3rd)
$sell=(int)$item['cost']/3;
$sell=floor($sell);
$DB->query("update inferno_user set money=money+'".$sell."' where gid='{$member['gid']}'")