mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Items/RandEnchants
* fix amount calculation for scaling enchantments * cache RandomPropPoints lookups
This commit is contained in:
@@ -18,6 +18,7 @@ class ItemList extends DBTypeList
|
|||||||
public array $rndEnchIds = [];
|
public array $rndEnchIds = [];
|
||||||
public array $subItems = [];
|
public array $subItems = [];
|
||||||
|
|
||||||
|
private array $randPropPoints = [];
|
||||||
private array $ssd = [];
|
private array $ssd = [];
|
||||||
private array $vendors = [];
|
private array $vendors = [];
|
||||||
private array $jsGlobals = []; // getExtendedCost creates some and has no access to template
|
private array $jsGlobals = []; // getExtendedCost creates some and has no access to template
|
||||||
@@ -1228,76 +1229,55 @@ class ItemList extends DBTypeList
|
|||||||
}
|
}
|
||||||
|
|
||||||
// from Trinity
|
// from Trinity
|
||||||
public function generateEnchSuffixFactor() : int
|
public function generateEnchSuffixFactor() : float
|
||||||
{
|
{
|
||||||
$rpp = DB::Aowow()->selectRow('SELECT * FROM ?_itemrandomproppoints WHERE `id` = ?', $this->curTpl['itemLevel']);
|
if (empty($this->randPropPoints[$this->curTpl['itemLevel']]))
|
||||||
if (!$rpp)
|
$this->randPropPoints[$this->curTpl['itemLevel']] = DB::Aowow()->selectRow('SELECT * FROM ?_itemrandomproppoints WHERE `id` = ?', $this->curTpl['itemLevel']);
|
||||||
return 0;
|
|
||||||
|
|
||||||
switch ($this->curTpl['slot'])
|
$rpp = &$this->randPropPoints[$this->curTpl['itemLevel']];
|
||||||
|
|
||||||
|
if (!$rpp)
|
||||||
|
return 0.0;
|
||||||
|
|
||||||
|
$fieldIdx = match((int)$this->curTpl['slot'])
|
||||||
{
|
{
|
||||||
// Items of that type don`t have points
|
INVTYPE_HEAD,
|
||||||
case INVTYPE_NON_EQUIP:
|
INVTYPE_BODY,
|
||||||
case INVTYPE_BAG:
|
INVTYPE_CHEST,
|
||||||
case INVTYPE_TABARD:
|
INVTYPE_LEGS,
|
||||||
case INVTYPE_AMMO:
|
INVTYPE_2HWEAPON,
|
||||||
case INVTYPE_QUIVER:
|
INVTYPE_ROBE => 1,
|
||||||
case INVTYPE_RELIC:
|
INVTYPE_SHOULDERS,
|
||||||
return 0;
|
INVTYPE_WAIST,
|
||||||
// Select point coefficient
|
INVTYPE_FEET,
|
||||||
case INVTYPE_HEAD:
|
INVTYPE_HANDS,
|
||||||
case INVTYPE_BODY:
|
INVTYPE_TRINKET => 2,
|
||||||
case INVTYPE_CHEST:
|
INVTYPE_NECK,
|
||||||
case INVTYPE_LEGS:
|
INVTYPE_WRISTS,
|
||||||
case INVTYPE_2HWEAPON:
|
INVTYPE_FINGER,
|
||||||
case INVTYPE_ROBE:
|
INVTYPE_SHIELD,
|
||||||
$suffixFactor = 1;
|
INVTYPE_CLOAK,
|
||||||
break;
|
INVTYPE_HOLDABLE => 3,
|
||||||
case INVTYPE_SHOULDERS:
|
INVTYPE_WEAPON,
|
||||||
case INVTYPE_WAIST:
|
INVTYPE_WEAPONMAINHAND,
|
||||||
case INVTYPE_FEET:
|
INVTYPE_WEAPONOFFHAND => 4,
|
||||||
case INVTYPE_HANDS:
|
INVTYPE_RANGED,
|
||||||
case INVTYPE_TRINKET:
|
INVTYPE_THROWN,
|
||||||
$suffixFactor = 2;
|
INVTYPE_RANGEDRIGHT => 5,
|
||||||
break;
|
default => 0 // inv types that don`t have points
|
||||||
case INVTYPE_NECK:
|
};
|
||||||
case INVTYPE_WRISTS:
|
|
||||||
case INVTYPE_FINGER:
|
if (!$fieldIdx)
|
||||||
case INVTYPE_SHIELD:
|
return 0.0;
|
||||||
case INVTYPE_CLOAK:
|
|
||||||
case INVTYPE_HOLDABLE:
|
|
||||||
$suffixFactor = 3;
|
|
||||||
break;
|
|
||||||
case INVTYPE_WEAPON:
|
|
||||||
case INVTYPE_WEAPONMAINHAND:
|
|
||||||
case INVTYPE_WEAPONOFFHAND:
|
|
||||||
$suffixFactor = 4;
|
|
||||||
break;
|
|
||||||
case INVTYPE_RANGED:
|
|
||||||
case INVTYPE_THROWN:
|
|
||||||
case INVTYPE_RANGEDRIGHT:
|
|
||||||
$suffixFactor = 5;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Select rare/epic modifier
|
// Select rare/epic modifier
|
||||||
switch ($this->curTpl['quality'])
|
return match((int)$this->curTpl['quality'])
|
||||||
{
|
{
|
||||||
case ITEM_QUALITY_UNCOMMON:
|
ITEM_QUALITY_UNCOMMON => $rpp['uncommon'.$fieldIdx] / 10000,
|
||||||
return $rpp['uncommon'.$suffixFactor] / 10000;
|
ITEM_QUALITY_RARE => $rpp['rare'.$fieldIdx] / 10000,
|
||||||
case ITEM_QUALITY_RARE:
|
ITEM_QUALITY_EPIC => $rpp['epic'.$fieldIdx] / 10000,
|
||||||
return $rpp['rare'.$suffixFactor] / 10000;
|
default => 0.0 // qualities that don't have random properties
|
||||||
case ITEM_QUALITY_EPIC:
|
};
|
||||||
return $rpp['epic'.$suffixFactor] / 10000;
|
|
||||||
case ITEM_QUALITY_LEGENDARY:
|
|
||||||
case ITEM_QUALITY_ARTIFACT:
|
|
||||||
return 0; // not have random properties
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function extendJsonStats() : void
|
public function extendJsonStats() : void
|
||||||
|
|||||||
Reference in New Issue
Block a user