| 1 |
<?php |
| 2 |
/** |
| 3 |
* File functions: |
| 4 |
* Lumbermill - making arrows and bows |
| 5 |
* |
| 6 |
* @name : lumbermill.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='Tartak'; |
| 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.'/lumbermill.php'); |
| 42 |
|
| 43 |
if ($player -> location != 'Altara') |
| 44 |
{ |
| 45 |
error (ERROR); |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Function to create items |
| 50 |
*/ |
| 51 |
function createitem() |
| 52 |
{ |
| 53 |
global $db; |
| 54 |
global $player; |
| 55 |
global $arrItem; |
| 56 |
global $intAbility; |
| 57 |
global $intItems; |
| 58 |
global $intGainexp; |
| 59 |
global $intChance; |
| 60 |
global $intCost; |
| 61 |
global $arrMaxbonus; |
| 62 |
global $intKey; |
| 63 |
|
| 64 |
if (rand(1,100) <= $intChance) |
| 65 |
{ |
| 66 |
$strName = $arrItem['name']; |
| 67 |
$intPower = $arrItem['power']; |
| 68 |
$intSpeed = $arrItem['szyb']; |
| 69 |
$intDur = $arrItem['wt']; |
| 70 |
$blnSpecial = false; |
| 71 |
if (floor( rand(1,100) - $intAbility / 100) < 21) // special item! Fletcher skill increases the chance |
| 72 |
{ |
| 73 |
$intRoll3 = rand(1, 101); |
| 74 |
$intItembonus = rand(ceil($player -> fletcher/2), ceil($player -> fletcher)); // includes bonuses (pure fletchery, gnome, artisan, bless + now gained fletchery)! |
| 75 |
if ($intRoll3 < 34 && $arrItem['type'] == 'R') // dragon arrows, the only special item for non-artisans |
| 76 |
{ |
| 77 |
$intPowerbonus = $intItembonus + $player -> strength / 50; |
| 78 |
$intPower += $intPowerbonus > $arrItem['level'] * 10 ? $arrItem['level'] * 10 : $intPowerbonus; |
| 79 |
if ($player -> clas == ARTISAN) |
| 80 |
$intPower += $player -> strength / 20; |
| 81 |
$strName = DRAGON2.$arrItem['name']; |
| 82 |
$blnSpecial = true; |
| 83 |
} |
| 84 |
if( $player -> clas == ARTISAN && $intRoll3 > 33) |
| 85 |
{ |
| 86 |
if ($intRoll3 < 67 && $arrItem['type'] == 'B') |
| 87 |
{ // elven bows |
| 88 |
$intAgibonus = $intItembonus + ($player -> agility / 50); |
| 89 |
$intSpeed += $intAgibonus > $arrItem['szyb'] * 10 ? $arrItem['szyb'] * 10 : $intAgibonus; |
| 90 |
$intSpeed += $player -> agility / 20; |
| 91 |
$strName = ELFS1.$arrItem['name']; |
| 92 |
$blnSpecial = true; |
| 93 |
} |
| 94 |
if ($intRoll3 > 66) |
| 95 |
{ |
| 96 |
if ($arrItem['type'] == 'B') // dwarven bow |
| 97 |
{ |
| 98 |
$intDurbonus = $intItembonus + ($player -> inteli / 50); |
| 99 |
$strName = DWARFS1.$arrItem['name']; |
| 100 |
$intDurbonus = $intDurbonus > $arrItem['wt'] * 10 ? $arrItem['wt'] * 10 : $intDurbonus; |
| 101 |
$intDurbonus += $player -> inteli / 20; |
| 102 |
} |
| 103 |
else |
| 104 |
{ |
| 105 |
$intDurbonus = min( rand(1, ceil($player -> fletcher / 10)), 100); // more arrows than usual |
| 106 |
} |
| 107 |
$intDur += $intDurbonus; |
| 108 |
$blnSpecial = true; |
| 109 |
} |
| 110 |
} |
| 111 |
} |
| 112 |
$intPower = round($intPower); |
| 113 |
$intSpeed = round($intSpeed); |
| 114 |
$intDur = round($intDur); |
| 115 |
$intGainexp += $arrItem['level'] * ($blnSpecial ? 100 + $player -> fletcher / 10 : 1); |
| 116 |
$intItems ++; |
| 117 |
$intAbility = round($intAbility + $arrItem['level'] / 100,3); |
| 118 |
if ($arrItem['type'] == 'B') |
| 119 |
{ |
| 120 |
$arrRepair = array(2, 8, 32, 128, 512); |
| 121 |
$intRepaircost = $arrItem['level'] * $arrRepair[$intKey]; |
| 122 |
$test = $db -> Execute('SELECT `id` FROM `equipment` WHERE `owner`='.$player -> id.' AND `name`=\''.$strName.'\' AND `wt`='.$intDur.' AND `type`=\'B\' AND `status`=\'U\' AND `power`='.$intPower.' AND `zr`=0 AND `szyb`='.$intSpeed.' AND `maxwt`='.$intDur.' AND `poison`=0 AND `cost`='.$intCost); |
| 123 |
if (!$test -> fields['id']) |
| 124 |
{ |
| 125 |
$db -> Execute('INSERT INTO `equipment` (`owner`, `name`, `power`, `type`, `cost`, `wt`, `minlev`, `maxwt`, `amount`, `magic`, `szyb`, `twohand`, `repair`) VALUES('.$player -> id.', \''.$strName.'\', '.$intPower.', \'B\', '.$intCost.', '.$intDur.', '.$arrItem['level'].', '.$intDur.', 1, \'N\', '.$intSpeed.',\'Y\', '.$intRepaircost.')'); |
| 126 |
} |
| 127 |
else |
| 128 |
{ |
| 129 |
$db -> Execute('UPDATE `equipment` SET `amount`=`amount`+1 WHERE `id`='.$test -> fields['id']); |
| 130 |
} |
| 131 |
$test -> Close(); |
| 132 |
} |
| 133 |
else |
| 134 |
{ |
| 135 |
$test = $db -> Execute('SELECT `id` FROM `equipment` WHERE `owner`='.$player -> id.' AND name=\''.$strName.'\' AND `power`='.$intPower.' AND `status`=\'U\' AND `cost`='.$intCost); |
| 136 |
if (!$test -> fields['id']) |
| 137 |
{ |
| 138 |
$db -> Execute('INSERT INTO `equipment` (`owner`, `name`, `power`, `type`, `cost`, `status`, `minlev`, `wt`) VALUES('.$player -> id.', \''.$strName.'\', '.$intPower.', \'R\', '.$intCost.', \'U\', '.$arrItem['level'].', '.$intDur.')'); |
| 139 |
} |
| 140 |
else |
| 141 |
{ |
| 142 |
$db -> Execute('UPDATE `equipment` SET `wt`=`wt`+'.$intDur.' WHERE `id`='.$test -> fields['id']); |
| 143 |
} |
| 144 |
$test -> Close(); |
| 145 |
} |
| 146 |
} |
| 147 |
else |
| 148 |
{ |
| 149 |
$intAbility += 0.005 * $arrItem['level']; |
| 150 |
} |
| 151 |
} |
| 152 |
|
| 153 |
/** |
| 154 |
* Lumberjack licenses |
| 155 |
*/ |
| 156 |
if (isset($_GET['mill']) && $_GET['mill'] == 'licenses') |
| 157 |
{ |
| 158 |
$oldFetchMode = $db -> SetFetchMode(ADODB_FETCH_NUM); |
| 159 |
$arrLevel = $db -> GetRow('SELECT `level` FROM `lumberjack` WHERE owner='.$player -> id); |
| 160 |
$db -> SetFetchMode($oldFetchMode); |
| 161 |
$intLevel = empty($arrLevel) ? 0 : ++$arrLevel[0]; |
| 162 |
if ($intLevel > 3) |
| 163 |
{ |
| 164 |
error(NO_LICENSES); |
| 165 |
} |
| 166 |
if (!isset($_GET['step']) || $_GET['step'] != 'buy') |
| 167 |
{ |
| 168 |
$_GET['step'] = ''; |
| 169 |
$arrLicenses = array(LICENSE1, LICENSE2, LICENSE3, LICENSE4); |
| 170 |
$smarty -> assign('Alicense', $arrLicenses[$intLevel]); |
| 171 |
} |
| 172 |
else |
| 173 |
/** |
| 174 |
* Buy licenses |
| 175 |
*/ |
| 176 |
{ |
| 177 |
$arrGold = array(1000, 2000, 10000, 50000); |
| 178 |
$arrMithril = array(0, 10, 50, 250); |
| 179 |
if ($player -> credits < $arrGold[$intLevel]) |
| 180 |
{ |
| 181 |
error(NO_MONEY); |
| 182 |
} |
| 183 |
if ($player -> platinum < $arrMithril[$intLevel]) |
| 184 |
{ |
| 185 |
error(NO_MITH); |
| 186 |
} |
| 187 |
$db -> Execute( !$intLevel ? 'INSERT INTO `lumberjack` (`owner`, `level`) VALUES('.$player -> id.', 0)' : 'UPDATE `lumberjack` SET `level`=`level`+1 WHERE `owner`='.$player -> id); |
| 188 |
$db -> Execute('UPDATE `players` SET `credits`=`credits`-'.$arrGold[$intLevel].', `platinum`=`platinum`-'.$arrMithril[$intLevel].' WHERE `id`='.$player -> id); |
| 189 |
$arrLicenses = array(LICENSE1, LICENSE2, LICENSE3, LICENSE4); |
| 190 |
$smarty -> assign('Message', YOU_BUY.$arrLicenses[$intLevel]); |
| 191 |
} |
| 192 |
$smarty -> assign('Step', $_GET['step']); |
| 193 |
} |
| 194 |
|
| 195 |
/** |
| 196 |
* Buy plans of items |
| 197 |
*/ |
| 198 |
if (isset ($_GET['mill']) && $_GET['mill'] == 'plany') |
| 199 |
{ |
| 200 |
if (!isset($_GET['buy'])) |
| 201 |
{ |
| 202 |
showplans ('mill', 0, $player -> lang); |
| 203 |
} |
| 204 |
else |
| 205 |
{ |
| 206 |
buyplan ('mill', $_GET['buy'], $player -> id, $player -> credits); |
| 207 |
} |
| 208 |
} |
| 209 |
|
| 210 |
/** |
| 211 |
* Make items |
| 212 |
*/ |
| 213 |
if (isset ($_GET['mill']) && $_GET['mill'] == 'mill') |
| 214 |
{ |
| 215 |
if (!isset($_GET['rob']) && !isset($_GET['konty'])) |
| 216 |
{ |
| 217 |
showplans ('mill', $player -> id, $player -> lang); |
| 218 |
showunfinished('mill_work', $player -> id); |
| 219 |
} |
| 220 |
else |
| 221 |
{ |
| 222 |
$arrEquip = $player -> equipment(); |
| 223 |
$arrRings = array(R_AGI, R_STR, R_INT); |
| 224 |
$arrStat = array('agility', 'strength', 'inteli'); |
| 225 |
if ($arrEquip[9][2]) |
| 226 |
{ |
| 227 |
$arrRingtype = explode(" ", $arrEquip[9][1]); |
| 228 |
$intAmount = count($arrRingtype) - 1; |
| 229 |
$intKey = array_search($arrRingtype[$intAmount], $arrRings); |
| 230 |
if ($intKey != NULL) |
| 231 |
{ |
| 232 |
$strStat = $arrStat[$intKey]; |
| 233 |
$player -> $strStat = $player -> $strStat + $arrEquip[9][2]; |
| 234 |
} |
| 235 |
} |
| 236 |
if ($arrEquip[10][2]) |
| 237 |
{ |
| 238 |
$arrRingtype = explode(" ", $arrEquip[10][1]); |
| 239 |
$intAmount = count($arrRingtype) - 1; |
| 240 |
$intKey = array_search($arrRingtype[$intAmount], $arrRings); |
| 241 |
if ($intKey != NULL) |
| 242 |
{ |
| 243 |
$strStat = $arrStat[$intKey]; |
| 244 |
$player -> $strStat = $player -> $strStat + $arrEquip[10][2]; |
| 245 |
} |
| 246 |
} |
| 247 |
} |
| 248 |
if (isset($_GET['ko']) || isset($_GET['dalej'])) |
| 249 |
{ |
| 250 |
if ($player -> hp == 0) |
| 251 |
{ |
| 252 |
error (YOU_DEAD); |
| 253 |
} |
| 254 |
$intItemId = isset($_GET['ko']) ? $_GET['ko'] : $_GET['dalej']; |
| 255 |
if (!ereg("^[1-9][0-9]*$", $intItemId)) |
| 256 |
{ |
| 257 |
error (ERROR); |
| 258 |
} |
| 259 |
integercheck($intItemId); |
| 260 |
} |
| 261 |
if (isset($_GET['ko'])) |
| 262 |
{ |
| 263 |
$objMaked = $db -> Execute('SELECT `name` FROM `mill_work` WHERE `id`='.$_GET['ko']); |
| 264 |
$smarty -> assign(array('Id' => $_GET['ko'], |
| 265 |
'Name' => $objMaked -> fields['name'], |
| 266 |
'Assignen' => ASSIGN_EN, |
| 267 |
'Menergy' => M_ENERGY, |
| 268 |
'Amake' => A_MAKE)); |
| 269 |
$objMaked -> Close(); |
| 270 |
} |
| 271 |
if (isset($_GET['dalej'])) |
| 272 |
{ |
| 273 |
$objLumber = $db -> Execute("SELECT name, type FROM mill WHERE id=".$_GET['dalej']); |
| 274 |
$smarty -> assign(array('Id' => $_GET['dalej'], |
| 275 |
'Name' => $objLumber -> fields['name'], |
| 276 |
'Type' => $objLumber -> fields['type'], |
| 277 |
'Lhazel' => L_HAZEL, |
| 278 |
'Lyew' => L_YEW, |
| 279 |
'Lelm' => L_ELM, |
| 280 |
'Lharder' => L_HARDER, |
| 281 |
'Lcomposite' => L_COMPOSITE, |
| 282 |
'Assignen' => ASSIGN_EN, |
| 283 |
'Menergy' => M_ENERGY, |
| 284 |
'Selectarr' => SELECT_ARR, |
| 285 |
'Amake' => A_MAKE)); |
| 286 |
$objLumber -> Close(); |
| 287 |
} |
| 288 |
/** |
| 289 |
* Continue making items |
| 290 |
*/ |
| 291 |
if (isset($_GET['konty'])) |
| 292 |
{ |
| 293 |
if (!ereg("^[1-9][0-9]*$", $_GET['konty'])) |
| 294 |
{ |
| 295 |
error (ERROR); |
| 296 |
} |
| 297 |
$objWork = $db -> Execute('SELECT * FROM `mill_work` WHERE `id`='.$_GET['konty']); |
| 298 |
$objLumber = $db -> Execute('SELECT `name`, `type`, `cost`, `amount`, `level`, `twohand` FROM `mill` WHERE owner='.$player -> id.' AND name=\''.$objWork -> fields['name'].'\''); |
| 299 |
if (!ereg("^[1-9][0-9]*$", $_POST['razy'])) |
| 300 |
{ |
| 301 |
error(ERROR); |
| 302 |
} |
| 303 |
if ($player -> energy < $_POST['razy']) |
| 304 |
{ |
| 305 |
error(NO_ENERGY); |
| 306 |
} |
| 307 |
$need = ($objWork -> fields['n_energy'] - $objWork -> fields['u_energy']); |
| 308 |
// Cut too big energy usage. |
| 309 |
if ($_POST['razy'] > $need) |
| 310 |
{ |
| 311 |
$_POST['razy'] = $need; |
| 312 |
} |
| 313 |
if ($objWork -> fields['owner'] != $player -> id) |
| 314 |
{ |
| 315 |
error (NO_ITEM); |
| 316 |
} |
| 317 |
|
| 318 |
/** |
| 319 |
* Add bonuses to ability |
| 320 |
*/ |
| 321 |
require_once('includes/abilitybonus.php'); |
| 322 |
$player -> fletcher = abilitybonus('fletcher'); |
| 323 |
|
| 324 |
/** |
| 325 |
* Count item attributes |
| 326 |
*/ |
| 327 |
if ($objLumber -> fields['type'] == 'B') |
| 328 |
{ |
| 329 |
$intPower = 0; |
| 330 |
$arrMineral = array('H', 'Y', 'E', 'A', 'C'); |
| 331 |
$intKey = array_search($objWork -> fields['mineral'], $arrMineral); |
| 332 |
$arrMaxdur = array(40, 80, 160, 320, 640); |
| 333 |
$intMaxdur = $arrMaxdur[$intKey]; |
| 334 |
$arrBowname = array(L_HAZEL, L_YEW, L_ELM, L_HARDER, L_COMPOSITE); |
| 335 |
$strName = $objLumber -> fields['name'].' '.$arrBowname[$intKey]; |
| 336 |
$arrMaxbonus = array(6, 10, 14, 17, 20); |
| 337 |
$intModif = $arrMaxbonus[$intKey]; |
| 338 |
$intSpeed = $objLumber -> fields['level'] * $intModif; |
| 339 |
} |
| 340 |
else |
| 341 |
{ |
| 342 |
$intPower = $objLumber -> fields['level']; |
| 343 |
$intSpeed = 0; |
| 344 |
$intMaxdur = 100; |
| 345 |
$strName = $objLumber -> fields['name']; |
| 346 |
$intModif = 0; |
| 347 |
} |
| 348 |
$intCost = ($objLumber -> fields['type'] == 'B') ? $objLumber -> fields['amount'] * $intModif * 3 : $objLumber -> fields['level'] * 5; |
| 349 |
$arrItem = array('power' => $intPower, |
| 350 |
'wt' => $intMaxdur, |
| 351 |
'name' => $strName, |
| 352 |
'type' => $objLumber -> fields['type'], |
| 353 |
'level' => $objLumber -> fields['level'], |
| 354 |
'szyb' => $intSpeed, |
| 355 |
'zr' => 0, |
| 356 |
'cost' => $intCost, |
| 357 |
'twohand' => $objLumber -> fields['twohand']); |
| 358 |
$intItems = 0; |
| 359 |
$intGainexp = 0; |
| 360 |
$intAbility = 0; |
| 361 |
$intChance = (50 - $intModif) * $player -> fletcher / $objLumber -> fields['level']; |
| 362 |
if ($intChance > 95) |
| 363 |
{ |
| 364 |
$intChance = 95; |
| 365 |
} |
| 366 |
if ($_POST['razy'] == $need) |
| 367 |
{ |
| 368 |
createitem(); |
| 369 |
if ($intItems) |
| 370 |
{ |
| 371 |
if ($player -> clas == ARTISAN) |
| 372 |
{ |
| 373 |
$intGainexp *= 2; |
| 374 |
$intAbility *= 2; |
| 375 |
} |
| 376 |
$intGainexp = ceil($intGainexp); |
| 377 |
$smarty -> assign ('Message', YOU_MAKE.$arrItem['name'].AND_GAIN2.$intGainexp.AND_EXP2.$intAbility.IN_MILL); |
| 378 |
} |
| 379 |
else |
| 380 |
{ |
| 381 |
$intAbility = round($intAbility*100, 0)/100; |
| 382 |
$intGainexp = 0; |
| 383 |
$smarty -> assign ('Message', YOU_TRY.$arrItem['name'].BUT_FAIL.$intAbility.IN_MILL); |
| 384 |
} |
| 385 |
$db -> Execute('DELETE FROM `mill_work` WHERE `owner`='.$player -> id); |
| 386 |
checkexp($player -> exp, $intGainexp, $player -> level, $player -> race, $player -> user, $player -> id, 0, 0, $player -> id, 'fletcher', $intAbility); |
| 387 |
} |
| 388 |
else |
| 389 |
{ |
| 390 |
$uenergia = $_POST['razy'] + $objWork -> fields['u_energy']; |
| 391 |
$procent = round(($uenergia / $objWork -> fields['n_energy']) * 100); |
| 392 |
$need = $objWork -> fields['n_energy'] - $uenergia; |
| 393 |
$smarty -> assign ('Message', YOU_WORK.$arrItem['name'].NEXT_EN.$_POST['razy'].NOW_IS.$procent.YOU_NEED2.$need.M_ENERGY); |
| 394 |
$db -> Execute('UPDATE `mill_work` SET `u_energy`=`u_energy`+'.$_POST['razy'].' WHERE owner='.$player -> id); |
| 395 |
} |
| 396 |
$db -> Execute('UPDATE `players` SET `energy`=`energy`-'.$_POST['razy'].' WHERE `id`='.$player -> id); |
| 397 |
} |
| 398 |
/** |
| 399 |
* Start making items |
| 400 |
*/ |
| 401 |
if (isset($_GET['rob'])) |
| 402 |
{ |
| 403 |
if (!ereg("^[1-9][0-9]*$", $_GET['rob'])) |
| 404 |
{ |
| 405 |
error(ERROR); |
| 406 |
} |
| 407 |
if (!isset($_POST['razy'])) |
| 408 |
{ |
| 409 |
error(HOW_MANY); |
| 410 |
} |
| 411 |
if (!ereg("^[1-9][0-9]*$", $_POST['razy'])) |
| 412 |
{ |
| 413 |
error(ERROR); |
| 414 |
} |
| 415 |
$objTest = $db -> Execute('SELECT `id` FROM `mill_work` WHERE `owner`='.$player -> id); |
| 416 |
if ($objTest -> fields['id']) |
| 417 |
{ |
| 418 |
error(YOU_MAKE2); |
| 419 |
} |
| 420 |
$objTest -> Close(); |
| 421 |
$objLumber = $db -> Execute('SELECT * FROM `mill` WHERE `id`='.$_GET['rob']); |
| 422 |
if ($objLumber -> fields['type'] == 'B') |
| 423 |
{ |
| 424 |
$arrMineral = array('H', 'Y', 'E', 'A', 'C'); |
| 425 |
if (!in_array($_POST['lumber'], $arrMineral)) |
| 426 |
{ |
| 427 |
error(ERROR); |
| 428 |
} |
| 429 |
} |
| 430 |
// Cut used energy to acceptable maximum. |
| 431 |
if ($_POST['razy'] > $player -> energy) |
| 432 |
{ |
| 433 |
$_POST['razy'] = $player -> energy; |
| 434 |
} |
| 435 |
// Cut energy to multiplication of item's level, so exceeding energy won't be lost. |
| 436 |
if ($_POST['razy'] % $objLumber -> fields['level'] != 0) |
| 437 |
{ |
| 438 |
$_POST['razy'] = $objLumber -> fields['level'] * (int)($_POST['razy'] / $objLumber -> fields['level']); |
| 439 |
} |
| 440 |
if ($player -> energy < $objLumber -> fields['level']) |
| 441 |
{ |
| 442 |
error(NO_ENERGY); |
| 443 |
} |
| 444 |
if ($objLumber -> fields['owner'] != $player -> id) |
| 445 |
{ |
| 446 |
error(NO_PLANS); |
| 447 |
} |
| 448 |
$intAmount = floor($_POST['razy'] / $objLumber -> fields['level']); |
| 449 |
$intNeedmineral = $intAmount * $objLumber -> fields['amount']; |
| 450 |
if ($objLumber -> fields['type'] == 'R') |
| 451 |
{ |
| 452 |
$arrNeedmineral = array('pine'); |
| 453 |
} |
| 454 |
else |
| 455 |
{ |
| 456 |
$intKey = array_search($_POST['lumber'], $arrMineral); |
| 457 |
if ($intKey < 3) |
| 458 |
{ |
| 459 |
$arrMinerals = array('hazel', 'yew', 'elm'); |
| 460 |
$arrNeedmineral = array($arrMinerals[$intKey]); |
| 461 |
} |
| 462 |
elseif ($intKey == 3) |
| 463 |
{ |
| 464 |
$arrNeedmineral = array('hazel', 'elm'); |
| 465 |
} |
| 466 |
elseif ($intKey == 4) |
| 467 |
{ |
| 468 |
$arrNeedmineral = array('pine', 'hazel', 'yew', 'elm'); |
| 469 |
} |
| 470 |
} |
| 471 |
foreach ($arrNeedmineral as $strNeedmineral) |
| 472 |
{ |
| 473 |
$objMineral = $db -> Execute('SELECT '.$strNeedmineral.' FROM `minerals` WHERE `owner`='.$player -> id); |
| 474 |
if ($objMineral -> fields[$strNeedmineral] < $intNeedmineral) |
| 475 |
{ |
| 476 |
error(NO_MAT); |
| 477 |
} |
| 478 |
$objMineral -> Close(); |
| 479 |
} |
| 480 |
/** |
| 481 |
* Add bonuses to ability |
| 482 |
*/ |
| 483 |
require_once('includes/abilitybonus.php'); |
| 484 |
$player -> fletcher = abilitybonus('fletcher'); |
| 485 |
|
| 486 |
/** |
| 487 |
* Count item attributes |
| 488 |
*/ |
| 489 |
if ($objLumber -> fields['type'] == 'B') |
| 490 |
{ |
| 491 |
$intPower = 0; |
| 492 |
$intSpeed = $objLumber -> fields['level']; |
| 493 |
$arrMaxdur = array(40, 80, 160, 320, 640); |
| 494 |
$intMaxdur = $arrMaxdur[$intKey]; |
| 495 |
$arrBowname = array(L_HAZEL, L_YEW, L_ELM, L_HARDER, L_COMPOSITE); |
| 496 |
$strName = $objLumber -> fields['name']." ".$arrBowname[$intKey]; |
| 497 |
$arrMaxbonus = array(6, 10, 14, 17, 20); |
| 498 |
$intModif = $arrMaxbonus[$intKey]; |
| 499 |
// Item cost: No of metal bars required to create one item * factor based on wood type. |
| 500 |
$intCost = $objLumber -> fields['amount'] * $intModif * 3; |
| 501 |
} |
| 502 |
else |
| 503 |
{ |
| 504 |
$intPower = $objLumber -> fields['level']; |
| 505 |
$intSpeed = 0; |
| 506 |
$intMaxdur = 100; |
| 507 |
$strName = $objLumber -> fields['name']; |
| 508 |
$intCost = $objLumber -> fields['level'] * 5; |
| 509 |
$intModif = 0; |
| 510 |
} |
| 511 |
$arrItem = array('power' => $intPower, |
| 512 |
'wt' => $intMaxdur, |
| 513 |
'name' => $strName, |
| 514 |
'type' => $objLumber -> fields['type'], |
| 515 |
'level' => $objLumber -> fields['level'], |
| 516 |
'szyb' => $intSpeed, |
| 517 |
'zr' => 0, |
| 518 |
'cost' => $intCost, |
| 519 |
'twohand' => $objLumber -> fields['twohand']); |
| 520 |
$intItems = 0; |
| 521 |
$intGainexp = 0; |
| 522 |
$intAbility = 0; |
| 523 |
$intChance = (50 - $intModif) * $player -> fletcher / $objLumber -> fields['level']; |
| 524 |
if ($intChance > 95) |
| 525 |
{ |
| 526 |
$intChance = 95; |
| 527 |
} |
| 528 |
if ($intAmount > 0) |
| 529 |
{ |
| 530 |
for ($i = 1; $i <= $intAmount; $i++) |
| 531 |
{ |
| 532 |
createitem(); |
| 533 |
} |
| 534 |
if ($player -> clas == ARTISAN) |
| 535 |
{ |
| 536 |
$intGainexp = $intGainexp * 2; |
| 537 |
$intAbility = $intAbility * 2; |
| 538 |
} |
| 539 |
|
| 540 |
$intAbility = round($intAbility*100, 0)/100; |
| 541 |
$intAbility = $intAbility ? $intAbility : 0.01; |
| 542 |
$intGainexp = ceil($intGainexp); |
| 543 |
$smarty -> assign ('Message', YOU_MAKE.$arrItem['name'].'</b> <b>'.$intItems.AND_GAIN2.$intGainexp.AND_EXP2.$intAbility.IN_MILL); |
| 544 |
checkexp($player -> exp, $intGainexp, $player -> level, $player -> race, $player -> user, $player -> id, 0, 0, $player -> id,'fletcher',$intAbility); |
| 545 |
} |
| 546 |
else |
| 547 |
{ |
| 548 |
$procent = round(($_POST['razy'] / $arrItem['level']) * 100); |
| 549 |
$need = ($objLumber -> fields['level'] - $_POST['razy']); |
| 550 |
$smarty -> assign ('Message', YOU_WORK.$arrItem['name'].YOU_USE.$_POST['razy'].AND_MAKE.$procent.TO_END.$need.M_ENERGY); |
| 551 |
if ($objLumber -> fields['type'] == 'R') |
| 552 |
{ |
| 553 |
$db -> Execute('INSERT INTO `mill_work` (`owner`, `name`, `u_energy`, `n_energy`) VALUES('.$player -> id.', \''.$objLumber -> fields['name'].'\', '.$_POST['razy'].', '.$arrItem['level'].')'); |
| 554 |
} |
| 555 |
else |
| 556 |
{ |
| 557 |
$db -> Execute('INSERT INTO `mill_work` (`owner`, `name`, `u_energy`, `n_energy`, `mineral`) VALUES('.$player -> id.', \''.$objLumber -> fields['name'].'\', '.$_POST['razy'].', '.$arrItem['level'].', \''.$_POST['lumber'].'\')'); |
| 558 |
} |
| 559 |
} |
| 560 |
foreach ($arrNeedmineral as $strNeedmineral) |
| 561 |
{ |
| 562 |
$objMineral = $db -> Execute('UPDATE `minerals` SET '.$strNeedmineral.'='.$strNeedmineral.'-'.$intNeedmineral.' WHERE `owner`='.$player -> id); |
| 563 |
} |
| 564 |
$db -> Execute('UPDATE `players` SET `energy`=`energy`-'.$_POST['razy'].' WHERE `id`='.$player -> id); |
| 565 |
} |
| 566 |
} |
| 567 |
|
| 568 |
/** |
| 569 |
* Make astral constructions |
| 570 |
*/ |
| 571 |
if (isset($_GET['mill']) && $_GET['mill'] == 'astral') |
| 572 |
{ |
| 573 |
if( !isset($_GET['component'] )) |
| 574 |
{ |
| 575 |
makeastral1(); |
| 576 |
} |
| 577 |
else |
| 578 |
{ |
| 579 |
makeastral1('fletcher', $_GET['component']); |
| 580 |
} |
| 581 |
} |
| 582 |
|
| 583 |
/** |
| 584 |
* Initialization of variables |
| 585 |
*/ |
| 586 |
if (!isset($_GET['mill'])) |
| 587 |
{ |
| 588 |
$_GET['mill'] = ''; |
| 589 |
$smarty -> assign(array('Millinfo' => MILL_INFO, |
| 590 |
'Aplans' => A_PLANS, |
| 591 |
'Amill' => A_MILL, |
| 592 |
'Alicenses' => A_LICENSES, |
| 593 |
'Aastral' => A_ASTRAL)); |
| 594 |
} |
| 595 |
|
| 596 |
if (!isset($_GET['buy'])) |
| 597 |
{ |
| 598 |
$_GET['buy'] = ''; |
| 599 |
} |
| 600 |
if (!isset($_GET['rob'])) |
| 601 |
{ |
| 602 |
$_GET['rob'] = ''; |
| 603 |
} |
| 604 |
if (!isset($_GET['konty'])) |
| 605 |
{ |
| 606 |
$_GET['konty'] = ''; |
| 607 |
} |
| 608 |
if (!isset($_GET['ko'])) |
| 609 |
{ |
| 610 |
$_GET['ko'] = ''; |
| 611 |
} |
| 612 |
if (!isset($_GET['dalej'])) |
| 613 |
{ |
| 614 |
$_GET['dalej'] = ''; |
| 615 |
} |
| 616 |
|
| 617 |
/** |
| 618 |
* Assign variables to template and display page |
| 619 |
*/ |
| 620 |
$smarty -> assign(array('Mill' => $_GET['mill'], |
| 621 |
'Buy' => $_GET['buy'], |
| 622 |
'Make' => $_GET['rob'], |
| 623 |
'Continue' => $_GET['konty'], |
| 624 |
'Cont' => $_GET['ko'], |
| 625 |
'Next' => $_GET['dalej'], |
| 626 |
'Aback' => A_BACK)); |
| 627 |
$smarty -> display ('lumbermill.tpl'); |
| 628 |
|
| 629 |
require_once('includes/foot.php'); |
| 630 |
?> |