Better character creation. Configurable vocation skills and will calculate HP/MP/CAP for each vocation at their configured starting level.

This commit is contained in:
Znote 2016-12-04 01:44:44 +01:00
parent 9173619e77
commit 366542d249
3 changed files with 169 additions and 80 deletions

View File

@ -1,7 +1,6 @@
<?php require_once 'engine/init.php'; include 'layout/overall/header.php'; <?php require_once 'engine/init.php'; include 'layout/overall/header.php';
protect_page(); protect_page();
admin_only($user_data); admin_only($user_data);
// start
// PREP: Create a function that echos player skills // PREP: Create a function that echos player skills
function playerSkill($skills, $id) { function playerSkill($skills, $id) {
@ -16,13 +15,16 @@ if (isset($_POST['pid']) && (int)$_POST['pid'] > 0) {
$pid = (int)$_POST['pid']; $pid = (int)$_POST['pid'];
if ($config['TFSVersion'] != 'TFS_10') $status = user_is_online($pid); if ($config['TFSVersion'] != 'TFS_10') $status = user_is_online($pid);
else $status = user_is_online_10($pid); else $status = user_is_online_10($pid);
if (!$status) { if (!$status) {
// New player level // New player level
$level = (int)$_POST['level']; $level = (int)$_POST['level'];
// Fetch stat gain for vocation // Fetch stat gain for vocation
$statgain = $config['vocations_gain'][(int)$_POST['vocation']]; $statgain = $config['vocations_gain'][(int)$_POST['vocation']];
$playercnf = $config['player'];
/*
if ((int)$_POST['vocation'] !== 0) { if ((int)$_POST['vocation'] !== 0) {
// Fetch base level and stats: // Fetch base level and stats:
$baselevel = $config['level']; $baselevel = $config['level'];
@ -36,13 +38,12 @@ if (isset($_POST['pid']) && (int)$_POST['pid'] > 0) {
$basemana = $config['nvMana']; $basemana = $config['nvMana'];
$basecap = $config['nvCap']; $basecap = $config['nvCap'];
} }
*/
$levelC = $level - $baselevel; $LevelsFromBase = $level - $playercnf['base']['level'];
if ($levelC >= 1) { $newhp = $playercnf['base']['health'] + ($statgain['hp'] * $LevelsFromBase);
$newhp = $basehealth + ($statgain['hp'] * $levelC); $newmp = $playercnf['base']['mana'] + ($statgain['mp'] * $LevelsFromBase);
$newmp = $basemana + ($statgain['mp'] * $levelC); $newcap = $playercnf['base']['cap'] + ($statgain['cap'] * $LevelsFromBase);
$newcap = $basecap + ($statgain['cap'] * $levelC);
} else die("Failed to calibrate skills. Level below $baselevel.");
// Calibrate hp/mana/cap // Calibrate hp/mana/cap
if ($config['TFSVersion'] != 'TFS_10') { if ($config['TFSVersion'] != 'TFS_10') {

View File

@ -394,31 +394,98 @@
// Available character vocation users can create. // Available character vocation users can create.
$config['available_vocations'] = array(1, 2, 3, 4); $config['available_vocations'] = array(1, 2, 3, 4);
// Available towns (specify town ids, etc: (0, 1, 2); to display 3 town options (town id 0, 1 and 2). // Available towns (specify town ids, etc: (1, 2, 3); to display 3 town options (town id 1, 2 and 3).
$config['available_towns'] = array(1,2,4,5); $config['available_towns'] = array(1, 2, 4, 5);
$config['level'] = 8; $config['player'] = array(
$config['health'] = 185; 'base' => array(
$config['mana'] = 40; 'level' => 8,
$config['cap'] = 470; 'health' => 185,
$config['soul'] = 100; 'mana' => 40,
'cap' => 470,
$config['maleOutfitId'] = 128; 'soul' => 100
$config['femaleOutfitId'] = 136; ),
$config['lookHead'] = 78; // health, mana cap etc are calculated with $config['vocations_gain'] and 'base' values of $config['player']
$config['lookBody'] = 68; 'create' => array(
$config['lookLegs'] = 58; 'level' => 8,
$config['lookFeet'] = 76; 'novocation' => array( // vocation id 0 (No vocation) special settings
'level' => 1, // Level
// No vocation info (if user select vocation id 0, we force thees configurations on him 'forceTown' => true,
$config['nvlevel'] = 1; 'townId' => 30
$config['nvHealth'] = 150; ),
$config['nvMana'] = 5; 'skills' => array( // See $config['vocations'] for proper vocation names of these IDs
$config['nvCap'] = 400; // No vocation
$config['nvSoul'] = 100; 0 => array(
'magic' => 0,
$config['nvForceTown'] = 0; // Force a town to no vocation even though he selected something else? 0 = no, 1 = yes. 'fist' => 10,
$config['nvTown'] = 0; // Town id to force no vocations to get to, if nvForceTown is 1. 'club' => 10,
'axe' => 10,
'sword' => 10,
'dist' => 10,
'shield' => 10,
'fishing' => 10,
),
// Sorcerer
1 => array(
'magic' => 0,
'fist' => 10,
'club' => 10,
'axe' => 10,
'sword' => 10,
'dist' => 10,
'shield' => 10,
'fishing' => 10,
),
// Druid
2 => array(
'magic' => 0,
'fist' => 10,
'club' => 10,
'axe' => 10,
'sword' => 10,
'dist' => 10,
'shield' => 10,
'fishing' => 10,
),
// Paladin
3 => array(
'magic' => 0,
'fist' => 10,
'club' => 10,
'axe' => 10,
'sword' => 10,
'dist' => 10,
'shield' => 10,
'fishing' => 10,
),
// Knight
4 => array(
'magic' => 0,
'fist' => 10,
'club' => 10,
'axe' => 10,
'sword' => 10,
'dist' => 10,
'shield' => 10,
'fishing' => 10,
),
),
'male_outfit' => array(
'id' => 128,
'head' => 78,
'body' => 68,
'legs' => 58,
'feet' => 76
),
'female_outfit' => array(
'id' => 136,
'head' => 78,
'body' => 68,
'legs' => 58,
'feet' => 76
)
)
);
// Minimum allowed character name letters. Etc 4 letters: "Kåre". // Minimum allowed character name letters. Etc 4 letters: "Kåre".
$config['minL'] = 4; $config['minL'] = 4;
@ -451,12 +518,6 @@
'price_sqm' => '50', // price per house sqm 'price_sqm' => '50', // price per house sqm
); );
$config['status'] = array(
'status_check' => false, //enable or disable status checker
'status_ip' => '127.0.0.1',
'status_port' => "7171",
);
$config['delete_character_interval'] = '3 DAY'; // Delay after user character delete request is executed eg. 1 DAY, 2 HOUR, 3 MONTH etc. $config['delete_character_interval'] = '3 DAY'; // Delay after user character delete request is executed eg. 1 DAY, 2 HOUR, 3 MONTH etc.
$config['validate_IP'] = true; $config['validate_IP'] = true;
@ -491,7 +552,7 @@
// What client version and server port are you using on this OT? // What client version and server port are you using on this OT?
// Used for the Downloads page. // Used for the Downloads page.
$config['client'] = 1098; // 954 = tibia 9.54 $config['client'] = 1098; // 954 = client 9.54
// Download link to client. // Download link to client.
$config['client_download'] = 'http://clients.halfaway.net/windows.php?tibia='. $config['client'] .''; $config['client_download'] = 'http://clients.halfaway.net/windows.php?tibia='. $config['client'] .'';
@ -499,6 +560,12 @@
$config['port'] = 7171; // Port number to connect to your OT. $config['port'] = 7171; // Port number to connect to your OT.
$config['status'] = array(
'status_check' => false, //enable or disable status checker
'status_ip' => '127.0.0.1',
'status_port' => "7171",
);
// Gameserver info is used for client 11+ loginWebService // Gameserver info is used for client 11+ loginWebService
$config['gameserver'] = array( $config['gameserver'] = array(
'ip' => $_SERVER["SERVER_ADDR"], // Can be an ip string like '123.123.123.123' 'ip' => $_SERVER["SERVER_ADDR"], // Can be an ip string like '123.123.123.123'

View File

@ -1136,42 +1136,52 @@ function user_create_character($character_data) {
array_walk($character_data, 'array_sanitize'); array_walk($character_data, 'array_sanitize');
$cnf = fullConfig(); $cnf = fullConfig();
if ($character_data['sex'] == 1) { $vocation = (int)$character_data['vocation'];
$outfit_type = $cnf['maleOutfitId']; $playercnf = $cnf['player'];
} else { $base = $playercnf['base'];
$outfit_type = $cnf['femaleOutfitId']; $create = $playercnf['create'];
} $skills = $create['skills'][$vocation];
$outfit = ($character_data['sex'] == 1) ? $create['male_outfit'] : $create['female_outfit'];
$leveldiff = $create['level'] - $base['level'];
$gains = $cnf['vocations_gain'][$vocation];
$health = $base['health'] + ( $gains['hp'] * $leveldiff );
$mana = $base['mana'] + ( $gains['mp'] * $leveldiff );
$cap = $base['cap'] + ( $gains['cap'] * $leveldiff );
// This is TFS 0.2 compatible import data with Znote AAC mysql schema // This is TFS 0.2 compatible import data with Znote AAC mysql schema
$import_data = array( $import_data = array(
'name' => $character_data['name'], 'name' => $character_data['name'],
'group_id' => 1, 'group_id' => 1,
'account_id' => $character_data['account_id'], 'account_id' => $character_data['account_id'],
'level' => $cnf['level'], 'level' => $create['level'],
'vocation' => $character_data['vocation'], 'vocation' => $vocation,
'health' => $cnf['health'], 'health' => $health,
'healthmax' => $cnf['health'], 'healthmax' => $health,
'experience' => 0, /* Will automatically be configured according to level after creating this array*/ 'experience' => level_to_experience($create['level']),
'lookbody' => $cnf['lookBody'], /* STARTER OUTFITS */ 'lookbody' => $outfit['body'], /* STARTER OUTFITS */
'lookfeet' => $cnf['lookFeet'], 'lookfeet' => $outfit['feet'],
'lookhead' => $cnf['lookHead'], 'lookhead' => $outfit['head'],
'looklegs' => $cnf['lookLegs'], 'looklegs' => $outfit['legs'],
'looktype' => $outfit_type, 'looktype' => $outfit['id'],
'lookaddons' => 0, 'lookaddons' => 0,
'maglevel' => 0, 'maglevel' => $skills['magic'],
'mana' => $cnf['mana'], 'mana' => $mana,
'manamax' => $cnf['mana'], 'manamax' => $mana,
'manaspent' => 0, 'manaspent' => 0,
'soul' => $cnf['soul'], 'soul' => $base['soul'],
'town_id' => $character_data['town_id'], 'town_id' => $character_data['town_id'],
'posx' => $cnf['default_pos']['x'], 'posx' => $cnf['default_pos']['x'],
'posy' => $cnf['default_pos']['y'], 'posy' => $cnf['default_pos']['y'],
'posz' => $cnf['default_pos']['z'], 'posz' => $cnf['default_pos']['z'],
'conditions' => '', 'conditions' => '',
'cap' => $cnf['cap'], 'cap' => $cap,
'sex' => $character_data['sex'], 'sex' => $character_data['sex'],
'lastlogin' => 0, 'lastlogin' => 0,
'lastip' => $character_data['lastip'], 'lastip' => $character_data['lastip'],
'save' => 1, 'save' => 1,
'skull' => 0, 'skull' => 0,
'skulltime' => 0, 'skulltime' => 0,
@ -1188,8 +1198,8 @@ function user_create_character($character_data) {
'balance' => 0 'balance' => 0
); );
// TFS 1.0 rules // TFS 1.0 variations
if (Config('TFSVersion') === 'TFS_10') { if ($cnf['TFSVersion'] === 'TFS_10') {
unset($import_data['rank_id']); unset($import_data['rank_id']);
unset($import_data['guildnick']); unset($import_data['guildnick']);
unset($import_data['direction']); unset($import_data['direction']);
@ -1199,24 +1209,24 @@ function user_create_character($character_data) {
unset($import_data['loss_mana']); unset($import_data['loss_mana']);
unset($import_data['premend']); unset($import_data['premend']);
unset($import_data['online']); unset($import_data['online']);
// Skills can be added into the same query on TFS 1.0+
$import_data['skill_fist'] = $skills['fist'];
$import_data['skill_club'] = $skills['club'];
$import_data['skill_sword'] = $skills['sword'];
$import_data['skill_axe'] = $skills['axe'];
$import_data['skill_dist'] = $skills['dist'];
$import_data['skill_shielding'] = $skills['shield'];
$import_data['skill_fishing'] = $skills['fishing'];
} }
// Set correct experience for level
$import_data['experience'] = level_to_experience($import_data['level']);
// If you are no vocation (id 0), use these details instead: // If you are no vocation (id 0), use these details instead:
if ($character_data['vocation'] === '0') { if ($vocation === 0) {
$import_data['level'] = $cnf['nvlevel']; $import_data['level'] = $create['novocation']['level'];
$import_data['experience'] = level_to_experience($cnf['nvlevel']); $import_data['experience'] = level_to_experience($create['novocation']['level']);
$import_data['health'] = $cnf['nvHealth'];
$import_data['healthmax'] = $cnf['nvHealth'];
$import_data['cap'] = $cnf['nvCap'];
$import_data['mana'] = $cnf['nvMana'];
$import_data['manamax'] = $cnf['nvMana'];
$import_data['soul'] = $cnf['nvSoul'];
if ($cnf['nvForceTown'] == 1) { if ($create['novocation']['forceTown'] === true) {
$import_data['town_id'] = $cnf['nvTown']; $import_data['town_id'] = $create['novocation']['townId'];
} }
} }
@ -1225,13 +1235,24 @@ function user_create_character($character_data) {
$fields_sql = implode("`, `", $fields); // Convert array into SQL compatible string $fields_sql = implode("`, `", $fields); // Convert array into SQL compatible string
$data_sql = implode("', '", $data); // Convert array into SQL compatible string $data_sql = implode("', '", $data); // Convert array into SQL compatible string
echo 1;
mysql_insert("INSERT INTO `players`(`$fields_sql`) VALUES ('$data_sql');"); mysql_insert("INSERT INTO `players`(`$fields_sql`) VALUES ('$data_sql');");
$created = time(); $created = time();
$charid = user_character_id($import_data['name']); $charid = user_character_id($import_data['name']);
echo 2;
mysql_insert("INSERT INTO `znote_players`(`player_id`, `created`, `hide_char`, `comment`) VALUES ('$charid', '$created', '0', '');"); mysql_insert("INSERT INTO `znote_players`(`player_id`, `created`, `hide_char`, `comment`) VALUES ('$charid', '$created', '0', '');");
// Player skills TFS 0.2, 0.3/4. (TFS 1.0 is done above character creation)
if ($cnf['TFSVersion'] != 'TFS_10') {
// Not quite sure if players table have player_skills creation triggers, this may need to be inserts instead of update queries.
mysql_update("UPDATE `player_skills` SET `value`='". $skills['fist'] ."' WHERE `player_id`='{$charid}' AND `skillid`='0' LIMIT 1;");
mysql_update("UPDATE `player_skills` SET `value`='". $skills['club'] ."' WHERE `player_id`='{$charid}' AND `skillid`='1' LIMIT 1;");
mysql_update("UPDATE `player_skills` SET `value`='". $skills['sword'] ."' WHERE `player_id`='{$charid}' AND `skillid`='2' LIMIT 1;");
mysql_update("UPDATE `player_skills` SET `value`='". $skills['axe'] ."' WHERE `player_id`='{$charid}' AND `skillid`='3' LIMIT 1;");
mysql_update("UPDATE `player_skills` SET `value`='". $skills['dist'] ."' WHERE `player_id`='{$charid}' AND `skillid`='4' LIMIT 1;");
mysql_update("UPDATE `player_skills` SET `value`='". $skills['shield'] ."' WHERE `player_id`='{$charid}' AND `skillid`='5' LIMIT 1;");
mysql_update("UPDATE `player_skills` SET `value`='". $skills['fish'] ."' WHERE `player_id`='{$charid}' AND `skillid`='6' LIMIT 1;");
}
} }
// Returns counted value of all players online // Returns counted value of all players online