| 1 |
<?php |
| 2 |
/** |
| 3 |
* File functions: |
| 4 |
* Blacksmith - making items - weapons, armors, shields, helmets, plate legs, arrowsheads |
| 5 |
* |
| 6 |
* @name : kowal.php |
| 7 |
* @copyright : (C) 2004,2005,2006,2007 Vallheru Team based on Gamers-Fusion ver 2.5 |
| 8 |
* @author : thindil <thindil@users.sourceforge.net> |
| 9 |
* @author : eyescream <tduda@users.sourceforge.net> |
| 10 |
* @version : 1.4 |
| 11 |
* @since : 23.03.2007 |
| 12 |
* |
| 13 |
*/ |
| 14 |
|
| 15 |
// |
| 16 |
// |
| 17 |
// This program is free software; you can redistribute it and/or modify |
| 18 |
// it under the terms of the GNU General Public License as published by |
| 19 |
// the Free Software Foundation; either version 2 of the License, or |
| 20 |
// (at your option) any later version. |
| 21 |
// |
| 22 |
// This program is distributed in the hope that it will be useful, |
| 23 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 24 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 25 |
// GNU General Public License for more details. |
| 26 |
// |
| 27 |
// You should have received a copy of the GNU General Public License |
| 28 |
// along with this program; if not, write to the Free Software |
| 29 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 30 |
// |
| 31 |
// $Id$ |
| 32 |
|
| 33 |
$title='Kuźnia'; |
| 34 |
require_once('includes/head.php'); |
| 35 |
require_once('includes/checkexp.php'); |
| 36 |
require_once('includes/artisan.php'); |
| 37 |
|
| 38 |
/** |
| 39 |
* Get the localization for game |
| 40 |
*/ |
| 41 |
require_once('languages/'.$player -> lang.'/kowal.php'); |
| 42 |
|
| 43 |
if ($player -> location != 'Ardulith') |
| 44 |
{ |
| 45 |
error (ERROR); |
| 46 |
} |
| 47 |
if ($player -> hp <= 0) |
| 48 |
{ |
| 49 |
error (YOU_DEAD); |
| 50 |
} |
| 51 |
|
| 52 |
function special(&$intItemStat, $intItembonus, $fltPlayerStat, $intMax, $charAgility='') |
| 53 |
{ |
| 54 |
$intX = $intItembonus + $fltPlayerStat / 50; |
| 55 |
if($charAgility !='a') |
| 56 |
$intItemStat += $intX > $intMax ? $intMax : $intX; |
| 57 |
else |
| 58 |
$intItemStat -= $intX > $intMax ? $intMax : $intX; |
| 59 |
} |
| 60 |
|
| 61 |
/** |
| 62 |
* Function create items |
| 63 |
*/ |
| 64 |
function createitem() |
| 65 |
{ |
| 66 |
global $db; |
| 67 |
global $player; |
| 68 |
global $arrItem; |
| 69 |
global $intAbility; |
| 70 |
global $intItems; |
| 71 |
global $intGainexp; |
| 72 |
global $intChance; |
| 73 |
global $intCost; |
| 74 |
global $intExp; |
| 75 |
global $arrMaxbonus; |
| 76 |
global $intKey; |
| 77 |
global $intSmith; |
| 78 |
|
| 79 |
if (rand(1,100) <= $intChance) |
| 80 |
{ |
| 81 |
$strName = $arrItem['name']; |
| 82 |
$intPower = $arrItem['power']; |
| 83 |
$intAgi = $arrItem['zr']; |
| 84 |
$intDur = $arrItem['wt']; |
| 85 |
$blnSpecial = false; |
| 86 |
if (floor( rand(1,100) - $intAbility / 100) < 21) // special item! Smithy ('ability') skill increases the chance |
| 87 |
{ |
| 88 |
$intRoll3 = rand(1, 100); |
| 89 |
$intItembonus = rand(ceil($intSmith/2), ceil($intSmith)); |
| 90 |
if ($arrItem['type'] == 'A' || $arrItem['type'] == 'L') // Dragon armor and plate legs -only special for non artisans. |
| 91 |
{ |
| 92 |
if ($intRoll3 < 34) |
| 93 |
{ |
| 94 |
if ($arrItem['type'] == 'A') |
| 95 |
{ |
| 96 |
$strName = DRAGON2.$arrItem['name']; |
| 97 |
$intItembonus *= 2; |
| 98 |
} |
| 99 |
else |
| 100 |
{ |
| 101 |
$strName = DRAGON3.$arrItem['name']; |
| 102 |
} |
| 103 |
special($intPower, $intItembonus, $player -> strength, $arrMaxbonus[$intKey] * $arrItem['power']); |
| 104 |
if ($player -> clas == ARTISAN) |
| 105 |
{ |
| 106 |
$intPower += $player -> strength / 20; |
| 107 |
} |
| 108 |
} |
| 109 |
if ($player -> clas == ARTISAN) |
| 110 |
{ |
| 111 |
if (($intRoll3 > 34 && $intRoll3 < 68)) //Dwarven armor |
| 112 |
{ |
| 113 |
$strName = ($arrItem['type'] == 'A' ? DWARFS2 : DWARFS3).$arrItem['name']; |
| 114 |
special($intDur, $intItembonus, $player -> inteli, $arrItem['wt'] * 10); |
| 115 |
$intDur += $player -> inteli / 20; |
| 116 |
} |
| 117 |
if ($intRoll3 > 68) // Elven armor/plate legs. |
| 118 |
{ |
| 119 |
if ($arrItem['type'] == 'A') |
| 120 |
{ |
| 121 |
$strName = ELFS2.$arrItem['name']; |
| 122 |
} |
| 123 |
else |
| 124 |
{ |
| 125 |
$strName = ELFS3.$arrItem['name']; |
| 126 |
$intItembonus = ceil($intItembonus / 2); |
| 127 |
} |
| 128 |
special($intAgi, $intItembonus, $player -> agility, $arrMaxbonus[$intKey] * $arrItem['zr'], 'a'); |
| 129 |
$intAgi -= $player -> agility / 20; |
| 130 |
} |
| 131 |
if ($intRoll3 == 34) // 1% chance for special dragon (power+durability) |
| 132 |
{ |
| 133 |
if ($arrItem['type'] == 'A') |
| 134 |
{ |
| 135 |
$strName = DRAGON2.$arrItem['name']; |
| 136 |
$intItembonus *= 2; |
| 137 |
} |
| 138 |
else |
| 139 |
{ |
| 140 |
$strName = DRAGON3.$arrItem['name']; |
| 141 |
} |
| 142 |
special($intPower, $intItembonus, $player -> strength, $arrMaxbonus[$intKey] * $arrItem['power']); |
| 143 |
special($intDur, $intItembonus, $player -> inteli, $arrItem['wt'] * 10); |
| 144 |
$intDur += $player -> inteli / 20; |
| 145 |
$intPower += $player -> strength / 20; |
| 146 |
} |
| 147 |
if ($intRoll3 == 68) // 1% chance for elven + durability |
| 148 |
{ |
| 149 |
if ($arrItem['type'] == 'A') |
| 150 |
{ |
| 151 |
$strName = ELFS2.$arrItem['name']; |
| 152 |
special($intAgi, $intItembonus, $player -> agility, $arrMaxbonus[$intKey] * $arrItem['zr'], 'a'); |
| 153 |
} |
| 154 |
else |
| 155 |
{ |
| 156 |
$strName = ELFS3.$arrItem['name']; |
| 157 |
special($intAgi,ceil($intItembonus / 2), $player -> agility, $arrMaxbonus[$intKey] * $arrItem['zr'], 'a'); |
| 158 |
} |
| 159 |
special($intDur, $intItembonus, $player -> inteli, $arrItem['wt'] * 10); |
| 160 |
$intDur += $player -> inteli / 20; |
| 161 |
$intAgi -= $player -> agility / 20; |
| 162 |
} |
| 163 |
$blnSpecial = true; |
| 164 |
} |
| 165 |
} |
| 166 |
else // Weapons, helmets, shields |
| 167 |
{ |
| 168 |
if ($intRoll3 < 51) // dragon |
| 169 |
{ |
| 170 |
$strName = ($arrItem['type'] == 'W' || $arrItem['type'] == 'H' ? DRAGON1 : DRAGON2).$arrItem['name']; |
| 171 |
special($intPower, $intItembonus, $player -> strength, $arrMaxbonus[$intKey] * $arrItem['power']); |
| 172 |
if ($player -> clas == ARTISAN) |
| 173 |
{ |
| 174 |
$intPower += $player -> strength / 20; |
| 175 |
} |
| 176 |
$blnSpecial = true; |
| 177 |
} |
| 178 |
if( $player -> clas == ARTISAN && $intRoll3 > 50) |
| 179 |
{ |
| 180 |
if ($intRoll3 == 51) //dragon+durability |
| 181 |
{ |
| 182 |
$strName = ($arrItem['type'] == 'W' || $arrItem['type'] == 'H' ? DRAGON1 : DRAGON2).$arrItem['name']; |
| 183 |
special($intPower, $intItembonus, $player -> strength, $arrMaxbonus[$intKey] * $arrItem['power']); |
| 184 |
special($intDur, $intItembonus, $player -> inteli, $arrItem['wt'] * 10); |
| 185 |
$intDur += $player -> inteli / 20; |
| 186 |
$intPower += $player -> strength / 20; |
| 187 |
} |
| 188 |
else // dwarven |
| 189 |
{ |
| 190 |
$strName = ($arrItem['type'] == 'W' || $arrItem['type'] == 'H' ? DWARFS1 : DWARFS2).$arrItem['name']; |
| 191 |
special($intDur, $intItembonus, $player -> inteli, $arrItem['wt'] * 10); |
| 192 |
$intDur += $player -> inteli / 20; |
| 193 |
} |
| 194 |
$blnSpecial = true; |
| 195 |
} |
| 196 |
} |
| 197 |
} |
| 198 |
$intGainexp += $intExp * $arrItem['level'] * ($blnSpecial ? 100 + $intAbility / 10 : 1); |
| 199 |
$intItems ++; |
| 200 |
$intAbility = round($intAbility + $arrItem['level'] / 100,3); |
| 201 |
if ($arrItem['type'] == 'A') |
| 202 |
{ |
| 203 |
$intAbility = round($intAbility + $arrItem['level'] / 100,3); |
| 204 |
} |
| 205 |
$arrRepair = array(1, 4, 16, 64, 256); |
| 206 |
$intRepaircost = $arrItem['level'] * $arrRepair[$intKey]; |
| 207 |
if ($arrItem['type'] == 'W' || $arrItem['type'] == 'A') |
| 208 |
{ |
| 209 |
$intRepaircost *= 2; |
| 210 |
} |
| 211 |
|
| 212 |
$intPower = (int)$intPower; |
| 213 |
$intAgi = (int)$intAgi; |
| 214 |
$intDur = (int)$intDur; |
| 215 |
$intCost = (int)$intCost; |
| 216 |
$test = $db -> getRow('SELECT `id` FROM `equipment` WHERE `name`=\''.$strName.'\' AND `wt`='.$intDur.' AND `type`=\''.$arrItem['type'].'\' AND `status`=\'U\' AND `owner`='.$player -> id.' AND `power`='.$intPower.' AND `zr`='.$intAgi.' AND `szyb`='.$arrItem['szyb'].' AND `maxwt`='.$intDur.' AND `poison`=0 AND `cost`='.$intCost.' AND `minlev` = '.$arrItem['level']); |
| 217 |
if (empty($test)) |
| 218 |
{ |
| 219 |
$db -> Execute('INSERT INTO `equipment` (`owner`, `name`, `power`, `type`, `cost`, `zr`, `wt`, `minlev`, `maxwt`, `amount`, `magic`, `poison`, `szyb`, `twohand`, `repair`) VALUES('.$player -> id.', \''.$strName.'\', '.$intPower.', \''.$arrItem['type'].'\', '.$intCost.', '.$intAgi.', '.$intDur.', '.$arrItem['level'].', '.$intDur.', 1, \'N\', 0,'.$arrItem['szyb'].', \''.$arrItem['twohand'].'\', '.$intRepaircost.')'); |
| 220 |
} |
| 221 |
else |
| 222 |
{ |
| 223 |
$db -> Execute('UPDATE `equipment` SET `amount`=`amount`+1 WHERE `id`='.$test['id']); |
| 224 |
} |
| 225 |
unset($test); |
| 226 |
} |
| 227 |
else |
| 228 |
{ |
| 229 |
$intAbility += 0.005 * $arrItem['level']; |
| 230 |
if ($arrItem['type'] == 'A') |
| 231 |
{ |
| 232 |
$intAbility += 0.005 * $arrItem['level']; |
| 233 |
} |
| 234 |
|
| 235 |
} |
| 236 |
} |
| 237 |
|
| 238 |
/** |
| 239 |
* Buy plans of items |
| 240 |
*/ |
| 241 |
if (isset ($_GET['kowal']) && $_GET['kowal'] == 'plany') |
| 242 |
{ |
| 243 |
$smarty -> assign(array('Hereis' => HERE_IS, |
| 244 |
'Aplansw' => A_PLANS_W, |
| 245 |
'Aplansa' => A_PLANS_A, |
| 246 |
'Aplansh' => A_PLANS_H, |
| 247 |
'Aplansl' => A_PLANS_L, |
| 248 |
'Aplanss' => A_PLANS_S)); |
| 249 |
/** |
| 250 |
* Show avaiable plans |
| 251 |
*/ |
| 252 |
if (isset($_GET['dalej'])) |
| 253 |
{ |
| 254 |
$arrType = array('W', 'A', 'H', 'L', 'S'); |
| 255 |
if (!in_array($_GET['dalej'], $arrType)) |
| 256 |
{ |
| 257 |
error (ERROR); |
| 258 |
} |
| 259 |
showplans ('smith', 0, $player -> lang, $_GET['dalej']); |
| 260 |
} |
| 261 |
/** |
| 262 |
* Buy new plan |
| 263 |
*/ |
| 264 |
if (isset($_GET['buy'])) |
| 265 |
{ |
| 266 |
buyplan ('smith', $_GET['buy'], $player -> id, $player -> credits); |
| 267 |
} |
| 268 |
} |
| 269 |
|
| 270 |
/** |
| 271 |
* Making items |
| 272 |
*/ |
| 273 |
if (isset ($_GET['kowal']) && $_GET['kowal'] == 'kuznia') |
| 274 |
{ |
| 275 |
if (!isset($_GET['rob']) && !isset($_GET['konty'])) |
| 276 |
{ |
| 277 |
$smarty -> assign(array('Hereis' => SMITH_INFO, |
| 278 |
'Amakew' => A_MAKE_W, |
| 279 |
'Amakea' => A_MAKE_A, |
| 280 |
'Amakeh' => A_MAKE_H, |
| 281 |
'Amakel' => A_MAKE_L, |
| 282 |
'Amakes' => A_MAKE_S, |
| 283 |
'Amaker' => A_MAKE_R)); |
| 284 |
if (isset($_GET['type'])) |
| 285 |
{ |
| 286 |
$arrType = array('W', 'A', 'H', 'L', 'S'); |
| 287 |
if (!in_array($_GET['type'], $arrType)) |
| 288 |
{ |
| 289 |
error (ERROR); |
| 290 |
} |
| 291 |
showplans ('smith', $player -> id, $player -> lang, $_GET['type']); |
| 292 |
} |
| 293 |
showunfinished('smith_work', $player -> id); |
| 294 |
} |
| 295 |
else |
| 296 |
{ |
| 297 |
$arrEquip = $player -> equipment(); |
| 298 |
$arrRings = array(R_AGI, R_STR, R_INT); |
| 299 |
$arrStat = array('agility', 'strength', 'inteli'); |
| 300 |
if ($arrEquip[9][2]) |
| 301 |
{ |
| 302 |
$arrRingtype = explode(" ", $arrEquip[9][1]); |
| 303 |
$intAmount = count($arrRingtype) - 1; |
| 304 |
$intKey = array_search($arrRingtype[$intAmount], $arrRings); |
| 305 |
if ($intKey != NULL) |
| 306 |
{ |
| 307 |
$strStat = $arrStat[$intKey]; |
| 308 |
$player -> $strStat = $player -> $strStat + $arrEquip[9][2]; |
| 309 |
} |
| 310 |
} |
| 311 |
if ($arrEquip[10][2]) |
| 312 |
{ |
| 313 |
$arrRingtype = explode(" ", $arrEquip[10][1]); |
| 314 |
$intAmount = count($arrRingtype) - 1; |
| 315 |
$intKey = array_search($arrRingtype[$intAmount], $arrRings); |
| 316 |
if ($intKey != NULL) |
| 317 |
{ |
| 318 |
$strStat = $arrStat[$intKey]; |
| 319 |
$player -> $strStat = $player -> $strStat + $arrEquip[10][2]; |
| 320 |
} |
| 321 |
} |
| 322 |
} |
| 323 |
if (isset($_GET['ko'])) |
| 324 |
{ |
| 325 |
if ($player -> hp == 0) |
| 326 |
{ |
| 327 |
error (YOU_DEAD); |
| 328 |
} |
| 329 |
if (!ereg("^[1-9][0-9]*$", $_GET['ko'])) |
| 330 |
{ |
| 331 |
error (ERROR); |
| 332 |
} |
| 333 |
$objMaked = $db -> Execute('SELECT `name` FROM `smith_work` WHERE `id`='.$_GET['ko']); |
| 334 |
$smarty -> assign(array('Link' => 'kowal.php?kowal=kuznia&konty='.$_GET['ko'], |
| 335 |
'Name' => $objMaked -> fields['name'], |
| 336 |
'Assignen' => ASSIGN_EN, |
| 337 |
'Senergy' => S_ENERGY, |
| 338 |
'Amake' => A_MAKE)); |
| 339 |
$objMaked -> Close(); |
| 340 |
} |
| 341 |
if (isset($_GET['dalej'])) |
| 342 |
{ |
| 343 |
if ($player -> hp == 0) |
| 344 |
{ |
| 345 |
error (YOU_DEAD); |
| 346 |
} |
| 347 |
if (!ereg("^[1-9][0-9]*$", $_GET['dalej'])) |
| 348 |
{ |
| 349 |
error (ERROR); |
| 350 |
} |
| 351 |
$objSmith = $db -> Execute('SELECT `name` FROM `smith` WHERE `id`='.$_GET['dalej']); |
| 352 |
$smarty -> assign(array('Link' => 'kowal.php?kowal=kuznia&rob='.$_GET['dalej'], |
| 353 |
'Name' => $objSmith -> fields['name'], |
| 354 |
'Assignen' => ASSIGN_EN, |
| 355 |
'Senergy' => S_ENERGY, |
| 356 |
'Amake' => A_MAKE, |
| 357 |
'Mcopper' => M_COPPER, |
| 358 |
'Mbronze' => M_BRONZE, |
| 359 |
'Mbrass' => M_BRASS, |
| 360 |
'Miron' => M_IRON, |
| 361 |
'Msteel' => M_STEEL)); |
| 362 |
$objSmith -> Close(); |
| 363 |
} |
| 364 |
/** |
| 365 |
* Continue making items |
| 366 |
*/ |
| 367 |
if (isset($_GET['konty'])) |
| 368 |
{ |
| 369 |
if (!ereg("^[1-9][0-9]*$", $_GET['konty']) || !ereg("^[1-9][0-9]*$", $_POST['razy'])) |
| 370 |
{ |
| 371 |
error (ERROR); |
| 372 |
} |
| 373 |
$objWork = $db -> Execute('SELECT * FROM `smith_work` WHERE `id`='.$_GET['konty']); |
| 374 |
$objSmith = $db -> Execute('SELECT `name`, `type`, `cost`, `amount`, `level`, `twohand` FROM `smith` WHERE owner='.$player -> id.' AND name=\''.$objWork -> fields['name'].'\''); |
| 375 |
if ($player -> energy < $_POST['razy']) |
| 376 |
{ |
| 377 |
error (NO_ENERGY); |
| 378 |
} |
| 379 |
$intNeed = ($objWork -> fields['n_energy'] - $objWork -> fields['u_energy']); |
| 380 |
if ($_POST['razy'] > $intNeed) |
| 381 |
{ |
| 382 |
error (TOO_MUCH); |
| 383 |
} |
| 384 |
if ($objWork -> fields['owner'] != $player -> id) |
| 385 |
{ |
| 386 |
error (NO_ITEM); |
| 387 |
} |
| 388 |
|
| 389 |
/** |
| 390 |
* Add bonuses to ability |
| 391 |
*/ |
| 392 |
require_once('includes/abilitybonus.php'); |
| 393 |
$intSmith = abilitybonus('ability'); |
| 394 |
|
| 395 |
$intItems = 0; |
| 396 |
$intGainexp = 0; |
| 397 |
$intAbility = 0; |
| 398 |
$arrMineral = array('copper', 'bronze', 'brass', 'iron', 'steel'); |
| 399 |
$intKey = array_search($objWork -> fields['mineral'], $arrMineral); |
| 400 |
$arrMaxbonus = array(6, 10, 14, 17, 20); |
| 401 |
// Item cost: No of metal bars required to create one item * factor based on metal type. |
| 402 |
$intCost = $objSmith -> fields['amount'] * $arrMaxbonus[$intKey] * 3; |
| 403 |
$arrName = array(M_COPPER, M_BRONZE, M_BRASS, M_IRON, M_STEEL); |
| 404 |
if ($objSmith -> fields['type'] == 'W' || $objSmith -> fields['type'] == 'A') |
| 405 |
{ |
| 406 |
$arrDur = array(40, 80, 160, 320, 640); |
| 407 |
} |
| 408 |
else |
| 409 |
{ |
| 410 |
$arrDur = array(20, 40, 80, 160, 320); |
| 411 |
} |
| 412 |
$intPower = $objSmith -> fields['level']; |
| 413 |
if ($objSmith -> fields['type'] == 'A') |
| 414 |
{ |
| 415 |
$intPower *= 3; |
| 416 |
$intAgility = floor($objSmith -> fields['level'] / 2); |
| 417 |
$intExp = 2; |
| 418 |
} |
| 419 |
elseif ($objSmith -> fields['type'] == 'L') |
| 420 |
{ |
| 421 |
$intAgility = floor($objSmith -> fields['level'] / 5); |
| 422 |
$intExp = 1; |
| 423 |
} |
| 424 |
else |
| 425 |
{ |
| 426 |
$intAgility = 0; |
| 427 |
$intExp = 1; |
| 428 |
} |
| 429 |
$strName = $objSmith -> fields['name']." ".$arrName[$intKey]; |
| 430 |
$arrItem = array('power' => $intPower, |
| 431 |
'wt' => $arrDur[$intKey], |
| 432 |
'name' => $strName, |
| 433 |
'type' => $objSmith -> fields['type'], |
| 434 |
'level' => $objSmith -> fields['level'], |
| 435 |
'szyb' => 0, |
| 436 |
'zr' => $intAgility, |
| 437 |
'cost' => $intCost, |
| 438 |
'twohand' => $objSmith -> fields['twohand']); |
| 439 |
if ($player -> clas == ARTISAN) |
| 440 |
{ |
| 441 |
$intExp *= 2; |
| 442 |
} |
| 443 |
$intChance = (50 - $arrMaxbonus[$intKey]) * $intSmith / $objSmith -> fields['level']; |
| 444 |
if ($intChance > 95) |
| 445 |
{ |
| 446 |
$intChance = 95; |
| 447 |
} |
| 448 |
if ($_POST['razy'] == $intNeed) |
| 449 |
{ |
| 450 |
createitem(); |
| 451 |
if ($player -> clas == ARTISAN) |
| 452 |
{ |
| 453 |
$intAbility *= 2; |
| 454 |
} |
| 455 |
$intGainexp = ceil($intGainexp); |
| 456 |
$intAbility = round($intAbility*100, 0)/100; |
| 457 |
if ($intItems) |
| 458 |
{ |
| 459 |
$smarty -> assign ('Message', YOU_MAKE.$strName.AND_GAIN2.$intGainexp.AND_EXP2.$intAbility.IN_SMITH); |
| 460 |
} |
| 461 |
else |
| 462 |
{ |
| 463 |
$intGainexp = 0; |
| 464 |
$smarty -> assign ('Message', YOU_TRY.$strName.BUT_FAIL.$intAbility.IN_SMITH); |
| 465 |
} |
| 466 |
$db -> Execute('DELETE FROM `smith_work` WHERE `owner`='.$player -> id); |
| 467 |
checkexp($player -> exp, $intGainexp, $player -> level, $player -> race, $player -> user, $player -> id, 0, 0, $player -> id, 'ability', $intAbility); |
| 468 |
} |
| 469 |
else |
| 470 |
{ |
| 471 |
$uenergia = ($_POST['razy'] + $objWork -> fields['u_energy']); |
| 472 |
$intEnergy = $objSmith -> fields['level']; |
| 473 |
if ($objSmith -> fields['type'] == 'A') |
| 474 |
{ |
| 475 |
$intEnergy *= 2; |
| 476 |
} |
| 477 |
$procent = round(($uenergia / $intEnergy) * 100); |
| 478 |
$need = $objWork -> fields['n_energy'] - $uenergia; |
| 479 |
$db -> Execute('UPDATE `smith_work` SET `u_energy`=`u_energy`+'.$_POST['razy'].' WHERE `owner`='.$player -> id); |
| 480 |
$smarty -> assign ('Message', YOU_WORK.$strName.NEXT_EN.$_POST['razy'].NOW_IS.$procent.YOU_NEED2.$need.S_ENERGY); |
| 481 |
} |
| 482 |
$db -> Execute('UPDATE `players` SET `energy`=`energy`-'.$_POST['razy'].' WHERE `id`='.$player -> id); |
| 483 |
} |
| 484 |
/** |
| 485 |
* Start making items |
| 486 |
*/ |
| 487 |
if (isset($_GET['rob'])) |
| 488 |
{ |
| 489 |
if (!ereg("^[1-9][0-9]*$", $_GET['rob']) || !isset($_POST['mineral'])) |
| 490 |
{ |
| 491 |
error(ERROR); |
| 492 |
} |
| 493 |
if (!isset($_POST['razy'])) |
| 494 |
{ |
| 495 |
error(HOW_MANY); |
| 496 |
} |
| 497 |
if (!ereg("^[1-9][0-9]*$", $_POST['razy'])) |
| 498 |
{ |
| 499 |
error(ERROR); |
| 500 |
} |
| 501 |
$arrMineral = array('copper', 'bronze', 'brass', 'iron', 'steel'); |
| 502 |
if (!in_array($_POST['mineral'], $arrMineral)) |
| 503 |
{ |
| 504 |
error(ERROR); |
| 505 |
} |
| 506 |
$objTest = $db -> Execute('SELECT `id` FROM `smith_work` WHERE `owner`='.$player -> id); |
| 507 |
if ($objTest -> fields['id']) |
| 508 |
{ |
| 509 |
error(YOU_MAKE2); |
| 510 |
} |
| 511 |
$objTest -> Close(); |
| 512 |
$objSmith = $db -> Execute('SELECT `owner`, `name`, `type`, `cost`, `amount`, `level`, `twohand` FROM `smith` WHERE id='.$_GET['rob']); |
| 513 |
$objMineral = $db -> Execute('SELECT `'.$_POST['mineral'].'` FROM `minerals` WHERE `owner`='.$player -> id); |
| 514 |
$strMineral = $_POST['mineral']; |
| 515 |
$intAmount = floor($_POST['razy'] / $objSmith -> fields['level']); |
| 516 |
$intEnergy = $objSmith -> fields['level']; |
| 517 |
$intEnergy2 = $intAmount * $objSmith -> fields['level']; |
| 518 |
if ($objSmith -> fields['type'] == 'A') |
| 519 |
{ |
| 520 |
$intAmount = floor($intAmount/2); |
| 521 |
$intEnergy *= 2; |
| 522 |
} |
| 523 |
$intAmineral = $objSmith -> fields['amount'] * ($intAmount ? $intAmount : 1); |
| 524 |
if ($intAmineral > $objMineral -> fields[$strMineral]) |
| 525 |
{ |
| 526 |
error (NO_MAT); |
| 527 |
} |
| 528 |
if ($player -> energy < $_POST['razy']) |
| 529 |
{ |
| 530 |
error (NO_ENERGY); |
| 531 |
} |
| 532 |
if ($objSmith -> fields['owner'] != $player -> id) |
| 533 |
{ |
| 534 |
error (NO_PLANS); |
| 535 |
} |
| 536 |
|
| 537 |
/** |
| 538 |
* Add bonuses to ability |
| 539 |
*/ |
| 540 |
require_once('includes/abilitybonus.php'); |
| 541 |
$intSmith = abilitybonus('smith'); |
| 542 |
|
| 543 |
$intItems = 0; |
| 544 |
$intGainexp = 0; |
| 545 |
$intAbility = 0; |
| 546 |
$intKey = array_search($_POST['mineral'], $arrMineral); |
| 547 |
$arrMaxbonus = array(6, 10, 14, 17, 20); |
| 548 |
// Item cost: No of metal bars required to create one item * factor based on metal type. |
| 549 |
$intCost = $objSmith -> fields['amount'] * $arrMaxbonus[$intKey] * 3; |
| 550 |
$arrName = array(M_COPPER, M_BRONZE, M_BRASS, M_IRON, M_STEEL); |
| 551 |
if ($objSmith -> fields['type'] == 'W' || $objSmith -> fields['type'] == 'A') |
| 552 |
{ |
| 553 |
$arrDur = array(40, 80, 160, 320, 640); |
| 554 |
} |
| 555 |
else |
| 556 |
{ |
| 557 |
$arrDur = array(20, 40, 80, 160, 320); |
| 558 |
} |
| 559 |
$intPower = $objSmith -> fields['level']; |
| 560 |
if ($objSmith -> fields['type'] == 'A') |
| 561 |
{ |
| 562 |
$intPower *= 3; |
| 563 |
$intAgility = floor($objSmith -> fields['level'] / 2); |
| 564 |
$intExp = 2; |
| 565 |
} |
| 566 |
elseif ($objSmith -> fields['type'] == 'L') |
| 567 |
{ |
| 568 |
$intAgility = floor($objSmith -> fields['level'] / 5); |
| 569 |
$intExp = 1; |
| 570 |
} |
| 571 |
else |
| 572 |
{ |
| 573 |
$intAgility = 0; |
| 574 |
$intExp = 1; |
| 575 |
} |
| 576 |
$strName = $objSmith -> fields['name'].' '.$arrName[$intKey]; |
| 577 |
$arrItem = array('power' => $intPower, |
| 578 |
'wt' => $arrDur[$intKey], |
| 579 |
'name' => $strName, |
| 580 |
'type' => $objSmith -> fields['type'], |
| 581 |
'level' => $objSmith -> fields['level'], |
| 582 |
'szyb' => 0, |
| 583 |
'zr' => $intAgility, |
| 584 |
'cost' => $intCost, |
| 585 |
'twohand' => $objSmith -> fields['twohand']); |
| 586 |
if ($player -> clas == ARTISAN) |
| 587 |
{ |
| 588 |
$intExp *= 2; |
| 589 |
} |
| 590 |
$intChance = (50 - $arrMaxbonus[$intKey]) * $intSmith / $objSmith -> fields['level']; |
| 591 |
if ($intChance > 95) |
| 592 |
{ |
| 593 |
$intChance = 95; |
| 594 |
} |
| 595 |
if ($intAmount > 0) |
| 596 |
{ |
| 597 |
for ($i = 1; $i <= $intAmount; $i++) |
| 598 |
{ |
| 599 |
createitem(); |
| 600 |
} |
| 601 |
$intGainexp = ceil($intGainexp); |
| 602 |
if ($player -> clas == ARTISAN) |
| 603 |
{ |
| 604 |
$intAbility *= 2; |
| 605 |
} |
| 606 |
$intAbility = round($intAbility*100, 0)/100; |
| 607 |
$intAbility = $intAbility ? $intAbility : 0.01; |
| 608 |
$smarty -> assign ('Message', YOU_MAKE.$objSmith -> fields['name'].'</b> <b>'.$intItems.AND_GAIN2.$intGainexp.AND_EXP2.$intAbility.IN_SMITH); |
| 609 |
checkexp($player -> exp, $intGainexp, $player -> level, $player -> race, $player -> user, $player -> id, 0, 0, $player -> id, 'ability', $intAbility); |
| 610 |
} |
| 611 |
else |
| 612 |
{ |
| 613 |
$procent = round(($_POST['razy'] / $intEnergy) * 100); |
| 614 |
$need = ($intEnergy - $_POST['razy']); |
| 615 |
$intEnergy2 = $_POST['razy']; |
| 616 |
$db -> Execute('INSERT INTO `smith_work` (`owner`, `name`, `u_energy`, `n_energy`, `mineral`) VALUES('.$player -> id.', \''.$objSmith -> fields['name'].'\', '.$_POST['razy'].', '.$intEnergy.', \''.$_POST['mineral'].'\')'); |
| 617 |
$smarty -> assign ('Message', YOU_WORK.$objSmith -> fields['name'].YOU_USE.$_POST['razy'].AND_MAKE.$procent.TO_END.$need.S_ENERGY); |
| 618 |
} |
| 619 |
$db -> Execute('UPDATE `minerals` SET `'.$_POST['mineral'].'`=`'.$_POST['mineral'].'`-'.$intAmineral.' WHERE `owner`='.$player -> id); |
| 620 |
$db -> Execute('UPDATE `players` SET `energy`=`energy`-'.$intEnergy2.' WHERE `id`='.$player -> id); |
| 621 |
} |
| 622 |
} |
| 623 |
|
| 624 |
/** |
| 625 |
* Make astral constructions |
| 626 |
*/ |
| 627 |
if (isset($_GET['kowal']) && $_GET['kowal'] == 'astral') |
| 628 |
{ |
| 629 |
if( !isset($_GET['component'] )) |
| 630 |
{ |
| 631 |
makeastral1(); |
| 632 |
} |
| 633 |
else |
| 634 |
{ |
| 635 |
makeastral1('ability', $_GET['component']); |
| 636 |
} |
| 637 |
} |
| 638 |
|
| 639 |
/** |
| 640 |
* Initialization of variables |
| 641 |
*/ |
| 642 |
if (!isset($_GET['kowal'])) |
| 643 |
{ |
| 644 |
$_GET['kowal'] = ''; |
| 645 |
$smarty -> assign(array('Smithinfo' => SMITH_INFO, |
| 646 |
'Aplans' => A_PLANS, |
| 647 |
'Asmith' => A_SMITH, |
| 648 |
'Aastral' => A_ASTRAL)); |
| 649 |
} |
| 650 |
else |
| 651 |
{ |
| 652 |
$smarty -> assign('Aback', A_BACK); |
| 653 |
} |
| 654 |
if (!isset($_GET['dalej'])) |
| 655 |
{ |
| 656 |
$_GET['dalej'] = ''; |
| 657 |
} |
| 658 |
if (!isset($_GET['buy'])) |
| 659 |
{ |
| 660 |
$_GET['buy'] = ''; |
| 661 |
} |
| 662 |
if (!isset($_GET['rob'])) |
| 663 |
{ |
| 664 |
$_GET['rob'] = ''; |
| 665 |
} |
| 666 |
if (!isset($_GET['konty'])) |
| 667 |
{ |
| 668 |
$_GET['konty'] = ''; |
| 669 |
} |
| 670 |
if (!isset($_GET['type'])) |
| 671 |
{ |
| 672 |
$_GET['type'] = ''; |
| 673 |
} |
| 674 |
if (!isset($_GET['ko'])) |
| 675 |
{ |
| 676 |
$_GET['ko'] = ''; |
| 677 |
} |
| 678 |
|
| 679 |
/** |
| 680 |
* Assign variables to template and display page |
| 681 |
*/ |
| 682 |
$smarty -> assign(array('Smith' => $_GET['kowal'], |
| 683 |
'Next' => $_GET['dalej'], |
| 684 |
'Buy' => $_GET['buy'], |
| 685 |
'Make' => $_GET['rob'], |
| 686 |
'Continue' => $_GET['konty'], |
| 687 |
'Type' => $_GET['type'], |
| 688 |
'Cont' => $_GET['ko'])); |
| 689 |
$smarty -> display ('kowal.tpl'); |
| 690 |
|
| 691 |
require_once('includes/foot.php'); |
| 692 |
?> |