Defines/SpellTrigger

* convert magic numbers to define and use as spell trigger types
This commit is contained in:
Sarjuuk
2023-06-08 12:37:53 +02:00
parent da8943095b
commit 6382302a30
6 changed files with 36 additions and 28 deletions

View File

@@ -832,6 +832,14 @@ define('ITEM_MOD_SHADOW_POWER', 60);
define('ITEM_MOD_NATURE_POWER', 61);
define('ITEM_MOD_ARCANE_POWER', 62);
// item trigger and recipe handling
define('SPELL_TRIGGER_USE', 0);
define('SPELL_TRIGGER_EQUIP', 1);
define('SPELL_TRIGGER_HIT', 2);
define('SPELL_TRIGGER_SOULSTONE', 4);
define('SPELL_TRIGGER_USE_NODELAY', 5);
define('SPELL_TRIGGER_LEARN', 6);
// learn trigger spells on items - 483: learn recipe; 55884: learn mount/pet
define('LEARN_SPELLS', [483, 55884]);

View File

@@ -964,7 +964,7 @@ class ItemList extends BaseType
else // build block with generic time
$extra[] = Lang::item('cooldown', 0, [Lang::formatTime($cd, 'game', 'timeAbbrev', true)]);
}
if ($this->curTpl['spellTrigger'.$j] == 2)
if ($this->curTpl['spellTrigger'.$j] == SPELL_TRIGGER_HIT)
if ($ppm = $this->curTpl['spellppmRate'.$j])
$extra[] = Lang::spell('ppm', [$ppm]);
@@ -2434,11 +2434,11 @@ class ItemListFilter extends Filter
return [
'OR',
['AND', ['spellTrigger1', 0], ['spellId1', 0, '!'], ['spellCooldown1', 0, '>'], ['spellCooldown1', $cr[2], $cr[1]]],
['AND', ['spellTrigger2', 0], ['spellId2', 0, '!'], ['spellCooldown2', 0, '>'], ['spellCooldown2', $cr[2], $cr[1]]],
['AND', ['spellTrigger3', 0], ['spellId3', 0, '!'], ['spellCooldown3', 0, '>'], ['spellCooldown3', $cr[2], $cr[1]]],
['AND', ['spellTrigger4', 0], ['spellId4', 0, '!'], ['spellCooldown4', 0, '>'], ['spellCooldown4', $cr[2], $cr[1]]],
['AND', ['spellTrigger5', 0], ['spellId5', 0, '!'], ['spellCooldown5', 0, '>'], ['spellCooldown5', $cr[2], $cr[1]]],
['AND', ['spellTrigger1', SPELL_TRIGGER_USE], ['spellId1', 0, '!'], ['spellCooldown1', 0, '>'], ['spellCooldown1', $cr[2], $cr[1]]],
['AND', ['spellTrigger2', SPELL_TRIGGER_USE], ['spellId2', 0, '!'], ['spellCooldown2', 0, '>'], ['spellCooldown2', $cr[2], $cr[1]]],
['AND', ['spellTrigger3', SPELL_TRIGGER_USE], ['spellId3', 0, '!'], ['spellCooldown3', 0, '>'], ['spellCooldown3', $cr[2], $cr[1]]],
['AND', ['spellTrigger4', SPELL_TRIGGER_USE], ['spellId4', 0, '!'], ['spellCooldown4', 0, '>'], ['spellCooldown4', $cr[2], $cr[1]]],
['AND', ['spellTrigger5', SPELL_TRIGGER_USE], ['spellId5', 0, '!'], ['spellCooldown5', 0, '>'], ['spellCooldown5', $cr[2], $cr[1]]],
];
}

View File

@@ -218,12 +218,12 @@ class EnchantmentPage extends GenericPage
$spellIds = $spellList->getFoundIDs();
$conditions = array(
'OR', // [use, useUndelayed]
['AND', ['spellTrigger1', [0, 5]], ['spellId1', $spellIds]],
['AND', ['spellTrigger2', [0, 5]], ['spellId2', $spellIds]],
['AND', ['spellTrigger3', [0, 5]], ['spellId3', $spellIds]],
['AND', ['spellTrigger4', [0, 5]], ['spellId4', $spellIds]],
['AND', ['spellTrigger5', [0, 5]], ['spellId5', $spellIds]]
'OR',
['AND', ['spellTrigger1', [SPELL_TRIGGER_USE, SPELL_TRIGGER_USE_NODELAY]], ['spellId1', $spellIds]],
['AND', ['spellTrigger2', [SPELL_TRIGGER_USE, SPELL_TRIGGER_USE_NODELAY]], ['spellId2', $spellIds]],
['AND', ['spellTrigger3', [SPELL_TRIGGER_USE, SPELL_TRIGGER_USE_NODELAY]], ['spellId3', $spellIds]],
['AND', ['spellTrigger4', [SPELL_TRIGGER_USE, SPELL_TRIGGER_USE_NODELAY]], ['spellId4', $spellIds]],
['AND', ['spellTrigger5', [SPELL_TRIGGER_USE, SPELL_TRIGGER_USE_NODELAY]], ['spellId5', $spellIds]]
);
$ubItems = new ItemList($conditions);

View File

@@ -168,7 +168,7 @@ class ItemPage extends genericPage
$hasUse = false;
for ($i = 1; $i < 6; $i++)
{
if ($this->subject->getField('spellId'.$i) <= 0 || in_array($this->subject->getField('spellTrigger'.$i), [1, 2]))
if ($this->subject->getField('spellId'.$i) <= 0 || in_array($this->subject->getField('spellTrigger'.$i), [SPELL_TRIGGER_EQUIP, SPELL_TRIGGER_HIT]))
continue;
$hasUse = true;
@@ -880,9 +880,9 @@ class ItemPage extends genericPage
$ids = $indirect = [];
for ($i = 1; $i < 6; $i++)
{
if ($this->subject->getField('spellTrigger'.$i) == 6)
if ($this->subject->getField('spellTrigger'.$i) == SPELL_TRIGGER_LEARN)
$ids[] = $this->subject->getField('spellId'.$i);
else if ($this->subject->getField('spellTrigger'.$i) == 0 && $this->subject->getField('spellId'.$i) > 0)
else if ($this->subject->getField('spellTrigger'.$i) == SPELL_TRIGGER_USE && $this->subject->getField('spellId'.$i) > 0)
$indirect[] = $this->subject->getField('spellId'.$i);
}

View File

@@ -588,12 +588,12 @@ class SpellPage extends GenericPage
// tab: used by - item
$conditions = array(
'OR', // 6: learn spell
['AND', ['spellTrigger1', 6, '!'], ['spellId1', $this->subject->id]],
['AND', ['spellTrigger2', 6, '!'], ['spellId2', $this->subject->id]],
['AND', ['spellTrigger3', 6, '!'], ['spellId3', $this->subject->id]],
['AND', ['spellTrigger4', 6, '!'], ['spellId4', $this->subject->id]],
['AND', ['spellTrigger5', 6, '!'], ['spellId5', $this->subject->id]]
'OR',
['AND', ['spellTrigger1', SPELL_TRIGGER_LEARN, '!'], ['spellId1', $this->subject->id]],
['AND', ['spellTrigger2', SPELL_TRIGGER_LEARN, '!'], ['spellId2', $this->subject->id]],
['AND', ['spellTrigger3', SPELL_TRIGGER_LEARN, '!'], ['spellId3', $this->subject->id]],
['AND', ['spellTrigger4', SPELL_TRIGGER_LEARN, '!'], ['spellId4', $this->subject->id]],
['AND', ['spellTrigger5', SPELL_TRIGGER_LEARN, '!'], ['spellId5', $this->subject->id]]
);
$ubItems = new ItemList($conditions);
@@ -1132,11 +1132,11 @@ class SpellPage extends GenericPage
// tab: taught by item (i'd like to precheck $this->subject->sources, but there is no source:item only complicated crap like "drop" and "vendor")
$conditions = array(
'OR',
['AND', ['spellTrigger1', 6], ['spellId1', $this->subject->id]],
['AND', ['spellTrigger2', 6], ['spellId2', $this->subject->id]],
['AND', ['spellTrigger3', 6], ['spellId3', $this->subject->id]],
['AND', ['spellTrigger4', 6], ['spellId4', $this->subject->id]],
['AND', ['spellTrigger5', 6], ['spellId5', $this->subject->id]],
['AND', ['spellTrigger1', SPELL_TRIGGER_LEARN], ['spellId1', $this->subject->id]],
['AND', ['spellTrigger2', SPELL_TRIGGER_LEARN], ['spellId2', $this->subject->id]],
['AND', ['spellTrigger3', SPELL_TRIGGER_LEARN], ['spellId3', $this->subject->id]],
['AND', ['spellTrigger4', SPELL_TRIGGER_LEARN], ['spellId4', $this->subject->id]],
['AND', ['spellTrigger5', SPELL_TRIGGER_LEARN], ['spellId5', $this->subject->id]],
);
$tbItem = new ItemList($conditions);

View File

@@ -62,8 +62,8 @@ class ItemStatSetup extends ItemList
continue;
// armor & weapons only onEquip && consumables only onUse
if (!(in_array($this->curTpl['class'], [ITEM_CLASS_WEAPON, ITEM_CLASS_ARMOR]) && $this->curTpl['spellTrigger'.$h] == 1) &&
!( $this->curTpl['class'] == ITEM_CLASS_CONSUMABLE && $this->curTpl['spellTrigger'.$h] == 0))
if (!(in_array($this->curTpl['class'], [ITEM_CLASS_WEAPON, ITEM_CLASS_ARMOR]) && $this->curTpl['spellTrigger'.$h] == SPELL_TRIGGER_EQUIP) &&
!( $this->curTpl['class'] == ITEM_CLASS_CONSUMABLE && $this->curTpl['spellTrigger'.$h] == SPELL_TRIGGER_USE))
continue;
$equipSpells[] = $this->curTpl['spellId'.$h];